-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* yarn add ts-xor * Isolate Query types * Define Abstract Router * Implement common functions for Routers * Wrappers for SynapseRouter, SynapseCCTPRouter * Abstraction for a set of Router instances * Finding bridge routes * Add SynapseRouter-specific functions * Add router/index.ts * Constructor for new SDK class * Add pools, swaps operations to new SDK * Fix: naming * Add origin router address to BridgeRoute * Add bridge operations to SDK * Match exports with the old SDK * Nuke old SDK * Add address property to Router class * Remove ABI from Router constructor * Remove `addresses` from RouterSet constructor * Rework address map generation * Fully isolate contract interaction * Don't expose routerContract in Router class * Fix: circular dependency * Adjust synapseRouter test * Adjust CCTP router test * Fix: pass addressMap as constructor arg * Fix: pass Router constructor as argument * Basic coverage for RouterSets * Refactor constants * Add test for getBridgeTokens * Add test: getOriginQueries * Tests: getDestinationQueries * Test SDK constructor * Add ETH -> ARB bridgeQuote tests * More bridge tests * Add tests for errors * Introduce SwapQuote type * Fix: return type for `getBridgeGas()` * Add coverage for the remainder of the functions * Fix: address handling in calculateAddLiquidity * Remove deprecated code * Add coverage for deadlines * Rename new tests * Add some clarity for used classes * yarn install * add comment for vercel build * Use llama public RPCs * [DROP IN PROD] modify to local * Fix: spelling * Explicit error when Router is not present * Add coverage * Set default timeout to 30s for SDK tests * Keep the Code Rabbit happy by resolving a few issues * Revert "[DROP IN PROD] modify to local" This reverts commit 4c33414. * Revert "add comment for vercel build" This reverts commit dd9979d. * bump * Revert "bump" This reverts commit 1883649. --------- Co-authored-by: Trajan0x <[email protected]> Co-authored-by: Jonah Lin <[email protected]>
- Loading branch information
1 parent
eaea09d
commit 174f545
Showing
34 changed files
with
2,812 additions
and
1,864 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
module.exports = { | ||
testTimeout: 30000, | ||
} |
This file contains 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,50 @@ | ||
import { CCTP_SUPPORTED_CHAIN_IDS, SUPPORTED_CHAIN_IDS } from './chainIds' | ||
|
||
export type AddressMap = { | ||
[chainId: number]: string | ||
} | ||
|
||
/** | ||
* Generates an address map for a given address and list of chain ids. | ||
* Will use the same address for all chain ids unless an exception map is provided. | ||
* In which case, the exception map will be used to override the address for the | ||
* specified chain ids. | ||
* | ||
* @param chainIds list of chain ids | ||
* @param address address to use for all chain ids unless overridden by exception map | ||
* @param exceptionMap optional map of chain ids to addresses to override the address param | ||
* @returns | ||
*/ | ||
const generateAddressMap = ( | ||
chainIds: number[], | ||
address: string, | ||
exceptionMap?: AddressMap | ||
): AddressMap => { | ||
return Object.fromEntries( | ||
chainIds.map((chainId) => [chainId, exceptionMap?.[chainId] ?? address]) | ||
) | ||
} | ||
|
||
/** | ||
* SynapseRouter contract address for all chains except ones from ROUTER_EXCEPTION_MAP. | ||
*/ | ||
const ROUTER_ADDRESS = '0x7E7A0e201FD38d3ADAA9523Da6C109a07118C96a' | ||
const ROUTER_EXCEPTION_MAP: AddressMap = {} | ||
|
||
export const ROUTER_ADDRESS_MAP: AddressMap = generateAddressMap( | ||
SUPPORTED_CHAIN_IDS, | ||
ROUTER_ADDRESS, | ||
ROUTER_EXCEPTION_MAP | ||
) | ||
|
||
/** | ||
* SynapseCCTP contract address for all chains except ones from CCTP_ROUTER_EXCEPTION_MAP. | ||
*/ | ||
const CCTP_ROUTER_ADDRESS = '0xD359bc471554504f683fbd4f6e36848612349DDF' | ||
const CCTP_ROUTER_EXCEPTION_MAP: AddressMap = {} | ||
|
||
export const CCTP_ROUTER_ADDRESS_MAP: AddressMap = generateAddressMap( | ||
CCTP_SUPPORTED_CHAIN_IDS, | ||
CCTP_ROUTER_ADDRESS, | ||
CCTP_ROUTER_EXCEPTION_MAP | ||
) |
This file contains 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,40 @@ | ||
export enum SupportedChainId { | ||
ETH = 1, | ||
OPTIMISM = 10, | ||
CRONOS = 25, | ||
BSC = 56, | ||
POLYGON = 137, | ||
FANTOM = 250, | ||
BOBA = 288, | ||
METIS = 1088, | ||
MOONBEAM = 1284, | ||
MOONRIVER = 1285, | ||
DOGECHAIN = 2000, | ||
CANTO = 7700, | ||
KLAYTN = 8217, | ||
BASE = 8453, | ||
ARBITRUM = 42161, | ||
AVALANCHE = 43114, | ||
DFK = 53935, | ||
AURORA = 1313161554, | ||
HARMONY = 1666600000, | ||
} | ||
|
||
/** | ||
* 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)) | ||
|
||
/** | ||
* List of chain ids where SynapseCCTP is deployed. | ||
* | ||
* Note: This is a subset of SUPPORTED_CHAIN_IDS. | ||
*/ | ||
export const CCTP_SUPPORTED_CHAIN_IDS: number[] = [ | ||
SupportedChainId.ETH, | ||
SupportedChainId.ARBITRUM, | ||
SupportedChainId.AVALANCHE, | ||
SupportedChainId.OPTIMISM, | ||
] |
This file contains 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 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,51 @@ | ||
import { SupportedChainId } from './chainIds' | ||
|
||
export const PUBLIC_PROVIDER_URLS: { [chainId: number]: string } = { | ||
[SupportedChainId.ETH]: 'https://eth.llamarpc.com', | ||
[SupportedChainId.OPTIMISM]: 'https://mainnet.optimism.io', | ||
[SupportedChainId.CRONOS]: 'https://evm.cronos.org', | ||
[SupportedChainId.BSC]: 'https://binance.llamarpc.com', | ||
[SupportedChainId.POLYGON]: 'https://polygon.llamarpc.com', | ||
[SupportedChainId.FANTOM]: 'https://rpc3.fantom.network', | ||
[SupportedChainId.BOBA]: 'https://boba-ethereum.gateway.tenderly.co', | ||
[SupportedChainId.METIS]: 'https://andromeda.metis.io/?owner=1088', | ||
[SupportedChainId.MOONBEAM]: 'https://moonbeam.public.blastapi.io', | ||
[SupportedChainId.MOONRIVER]: 'https://moonriver.public.blastapi.io', | ||
[SupportedChainId.DOGECHAIN]: 'https://rpc.ankr.com/dogechain', | ||
[SupportedChainId.CANTO]: 'https://mainnode.plexnode.org:8545', | ||
[SupportedChainId.KLAYTN]: 'https://klaytn.api.onfinality.io/public', | ||
[SupportedChainId.BASE]: 'https://developer-access-mainnet.base.org', | ||
[SupportedChainId.ARBITRUM]: 'https://arbitrum.llamarpc.com', | ||
[SupportedChainId.AVALANCHE]: 'https://api.avax.network/ext/bc/C/rpc', | ||
[SupportedChainId.DFK]: | ||
'https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc', | ||
[SupportedChainId.AURORA]: 'https://mainnet.aurora.dev', | ||
[SupportedChainId.HARMONY]: 'https://api.s0.t.hmny.io', | ||
} | ||
|
||
// Token addresses on Ethereum mainnet | ||
export const ETH_DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F' | ||
export const ETH_NUSD = '0x1B84765dE8B7566e4cEAF4D0fD3c5aF52D3DdE4F' | ||
export const ETH_USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' | ||
export const ETH_USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7' | ||
// Token addresses on Arbitrum mainnet | ||
export const ARB_NETH = '0x3ea9B0ab55F34Fb188824Ee288CeaEfC63cf908e' | ||
export const ARB_NUSD = '0x2913E812Cf0dcCA30FB28E6Cac3d2DCFF4497688' | ||
export const ARB_USDC = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' | ||
export const ARB_USDC_E = '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8' | ||
export const ARB_USDT = '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9' | ||
export const ARB_WETH = '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1' | ||
// Token addresses on Avalanche mainnet | ||
export const AVAX_GOHM = '0x321E7092a180BB43555132ec53AaA65a5bF84251' | ||
export const AVAX_USDC = '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E' | ||
export const AVAX_USDC_E = '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664' | ||
// Token addresses on BSC mainnet | ||
export const BSC_GOHM = '0x88918495892BAF4536611E38E75D771Dc6Ec0863' | ||
export const BSC_USDC = '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d' | ||
|
||
// Pool addresses on Ethereum mainnet | ||
export const ETH_POOL_NUSD = '0x1116898DdA4015eD8dDefb84b6e8Bc24528Af2d8' | ||
// Pool addresses on Arbitrum mainnet | ||
export const ARB_POOL_ETH_WRAPPER = '0x1c3fe783a7c06bfAbd124F2708F5Cc51fA42E102' | ||
export const ARB_POOL_NETH = '0xa067668661C84476aFcDc6fA5D758C4c01C34352' | ||
export const ARB_POOL_NUSD = '0x9Dd329F5411466d9e0C488fF72519CA9fEf0cb40' |
Oops, something went wrong.