Skip to content

feat: add AsterDEX to defi referral program#40563

Merged
ameliejyc merged 6 commits intomainfrom
add-asterdex-to-referral-program
Mar 4, 2026
Merged

feat: add AsterDEX to defi referral program#40563
ameliejyc merged 6 commits intomainfrom
add-asterdex-to-referral-program

Conversation

@ameliejyc
Copy link
Copy Markdown
Contributor

@ameliejyc ameliejyc commented Mar 3, 2026

Description

Adds AsterDEX to the DeFi referral program with a two-step connection flow: the referral is shown only after both (1) wallet_requestPermissions succeed and (2) a successful eth_signTypedData_v4 for the same origin/tab. Other partners (Hyperliquid, GMX) keep the existing single-step behavior (trigger on permissions only).

  • Config (shared/constants/defi-referrals.ts): Introduces ConnectionFlow ('permissions' | 'permissions_then_signature') and connectionFlow on partner config; adds AsterDEX with connectionFlow: 'permissions_then_signature'.
  • Middleware (app/scripts/lib/createDefiReferralMiddleware.ts): For two-step partners, records a permissions grant in a pendingSignatureMap (keyed by origin:tabId) and triggers the referral only when a matching eth_signTypedData_v4 succeeds 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 any eth_signTypedData_v4 requests that haven't occurred directly after the connection permissions step. The referral screen should only show after the 2-step connection flow.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Added AsterDEX to the DeFi referral program

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/CEUX-745

Manual testing steps

  1. Open AsterDEX; connect wallet (permissions then sign typed data). Confirm the referral consent is shown only after both steps succeed.
  2. Open Hyperliquid or GMX and connect. Confirm the referral still triggers on permissions alone.
  3. For AsterDEX, confirm that only approving the permissions step does not trigger the referral.

Screenshots/Recordings

Before

After

asterdex.mov

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

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 referrals state, e2e fixtures, and Storybook consent stories.

Extends partner config with a connectionFlow (permissions vs permissions_then_signature) and updates createDefiReferralMiddleware to support a two-step trigger: for two-step partners it records a successful permissions grant and only fires the referral after a matching eth_signTypedData_v4 succeeds within a short window.

Updates _updateDefiReferralUrl to 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

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.

@metamaskbot metamaskbot added the team-core-extension-ux Core Extension UX team label Mar 3, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 3, 2026

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (1 files, +22 -0)
  • 📁 ui/
    • 📁 pages/
      • 📁 confirmations/
        • 📁 confirmation/
          • 📁 stories/
            • 📄 defi-referral-consent.stories.tsx +22 -0

👨‍🔧 @MetaMask/core-extension-ux (1 files, +1 -0)
  • 📁 ui/
    • 📁 pages/
      • 📁 core/
        • 📁 defi-referral-consent/
          • 📄 defi-referral-consent.tsx +1 -0

👨‍🔧 @MetaMask/extension-platform (1 files, +1 -0)
  • 📁 test/
    • 📁 e2e/
      • 📁 fixtures/
        • 📄 onboarding-fixture.json +1 -0

🕵️ @MetaMask/extension-privacy-reviewers (1 files, +1 -0)
  • 📁 test/
    • 📁 e2e/
      • 📁 tests/
        • 📁 settings/
          • 📄 state-logs.json +1 -0

🧪 @MetaMask/qa (2 files, +2 -0)
  • 📁 test/
    • 📁 e2e/
      • 📁 fixtures/
        • 📄 onboarding-fixture.json +1 -0
      • 📁 tests/
        • 📁 settings/
          • 📄 state-logs.json +1 -0

👨‍🔧 @MetaMask/wallet-integrations (1 files, +115 -37)
  • 📁 app/
    • 📁 scripts/
      • 📁 lib/
        • 📄 createDefiReferralMiddleware.ts +115 -37

@github-actions github-actions bot added the size-M label Mar 3, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 3, 2026

