Skip to content

Commit

Permalink
feat: arbitrum nova
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewlilley committed Aug 9, 2022
1 parent f5aa5a5 commit 3df11ea
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 58 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@
"@sentry/nextjs": "^7.0.0",
"@sentry/react": "^7.0.0",
"@sentry/tracing": "^7.0.0",
"@sushiswap/bentobox-sdk": "1.0.0-canary.109",
"@sushiswap/bentobox-sdk": "1.0.0-canary.112",
"@sushiswap/chainlink-whitelist": "0.2.8",
"@sushiswap/core": "^2.0.0-canary.1",
"@sushiswap/core-sdk": "1.0.0-canary.128",
"@sushiswap/kashi-sdk": "1.0.0-canary.100",
"@sushiswap/core-sdk": "1.0.0-canary.131",
"@sushiswap/kashi-sdk": "1.0.0-canary.103",
"@sushiswap/limit-order-pair-list": "0.2.17",
"@sushiswap/limit-order-sdk": "1.0.0-canary.109",
"@sushiswap/limit-order-sdk": "1.0.0-canary.112",
"@sushiswap/miso": "1.0.0-canary.47",
"@sushiswap/miso-sdk": "1.0.0-canary.98",
"@sushiswap/miso-sdk": "1.0.0-canary.101",
"@sushiswap/trident": "^1.0.0-canary.40",
"@sushiswap/trident-sdk": "1.0.0-canary.137",
"@sushiswap/trident-sdk": "1.0.0-canary.140",
"@testing-library/jest-dom": "^5.14.0",
"@testing-library/react": "^12.1.0",
"@transak/transak-sdk": "^1.0.31",
Expand Down
2 changes: 2 additions & 0 deletions src/components/CurrencyLogo/CurrencyLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const BLOCKCHAIN = {
[ChainId.MOONBEAM]: 'moonbeam',
[ChainId.KAVA]: 'kava',
[ChainId.METIS]: 'metis',
[ChainId.ARBITRUM_NOVA]: 'arbitrum-nova',
[ChainId.HARDHAT]: 'hardhat',
}

Expand Down Expand Up @@ -116,6 +117,7 @@ const LOGO: Record<ChainId, string> = {
[ChainId.OPTIMISM]: EthereumLogo,
[ChainId.KAVA]: KavaLogo,
[ChainId.METIS]: MetisLogo,
[ChainId.ARBITRUM_NOVA]: EthereumLogo,
}

