Skip to content

Commit

Permalink
Merge pull request #294 from levelkdev/feature/arbitrum-mainnet-support
Browse files Browse the repository at this point in the history
Arbitrum mainnet and Rinkeby testnet support
  • Loading branch information
Federico Luzzi authored Jul 29, 2021
2 parents 4a5a73c + 2d719c4 commit d215b4d
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 237 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
"cross-env": "^7.0.2",
"cypress": "^4.11.0",
"decimal.js-light": "^2.5.1",
"dxswap-core": "git://github.com/levelkdev/dxswap-core.git#v0.3.7",
"dxswap-periphery": "git://github.com/levelkdev/dxswap-periphery.git#v0.3.8",
"dxswap-sdk": "git://github.com/levelkdev/dxswap-sdk.git#v0.8.5",
"dxswap-core": "git://github.com/levelkdev/dxswap-core.git#v0.3.9",
"dxswap-periphery": "git://github.com/levelkdev/dxswap-periphery.git#v0.3.10",
"dxswap-sdk": "git://github.com/levelkdev/dxswap-sdk.git#v0.9.3",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
Expand Down
8 changes: 8 additions & 0 deletions src/apollo/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@ export const subgraphClients: { [chainId in ChainId]?: ApolloClient<NormalizedCa
[ChainId.XDAI]: new ApolloClient({
uri: 'https://api.thegraph.com/subgraphs/name/luzzif/swapr-xdai',
cache: new InMemoryCache()
}),
[ChainId.ARBITRUM_ONE]: new ApolloClient({
uri: 'https://api.thegraph.com/subgraphs/name/luzzif/swapr-arbitrum-one',
cache: new InMemoryCache()
}),
[ChainId.ARBITRUM_RINKEBY]: new ApolloClient({
uri: 'https://api.thegraph.com/subgraphs/name/luzzif/swapr-arbitrum-rinkeby',
cache: new InMemoryCache()
})
}
Binary file removed src/assets/images/poa-logo.png
Binary file not shown.
5 changes: 2 additions & 3 deletions src/components/CurrencyLogo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Skeleton from 'react-loading-skeleton'
import styled from 'styled-components'

