Skip to content

Commit

Permalink
* feat(SWA-129): add Scroll chain support (#1902)
Browse files Browse the repository at this point in the history
* feat(SWA-129): add Scroll chain info to the dapp
* feat(SWA-129): increase swap price impact filtering from less than 1% to less than 5%
  • Loading branch information
ElRodrigote authored Feb 2, 2024
1 parent 87b93e3 commit 6460f0e
Show file tree
Hide file tree
Showing 17 changed files with 706 additions and 642 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@reduxjs/toolkit": "^1.9.5",
"@swapr/core": "^0.3.19",
"@swapr/periphery": "^0.3.22",
"@swapr/sdk": "1.10.5",
"@swapr/sdk": "1.11.0",
"@tanstack/react-query": "4.24.6",
"@uniswap/token-lists": "^1.0.0-beta.27",
"@uniswap/v3-periphery": "1.4.1",
Expand Down
35 changes: 34 additions & 1 deletion src/analytics/generated/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ export type FathomRegisteredEventName =
| 'undefined-324/ecoRouter/1inch/volumeUSD'
| 'undefined-324/ecoRouter/1inch/volumeUSD/pro'
| 'bsc-56/ecoRouter/biswap/volumeUSD/pro'
| 'gnosis-100/ecoRouter/sushiswap/volumeUSD'
| 'optimism-10/ecoRouter/sushiswap/volumeUSD'
| 'gnosis-100/ecoRouter/sushiswap/volumeUSD/pro'
| 'optimism-10/ecoRouter/sushiswap/volumeUSD/pro'
| 'undefined'
export type FathomRegisteredNetworkName =
| 'ethereum'
| 'rinkeby'
Expand Down Expand Up @@ -1699,8 +1704,36 @@ export const siteEvents: FathomSiteInformation = {
currency: null,
created_at: '2023-06-20 14:52:02',
},
{
id: '2BRDLVOG',
object: 'event',
name: 'gnosis-100/ecoRouter/sushiswap/volumeUSD',
currency: null,
created_at: '2024-01-25 20:43:16',
},
{
id: 'WSDDMCY3',
object: 'event',
name: 'optimism-10/ecoRouter/sushiswap/volumeUSD',
currency: null,
created_at: '2024-01-25 20:43:16',
},
{
id: 'EM0SJT3A',
object: 'event',
name: 'gnosis-100/ecoRouter/sushiswap/volumeUSD/pro',
currency: null,
created_at: '2024-01-25 20:43:17',
},
{
id: 'LPBAST5C',
object: 'event',
name: 'optimism-10/ecoRouter/sushiswap/volumeUSD/pro',
currency: null,
created_at: '2024-01-25 20:43:17',
},
],
timestamp: '2023-06-20T17:55:12.893Z',
timestamp: '2024-01-25T20:50:58.718Z',
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/analytics/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export function getProModeEventNameByChainId(chainId?: ChainId): string {
[ChainId.GNOSIS]: 'proMode/gnosis/15seconds',
[ChainId.RINKEBY]: 'proMode/rinkbey/15seconds',
[ChainId.ARBITRUM_ONE]: 'proMode/arbitrum/15seconds',
[ChainId.OPTIMISM_MAINNET]: 'proMode/optimism/15seconds',
[ChainId.POLYGON]: 'proMode/polygon/15seconds',
[ChainId.ARBITRUM_GOERLI]: 'proMode/arbitrum-goerli/15seconds',
[ChainId.ARBITRUM_RINKEBY]: 'proMode/arbitrum-rinkeby/15seconds',
[ChainId.BSC_MAINNET]: 'proMode/bsc/15seconds',
[ChainId.BSC_TESTNET]: 'proMode/bsc-testnet/15seconds',
[ChainId.OPTIMISM_MAINNET]: 'proMode/optimism/15seconds',
[ChainId.OPTIMISM_GOERLI]: 'proMode/optimism-goerli/15seconds',
[ChainId.SCROLL_MAINNET]: 'proMode/scroll/15seconds',
[ChainId.ZK_SYNC_ERA_MAINNET]: 'proMode/zksync/15seconds',
[ChainId.ZK_SYNC_ERA_TESTNET]: 'proMode/zksync-testnet/15seconds',
}[chainId]
Expand Down
54 changes: 28 additions & 26 deletions src/apollo/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import { GraphQLClient } from 'graphql-request'
import { SWPRSupportedChains } from '../utils/chainSupportsSWPR'

