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

Commit

Permalink
Fixed bug that returned an empty swap router 02 address for base chain (
Browse files Browse the repository at this point in the history
#120)

* Updated code to correctly access addresses

* add test to ensure no regression

---------

Co-authored-by: jsy1218 <91580504+jsy1218@users.noreply.github.com>
  • Loading branch information
dallinlarsen and jsy1218 authored Feb 23, 2024
1 parent 27d7888 commit 10d0ad0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
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

0 comments on commit 10d0ad0

Please sign in to comment.