Builds ready [0aec688]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account29127830911296309
total29127830911296309
Confirm Txconfirm_tx605860506072960576072
total605860506072960576072
Bridge User Actionsbridge_load_page25720133754302337
bridge_load_asset_picker20718423016208230
bridge_search_token72570373913735739
total1207110812675912471267
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14671245178910815221658
load1232103714659912881429
domContentLoaded122499914539812831389
domInteractive3016106192684
firstPaint169691283137213356
backgroundConnect21719429116220244
firstReactRender20133752130
initialActions107113
loadScripts102581012539710811195
setupStore1573661825
numNetworkReqs312296192984
Power User HomeuiStartup2364143110200149721924561
load12301052202618212681650
domContentLoaded12121045190917212491634
domInteractive40201943338115
firstPaint19578575102250341
backgroundConnect63626964209343562665
firstReactRender26165382844
initialActions1011113
loadScripts991828168416510321386
setupStore1665381731
numNetworkReqs1033825141130175
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2212172243223224
srpButtonToSrpForm94939519495
confirmSrpToPwForm22212312223
pwFormToMetricsScreen16151601616
metricsToWalletReadyScreen16161601616
doneButtonToHomeScreen67459776861697768
openAccountMenuToAccountListLoaded290629012910329072910
total3952387640406239884040
Onboarding New WalletcreateWalletToSocialScreen2212202211221221
srpButtonToPwForm1061061070106107
createPwToRecoveryScreen889099
skipBackupToMetricsScreen36343713637
agreeButtonToOnboardingSuccess16161701617
doneButtonToAssetList53848864161523641
total9268761033639091033
Asset DetailsassetClickToPriceChart673698228498
total673698228498
Solana Asset DetailsassetClickToPriceChart75707937779
total75707937779
Import Srp HomeloginToHomeScreen1964185520477119992047
openAccountMenuAfterLogin583179187879
homeAfterImportWithNewWallet27672610302815528423028
total4725465748728747064872
Send TransactionsopenSendPageFromHome25173772837
selectTokenToSendFormLoaded19172122021
reviewTransactionToConfirmationPage8478468512847851
total89587991213909912
SwapopenSwapPageFromHome1121071153113115
fetchAndDisplaySwapQuotes289028882896328892896
total300230023003130033003
🌐 Dapp Page Load Benchmarks