export const subgraphClientsUris: { [chainId in SWPRSupportedChains]: string } = {
[ChainId.MAINNET]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-mainnet-v2',
[ChainId.ARBITRUM_GOERLI]: '', // FIXME: fix this once the subgraph is deployed
[ChainId.ARBITRUM_RINKEBY]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-arbitrum-rinkeby-v2',
[ChainId.ARBITRUM_ONE]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-arbitrum-one-v3',
[ChainId.XDAI]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-xdai-v2',
[ChainId.RINKEBY]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-rinkeby',
[ChainId.GOERLI]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-goerli',
[ChainId.ARBITRUM_RINKEBY]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-arbitrum-rinkeby-v2',
[ChainId.ARBITRUM_GOERLI]: '', // FIXME: fix this once the subgraph is deployed
[ChainId.MAINNET]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-mainnet-v2',
[ChainId.RINKEBY]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-rinkeby',
[ChainId.SCROLL_MAINNET]: '', // FIXME: fix this once the subgraph is deployed
[ChainId.XDAI]: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-xdai-v2',
}

const setupApolloClient = (network: SWPRSupportedChains) =>
Expand All @@ -26,24 +27,25 @@ export const defaultSubgraphClient = setupApolloClient(ChainId.MAINNET)
export const subgraphClients: {
[chainId in SWPRSupportedChains]: ApolloClient<NormalizedCacheObject>
} = {
[ChainId.MAINNET]: defaultSubgraphClient,
[ChainId.XDAI]: setupApolloClient(ChainId.XDAI),
[ChainId.ARBITRUM_GOERLI]: setupApolloClient(ChainId.ARBITRUM_GOERLI), // FIXME: fix this once the subgraph is deployed
[ChainId.ARBITRUM_ONE]: setupApolloClient(ChainId.ARBITRUM_ONE),
// testnets
[ChainId.RINKEBY]: setupApolloClient(ChainId.RINKEBY),
[ChainId.GOERLI]: setupApolloClient(ChainId.GOERLI),
[ChainId.ARBITRUM_RINKEBY]: setupApolloClient(ChainId.ARBITRUM_RINKEBY),
[ChainId.ARBITRUM_GOERLI]: setupApolloClient(ChainId.ARBITRUM_GOERLI), // FIXME: fix this once the subgraph is deployed
[ChainId.GOERLI]: setupApolloClient(ChainId.GOERLI),
[ChainId.MAINNET]: defaultSubgraphClient,
[ChainId.RINKEBY]: setupApolloClient(ChainId.RINKEBY),
[ChainId.SCROLL_MAINNET]: setupApolloClient(ChainId.SCROLL_MAINNET), // FIXME: fix this once the subgraph is deployed
[ChainId.XDAI]: setupApolloClient(ChainId.XDAI),
}

