feat: add AsterDEX to defi referral program#40563
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (1 files, +22 -0)
👨🔧 @MetaMask/core-extension-ux (1 files, +1 -0)
👨🔧 @MetaMask/extension-platform (1 files, +1 -0)
🕵️ @MetaMask/extension-privacy-reviewers (1 files, +1 -0)
🧪 @MetaMask/qa (2 files, +2 -0)
👨🔧 @MetaMask/wallet-integrations (1 files, +115 -37)
|
Builds ready [0aec688]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [9b4db1d]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Builds ready [7e9f4a1]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
@ameliejyc |
|
Builds ready [ed72866]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| * - permissions: show referral when permissions succeed (e.g. wallet_requestPermissions). | ||
| * - permissions_then_signature: show referral after permissions and signature succeed. | ||
| */ | ||
| export type ConnectionFlow = 'permissions' | 'permissions_then_signature'; |



Description
Adds AsterDEX to the DeFi referral program with a two-step connection flow: the referral is shown only after both (1)
wallet_requestPermissionssucceed and (2) a successfuleth_signTypedData_v4for the same origin/tab. Other partners (Hyperliquid, GMX) keep the existing single-step behavior (trigger on permissions only).shared/constants/defi-referrals.ts): IntroducesConnectionFlow('permissions'|'permissions_then_signature') andconnectionFlowon partner config; adds AsterDEX withconnectionFlow: 'permissions_then_signature'.app/scripts/lib/createDefiReferralMiddleware.ts): For two-step partners, records a permissions grant in apendingSignatureMap(keyed byorigin:tabId) and triggers the referral only when a matchingeth_signTypedData_v4succeeds within 10 seconds; map entries are pruned by a timer and the interval is cleared when empty. This means that users have 10 seconds on AsterDEX to approve the signature request before the map entry gets pruned. The idea is that this prevents users inadvertently seeing the referral approval screen if they sign anyeth_signTypedData_v4requests that haven't occurred directly after the connection permissions step. The referral screen should only show after the 2-step connection flow.Changelog
CHANGELOG entry: Added AsterDEX to the DeFi referral program
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/CEUX-745
Manual testing steps
Screenshots/Recordings
Before
After
asterdex.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Medium risk: changes referral-triggering middleware logic by adding stateful, time-windowed tracking across JSON-RPC calls, which could affect when/if referral prompts appear for partner origins.
Overview
Adds AsterDEX as a new DeFi referral partner, including new locale copy and wiring it into default
referralsstate, e2e fixtures, and Storybook consent stories.Extends partner config with a
connectionFlow(permissionsvspermissions_then_signature) and updatescreateDefiReferralMiddlewareto support a two-step trigger: for two-step partners it records a successful permissions grant and only fires the referral after a matchingeth_signTypedData_v4succeeds within a short window.Updates
_updateDefiReferralUrlto merge existing tab query params into the partner’s referral URL (preserving both existing and referral parameters) instead of appending the current search string verbatim.Written by Cursor Bugbot for commit ed72866. This will update automatically on new commits. Configure here.