diff --git a/package.json b/package.json index 1c3ae0c2..5e5d2d5d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@uniswap/sdk-core", "license": "MIT", - "version": "4.1.1", + "version": "4.1.3", "description": "⚒️ An SDK for building applications on top of Uniswap V3", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/src/addresses.test.ts b/src/addresses.test.ts new file mode 100644 index 00000000..d0fc0199 --- /dev/null +++ b/src/addresses.test.ts @@ -0,0 +1,41 @@ +import { SWAP_ROUTER_02_ADDRESSES } from './addresses' +import { ChainId } from './chains' + +describe('addresses', () => { + describe('swap router 02 addresses', () => { + it('should return the correct address for base', () => { + const address = SWAP_ROUTER_02_ADDRESSES(ChainId.BASE) + expect(address).toEqual('0x2626664c2603336E57B271c5C0b26F421741e481') + }) + + it('should return the correct address for base goerli', () => { + const address = SWAP_ROUTER_02_ADDRESSES(ChainId.BASE_GOERLI) + expect(address).toEqual('0x8357227D4eDc78991Db6FDB9bD6ADE250536dE1d') + }) + + it('should return the correct address for avalanche', () => { + const address = SWAP_ROUTER_02_ADDRESSES(ChainId.AVALANCHE) + expect(address).toEqual('0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE') + }) + + it('should return the correct address for BNB', () => { + const address = SWAP_ROUTER_02_ADDRESSES(ChainId.BNB) + expect(address).toEqual('0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2') + }) + + it('should return the correct address for arbitrum goerli', () => { + const address = SWAP_ROUTER_02_ADDRESSES(ChainId.ARBITRUM_GOERLI) + expect(address).toEqual('0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45') + }) + + it('should return the correct address for optimism sepolia', () => { + const address = SWAP_ROUTER_02_ADDRESSES(ChainId.OPTIMISM_SEPOLIA) + expect(address).toEqual('0x94cC0AaC535CCDB3C01d6787D6413C739ae12bc4') + }) + + it('should return the correct address for sepolia', () => { + const address = SWAP_ROUTER_02_ADDRESSES(ChainId.SEPOLIA) + expect(address).toEqual('0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E') + }) + }) +}) diff --git a/src/addresses.ts b/src/addresses.ts index 2c160a23..7c57b798 100644 --- a/src/addresses.ts +++ b/src/addresses.ts @@ -127,7 +127,8 @@ const OPTIMISM_SEPOLIA_ADDRESSES: ChainAddresses = { quoterAddress: '0x0FBEa6cf957d95ee9313490050F6A0DA68039404', v3MigratorAddress: '0xE7EcbAAaA54D007A00dbb6c1d2f150066D69dA07', nonfungiblePositionManagerAddress: '0xdA75cEf1C93078e8b736FCA5D5a30adb97C8957d', - tickLensAddress: '0xCb7f54747F58F8944973cea5b8f4ac2209BadDC5' + tickLensAddress: '0xCb7f54747F58F8944973cea5b8f4ac2209BadDC5', + swapRouter02Address: '0x94cC0AaC535CCDB3C01d6787D6413C739ae12bc4' } // arbitrum goerli v3 addresses @@ -147,7 +148,8 @@ const ARBITRUM_SEPOLIA_ADDRESSES: ChainAddresses = { quoterAddress: '0x2779a0CC1c3e0E44D2542EC3e79e3864Ae93Ef0B', v3MigratorAddress: '0x398f43ef2c67B941147157DA1c5a868E906E043D', nonfungiblePositionManagerAddress: '0x6b2937Bde17889EDCf8fbD8dE31C3C2a70Bc4d65', - tickLensAddress: '0x0fd18587734e5C2dcE2dccDcC7DD1EC89ba557d9' + tickLensAddress: '0x0fd18587734e5C2dcE2dccDcC7DD1EC89ba557d9', + swapRouter02Address: '0x101F443B4d1b059569D643917553c771E1b9663E' } // sepolia v3 addresses @@ -157,7 +159,8 @@ const SEPOLIA_ADDRESSES: ChainAddresses = { quoterAddress: '0xEd1f6473345F45b75F8179591dd5bA1888cf2FB3', v3MigratorAddress: '0x729004182cF005CEC8Bd85df140094b6aCbe8b15', nonfungiblePositionManagerAddress: '0x1238536071E1c677A632429e3655c799b22cDA52', - tickLensAddress: '0xd7f33bcdb21b359c8ee6f0251d30e94832baad07' + tickLensAddress: '0xd7f33bcdb21b359c8ee6f0251d30e94832baad07', + swapRouter02Address: '0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E' } // Avalanche v3 addresses @@ -310,8 +313,9 @@ export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = SUPPORTED_CHAINS.redu }, {}) export const SWAP_ROUTER_02_ADDRESSES = (chainId: number) => { - if (chainId == ChainId.BNB) { - return CHAIN_TO_ADDRESSES_MAP[chainId].swapRouter02Address + if (SUPPORTED_CHAINS.includes(chainId)) { + const id = chainId as SupportedChainsType + return CHAIN_TO_ADDRESSES_MAP[id].swapRouter02Address ?? '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45' } - return '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45' + return '' }