export interface CurrencyLogoProps {
Expand Down
1 change: 1 addition & 0 deletions src/config/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const features: FeatureMap = {
[ChainId.OPTIMISM]: [Feature.TRIDENT, Feature.BENTOBOX],
[ChainId.KAVA]: [Feature.TRIDENT, Feature.BENTOBOX, Feature.LIQUIDITY_MINING],
[ChainId.METIS]: [Feature.TRIDENT, Feature.BENTOBOX, Feature.LIQUIDITY_MINING],
[ChainId.ARBITRUM_NOVA]: [Feature.AMM],
}

export default features
2 changes: 2 additions & 0 deletions src/config/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const NETWORK_ICON: Record<number, string> = {
[ChainId.OPTIMISM]: Optimism,
[ChainId.KAVA]: Kava,
[ChainId.METIS]: Metis,
[ChainId.ARBITRUM_NOVA]: Arbitrum,
}

export const NETWORK_LABEL: Record<number, string> = {
Expand Down Expand Up @@ -93,4 +94,5 @@ export const NETWORK_LABEL: Record<number, string> = {
[ChainId.OPTIMISM]: 'Optimism',
[ChainId.KAVA]: 'Kava',
[ChainId.METIS]: 'Metis',
[ChainId.ARBITRUM_NOVA]: 'Arbitrum Nova',
}
24 changes: 24 additions & 0 deletions src/config/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ChainId, SUSHI, Token, WNATIVE } from '@sushiswap/core-sdk'

import * as ARBITRUM from './tokens/arbitrum'
import * as ARBITRUM_NOVA from './tokens/arbitrum-nova'
import * as AVALANCHE from './tokens/avalanche'
import * as BSC from './tokens/bsc'
import * as CELO from './tokens/celo'
Expand All @@ -20,6 +21,7 @@ import * as OPTIMISM from './tokens/optimism'
import * as PALM from './tokens/palm'
import * as TELOS from './tokens/telos'
import * as XDAI from './tokens/xdai'

type ChainTokenList = {
readonly [chainId: number]: Token[]
}
Expand Down Expand Up @@ -78,6 +80,7 @@ const WRAPPED_NATIVE_ONLY: ChainTokenList = {
[ChainId.OPTIMISM]: [WNATIVE[ChainId.OPTIMISM]],
[ChainId.KAVA]: [WNATIVE[ChainId.KAVA]],
[ChainId.METIS]: [WNATIVE[ChainId.METIS]],
[ChainId.ARBITRUM_NOVA]: [WNATIVE[ChainId.ARBITRUM_NOVA]],
}

// used to construct intermediary pairs for trading
Expand Down Expand Up @@ -246,6 +249,13 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
],
[ChainId.KAVA]: [...WRAPPED_NATIVE_ONLY[ChainId.KAVA], KAVA.USDC, KAVA.USDT, KAVA.WETH, KAVA.WBTC, KAVA.DAI],
[ChainId.METIS]: [...WRAPPED_NATIVE_ONLY[ChainId.METIS], METIS.USDC, METIS.USDT, METIS.WETH, METIS.DAI, METIS.WBTC],
[ChainId.ARBITRUM_NOVA]: [
...WRAPPED_NATIVE_ONLY[ChainId.ARBITRUM_NOVA],
ARBITRUM_NOVA.USDC,
ARBITRUM_NOVA.USDT,
ARBITRUM_NOVA.DAI,
ARBITRUM_NOVA.WBTC,
],
}

export const ADDITIONAL_BASES: {
Expand Down Expand Up @@ -643,6 +653,13 @@ export const COMMON_BASES: ChainTokenList = {
],
[ChainId.KAVA]: [...WRAPPED_NATIVE_ONLY[ChainId.KAVA], KAVA.USDC, KAVA.USDT, KAVA.WETH, KAVA.WBTC, KAVA.DAI],
[ChainId.METIS]: [...WRAPPED_NATIVE_ONLY[ChainId.METIS], METIS.USDC, METIS.USDT, METIS.WETH, METIS.DAI, METIS.WBTC],
[ChainId.ARBITRUM_NOVA]: [
...WRAPPED_NATIVE_ONLY[ChainId.ARBITRUM_NOVA],
ARBITRUM_NOVA.USDC,
ARBITRUM_NOVA.USDT,
ARBITRUM_NOVA.DAI,
ARBITRUM_NOVA.WBTC,
],
}

// used to construct the list of all pairs we consider by default in the frontend
Expand Down Expand Up @@ -792,6 +809,13 @@ export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = {
],
[ChainId.KAVA]: [...WRAPPED_NATIVE_ONLY[ChainId.KAVA], KAVA.USDC, KAVA.USDT, KAVA.WETH, KAVA.WBTC, KAVA.DAI],
[ChainId.METIS]: [...WRAPPED_NATIVE_ONLY[ChainId.METIS], METIS.USDC, METIS.USDT, METIS.WETH, METIS.DAI, METIS.WBTC],
[ChainId.ARBITRUM_NOVA]: [
...WRAPPED_NATIVE_ONLY[ChainId.ARBITRUM_NOVA],
ARBITRUM_NOVA.USDC,
ARBITRUM_NOVA.USDT,
ARBITRUM_NOVA.DAI,
ARBITRUM_NOVA.WBTC,
],
}

