Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Fixed bug that returned an empty swap router 02 address for base chain #120

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/addresses.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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')
});
});
});
2 changes: 1 addition & 1 deletion src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = SUPPORTED_CHAINS.redu
}, {})

export const SWAP_ROUTER_02_ADDRESSES = (chainId: number) => {
if (chainId in SUPPORTED_CHAINS) {
if (SUPPORTED_CHAINS.includes(chainId)) {
const id = chainId as SupportedChainsType
return CHAIN_TO_ADDRESSES_MAP[id].swapRouter02Address ?? '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'
}
Expand Down
Loading