Skip to content
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

feat: implement Affiliates protocol interactions #1074

Merged
merged 15 commits into from
Oct 3, 2024
Merged

Conversation

rosepuppy
Copy link
Contributor

@rosepuppy rosepuppy commented Sep 27, 2024

Implement Affiliate read and writes to the validator.

When a user lands on a referral link, we store the referral address to redux-persist via the affiliates slice. As soon a the user has a balance, we will call registerAffiliate to register the affiliate, and then remove the affiliate from localstorage.

  • most of the logic is in useSubaccount for detecting the user wallet balance and affiliate address in localstorage to send the registerAffiliate transaction.

  • update src/hooks/useAffiliatesInfo.ts to fetch for affiliate info from both the indexer and the protocol, check for eligibility by determining volumeEligibility and isWhitelisted

  • Add getAffiliateInfo and getReferredBy calls to useDydxClient

  • create useReferredBy hook for getting the referredBy address

  • added a dev only account menu item for testing RegisterAffiliate.

Copy link

vercel bot commented Sep 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
v4-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2024 4:56pm
v4-testnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2024 4:56pm

@rosepuppy rosepuppy changed the title Affiliates protocol feat: Affiliates protocol Sep 27, 2024
@rosepuppy rosepuppy changed the title feat: Affiliates protocol feat: implement Affiliates protocol interactions Oct 2, 2024
Copy link
Contributor

@yogurtandjam yogurtandjam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks sane!

though i'm wondering if it's worth making a slice for affiliates. don't know if there's challenges to this, but i feel like all the affiliates functionality could be in a single high level hook that depends on useSubaccount etc.

src/hooks/useReferralAddress.ts Outdated Show resolved Hide resolved
src/hooks/useSubaccount.tsx Outdated Show resolved Hide resolved
@rosepuppy
Copy link
Contributor Author

though i'm wondering if it's worth making a slice for affiliates. don't know if there's challenges to this, but i feel like all the affiliates functionality could be in a single high level hook that depends on useSubaccount etc.

The slice is basically to leverage redux-persist, since we are deprecating our localstorage hooks.

src/hooks/useReferralAddress.ts Outdated Show resolved Hide resolved
src/hooks/useReferredBy.ts Outdated Show resolved Hide resolved
src/hooks/useSubaccount.tsx Show resolved Hide resolved
src/views/dialogs/ReferralDialog.tsx Outdated Show resolved Hide resolved
src/hooks/useSubaccount.tsx Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants