-
Notifications
You must be signed in to change notification settings - Fork 198
feat: add Stargate V2 swapper #12262
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
swdiscordia
wants to merge
17
commits into
shapeshift:develop
Choose a base branch
from
swdiscordia:feat/stargate-swapper
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
58168a1
feat: add Stargate V2 swapper integration
swdiscordia 1c8e99a
fix: stargate swapper rule compliance
swdiscordia 28ddec2
fix: use correct LayerZero scan API endpoint
swdiscordia 054c277
fix: add missing newline at end of fetchStargateTrade.ts
swdiscordia 447f81e
fix: prettier newline in StargateSwapper endpoints
swdiscordia 3bf2c82
chore: remove Odos scaffolding from Stargate branch
6237fe1
chore: apply lint fixes to Stargate swapper integration
aa6db85
fix(stargate): apply slippage to minAmountLD, add TradeQuoteError cod…
c0c8662
docs: document unchained-client generate prerequisite for running tests
dd769c4
fix(stargate): simplify type cast, log fee fallback, use real gasLimit
bc92b96
test(stargate): add cross-chain pair coverage — native bridge, revers…
04350e6
test(stargate): expand asset coverage and add E2E fixture
a9c8e5d
feat: enable Stargate V2 swapper and fix E2E wallet-health fixture
5efb802
fix(stargate): address CodeRabbit review comments
swdiscordia 8367001
chore(stargate): remove unrelated agent fixture changes
swdiscordia 15f9c70
test(e2e): force english locale in qa fixtures
swdiscordia 12eb142
Revert "test(e2e): force english locale in qa fixtures"
swdiscordia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| name: Stargate USDC Ethereum → Arbitrum | ||
| description: > | ||
| Cross-chain USDC swap via Stargate V2 swapper: sell USDC on Ethereum mainnet, | ||
| receive USDC on Arbitrum One. Verifies that Stargate appears as a quote source, | ||
| that slippage is respected, and that the transaction builds and signs correctly. | ||
| route: /trade | ||
| depends_on: | ||
| - wallet-health.yaml | ||
|
|
||
| steps: | ||
| - name: Dismiss stale notifications | ||
| instruction: > | ||
| Dismiss any lingering notifications, toasts, or feedback dialogs from | ||
| previous tests (close buttons, "Maybe Later", etc.). | ||
| expected: Clean trade page with no overlays | ||
| screenshot: true | ||
|
|
||
| - name: Select USDC (Ethereum) as sell asset | ||
| instruction: > | ||
| Click the sell asset selector. Search for "USDC". From the results, | ||
| select "USD Coin (USDC)" on the Ethereum chain (not Arbitrum, not Base). | ||
| Verify USDC Ethereum is selected as the sell asset. | ||
| expected: USDC on Ethereum mainnet is the sell asset | ||
| screenshot: true | ||
|
|
||
| - name: Select USDC (Arbitrum) as buy asset | ||
| instruction: > | ||
| Click the buy/receive asset selector. Search for "USDC". From the results, | ||
| expand USDC if needed and select "USD Coin (USDC)" on the Arbitrum One chain. | ||
| Verify USDC on Arbitrum is selected as the buy asset. | ||
| expected: USDC on Arbitrum One is the buy asset | ||
| screenshot: true | ||
|
|
||
| - name: Toggle to fiat input mode | ||
| instruction: > | ||
| Click the "≈ $0.00" button below the sell amount to toggle to fiat/USD input mode. | ||
| If already in fiat mode (placeholder shows "$0"), skip this step. | ||
| expected: Sell input is in fiat/USD mode | ||
| screenshot: false | ||
|
|
||
| - name: Enter swap amount ($1) | ||
| instruction: > | ||
| Click the sell amount input and type "1" character by character using press | ||
| (NOT fill). Wait for the value to register. | ||
| expected: $1.00 entered as sell amount | ||
| screenshot: true | ||
|
|
||
| - name: Wait for Stargate quote | ||
| instruction: > | ||
| Wait up to 15 seconds for a quote to appear. Verify that: | ||
| 1. The "You Get" field shows a USDC amount close to $1 (slightly less due to fees) | ||
| 2. Stargate appears as the swapper source (look for "Stargate" label) | ||
| 3. The "Preview Trade" button is enabled | ||
| If multiple swappers are shown, check that Stargate is one of them. | ||
| expected: > | ||
| Quote shown with a USDC receive amount slightly less than sell amount, | ||
| Stargate visible as source, Preview Trade button enabled | ||
| screenshot: true | ||
|
|
||
| - name: Verify protocol fee is displayed | ||
| instruction: > | ||
| In the quote view, look for a fee breakdown section. Verify that a protocol fee | ||
| is shown (the Stargate OFT fee, typically 0.5-1% of the swap amount). | ||
| Note the fee amount shown. | ||
| expected: Protocol fee visible in the quote breakdown | ||
| screenshot: true | ||
|
|
||
| - name: Preview trade | ||
| instruction: > | ||
| Click the "Preview Trade" button. Wait for the "Confirm Details" screen to appear | ||
| showing: sell amount (USDC Ethereum), receive amount (USDC Arbitrum), swapper name | ||
| (Stargate), estimated fees, and a "Confirm and Trade" button. | ||
| expected: > | ||
| Confirm Details screen visible with cross-chain summary: | ||
| sell = USDC on Ethereum, receive = USDC on Arbitrum, swapper = Stargate | ||
| screenshot: true | ||
|
|
||
| - name: Confirm and sign | ||
| instruction: > | ||
| Click the "Confirm and Trade" button. Wait up to 30 seconds for the | ||
| "Sign & Swap" button to become enabled (not loading/disabled). | ||
| Then click "Sign & Swap". The native wallet signs automatically. | ||
| expected: Transaction submitted, cross-chain swap in progress | ||
| screenshot: true | ||
|
|
||
| - name: Wait for Stargate bridge completion | ||
| instruction: > | ||
| Cross-chain Stargate bridges take 1-3 minutes (LayerZero messaging). | ||
| Wait up to 300 seconds for the swap to complete. Check every 10 seconds. | ||
| Look for: trade page reappearing, success notification, Arbitrum USDC | ||
| balance increased, or "Awaiting swap" disappearing. | ||
| A feedback dialog may appear — dismiss it with "Maybe Later". | ||
| expected: > | ||
| Swap completed — back on trade page, USDC balance on Arbitrum increased, | ||
| no "Awaiting swap" visible | ||
| screenshot: true | ||
|
|
||
| - name: Clean up notifications | ||
| instruction: > | ||
| Dismiss any remaining notifications, feedback dialogs, or toasts. | ||
| expected: Clean trade page, ready for next test | ||
| screenshot: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import type { Csp } from '../../../types' | ||
|
|
||
| export const csp: Csp = { | ||
| 'connect-src': ['https://api-mainnet.layerzero-scan.com'], | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/swapper/src/swappers/StargateSwapper/StargateSwapper.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import type { Swapper } from '../../types' | ||
| import { executeEvmTransaction } from '../../utils' | ||
|
|
||
| export const stargateSwapper: Swapper = { | ||
| executeEvmTransaction, | ||
| } |
107 changes: 107 additions & 0 deletions
107
packages/swapper/src/swappers/StargateSwapper/constant.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import type { ChainId } from '@shapeshiftoss/caip' | ||
| import { | ||
| arbitrumChainId, | ||
| avalancheChainId, | ||
| baseChainId, | ||
| blastChainId, | ||
| bscChainId, | ||
| ethChainId, | ||
| gnosisChainId, | ||
| lineaChainId, | ||
| mantleChainId, | ||
| optimismChainId, | ||
| polygonChainId, | ||
| scrollChainId, | ||
| sonicChainId, | ||
| } from '@shapeshiftoss/caip' | ||
|
|
||
| const metisChainId: ChainId = 'eip155:1088' as ChainId | ||
|
|
||
| export const chainIdToStargateEndpointId = { | ||
| [ethChainId]: 30101, | ||
| [arbitrumChainId]: 30110, | ||
| [optimismChainId]: 30111, | ||
| [baseChainId]: 30184, | ||
| [polygonChainId]: 30109, | ||
| [bscChainId]: 30102, | ||
| [avalancheChainId]: 30106, | ||
| [scrollChainId]: 30214, | ||
| [lineaChainId]: 30183, | ||
| [mantleChainId]: 30181, | ||
| [gnosisChainId]: 30145, | ||
| [metisChainId]: 30151, | ||
| [sonicChainId]: 30332, | ||
| [blastChainId]: 30243, | ||
| } as const satisfies Record<ChainId, number> | ||
|
|
||
| export const STARGATE_SUPPORTED_CHAIN_IDS: ChainId[] = Object.keys( | ||
| chainIdToStargateEndpointId, | ||
| ) as ChainId[] | ||
|
|
||
| export const stargateContractsByChainAndAsset: Record<string, Record<string, string>> = { | ||
| [ethChainId]: { | ||
| '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': '0xc026395860Db2d07ee33e05fE50ed7bD583189C7', | ||
| '0xdac17f958d2ee523a2206206994597c13d831ec7': '0x933597a323Eb81cAe705C5bC29985172fd5A3973', | ||
| '0x0000000000000000000000000000000000000000': '0x77b2043768d28E9C9aB44E1aBfC95944bcE57931', | ||
| '0x9e32b13ce7f2e80a01932b42553652e053d6ed8e': '0xcDafB1b2dB43f366E48e6F614b8DCCBFeeFEEcD3', | ||
| '0xd5f7838f5c461feff7fe49ea5ebaf7728bb0adfa': '0x268Ca24DAefF1FaC2ed883c598200CcbB79E931D', | ||
| '0x1abaea1f7c830bd89acc67ec4af516284b1bc33c': '0x783129E4d7bA0Af0C896c239E57C06DF379aAE8c', | ||
| }, | ||
| [arbitrumChainId]: { | ||
| '0xaf88d065e77c8cc2239327c5edb3a432268e5831': '0xe8CDF27AcD73a434D661C84887215F7598e7d0d3', | ||
| '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': '0xcE8CcA271Ebc0533920C83d39F417ED6A0abB7D0', | ||
| '0x0000000000000000000000000000000000000000': '0xA45B5130f36CDcA45667738e2a258AB09f4A5f7F', | ||
| }, | ||
| [optimismChainId]: { | ||
| '0x0b2c639c533813f4aa9d7837caf62653d097ff85': '0xcE8CcA271Ebc0533920C83d39F417ED6A0abB7D0', | ||
| '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58': '0x19cFCE47eD54a88614648DC3f19A5980097007dD', | ||
| '0x0000000000000000000000000000000000000000': '0xe8CDF27AcD73a434D661C84887215F7598e7d0d3', | ||
| }, | ||
| [baseChainId]: { | ||
| '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913': '0x27a16dc786820B16E5c9028b75B99F6f604b5d26', | ||
| '0x0000000000000000000000000000000000000000': '0xdc181Bd607330aeeBEF6ea62e03e5e1Fb4B6F7C7', | ||
| }, | ||
| [polygonChainId]: { | ||
| '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359': '0x9Aa02D4Fae7F58b8E8f34c66E756cC734DAc7fe4', | ||
| '0xc2132d05d31c914a87c6611c10748aeb04b58e8f': '0xd47b03ee6d86Cf251ee7860FB2ACf9f91B9fD4d7', | ||
| }, | ||
| [bscChainId]: { | ||
| '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d': '0x962Bd449E630b0d928f308Ce63f1A21F02576057', | ||
| '0x55d398326f99059ff775485246999027b3197955': '0x138EB30f73BC423c6455C53df6D89CB01d9eBc63', | ||
| }, | ||
| [avalancheChainId]: { | ||
| '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e': '0x5634c4a5FEd09819E3c46D86A965Dd9447d86e47', | ||
| '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': '0x12dC9256Acc9895B076f6638D628382881e62CeE', | ||
| }, | ||
| [scrollChainId]: { | ||
| '0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4': '0x3Fc69CC4A842838bCDC9499178740226062b14E4', | ||
| '0x0000000000000000000000000000000000000000': '0xC2b638Cb5042c1B3c5d5C969361fB50569840583', | ||
| }, | ||
| [lineaChainId]: { | ||
| '0x0000000000000000000000000000000000000000': '0x81F6138153d473E8c5EcebD3DC8Cd4903506B075', | ||
| }, | ||
| [mantleChainId]: { | ||
| '0x09bc4e0d864854c6afb6eb9a9cdf58ac190d0df9': '0xAc290Ad4e0c891FDc295ca4F0a6214cf6dC6acDC', | ||
| '0x201eba5cc46d216ce6dc03f6a759e8e766e956ae': '0xB715B85682B731dB9D5063187C450095c91C57FC', | ||
| '0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111': '0x4c1d3Fc3fC3c177c3b633427c2F769276c547463', | ||
| '0xcda86a272531e8640cd7f1a92c01839911b90bb0': '0xF7628d84a2BbD9bb9c8E686AC95BB5d55169F3F1', | ||
| }, | ||
| [gnosisChainId]: { | ||
| '0x2a22f9c3b484c3629090feed35f17ff8f88f76f0': '0xB1EeAD6959cb5bB9B20417d6689922523B2B86C3', | ||
| '0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1': '0xe9aBA835f813ca05E50A6C0ce65D0D74390F7dE7', | ||
| }, | ||
| [metisChainId]: { | ||
| '0xbb06dca3ae6887fabf931640f67cab3e3a16f4dc': '0x4dCBFC0249e8d5032F89D6461218a9D2eFff5125', | ||
| '0x420000000000000000000000000000000000000a': '0x36ed193dc7160D3858EC250e69D12B03Ca087D08', | ||
| '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000': '0xD9050e7043102a0391F81462a3916326F86331F0', | ||
| }, | ||
| [sonicChainId]: { | ||
| '0x29219dd400f2bf60e5a23d13be72b486d4038894': '0xA272fFe20cFfe769CdFc4b63088DCD2C82a2D8F9', | ||
| }, | ||
| } | ||
|
|
||
| export const STARGATE_NATIVE_ASSET_ADDRESS = '0x0000000000000000000000000000000000000000' | ||
|
|
||
| export const DEFAULT_STARGATE_USER_ADDRESS = '0x0000000000000000000000000000000000000dead' | ||
|
|
||
| export const DEFAULT_STARGATE_GAS_LIMIT = '500000' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.