Commit f4935e92 authored by Moody Salem's avatar Moody Salem

fix(arbitrum): miscellaneous arbitrum network changes

- adds the arbitrum rinkeby testnet deployment
- compute usdc prices on arbitrum one
parent 6b3914b7
...@@ -28,6 +28,7 @@ const NETWORK_URLS: { ...@@ -28,6 +28,7 @@ const NETWORK_URLS: {
[SupportedChainId.GOERLI]: `https://goerli.infura.io/v3/${INFURA_KEY}`, [SupportedChainId.GOERLI]: `https://goerli.infura.io/v3/${INFURA_KEY}`,
[SupportedChainId.KOVAN]: `https://kovan.infura.io/v3/${INFURA_KEY}`, [SupportedChainId.KOVAN]: `https://kovan.infura.io/v3/${INFURA_KEY}`,
[SupportedChainId.ARBITRUM_ONE]: `https://arb1.arbitrum.io/rpc`, [SupportedChainId.ARBITRUM_ONE]: `https://arb1.arbitrum.io/rpc`,
[SupportedChainId.ARBITRUM_RINKEBY]: `https://rinkeby.arbitrum.io/rpc`,
} }
const SUPPORTED_CHAIN_IDS: SupportedChainId[] = [ const SUPPORTED_CHAIN_IDS: SupportedChainId[] = [
...@@ -37,6 +38,7 @@ const SUPPORTED_CHAIN_IDS: SupportedChainId[] = [ ...@@ -37,6 +38,7 @@ const SUPPORTED_CHAIN_IDS: SupportedChainId[] = [
SupportedChainId.RINKEBY, SupportedChainId.RINKEBY,
SupportedChainId.ROPSTEN, SupportedChainId.ROPSTEN,
SupportedChainId.ARBITRUM_ONE, SupportedChainId.ARBITRUM_ONE,
SupportedChainId.ARBITRUM_RINKEBY,
] ]
export const network = new NetworkConnector({ export const network = new NetworkConnector({
......
...@@ -5,16 +5,14 @@ import { SupportedChainId } from './chains' ...@@ -5,16 +5,14 @@ import { SupportedChainId } from './chains'
type AddressMap = { [chainId: number]: string } type AddressMap = { [chainId: number]: string }
export const UNI_ADDRESS: AddressMap = constructSameAddressMap('0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984', false) export const UNI_ADDRESS: AddressMap = constructSameAddressMap('0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984')
export const MULTICALL2_ADDRESSES: AddressMap = { export const MULTICALL2_ADDRESSES: AddressMap = {
...constructSameAddressMap('0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696', false), ...constructSameAddressMap('0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696'),
[SupportedChainId.ARBITRUM_ONE]: '0x021CeAC7e681dBCE9b5039d2535ED97590eB395c', [SupportedChainId.ARBITRUM_ONE]: '0x021CeAC7e681dBCE9b5039d2535ED97590eB395c',
[SupportedChainId.ARBITRUM_RINKEBY]: '0x334f67349c1cB3A8fF1268c3eC43FF1D3De246C6',
} }
export const V2_FACTORY_ADDRESSES: AddressMap = constructSameAddressMap(V2_FACTORY_ADDRESS, false) export const V2_FACTORY_ADDRESSES: AddressMap = constructSameAddressMap(V2_FACTORY_ADDRESS)
export const V2_ROUTER_ADDRESS: AddressMap = constructSameAddressMap( export const V2_ROUTER_ADDRESS: AddressMap = constructSameAddressMap('0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D')
'0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
false
)
// most current governance contract address should always be the 0 index // most current governance contract address should always be the 0 index
// only support governance on mainnet // only support governance on mainnet
...@@ -26,9 +24,7 @@ export const GOVERNANCE_ADDRESSES: AddressMap[] = [ ...@@ -26,9 +24,7 @@ export const GOVERNANCE_ADDRESSES: AddressMap[] = [
[SupportedChainId.MAINNET]: '0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F', [SupportedChainId.MAINNET]: '0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F',
}, },
] ]
export const TIMELOCK_ADDRESS: AddressMap = { export const TIMELOCK_ADDRESS: AddressMap = constructSameAddressMap('0x1a9C8182C09F50C8318d769245beA52c32BE35BC')
[SupportedChainId.MAINNET]: '0x1a9C8182C09F50C8318d769245beA52c32BE35BC',
}
export const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap = { export const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap = {
[SupportedChainId.MAINNET]: '0x090D4613473dEE047c3f2706764f49E0821D256e', [SupportedChainId.MAINNET]: '0x090D4613473dEE047c3f2706764f49E0821D256e',
...@@ -36,11 +32,17 @@ export const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap = { ...@@ -36,11 +32,17 @@ export const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap = {
export const ARGENT_WALLET_DETECTOR_ADDRESS: AddressMap = { export const ARGENT_WALLET_DETECTOR_ADDRESS: AddressMap = {
[SupportedChainId.MAINNET]: '0xeca4B0bDBf7c55E9b7925919d03CbF8Dc82537E8', [SupportedChainId.MAINNET]: '0xeca4B0bDBf7c55E9b7925919d03CbF8Dc82537E8',
} }
export const V3_CORE_FACTORY_ADDRESSES: AddressMap = constructSameAddressMap(V3_FACTORY_ADDRESS, true) export const V3_CORE_FACTORY_ADDRESSES: AddressMap = constructSameAddressMap(V3_FACTORY_ADDRESS, [
export const QUOTER_ADDRESSES: AddressMap = constructSameAddressMap('0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6', true) SupportedChainId.ARBITRUM_ONE,
SupportedChainId.ARBITRUM_RINKEBY,
])
export const QUOTER_ADDRESSES: AddressMap = constructSameAddressMap('0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6', [
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.ARBITRUM_RINKEBY,
])
export const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: AddressMap = constructSameAddressMap( export const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: AddressMap = constructSameAddressMap(
'0xC36442b4a4522E871399CD717aBDD847Ab11FE88', '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
true [SupportedChainId.ARBITRUM_ONE, SupportedChainId.ARBITRUM_RINKEBY]
) )
export const ENS_REGISTRAR_ADDRESSES: AddressMap = { export const ENS_REGISTRAR_ADDRESSES: AddressMap = {
[SupportedChainId.MAINNET]: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', [SupportedChainId.MAINNET]: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
...@@ -51,11 +53,11 @@ export const ENS_REGISTRAR_ADDRESSES: AddressMap = { ...@@ -51,11 +53,11 @@ export const ENS_REGISTRAR_ADDRESSES: AddressMap = {
export const SOCKS_CONTROLLER_ADDRESSES: AddressMap = { export const SOCKS_CONTROLLER_ADDRESSES: AddressMap = {
[SupportedChainId.MAINNET]: '0x65770b5283117639760beA3F867b69b3697a91dd', [SupportedChainId.MAINNET]: '0x65770b5283117639760beA3F867b69b3697a91dd',
} }
export const SWAP_ROUTER_ADDRESSES: AddressMap = constructSameAddressMap( export const SWAP_ROUTER_ADDRESSES: AddressMap = constructSameAddressMap('0xE592427A0AEce92De3Edee1F18E0157C05861564', [
'0xE592427A0AEce92De3Edee1F18E0157C05861564', SupportedChainId.ARBITRUM_ONE,
true SupportedChainId.ARBITRUM_RINKEBY,
) ])
export const V3_MIGRATOR_ADDRESSES: AddressMap = constructSameAddressMap( export const V3_MIGRATOR_ADDRESSES: AddressMap = constructSameAddressMap('0xA5644E29708357803b5A882D272c41cC0dF92B34', [
'0xA5644E29708357803b5A882D272c41cC0dF92B34', SupportedChainId.ARBITRUM_ONE,
true SupportedChainId.ARBITRUM_RINKEBY,
) ])
...@@ -5,6 +5,7 @@ export enum SupportedChainId { ...@@ -5,6 +5,7 @@ export enum SupportedChainId {
GOERLI = 5, GOERLI = 5,
KOVAN = 42, KOVAN = 42,
ARBITRUM_ONE = 42161, ARBITRUM_ONE = 42161,
ARBITRUM_RINKEBY = 421611,
} }
export const NETWORK_LABELS: { [chainId in SupportedChainId | number]: string } = { export const NETWORK_LABELS: { [chainId in SupportedChainId | number]: string } = {
...@@ -14,4 +15,5 @@ export const NETWORK_LABELS: { [chainId in SupportedChainId | number]: string } ...@@ -14,4 +15,5 @@ export const NETWORK_LABELS: { [chainId in SupportedChainId | number]: string }
[SupportedChainId.GOERLI]: 'Görli', [SupportedChainId.GOERLI]: 'Görli',
[SupportedChainId.KOVAN]: 'Kovan', [SupportedChainId.KOVAN]: 'Kovan',
[SupportedChainId.ARBITRUM_ONE]: 'Arbitrum One', [SupportedChainId.ARBITRUM_ONE]: 'Arbitrum One',
[SupportedChainId.ARBITRUM_RINKEBY]: 'Arbitrum Testnet',
} }
...@@ -2,27 +2,112 @@ import { WETH9, Token, Ether } from '@uniswap/sdk-core' ...@@ -2,27 +2,112 @@ import { WETH9, Token, Ether } from '@uniswap/sdk-core'
import { UNI_ADDRESS } from './addresses' import { UNI_ADDRESS } from './addresses'
import { SupportedChainId } from './chains' import { SupportedChainId } from './chains'
export const AMPL = new Token(1, '0xD46bA6D942050d489DBd938a2C909A5d5039A161', 9, 'AMPL', 'Ampleforth') export const AMPL = new Token(
export const DAI = new Token(1, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18, 'DAI', 'Dai Stablecoin') SupportedChainId.MAINNET,
export const USDC = new Token(1, '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 6, 'USDC', 'USD//C') '0xD46bA6D942050d489DBd938a2C909A5d5039A161',
export const USDT = new Token(1, '0xdAC17F958D2ee523a2206206994597C13D831ec7', 6, 'USDT', 'Tether USD') 9,
export const WBTC = new Token(1, '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', 8, 'WBTC', 'Wrapped BTC') 'AMPL',
export const FEI = new Token(1, '0x956F47F50A910163D8BF957Cf5846D573E7f87CA', 18, 'FEI', 'Fei USD') 'Ampleforth'
export const TRIBE = new Token(1, '0xc7283b66Eb1EB5FB86327f08e1B5816b0720212B', 18, 'TRIBE', 'Tribe') )
export const FRAX = new Token(1, '0x853d955aCEf822Db058eb8505911ED77F175b99e', 18, 'FRAX', 'Frax') export const DAI = new Token(
export const FXS = new Token(1, '0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0', 18, 'FXS', 'Frax Share') SupportedChainId.MAINNET,
export const renBTC = new Token(1, '0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D', 8, 'renBTC', 'renBTC') '0x6B175474E89094C44Da98b954EedeAC495271d0F',
export const UMA = new Token(1, '0x04Fa0d235C4abf4BcF4787aF4CF447DE572eF828', 18, 'UMA', 'UMA Voting Token v1') 18,
'DAI',
'Dai Stablecoin'
)
export const USDC = new Token(
SupportedChainId.MAINNET,
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
6,
'USDC',
'USD//C'
)
export const USDC_ARBITRUM = new Token(
SupportedChainId.ARBITRUM_ONE,
'0xe865dF68133fcEd7c2285ff3896B406CAfAa2dB8',
6,
'USDC',
'USD//C'
)
export const USDT = new Token(
SupportedChainId.MAINNET,
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
6,
'USDT',
'Tether USD'
)
export const WBTC = new Token(
SupportedChainId.MAINNET,
'0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
8,
'WBTC',
'Wrapped BTC'
)
export const FEI = new Token(
SupportedChainId.MAINNET,
'0x956F47F50A910163D8BF957Cf5846D573E7f87CA',
18,
'FEI',
'Fei USD'
)
export const TRIBE = new Token(
SupportedChainId.MAINNET,
'0xc7283b66Eb1EB5FB86327f08e1B5816b0720212B',
18,
'TRIBE',
'Tribe'
)
export const FRAX = new Token(
SupportedChainId.MAINNET,
'0x853d955aCEf822Db058eb8505911ED77F175b99e',
18,
'FRAX',
'Frax'
)
export const FXS = new Token(
SupportedChainId.MAINNET,
'0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0',
18,
'FXS',
'Frax Share'
)
export const renBTC = new Token(
SupportedChainId.MAINNET,
'0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D',
8,
'renBTC',
'renBTC'
)
export const UMA = new Token(
SupportedChainId.MAINNET,
'0x04Fa0d235C4abf4BcF4787aF4CF447DE572eF828',
18,
'UMA',
'UMA Voting Token v1'
)
export const ETH2X_FLI = new Token( export const ETH2X_FLI = new Token(
1, SupportedChainId.MAINNET,
'0xAa6E8127831c9DE45ae56bB1b0d4D4Da6e5665BD', '0xAa6E8127831c9DE45ae56bB1b0d4D4Da6e5665BD',
18, 18,
'ETH2x-FLI', 'ETH2x-FLI',
'ETH 2x Flexible Leverage Index' 'ETH 2x Flexible Leverage Index'
) )
// Mirror Protocol compat. // Mirror Protocol compat.
export const UST = new Token(1, '0xa47c8bf37f92abed4a126bda807a7b7498661acd', 18, 'UST', 'Wrapped UST') export const UST = new Token(
export const MIR = new Token(1, '0x09a3ecafa817268f77be1283176b946c4ff2e608', 18, 'MIR', 'Wrapped MIR') SupportedChainId.MAINNET,
'0xa47c8bf37f92abed4a126bda807a7b7498661acd',
18,
'UST',
'Wrapped UST'
)
export const MIR = new Token(
SupportedChainId.MAINNET,
'0x09a3ecafa817268f77be1283176b946c4ff2e608',
18,
'MIR',
'Wrapped MIR'
)
export const UNI: { [chainId: number]: Token } = { export const UNI: { [chainId: number]: Token } = {
[SupportedChainId.MAINNET]: new Token(SupportedChainId.MAINNET, UNI_ADDRESS[1], 18, 'UNI', 'Uniswap'), [SupportedChainId.MAINNET]: new Token(SupportedChainId.MAINNET, UNI_ADDRESS[1], 18, 'UNI', 'Uniswap'),
[SupportedChainId.RINKEBY]: new Token(SupportedChainId.RINKEBY, UNI_ADDRESS[4], 18, 'UNI', 'Uniswap'), [SupportedChainId.RINKEBY]: new Token(SupportedChainId.RINKEBY, UNI_ADDRESS[4], 18, 'UNI', 'Uniswap'),
...@@ -30,6 +115,7 @@ export const UNI: { [chainId: number]: Token } = { ...@@ -30,6 +115,7 @@ export const UNI: { [chainId: number]: Token } = {
[SupportedChainId.GOERLI]: new Token(SupportedChainId.GOERLI, UNI_ADDRESS[5], 18, 'UNI', 'Uniswap'), [SupportedChainId.GOERLI]: new Token(SupportedChainId.GOERLI, UNI_ADDRESS[5], 18, 'UNI', 'Uniswap'),
[SupportedChainId.KOVAN]: new Token(SupportedChainId.KOVAN, UNI_ADDRESS[42], 18, 'UNI', 'Uniswap'), [SupportedChainId.KOVAN]: new Token(SupportedChainId.KOVAN, UNI_ADDRESS[42], 18, 'UNI', 'Uniswap'),
} }
export const WETH9_EXTENDED: { [chainId: number]: Token } = { export const WETH9_EXTENDED: { [chainId: number]: Token } = {
...WETH9, ...WETH9,
[SupportedChainId.ARBITRUM_ONE]: new Token( [SupportedChainId.ARBITRUM_ONE]: new Token(
...@@ -39,6 +125,13 @@ export const WETH9_EXTENDED: { [chainId: number]: Token } = { ...@@ -39,6 +125,13 @@ export const WETH9_EXTENDED: { [chainId: number]: Token } = {
'WETH', 'WETH',
'Wrapped Ether' 'Wrapped Ether'
), ),
[SupportedChainId.ARBITRUM_RINKEBY]: new Token(
SupportedChainId.ARBITRUM_RINKEBY,
'0xB47e6A5f8b33b3F17603C83a0535A9dcD7E32681',
18,
'WETH',
'Wrapped Ether'
),
} }
export class ExtendedEther extends Ether { export class ExtendedEther extends Ether {
...@@ -47,7 +140,9 @@ export class ExtendedEther extends Ether { ...@@ -47,7 +140,9 @@ export class ExtendedEther extends Ether {
throw new Error('Unsupported chain ID') throw new Error('Unsupported chain ID')
} }
private static _cachedEther: { [chainId: number]: ExtendedEther } = {}
public static onChain(chainId: number): ExtendedEther { public static onChain(chainId: number): ExtendedEther {
return new ExtendedEther(chainId) return this._cachedEther[chainId] ?? (this._cachedEther[chainId] = new ExtendedEther(chainId))
} }
} }
import { Currency, CurrencyAmount, Price, Token } from '@uniswap/sdk-core' import { Currency, CurrencyAmount, Price, Token } from '@uniswap/sdk-core'
import { useMemo } from 'react' import { useMemo } from 'react'
import { SupportedChainId } from '../constants/chains' import { SupportedChainId } from '../constants/chains'
import { USDC } from '../constants/tokens' import { USDC, USDC_ARBITRUM } from '../constants/tokens'
import { useV2TradeExactOut } from './useV2Trade' import { useV2TradeExactOut } from './useV2Trade'
import { useBestV3TradeExactOut } from './useBestV3Trade' import { useBestV3TradeExactOut } from './useBestV3Trade'
import { useActiveWeb3React } from './web3' import { useActiveWeb3React } from './web3'
...@@ -10,6 +10,7 @@ import { useActiveWeb3React } from './web3' ...@@ -10,6 +10,7 @@ import { useActiveWeb3React } from './web3'
// The amount is large enough to filter low liquidity pairs. // The amount is large enough to filter low liquidity pairs.
const STABLECOIN_AMOUNT_OUT: { [chainId: number]: CurrencyAmount<Token> } = { const STABLECOIN_AMOUNT_OUT: { [chainId: number]: CurrencyAmount<Token> } = {
[SupportedChainId.MAINNET]: CurrencyAmount.fromRawAmount(USDC, 100_000e6), [SupportedChainId.MAINNET]: CurrencyAmount.fromRawAmount(USDC, 100_000e6),
[SupportedChainId.ARBITRUM_ONE]: CurrencyAmount.fromRawAmount(USDC_ARBITRUM, 10_000e6),
} }
/** /**
......
import { SupportedChainId } from '../constants/chains' import { SupportedChainId } from '../constants/chains'
const MAINNET_AND_TESTNETS = [
SupportedChainId.MAINNET,
SupportedChainId.ROPSTEN,
SupportedChainId.RINKEBY,
SupportedChainId.GOERLI,
SupportedChainId.KOVAN,
]
export function constructSameAddressMap<T extends string>( export function constructSameAddressMap<T extends string>(
address: T, address: T,
includeArbitrum: boolean additionalNetworks: SupportedChainId[] = []
): { [chainId: number]: T } { ): { [chainId: number]: T } {
if (includeArbitrum) return MAINNET_AND_TESTNETS.concat(additionalNetworks).reduce<{ [chainId: number]: T }>((memo, chainId) => {
return { memo[chainId] = address
[SupportedChainId.MAINNET]: address, return memo
[SupportedChainId.ROPSTEN]: address, }, {})
[SupportedChainId.RINKEBY]: address,
[SupportedChainId.GOERLI]: address,
[SupportedChainId.KOVAN]: address,
[SupportedChainId.ARBITRUM_ONE]: address,
}
return {
[SupportedChainId.MAINNET]: address,
[SupportedChainId.ROPSTEN]: address,
[SupportedChainId.RINKEBY]: address,
[SupportedChainId.GOERLI]: address,
[SupportedChainId.KOVAN]: address,
}
} }
...@@ -3,6 +3,7 @@ import { SupportedChainId } from '../constants/chains' ...@@ -3,6 +3,7 @@ import { SupportedChainId } from '../constants/chains'
const NETWORK_POLLING_INTERVALS: { [chainId: number]: number } = { const NETWORK_POLLING_INTERVALS: { [chainId: number]: number } = {
[SupportedChainId.ARBITRUM_ONE]: 1_000, [SupportedChainId.ARBITRUM_ONE]: 1_000,
[SupportedChainId.ARBITRUM_RINKEBY]: 1_000,
} }
export default function getLibrary(provider: any): Web3Provider { export default function getLibrary(provider: any): Web3Provider {
......
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