export const immediateSubgraphClients: { [chainId in SWPRSupportedChains]: GraphQLClient } = {
[ChainId.ARBITRUM_GOERLI]: new GraphQLClient(subgraphClientsUris[ChainId.ARBITRUM_GOERLI]), // FIXME: fix this once the subgraph is deployed
[ChainId.ARBITRUM_ONE]: new GraphQLClient(subgraphClientsUris[ChainId.ARBITRUM_ONE]),
[ChainId.ARBITRUM_RINKEBY]: new GraphQLClient(subgraphClientsUris[ChainId.ARBITRUM_RINKEBY]),
[ChainId.GOERLI]: new GraphQLClient(subgraphClientsUris[ChainId.GOERLI]),
[ChainId.MAINNET]: new GraphQLClient(subgraphClientsUris[ChainId.MAINNET]),
[ChainId.RINKEBY]: new GraphQLClient(subgraphClientsUris[ChainId.RINKEBY]),
[ChainId.GOERLI]: new GraphQLClient(subgraphClientsUris[ChainId.GOERLI]),
[ChainId.SCROLL_MAINNET]: new GraphQLClient(subgraphClientsUris[ChainId.SCROLL_MAINNET]), // FIXME: fix this once the subgraph is deployed
[ChainId.XDAI]: new GraphQLClient(subgraphClientsUris[ChainId.XDAI]),
[ChainId.ARBITRUM_ONE]: new GraphQLClient(subgraphClientsUris[ChainId.ARBITRUM_ONE]),
[ChainId.ARBITRUM_RINKEBY]: new GraphQLClient(subgraphClientsUris[ChainId.ARBITRUM_RINKEBY]),
[ChainId.ARBITRUM_GOERLI]: new GraphQLClient(subgraphClientsUris[ChainId.ARBITRUM_GOERLI]), // FIXME: fix this once the subgraph is deployed
}