Current Commit: 0aec688 | Date: 3/3/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.07s (±47ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 752ms (±43ms) 🟢 | historical mean value: 731ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 83ms (±15ms) 🟢 | historical mean value: 83ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.07s 47ms 1.03s 1.42s 1.10s 1.42s
domContentLoaded 752ms 43ms 717ms 1.08s 778ms 1.08s
firstPaint 83ms 15ms 60ms 220ms 96ms 220ms
firstContentfulPaint 83ms 15ms 60ms 220ms 96ms 220ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.17 KiB (0.02%)
  • ui: 35 Bytes (0%)
  • common: 182 Bytes (0%)

@MetaMask MetaMask deleted a comment from sonarqubecloud bot Mar 3, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 3, 2026

Builds ready [9b4db1d]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account41934051677510516
total41934051677510516
Confirm Txconfirm_tx6065602161193660736119
total6065602161193660736119
Bridge User Actionsbridge_load_page23618228637264286
bridge_load_asset_picker25821628626282286
bridge_search_token74373076315759763
total123012261233312331233
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14771241204011915361686
load12391025171110613041423
domContentLoaded12321020170410412971391
domInteractive3018124212687
firstPaint168741327139218301
backgroundConnect21519726013222243
firstReactRender19133542026
initialActions207124
loadScripts1033817150410310951200
setupStore1473961727
numNetworkReqs312294192284
Power User HomeuiStartup17361406233315217952040
load11721052168313411701553
domContentLoaded11571038165013011511526
domInteractive3519125213478
firstPaint1667042982232312
backgroundConnect30225944827309354
firstReactRender23165662634
initialActions105112
loadScripts93883014031279221300
setupStore1754771930
numNetworkReqs58371702456117
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2192182190219219
srpButtonToSrpForm93919619496
confirmSrpToPwForm21212202222
pwFormToMetricsScreen15151501515
metricsToWalletReadyScreen16151711617
doneButtonToHomeScreen730586959152862959
openAccountMenuToAccountListLoaded27182283295828129362958
total38223606401914739004019
Onboarding New WalletcreateWalletToSocialScreen2202192200220220
srpButtonToPwForm1081051123110112
createPwToRecoveryScreen989099
skipBackupToMetricsScreen35343613636
agreeButtonToOnboardingSuccess16151711617
doneButtonToAssetList55048362266608622
total9388711006639941006
Asset DetailsassetClickToPriceChart48406074960
total48406074960
Solana Asset DetailsassetClickToPriceChart74697837778
total74697837778
Import Srp HomeloginToHomeScreen2131201522478321882247
openAccountMenuAfterLogin55506255662
homeAfterImportWithNewWallet30152811338422231523384
total50914886527913951035279
Send TransactionsopenSendPageFromHome27233132931
selectTokenToSendFormLoaded17161911819
reviewTransactionToConfirmationPage86284790525848905
total90588995026891950
SwapopenSwapPageFromHome1091051113111111
fetchAndDisplaySwapQuotes2918289029682829262968
total3036299630803730793080
🌐 Dapp Page Load Benchmarks

Current Commit: 9b4db1d | Date: 3/3/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±40ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 732ms (±37ms) 🟢 | historical mean value: 736ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 81ms (±10ms) 🟢 | historical mean value: 85ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 40ms 1.01s 1.33s 1.06s 1.33s
domContentLoaded 732ms 37ms 706ms 1.01s 755ms 1.01s
firstPaint 81ms 10ms 64ms 164ms 92ms 164ms
firstContentfulPaint 81ms 10ms 64ms 164ms 92ms 164ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.17 KiB (0.02%)
  • ui: 1.74 KiB (0.02%)
  • common: 4.33 KiB (0.04%)

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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.

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 3, 2026

Builds ready [7e9f4a1]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account28526633026276330
total28526633026276330
Confirm Txconfirm_tx606160546068560636068
total606160546068560636068
Bridge User Actionsbridge_load_page2292272322229232
bridge_load_asset_picker20418922917220229
bridge_search_token7027007052703705
total1137111211732211521173
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup13881162179110214341574
load116698515069111961336
domContentLoaded116098114979111931322
domInteractive2716122192476
firstPaint1466940274206272
backgroundConnect20819027014213239
firstReactRender19124352027
initialActions106225
loadScripts9677851301919941135
setupStore1362951525
numNetworkReqs312288182579
Power User HomeuiStartup17761445236118518172255
load11911067173115511711674
domContentLoaded11761052172215211631635
domInteractive3720150233691
firstPaint206841519161256371
backgroundConnect31127145231316374
firstReactRender24166482642
initialActions106113
loadScripts95083814881479341377
setupStore1685771826
numNetworkReqs59361572657135
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2212152274223227
srpButtonToSrpForm1049411610116116
confirmSrpToPwForm23212832128
pwFormToMetricsScreen16161601616
metricsToWalletReadyScreen17161711717
doneButtonToHomeScreen64658271046659710
openAccountMenuToAccountListLoaded27452491292420629122924
total38153483398619439763986
Onboarding New WalletcreateWalletToSocialScreen2202192221221222
srpButtonToPwForm1111061174112117
createPwToRecoveryScreen989099
skipBackupToMetricsScreen37363813738
agreeButtonToOnboardingSuccess17161701717
doneButtonToAssetList54550560136546601
total94689599839963998
Asset DetailsassetClickToPriceChart473664115764
total473664115764
Solana Asset DetailsassetClickToPriceChart82778958789
total82778958789
Import Srp HomeloginToHomeScreen2072196721356321192135
openAccountMenuAfterLogin40354444444
homeAfterImportWithNewWallet30822802329522932793295
total51944868545823754315458
Send TransactionsopenSendPageFromHome27262812828
selectTokenToSendFormLoaded19182112021
reviewTransactionToConfirmationPage8468458502845850
total8938918972893897
SwapopenSwapPageFromHome11710213613124136
fetchAndDisplaySwapQuotes289328912896228932896
total3010299330291430153029
🌐 Dapp Page Load Benchmarks

Current Commit: 7e9f4a1 | Date: 3/3/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 986ms (±43ms) 🟢 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 693ms (±39ms) 🟢 | historical mean value: 737ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±11ms) 🟢 | historical mean value: 85ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 986ms 43ms 956ms 1.31s 1.00s 1.31s
domContentLoaded 693ms 39ms 669ms 988ms 718ms 988ms
firstPaint 79ms 11ms 64ms 176ms 88ms 176ms
firstContentfulPaint 79ms 11ms 64ms 176ms 88ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.82 KiB (0.03%)
  • ui: 3.02 KiB (0.04%)
  • common: 4.67 KiB (0.04%)

