Skip to content

Commit

Permalink
Fix excludeCCTP flag tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Dec 22, 2023
1 parent f085620 commit 338a31c
Showing 1 changed file with 111 additions and 112 deletions.
223 changes: 111 additions & 112 deletions packages/sdk-router/src/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BridgeQuote> = 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<BridgeQuote> = 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<BridgeQuote> = 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<BridgeQuote> = synapse.bridgeQuote(
Expand Down Expand Up @@ -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<BridgeQuote> = 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<BridgeQuote> = 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<BridgeQuote> = 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<BridgeQuote> = synapse.bridgeQuote(
Expand Down

0 comments on commit 338a31c

Please sign in to comment.