export const immediateCarrotSubgraphClients: { [chainId: number]: GraphQLClient } = {
Expand All @@ -63,14 +65,14 @@ export const carrotSubgraphClient: { [chainId: number]: ApolloClient<NormalizedC
}

export const subgraphBlocksClientsUris: { [chainId in SWPRSupportedChains]: string } = {
[ChainId.MAINNET]: 'https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks',
[ChainId.ARBITRUM_GOERLI]: '', // FIXME: fix this once the subgraph is deployed
[ChainId.ARBITRUM_ONE]: 'https://api.thegraph.com/subgraphs/name/dodoex/arbitrum-one-blocks',
[ChainId.ARBITRUM_RINKEBY]: 'https://api.thegraph.com/subgraphs/name/dodoex/arbitrum-one-blocks',
[ChainId.GNOSIS]: 'https://api.thegraph.com/subgraphs/name/1hive/xdai-blocks',
// testnests
[ChainId.RINKEBY]: 'https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks',
[ChainId.GOERLI]: 'https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks',
[ChainId.ARBITRUM_RINKEBY]: 'https://api.thegraph.com/subgraphs/name/dodoex/arbitrum-one-blocks',
[ChainId.ARBITRUM_GOERLI]: '', // FIXME: fix this once the subgraph is deployed
[ChainId.MAINNET]: 'https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks',
[ChainId.RINKEBY]: 'https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks',
[ChainId.SCROLL_MAINNET]: '', // FIXME: fix this once the subgraph is deployed
}

export const subgraphPriceClientsUris: { [chainId: number]: string } = {
Expand All @@ -88,14 +90,14 @@ const setupBlocksApolloClient = (network: SWPRSupportedChains) =>
export const subgraphBlocksClients: {
[chainId in SWPRSupportedChains]: ApolloClient<NormalizedCacheObject>
} = {
[ChainId.MAINNET]: setupBlocksApolloClient(ChainId.MAINNET),
[ChainId.XDAI]: setupBlocksApolloClient(ChainId.XDAI),
[ChainId.ARBITRUM_GOERLI]: setupBlocksApolloClient(ChainId.ARBITRUM_GOERLI), // FIXME: fix this once the subgraph is deployed
[ChainId.ARBITRUM_RINKEBY]: setupBlocksApolloClient(ChainId.ARBITRUM_RINKEBY),
[ChainId.ARBITRUM_ONE]: setupBlocksApolloClient(ChainId.ARBITRUM_ONE),
// testnets
[ChainId.RINKEBY]: setupBlocksApolloClient(ChainId.RINKEBY),
[ChainId.GOERLI]: setupBlocksApolloClient(ChainId.GOERLI),
[ChainId.ARBITRUM_RINKEBY]: setupBlocksApolloClient(ChainId.ARBITRUM_RINKEBY),
[ChainId.ARBITRUM_GOERLI]: setupBlocksApolloClient(ChainId.ARBITRUM_GOERLI), // FIXME: fix this once the subgraph is deployed
[ChainId.MAINNET]: setupBlocksApolloClient(ChainId.MAINNET),
[ChainId.RINKEBY]: setupBlocksApolloClient(ChainId.RINKEBY),
[ChainId.SCROLL_MAINNET]: setupBlocksApolloClient(ChainId.SCROLL_MAINNET), // FIXME: fix this once the subgraph is deployed
[ChainId.XDAI]: setupBlocksApolloClient(ChainId.XDAI),
}

const setupBaseApolloClient = (uri: string) =>
Expand Down
12 changes: 12 additions & 0 deletions src/assets/images/scroll-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 13 additions & 11 deletions src/components/CurrencyLogo/CurrencyLogo.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,32 @@ import PolygonMaticLogo from '../../assets/images/polygon-matic-logo.svg'
import XDAILogo from '../../assets/images/xdai-logo.png'

export const NATIVE_CURRENCY_LOGO: { [chainId in ChainId]: string } = {
[ChainId.XDAI]: XDAILogo,
[ChainId.MAINNET]: EtherLogo,
[ChainId.RINKEBY]: EtherLogo,
[ChainId.ARBITRUM_GOERLI]: EtherLogo,
[ChainId.ARBITRUM_ONE]: EtherLogo,
[ChainId.ARBITRUM_RINKEBY]: EtherLogo,
[ChainId.ARBITRUM_GOERLI]: EtherLogo,
[ChainId.POLYGON]: PolygonMaticLogo,
[ChainId.OPTIMISM_GOERLI]: EtherLogo,
[ChainId.OPTIMISM_MAINNET]: EtherLogo,
[ChainId.GOERLI]: EtherLogo,
[ChainId.BSC_MAINNET]: BNBLogo,
[ChainId.BSC_TESTNET]: BNBLogo,
[ChainId.GOERLI]: EtherLogo,
[ChainId.MAINNET]: EtherLogo,
[ChainId.OPTIMISM_GOERLI]: EtherLogo,
[ChainId.OPTIMISM_MAINNET]: EtherLogo,
[ChainId.RINKEBY]: EtherLogo,
[ChainId.SCROLL_MAINNET]: EtherLogo,
[ChainId.XDAI]: XDAILogo,
[ChainId.ZK_SYNC_ERA_MAINNET]: EtherLogo,
[ChainId.ZK_SYNC_ERA_TESTNET]: EtherLogo,
}

// From repo https://github.com/trustwallet/assets/tree/master/blockchains
const trustWalletChainMapping: { [chainId in ChainId]?: string } = {
[ChainId.XDAI]: 'xdai',
[ChainId.POLYGON]: 'polygon',
[ChainId.MAINNET]: 'ethereum',
[ChainId.ARBITRUM_ONE]: 'arbitrum',
[ChainId.OPTIMISM_MAINNET]: 'optimism',
[ChainId.BSC_MAINNET]: 'binance',
[ChainId.MAINNET]: 'ethereum',
[ChainId.OPTIMISM_MAINNET]: 'optimism',
[ChainId.POLYGON]: 'polygon',
[ChainId.SCROLL_MAINNET]: 'scroll',
[ChainId.XDAI]: 'xdai',
[ChainId.ZK_SYNC_ERA_MAINNET]: 'zksync',
}

Expand Down
7 changes: 7 additions & 0 deletions src/components/NetworkSwitcher/NetworkSwitcher.preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import EthereumLogo from '../../assets/images/ethereum-logo.svg'
import GnosisLogo from '../../assets/images/gnosis-chain-logo.svg'
import OptimismLogo from '../../assets/images/optimism-logo.svg'
import PolygonMaticLogo from '../../assets/images/polygon-matic-logo.svg'
import ScrolLogo from '../../assets/images/scroll-logo.svg'
import ZkSyncEraLogo from '../../assets/images/zk-sync-era-logo.svg'

import { NetworkOptionsPreset, NetworkSwitcherTags } from './NetworkSwitcher.types'
Expand Down Expand Up @@ -54,6 +55,12 @@ export const networkOptionsPreset: NetworkOptionsPreset[] = [
logoSrc: ZkSyncEraLogo,
color: '#1E69FF',
},
{
chainId: ChainId.SCROLL_MAINNET,
name: 'Scroll',
logoSrc: ScrolLogo,
color: '#FFDBB0',
},

// TESTNETS
{
Expand Down
18 changes: 10 additions & 8 deletions src/components/Web3Status/AccountStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import EthereumLogo from '../../assets/images/ethereum-logo.svg'
import GnosisLogo from '../../assets/images/gnosis-chain-logo.svg'
import OptimismLogo from '../../assets/images/optimism-logo.svg'
import PolygonMaticLogo from '../../assets/images/polygon-matic-logo.svg'
import ScrollLogo from '../../assets/images/scroll-logo.svg'
import ZkSyncEraLogo from '../../assets/images/zk-sync-era-logo.svg'
import { ENSAvatarData } from '../../hooks/useENSAvatar'
import { ApplicationModal } from '../../state/application/actions'
Expand All @@ -26,17 +27,18 @@ import NetworkSwitcherPopover from '../NetworkSwitcherPopover'
import { RowBetween } from '../Row'

const ChainLogo: any = {
[ChainId.MAINNET]: EthereumLogo,
[ChainId.RINKEBY]: EthereumLogo,
[ChainId.GOERLI]: EthereumLogo,
[ChainId.ARBITRUM_GOERLI]: ArbitrumLogo,
[ChainId.ARBITRUM_ONE]: ArbitrumLogo,
[ChainId.ARBITRUM_RINKEBY]: ArbitrumLogo,
[ChainId.XDAI]: GnosisLogo,
[ChainId.POLYGON]: PolygonMaticLogo,
[ChainId.OPTIMISM_MAINNET]: OptimismLogo,
[ChainId.OPTIMISM_GOERLI]: OptimismLogo,
[ChainId.ARBITRUM_GOERLI]: ArbitrumLogo,
[ChainId.BSC_MAINNET]: BSCLogo,
[ChainId.GOERLI]: EthereumLogo,
[ChainId.MAINNET]: EthereumLogo,
[ChainId.OPTIMISM_GOERLI]: OptimismLogo,
[ChainId.OPTIMISM_MAINNET]: OptimismLogo,
[ChainId.POLYGON]: PolygonMaticLogo,
[ChainId.RINKEBY]: EthereumLogo,
[ChainId.SCROLL_MAINNET]: ScrollLogo,
[ChainId.XDAI]: GnosisLogo,
[ChainId.ZK_SYNC_ERA_MAINNET]: ZkSyncEraLogo,
[ChainId.ZK_SYNC_ERA_TESTNET]: ZkSyncEraLogo,
}
Expand Down
39 changes: 21 additions & 18 deletions src/connectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ export const [network, networkHooks] = initializeConnector<Network>(
new Network({
actions,
urlMap: {
[ChainId.MAINNET]: `https://rpc.mevblocker.io/`,
[ChainId.XDAI]: 'https://rpc.gnosischain.com/',
[ChainId.ARBITRUM_ONE]: 'https://arb1.arbitrum.io/rpc',
[ChainId.POLYGON]: 'https://polygon-rpc.com/',
[ChainId.ARBITRUM_GOERLI]: 'https://goerli-rollup.arbitrum.io/rpc',
[ChainId.OPTIMISM_MAINNET]: 'https://mainnet.optimism.io',
[ChainId.OPTIMISM_GOERLI]: 'https://goerli.optimism.io',
[ChainId.ARBITRUM_ONE]: 'https://arb1.arbitrum.io/rpc',
[ChainId.BSC_MAINNET]: 'https://bsc-dataseed.binance.org/',
[ChainId.MAINNET]: `https://rpc.mevblocker.io/`,
[ChainId.OPTIMISM_GOERLI]: 'https://goerli.optimism.io',
[ChainId.OPTIMISM_MAINNET]: 'https://mainnet.optimism.io',
[ChainId.POLYGON]: 'https://polygon-rpc.com/',
[ChainId.SCROLL_MAINNET]: 'https://rpc.scroll.io/',
[ChainId.XDAI]: 'https://rpc.gnosischain.com/',
[ChainId.ZK_SYNC_ERA_MAINNET]: `https://mainnet.era.zksync.io`,
[ChainId.ZK_SYNC_ERA_TESTNET]: `https://testnet.era.zksync.dev`,
},
Expand All @@ -37,28 +38,30 @@ export const [walletConnect, walletConnectHooks] = initializeConnector<WalletCon
projectId: process.env.REACT_APP_WALLET_CONNECT_ID as string,
chains: [],
optionalChains: [
ChainId.MAINNET,
ChainId.RINKEBY,
ChainId.ARBITRUM_GOERLI,
ChainId.ARBITRUM_ONE,
ChainId.ARBITRUM_RINKEBY,
ChainId.BSC_MAINNET,
ChainId.GNOSIS,
ChainId.POLYGON,
ChainId.ARBITRUM_GOERLI,
ChainId.OPTIMISM_MAINNET,
ChainId.MAINNET,
ChainId.OPTIMISM_GOERLI,
ChainId.BSC_MAINNET,
ChainId.OPTIMISM_MAINNET,
ChainId.POLYGON,
ChainId.RINKEBY,
ChainId.SCROLL_MAINNET,
ChainId.ZK_SYNC_ERA_MAINNET,
ChainId.ZK_SYNC_ERA_TESTNET,
],
rpcMap: {
[ChainId.MAINNET]: `https://rpc.mevblocker.io/`,
[ChainId.XDAI]: 'https://rpc.gnosischain.com/',
[ChainId.ARBITRUM_ONE]: 'https://arb1.arbitrum.io/rpc',
[ChainId.POLYGON]: 'https://polygon-rpc.com/',
[ChainId.ARBITRUM_GOERLI]: 'https://goerli-rollup.arbitrum.io/rpc',
[ChainId.OPTIMISM_MAINNET]: 'https://mainnet.optimism.io',
[ChainId.OPTIMISM_GOERLI]: 'https://goerli.optimism.io',
[ChainId.ARBITRUM_ONE]: 'https://arb1.arbitrum.io/rpc',
[ChainId.BSC_MAINNET]: 'https://bsc-dataseed.binance.org/',
[ChainId.MAINNET]: `https://rpc.mevblocker.io/`,
[ChainId.OPTIMISM_GOERLI]: 'https://goerli.optimism.io',
[ChainId.OPTIMISM_MAINNET]: 'https://mainnet.optimism.io',
[ChainId.POLYGON]: 'https://polygon-rpc.com/',
[ChainId.SCROLL_MAINNET]: `https://rpc.scroll.io/`,
[ChainId.XDAI]: 'https://rpc.gnosischain.com/',
[ChainId.ZK_SYNC_ERA_MAINNET]: `https://mainnet.era.zksync.io`,
[ChainId.ZK_SYNC_ERA_TESTNET]: `https://testnet.era.zksync.dev`,
},
Expand Down
Loading

0 comments on commit 6460f0e

Please sign in to comment.