import EthereumLogo from '../../assets/images/ethereum-logo.png'
import PoaLogo from '../../assets/images/poa-logo.png'
import XDAILogo from '../../assets/images/xdai-logo.png'
import DXDLogo from '../../assets/svg/dxd.svg'
import { useActiveWeb3React } from '../../hooks'
Expand Down Expand Up @@ -49,10 +48,10 @@ const Wrapper = styled.div<{ size: string; marginRight: number; marginLeft: numb
`

const NATIVE_CURRENCY_LOGO: { [chainId in ChainId]: string } = {
[ChainId.ARBITRUM_TESTNET_V3]: EthereumLogo,
[ChainId.ARBITRUM_ONE]: EthereumLogo,
[ChainId.ARBITRUM_RINKEBY]: EthereumLogo,
[ChainId.MAINNET]: EthereumLogo,
[ChainId.RINKEBY]: EthereumLogo,
[ChainId.SOKOL]: PoaLogo,
[ChainId.XDAI]: XDAILogo
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function Footer() {
const [darkMode, toggleDarkMode] = useDarkModeManager()

return (
<FooterFrame>
<FooterFrame>
<ButtonSecondary onClick={toggleDarkMode} p="8px 12px" ml="0.5rem" width="min-content">
{darkMode ? <Sun size={16} /> : <Moon size={16} />}
</ButtonSecondary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Pair, Token, TokenAmount } from 'dxswap-sdk'
import React, { useCallback, useState } from 'react'
import { Box, Flex } from 'rebass'
import styled from 'styled-components'
import { useAllTokens } from '../../../../../hooks/Tokens'
import CurrencySearchModal from '../../../../SearchModal/CurrencySearchModal'
import PairSearchModal from '../../../../SearchModal/PairSearchModal'
import { Card, Divider } from '../../../styleds'
Expand Down Expand Up @@ -35,7 +34,6 @@ export default function PairAndReward({
}: PairAndRewardProps) {
const [pairSearchOpen, setPairSearchOpen] = useState<boolean>(false)
const [currencySearchOpen, setCurrencySearchOpen] = useState<boolean>(false)
const allTokens = useAllTokens()

const handleOpenPairSearch = useCallback(() => {
setPairSearchOpen(true)
Expand Down Expand Up @@ -67,17 +65,6 @@ export default function PairAndReward({
[onRewardTokenChange]
)

const filterPairs = useCallback(
(pair: Pair) => {
const adjustedTokens = Object.values(allTokens)
return (
adjustedTokens.some(token => token.equals(pair.token0)) &&
adjustedTokens.some(token => token.equals(pair.token1))
)
},
[allTokens]
)

return (
<>
<Card>
Expand All @@ -103,7 +90,6 @@ export default function PairAndReward({
onDismiss={handleDismissPairSearch}
onPairSelect={handlePairSelection}
selectedPair={liquidityPair}
filterPairs={filterPairs}
/>
<CurrencySearchModal
isOpen={currencySearchOpen}
Expand Down
6 changes: 2 additions & 4 deletions src/components/NetworkSwitcherPopover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ export default function NetworkSwitcherPopover({ children }: { children: ReactNo
/>
<Option
onClick={() => {
selectNetwork(ChainId.ARBITRUM_TESTNET_V3)
selectNetwork(ChainId.ARBITRUM_ONE)
}}
header={'Arbitrum'}
header={'Arbitrum one'}
logoSrc={ArbitrumLogo}
disabled={true}
clickable={false}
/>
</OptionGrid>
}
Expand Down
13 changes: 7 additions & 6 deletions src/components/Web3Status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ import ArbitrumLogo from '../../assets/images/arbitrum-logo.jpg'
import { ChainId } from 'dxswap-sdk'
import { useActiveWeb3React } from '../../hooks'

const ChainLogo: any = {
const ChainLogo: { [chainId in ChainId]: string } = {
[ChainId.MAINNET]: EthereumLogo,
[ChainId.RINKEBY]: EthereumLogo,
[ChainId.ARBITRUM_TESTNET_V3]: ArbitrumLogo,
[ChainId.SOKOL]: '',
[ChainId.ARBITRUM_ONE]: ArbitrumLogo,
[ChainId.ARBITRUM_RINKEBY]: ArbitrumLogo,
[ChainId.XDAI]: XDAILogo
}

const ChainLabel: any = {
const ChainLabel: { [chainId in ChainId]: string } = {
[ChainId.MAINNET]: 'Ethereum',
[ChainId.RINKEBY]: 'Rinkeby',
[ChainId.ARBITRUM_TESTNET_V3]: 'Arbitrum',
[ChainId.SOKOL]: 'Sokol',
[ChainId.ARBITRUM_ONE]: 'Arbitrum One',
[ChainId.ARBITRUM_RINKEBY]: 'Arbitrum RInkeby',
[ChainId.XDAI]: 'xDai'
}

Expand All @@ -46,6 +46,7 @@ const IconWrapper = styled.div<{ size?: number | null }>`
justify-content: center;
& > img,
span {
border-radius: ${props => (props.size ? props.size / 2 : 15)}px;
height: ${({ size }) => (size ? size + 'px' : '30px')};
}
${({ theme }) => theme.mediaWidth.upToMedium`
Expand Down
6 changes: 4 additions & 2 deletions src/connectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ export const INFURA_PROJECT_ID = '0ebf4dd05d6740f482938b8a80860d13'
export const network = new CustomNetworkConnector({
urls: {
[ChainId.MAINNET]: `https://mainnet.infura.io/v3/${INFURA_PROJECT_ID}`,
[ChainId.XDAI]: 'https://rpc.xdaichain.com/'
[ChainId.XDAI]: 'https://rpc.xdaichain.com/',
[ChainId.ARBITRUM_ONE]: 'https://arb1.arbitrum.io/rpc',
[ChainId.ARBITRUM_RINKEBY]: 'https://rinkeby.arbitrum.io/rpc'
},
defaultChainId: ChainId.MAINNET
})

export const injected = new InjectedConnector({
supportedChainIds: [ChainId.MAINNET, ChainId.RINKEBY, ChainId.ARBITRUM_TESTNET_V3, ChainId.SOKOL, ChainId.XDAI]
supportedChainIds: [ChainId.MAINNET, ChainId.RINKEBY, ChainId.ARBITRUM_ONE, ChainId.ARBITRUM_RINKEBY, ChainId.XDAI]
})

