From 338a31c2f36e282fb10208d30f602a586ef74d1b Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Fri, 22 Dec 2023 10:56:37 +0000 Subject: [PATCH] Fix excludeCCTP flag tests --- packages/sdk-router/src/sdk.test.ts | 223 ++++++++++++++-------------- 1 file changed, 111 insertions(+), 112 deletions(-) diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index dc4e549c01..80efc869ca 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -240,118 +240,6 @@ describe('SynapseSDK', () => { ) }) - describe('ETH USDC -> ARB USDT (excludeCCTP flag omitted)', () => { - // Try to find ETH USDC -> ARB USDT quote for 1M USDC, - // which by default is routed through USDC - const amount = BigNumber.from(10).pow(12) - const resultPromise: Promise = synapse.bridgeQuote( - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - ARB_USDT, - amount - ) - - createBridgeQuoteTests( - synapse, - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - amount, - resultPromise - ) - - it('Fetches a CCTP bridge quote', async () => { - const result = await resultPromise - expect(result.routerAddress).toEqual( - CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ETH] - ) - // SynapseCCTPRouterQuery has routerAdapter property - expect(result.originQuery.routerAdapter).toBeDefined() - // Estimated time must match the SynapseCCTP median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_CCTP[SupportedChainId.ETH] - ) - expect(result.bridgeModuleName).toEqual('SynapseCCTP') - }) - }) - - describe('ETH USDC -> ARB USDT (excludeCCTP flag off)', () => { - // Try to find ETH USDC -> ARB USDT quote for 1M USDC, - // which by default is routed through USDC - const amount = BigNumber.from(10).pow(12) - const resultPromise: Promise = synapse.bridgeQuote( - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - ARB_USDT, - amount, - undefined, - false - ) - - createBridgeQuoteTests( - synapse, - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - amount, - resultPromise - ) - - it('Fetches a CCTP bridge quote', async () => { - const result = await resultPromise - expect(result.routerAddress).toEqual( - CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ETH] - ) - // SynapseCCTPRouterQuery has routerAdapter property - expect(result.originQuery.routerAdapter).toBeDefined() - // Estimated time must match the SynapseCCTP median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_CCTP[SupportedChainId.ETH] - ) - expect(result.bridgeModuleName).toEqual('SynapseCCTP') - }) - }) - - describe('ETH USDC -> ARB USDT (excludeCCTP flag on)', () => { - // Try to find ETH USDC -> ARB USDT quote for 1M USDC, - // which by default is routed through USDC - const amount = BigNumber.from(10).pow(12) - const resultPromise: Promise = synapse.bridgeQuote( - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - ARB_USDT, - amount, - undefined, - true - ) - - createBridgeQuoteTests( - synapse, - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - amount, - resultPromise - ) - - it('Fetches a Synapse bridge quote', async () => { - const result = await resultPromise - expect(result.routerAddress).toEqual( - ROUTER_ADDRESS_MAP[SupportedChainId.ETH] - ) - // SynapseRouterQuery has swapAdapter property - expect(result.originQuery.swapAdapter).toBeDefined() - // Estimated time must match the SynapseBridge median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_BRIDGE[SupportedChainId.ETH] - ) - expect(result.bridgeModuleName).toEqual('SynapseBridge') - }) - }) - describe('ETH Native -> ARB Native', () => { const amount = BigNumber.from(10).pow(18) const resultPromise: Promise = synapse.bridgeQuote( @@ -536,6 +424,117 @@ describe('SynapseSDK', () => { }) }) + describe('ARB USDT -> ETH USDC (excludeCCTP flag tests)', () => { + // Use $1000 USDT as amount. SynapseCCTP requires less gas on Ethereum to be completed, + // when USDC is used as a tokenOut (compared to SynapseBridge route). + // Therefore we can expect that the min fees would be lower. Meaning for amount this low, + // we should get a CCTP quote unless we explicitly exclude CCTP. + const amount = BigNumber.from(10).pow(9) + + describe('excludeCCTP flag omitted', () => { + const resultPromise: Promise = synapse.bridgeQuote( + SupportedChainId.ARBITRUM, + SupportedChainId.ETH, + ARB_USDT, + ETH_USDC, + amount + ) + + createBridgeQuoteTests( + synapse, + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + ETH_USDC, + amount, + resultPromise + ) + + it('Fetches a CCTP bridge quote', async () => { + const result = await resultPromise + expect(result.routerAddress).toEqual( + CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] + ) + // SynapseCCTPRouterQuery has routerAdapter property + expect(result.originQuery.routerAdapter).toBeDefined() + // Estimated time must match the SynapseCCTP median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_CCTP[SupportedChainId.ARBITRUM] + ) + expect(result.bridgeModuleName).toEqual('SynapseCCTP') + }) + }) + + describe('excludeCCTP flag off', () => { + const resultPromise: Promise = synapse.bridgeQuote( + SupportedChainId.ARBITRUM, + SupportedChainId.ETH, + ARB_USDT, + ETH_USDC, + amount, + undefined, + false + ) + + createBridgeQuoteTests( + synapse, + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + ETH_USDC, + amount, + resultPromise + ) + + it('Fetches a CCTP bridge quote', async () => { + const result = await resultPromise + expect(result.routerAddress).toEqual( + CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] + ) + // SynapseCCTPRouterQuery has routerAdapter property + expect(result.originQuery.routerAdapter).toBeDefined() + // Estimated time must match the SynapseCCTP median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_CCTP[SupportedChainId.ARBITRUM] + ) + expect(result.bridgeModuleName).toEqual('SynapseCCTP') + }) + }) + + describe('excludeCCTP flag on', () => { + const resultPromise: Promise = synapse.bridgeQuote( + SupportedChainId.ARBITRUM, + SupportedChainId.ETH, + ARB_USDT, + ETH_USDC, + amount, + undefined, + true + ) + + createBridgeQuoteTests( + synapse, + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + ETH_USDC, + amount, + resultPromise + ) + + it('Fetches a Synapse bridge quote', async () => { + const result = await resultPromise + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.ARBITRUM] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') + }) + }) + }) + describe('ARB Native -> ETH Native', () => { const amount = BigNumber.from(10).pow(18) const resultPromise: Promise = synapse.bridgeQuote(