export const PINNED_PAIRS: { readonly [chainId: number]: [Token, Token][] } = {
Expand Down
1 change: 1 addition & 0 deletions src/config/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const RPC = {
[ChainId.OPTIMISM]: 'https://mainnet.optimism.io',
[ChainId.KAVA]: 'https://evm.kava.io',
[ChainId.METIS]: 'https://andromeda.metis.io/?owner=1088',
[ChainId.ARBITRUM_NOVA]: 'https://a4ba.arbitrum.io/rpc',
}

export default RPC
8 changes: 3 additions & 5 deletions src/config/token-lists.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const BA_LIST = 'https://raw.githubusercontent.com/The-Blockchain-Association/sec-notice-list/master/ba-sec-list.json'
const YEARN_LIST = 'https://yearn.science/static/tokenlist.json'
const NFTX_LIST = 'https://nftx.ethereumdb.com/v2/tokenlist/'
const NFTX_LIST = 'https://tokenlist.nftx.io'
const SYNTHETIX_LIST = 'synths.snx.eth'
const AAVE_LIST = 'tokenlist.aave.eth'
const CMC_ALL_LIST = 'https://api.coinmarketcap.com/data-api/v3/uniswap/all.json'
Expand All @@ -27,10 +26,9 @@ const DEFAULT_LIST_OF_LISTS_TO_DISPLAY: string[] = [
CHAINLINK_LIST,
COMPOUND_LIST,
AAVE_LIST,
CMC_ALL_LIST,
// CMC_ALL_LIST,
COINGECKO_LIST,
UMA_LIST,
YEARN_LIST,
// UMA_LIST,
SYNTHETIX_LIST,
KLEROS_LIST,
GEMINI_LIST,
Expand Down
30 changes: 30 additions & 0 deletions src/config/tokens/arbitrum-nova.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ChainId, Token } from '@sushiswap/core-sdk'

export const USDC = new Token(
ChainId.ARBITRUM_NOVA,
'0x750ba8b76187092B0D1E87E28daaf484d1b5273b',
6,
'USDC',
'USD Coin'
)
export const WBTC = new Token(
ChainId.ARBITRUM_NOVA,
'0x1d05e4e72cD994cdF976181CfB0707345763564d',
8,
'WBTC',
'Wrapped Bitcoin'
)
export const USDT = new Token(
ChainId.ARBITRUM_NOVA,
'0x52484E1ab2e2B22420a25c20FA49E173a26202Cd',
8,
'USDT',
'Tether USD'
)
export const DAI = new Token(
ChainId.ARBITRUM_NOVA,
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
18,
'DAI',
'Dai Stablecoin'
)
1 change: 1 addition & 0 deletions src/enums/ChainSubdomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export enum ChainSubdomain {
FUSE = 'fuse',
TELOS = 'telos',
MOONBEAM = 'moonbeam',
ARBITRUM_NOVA = 'arbitrum-nova',
}
28 changes: 17 additions & 11 deletions src/features/trade/HeaderNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { Currency } from '@sushiswap/core-sdk'
import NavLink from 'app/components/NavLink'
import Settings from 'app/components/Settings'
import Typography from 'app/components/Typography'
import { Feature } from 'app/enums'
import MyOrders from 'app/features/legacy/limit-order/MyOrders'
import { featureEnabled } from 'app/functions'
import { useActiveWeb3React } from 'app/services/web3'
import { useRouter } from 'next/router'
import React, { FC } from 'react'

Expand All @@ -27,6 +30,7 @@ interface HeaderNewProps {
}

const HeaderNew: FC<HeaderNewProps> = ({ inputCurrency, outputCurrency, trident = false }) => {
const { chainId } = useActiveWeb3React()
const { i18n } = useLingui()
const { asPath } = useRouter()
const isLimitOrder = asPath.startsWith('/limit-order')
Expand All @@ -45,17 +49,19 @@ const HeaderNew: FC<HeaderNewProps> = ({ inputCurrency, outputCurrency, trident
{i18n._(t`Swap`)}
</Typography>
</NavLink>
<NavLink
activeClassName="text-high-emphesis"
href={{
pathname: '/limit-order',
query: getQuery(inputCurrency, outputCurrency),
}}
>
<Typography weight={700} className="text-secondary hover:text-white">
{i18n._(t`Limit`)}
</Typography>
</NavLink>
{featureEnabled(Feature.LIMIT_ORDERS, chainId) ? (
<NavLink
activeClassName="text-high-emphesis"
href={{
pathname: '/limit-order',
query: getQuery(inputCurrency, outputCurrency),
}}
>
<Typography weight={700} className="text-secondary hover:text-white">
{i18n._(t`Limit`)}
</Typography>
</NavLink>
) : null}
</div>
<div className="flex gap-4">
{isLimitOrder && <MyOrders />}
Expand Down
4 changes: 4 additions & 0 deletions src/functions/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ const chains: ChainObject = {
link: 'https://andromeda-explorer.metis.io/',
builder: explorers.blockscout,
},
[ChainId.ARBITRUM_NOVA]: {
link: 'https://nova-explorer.arbitrum.io/',
builder: explorers.blockscout,
},
}

export function getExplorerLink(
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ const MULTICALL_ADDRESS = {
[ChainId.PALM]: '0x4d4A0D45a98AE8EC25b359D93A088A87BC9eF70b',
[ChainId.KAVA]: '0x67dA5f2FfaDDfF067AB9d5F025F8810634d84287',
[ChainId.METIS]: '0x67dA5f2FfaDDfF067AB9d5F025F8810634d84287',
[ChainId.ARBITRUM_NOVA]: '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F',
}

export function useInterfaceMulticall(): Contract | null | undefined {
Expand Down
1 change: 1 addition & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const SUBDOMAIN_CHAIN_ID: { [subdomain: string]: string } = {
[ChainSubdomain.FUSE]: '122',
[ChainSubdomain.TELOS]: '40',
[ChainSubdomain.MOONBEAM]: '1284',
[ChainSubdomain.ARBITRUM_NOVA]: '42170',
}

const DEFAULT_CHAIN_ID = '1'
Expand Down
12 changes: 12 additions & 0 deletions src/modals/NetworkModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,17 @@ export const SUPPORTED_NETWORKS: Record<
rpcUrls: ['https://andromeda.metis.io/?owner=1088'],
blockExplorerUrls: ['https://andromeda-explorer.metis.io/'],
},
[ChainId.ARBITRUM_NOVA]: {
chainId: '0xA4BA',
chainName: 'Arbitrum Nova',
nativeCurrency: {
name: 'Ether',
symbol: 'ETH',
decimals: 18,
},
rpcUrls: ['https://nova.arbitrum.io/rpc '],
blockExplorerUrls: ['https://nova-explorer.arbitrum.io/'],
},
}

const NetworkModal: FC<{ switchNetwork: (targetChain: number) => void }> = ({ switchNetwork }) => {
Expand All @@ -301,6 +312,7 @@ const NetworkModal: FC<{ switchNetwork: (targetChain: number) => void }> = ({ sw
{[
ChainId.ETHEREUM,
ChainId.ARBITRUM,
ChainId.ARBITRUM_NOVA,
ChainId.MATIC,
ChainId.XDAI,
ChainId.FANTOM,
Expand Down
3 changes: 2 additions & 1 deletion src/pages/legacy/swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const Swap = ({ banners }: SwapProps) => {
const { i18n } = useLingui()

const loadedUrlParams = useDefaultsFromURLSearch()
const { account } = useActiveWeb3React()
const { account, chainId } = useActiveWeb3React()

const defaultTokens = useAllTokens()

const [isExpertMode] = useExpertModeManager()
Expand Down
2 changes: 1 addition & 1 deletion src/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PERSISTED_KEYS: string[] = ['user', 'transactions', 'lists', 'slippage']
const persistConfig = {
key: 'root',
whitelist: PERSISTED_KEYS,
version: 4,
version: 5,
storage,
migrate: createMigrate(migrations, { debug: process.env.NODE_ENV === 'development' }),
}
Expand Down
7 changes: 7 additions & 0 deletions src/state/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ const migrations = {
lists: initialListsState,
}
},
// @ts-ignore
5: (state) => {
return {
...state,
lists: initialListsState,
}
},
}

export default migrations
Loading

0 comments on commit 3df11ea

Please sign in to comment.