// mainnet only
Expand Down
40 changes: 20 additions & 20 deletions src/constants/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import React, { ReactNode } from 'react'
import { AbstractConnector } from '@web3-react/abstract-connector'
import {
ChainId,
JSBI,
Percent,
CurrencyAmount,
WETH,
WSPOA,
DXD,
WXDAI,
Token,
Currency,
RoutablePlatform
} from 'dxswap-sdk'
import { ChainId, JSBI, Percent, CurrencyAmount, WETH, DXD, WXDAI, Token, Currency, RoutablePlatform } from 'dxswap-sdk'
import { authereum, injected, walletConnect } from '../connectors'
import UniswapLogo from '../assets/svg/uniswap-logo.svg'
import SwaprLogo from '../assets/svg/logo.svg'
Expand Down Expand Up @@ -100,8 +88,8 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
USDT[ChainId.MAINNET]
],
[ChainId.RINKEBY]: [WETH[ChainId.RINKEBY]],
[ChainId.ARBITRUM_TESTNET_V3]: [WETH[ChainId.ARBITRUM_TESTNET_V3]],
[ChainId.SOKOL]: [WSPOA[ChainId.SOKOL]],
[ChainId.ARBITRUM_ONE]: [WETH[ChainId.ARBITRUM_ONE], DXD[ChainId.ARBITRUM_ONE]],
[ChainId.ARBITRUM_RINKEBY]: [WETH[ChainId.ARBITRUM_RINKEBY], DXD[ChainId.ARBITRUM_RINKEBY]],
[ChainId.XDAI]: [
WXDAI[ChainId.XDAI],
WETH[ChainId.XDAI],
Expand All @@ -121,17 +109,17 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
export const SUGGESTED_BASES: ChainTokenList = {
[ChainId.MAINNET]: [DXD[ChainId.MAINNET], DAI, USDC[ChainId.MAINNET], USDT[ChainId.MAINNET], WBTC[ChainId.MAINNET]],
[ChainId.RINKEBY]: [],
[ChainId.ARBITRUM_TESTNET_V3]: [],
[ChainId.SOKOL]: [],
[ChainId.ARBITRUM_ONE]: [WETH[ChainId.ARBITRUM_ONE], DXD[ChainId.ARBITRUM_ONE]],
[ChainId.ARBITRUM_RINKEBY]: [WETH[ChainId.ARBITRUM_RINKEBY], DXD[ChainId.ARBITRUM_RINKEBY]],
[ChainId.XDAI]: [DXD[ChainId.XDAI], WETH[ChainId.XDAI], USDC[ChainId.XDAI]]
}

// used to construct the list of all pairs we consider by default in the frontend
export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = {
[ChainId.MAINNET]: [WETH[ChainId.MAINNET], DXD[ChainId.MAINNET], DAI, USDC[ChainId.MAINNET], USDT[ChainId.MAINNET]],
[ChainId.RINKEBY]: [WETH[ChainId.RINKEBY]],
[ChainId.ARBITRUM_TESTNET_V3]: [WETH[ChainId.ARBITRUM_TESTNET_V3]],
[ChainId.SOKOL]: [Token.WSPOA[ChainId.SOKOL]],
[ChainId.ARBITRUM_ONE]: [WETH[ChainId.ARBITRUM_ONE], DXD[ChainId.ARBITRUM_ONE]],
[ChainId.ARBITRUM_RINKEBY]: [WETH[ChainId.ARBITRUM_RINKEBY], DXD[ChainId.ARBITRUM_RINKEBY]],
[ChainId.XDAI]: [WXDAI[ChainId.XDAI], DXD[ChainId.XDAI], WETH[ChainId.XDAI], USDC[ChainId.XDAI], STAKE]
}

Expand Down Expand Up @@ -217,7 +205,7 @@ export const BLOCKED_PRICE_IMPACT_NON_EXPERT: Percent = new Percent(JSBI.BigInt(
// used to ensure the user doesn't send so much ETH so they end up with <.01
export const MIN_ETH: JSBI = JSBI.exponentiate(JSBI.BigInt(10), JSBI.BigInt(16)) // .01 ETH

export const DEFAULT_TOKEN_LIST = 'https://bafybeiehsfbbppkaq23rau7ikxmmwjca2l5u524th2thuiarg2tcz6anna.ipfs.dweb.link/'
export const DEFAULT_TOKEN_LIST = 'ipfs://QmeCv4FhDPXRCcG1odeaFyEqrfKe8DGjaprT8BeTurYY51'

export const ZERO_USD = CurrencyAmount.usd('0')

Expand Down Expand Up @@ -258,6 +246,18 @@ export const NETWORK_DETAIL: { [chainId: number]: NetworkDetails } = {
rpcUrls: ['https://rpc.xdaichain.com/'],
blockExplorerUrls: ['https://blockscout.com/xdai/mainnet'],
metamaskAddable: true
},
[ChainId.ARBITRUM_ONE]: {
chainId: `0x${ChainId.ARBITRUM_ONE.toString(16)}`,
chainName: 'Arbitrum one',
nativeCurrency: {
name: Currency.ETHER.name || 'Ether',
symbol: Currency.ETHER.symbol || 'ETH',
decimals: Currency.ETHER.decimals || 18
},
rpcUrls: ['https://arb1.arbitrum.io/rpc/'],
blockExplorerUrls: ['https://explorer.arbitrum.io/'],
metamaskAddable: true
}
}

Expand Down
143 changes: 0 additions & 143 deletions src/constants/multicall/abi.json

This file was deleted.

Loading

0 comments on commit d215b4d

Please sign in to comment.