Skip to content

Delegation Chain Enforcer - Referral System #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

hanzel98
Copy link
Contributor

@hanzel98 hanzel98 commented May 2, 2025

What?

  • Enables a referral system where people can get prizes for referring new users.
  • This system depends on an off-chain system for certain validations like KYC, repeated addresses, and correct usage of enforcers in the delegations.

How?

  • The system creates a delegation that allows a redeemer to call an enforcer function post(address[] referrals), this method stores an array of addresses that will be paid in the afterHook of the enforcer. The delegators (referrers) validate their position in the array when calling the function post in the beforeHook of the enforcer. The afterHook validates that the post function has stored the addresses in the state and it pays these addresses using an allowance delegation passed in the args by the redeemer.

Intermediary Chain Account Responsibilities - Offchain Part

  • Get a delegation from the Root Delegator, DelegationChainEnforcer's Owner.
  • Redelegate to the users to extend the chain.
  • Validate that a referral address is only once in the chain.
  • Validate that the delegation from the User=>ICA includes the DelegationChainEnforcer, once and only once, and the correct position in the terms.
  • Validate the KYC and off-chain steps.
  • Prepare for redemption when requested. Create the post(address[]) execution, and make sure it doesn't have duplicate addresses.
    • Make sure someone can't add himself twice in the same delegation chain.
    • Make sure the intermediary chain is involved on every level otherwise fails.
  • Get the erc20 allowance delegations for paying the prizes. According to the position of each address.
  • Submit as a redeemer the execution to the post(address[]) using the referral delegation chain, attaching in the args the erc20 allowance delegations for paying the prizes.

Intermediary Chain Account Responsibilities - Onchain Part

  • Make sure that the same array of referrals doesn't get paid twice. The array of addresses is hashed and marked as paid.
  • Pay the referrals the prize amount according to their position, no matter the array length it always pays the last 5 for example.
  • Allow each delegator to enforce their position in the array of referrals, so no one can submit an incorrect array.
  • Redeem the allowance delegations passed in the args in the afterHook to pay the prizes. Protects the allowance delegation with the delegation hash+redeemer.
  • Make sure the referrals get their correct amount of ERC20 tokens, in the afterHook as a prize, otherwise revert.

@hanzel98 hanzel98 requested a review from a team as a code owner May 2, 2025 02:04
@hanzel98 hanzel98 self-assigned this May 2, 2025
@hanzel98 hanzel98 marked this pull request as draft May 2, 2025 02:04
@hanzel98 hanzel98 changed the title feat: delegation chain enforcer and test Delegation Chain Enforcer - Referral System May 13, 2025
@hanzel98 hanzel98 marked this pull request as ready for review May 19, 2025 16:49
@hanzel98 hanzel98 requested a review from McOso May 20, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant