Skip to content

Commit

Permalink
Chain Pauses Update (#3468)
Browse files Browse the repository at this point in the history
* paused chain + updated SDK

* fix: use correct address for tests

---------

Co-authored-by: ChiTimesChi <[email protected]>
  • Loading branch information
Defi-Moses and ChiTimesChi authored Dec 18, 2024
1 parent 3feab21 commit cf8cd3e
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/sdk-router/src/constants/chainIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ 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.
*/
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:
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk-router/src/constants/testValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
51 changes: 51 additions & 0 deletions packages/sdk-router/src/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
AVAX_GOHM,
AVAX_USDC,
AVAX_USDC_E,
BOBA_USDC,
BSC_GOHM,
BSC_USDC,
ETH_DAI,
Expand Down Expand Up @@ -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)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,12 @@
"disableBanner": false,
"disableWarning": true,
"disableCountdown": false
},
{
"id": "boba-chain-pause",
"pausedFromChains": [288],
"pausedToChains": [288],
"pauseBridge": true,
"pauseSwap": false
}
]

0 comments on commit cf8cd3e

Please sign in to comment.