Commit c2751a83 authored by marktoda's avatar marktoda Committed by GitHub

feat: add new v2 factory addresses (#151)

* feat: add new v2 factory addresses

BREAKING CHANGE: FACTORY_ADDRESS field removed, replaced with
FACTORY_ADDRESS_MAP

* Fix code style issues with Prettier

---------
Co-authored-by: default avatarLint Action <lint-action@samuelmeuli.com>
parent 81948482
import { Percent } from '@uniswap/sdk-core' import { Percent } from '@uniswap/sdk-core'
import JSBI from 'jsbi' import JSBI from 'jsbi'
export const FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f' export const FACTORY_ADDRESS_MAP: { [chainId: number]: string } = {
// Mainnet
1: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
// Ropsten
3: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
// Goerli
5: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
// Optimism
10: '0x0c3c1c532F1e39EdF36BE9Fe0bE1410313E074Bf',
// Arbitrum
42161: '0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9',
// Avalanche
43114: '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C',
// Base
8453: '0x8909dc15e40173ff4699343b6eb8132c65e18ec6',
// BNB
56: '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6',
// Polygon
137: '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C'
}
export const INIT_CODE_HASH = '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' export const INIT_CODE_HASH = '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
......
...@@ -6,7 +6,7 @@ import { getCreate2Address } from '@ethersproject/address' ...@@ -6,7 +6,7 @@ import { getCreate2Address } from '@ethersproject/address'
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import { import {
FACTORY_ADDRESS, FACTORY_ADDRESS_MAP,
INIT_CODE_HASH, INIT_CODE_HASH,
MINIMUM_LIQUIDITY, MINIMUM_LIQUIDITY,
FIVE, FIVE,
...@@ -41,7 +41,7 @@ export class Pair { ...@@ -41,7 +41,7 @@ export class Pair {
private readonly tokenAmounts: [CurrencyAmount<Token>, CurrencyAmount<Token>] private readonly tokenAmounts: [CurrencyAmount<Token>, CurrencyAmount<Token>]
public static getAddress(tokenA: Token, tokenB: Token): string { public static getAddress(tokenA: Token, tokenB: Token): string {
return computePairAddress({ factoryAddress: FACTORY_ADDRESS, tokenA, tokenB }) return computePairAddress({ factoryAddress: FACTORY_ADDRESS_MAP[tokenA.chainId], tokenA, tokenB })
} }
public constructor(currencyAmountA: CurrencyAmount<Token>, tokenAmountB: CurrencyAmount<Token>) { public constructor(currencyAmountA: CurrencyAmount<Token>, tokenAmountB: CurrencyAmount<Token>) {
......
export { FACTORY_ADDRESS, INIT_CODE_HASH, MINIMUM_LIQUIDITY } from './constants' export { FACTORY_ADDRESS_MAP, INIT_CODE_HASH, MINIMUM_LIQUIDITY } from './constants'
export * from './errors' export * from './errors'
export * from './entities' export * from './entities'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment