Skip to content

Commit

Permalink
Merge pull request #175 from levelkdev/feature/arbitrum-goerli
Browse files Browse the repository at this point in the history
feat: support for Arbitrum Goerli Nitro testnet
  • Loading branch information
adamazad authored Jul 29, 2022
2 parents 3eacdf2 + 1e9770e commit ef903d4
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 15 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"@ethersproject/solidity": "^5.4.0",
"@ethersproject/transactions": "^5.4.0",
"@ethersproject/units": "^5.4.0",
"@swapr/core": "^0.3.18",
"@swapr/periphery": "^0.3.20",
"@swapr/core": "^0.3.19",
"@swapr/periphery": "^0.3.21",
"@uniswap/smart-order-router": "^2.6.0",
"big.js": "^5.2.2",
"dayjs": "^1.11.0",
Expand Down
9 changes: 8 additions & 1 deletion src/constants/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { AddressZero } from '@ethersproject/constants'
import {
arbitrumGoerliTestnet as coreArbitrumGoerliTestnet,
arbitrumOne as coreArbitrumOne,
arbitrumRinkebyTestnet as coreArbitrumRinkebyTestnet,
mainnet as coreMainnet,
rinkeby as coreRinkeby,
xdai as coreXDai,
} from '@swapr/core/.contracts.json'
import {
arbitrumGoerliTestnet as peripheryArbitrumGoerliTestnet,
arbitrumOne as peripheryArbitrumOne,
arbitrumRinkebyTestnet as peripheryArbitrumRinkebyTestnet,
mainnet as peripheryMainnet,
Expand All @@ -16,11 +18,12 @@ import {

import { ChainId } from './chains'

const emptyAddressList = {
const emptyAddressList: Record<ChainId, string> = {
[ChainId.MAINNET]: AddressZero,
[ChainId.RINKEBY]: AddressZero,
[ChainId.ARBITRUM_ONE]: AddressZero,
[ChainId.ARBITRUM_RINKEBY]: AddressZero,
[ChainId.ARBITRUM_GOERLI]: AddressZero,
[ChainId.XDAI]: AddressZero,
[ChainId.POLYGON]: AddressZero,
[ChainId.GOERLI]: AddressZero,
Expand All @@ -37,6 +40,7 @@ export const FACTORY_ADDRESS: Record<ChainId, string> = {
[ChainId.RINKEBY]: coreRinkeby.factory,
[ChainId.ARBITRUM_ONE]: coreArbitrumOne.factory,
[ChainId.ARBITRUM_RINKEBY]: coreArbitrumRinkebyTestnet.factory,
[ChainId.ARBITRUM_GOERLI]: coreArbitrumGoerliTestnet.factory,
[ChainId.XDAI]: coreXDai.factory,
}

Expand All @@ -50,6 +54,7 @@ export const ROUTER_ADDRESS: Record<ChainId, string> = {
[ChainId.XDAI]: peripheryXDai.router,
[ChainId.ARBITRUM_ONE]: peripheryArbitrumOne.router,
[ChainId.ARBITRUM_RINKEBY]: peripheryArbitrumRinkebyTestnet.router,
[ChainId.ARBITRUM_GOERLI]: peripheryArbitrumGoerliTestnet.router,
}

/**
Expand All @@ -62,6 +67,7 @@ export const STAKING_REWARDS_FACTORY_ADDRESS: Record<ChainId, string> = {
[ChainId.XDAI]: '0xa039793Af0bb060c597362E8155a0327d9b8BEE8',
[ChainId.ARBITRUM_ONE]: '0xecA7F78d59D16812948849663b26FE10E320f80C',
[ChainId.ARBITRUM_RINKEBY]: '0x41e657cAdE74f45b7E2F0F4a5AeE0239f2fB4E1F',
[ChainId.ARBITRUM_GOERLI]: '0x95Bf186929194099899139Ff79998cC147290F28',
}

/**
Expand Down Expand Up @@ -91,6 +97,7 @@ export const MULTICALL2_ADDRESS: Record<ChainId, string> = {
[ChainId.ARBITRUM_ONE]: '0x80c7dd17b01855a6d2347444a0fcc36136a314de',
[ChainId.XDAI]: '0xFAa296891cA6CECAF2D86eF5F7590316d0A17dA0',
[ChainId.ARBITRUM_RINKEBY]: '0x309e61A4c36a4a9f131f8844eA521F6384B6C9E3',
[ChainId.ARBITRUM_GOERLI]: '0xBbB06b25484AB9E23FEe8Ee321Af8e253ea7A76a',
[ChainId.POLYGON]: '0x275617327c958bD06b5D6b871E7f491D76113dd8',
[ChainId.GOERLI]: '0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696',
[ChainId.OPTIMISM_MAINNET]: '0xca11bde05977b3631167028862be2a173976ca11',
Expand Down
1 change: 1 addition & 0 deletions src/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum ChainId {
POLYGON = 137,
ARBITRUM_ONE = 42161,
ARBITRUM_RINKEBY = 421611,
ARBITRUM_GOERLI = 421613,

/**
* Optimism Mainnet
Expand Down
4 changes: 4 additions & 0 deletions src/entities/DistributionCampaignBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const MINIMUM_STAKED_AMOUNT_NATIVE_CURRENCY: Record<ChainId, CurrencyAmount> = {
parseUnits('0.05', Token.getNative(ChainId.ARBITRUM_RINKEBY).decimals).toString(),
ChainId.ARBITRUM_RINKEBY
),
[ChainId.ARBITRUM_GOERLI]: CurrencyAmount.nativeCurrency(
parseUnits('0.05', Token.getNative(ChainId.ARBITRUM_GOERLI).decimals).toString(),
ChainId.ARBITRUM_GOERLI
),
[ChainId.POLYGON]: CurrencyAmount.nativeCurrency(
parseUnits('0', Token.getNative(ChainId.POLYGON).decimals).toString(),
ChainId.POLYGON
Expand Down
1 change: 1 addition & 0 deletions src/entities/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class Currency {
[ChainId.RINKEBY]: Currency.ETHER,
[ChainId.ARBITRUM_ONE]: Currency.ETHER,
[ChainId.ARBITRUM_RINKEBY]: Currency.ETHER,
[ChainId.ARBITRUM_GOERLI]: Currency.ETHER,
[ChainId.XDAI]: Currency.XDAI,
[ChainId.POLYGON]: Currency.MATIC,
[ChainId.GOERLI]: Currency.ETHER,
Expand Down
1 change: 1 addition & 0 deletions src/entities/pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const INITIAL_CACHE_STATE: Record<ChainId, any> = {
[ChainId.RINKEBY]: {},
[ChainId.ARBITRUM_ONE]: {},
[ChainId.ARBITRUM_RINKEBY]: {},
[ChainId.ARBITRUM_GOERLI]: {},
[ChainId.XDAI]: {},
[ChainId.POLYGON]: {},
[ChainId.GOERLI]: {},
Expand Down
8 changes: 8 additions & 0 deletions src/entities/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export class Token extends Currency {
'WETH',
'Wrapped Ether'
),
[ChainId.ARBITRUM_GOERLI]: new Token(
ChainId.GOERLI,
'0x89C0DBbF7559E200443735e113039cE5f1e0e6F0',
18,
'WETH',
'Wrapped Ether on Görli'
),
[ChainId.XDAI]: new Token(
ChainId.XDAI,
'0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1',
Expand Down Expand Up @@ -133,6 +140,7 @@ export class Token extends Currency {
[ChainId.GOERLI]: Token.WETH[ChainId.GOERLI],
[ChainId.OPTIMISM_MAINNET]: Token.WETH[ChainId.OPTIMISM_MAINNET],
[ChainId.OPTIMISM_GOERLI]: Token.WETH[ChainId.OPTIMISM_MAINNET],
[ChainId.ARBITRUM_GOERLI]: Token.WETH[ChainId.ARBITRUM_GOERLI],
}

public constructor(chainId: ChainId, address: string, decimals: number, symbol?: string, name?: string) {
Expand Down
1 change: 1 addition & 0 deletions src/entities/trades/0x/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const ZEROX_API_URL: Record<ChainId, string> = {
[ChainId.RINKEBY]: '',
[ChainId.ARBITRUM_ONE]: '',
[ChainId.ARBITRUM_RINKEBY]: '',
[ChainId.ARBITRUM_GOERLI]: '',
[ChainId.XDAI]: '',
[ChainId.POLYGON]: 'https://polygon.api.0x.org/',
[ChainId.GOERLI]: '',
Expand Down
1 change: 1 addition & 0 deletions src/entities/trades/curve/pools/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ export const CURVE_POOLS: Record<ChainId, CurvePool[]> = {
// Empty
[ChainId.RINKEBY]: [],
[ChainId.ARBITRUM_RINKEBY]: [],
[ChainId.ARBITRUM_GOERLI]: [],
[ChainId.POLYGON]: [],
[ChainId.GOERLI]: [],
[ChainId.OPTIMISM_MAINNET]: [],
Expand Down
1 change: 1 addition & 0 deletions src/entities/trades/curve/tokens/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ export const CURVE_TOKENS: CurveTokenList = {
[ChainId.XDAI]: TOKENS_XDAI,
[ChainId.ARBITRUM_ONE]: TOKENS_ARBITRUM_ONE,
[ChainId.ARBITRUM_RINKEBY]: {},
[ChainId.ARBITRUM_GOERLI]: {},
[ChainId.RINKEBY]: {},
[ChainId.POLYGON]: {},
[ChainId.GOERLI]: {},
Expand Down
1 change: 1 addition & 0 deletions src/entities/trades/uniswap-v2/cache/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function createCacheList<T = any>(): GeneralCacheList<T> {
[ChainId.XDAI]: new Map(),
[ChainId.RINKEBY]: new Map(),
[ChainId.ARBITRUM_RINKEBY]: new Map(),
[ChainId.ARBITRUM_GOERLI]: new Map(),
[ChainId.POLYGON]: new Map(),
[ChainId.GOERLI]: new Map(),
[ChainId.OPTIMISM_MAINNET]: new Map(),
Expand Down
1 change: 1 addition & 0 deletions src/entities/trades/uniswap-v2/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
USDT[ChainId.ARBITRUM_ONE],
],
[ChainId.ARBITRUM_RINKEBY]: [WETH[ChainId.ARBITRUM_RINKEBY], DXD[ChainId.ARBITRUM_RINKEBY]],
[ChainId.ARBITRUM_GOERLI]: [WETH[ChainId.ARBITRUM_GOERLI]],
[ChainId.XDAI]: [
WXDAI[ChainId.XDAI],
WETH[ChainId.XDAI],
Expand Down
1 change: 1 addition & 0 deletions src/entities/trades/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const RPC_PROVIDER_LIST: Record<ChainId, string> = {
[ChainId.RINKEBY]: 'https://rinkeby.infura.io/v3/e1a3bfc40093494ca4f36b286ab36f2d',
[ChainId.ARBITRUM_ONE]: 'https://arb1.arbitrum.io/rpc',
[ChainId.ARBITRUM_RINKEBY]: 'https://rinkeby.arbitrum.io/rpc',
[ChainId.ARBITRUM_GOERLI]: 'https://goerli-rollup.arbitrum.io/rpc',
[ChainId.POLYGON]: 'https://polygon-rpc.com',
[ChainId.GOERLI]: 'https://goerli.infura.io/v3/e1a3bfc40093494ca4f36b286ab36f2d',
[ChainId.OPTIMISM_MAINNET]: 'https://mannet.optimism.io',
Expand Down

0 comments on commit ef903d4

Please sign in to comment.