@ameliejyc ameliejyc marked this pull request as ready for review March 4, 2026 10:01
@ameliejyc ameliejyc requested review from a team as code owners March 4, 2026 10:01
OGPoyraz
OGPoyraz previously approved these changes Mar 4, 2026
Copy link
Copy Markdown
Member

@OGPoyraz OGPoyraz left a comment

Choose a reason for hiding this comment

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

Confirmation changes LGTM

@michaelmccallam
Copy link
Copy Markdown

@ameliejyc
This is the EVM code - there is also a separate Solana code to be created if required
Code: 82636D
https://www.asterdex.com/en/referral/82636D

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 4, 2026

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 4, 2026

Builds ready [ed72866]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2822762916282291
total2822762916282291
Confirm Txconfirm_tx604660416050460506050
total604660416050460506050
Bridge User Actionsbridge_load_page25721730029278300
bridge_load_asset_picker22012633474271334
bridge_search_token73169876025757760
total1208110212827912751282
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14141193167110714611612
load1190100613999712411368
domContentLoaded118398013869612331356
domInteractive281795182580
firstPaint163701055116203276
backgroundConnect21119327615213243
firstReactRender19123742029
initialActions106124
loadScripts98878911979410441162
setupStore1372951523
numNetworkReqs312289192281
Power User HomeuiStartup240614259163146722915840
load12021030167913612301491
domContentLoaded11851021159012712211477
domInteractive3620131203789
firstPaint199871492154257347
backgroundConnect64226337997725902558
firstReactRender23154362437
initialActions105112
loadScripts974818136012310061264
setupStore1454161628
numNetworkReqs72271512587115
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2202192211220221
srpButtonToSrpForm9590102494102
confirmSrpToPwForm21212102121
pwFormToMetricsScreen15151601516
metricsToWalletReadyScreen16151601616
doneButtonToHomeScreen724595937129799937
openAccountMenuToAccountListLoaded2935291029561729452956
total3927386839754439753975
Onboarding New WalletcreateWalletToSocialScreen2192192200220220
srpButtonToPwForm1051041061106106
createPwToRecoveryScreen888088
skipBackupToMetricsScreen35343813638
agreeButtonToOnboardingSuccess17161811818
doneButtonToAssetList56947968277609682
total9578641067789931067
Asset DetailsassetClickToPriceChart45444714647
total45444714647
Solana Asset DetailsassetClickToPriceChart74698257482
total74698257482
Import Srp HomeloginToHomeScreen20901930220410322012204
openAccountMenuAfterLogin534074167174
homeAfterImportWithNewWallet2387233424454224042445
total45404416467710846134677
Send TransactionsopenSendPageFromHome20182221922
selectTokenToSendFormLoaded23173273132
reviewTransactionToConfirmationPage8478478481848848
total8888839018885901
SwapopenSwapPageFromHome1151091246117124
fetchAndDisplaySwapQuotes2903288929251329082925
total3013298230332030323033
🌐 Dapp Page Load Benchmarks

Current Commit: ed72866 | Date: 3/4/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±44ms) 🟡 | historical mean value: 1.06s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 744ms (±41ms) 🟢 | historical mean value: 748ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 82ms (±14ms) 🟢 | historical mean value: 83ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 44ms 1.04s 1.38s 1.09s 1.38s
domContentLoaded 744ms 41ms 722ms 1.05s 769ms 1.05s
firstPaint 82ms 14ms 64ms 208ms 92ms 208ms
firstContentfulPaint 82ms 14ms 64ms 208ms 92ms 208ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 2.34 KiB (0.04%)
  • ui: -5.87 KiB (-0.07%)
  • common: 4.92 KiB (0.04%)

Copy link
Copy Markdown
Member

@seaona seaona left a comment

Choose a reason for hiding this comment

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

e2e LGTM!

* - 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';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 string unions

@ameliejyc ameliejyc added this pull request to the merge queue Mar 4, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2026
@ameliejyc ameliejyc added this pull request to the merge queue Mar 4, 2026
Merged via the queue into main with commit 97d0b0b Mar 4, 2026
184 checks passed
@ameliejyc ameliejyc deleted the add-asterdex-to-referral-program branch March 4, 2026 16:31
@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2026
@metamaskbot metamaskbot added the release-13.22.0 Issue or pull request that will be included in release 13.22.0 label Mar 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.22.0 Issue or pull request that will be included in release 13.22.0 size-M team-core-extension-ux Core Extension UX team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants