From cf8cd3e02f6eff2601fefa3822b7020382c5d191 Mon Sep 17 00:00:00 2001 From: Moses <103143573+Defi-Moses@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:24:38 +0000 Subject: [PATCH] Chain Pauses Update (#3468) * paused chain + updated SDK * fix: use correct address for tests --------- Co-authored-by: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> --- packages/sdk-router/src/constants/chainIds.ts | 10 +++- .../sdk-router/src/constants/testValues.ts | 2 + packages/sdk-router/src/sdk.test.ts | 51 +++++++++++++++++++ .../public/pauses/v1/paused-chains.json | 7 +++ 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/packages/sdk-router/src/constants/chainIds.ts b/packages/sdk-router/src/constants/chainIds.ts index b3fe066cfe..041705a69e 100644 --- a/packages/sdk-router/src/constants/chainIds.ts +++ b/packages/sdk-router/src/constants/chainIds.ts @@ -33,6 +33,11 @@ const UNSUPPORTED_BRIDGE_CHAIN_IDS: number[] = [ SupportedChainId.WORLDCHAIN, ] +/** + * List of paused chain IDs + */ +export const PAUSED_CHAIN_IDS: SupportedChainId[] = [SupportedChainId.BOBA] + /** * List of supported chain ids, where SynapseBridge is deployed. */ @@ -40,6 +45,7 @@ export const SUPPORTED_CHAIN_IDS: number[] = Object.values(SupportedChainId) .map((chainId) => Number(chainId)) .filter((chainId) => !isNaN(chainId)) .filter((chainId) => !UNSUPPORTED_BRIDGE_CHAIN_IDS.includes(chainId)) + .filter((chainId) => !PAUSED_CHAIN_IDS.includes(chainId)) /** * List of chain ids where SynapseCCTP is deployed, ordered by CCTP's domain: @@ -54,7 +60,7 @@ export const CCTP_SUPPORTED_CHAIN_IDS: number[] = [ SupportedChainId.ARBITRUM, SupportedChainId.BASE, SupportedChainId.POLYGON, // Circle domain 7 -] +].filter((chainId) => !PAUSED_CHAIN_IDS.includes(chainId)) /** * List of chain ids where FastBridge (RFQ) is deployed, ordered by chain id @@ -70,7 +76,7 @@ export const RFQ_SUPPORTED_CHAIN_IDS: number[] = [ SupportedChainId.LINEA, SupportedChainId.BLAST, SupportedChainId.SCROLL, -] +].filter((chainId) => !PAUSED_CHAIN_IDS.includes(chainId)) /** * List of chain ids where hydrating on constructor is supported , ordered by monke diff --git a/packages/sdk-router/src/constants/testValues.ts b/packages/sdk-router/src/constants/testValues.ts index 9f7df6a616..12ce35bfd9 100644 --- a/packages/sdk-router/src/constants/testValues.ts +++ b/packages/sdk-router/src/constants/testValues.ts @@ -31,6 +31,8 @@ export const AVAX_GOHM = '0x321E7092a180BB43555132ec53AaA65a5bF84251' export const AVAX_USDC = '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E' export const AVAX_USDC_E = '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664' export const AVAX_GMX = '0x62edc0692BD897D2295872a9FFCac5425011c661' +// Token addresses on BOBA mainnet +export const BOBA_USDC = '0x66a2A913e447d6b4BF33EFbec43aAeF87890FBbc' // Token addresses on BSC mainnet export const BSC_GOHM = '0x88918495892BAF4536611E38E75D771Dc6Ec0863' export const BSC_USDC = '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d' diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index 68d6d259a2..226325f7f2 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -19,6 +19,7 @@ import { AVAX_GOHM, AVAX_USDC, AVAX_USDC_E, + BOBA_USDC, BSC_GOHM, BSC_USDC, ETH_DAI, @@ -1818,3 +1819,53 @@ describe('SynapseSDK', () => { }) }) }) + +describe('Paused Chain Tests', () => { + let synapseSDK: SynapseSDK + + beforeEach(() => { + // Setup SDK with test providers + const chainIds = [SupportedChainId.ETH, SupportedChainId.BOBA] // Include a paused chain + const providers = chainIds.map((chainId) => getTestProvider(chainId)) + synapseSDK = new SynapseSDK(chainIds, providers) + }) + + describe('Bridge Quote Generation', () => { + it('should not find quotes when origin chain is paused', async () => { + // Try to get quote from paused chain (BOBA) + await expect( + synapseSDK.bridgeQuote( + SupportedChainId.BOBA, // Paused chain as origin + SupportedChainId.ETH, + BOBA_USDC, // Example token addresses + ETH_USDC, + parseFixed('100', 6) + ) + ).rejects.toThrow('No route found') + }) + + it('should not find quotes when destination chain is paused', async () => { + await expect( + synapseSDK.bridgeQuote( + SupportedChainId.ETH, + SupportedChainId.BOBA, // Paused chain as destination + ETH_USDC, + BOBA_USDC, + parseFixed('100', 6) + ) + ).rejects.toThrow('No route found') + }) + + it('should not find quotes when allBridgeQuotes is called with paused chains', async () => { + const quotes = await synapseSDK.allBridgeQuotes( + SupportedChainId.BOBA, // Paused chain + SupportedChainId.ETH, + BOBA_USDC, + ETH_USDC, + parseFixed('100', 6) + ) + + expect(quotes).toHaveLength(0) + }) + }) +}) diff --git a/packages/synapse-interface/public/pauses/v1/paused-chains.json b/packages/synapse-interface/public/pauses/v1/paused-chains.json index fd6f6ab202..8b8cca0433 100644 --- a/packages/synapse-interface/public/pauses/v1/paused-chains.json +++ b/packages/synapse-interface/public/pauses/v1/paused-chains.json @@ -49,5 +49,12 @@ "disableBanner": false, "disableWarning": true, "disableCountdown": false + }, + { + "id": "boba-chain-pause", + "pausedFromChains": [288], + "pausedToChains": [288], + "pauseBridge": true, + "pauseSwap": false } ]