From 1e82b97d281c0494d79a365aee66cc7a7fc70350 Mon Sep 17 00:00:00 2001 From: Mrsirdev Date: Sat, 25 Feb 2023 23:45:13 -0500 Subject: [PATCH 01/55] add fuji testnet --- src/components/FeeSelector/shared.tsx | 9 +- src/components/Identicon/StatusIcon.tsx | 3 +- src/components/NavBar/ChainSelector.tsx | 8 +- src/components/NavBar/SuggestionRow.tsx | 2 +- src/components/NetworkAlert/NetworkAlert.tsx | 50 +- src/components/PositionListItem/index.tsx | 6 +- src/components/Tokens/TokenDetails/About.tsx | 2 +- src/components/TransactionSettings/index.tsx | 3 +- src/constants/TokenSafetyLookupTable.ts | 9 +- src/constants/addresses.ts | 113 +---- src/constants/chainInfo.ts | 165 +------ src/constants/chains.ts | 75 +-- src/constants/lists.ts | 37 +- src/constants/networks.ts | 99 +--- src/constants/providers.ts | 12 +- src/constants/routing.ts | 184 +------- src/constants/tokens.ts | 433 ++---------------- src/graphql/data/SearchTokens.ts | 2 +- .../data/__generated__/types-and-hooks.ts | 78 +++- src/graphql/data/util.tsx | 30 +- src/graphql/thegraph/apollo.ts | 9 +- src/hooks/Tokens.ts | 51 +-- src/hooks/useClientSideV3Trade.ts | 10 +- src/hooks/useERC20Permit.ts | 23 +- src/hooks/usePoolTickData.ts | 2 +- src/hooks/useStablecoinPrice.ts | 10 +- src/lib/hooks/transactions/updater.tsx | 5 +- src/lib/hooks/useCurrencyLogoURIs.ts | 39 +- src/lib/state/multicall.tsx | 5 +- src/state/stake/hooks.tsx | 15 +- .../RadialGradientByChainUpdater.ts | 33 +- src/utils/constructSameAddressMap.ts | 8 +- src/utils/getExplorerLink.ts | 42 +- src/utils/nativeTokens.ts | 8 +- src/utils/switchChain.ts | 5 +- src/utils/unwrappedToken.ts | 6 +- 36 files changed, 226 insertions(+), 1365 deletions(-) diff --git a/src/components/FeeSelector/shared.tsx b/src/components/FeeSelector/shared.tsx index 0824ccf4697..387d85af057 100644 --- a/src/components/FeeSelector/shared.tsx +++ b/src/components/FeeSelector/shared.tsx @@ -10,14 +10,7 @@ export const FEE_AMOUNT_DETAIL: Record< [FeeAmount.LOWEST]: { label: '0.01', description: Best for very stable pairs., - supportedChains: [ - SupportedChainId.MAINNET, - SupportedChainId.POLYGON, - SupportedChainId.POLYGON_MUMBAI, - SupportedChainId.CELO, - SupportedChainId.CELO_ALFAJORES, - SupportedChainId.OPTIMISM, - ], + supportedChains: [SupportedChainId.MAINNET, SupportedChainId.FUJI], }, [FeeAmount.LOW]: { label: '0.05', diff --git a/src/components/Identicon/StatusIcon.tsx b/src/components/Identicon/StatusIcon.tsx index c2279828d24..efd30d82419 100644 --- a/src/components/Identicon/StatusIcon.tsx +++ b/src/components/Identicon/StatusIcon.tsx @@ -7,7 +7,6 @@ import { flexColumnNoWrap } from 'theme/styles' import CoinbaseWalletIcon from '../../assets/images/coinbaseWalletIcon.svg' import WalletConnectIcon from '../../assets/images/walletConnectIcon.svg' import sockImg from '../../assets/svg/socks.svg' -import { useHasSocks } from '../../hooks/useSocksBalance' import Identicon from '../Identicon' export const IconWrapper = styled.div<{ size?: number }>` @@ -66,7 +65,7 @@ const useIcon = (connectionType: ConnectionType) => { } export default function StatusIcon({ connectionType, size }: { connectionType: ConnectionType; size?: number }) { - const hasSocks = useHasSocks() + const hasSocks = false const icon = useIcon(connectionType) return ( diff --git a/src/components/NavBar/ChainSelector.tsx b/src/components/NavBar/ChainSelector.tsx index a40798b0a47..dab3a7a9ef2 100644 --- a/src/components/NavBar/ChainSelector.tsx +++ b/src/components/NavBar/ChainSelector.tsx @@ -19,13 +19,7 @@ import * as styles from './ChainSelector.css' import ChainSelectorRow from './ChainSelectorRow' import { NavDropdown } from './NavDropdown' -const NETWORK_SELECTOR_CHAINS = [ - SupportedChainId.MAINNET, - SupportedChainId.POLYGON, - SupportedChainId.OPTIMISM, - SupportedChainId.ARBITRUM_ONE, - SupportedChainId.CELO, -] +const NETWORK_SELECTOR_CHAINS = [SupportedChainId.MAINNET, SupportedChainId.FUJI] interface ChainSelectorProps { leftAlign?: boolean diff --git a/src/components/NavBar/SuggestionRow.tsx b/src/components/NavBar/SuggestionRow.tsx index 9a0c531b742..875fe71aeb5 100644 --- a/src/components/NavBar/SuggestionRow.tsx +++ b/src/components/NavBar/SuggestionRow.tsx @@ -63,7 +63,7 @@ export const CollectionRow = ({ const navigate = useNavigate() const handleClick = useCallback(() => { - addRecentlySearchedAsset({ ...collection, isNft: true, chain: Chain.Ethereum }) + addRecentlySearchedAsset({ ...collection, isNft: true, chain: Chain.Evmos }) toggleOpen() sendAnalyticsEvent(InterfaceEventName.NAVBAR_RESULT_SELECTED, { ...eventProperties }) }, [addRecentlySearchedAsset, collection, toggleOpen, eventProperties]) diff --git a/src/components/NetworkAlert/NetworkAlert.tsx b/src/components/NetworkAlert/NetworkAlert.tsx index 6ddcf3058c2..404c9df7919 100644 --- a/src/components/NetworkAlert/NetworkAlert.tsx +++ b/src/components/NetworkAlert/NetworkAlert.tsx @@ -29,14 +29,7 @@ const RootWrapper = styled.div` ` const SHOULD_SHOW_ALERT = { - [SupportedChainId.OPTIMISM]: true, - [SupportedChainId.OPTIMISM_GOERLI]: true, - [SupportedChainId.ARBITRUM_ONE]: true, - [SupportedChainId.ARBITRUM_RINKEBY]: true, - [SupportedChainId.POLYGON]: true, - [SupportedChainId.POLYGON_MUMBAI]: true, - [SupportedChainId.CELO]: true, - [SupportedChainId.CELO_ALFAJORES]: true, + [SupportedChainId.FUJI]: false, } type NetworkAlertChains = keyof typeof SHOULD_SHOW_ALERT @@ -45,40 +38,12 @@ const BG_COLORS_BY_DARK_MODE_AND_CHAIN_ID: { [darkMode in 'dark' | 'light']: { [chainId in NetworkAlertChains]: string } } = { dark: { - [SupportedChainId.POLYGON]: + [SupportedChainId.FUJI]: 'radial-gradient(100% 93.36% at 0% 6.64%, rgba(160, 108, 247, 0.1) 0%, rgba(82, 32, 166, 0.1) 100%)', - [SupportedChainId.POLYGON_MUMBAI]: - 'radial-gradient(100% 93.36% at 0% 6.64%, rgba(160, 108, 247, 0.1) 0%, rgba(82, 32, 166, 0.1) 100%)', - [SupportedChainId.CELO]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)', - [SupportedChainId.CELO_ALFAJORES]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)', - [SupportedChainId.OPTIMISM]: - 'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.01) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.01) 0%, rgba(235, 0, 255, 0.01) 96%)', - [SupportedChainId.OPTIMISM_GOERLI]: - 'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.04) 0%, rgba(235, 0, 255, 0.01 96%)', - [SupportedChainId.ARBITRUM_ONE]: - 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.01) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(75% 75% at 0% 0%, rgba(150, 190, 220, 0.05) 0%, rgba(33, 114, 229, 0.05) 100%), hsla(0, 0%, 100%, 0.05)', - [SupportedChainId.ARBITRUM_RINKEBY]: - 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.05) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(75% 75% at 0% 0%, rgba(150, 190, 220, 0.05) 0%, rgba(33, 114, 229, 0.1) 100%), hsla(0, 0%, 100%, 0.05)', }, light: { - [SupportedChainId.POLYGON]: - 'radial-gradient(182.71% 205.59% at 2.81% 7.69%, rgba(130, 71, 229, 0.2) 0%, rgba(167, 202, 255, 0.2) 100%)', - [SupportedChainId.POLYGON_MUMBAI]: + [SupportedChainId.FUJI]: 'radial-gradient(182.71% 205.59% at 2.81% 7.69%, rgba(130, 71, 229, 0.2) 0%, rgba(167, 202, 255, 0.2) 100%)', - [SupportedChainId.CELO]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)', - [SupportedChainId.CELO_ALFAJORES]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)', - [SupportedChainId.OPTIMISM]: - 'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)', - [SupportedChainId.OPTIMISM_GOERLI]: - 'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)', - [SupportedChainId.ARBITRUM_ONE]: - 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.1) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(circle at top left, hsla(206, 50%, 75%, 0.01), hsla(215, 79%, 51%, 0.12)), hsla(0, 0%, 100%, 0.1)', - [SupportedChainId.ARBITRUM_RINKEBY]: - 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.1) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(circle at top left, hsla(206, 50%, 75%, 0.01), hsla(215, 79%, 51%, 0.12)), hsla(0, 0%, 100%, 0.1)', }, } @@ -130,14 +95,7 @@ const StyledArrowUpRight = styled(ArrowUpRight)` ` const TEXT_COLORS: { [chainId in NetworkAlertChains]: string } = { - [SupportedChainId.POLYGON]: 'rgba(130, 71, 229)', - [SupportedChainId.POLYGON_MUMBAI]: 'rgba(130, 71, 229)', - [SupportedChainId.CELO]: 'rgba(53, 178, 97)', - [SupportedChainId.CELO_ALFAJORES]: 'rgba(53, 178, 97)', - [SupportedChainId.OPTIMISM]: '#ff3856', - [SupportedChainId.OPTIMISM_GOERLI]: '#ff3856', - [SupportedChainId.ARBITRUM_ONE]: '#0490ed', - [SupportedChainId.ARBITRUM_RINKEBY]: '#0490ed', + [SupportedChainId.FUJI]: 'rgba(130, 71, 229)', } function shouldShowAlert(chainId: number | undefined): chainId is NetworkAlertChains { diff --git a/src/components/PositionListItem/index.tsx b/src/components/PositionListItem/index.tsx index 1747684fbbe..096d6bef770 100644 --- a/src/components/PositionListItem/index.tsx +++ b/src/components/PositionListItem/index.tsx @@ -20,7 +20,7 @@ import { formatTickPrice } from 'utils/formatTickPrice' import { unwrappedToken } from 'utils/unwrappedToken' import { hasURL } from 'utils/urlChecks' -import { DAI, USDC_MAINNET, USDT, WBTC, WRAPPED_NATIVE_CURRENCY } from '../../constants/tokens' +import { USDC_FUJI, WRAPPED_NATIVE_CURRENCY } from '../../constants/tokens' const LinkRow = styled(Link)` align-items: center; @@ -133,7 +133,7 @@ export function getPriceOrderingFromPositionForUI(position?: Position): { const token1 = position.amount1.currency // if token0 is a dollar-stable asset, set it as the quote token - const stables = [DAI, USDC_MAINNET, USDT] + const stables = [USDC_FUJI] if (stables.some((stable) => stable.equals(token0))) { return { priceLower: position.token0PriceUpper.invert(), @@ -144,7 +144,7 @@ export function getPriceOrderingFromPositionForUI(position?: Position): { } // if token1 is an ETH-/BTC-stable asset, set it as the base token - const bases = [...Object.values(WRAPPED_NATIVE_CURRENCY), WBTC] + const bases = [...Object.values(WRAPPED_NATIVE_CURRENCY)] if (bases.some((base) => base && base.equals(token1))) { return { priceLower: position.token0PriceUpper.invert(), diff --git a/src/components/Tokens/TokenDetails/About.tsx b/src/components/Tokens/TokenDetails/About.tsx index eec5f2c9ede..742caa0f2d6 100644 --- a/src/components/Tokens/TokenDetails/About.tsx +++ b/src/components/Tokens/TokenDetails/About.tsx @@ -1,6 +1,6 @@ import { Trans } from '@lingui/macro' -import { SupportedChainId } from '@uniswap/sdk-core' import { getChainInfo } from 'constants/chainInfo' +import { SupportedChainId } from 'constants/chains' import { darken } from 'polished' import { useState } from 'react' import styled from 'styled-components/macro' diff --git a/src/components/TransactionSettings/index.tsx b/src/components/TransactionSettings/index.tsx index 08d6ce53ce7..c9b01605aa1 100644 --- a/src/components/TransactionSettings/index.tsx +++ b/src/components/TransactionSettings/index.tsx @@ -1,7 +1,6 @@ import { Trans } from '@lingui/macro' import { Percent } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' -import { L2_CHAIN_IDS } from 'constants/chains' import { DEFAULT_DEADLINE_FROM_NOW } from 'constants/misc' import ms from 'ms.macro' import { darken } from 'polished' @@ -165,7 +164,7 @@ export default function TransactionSettings({ placeholderSlippage }: Transaction } } - const showCustomDeadlineRow = Boolean(chainId && !L2_CHAIN_IDS.includes(chainId)) + const showCustomDeadlineRow = Boolean(chainId && true) return ( diff --git a/src/constants/TokenSafetyLookupTable.ts b/src/constants/TokenSafetyLookupTable.ts index 8393425893d..7468a33e7c3 100644 --- a/src/constants/TokenSafetyLookupTable.ts +++ b/src/constants/TokenSafetyLookupTable.ts @@ -1,7 +1,7 @@ import { TokenInfo } from '@uniswap/token-lists' import store from '../state' -import { UNI_EXTENDED_LIST, UNI_LIST, UNSUPPORTED_LIST_URLS } from './lists' +import { FUJI_LIST, UNSUPPORTED_LIST_URLS } from './lists' import brokenTokenList from './tokenLists/broken.tokenlist.json' import { NATIVE_CHAIN_ID } from './tokens' @@ -19,13 +19,8 @@ class TokenSafetyLookupTable { createMap() { const dict: { [key: string]: TOKEN_LIST_TYPES } = {} - // Initialize extended tokens first - store.getState().lists.byUrl[UNI_EXTENDED_LIST].current?.tokens.forEach((token) => { - dict[token.address.toLowerCase()] = TOKEN_LIST_TYPES.UNI_EXTENDED - }) - // Initialize default tokens second, so that any tokens on both default and extended will display as default (no warning) - store.getState().lists.byUrl[UNI_LIST].current?.tokens.forEach((token) => { + store.getState().lists.byUrl[FUJI_LIST].current?.tokens.forEach((token) => { dict[token.address.toLowerCase()] = TOKEN_LIST_TYPES.UNI_DEFAULT }) diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index 227e30d0879..3691e9847c7 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -1,5 +1,4 @@ import { FACTORY_ADDRESS as V2_FACTORY_ADDRESS } from '@uniswap/v2-sdk' -import { FACTORY_ADDRESS as V3_FACTORY_ADDRESS } from '@uniswap/v3-sdk' import { constructSameAddressMap } from '../utils/constructSameAddressMap' import { SupportedChainId } from './chains' @@ -13,64 +12,30 @@ export const UNISWAP_NFT_AIRDROP_CLAIM_ADDRESS = '0x8B799381ac40b838BBA4131ffB26 export const V2_FACTORY_ADDRESSES: AddressMap = constructSameAddressMap(V2_FACTORY_ADDRESS) export const V2_ROUTER_ADDRESS: AddressMap = constructSameAddressMap('0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D') -// celo v3 addresses -const CELO_V3_CORE_FACTORY_ADDRESSES = '0xAfE208a311B21f13EF87E33A90049fC17A7acDEc' -const CELO_ROUTER_ADDRESS = '0x5615CDAb10dc425a742d643d949a7F474C01abc4' -const CELO_V3_MIGRATOR_ADDRESSES = '0x3cFd4d48EDfDCC53D3f173F596f621064614C582' -const CELO_MULTICALL_ADDRESS = '0x633987602DE5C4F337e3DbF265303A1080324204' -const CELO_QUOTER_ADDRESSES = '0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8' -const CELO_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES = '0x3d79EdAaBC0EaB6F08ED885C05Fc0B014290D95A' -const CELO_TICK_LENS_ADDRESSES = '0x5f115D9113F88e0a0Db1b5033D90D4a9690AcD3D' +// fuji addresses +const FUJI_V3_CORE_FACTORY_ADDRESSES = '0x43bDe47a34801f6aB2d66016Aef723Ba1b3A62b3' +const FUJI_ROUTER_ADDRESS = '0xd55586A56F208daeb184647aD17466c404ee1A51' +const FUJI_V3_MIGRATOR_ADDRESSES = '0x021d2b456b66e6b54fCef45CA2De298D533faC6B' +const FUJI_MULTICALL_ADDRESS = '0xBeFe898407483f0f2fF605971FBD8Cf8FbD8B160' +const FUJI_QUOTER_ADDRESSES = '0x92b5f5EAe221BC6FeD88259cd2805A9C842c29bF' +const FUJI_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES = '0x0Ca5659fE0fD4a10bde2Ca4d78156B78e9F1de1a' +const FUJI_TICK_LENS_ADDRESSES = '0x4A3be35489fa980D75B4b96B7b7F8a14748F0172' /* V3 Contract Addresses */ export const V3_CORE_FACTORY_ADDRESSES: AddressMap = { - ...constructSameAddressMap(V3_FACTORY_ADDRESS, [ - SupportedChainId.OPTIMISM, - SupportedChainId.OPTIMISM_GOERLI, - SupportedChainId.ARBITRUM_ONE, - SupportedChainId.ARBITRUM_RINKEBY, - SupportedChainId.POLYGON_MUMBAI, - SupportedChainId.POLYGON, - ]), - [SupportedChainId.CELO]: CELO_V3_CORE_FACTORY_ADDRESSES, - [SupportedChainId.CELO_ALFAJORES]: CELO_V3_CORE_FACTORY_ADDRESSES, + [SupportedChainId.FUJI]: FUJI_V3_CORE_FACTORY_ADDRESSES, } export const V3_MIGRATOR_ADDRESSES: AddressMap = { - ...constructSameAddressMap('0xA5644E29708357803b5A882D272c41cC0dF92B34', [ - SupportedChainId.ARBITRUM_ONE, - SupportedChainId.ARBITRUM_RINKEBY, - SupportedChainId.POLYGON_MUMBAI, - SupportedChainId.POLYGON, - ]), - [SupportedChainId.CELO]: CELO_V3_MIGRATOR_ADDRESSES, - [SupportedChainId.CELO_ALFAJORES]: CELO_V3_MIGRATOR_ADDRESSES, + [SupportedChainId.FUJI]: FUJI_V3_MIGRATOR_ADDRESSES, } export const MULTICALL_ADDRESS: AddressMap = { - ...constructSameAddressMap('0x1F98415757620B543A52E61c46B32eB19261F984', [ - SupportedChainId.OPTIMISM_GOERLI, - SupportedChainId.OPTIMISM, - SupportedChainId.POLYGON_MUMBAI, - SupportedChainId.POLYGON, - ]), - [SupportedChainId.ARBITRUM_ONE]: '0xadF885960B47eA2CD9B55E6DAc6B42b7Cb2806dB', - [SupportedChainId.ARBITRUM_RINKEBY]: '0xa501c031958F579dB7676fF1CE78AD305794d579', - [SupportedChainId.CELO]: CELO_MULTICALL_ADDRESS, - [SupportedChainId.CELO_ALFAJORES]: CELO_MULTICALL_ADDRESS, + [SupportedChainId.FUJI]: FUJI_MULTICALL_ADDRESS, } export const SWAP_ROUTER_ADDRESSES: AddressMap = { - ...constructSameAddressMap('0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45', [ - SupportedChainId.OPTIMISM, - SupportedChainId.OPTIMISM_GOERLI, - SupportedChainId.ARBITRUM_ONE, - SupportedChainId.ARBITRUM_RINKEBY, - SupportedChainId.POLYGON, - SupportedChainId.POLYGON_MUMBAI, - ]), - [SupportedChainId.CELO]: CELO_ROUTER_ADDRESS, - [SupportedChainId.CELO_ALFAJORES]: CELO_ROUTER_ADDRESS, + [SupportedChainId.FUJI]: FUJI_ROUTER_ADDRESS, } /** @@ -82,66 +47,30 @@ export const GOVERNANCE_ALPHA_V0_ADDRESSES: AddressMap = constructSameAddressMap /** * The older V1 governance address */ -export const GOVERNANCE_ALPHA_V1_ADDRESSES: AddressMap = { - [SupportedChainId.MAINNET]: '0xC4e172459f1E7939D522503B81AFAaC1014CE6F6', -} +export const GOVERNANCE_ALPHA_V1_ADDRESSES: AddressMap = {} /** * The latest governor bravo that is currently admin of timelock */ -export const GOVERNANCE_BRAVO_ADDRESSES: AddressMap = { - [SupportedChainId.MAINNET]: '0x408ED6354d4973f66138C91495F2f2FCbd8724C3', -} +export const GOVERNANCE_BRAVO_ADDRESSES: AddressMap = {} export const TIMELOCK_ADDRESS: AddressMap = constructSameAddressMap('0x1a9C8182C09F50C8318d769245beA52c32BE35BC') -export const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap = { - [SupportedChainId.MAINNET]: '0x090D4613473dEE047c3f2706764f49E0821D256e', -} +export const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap = {} -export const ARGENT_WALLET_DETECTOR_ADDRESS: AddressMap = { - [SupportedChainId.MAINNET]: '0xeca4B0bDBf7c55E9b7925919d03CbF8Dc82537E8', -} +export const ARGENT_WALLET_DETECTOR_ADDRESS: AddressMap = {} export const QUOTER_ADDRESSES: AddressMap = { - ...constructSameAddressMap('0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6', [ - SupportedChainId.OPTIMISM, - SupportedChainId.OPTIMISM_GOERLI, - SupportedChainId.ARBITRUM_ONE, - SupportedChainId.ARBITRUM_RINKEBY, - SupportedChainId.POLYGON_MUMBAI, - SupportedChainId.POLYGON, - ]), - [SupportedChainId.CELO]: CELO_QUOTER_ADDRESSES, - [SupportedChainId.CELO_ALFAJORES]: CELO_QUOTER_ADDRESSES, + [SupportedChainId.FUJI]: FUJI_QUOTER_ADDRESSES, } export const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: AddressMap = { - ...constructSameAddressMap('0xC36442b4a4522E871399CD717aBDD847Ab11FE88', [ - SupportedChainId.OPTIMISM, - SupportedChainId.OPTIMISM_GOERLI, - SupportedChainId.ARBITRUM_ONE, - SupportedChainId.ARBITRUM_RINKEBY, - SupportedChainId.POLYGON_MUMBAI, - SupportedChainId.POLYGON, - ]), - [SupportedChainId.CELO]: CELO_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES, - [SupportedChainId.CELO_ALFAJORES]: CELO_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES, + [SupportedChainId.FUJI]: FUJI_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES, } -export const ENS_REGISTRAR_ADDRESSES: AddressMap = { - [SupportedChainId.MAINNET]: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', - [SupportedChainId.ROPSTEN]: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', - [SupportedChainId.GOERLI]: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', - [SupportedChainId.RINKEBY]: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', -} +export const ENS_REGISTRAR_ADDRESSES: AddressMap = {} -export const SOCKS_CONTROLLER_ADDRESSES: AddressMap = { - [SupportedChainId.MAINNET]: '0x65770b5283117639760beA3F867b69b3697a91dd', -} +export const SOCKS_CONTROLLER_ADDRESSES: AddressMap = {} export const TICK_LENS_ADDRESSES: AddressMap = { - [SupportedChainId.ARBITRUM_ONE]: '0xbfd8137f7d1516D3ea5cA83523914859ec47F573', - [SupportedChainId.ARBITRUM_RINKEBY]: '0xbfd8137f7d1516D3ea5cA83523914859ec47F573', - [SupportedChainId.CELO]: CELO_TICK_LENS_ADDRESSES, - [SupportedChainId.CELO_ALFAJORES]: CELO_TICK_LENS_ADDRESSES, + [SupportedChainId.FUJI]: FUJI_TICK_LENS_ADDRESSES, } diff --git a/src/constants/chainInfo.ts b/src/constants/chainInfo.ts index 3937caa677e..1ed55ca8547 100644 --- a/src/constants/chainInfo.ts +++ b/src/constants/chainInfo.ts @@ -1,15 +1,9 @@ -import celoCircleLogoUrl from 'assets/images/celoCircle.png' import ethereumLogoUrl from 'assets/images/ethereum-logo.png' -import polygonCircleLogoUrl from 'assets/images/polygonCircle.png' -import { default as arbitrumCircleLogoUrl, default as arbitrumLogoUrl } from 'assets/svg/arbitrum_logo.svg' -import celoLogo from 'assets/svg/celo_logo.svg' -import optimismLogoUrl from 'assets/svg/optimistic_ethereum.svg' -import polygonMaticLogo from 'assets/svg/polygon-matic-logo.svg' import ms from 'ms.macro' import { darkTheme } from 'theme/colors' import { SupportedChainId, SupportedL1ChainId, SupportedL2ChainId } from './chains' -import { ARBITRUM_LIST, CELO_LIST, OPTIMISM_LIST } from './lists' +import { FUJI_LIST } from './lists' export const AVERAGE_L1_BLOCK_TIME = ms`12s` @@ -54,6 +48,20 @@ type ChainInfoMap = { readonly [chainId: number]: L1ChainInfo | L2ChainInfo } & } & { readonly [chainId in SupportedL1ChainId]: L1ChainInfo } const CHAIN_INFO: ChainInfoMap = { + [SupportedChainId.FUJI]: { + networkType: NetworkType.L1, + blockWaitMsBeforeWarning: ms`10m`, + docs: 'https://docs.avax.network/quickstart/fuji-workflow', + explorer: 'https://testnet.snowtrace.io/', + infoLink: '', + label: 'Fuji', + logoUrl: + 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/assets/0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7/logo.png', + circleLogoUrl: + 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/assets/0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7/logo.png', + nativeCurrency: { name: 'Avax', symbol: 'AVAX', decimals: 18 }, + defaultListUrl: FUJI_LIST, + }, [SupportedChainId.MAINNET]: { networkType: NetworkType.L1, docs: 'https://docs.uniswap.org/', @@ -64,159 +72,24 @@ const CHAIN_INFO: ChainInfoMap = { nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, color: darkTheme.chain_1, }, - [SupportedChainId.RINKEBY]: { - networkType: NetworkType.L1, - docs: 'https://docs.uniswap.org/', - explorer: 'https://rinkeby.etherscan.io/', - infoLink: 'https://info.uniswap.org/#/', - label: 'Rinkeby', - logoUrl: ethereumLogoUrl, - nativeCurrency: { name: 'Rinkeby Ether', symbol: 'rETH', decimals: 18 }, - color: darkTheme.chain_4, - }, - [SupportedChainId.ROPSTEN]: { - networkType: NetworkType.L1, - docs: 'https://docs.uniswap.org/', - explorer: 'https://ropsten.etherscan.io/', - infoLink: 'https://info.uniswap.org/#/', - label: 'Ropsten', - logoUrl: ethereumLogoUrl, - nativeCurrency: { name: 'Ropsten Ether', symbol: 'ropETH', decimals: 18 }, - color: darkTheme.chain_3, - }, - [SupportedChainId.KOVAN]: { - networkType: NetworkType.L1, - docs: 'https://docs.uniswap.org/', - explorer: 'https://kovan.etherscan.io/', - infoLink: 'https://info.uniswap.org/#/', - label: 'Kovan', - logoUrl: ethereumLogoUrl, - nativeCurrency: { name: 'Kovan Ether', symbol: 'kovETH', decimals: 18 }, - color: darkTheme.chain_420, - }, - [SupportedChainId.GOERLI]: { - networkType: NetworkType.L1, - docs: 'https://docs.uniswap.org/', - explorer: 'https://goerli.etherscan.io/', - infoLink: 'https://info.uniswap.org/#/', - label: 'Görli', - logoUrl: ethereumLogoUrl, - nativeCurrency: { name: 'Görli Ether', symbol: 'görETH', decimals: 18 }, - color: darkTheme.chain_5, - }, [SupportedChainId.OPTIMISM]: { networkType: NetworkType.L2, blockWaitMsBeforeWarning: ms`25m`, bridge: 'https://app.optimism.io/bridge', - defaultListUrl: OPTIMISM_LIST, + defaultListUrl: FUJI_LIST, docs: 'https://optimism.io/', explorer: 'https://optimistic.etherscan.io/', infoLink: 'https://info.uniswap.org/#/optimism/', label: 'Optimism', - logoUrl: optimismLogoUrl, + logoUrl: ethereumLogoUrl, // Optimism perfers same icon for both - circleLogoUrl: optimismLogoUrl, + circleLogoUrl: ethereumLogoUrl, statusPage: 'https://optimism.io/status', helpCenterUrl: 'https://help.uniswap.org/en/collections/3137778-uniswap-on-optimistic-ethereum-oξ', nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, color: darkTheme.chain_10, backgroundColor: darkTheme.chain_10_background, }, - [SupportedChainId.OPTIMISM_GOERLI]: { - networkType: NetworkType.L2, - blockWaitMsBeforeWarning: ms`25m`, - bridge: 'https://app.optimism.io/bridge', - defaultListUrl: OPTIMISM_LIST, - docs: 'https://optimism.io/', - explorer: 'https://goerli-optimism.etherscan.io/', - infoLink: 'https://info.uniswap.org/#/optimism/', - label: 'Optimism Görli', - logoUrl: optimismLogoUrl, - statusPage: 'https://optimism.io/status', - helpCenterUrl: 'https://help.uniswap.org/en/collections/3137778-uniswap-on-optimistic-ethereum-oξ', - nativeCurrency: { name: 'Optimism Goerli Ether', symbol: 'görOpETH', decimals: 18 }, - color: darkTheme.chain_420, - }, - [SupportedChainId.ARBITRUM_ONE]: { - networkType: NetworkType.L2, - blockWaitMsBeforeWarning: ms`10m`, - bridge: 'https://bridge.arbitrum.io/', - docs: 'https://offchainlabs.com/', - explorer: 'https://arbiscan.io/', - infoLink: 'https://info.uniswap.org/#/arbitrum', - label: 'Arbitrum', - logoUrl: arbitrumLogoUrl, - circleLogoUrl: arbitrumCircleLogoUrl, - defaultListUrl: ARBITRUM_LIST, - helpCenterUrl: 'https://help.uniswap.org/en/collections/3137787-uniswap-on-arbitrum', - nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, - color: darkTheme.chain_42, - backgroundColor: darkTheme.chain_42161_background, - }, - [SupportedChainId.ARBITRUM_RINKEBY]: { - networkType: NetworkType.L2, - blockWaitMsBeforeWarning: ms`10m`, - bridge: 'https://bridge.arbitrum.io/', - docs: 'https://offchainlabs.com/', - explorer: 'https://rinkeby-explorer.arbitrum.io/', - infoLink: 'https://info.uniswap.org/#/arbitrum/', - label: 'Arbitrum Rinkeby', - logoUrl: arbitrumLogoUrl, - defaultListUrl: ARBITRUM_LIST, - helpCenterUrl: 'https://help.uniswap.org/en/collections/3137787-uniswap-on-arbitrum', - nativeCurrency: { name: 'Rinkeby Arbitrum Ether', symbol: 'rinkArbETH', decimals: 18 }, - color: darkTheme.chain_421611, - }, - [SupportedChainId.POLYGON]: { - networkType: NetworkType.L1, - blockWaitMsBeforeWarning: ms`10m`, - bridge: 'https://wallet.polygon.technology/login', - docs: 'https://polygon.io/', - explorer: 'https://polygonscan.com/', - infoLink: 'https://info.uniswap.org/#/polygon/', - label: 'Polygon', - logoUrl: polygonMaticLogo, - circleLogoUrl: polygonCircleLogoUrl, - nativeCurrency: { name: 'Polygon Matic', symbol: 'MATIC', decimals: 18 }, - color: darkTheme.chain_137, - backgroundColor: darkTheme.chain_137_background, - }, - [SupportedChainId.POLYGON_MUMBAI]: { - networkType: NetworkType.L1, - blockWaitMsBeforeWarning: ms`10m`, - bridge: 'https://wallet.polygon.technology/bridge', - docs: 'https://polygon.io/', - explorer: 'https://mumbai.polygonscan.com/', - infoLink: 'https://info.uniswap.org/#/polygon/', - label: 'Polygon Mumbai', - logoUrl: polygonMaticLogo, - nativeCurrency: { name: 'Polygon Mumbai Matic', symbol: 'mMATIC', decimals: 18 }, - }, - [SupportedChainId.CELO]: { - networkType: NetworkType.L1, - blockWaitMsBeforeWarning: ms`10m`, - bridge: 'https://www.portalbridge.com/#/transfer', - docs: 'https://docs.celo.org/', - explorer: 'https://celoscan.io/', - infoLink: 'https://info.uniswap.org/#/celo', - label: 'Celo', - logoUrl: celoLogo, - circleLogoUrl: celoCircleLogoUrl, - nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 }, - defaultListUrl: CELO_LIST, - }, - [SupportedChainId.CELO_ALFAJORES]: { - networkType: NetworkType.L1, - blockWaitMsBeforeWarning: ms`10m`, - bridge: 'https://www.portalbridge.com/#/transfer', - docs: 'https://docs.celo.org/', - explorer: 'https://alfajores-blockscout.celo-testnet.org/', - infoLink: 'https://info.uniswap.org/#/celo', - label: 'Celo Alfajores', - logoUrl: celoLogo, - nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 }, - defaultListUrl: CELO_LIST, - }, } export function getChainInfo(chainId: SupportedL1ChainId): L1ChainInfo @@ -224,7 +97,7 @@ export function getChainInfo(chainId: SupportedL2ChainId): L2ChainInfo export function getChainInfo(chainId: SupportedChainId): L1ChainInfo | L2ChainInfo export function getChainInfo( chainId: SupportedChainId | SupportedL1ChainId | SupportedL2ChainId | number | undefined -): L1ChainInfo | L2ChainInfo | undefined +): L1ChainInfo | L2ChainInfo /** * Overloaded method for returning ChainInfo given a chainID diff --git a/src/constants/chains.ts b/src/constants/chains.ts index c14e99efdc8..2cb6e2edfd4 100644 --- a/src/constants/chains.ts +++ b/src/constants/chains.ts @@ -2,39 +2,15 @@ * List of all the networks supported by the Uniswap Interface */ export enum SupportedChainId { - MAINNET = 1, - ROPSTEN = 3, - RINKEBY = 4, - GOERLI = 5, - KOVAN = 42, - - ARBITRUM_ONE = 42161, - ARBITRUM_RINKEBY = 421611, - + FUJI = 43113, + MAINNET = 9001, OPTIMISM = 10, - OPTIMISM_GOERLI = 420, - - POLYGON = 137, - POLYGON_MUMBAI = 80001, - - CELO = 42220, - CELO_ALFAJORES = 44787, } export const CHAIN_IDS_TO_NAMES = { - [SupportedChainId.MAINNET]: 'mainnet', - [SupportedChainId.ROPSTEN]: 'ropsten', - [SupportedChainId.RINKEBY]: 'rinkeby', - [SupportedChainId.GOERLI]: 'goerli', - [SupportedChainId.KOVAN]: 'kovan', - [SupportedChainId.POLYGON]: 'polygon', - [SupportedChainId.POLYGON_MUMBAI]: 'polygon_mumbai', - [SupportedChainId.CELO]: 'celo', - [SupportedChainId.CELO_ALFAJORES]: 'celo_alfajores', - [SupportedChainId.ARBITRUM_ONE]: 'arbitrum', - [SupportedChainId.ARBITRUM_RINKEBY]: 'arbitrum_rinkeby', + [SupportedChainId.MAINNET]: 'evmos', + [SupportedChainId.FUJI]: 'fuji', [SupportedChainId.OPTIMISM]: 'optimism', - [SupportedChainId.OPTIMISM_GOERLI]: 'optimism_goerli', } /** @@ -48,49 +24,21 @@ export function isSupportedChain(chainId: number | null | undefined): chainId is return !!chainId && !!SupportedChainId[chainId] } -export const SUPPORTED_GAS_ESTIMATE_CHAIN_IDS = [ - SupportedChainId.MAINNET, - SupportedChainId.POLYGON, - SupportedChainId.CELO, - SupportedChainId.OPTIMISM, - SupportedChainId.ARBITRUM_ONE, -] +export const SUPPORTED_GAS_ESTIMATE_CHAIN_IDS = [SupportedChainId.MAINNET, SupportedChainId.FUJI] /** * Unsupported networks for V2 pool behavior. */ -export const UNSUPPORTED_V2POOL_CHAIN_IDS = [ - SupportedChainId.POLYGON, - SupportedChainId.OPTIMISM, - SupportedChainId.ARBITRUM_ONE, -] +export const UNSUPPORTED_V2POOL_CHAIN_IDS = [SupportedChainId.FUJI] -export const TESTNET_CHAIN_IDS = [ - SupportedChainId.ROPSTEN, - SupportedChainId.RINKEBY, - SupportedChainId.GOERLI, - SupportedChainId.KOVAN, - SupportedChainId.POLYGON_MUMBAI, - SupportedChainId.ARBITRUM_RINKEBY, - SupportedChainId.OPTIMISM_GOERLI, -] as const +export const TESTNET_CHAIN_IDS = [SupportedChainId.FUJI] as const export type SupportedTestnetChainId = typeof TESTNET_CHAIN_IDS[number] /** * All the chain IDs that are running the Ethereum protocol. */ -export const L1_CHAIN_IDS = [ - SupportedChainId.MAINNET, - SupportedChainId.ROPSTEN, - SupportedChainId.RINKEBY, - SupportedChainId.GOERLI, - SupportedChainId.KOVAN, - SupportedChainId.POLYGON, - SupportedChainId.POLYGON_MUMBAI, - SupportedChainId.CELO, - SupportedChainId.CELO_ALFAJORES, -] as const +export const L1_CHAIN_IDS = [SupportedChainId.MAINNET, SupportedChainId.FUJI] as const export type SupportedL1ChainId = typeof L1_CHAIN_IDS[number] @@ -98,11 +46,6 @@ export type SupportedL1ChainId = typeof L1_CHAIN_IDS[number] * Controls some L2 specific behavior, e.g. slippage tolerance, special UI behavior. * The expectation is that all of these networks have immediate transaction confirmation. */ -export const L2_CHAIN_IDS = [ - SupportedChainId.ARBITRUM_ONE, - SupportedChainId.ARBITRUM_RINKEBY, - SupportedChainId.OPTIMISM, - SupportedChainId.OPTIMISM_GOERLI, -] as const +export const L2_CHAIN_IDS = [SupportedChainId.OPTIMISM] as const export type SupportedL2ChainId = typeof L2_CHAIN_IDS[number] diff --git a/src/constants/lists.ts b/src/constants/lists.ts index aa761c1ecf6..f4e3bc7ff0b 100644 --- a/src/constants/lists.ts +++ b/src/constants/lists.ts @@ -1,38 +1,9 @@ -export const UNI_LIST = 'https://tokens.uniswap.org' -export const UNI_EXTENDED_LIST = 'https://extendedtokens.uniswap.org/' -const UNI_UNSUPPORTED_LIST = 'https://unsupportedtokens.uniswap.org/' -const AAVE_LIST = 'tokenlist.aave.eth' -const BA_LIST = 'https://raw.githubusercontent.com/The-Blockchain-Association/sec-notice-list/master/ba-sec-list.json' -const CMC_ALL_LIST = 'https://api.coinmarketcap.com/data-api/v3/uniswap/all.json' -const COINGECKO_LIST = 'https://tokens.coingecko.com/uniswap/all.json' -const COMPOUND_LIST = 'https://raw.githubusercontent.com/compound-finance/token-list/master/compound.tokenlist.json' -const GEMINI_LIST = 'https://www.gemini.com/uniswap/manifest.json' -const KLEROS_LIST = 't2crtokens.eth' -const SET_LIST = 'https://raw.githubusercontent.com/SetProtocol/uniswap-tokenlist/main/set.tokenlist.json' -const WRAPPED_LIST = 'wrapped.tokensoft.eth' +export const FUJI_LIST = 'https://raw.githubusercontent.com/Orbital-Apes-Labs/tokenlist/fuji-testnet/src/tokenlist.json' -export const OPTIMISM_LIST = 'https://static.optimism.io/optimism.tokenlist.json' -export const ARBITRUM_LIST = 'https://bridge.arbitrum.io/token-list-42161.json' -export const CELO_LIST = 'https://celo-org.github.io/celo-token-list/celo.tokenlist.json' - -export const UNSUPPORTED_LIST_URLS: string[] = [BA_LIST, UNI_UNSUPPORTED_LIST] +export const UNSUPPORTED_LIST_URLS: string[] = [] // default lists to be 'active' aka searched across -export const DEFAULT_ACTIVE_LIST_URLS: string[] = [UNI_LIST] -export const DEFAULT_INACTIVE_LIST_URLS: string[] = [ - UNI_EXTENDED_LIST, - COMPOUND_LIST, - AAVE_LIST, - CMC_ALL_LIST, - COINGECKO_LIST, - KLEROS_LIST, - GEMINI_LIST, - WRAPPED_LIST, - SET_LIST, - ARBITRUM_LIST, - OPTIMISM_LIST, - CELO_LIST, - ...UNSUPPORTED_LIST_URLS, -] +export const DEFAULT_ACTIVE_LIST_URLS: string[] = [FUJI_LIST] +export const DEFAULT_INACTIVE_LIST_URLS: string[] = [...UNSUPPORTED_LIST_URLS] export const DEFAULT_LIST_OF_LISTS: string[] = [...DEFAULT_ACTIVE_LIST_URLS, ...DEFAULT_INACTIVE_LIST_URLS] diff --git a/src/constants/networks.ts b/src/constants/networks.ts index d59f5594b36..f5ae9c24145 100644 --- a/src/constants/networks.ts +++ b/src/constants/networks.ts @@ -24,68 +24,13 @@ export const FALLBACK_URLS: { [key in SupportedChainId]: string[] } = { 'https://rpc.ankr.com/eth', 'https://eth-mainnet.public.blastapi.io', ], - [SupportedChainId.ROPSTEN]: [ - // "Fallback" URLs - 'https://rpc.ankr.com/eth_ropsten', - ], - [SupportedChainId.RINKEBY]: [ - // "Fallback" URLs - 'https://rinkeby-light.eth.linkpool.io/', - ], - [SupportedChainId.GOERLI]: [ - // "Safe" URLs - 'https://rpc.goerli.mudit.blog/', - // "Fallback" URLs - 'https://rpc.ankr.com/eth_goerli', - ], - [SupportedChainId.KOVAN]: [ - // "Safe" URLs - 'https://kovan.poa.network', - // "Fallback" URLs - 'https://eth-kovan.public.blastapi.io', - ], - [SupportedChainId.POLYGON]: [ - // "Safe" URLs - 'https://polygon-rpc.com/', - 'https://rpc-mainnet.matic.network', - 'https://matic-mainnet.chainstacklabs.com', - 'https://rpc-mainnet.maticvigil.com', - 'https://rpc-mainnet.matic.quiknode.pro', - 'https://matic-mainnet-full-rpc.bwarelabs.com', - ], - [SupportedChainId.POLYGON_MUMBAI]: [ - // "Safe" URLs - 'https://matic-mumbai.chainstacklabs.com', - 'https://rpc-mumbai.maticvigil.com', - 'https://matic-testnet-archive-rpc.bwarelabs.com', - ], - [SupportedChainId.ARBITRUM_ONE]: [ - // "Safe" URLs - 'https://arb1.arbitrum.io/rpc', - // "Fallback" URLs - 'https://arbitrum.public-rpc.com', - ], - [SupportedChainId.ARBITRUM_RINKEBY]: [ + [SupportedChainId.FUJI]: [ // "Safe" URLs - 'https://rinkeby.arbitrum.io/rpc', + 'https://ava-testnet.public.blastapi.io/ext/bc/C/rpc ', ], [SupportedChainId.OPTIMISM]: [ // "Safe" URLs - 'https://mainnet.optimism.io/', - // "Fallback" URLs - 'https://rpc.ankr.com/optimism', - ], - [SupportedChainId.OPTIMISM_GOERLI]: [ - // "Safe" URLs - 'https://goerli.optimism.io', - ], - [SupportedChainId.CELO]: [ - // "Safe" URLs - `https://forno.celo.org`, - ], - [SupportedChainId.CELO_ALFAJORES]: [ - // "Safe" URLs - `https://alfajores-forno.celo-testnet.org`, + 'https://ava-testnet.public.blastapi.io/ext/bc/C/rpc ', ], } @@ -98,40 +43,6 @@ export const RPC_URLS: { [key in SupportedChainId]: string[] } = { `https://mainnet.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[SupportedChainId.MAINNET], ], - [SupportedChainId.RINKEBY]: [ - `https://rinkeby.infura.io/v3/${INFURA_KEY}`, - ...FALLBACK_URLS[SupportedChainId.RINKEBY], - ], - [SupportedChainId.ROPSTEN]: [ - `https://ropsten.infura.io/v3/${INFURA_KEY}`, - ...FALLBACK_URLS[SupportedChainId.ROPSTEN], - ], - [SupportedChainId.GOERLI]: [`https://goerli.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[SupportedChainId.GOERLI]], - [SupportedChainId.KOVAN]: [`https://kovan.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[SupportedChainId.KOVAN]], - [SupportedChainId.OPTIMISM]: [ - `https://optimism-mainnet.infura.io/v3/${INFURA_KEY}`, - ...FALLBACK_URLS[SupportedChainId.OPTIMISM], - ], - [SupportedChainId.OPTIMISM_GOERLI]: [ - `https://optimism-goerli.infura.io/v3/${INFURA_KEY}`, - ...FALLBACK_URLS[SupportedChainId.OPTIMISM_GOERLI], - ], - [SupportedChainId.ARBITRUM_ONE]: [ - `https://arbitrum-mainnet.infura.io/v3/${INFURA_KEY}`, - ...FALLBACK_URLS[SupportedChainId.ARBITRUM_ONE], - ], - [SupportedChainId.ARBITRUM_RINKEBY]: [ - `https://arbitrum-rinkeby.infura.io/v3/${INFURA_KEY}`, - ...FALLBACK_URLS[SupportedChainId.ARBITRUM_RINKEBY], - ], - [SupportedChainId.POLYGON]: [ - `https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`, - ...FALLBACK_URLS[SupportedChainId.POLYGON], - ], - [SupportedChainId.POLYGON_MUMBAI]: [ - `https://polygon-mumbai.infura.io/v3/${INFURA_KEY}`, - ...FALLBACK_URLS[SupportedChainId.POLYGON_MUMBAI], - ], - [SupportedChainId.CELO]: FALLBACK_URLS[SupportedChainId.CELO], - [SupportedChainId.CELO_ALFAJORES]: FALLBACK_URLS[SupportedChainId.CELO_ALFAJORES], + [SupportedChainId.FUJI]: [`https://api.avax-test.network/ext/bc/C/rpc `, ...FALLBACK_URLS[SupportedChainId.FUJI]], + [SupportedChainId.OPTIMISM]: [`https://api.avax-test.network/ext/bc/C/rpc `, ...FALLBACK_URLS[SupportedChainId.FUJI]], } diff --git a/src/constants/providers.ts b/src/constants/providers.ts index f0262b726b0..d62379149db 100644 --- a/src/constants/providers.ts +++ b/src/constants/providers.ts @@ -57,17 +57,7 @@ class AppJsonRpcProvider extends StaticJsonRpcProvider { * These are the only JsonRpcProviders used directly by the interface. */ export const RPC_PROVIDERS: { [key in SupportedChainId]: StaticJsonRpcProvider } = { + [SupportedChainId.FUJI]: new AppJsonRpcProvider(SupportedChainId.FUJI), [SupportedChainId.MAINNET]: new AppJsonRpcProvider(SupportedChainId.MAINNET), - [SupportedChainId.RINKEBY]: new AppJsonRpcProvider(SupportedChainId.RINKEBY), - [SupportedChainId.ROPSTEN]: new AppJsonRpcProvider(SupportedChainId.ROPSTEN), - [SupportedChainId.GOERLI]: new AppJsonRpcProvider(SupportedChainId.GOERLI), - [SupportedChainId.KOVAN]: new AppJsonRpcProvider(SupportedChainId.KOVAN), [SupportedChainId.OPTIMISM]: new AppJsonRpcProvider(SupportedChainId.OPTIMISM), - [SupportedChainId.OPTIMISM_GOERLI]: new AppJsonRpcProvider(SupportedChainId.OPTIMISM_GOERLI), - [SupportedChainId.ARBITRUM_ONE]: new AppJsonRpcProvider(SupportedChainId.ARBITRUM_ONE), - [SupportedChainId.ARBITRUM_RINKEBY]: new AppJsonRpcProvider(SupportedChainId.ARBITRUM_RINKEBY), - [SupportedChainId.POLYGON]: new AppJsonRpcProvider(SupportedChainId.POLYGON), - [SupportedChainId.POLYGON_MUMBAI]: new AppJsonRpcProvider(SupportedChainId.POLYGON_MUMBAI), - [SupportedChainId.CELO]: new AppJsonRpcProvider(SupportedChainId.CELO), - [SupportedChainId.CELO_ALFAJORES]: new AppJsonRpcProvider(SupportedChainId.CELO_ALFAJORES), } diff --git a/src/constants/routing.ts b/src/constants/routing.ts index 6b0b96f8dab..9acdfd36d61 100644 --- a/src/constants/routing.ts +++ b/src/constants/routing.ts @@ -2,45 +2,7 @@ import { Currency, Token } from '@uniswap/sdk-core' import { SupportedChainId } from './chains' -import { - AMPL, - CEUR_CELO, - CEUR_CELO_ALFAJORES, - CMC02_CELO, - CUSD_CELO, - CUSD_CELO_ALFAJORES, - DAI, - DAI_ARBITRUM_ONE, - DAI_OPTIMISM, - DAI_POLYGON, - ETH2X_FLI, - FEI, - FRAX, - FXS, - nativeOnChain, - PORTAL_ETH_CELO, - PORTAL_USDC_CELO, - renBTC, - rETH2, - sETH2, - SWISE, - TRIBE, - USDC_ARBITRUM, - USDC_MAINNET, - USDC_OPTIMISM, - USDC_POLYGON, - USDT, - USDT_ARBITRUM_ONE, - USDT_OPTIMISM, - USDT_POLYGON, - WBTC, - WBTC_ARBITRUM_ONE, - WBTC_OPTIMISM, - WBTC_POLYGON, - WETH_POLYGON, - WETH_POLYGON_MUMBAI, - WRAPPED_NATIVE_CURRENCY, -} from './tokens' +import { nativeOnChain, USDC_FUJI, WETH_FUJI, WRAPPED_NATIVE_CURRENCY } from './tokens' type ChainTokenList = { readonly [chainId: number]: Token[] @@ -59,56 +21,15 @@ const WRAPPED_NATIVE_CURRENCIES_ONLY: ChainTokenList = Object.fromEntries( // used to construct intermediary pairs for trading export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { ...WRAPPED_NATIVE_CURRENCIES_ONLY, - [SupportedChainId.MAINNET]: [ - ...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.MAINNET], - DAI, - USDC_MAINNET, - USDT, - WBTC, - ], - [SupportedChainId.OPTIMISM]: [ - ...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.OPTIMISM], - DAI_OPTIMISM, - USDT_OPTIMISM, - WBTC_OPTIMISM, - ], - [SupportedChainId.ARBITRUM_ONE]: [ - ...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.ARBITRUM_ONE], - DAI_ARBITRUM_ONE, - USDT_ARBITRUM_ONE, - WBTC_ARBITRUM_ONE, - ], - [SupportedChainId.POLYGON]: [ - ...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.POLYGON], - DAI_POLYGON, - USDC_POLYGON, - USDT_POLYGON, - WETH_POLYGON, - ], - [SupportedChainId.CELO]: [CUSD_CELO, CEUR_CELO, CMC02_CELO, PORTAL_USDC_CELO, PORTAL_ETH_CELO], -} -export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = { - [SupportedChainId.MAINNET]: { - '0xF16E4d813f4DcfDe4c5b44f305c908742De84eF0': [ETH2X_FLI], - [rETH2.address]: [sETH2], - [SWISE.address]: [sETH2], - [FEI.address]: [TRIBE], - [TRIBE.address]: [FEI], - [FRAX.address]: [FXS], - [FXS.address]: [FRAX], - [WBTC.address]: [renBTC], - [renBTC.address]: [WBTC], - }, + [SupportedChainId.MAINNET]: [...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.MAINNET]], + [SupportedChainId.FUJI]: [USDC_FUJI, WETH_FUJI], } +export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = {} /** * Some tokens can only be swapped via certain pairs, so we override the list of bases that are considered for these * tokens. */ -export const CUSTOM_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = { - [SupportedChainId.MAINNET]: { - [AMPL.address]: [DAI, WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token], - }, -} +export const CUSTOM_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = {} /** * Shows up in the currency select for swap and add liquidity @@ -116,101 +37,16 @@ export const CUSTOM_BASES: { [chainId: number]: { [tokenAddress: string]: Token[ export const COMMON_BASES: ChainCurrencyList = { [SupportedChainId.MAINNET]: [ nativeOnChain(SupportedChainId.MAINNET), - DAI, - USDC_MAINNET, - USDT, - WBTC, - WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token, - ], - [SupportedChainId.ROPSTEN]: [ - nativeOnChain(SupportedChainId.ROPSTEN), - WRAPPED_NATIVE_CURRENCY[SupportedChainId.ROPSTEN] as Token, - ], - [SupportedChainId.RINKEBY]: [ - nativeOnChain(SupportedChainId.RINKEBY), - WRAPPED_NATIVE_CURRENCY[SupportedChainId.RINKEBY] as Token, - ], - [SupportedChainId.GOERLI]: [ - nativeOnChain(SupportedChainId.GOERLI), - WRAPPED_NATIVE_CURRENCY[SupportedChainId.GOERLI] as Token, - ], - [SupportedChainId.KOVAN]: [ - nativeOnChain(SupportedChainId.KOVAN), - WRAPPED_NATIVE_CURRENCY[SupportedChainId.KOVAN] as Token, - ], - [SupportedChainId.ARBITRUM_ONE]: [ - nativeOnChain(SupportedChainId.ARBITRUM_ONE), - DAI_ARBITRUM_ONE, - USDC_ARBITRUM, - USDT_ARBITRUM_ONE, - WBTC_ARBITRUM_ONE, - WRAPPED_NATIVE_CURRENCY[SupportedChainId.ARBITRUM_ONE] as Token, - ], - [SupportedChainId.ARBITRUM_RINKEBY]: [ - nativeOnChain(SupportedChainId.ARBITRUM_RINKEBY), - WRAPPED_NATIVE_CURRENCY[SupportedChainId.ARBITRUM_RINKEBY] as Token, - ], - [SupportedChainId.OPTIMISM]: [ - nativeOnChain(SupportedChainId.OPTIMISM), - DAI_OPTIMISM, - USDC_OPTIMISM, - USDT_OPTIMISM, - WBTC_OPTIMISM, - ], - [SupportedChainId.OPTIMISM_GOERLI]: [nativeOnChain(SupportedChainId.OPTIMISM_GOERLI)], - [SupportedChainId.POLYGON]: [ - nativeOnChain(SupportedChainId.POLYGON), - WETH_POLYGON, - USDC_POLYGON, - DAI_POLYGON, - USDT_POLYGON, - WBTC_POLYGON, - ], - [SupportedChainId.POLYGON_MUMBAI]: [ - nativeOnChain(SupportedChainId.POLYGON_MUMBAI), - WRAPPED_NATIVE_CURRENCY[SupportedChainId.POLYGON_MUMBAI] as Token, - WETH_POLYGON_MUMBAI, - ], - [SupportedChainId.CELO]: [ - nativeOnChain(SupportedChainId.CELO), - CEUR_CELO, - CUSD_CELO, - PORTAL_ETH_CELO, - PORTAL_USDC_CELO, - CMC02_CELO, - ], - [SupportedChainId.CELO_ALFAJORES]: [ - nativeOnChain(SupportedChainId.CELO_ALFAJORES), - CUSD_CELO_ALFAJORES, - CEUR_CELO_ALFAJORES, + WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token, ], + [SupportedChainId.FUJI]: [nativeOnChain(SupportedChainId.FUJI), USDC_FUJI], } // used to construct the list of all pairs we consider by default in the frontend export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = { ...WRAPPED_NATIVE_CURRENCIES_ONLY, - [SupportedChainId.MAINNET]: [ - ...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.MAINNET], - DAI, - USDC_MAINNET, - USDT, - WBTC, - ], -} -export const PINNED_PAIRS: { readonly [chainId: number]: [Token, Token][] } = { - [SupportedChainId.MAINNET]: [ - [ - new Token(SupportedChainId.MAINNET, '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643', 8, 'cDAI', 'Compound Dai'), - new Token( - SupportedChainId.MAINNET, - '0x39AA39c021dfbaE8faC545936693aC917d5E7563', - 8, - 'cUSDC', - 'Compound USD Coin' - ), - ], - [USDC_MAINNET, USDT], - [DAI, USDT], - ], + [SupportedChainId.MAINNET]: [...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.MAINNET]], + [SupportedChainId.FUJI]: [...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.FUJI], USDC_FUJI], } +export const PINNED_PAIRS: { readonly [chainId: number]: [Token, Token][] } = {} diff --git a/src/constants/tokens.ts b/src/constants/tokens.ts index 09dbb21663b..7025d87a6ff 100644 --- a/src/constants/tokens.ts +++ b/src/constants/tokens.ts @@ -1,7 +1,6 @@ -import { Currency, Ether, NativeCurrency, Token, WETH9 } from '@uniswap/sdk-core' +import { Currency, Ether, NativeCurrency, Token } from '@uniswap/sdk-core' import invariant from 'tiny-invariant' -import { UNI_ADDRESS } from './addresses' import { SupportedChainId } from './chains' export const NATIVE_CHAIN_ID = 'NATIVE' @@ -11,420 +10,70 @@ export const NATIVE_CHAIN_ID = 'NATIVE' // https://docs.openzeppelin.com/contracts/3.x/erc20 export const DEFAULT_ERC20_DECIMALS = 18 -export const USDC_MAINNET = new Token( - SupportedChainId.MAINNET, - '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', - 6, - 'USDC', - 'USD//C' -) -const USDC_ROPSTEN = new Token( - SupportedChainId.ROPSTEN, - '0x07865c6e87b9f70255377e024ace6630c1eaa37f', - 6, - 'USDC', - 'USD//C' -) -const USDC_RINKEBY = new Token( - SupportedChainId.RINKEBY, - '0x4DBCdF9B62e891a7cec5A2568C3F4FAF9E8Abe2b', - 6, - 'tUSDC', - 'test USD//C' -) -const USDC_GOERLI = new Token( - SupportedChainId.GOERLI, - '0x07865c6e87b9f70255377e024ace6630c1eaa37f', - 6, - 'USDC', - 'USD//C' -) -const USDC_KOVAN = new Token(SupportedChainId.KOVAN, '0x31eeb2d0f9b6fd8642914ab10f4dd473677d80df', 6, 'USDC', 'USD//C') -export const USDC_OPTIMISM = new Token( - SupportedChainId.OPTIMISM, - '0x7F5c764cBc14f9669B88837ca1490cCa17c31607', - 6, - 'USDC', - 'USD//C' -) -const USDC_OPTIMISM_GOERLI = new Token( - SupportedChainId.OPTIMISM_GOERLI, - '0x7E07E15D2a87A24492740D16f5bdF58c16db0c4E', - 6, - 'USDC', - 'USD//C' -) -export const USDC_ARBITRUM = new Token( - SupportedChainId.ARBITRUM_ONE, - '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', - 6, - 'USDC', - 'USD//C' -) -const USDC_ARBITRUM_RINKEBY = new Token( - SupportedChainId.ARBITRUM_RINKEBY, - '0x09b98f8b2395d076514037ff7d39a091a536206c', - 6, - 'USDC', - 'USD//C' -) -export const USDC_POLYGON = new Token( - SupportedChainId.POLYGON, - '0x2791bca1f2de4661ed88a30c99a7a9449aa84174', - 6, - 'USDC', - 'USD//C' -) -const USDC_POLYGON_MUMBAI = new Token( - SupportedChainId.POLYGON_MUMBAI, - '0xe11a86849d99f524cac3e7a0ec1241828e332c62', - 6, +export const USDC_FUJI = new Token( + SupportedChainId.FUJI, + '0xeC5bfc01218e1CA43027A987c185E94A67AeDB6D', + 18, 'USDC', 'USD//C' ) -export const PORTAL_USDC_CELO = new Token( - SupportedChainId.CELO, - '0x37f750B7cC259A2f741AF45294f6a16572CF5cAd', - 6, - 'USDCet', - 'USDC (Portal from Ethereum)' -) -export const AMPL = new Token( - SupportedChainId.MAINNET, - '0xD46bA6D942050d489DBd938a2C909A5d5039A161', - 9, - 'AMPL', - 'Ampleforth' -) -export const DAI = new Token( - SupportedChainId.MAINNET, - '0x6B175474E89094C44Da98b954EedeAC495271d0F', - 18, - 'DAI', - 'Dai Stablecoin' -) -export const DAI_ARBITRUM_ONE = new Token( - SupportedChainId.ARBITRUM_ONE, - '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1', - 18, - 'DAI', - 'Dai stable coin' -) -export const DAI_OPTIMISM = new Token( - SupportedChainId.OPTIMISM, - '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1', - 18, - 'DAI', - 'Dai stable coin' -) -export const DAI_POLYGON = new Token( - SupportedChainId.POLYGON, - '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063', - 18, - 'DAI', - 'Dai Stablecoin' -) -export const USDT_POLYGON = new Token( - SupportedChainId.POLYGON, - '0xc2132d05d31c914a87c6611c10748aeb04b58e8f', - 6, - 'USDT', - 'Tether USD' -) -export const WBTC_POLYGON = new Token( - SupportedChainId.POLYGON, - '0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6', - 8, - 'WBTC', - 'Wrapped BTC' -) -export const USDT = new Token( - SupportedChainId.MAINNET, - '0xdAC17F958D2ee523a2206206994597C13D831ec7', - 6, - 'USDT', - 'Tether USD' -) -export const USDT_ARBITRUM_ONE = new Token( - SupportedChainId.ARBITRUM_ONE, - '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9', - 6, - 'USDT', - 'Tether USD' -) -export const USDT_OPTIMISM = new Token( - SupportedChainId.OPTIMISM, - '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58', - 6, - 'USDT', - 'Tether USD' -) -export const WBTC = new Token( - SupportedChainId.MAINNET, - '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', - 8, - 'WBTC', - 'Wrapped BTC' -) -export const WBTC_ARBITRUM_ONE = new Token( - SupportedChainId.ARBITRUM_ONE, - '0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f', - 8, - 'WBTC', - 'Wrapped BTC' -) -export const WBTC_OPTIMISM = new Token( - SupportedChainId.OPTIMISM, - '0x68f180fcCe6836688e9084f035309E29Bf0A2095', - 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 ETH2X_FLI = new Token( - SupportedChainId.MAINNET, - '0xAa6E8127831c9DE45ae56bB1b0d4D4Da6e5665BD', - 18, - 'ETH2x-FLI', - 'ETH 2x Flexible Leverage Index' -) -export const sETH2 = new Token( - SupportedChainId.MAINNET, - '0xFe2e637202056d30016725477c5da089Ab0A043A', - 18, - 'sETH2', - 'StakeWise Staked ETH2' -) -export const rETH2 = new Token( - SupportedChainId.MAINNET, - '0x20BC832ca081b91433ff6c17f85701B6e92486c5', - 18, - 'rETH2', - 'StakeWise Reward ETH2' -) -export const SWISE = new Token( - SupportedChainId.MAINNET, - '0x48C3399719B582dD63eB5AADf12A40B4C3f52FA2', - 18, - 'SWISE', - 'StakeWise' -) -export const WETH_POLYGON_MUMBAI = new Token( - SupportedChainId.POLYGON_MUMBAI, - '0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa', - 18, - 'WETH', - 'Wrapped Ether' -) -export const WETH_POLYGON = new Token( - SupportedChainId.POLYGON, - '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619', +export const WETH_FUJI = new Token( + SupportedChainId.FUJI, + '0x0F70b839BDdC6E95113cA3A51dFfC0CEd73d55a5', 18, 'WETH', 'Wrapped Ether' ) -const CELO_CELO = new Token(SupportedChainId.CELO, '0x471EcE3750Da237f93B8E339c536989b8978a438', 18, 'CELO', 'Celo') -export const CUSD_CELO = new Token( - SupportedChainId.CELO, - '0x765DE816845861e75A25fCA122bb6898B8B1282a', - 18, - 'cUSD', - 'Celo Dollar' -) -export const CEUR_CELO = new Token( - SupportedChainId.CELO, - '0xD8763CBa276a3738E6DE85b4b3bF5FDed6D6cA73', - 18, - 'cEUR', - 'Celo Euro Stablecoin' -) -export const PORTAL_ETH_CELO = new Token( - SupportedChainId.CELO, - '0x66803FB87aBd4aaC3cbB3fAd7C3aa01f6F3FB207', - 18, - 'ETH', - 'Portal Ether' -) -export const CMC02_CELO = new Token( - SupportedChainId.CELO, - '0x32A9FE697a32135BFd313a6Ac28792DaE4D9979d', - 18, - 'cMCO2', - 'Celo Moss Carbon Credit' -) -const CELO_CELO_ALFAJORES = new Token( - SupportedChainId.CELO_ALFAJORES, - '0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9', - 18, - 'CELO', - 'Celo' -) -export const CUSD_CELO_ALFAJORES = new Token( - SupportedChainId.CELO_ALFAJORES, - '0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1', - 18, - 'CUSD', - 'Celo Dollar' -) -export const CEUR_CELO_ALFAJORES = new Token( - SupportedChainId.CELO_ALFAJORES, - '0x10c892A6EC43a53E45D0B916B4b7D383B1b78C0F', - 18, - 'CEUR', - 'Celo Euro Stablecoin' -) -export const UNI: { [chainId: number]: Token } = { - [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.ROPSTEN]: new Token(SupportedChainId.ROPSTEN, UNI_ADDRESS[3], 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'), -} +export const UNI: { [chainId: number]: Token } = {} export const WRAPPED_NATIVE_CURRENCY: { [chainId: number]: Token | undefined } = { - ...(WETH9 as Record), - [SupportedChainId.OPTIMISM]: new Token( - SupportedChainId.OPTIMISM, - '0x4200000000000000000000000000000000000006', - 18, - 'WETH', - 'Wrapped Ether' - ), - [SupportedChainId.OPTIMISM_GOERLI]: new Token( - SupportedChainId.OPTIMISM_GOERLI, - '0x4200000000000000000000000000000000000006', - 18, - 'WETH', - 'Wrapped Ether' - ), - [SupportedChainId.ARBITRUM_ONE]: new Token( - SupportedChainId.ARBITRUM_ONE, - '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1', + [SupportedChainId.FUJI]: new Token( + SupportedChainId.FUJI, + '0x1D308089a2D1Ced3f1Ce36B1FcaF815b07217be3', 18, - 'WETH', - 'Wrapped Ether' + 'WAVAX', + 'Wrapped AVAX' ), - [SupportedChainId.ARBITRUM_RINKEBY]: new Token( - SupportedChainId.ARBITRUM_RINKEBY, - '0xB47e6A5f8b33b3F17603C83a0535A9dcD7E32681', - 18, - 'WETH', - 'Wrapped Ether' - ), - [SupportedChainId.POLYGON]: new Token( - SupportedChainId.POLYGON, - '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', + [SupportedChainId.MAINNET]: new Token( + SupportedChainId.FUJI, + '0x0F70b839BDdC6E95113cA3A51dFfC0CEd73d55a5', 18, 'WMATIC', 'Wrapped MATIC' ), - [SupportedChainId.POLYGON_MUMBAI]: new Token( - SupportedChainId.POLYGON_MUMBAI, - '0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889', - 18, - 'WMATIC', - 'Wrapped MATIC' - ), - [SupportedChainId.CELO]: new Token( - SupportedChainId.CELO, - '0x471ece3750da237f93b8e339c536989b8978a438', - 18, - 'CELO', - 'Celo native asset' - ), - [SupportedChainId.CELO_ALFAJORES]: new Token( - SupportedChainId.CELO_ALFAJORES, - '0xf194afdf50b03e69bd7d057c1aa9e10c9954e4c9', - 18, - 'CELO', - 'Celo native asset' - ), -} - -export function isCelo(chainId: number): chainId is SupportedChainId.CELO | SupportedChainId.CELO_ALFAJORES { - return chainId === SupportedChainId.CELO_ALFAJORES || chainId === SupportedChainId.CELO } -function getCeloNativeCurrency(chainId: number) { - switch (chainId) { - case SupportedChainId.CELO_ALFAJORES: - return CELO_CELO_ALFAJORES - case SupportedChainId.CELO: - return CELO_CELO - default: - throw new Error('Not celo') +class ExtendedEther extends Ether { + public get wrapped(): Token { + const wrapped = WRAPPED_NATIVE_CURRENCY[this.chainId] + if (wrapped) return wrapped + throw new Error('Unsupported chain ID') } -} -function isMatic(chainId: number): chainId is SupportedChainId.POLYGON | SupportedChainId.POLYGON_MUMBAI { - return chainId === SupportedChainId.POLYGON_MUMBAI || chainId === SupportedChainId.POLYGON + private static _cachedExtendedEther: { [chainId: number]: NativeCurrency } = {} + + public static onChain(chainId: number): ExtendedEther { + return this._cachedExtendedEther[chainId] ?? (this._cachedExtendedEther[chainId] = new ExtendedEther(chainId)) + } } -class MaticNativeCurrency extends NativeCurrency { +class FujiNativeCurrency extends NativeCurrency { equals(other: Currency): boolean { return other.isNative && other.chainId === this.chainId } get wrapped(): Token { - if (!isMatic(this.chainId)) throw new Error('Not matic') + if (this.chainId !== SupportedChainId.FUJI) throw new Error('Not Fuji') const wrapped = WRAPPED_NATIVE_CURRENCY[this.chainId] invariant(wrapped instanceof Token) return wrapped } public constructor(chainId: number) { - if (!isMatic(chainId)) throw new Error('Not matic') - super(chainId, 18, 'MATIC', 'Polygon Matic') - } -} - -class ExtendedEther extends Ether { - public get wrapped(): Token { - const wrapped = WRAPPED_NATIVE_CURRENCY[this.chainId] - if (wrapped) return wrapped - throw new Error('Unsupported chain ID') - } - - private static _cachedExtendedEther: { [chainId: number]: NativeCurrency } = {} - - public static onChain(chainId: number): ExtendedEther { - return this._cachedExtendedEther[chainId] ?? (this._cachedExtendedEther[chainId] = new ExtendedEther(chainId)) + if (chainId !== SupportedChainId.FUJI) throw new Error('Not Fuji') + super(chainId, 18, 'AVAX', 'Avax') } } @@ -432,10 +81,8 @@ const cachedNativeCurrency: { [chainId: number]: NativeCurrency | Token } = {} export function nativeOnChain(chainId: number): NativeCurrency | Token { if (cachedNativeCurrency[chainId]) return cachedNativeCurrency[chainId] let nativeCurrency: NativeCurrency | Token - if (isMatic(chainId)) { - nativeCurrency = new MaticNativeCurrency(chainId) - } else if (isCelo(chainId)) { - nativeCurrency = getCeloNativeCurrency(chainId) + if (chainId === SupportedChainId.FUJI) { + nativeCurrency = new FujiNativeCurrency(chainId) } else { nativeCurrency = ExtendedEther.onChain(chainId) } @@ -444,18 +91,6 @@ export function nativeOnChain(chainId: number): NativeCurrency | Token { export const TOKEN_SHORTHANDS: { [shorthand: string]: { [chainId in SupportedChainId]?: string } } = { USDC: { - [SupportedChainId.MAINNET]: USDC_MAINNET.address, - [SupportedChainId.ARBITRUM_ONE]: USDC_ARBITRUM.address, - [SupportedChainId.OPTIMISM]: USDC_OPTIMISM.address, - [SupportedChainId.ARBITRUM_RINKEBY]: USDC_ARBITRUM_RINKEBY.address, - [SupportedChainId.OPTIMISM_GOERLI]: USDC_OPTIMISM_GOERLI.address, - [SupportedChainId.POLYGON]: USDC_POLYGON.address, - [SupportedChainId.POLYGON_MUMBAI]: USDC_POLYGON_MUMBAI.address, - [SupportedChainId.CELO]: PORTAL_USDC_CELO.address, - [SupportedChainId.CELO_ALFAJORES]: PORTAL_USDC_CELO.address, - [SupportedChainId.GOERLI]: USDC_GOERLI.address, - [SupportedChainId.RINKEBY]: USDC_RINKEBY.address, - [SupportedChainId.KOVAN]: USDC_KOVAN.address, - [SupportedChainId.ROPSTEN]: USDC_ROPSTEN.address, + [SupportedChainId.FUJI]: USDC_FUJI.address, }, } diff --git a/src/graphql/data/SearchTokens.ts b/src/graphql/data/SearchTokens.ts index e041d2e6bd9..d2505ce49a1 100644 --- a/src/graphql/data/SearchTokens.ts +++ b/src/graphql/data/SearchTokens.ts @@ -50,7 +50,7 @@ function isMoreRevelantToken(current: SearchToken, existing: SearchToken | undef if (current.standard === 'NATIVE' && (existing.standard !== 'NATIVE' || current.chain === searchChain)) return true // Prefer tokens on the searched chain, otherwise prefer mainnet tokens - return current.chain === searchChain || (existing.chain !== searchChain && current.chain === Chain.Ethereum) + return current.chain === searchChain || (existing.chain !== searchChain && current.chain === Chain.Evmos) } // Places natives first, wrapped native on current chain next, then sorts by volume diff --git a/src/graphql/data/__generated__/types-and-hooks.ts b/src/graphql/data/__generated__/types-and-hooks.ts index 0d61b4addd6..8fe5d218853 100644 --- a/src/graphql/data/__generated__/types-and-hooks.ts +++ b/src/graphql/data/__generated__/types-and-hooks.ts @@ -77,12 +77,8 @@ export type AssetActivity = { export type AssetChange = NftApproval | NftApproveForAll | NftTransfer | TokenApproval | TokenTransfer; export enum Chain { - Arbitrum = 'ARBITRUM', - Celo = 'CELO', - Ethereum = 'ETHEREUM', - EthereumGoerli = 'ETHEREUM_GOERLI', - Optimism = 'OPTIMISM', - Polygon = 'POLYGON', + Fuji = 'FUJI', + Evmos = 'EVMOS', UnknownChain = 'UNKNOWN_CHAIN' } @@ -96,11 +92,6 @@ export enum Currency { Usd = 'USD' } -export enum DatasourceProvider { - Alternate = 'ALTERNATE', - Legacy = 'LEGACY' -} - export type Dimensions = { __typename?: 'Dimensions'; height?: Maybe; @@ -145,6 +136,49 @@ export enum MarketSortableField { Volume = 'VOLUME' } +export type NftActivity = { + __typename?: 'NftActivity'; + address: Scalars['String']; + asset?: Maybe; + fromAddress: Scalars['String']; + id: Scalars['ID']; + marketplace?: Maybe; + orderStatus?: Maybe; + price?: Maybe; + quantity?: Maybe; + timestamp: Scalars['Int']; + toAddress?: Maybe; + tokenId?: Maybe; + transactionHash?: Maybe; + type: NftActivityType; + url?: Maybe; +}; + +export type NftActivityConnection = { + __typename?: 'NftActivityConnection'; + edges: Array; + pageInfo: PageInfo; +}; + +export type NftActivityEdge = { + __typename?: 'NftActivityEdge'; + cursor: Scalars['String']; + node: NftActivity; +}; + +export type NftActivityFilterInput = { + activityTypes?: InputMaybe>; + address?: InputMaybe; + tokenId?: InputMaybe; +}; + +export enum NftActivityType { + CancelListing = 'CANCEL_LISTING', + Listing = 'LISTING', + Sale = 'SALE', + Transfer = 'TRANSFER' +} + export type NftApproval = { __typename?: 'NftApproval'; approvedAddress: Scalars['String']; @@ -196,7 +230,6 @@ export type NftAssetListingsArgs = { after?: InputMaybe; asc?: InputMaybe; before?: InputMaybe; - datasource?: InputMaybe; first?: InputMaybe; last?: InputMaybe; }; @@ -311,7 +344,6 @@ export type NftCollection = { export type NftCollectionMarketsArgs = { currencies: Array; - datasource?: InputMaybe; }; export type NftCollectionConnection = { @@ -602,6 +634,7 @@ export type PortfolioTokensTotalDenominatedValueChangeArgs = { export type Query = { __typename?: 'Query'; + nftActivity?: Maybe; nftAssets?: Maybe; nftBalances?: Maybe; nftCollections?: Maybe; @@ -617,13 +650,20 @@ export type Query = { }; +export type QueryNftActivityArgs = { + chain?: InputMaybe; + cursor?: InputMaybe; + filter?: InputMaybe; + limit?: InputMaybe; +}; + + export type QueryNftAssetsArgs = { address: Scalars['String']; after?: InputMaybe; asc?: InputMaybe; before?: InputMaybe; chain?: InputMaybe; - datasource?: InputMaybe; filter?: InputMaybe; first?: InputMaybe; last?: InputMaybe; @@ -636,7 +676,6 @@ export type QueryNftBalancesArgs = { before?: InputMaybe; chain?: InputMaybe; cursor?: InputMaybe; - datasource?: InputMaybe; filter?: InputMaybe; first?: InputMaybe; last?: InputMaybe; @@ -646,12 +685,10 @@ export type QueryNftBalancesArgs = { export type QueryNftCollectionsArgs = { - after?: InputMaybe; - before?: InputMaybe; - datasource?: InputMaybe; + chain?: InputMaybe; + cursor?: InputMaybe; filter?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; + limit?: InputMaybe; }; @@ -670,7 +707,6 @@ export type QueryNftRouteArgs = { export type QueryPortfoliosArgs = { ownerAddresses: Array; - useAltDataSource?: InputMaybe; }; diff --git a/src/graphql/data/util.tsx b/src/graphql/data/util.tsx index 695d5f94e18..40810d49957 100644 --- a/src/graphql/data/util.tsx +++ b/src/graphql/data/util.tsx @@ -55,16 +55,8 @@ export function isPricePoint(p: PricePoint | null): p is PricePoint { } export const CHAIN_ID_TO_BACKEND_NAME: { [key: number]: Chain } = { - [SupportedChainId.MAINNET]: Chain.Ethereum, - [SupportedChainId.GOERLI]: Chain.EthereumGoerli, - [SupportedChainId.POLYGON]: Chain.Polygon, - [SupportedChainId.POLYGON_MUMBAI]: Chain.Polygon, - [SupportedChainId.CELO]: Chain.Celo, - [SupportedChainId.CELO_ALFAJORES]: Chain.Celo, - [SupportedChainId.ARBITRUM_ONE]: Chain.Arbitrum, - [SupportedChainId.ARBITRUM_RINKEBY]: Chain.Arbitrum, - [SupportedChainId.OPTIMISM]: Chain.Optimism, - [SupportedChainId.OPTIMISM_GOERLI]: Chain.Optimism, + [SupportedChainId.MAINNET]: Chain.Evmos, + [SupportedChainId.FUJI]: Chain.Fuji, } export function chainIdToBackendName(chainId: number | undefined) { @@ -74,26 +66,20 @@ export function chainIdToBackendName(chainId: number | undefined) { } const URL_CHAIN_PARAM_TO_BACKEND: { [key: string]: Chain } = { - ethereum: Chain.Ethereum, - polygon: Chain.Polygon, - celo: Chain.Celo, - arbitrum: Chain.Arbitrum, - optimism: Chain.Optimism, + evmos: Chain.Evmos, + fuji: Chain.Fuji, } export function validateUrlChainParam(chainName: string | undefined) { - return chainName && URL_CHAIN_PARAM_TO_BACKEND[chainName] ? URL_CHAIN_PARAM_TO_BACKEND[chainName] : Chain.Ethereum + return chainName && URL_CHAIN_PARAM_TO_BACKEND[chainName] ? URL_CHAIN_PARAM_TO_BACKEND[chainName] : Chain.Evmos } export const CHAIN_NAME_TO_CHAIN_ID: { [key: string]: SupportedChainId } = { - ETHEREUM: SupportedChainId.MAINNET, - POLYGON: SupportedChainId.POLYGON, - CELO: SupportedChainId.CELO, - ARBITRUM: SupportedChainId.ARBITRUM_ONE, - OPTIMISM: SupportedChainId.OPTIMISM, + EVMOS: SupportedChainId.MAINNET, + FUJI: SupportedChainId.FUJI, } -export const BACKEND_CHAIN_NAMES: Chain[] = [Chain.Ethereum, Chain.Polygon, Chain.Optimism, Chain.Arbitrum, Chain.Celo] +export const BACKEND_CHAIN_NAMES: Chain[] = [Chain.Evmos, Chain.Fuji] export function getTokenDetailsURL({ address, chain }: { address?: string | null; chain: Chain }) { return `/tokens/${chain.toLowerCase()}/${address ?? NATIVE_CHAIN_ID}` diff --git a/src/graphql/thegraph/apollo.ts b/src/graphql/thegraph/apollo.ts index f9831b2f3dd..383d9960556 100644 --- a/src/graphql/thegraph/apollo.ts +++ b/src/graphql/thegraph/apollo.ts @@ -5,15 +5,8 @@ import store, { AppState } from '../../state/index' const CHAIN_SUBGRAPH_URL: Record = { [SupportedChainId.MAINNET]: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3', - [SupportedChainId.RINKEBY]: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3', - [SupportedChainId.ARBITRUM_ONE]: 'https://api.thegraph.com/subgraphs/name/ianlapham/arbitrum-minimal', - - [SupportedChainId.OPTIMISM]: 'https://api.thegraph.com/subgraphs/name/ianlapham/optimism-post-regenesis', - - [SupportedChainId.POLYGON]: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon', - - [SupportedChainId.CELO]: 'https://api.thegraph.com/subgraphs/name/jesse-sawa/uniswap-celo', + [SupportedChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/orbital-apes-labs/v3-subgraph', } const httpLink = new HttpLink({ uri: CHAIN_SUBGRAPH_URL[SupportedChainId.MAINNET] }) diff --git a/src/hooks/Tokens.ts b/src/hooks/Tokens.ts index 36db93648e2..0d895e87204 100644 --- a/src/hooks/Tokens.ts +++ b/src/hooks/Tokens.ts @@ -1,12 +1,9 @@ import { Currency, Token } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' -import { getChainInfo } from 'constants/chainInfo' -import { SupportedChainId } from 'constants/chains' import { DEFAULT_INACTIVE_LIST_URLS } from 'constants/lists' import { useCurrencyFromMap, useTokenFromMapOrNetwork } from 'lib/hooks/useCurrency' import { getTokenFilter } from 'lib/hooks/useTokenList/filtering' import { useMemo } from 'react' -import { isL2ChainId } from 'utils/chains' import { useAllLists, useCombinedActiveList } from '../state/lists/hooks' import { WrappedTokenInfo } from '../state/lists/wrappedTokenInfo' @@ -48,57 +45,11 @@ export function useAllTokens(): { [address: string]: Token } { }, [tokensFromMap, userAddedTokens]) } -type BridgeInfo = Record< - SupportedChainId, - { - tokenAddress: string - originBridgeAddress: string - destBridgeAddress: string - } -> - export function useUnsupportedTokens(): { [address: string]: Token } { - const { chainId } = useWeb3React() - const listsByUrl = useAllLists() const unsupportedTokensMap = useUnsupportedTokenList() const unsupportedTokens = useTokensFromMap(unsupportedTokensMap) - // checks the default L2 lists to see if `bridgeInfo` has an L1 address value that is unsupported - const l2InferredBlockedTokens: typeof unsupportedTokens = useMemo(() => { - if (!chainId || !isL2ChainId(chainId)) { - return {} - } - - if (!listsByUrl) { - return {} - } - - const listUrl = getChainInfo(chainId).defaultListUrl - - const { current: list } = listsByUrl[listUrl] - if (!list) { - return {} - } - - const unsupportedSet = new Set(Object.keys(unsupportedTokens)) - - return list.tokens.reduce((acc, tokenInfo) => { - const bridgeInfo = tokenInfo.extensions?.bridgeInfo as unknown as BridgeInfo - if ( - bridgeInfo && - bridgeInfo[SupportedChainId.MAINNET] && - bridgeInfo[SupportedChainId.MAINNET].tokenAddress && - unsupportedSet.has(bridgeInfo[SupportedChainId.MAINNET].tokenAddress) - ) { - const address = bridgeInfo[SupportedChainId.MAINNET].tokenAddress - // don't rely on decimals--it's possible that a token could be bridged w/ different decimals on the L2 - return { ...acc, [address]: new Token(SupportedChainId.MAINNET, address, tokenInfo.decimals) } - } - return acc - }, {}) - }, [chainId, listsByUrl, unsupportedTokens]) - - return { ...unsupportedTokens, ...l2InferredBlockedTokens } + return { ...unsupportedTokens } } export function useSearchInactiveTokenLists(search: string | undefined, minResults = 10): WrappedTokenInfo[] { diff --git a/src/hooks/useClientSideV3Trade.ts b/src/hooks/useClientSideV3Trade.ts index b8ba6fe55a0..b767530d7cb 100644 --- a/src/hooks/useClientSideV3Trade.ts +++ b/src/hooks/useClientSideV3Trade.ts @@ -7,17 +7,11 @@ import { useSingleContractWithCallData } from 'lib/hooks/multicall' import { useMemo } from 'react' import { InterfaceTrade, TradeState } from 'state/routing/types' -import { isCelo } from '../constants/tokens' import { useAllV3Routes } from './useAllV3Routes' import { useQuoter } from './useContract' const QUOTE_GAS_OVERRIDES: { [chainId: number]: number } = { - [SupportedChainId.ARBITRUM_ONE]: 25_000_000, - [SupportedChainId.ARBITRUM_RINKEBY]: 25_000_000, - [SupportedChainId.CELO]: 50_000_000, - [SupportedChainId.CELO_ALFAJORES]: 50_000_000, - [SupportedChainId.POLYGON]: 40_000_000, - [SupportedChainId.POLYGON_MUMBAI]: 40_000_000, + [SupportedChainId.FUJI]: 40_000_000, } const DEFAULT_GAS_QUOTE = 2_000_000 @@ -41,7 +35,7 @@ export function useClientSideV3Trade( const { chainId } = useWeb3React() // Chains deployed using the deploy-v3 script only deploy QuoterV2. - const useQuoterV2 = useMemo(() => Boolean(chainId && isCelo(chainId)), [chainId]) + const useQuoterV2 = useMemo(() => Boolean(chainId && true), [chainId]) const quoter = useQuoter(useQuoterV2) const callData = useMemo( () => diff --git a/src/hooks/useERC20Permit.ts b/src/hooks/useERC20Permit.ts index 9d4280c1d42..b794cedb9e9 100644 --- a/src/hooks/useERC20Permit.ts +++ b/src/hooks/useERC20Permit.ts @@ -8,7 +8,7 @@ import { useSingleCallResult } from 'lib/hooks/multicall' import { useMemo, useState } from 'react' import { SWAP_ROUTER_ADDRESSES } from '../constants/addresses' -import { DAI, UNI, USDC_MAINNET } from '../constants/tokens' +import { USDC_FUJI } from '../constants/tokens' import { useEIP2612Contract } from './useContract' import useIsArgentWallet from './useIsArgentWallet' @@ -33,24 +33,11 @@ const PERMITTABLE_TOKENS: { [checksummedTokenAddress: string]: PermitInfo } } = { - 1: { - [USDC_MAINNET.address]: { type: PermitType.AMOUNT, name: 'USD Coin', version: '2' }, - [DAI.address]: { type: PermitType.ALLOWED, name: 'Dai Stablecoin', version: '1' }, - [UNI[1].address]: { type: PermitType.AMOUNT, name: 'Uniswap' }, + 43113: { + [USDC_FUJI.address]: { type: PermitType.AMOUNT, name: 'USD Coin', version: '2' }, }, - 4: { - '0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735': { type: PermitType.ALLOWED, name: 'Dai Stablecoin', version: '1' }, - [UNI[4].address]: { type: PermitType.AMOUNT, name: 'Uniswap' }, - }, - 3: { - [UNI[3].address]: { type: PermitType.AMOUNT, name: 'Uniswap' }, - '0x07865c6E87B9F70255377e024ace6630C1Eaa37F': { type: PermitType.AMOUNT, name: 'USD Coin', version: '2' }, - }, - 5: { - [UNI[5].address]: { type: PermitType.AMOUNT, name: 'Uniswap' }, - }, - 42: { - [UNI[42].address]: { type: PermitType.AMOUNT, name: 'Uniswap' }, + 9001: { + [USDC_FUJI.address]: { type: PermitType.AMOUNT, name: 'USD Coin', version: '2' }, }, } diff --git a/src/hooks/usePoolTickData.ts b/src/hooks/usePoolTickData.ts index acbcab2ddd8..53fb4c66e55 100644 --- a/src/hooks/usePoolTickData.ts +++ b/src/hooks/usePoolTickData.ts @@ -15,7 +15,7 @@ import { useTickLens } from './useContract' import { PoolState, usePool } from './usePools' const PRICE_FIXED_DIGITS = 8 -const CHAIN_IDS_MISSING_SUBGRAPH_DATA = [SupportedChainId.ARBITRUM_ONE, SupportedChainId.ARBITRUM_RINKEBY] +const CHAIN_IDS_MISSING_SUBGRAPH_DATA = [SupportedChainId.OPTIMISM] // Tick with fields parsed to JSBIs, and active liquidity computed. export interface TickProcessed { diff --git a/src/hooks/useStablecoinPrice.ts b/src/hooks/useStablecoinPrice.ts index 70e7b833fc7..aa2ccf2906d 100644 --- a/src/hooks/useStablecoinPrice.ts +++ b/src/hooks/useStablecoinPrice.ts @@ -6,16 +6,14 @@ import { RouterPreference } from 'state/routing/slice' import { useRoutingAPITrade } from 'state/routing/useRoutingAPITrade' import { SupportedChainId } from '../constants/chains' -import { CUSD_CELO, DAI_OPTIMISM, USDC_ARBITRUM, USDC_MAINNET, USDC_POLYGON } from '../constants/tokens' +import { USDC_FUJI } from '../constants/tokens' // Stablecoin amounts used when calculating spot price for a given currency. // The amount is large enough to filter low liquidity pairs. const STABLECOIN_AMOUNT_OUT: { [chainId: number]: CurrencyAmount } = { - [SupportedChainId.MAINNET]: CurrencyAmount.fromRawAmount(USDC_MAINNET, 100_000e6), - [SupportedChainId.ARBITRUM_ONE]: CurrencyAmount.fromRawAmount(USDC_ARBITRUM, 10_000e6), - [SupportedChainId.OPTIMISM]: CurrencyAmount.fromRawAmount(DAI_OPTIMISM, 10_000e18), - [SupportedChainId.POLYGON]: CurrencyAmount.fromRawAmount(USDC_POLYGON, 10_000e6), - [SupportedChainId.CELO]: CurrencyAmount.fromRawAmount(CUSD_CELO, 10_000e18), + // TODO: replace USDC fuji by mainnet + [SupportedChainId.MAINNET]: CurrencyAmount.fromRawAmount(USDC_FUJI, 100_000e6), + [SupportedChainId.FUJI]: CurrencyAmount.fromRawAmount(USDC_FUJI, 10_000e18), } /** diff --git a/src/lib/hooks/transactions/updater.tsx b/src/lib/hooks/transactions/updater.tsx index 8a852926804..24e9e549720 100644 --- a/src/lib/hooks/transactions/updater.tsx +++ b/src/lib/hooks/transactions/updater.tsx @@ -31,9 +31,8 @@ export function shouldCheck(lastBlockNumber: number, tx: Transaction): boolean { } const RETRY_OPTIONS_BY_CHAIN_ID: { [chainId: number]: RetryOptions } = { - [SupportedChainId.ARBITRUM_ONE]: { n: 10, minWait: 250, maxWait: 1000 }, - [SupportedChainId.ARBITRUM_RINKEBY]: { n: 10, minWait: 250, maxWait: 1000 }, - [SupportedChainId.OPTIMISM_GOERLI]: { n: 10, minWait: 250, maxWait: 1000 }, + [SupportedChainId.FUJI]: { n: 10, minWait: 250, maxWait: 1000 }, + [SupportedChainId.MAINNET]: { n: 10, minWait: 250, maxWait: 1000 }, [SupportedChainId.OPTIMISM]: { n: 10, minWait: 250, maxWait: 1000 }, } const DEFAULT_RETRY_OPTIONS: RetryOptions = { n: 1, minWait: 0, maxWait: 0 } diff --git a/src/lib/hooks/useCurrencyLogoURIs.ts b/src/lib/hooks/useCurrencyLogoURIs.ts index 291a494a029..458a5f67555 100644 --- a/src/lib/hooks/useCurrencyLogoURIs.ts +++ b/src/lib/hooks/useCurrencyLogoURIs.ts @@ -4,53 +4,34 @@ import { useMemo } from 'react' import { isAddress } from 'utils' import EthereumLogo from '../../assets/images/ethereum-logo.png' -import CeloLogo from '../../assets/svg/celo_logo.svg' -import MaticLogo from '../../assets/svg/matic-token-icon.svg' -import { isCelo, NATIVE_CHAIN_ID, nativeOnChain } from '../../constants/tokens' +import { NATIVE_CHAIN_ID } from '../../constants/tokens' -type Network = 'ethereum' | 'arbitrum' | 'optimism' | 'polygon' +type Network = 'evmos' | 'fuji' export function chainIdToNetworkName(networkId: SupportedChainId): Network { switch (networkId) { - case SupportedChainId.MAINNET: - return 'ethereum' - case SupportedChainId.ARBITRUM_ONE: - return 'arbitrum' - case SupportedChainId.OPTIMISM: - return 'optimism' - case SupportedChainId.POLYGON: - return 'polygon' + case SupportedChainId.FUJI: + return 'fuji' default: - return 'ethereum' + return 'evmos' } } -export function getNativeLogoURI(chainId: SupportedChainId = SupportedChainId.MAINNET): string { +export function getNativeLogoURI(chainId: SupportedChainId = SupportedChainId.FUJI): string { switch (chainId) { - case SupportedChainId.POLYGON: - case SupportedChainId.POLYGON_MUMBAI: - return MaticLogo - case SupportedChainId.CELO: - case SupportedChainId.CELO_ALFAJORES: - return CeloLogo + case SupportedChainId.FUJI: + return 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/assets/0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7/logo.png' default: return EthereumLogo } } -function getTokenLogoURI(address: string, chainId: SupportedChainId = SupportedChainId.MAINNET): string | void { +function getTokenLogoURI(address: string, chainId: SupportedChainId = SupportedChainId.FUJI): string | void { const networkName = chainIdToNetworkName(chainId) - const networksWithUrls = [SupportedChainId.ARBITRUM_ONE, SupportedChainId.MAINNET, SupportedChainId.OPTIMISM] + const networksWithUrls = [SupportedChainId.FUJI, SupportedChainId.MAINNET] if (networksWithUrls.includes(chainId)) { return `https://raw.githubusercontent.com/Uniswap/assets/master/blockchains/${networkName}/assets/${address}/logo.png` } - - // Celo logo logo is hosted elsewhere. - if (isCelo(chainId)) { - if (address === nativeOnChain(chainId).wrapped.address) { - return 'https://raw.githubusercontent.com/ubeswap/default-token-list/master/assets/asset_CELO.png' - } - } } export default function useCurrencyLogoURIs( diff --git a/src/lib/state/multicall.tsx b/src/lib/state/multicall.tsx index 4a75ff2b091..d7ed0329ca5 100644 --- a/src/lib/state/multicall.tsx +++ b/src/lib/state/multicall.tsx @@ -11,11 +11,10 @@ export default multicall function getBlocksPerFetchForChainId(chainId: number | undefined): number { switch (chainId) { - case SupportedChainId.ARBITRUM_ONE: case SupportedChainId.OPTIMISM: return 15 - case SupportedChainId.CELO: - case SupportedChainId.CELO_ALFAJORES: + case SupportedChainId.MAINNET: + case SupportedChainId.FUJI: return 5 default: return 1 diff --git a/src/state/stake/hooks.tsx b/src/state/stake/hooks.tsx index 88c2a6cb664..58bb03cbca1 100644 --- a/src/state/stake/hooks.tsx +++ b/src/state/stake/hooks.tsx @@ -9,7 +9,7 @@ import JSBI from 'jsbi' import { NEVER_RELOAD, useMultipleContractSingleData } from 'lib/hooks/multicall' import { useMemo } from 'react' -import { DAI, UNI, USDC_MAINNET, USDT, WBTC, WRAPPED_NATIVE_CURRENCY } from '../../constants/tokens' +import { UNI, USDC_FUJI, WRAPPED_NATIVE_CURRENCY } from '../../constants/tokens' const STAKING_REWARDS_INTERFACE = new Interface(STAKING_REWARDS_ABI) @@ -23,21 +23,14 @@ const STAKING_REWARDS_INFO: { } = { 1: [ { - tokens: [WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token, DAI], + // TODO: replace USDC_FUJI with mainnet + tokens: [WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token, USDC_FUJI], stakingRewardAddress: '0xa1484C3aa22a66C62b77E0AE78E15258bd0cB711', }, { - tokens: [WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token, USDC_MAINNET], + tokens: [WRAPPED_NATIVE_CURRENCY[SupportedChainId.FUJI] as Token, USDC_FUJI], stakingRewardAddress: '0x7FBa4B8Dc5E7616e59622806932DBea72537A56b', }, - { - tokens: [WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token, USDT], - stakingRewardAddress: '0x6C3e4cb2E96B01F4b866965A91ed4437839A121a', - }, - { - tokens: [WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token, WBTC], - stakingRewardAddress: '0xCA35e32e7926b96A9988f61d510E038108d8068e', - }, ], } diff --git a/src/theme/components/RadialGradientByChainUpdater.ts b/src/theme/components/RadialGradientByChainUpdater.ts index 93245feaa41..87cd2b55741 100644 --- a/src/theme/components/RadialGradientByChainUpdater.ts +++ b/src/theme/components/RadialGradientByChainUpdater.ts @@ -47,28 +47,7 @@ export default function RadialGradientByChainUpdater(): null { } switch (chainId) { - case SupportedChainId.ARBITRUM_ONE: - case SupportedChainId.ARBITRUM_RINKEBY: { - setBackground(backgroundResetStyles) - const arbitrumLightGradient = - 'radial-gradient(100% 100% at 50% 0%, rgba(205, 232, 251, 0.7) 0%, rgba(252, 243, 249, 0.6536) 49.48%, rgba(255, 255, 255, 0) 100%), #FFFFFF' - const arbitrumDarkGradient = - 'radial-gradient(100% 100% at 50% 0%, rgba(10, 41, 75, 0.7) 0%, rgba(34, 30, 48, 0.6536) 49.48%, rgba(31, 33, 40, 0) 100%), #0D0E0E' - backgroundRadialGradientElement.style.background = darkMode ? arbitrumDarkGradient : arbitrumLightGradient - break - } - case SupportedChainId.OPTIMISM: - case SupportedChainId.OPTIMISM_GOERLI: { - setBackground(backgroundResetStyles) - const optimismLightGradient = - 'radial-gradient(100% 100% at 50% 0%, rgba(255, 251, 242, 0.8) 0%, rgba(255, 244, 249, 0.6958) 50.52%, rgba(255, 255, 255, 0) 100%), #FFFFFF' - const optimismDarkGradient = - 'radial-gradient(100% 100% at 50% 0%, rgba(62, 46, 56, 0.8) 0%, rgba(44, 31, 45, 0.6958) 50.52%, rgba(31, 33, 40, 0) 100%), #0D0E0E' - backgroundRadialGradientElement.style.background = darkMode ? optimismDarkGradient : optimismLightGradient - break - } - case SupportedChainId.POLYGON: - case SupportedChainId.POLYGON_MUMBAI: { + case SupportedChainId.FUJI: { setBackground(backgroundResetStyles) const polygonLightGradient = 'radial-gradient(100% 100% at 50% 0%, rgba(130, 71, 229, 0.2) 0%, rgba(200, 168, 255, 0.05) 52.6%, rgba(0, 0, 0, 0) 100%), #FFFFFF' @@ -77,16 +56,6 @@ export default function RadialGradientByChainUpdater(): null { backgroundRadialGradientElement.style.background = darkMode ? polygonDarkGradient : polygonLightGradient break } - case SupportedChainId.CELO: - case SupportedChainId.CELO_ALFAJORES: { - setBackground(backgroundResetStyles) - const celoLightGradient = - 'radial-gradient(100% 100% at 50% 0%, rgba(186, 228, 210, 0.7) 0%, rgba(252, 243, 249, 0.6536) 49.48%, rgba(255, 255, 255, 0) 100%), #FFFFFF' - const celoDarkGradient = - 'radial-gradient(100% 100% at 50% 0%, rgba(20, 49, 37, 0.29) 0%, rgba(12, 31, 23, 0.6536) 49.48%, rgba(31, 33, 40, 0) 100%, rgba(31, 33, 40, 0) 100%), #0D0E0E' - backgroundRadialGradientElement.style.background = darkMode ? celoDarkGradient : celoLightGradient - break - } default: { setBackground(initialStyles) const defaultLightGradient = diff --git a/src/utils/constructSameAddressMap.ts b/src/utils/constructSameAddressMap.ts index 6001852ab46..019406700c8 100644 --- a/src/utils/constructSameAddressMap.ts +++ b/src/utils/constructSameAddressMap.ts @@ -1,12 +1,6 @@ import { SupportedChainId } from '../constants/chains' -const DEFAULT_NETWORKS = [ - SupportedChainId.MAINNET, - SupportedChainId.ROPSTEN, - SupportedChainId.RINKEBY, - SupportedChainId.GOERLI, - SupportedChainId.KOVAN, -] +const DEFAULT_NETWORKS = [SupportedChainId.FUJI, SupportedChainId.MAINNET] export function constructSameAddressMap( address: T, diff --git a/src/utils/getExplorerLink.ts b/src/utils/getExplorerLink.ts index 379c9a5620c..f1c72980ef6 100644 --- a/src/utils/getExplorerLink.ts +++ b/src/utils/getExplorerLink.ts @@ -2,16 +2,7 @@ import { SupportedChainId } from '../constants/chains' const BLOCK_EXPLORER_PREFIXES: { [chainId: number]: string } = { [SupportedChainId.MAINNET]: 'https://etherscan.io', - [SupportedChainId.ROPSTEN]: 'https://ropsten.etherscan.io', - [SupportedChainId.RINKEBY]: 'https://rinkeby.etherscan.io', - [SupportedChainId.GOERLI]: 'https://goerli.etherscan.io', - [SupportedChainId.KOVAN]: 'https://kovan.etherscan.io', - [SupportedChainId.OPTIMISM]: 'https://optimistic.etherscan.io', - [SupportedChainId.OPTIMISM_GOERLI]: 'https://goerli-optimism.etherscan.io', - [SupportedChainId.POLYGON]: 'https://polygonscan.com', - [SupportedChainId.POLYGON_MUMBAI]: 'https://mumbai.polygonscan.com', - [SupportedChainId.CELO]: 'https://celoscan.io', - [SupportedChainId.CELO_ALFAJORES]: 'https://alfajores-blockscout.celo-testnet.org', + [SupportedChainId.FUJI]: 'https://etherscan.io', } export enum ExplorerDataType { @@ -28,34 +19,6 @@ export enum ExplorerDataType { * @param type the type of the data */ export function getExplorerLink(chainId: number, data: string, type: ExplorerDataType): string { - if (chainId === SupportedChainId.ARBITRUM_ONE) { - switch (type) { - case ExplorerDataType.TRANSACTION: - return `https://arbiscan.io/tx/${data}` - case ExplorerDataType.ADDRESS: - case ExplorerDataType.TOKEN: - return `https://arbiscan.io/address/${data}` - case ExplorerDataType.BLOCK: - return `https://arbiscan.io/block/${data}` - default: - return `https://arbiscan.io/` - } - } - - if (chainId === SupportedChainId.ARBITRUM_RINKEBY) { - switch (type) { - case ExplorerDataType.TRANSACTION: - return `https://rinkeby-explorer.arbitrum.io/tx/${data}` - case ExplorerDataType.ADDRESS: - case ExplorerDataType.TOKEN: - return `https://rinkeby-explorer.arbitrum.io/address/${data}` - case ExplorerDataType.BLOCK: - return `https://rinkeby-explorer.arbitrum.io/block/${data}` - default: - return `https://rinkeby-explorer.arbitrum.io/` - } - } - const prefix = BLOCK_EXPLORER_PREFIXES[chainId] ?? 'https://etherscan.io' switch (type) { @@ -66,9 +29,6 @@ export function getExplorerLink(chainId: number, data: string, type: ExplorerDat return `${prefix}/token/${data}` case ExplorerDataType.BLOCK: - if (chainId === SupportedChainId.OPTIMISM || chainId === SupportedChainId.OPTIMISM_GOERLI) { - return `${prefix}/tx/${data}` - } return `${prefix}/block/${data}` case ExplorerDataType.ADDRESS: diff --git a/src/utils/nativeTokens.ts b/src/utils/nativeTokens.ts index f057f393473..23ab2e89422 100644 --- a/src/utils/nativeTokens.ts +++ b/src/utils/nativeTokens.ts @@ -5,13 +5,9 @@ import { CHAIN_NAME_TO_CHAIN_ID } from 'graphql/data/util' export function getNativeTokenDBAddress(chain: Chain): string | undefined { const pageChainId = CHAIN_NAME_TO_CHAIN_ID[chain] switch (chain) { - case Chain.Celo: - case Chain.Polygon: + case Chain.Evmos: + case Chain.Fuji: return nativeOnChain(pageChainId).wrapped.address - case Chain.Ethereum: - case Chain.Arbitrum: - case Chain.EthereumGoerli: - case Chain.Optimism: default: return undefined } diff --git a/src/utils/switchChain.ts b/src/utils/switchChain.ts index da1187b683f..470d6110d36 100644 --- a/src/utils/switchChain.ts +++ b/src/utils/switchChain.ts @@ -7,10 +7,7 @@ import { FALLBACK_URLS, RPC_URLS } from 'constants/networks' function getRpcUrl(chainId: SupportedChainId): string { switch (chainId) { case SupportedChainId.MAINNET: - case SupportedChainId.RINKEBY: - case SupportedChainId.ROPSTEN: - case SupportedChainId.KOVAN: - case SupportedChainId.GOERLI: + case SupportedChainId.FUJI: return RPC_URLS[chainId][0] // Attempting to add a chain using an infura URL will not work, as the URL will be unreachable from the MetaMask background page. // MetaMask allows switching to any publicly reachable URL, but for novel chains, it will display a warning if it is not on the "Safe" list. diff --git a/src/utils/unwrappedToken.ts b/src/utils/unwrappedToken.ts index 315126a7835..6a6583641f7 100644 --- a/src/utils/unwrappedToken.ts +++ b/src/utils/unwrappedToken.ts @@ -6,7 +6,9 @@ import { supportedChainId } from './supportedChainId' export function unwrappedToken(currency: Currency): Currency { if (currency.isNative) return currency const formattedChainId = supportedChainId(currency.chainId) - if (formattedChainId && WRAPPED_NATIVE_CURRENCY[formattedChainId]?.equals(currency)) - return nativeOnChain(currency.chainId) + if (formattedChainId && WRAPPED_NATIVE_CURRENCY[formattedChainId]?.equals(currency)) { + const _nativeOnChain = nativeOnChain(currency.chainId) + return _nativeOnChain.wrapped ? _nativeOnChain.wrapped : _nativeOnChain + } return currency } From 7dcab8d842a7bef61aa60f096dee667e67c56f91 Mon Sep 17 00:00:00 2001 From: 0xctrlaltape Date: Sun, 26 Feb 2023 16:54:03 +0400 Subject: [PATCH 02/55] add router api --- src/state/routing/slice.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state/routing/slice.ts b/src/state/routing/slice.ts index 9d0a7c88288..cc03e5e77f2 100644 --- a/src/state/routing/slice.ts +++ b/src/state/routing/slice.ts @@ -67,7 +67,7 @@ const PRICE_PARAMS = { export const routingApi = createApi({ reducerPath: 'routingApi', baseQuery: fetchBaseQuery({ - baseUrl: 'https://api.uniswap.org/v1/', + baseUrl: 'https://21x5w4o8d6.execute-api.us-east-1.amazonaws.com/prod/', }), endpoints: (build) => ({ getQuote: build.query< From 26eca1a039d28939119d125b5830e3e0cba56bf0 Mon Sep 17 00:00:00 2001 From: Mrsirdev Date: Mon, 27 Feb 2023 21:13:10 -0500 Subject: [PATCH 03/55] update navbar, show pools, hide tokens --- src/components/NavBar/index.tsx | 34 +- src/components/Pools/PoolTable.tsx | 348 ++++++++++++++ .../WalletDropdown/AuthenticatedHeader.tsx | 22 +- src/components/WalletDropdown/DefaultMenu.tsx | 8 +- src/components/shared/index.tsx | 27 ++ src/pages/App.tsx | 96 +--- src/pages/Pools/index.tsx | 73 +++ src/pages/Pools/poolData.ts | 441 ++++++++++++++++++ 8 files changed, 915 insertions(+), 134 deletions(-) create mode 100644 src/components/Pools/PoolTable.tsx create mode 100644 src/components/shared/index.tsx create mode 100644 src/pages/Pools/index.tsx create mode 100644 src/pages/Pools/poolData.ts diff --git a/src/components/NavBar/index.tsx b/src/components/NavBar/index.tsx index 7eb51edddb7..970174c4a9a 100644 --- a/src/components/NavBar/index.tsx +++ b/src/components/NavBar/index.tsx @@ -1,8 +1,6 @@ import { Trans } from '@lingui/macro' -import { useWeb3React } from '@web3-react/core' import Web3Status from 'components/Web3Status' import { NftListV2Variant, useNftListV2Flag } from 'featureFlags/flags/nftListV2' -import { chainIdToBackendName } from 'graphql/data/util' import { useIsNftPage } from 'hooks/useIsNftPage' import { Box } from 'nft/components/Box' import { Row } from 'nft/components/Flex' @@ -50,28 +48,32 @@ const MenuItem = ({ href, dataTestId, id, isActive, children }: MenuItemProps) = export const PageTabs = () => { const { pathname } = useLocation() - const { chainId: connectedChainId } = useWeb3React() - const chainName = chainIdToBackendName(connectedChainId) const isPoolActive = - pathname.startsWith('/pool') || - pathname.startsWith('/add') || - pathname.startsWith('/remove') || - pathname.startsWith('/increase') - - const isNftPage = useIsNftPage() + (pathname.startsWith('/pool') || + pathname.startsWith('/add') || + pathname.startsWith('/remove') || + pathname.startsWith('/increase')) && + !pathname.startsWith('/pools') return ( <> Swap - - Tokens + + Pools - + + NFTs - + + Pool @@ -113,9 +115,7 @@ const Navbar = () => { - - - + diff --git a/src/components/Pools/PoolTable.tsx b/src/components/Pools/PoolTable.tsx new file mode 100644 index 00000000000..34a6f3b7e5f --- /dev/null +++ b/src/components/Pools/PoolTable.tsx @@ -0,0 +1,348 @@ +import { Token } from '@uniswap/sdk-core' +import Card from 'components/Card' +import { AutoColumn } from 'components/Column' +import DoubleCurrencyLogo from 'components/DoubleLogo' +import Loader from 'components/Loader' +import { LoadingRows } from 'components/Loader/styled' +import { RowFixed } from 'components/Row' +import { Arrow, Break, PageButtons } from 'components/shared' +import { MAX_WIDTH_MEDIA_BREAKPOINT } from 'components/Tokens/constants' +import { SupportedChainId } from 'constants/chains' +import numbro from 'numbro' +import React, { useCallback, useEffect, useMemo, useState } from 'react' +import { Link } from 'react-router-dom' +import { Text } from 'rebass' +import styled from 'styled-components/macro' +import { darkTheme } from 'theme/colors' + +const GreyBadge = styled(Card)` + width: fit-content; + border-radius: 8px; + background: ${darkTheme.background}; + color: ${darkTheme.textPrimary}; + padding: 4px 6px; + font-weight: 400; +` + +const DarkGreyCard = styled(Card)` + background-color: ${darkTheme.background}; +` + +const formatDollarAmount = (num: number | undefined, digits = 2, round = true) => { + if (num === 0) return '$0.00' + if (!num) return '-' + if (num < 0.001 && digits <= 3) { + return '<$0.001' + } + + return numbro(num).formatCurrency({ + average: round, + mantissa: num > 1000 ? 2 : digits, + abbreviations: { + million: 'M', + billion: 'B', + }, + }) +} + +const TextWrapper = styled(Text)<{ color: string; fontSize: number; fontWeight: number }>` + color: ${({ color, theme }) => (theme as any)[color]}; +` + +function feeTierPercent(fee: number): string { + return (fee / 10000).toPrecision(1) + '%' +} + +const Label = styled.div<{ end?: number }>` + display: flex; + font-size: 16px; + font-weight: 400; + justify-content: ${({ end }) => (end ? 'flex-end' : 'flex-start')}; + align-items: center; + font-variant-numeric: tabular-nums; + @media screen and (max-width: 640px) { + font-size: 14px; + } +` + +const ClickableText = styled(Label)` + text-align: end; + &:hover { + cursor: pointer; + opacity: 0.6; + } + user-select: none; + @media screen and (max-width: 640px) { + font-size: 12px; + } +` + +export interface PoolData { + // basic token info + address: string + feeTier: number + + token0: { + name: string + symbol: string + address: string + decimals: number + derivedETH: number + } + + token1: { + name: string + symbol: string + address: string + decimals: number + derivedETH: number + } + + // for tick math + liquidity: number + sqrtPrice: number + tick: number + + // volume + volumeUSD: number + volumeUSDChange: number + volumeUSDWeek: number + + // liquidity + tvlUSD: number + tvlUSDChange: number + + // prices + token0Price: number + token1Price: number + + // token amounts + tvlToken0: number + tvlToken1: number +} + +const Wrapper = styled(DarkGreyCard)` + width: 100%; +` + +const ResponsiveGrid = styled.div` + display: grid; + grid-gap: 1em; + align-items: center; + + grid-template-columns: 20px 3.5fr repeat(3, 1fr); + + @media screen and (max-width: 900px) { + grid-template-columns: 20px 1.5fr repeat(2, 1fr); + & :nth-child(3) { + display: none; + } + } + + @media screen and (max-width: 500px) { + grid-template-columns: 20px 1.5fr repeat(1, 1fr); + & :nth-child(5) { + display: none; + } + } + + @media screen and (max-width: 480px) { + grid-template-columns: 2.5fr repeat(1, 1fr); + > *:nth-child(1) { + display: none; + } + } +` + +const LinkWrapper = styled(Link)` + text-decoration: none; + :hover { + cursor: pointer; + opacity: 0.7; + } +` + +const SORT_FIELD = { + feeTier: 'feeTier', + volumeUSD: 'volumeUSD', + tvlUSD: 'tvlUSD', + volumeUSDWeek: 'volumeUSDWeek', +} + +const GridContainer = styled.div` + display: flex; + flex-direction: column; + max-width: ${MAX_WIDTH_MEDIA_BREAKPOINT}; + background-color: ${({ theme }) => theme.backgroundSurface}; + box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.01), 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 16px 24px rgba(0, 0, 0, 0.04), + 0px 24px 32px rgba(0, 0, 0, 0.01); + margin-left: auto; + margin-right: auto; + border-radius: 12px; + justify-content: center; + align-items: center; + border: 1px solid ${({ theme }) => theme.backgroundOutline}; +` + +const DataRow = ({ poolData, index }: { poolData: PoolData; index: number }) => { + const currency0 = new Token( + SupportedChainId.FUJI, + poolData.token0.address, + poolData.token0.decimals, + poolData.token0.symbol + ) + const currency1 = new Token( + SupportedChainId.FUJI, + poolData.token1.address, + poolData.token1.decimals, + poolData.token1.symbol + ) + return ( + + + + + + + + + + ) +} + +const MAX_ITEMS = 10 + +export default function PoolTable({ poolDatas, maxItems = MAX_ITEMS }: { poolDatas: PoolData[]; maxItems?: number }) { + // for sorting + const [sortField, setSortField] = useState(SORT_FIELD.tvlUSD) + const [sortDirection, setSortDirection] = useState(true) + + // pagination + const [page, setPage] = useState(1) + const [maxPage, setMaxPage] = useState(1) + useEffect(() => { + let extraPages = 1 + if (poolDatas.length % maxItems === 0) { + extraPages = 0 + } + setMaxPage(Math.floor(poolDatas.length / maxItems) + extraPages) + }, [maxItems, poolDatas]) + + const sortedPools = useMemo(() => { + return poolDatas + ? poolDatas + .sort((a, b) => { + if (a && b) { + return a[sortField as keyof PoolData] > b[sortField as keyof PoolData] + ? (sortDirection ? -1 : 1) * 1 + : (sortDirection ? -1 : 1) * -1 + } else { + return -1 + } + }) + .slice(maxItems * (page - 1), page * maxItems) + : [] + }, [maxItems, page, poolDatas, sortDirection, sortField]) + + const handleSort = useCallback( + (newField: string) => { + setSortField(newField) + setSortDirection(sortField !== newField ? true : !sortDirection) + }, + [sortDirection, sortField] + ) + + const arrow = useCallback( + (field: string) => { + return sortField === field ? (!sortDirection ? '↑' : '↓') : '' + }, + [sortDirection, sortField] + ) + + if (!poolDatas) { + return + } + + return ( + + + {sortedPools.length > 0 ? ( + + + + handleSort(SORT_FIELD.feeTier)}> + Pool {arrow(SORT_FIELD.feeTier)} + + handleSort(SORT_FIELD.tvlUSD)}> + TVL {arrow(SORT_FIELD.tvlUSD)} + + handleSort(SORT_FIELD.volumeUSD)}> + Volume 24H {arrow(SORT_FIELD.volumeUSD)} + + handleSort(SORT_FIELD.volumeUSDWeek)}> + Volume 7D {arrow(SORT_FIELD.volumeUSDWeek)} + + + + {sortedPools.map((poolData, i) => { + if (poolData) { + return ( + + + + + ) + } + return null + })} + +
{ + setPage(page === 1 ? page : page - 1) + }} + > + +
+ + + {'Page ' + page + ' of ' + maxPage} + +
{ + setPage(page === maxPage ? page : page + 1) + }} + > + +
+
+
+ ) : ( + +
+
+
+
+
+
+
+
+
+
+
+
+ + )} + + + ) +} diff --git a/src/components/WalletDropdown/AuthenticatedHeader.tsx b/src/components/WalletDropdown/AuthenticatedHeader.tsx index 55f339eceb9..c2f87b7edcb 100644 --- a/src/components/WalletDropdown/AuthenticatedHeader.tsx +++ b/src/components/WalletDropdown/AuthenticatedHeader.tsx @@ -13,12 +13,9 @@ import useCopyClipboard from 'hooks/useCopyClipboard' import useStablecoinPrice from 'hooks/useStablecoinPrice' import useNativeCurrency from 'lib/hooks/useNativeCurrency' import ms from 'ms.macro' -import { useProfilePageState, useSellAsset, useWalletCollections } from 'nft/hooks' import { useIsNftClaimAvailable } from 'nft/hooks/useIsNftClaimAvailable' -import { ProfilePageStateType } from 'nft/types' import { useCallback, useEffect, useMemo, useState } from 'react' import { Copy, CreditCard, ExternalLink as ExternalLinkIcon, Info, Power } from 'react-feather' -import { useNavigate } from 'react-router-dom' import { useCurrencyBalanceString } from 'state/connection/hooks' import { useAppDispatch } from 'state/hooks' import { useFiatOnrampAck } from 'state/user/hooks' @@ -27,7 +24,7 @@ import styled, { css, keyframes } from 'styled-components/macro' import { ExternalLink, ThemedText } from 'theme' import { shortenAddress } from '../../nft/utils/address' -import { useCloseModal, useFiatOnrampAvailability, useOpenModal, useToggleModal } from '../../state/application/hooks' +import { useFiatOnrampAvailability, useOpenModal, useToggleModal } from '../../state/application/hooks' import { ApplicationModal } from '../../state/application/reducer' import { useUserHasAvailableClaim, useUserUnclaimedAmount } from '../../state/claim/hooks' import StatusIcon from '../Identicon/StatusIcon' @@ -186,11 +183,6 @@ const AuthenticatedHeader = () => { nativeCurrency: { symbol: nativeCurrencySymbol }, explorer, } = getChainInfoOrDefault(chainId ? chainId : SupportedChainId.MAINNET) - const navigate = useNavigate() - const closeModal = useCloseModal() - const setSellPageState = useProfilePageState((state) => state.setProfilePageState) - const resetSellAssets = useSellAsset((state) => state.reset) - const clearCollectionFilters = useWalletCollections((state) => state.clearCollectionFilters) const isClaimAvailable = useIsNftClaimAvailable((state) => state.isClaimAvailable) const unclaimedAmount: CurrencyAmount | undefined = useUserUnclaimedAmount(account) @@ -215,14 +207,6 @@ const AuthenticatedHeader = () => { return price * balance }, [balanceString, nativeCurrencyPrice]) - const navigateToProfile = useCallback(() => { - resetSellAssets() - setSellPageState(ProfilePageStateType.VIEWING) - clearCollectionFilters() - navigate('/nfts/profile') - closeModal() - }, [clearCollectionFilters, closeModal, navigate, resetSellAssets, setSellPageState]) - // animate the border of the buy crypto button when a user navigates here from the feature announcement // can be removed when components/FiatOnrampAnnouncment.tsx is no longer used const [acknowledgements, acknowledge] = useFiatOnrampAck() @@ -307,7 +291,9 @@ const AuthenticatedHeader = () => { { + window.open('https://www.orbitmarket.io/profile/' + account) + }} size={ButtonSize.medium} emphasis={ButtonEmphasis.medium} > diff --git a/src/components/WalletDropdown/DefaultMenu.tsx b/src/components/WalletDropdown/DefaultMenu.tsx index a087aaad75b..f0cc55ae92a 100644 --- a/src/components/WalletDropdown/DefaultMenu.tsx +++ b/src/components/WalletDropdown/DefaultMenu.tsx @@ -4,9 +4,8 @@ import { TransactionSummary } from 'components/AccountDetailsV2' import { ButtonPrimary } from 'components/Button' import { useActiveLocale } from 'hooks/useActiveLocale' import { useMemo } from 'react' -import { ChevronRight, Moon, Sun } from 'react-feather' +import { ChevronRight } from 'react-feather' import { useToggleWalletModal } from 'state/application/hooks' -import { useDarkModeManager } from 'state/user/hooks' import styled from 'styled-components/macro' import { useAllTransactions } from '../../state/transactions/hooks' @@ -106,7 +105,6 @@ const CenterVertically = styled.div` const WalletDropdown = ({ setMenu }: { setMenu: (state: MenuState) => void }) => { const { account } = useWeb3React() const isAuthenticated = !!account - const [darkMode, toggleDarkMode] = useDarkModeManager() const activeLocale = useActiveLocale() const ISO = activeLocale.split('-')[0].toUpperCase() const allTransactions = useAllTransactions() @@ -170,10 +168,6 @@ const WalletDropdown = ({ setMenu }: { setMenu: (state: MenuState) => void }) => - - {darkMode ? Light theme : Dark theme} - {darkMode ? : } - ) } diff --git a/src/components/shared/index.tsx b/src/components/shared/index.tsx new file mode 100644 index 00000000000..e9c427045ca --- /dev/null +++ b/src/components/shared/index.tsx @@ -0,0 +1,27 @@ +import styled from 'styled-components/macro' +import { darkTheme } from 'theme/colors' + +export const PageButtons = styled.div` + width: 100%; + display: flex; + align-items: center; + justify-content: center; + margin-top: 0.2em; + margin-bottom: 0.5em; +` + +export const Arrow = styled.div<{ faded: boolean }>` + color: ${darkTheme.textPrimary}; + opacity: ${1}; + padding: 0 20px; + user-select: none; + :hover { + cursor: pointer; + } +` + +export const Break = styled.div` + height: 1px; + background-color: ${darkTheme.background}; + width: 100%; +` diff --git a/src/pages/App.tsx b/src/pages/App.tsx index 6124296b9cd..1b24601044d 100644 --- a/src/pages/App.tsx +++ b/src/pages/App.tsx @@ -14,12 +14,11 @@ import TopLevelModals from 'components/TopLevelModals' import { useFeatureFlagsIsLoaded } from 'featureFlags' import ApeModeQueryParamReader from 'hooks/useApeModeQueryParamReader' import { Box } from 'nft/components/Box' -import { lazy, Suspense, useEffect, useMemo, useState } from 'react' +import { Suspense, useEffect, useMemo, useState } from 'react' import { Navigate, Route, Routes, useLocation } from 'react-router-dom' import { useIsDarkMode } from 'state/user/hooks' import { StatsigProvider, StatsigUser } from 'statsig-react' import styled from 'styled-components/macro' -import { SpinnerSVG } from 'theme/components' import { flexRowNoWrap } from 'theme/styles' import { Z_INDEX } from 'theme/zIndex' import { getEnvName, isProductionEnv } from 'utils/env' @@ -35,27 +34,15 @@ import { useIsExpertMode } from '../state/user/hooks' import DarkModeQueryParamReader from '../theme/components/DarkModeQueryParamReader' import AddLiquidity from './AddLiquidity' import { RedirectDuplicateTokenIds } from './AddLiquidity/redirects' -import { RedirectDuplicateTokenIdsV2 } from './AddLiquidityV2/redirects' import Landing from './Landing' import MigrateV2 from './MigrateV2' import MigrateV2Pair from './MigrateV2/MigrateV2Pair' import NotFound from './NotFound' import Pool from './Pool' import { PositionPage } from './Pool/PositionPage' -import PoolV2 from './Pool/v2' -import PoolFinder from './PoolFinder' -import RemoveLiquidity from './RemoveLiquidity' +import Pools from './Pools' import RemoveLiquidityV3 from './RemoveLiquidity/V3' import Swap from './Swap' -import { RedirectPathToSwapOnly } from './Swap/redirects' -import Tokens from './Tokens' - -const TokenDetails = lazy(() => import('./TokenDetails')) -const Vote = lazy(() => import('./Vote')) -const NftExplore = lazy(() => import('nft/pages/explore')) -const Collection = lazy(() => import('nft/pages/collection')) -const Profile = lazy(() => import('nft/pages/profile/profile')) -const Asset = lazy(() => import('nft/pages/asset/Asset')) // Placeholder API key. Actual API key used in the proxy server const ANALYTICS_DUMMY_KEY = '00000000000000000000000000000000' @@ -131,20 +118,6 @@ function getCurrentPageFromLocation(locationPathname: string): InterfacePageName } } -// this is the same svg defined in assets/images/blue-loader.svg -// it is defined here because the remote asset may not have had time to load when this file is executing -const LazyLoadSpinner = () => ( - - - -) - export default function App() { const isLoaded = useFeatureFlagsIsLoaded() @@ -228,32 +201,13 @@ export default function App() { } /> - }> - - - } /> - }> - - - } - /> - } /> - - } /> } /> - } /> - } /> + } /> + } /> } /> - }> - - - }> {/* this is workaround since react-router-dom v6 doesn't support optional parameters any more */} @@ -268,53 +222,11 @@ export default function App() { - } /> } /> } /> } /> - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - } /> } /> diff --git a/src/pages/Pools/index.tsx b/src/pages/Pools/index.tsx new file mode 100644 index 00000000000..9247e924134 --- /dev/null +++ b/src/pages/Pools/index.tsx @@ -0,0 +1,73 @@ +import { Trans } from '@lingui/macro' +import { Trace } from '@uniswap/analytics' +import { InterfacePageName } from '@uniswap/analytics-events' +import PoolTable from 'components/Pools/PoolTable' +import { MAX_WIDTH_MEDIA_BREAKPOINT } from 'components/Tokens/constants' +import { filterStringAtom } from 'components/Tokens/state' +import { MouseoverTooltip } from 'components/Tooltip' +import { useResetAtom } from 'jotai/utils' +import { useEffect, useMemo } from 'react' +import { useLocation } from 'react-router-dom' +import styled from 'styled-components/macro' +import { ThemedText } from 'theme' + +import { usePoolDatas } from './poolData' + +const ExploreContainer = styled.div` + width: 100%; + min-width: 320px; + padding: 68px 12px 0px; + + @media only screen and (max-width: ${({ theme }) => `${theme.breakpoint.md}px`}) { + padding-top: 48px; + } + + @media only screen and (max-width: ${({ theme }) => `${theme.breakpoint.sm}px`}) { + padding-top: 20px; + } +` +const TitleContainer = styled.div` + margin-bottom: 32px; + max-width: ${MAX_WIDTH_MEDIA_BREAKPOINT}; + margin-left: auto; + margin-right: auto; + display: flex; +` +function notEmpty(value: TValue | null | undefined): value is TValue { + return value !== null && value !== undefined +} + +const Pools = () => { + const resetFilterString = useResetAtom(filterStringAtom) + const location = useLocation() + const allPoolData = usePoolDatas() + + const poolDatas = useMemo(() => { + return Object.values(allPoolData.data ?? {}) + .map((p) => p) + .filter(notEmpty) + }, [allPoolData]) + useEffect(() => { + resetFilterString() + }, [location, resetFilterString]) + + return ( + + + + This table contains the top pools by Orbitswap volume, sorted based on your input.} + placement="bottom" + > + + Top pools on Orbitswap + + + + + + + ) +} + +export default Pools diff --git a/src/pages/Pools/poolData.ts b/src/pages/Pools/poolData.ts new file mode 100644 index 00000000000..b8c1bfbcd91 --- /dev/null +++ b/src/pages/Pools/poolData.ts @@ -0,0 +1,441 @@ +import { ApolloClient, InMemoryCache, NormalizedCacheObject, useQuery } from '@apollo/client' +import { PoolData } from 'components/Pools/PoolTable' +import { SupportedChainId } from 'constants/chains' +import { WRAPPED_NATIVE_CURRENCY } from 'constants/tokens' +import dayjs from 'dayjs' +import gql from 'graphql-tag' +import { useEffect, useMemo, useState } from 'react' + +function formatTokenSymbol(address: string, symbol: string) { + if (address === WRAPPED_NATIVE_CURRENCY[SupportedChainId.FUJI]?.address) { + return 'AVAX' + } + return symbol +} + +function formatTokenName(address: string, name: string) { + if (address === WRAPPED_NATIVE_CURRENCY[SupportedChainId.FUJI]?.address) { + return 'AVAX' + } + return name +} + +const fujiClient = new ApolloClient({ + uri: 'https://api.thegraph.com/subgraphs/name/orbital-apes-labs/v3-subgraph', + cache: new InMemoryCache({ + typePolicies: { + Token: { + // Singleton types that have no identifying field can use an empty + // array for their keyFields. + keyFields: false, + }, + Pool: { + // Singleton types that have no identifying field can use an empty + // array for their keyFields. + keyFields: false, + }, + }, + }), + queryDeduplication: true, + defaultOptions: { + watchQuery: { + fetchPolicy: 'no-cache', + }, + query: { + fetchPolicy: 'no-cache', + errorPolicy: 'all', + }, + }, +}) +const fujiBlockClient = new ApolloClient({ + uri: 'https://api.thegraph.com/subgraphs/name/orbital-apes-labs/blocks-subgraph', + cache: new InMemoryCache(), + queryDeduplication: true, + defaultOptions: { + watchQuery: { + fetchPolicy: 'cache-first', + }, + query: { + fetchPolicy: 'cache-first', + errorPolicy: 'all', + }, + }, +}) + +const GET_BLOCKS = (timestamps: string[]) => { + let queryString = 'query blocks {' + queryString += timestamps.map((timestamp) => { + return `t${timestamp}:blocks(first: 1, orderBy: timestamp, orderDirection: desc, where: { timestamp_gt: ${timestamp}, timestamp_lt: ${ + timestamp + 600 + } }) { + number + }` + }) + queryString += '}' + return gql(queryString) +} + +async function splitQuery( + query: any, + client: ApolloClient, + vars: any[], + values: any[], + skipCount = 1000 +) { + let fetchedData = {} + let allFound = false + let skip = 0 + try { + while (!allFound) { + let end = values.length + if (skip + skipCount < values.length) { + end = skip + skipCount + } + const sliced = values.slice(skip, end) + const result = await client.query({ + query: query(...vars, sliced), + fetchPolicy: 'network-only', + }) + fetchedData = { + ...fetchedData, + ...result.data, + } + if (Object.keys(result.data).length < skipCount || skip + skipCount > values.length) { + allFound = true + } else { + skip += skipCount + } + } + return fetchedData + } catch (e) { + console.log(e) + return undefined + } +} + +function useBlocksFromTimestamps(timestamps: number[]): { + blocks: + | { + timestamp: string + number: any + }[] + | undefined + error: boolean +} { + const activeNetwork = { id: SupportedChainId.FUJI } + const [blocks, setBlocks] = useState() + const [error, setError] = useState(false) + + // derive blocks based on active network + const networkBlocks = blocks?.[activeNetwork.id] + + useEffect(() => { + async function fetchData() { + const results = await splitQuery(GET_BLOCKS, fujiBlockClient, [], timestamps) + if (results) { + setBlocks({ ...(blocks ?? {}), [activeNetwork.id]: results }) + } else { + setError(true) + } + } + if (!networkBlocks && !error) { + fetchData() + } + }) + + const blocksFormatted = useMemo(() => { + if (blocks?.[activeNetwork.id]) { + const networkBlocks = blocks?.[activeNetwork.id] + const formatted = [] + for (const t in networkBlocks) { + if (networkBlocks[t].length > 0) { + formatted.push({ + timestamp: t.split('t')[1], + number: networkBlocks[t][0]['number'], + }) + } + } + return formatted + } + return undefined + }, [activeNetwork.id, blocks]) + + return { + blocks: blocksFormatted, + error, + } +} + +const get2DayChange = (valueNow: string, value24HoursAgo: string, value48HoursAgo: string): [number, number] => { + // get volume info for both 24 hour periods + const currentChange = parseFloat(valueNow) - parseFloat(value24HoursAgo) + const previousChange = parseFloat(value24HoursAgo) - parseFloat(value48HoursAgo) + const adjustedPercentChange = ((currentChange - previousChange) / previousChange) * 100 + if (isNaN(adjustedPercentChange) || !isFinite(adjustedPercentChange)) { + return [currentChange, 0] + } + return [currentChange, adjustedPercentChange] +} + +function useDeltaTimestamps(): [number, number, number] { + const utcCurrentTime = dayjs() + const t1 = utcCurrentTime.subtract(1, 'day').startOf('minute').unix() + const t2 = utcCurrentTime.subtract(2, 'day').startOf('minute').unix() + const tWeek = utcCurrentTime.subtract(1, 'week').startOf('minute').unix() + return [t1, t2, tWeek] +} + +const POOLS_BULK = (block: number | undefined) => { + const queryString = + ` + query pools { + pools(` + + (block ? `block: {number: ${block}} ,` : ``) + + ` orderBy: totalValueLockedUSD, orderDirection: desc, subgraphError: allow) { + id + feeTier + liquidity + sqrtPrice + tick + token0 { + id + symbol + name + decimals + derivedETH + } + token1 { + id + symbol + name + decimals + derivedETH + } + token0Price + token1Price + volumeUSD + volumeToken0 + volumeToken1 + txCount + totalValueLockedToken0 + totalValueLockedToken1 + totalValueLockedUSD + } + bundles (where: {id: "1"}) { + ethPriceUSD + } + } + ` + return gql(queryString) +} + +interface PoolFields { + id: string + feeTier: string + liquidity: string + sqrtPrice: string + tick: string + token0: { + id: string + symbol: string + name: string + decimals: string + derivedETH: string + } + token1: { + id: string + symbol: string + name: string + decimals: string + derivedETH: string + } + token0Price: string + token1Price: string + volumeUSD: string + volumeToken0: string + volumeToken1: string + txCount: string + totalValueLockedToken0: string + totalValueLockedToken1: string + totalValueLockedUSD: string +} + +interface PoolDataResponse { + pools: PoolFields[] + bundles: { + ethPriceUSD: string + }[] +} + +/** + * Fetch top addresses by volume + */ +export function usePoolDatas(): { + loading: boolean + error: boolean + data: + | { + [address: string]: PoolData + } + | undefined +} { + // get client + const dataClient = fujiClient + // get blocks from historic timestamps + const [t24, t48, tWeek] = useDeltaTimestamps() + const { blocks, error: blockError } = useBlocksFromTimestamps([t24, t48, tWeek]) + const [block24, block48, blockWeek] = blocks ?? [] + + const { loading, error, data } = useQuery(POOLS_BULK(undefined), { + client: dataClient, + }) + + const { + loading: loading24, + error: error24, + data: data24, + } = useQuery(POOLS_BULK(block24?.number), { client: dataClient }) + const { + loading: loading48, + error: error48, + data: data48, + } = useQuery(POOLS_BULK(block48?.number), { client: dataClient }) + const { + loading: loadingWeek, + error: errorWeek, + data: dataWeek, + } = useQuery(POOLS_BULK(blockWeek?.number), { client: dataClient }) + + const anyError = Boolean(error || error24 || error48 || blockError || errorWeek) + const anyLoading = Boolean(loading || loading24 || loading48 || loadingWeek) + + // return early if not all data yet + if (anyError || anyLoading) { + return { + loading: anyLoading, + error: anyError, + data: undefined, + } + } + + const ethPriceUSD = data?.bundles?.[0]?.ethPriceUSD ? parseFloat(data?.bundles?.[0]?.ethPriceUSD) : 0 + + const parsed = data?.pools + ? data.pools.reduce((accum: { [address: string]: PoolFields }, poolData) => { + accum[poolData.id] = poolData + return accum + }, {}) + : {} + const parsed24 = data24?.pools + ? data24.pools.reduce((accum: { [address: string]: PoolFields }, poolData) => { + accum[poolData.id] = poolData + return accum + }, {}) + : {} + const parsed48 = data48?.pools + ? data48.pools.reduce((accum: { [address: string]: PoolFields }, poolData) => { + accum[poolData.id] = poolData + return accum + }, {}) + : {} + const parsedWeek = dataWeek?.pools + ? dataWeek.pools.reduce((accum: { [address: string]: PoolFields }, poolData) => { + accum[poolData.id] = poolData + return accum + }, {}) + : {} + + // format data and calculate daily changes + const formatted = data?.pools.reduce((accum: { [address: string]: PoolData }, pool) => { + const current: PoolFields | undefined = parsed[pool.id] + const oneDay: PoolFields | undefined = parsed24[pool.id] + const twoDay: PoolFields | undefined = parsed48[pool.id] + const week: PoolFields | undefined = parsedWeek[pool.id] + + const [volumeUSD, volumeUSDChange] = + current && oneDay && twoDay + ? get2DayChange(current.volumeUSD, oneDay.volumeUSD, twoDay.volumeUSD) + : current + ? [parseFloat(current.volumeUSD), 0] + : [0, 0] + + const volumeUSDWeek = + current && week + ? parseFloat(current.volumeUSD) - parseFloat(week.volumeUSD) + : current + ? parseFloat(current.volumeUSD) + : 0 + + // Hotifx: Subtract fees from TVL to correct data while subgraph is fixed. + /** + * Note: see issue desribed here https://github.com/Uniswap/v3-subgraph/issues/74 + * During subgraph deploy switch this month we lost logic to fix this accounting. + * Grafted sync pending fix now. + */ + const feePercent = current ? parseFloat(current.feeTier) / 10000 / 100 : 0 + const tvlAdjust0 = current?.volumeToken0 ? (parseFloat(current.volumeToken0) * feePercent) / 2 : 0 + const tvlAdjust1 = current?.volumeToken1 ? (parseFloat(current.volumeToken1) * feePercent) / 2 : 0 + const tvlToken0 = current ? parseFloat(current.totalValueLockedToken0) - tvlAdjust0 : 0 + const tvlToken1 = current ? parseFloat(current.totalValueLockedToken1) - tvlAdjust1 : 0 + let tvlUSD = current ? parseFloat(current.totalValueLockedUSD) : 0 + + const tvlUSDChange = + current && oneDay + ? ((parseFloat(current.totalValueLockedUSD) - parseFloat(oneDay.totalValueLockedUSD)) / + parseFloat(oneDay.totalValueLockedUSD === '0' ? '1' : oneDay.totalValueLockedUSD)) * + 100 + : 0 + + // Part of TVL fix + const tvlUpdated = current + ? tvlToken0 * parseFloat(current.token0.derivedETH) * ethPriceUSD + + tvlToken1 * parseFloat(current.token1.derivedETH) * ethPriceUSD + : undefined + if (tvlUpdated) { + tvlUSD = tvlUpdated + } + + const feeTier = current ? parseInt(current.feeTier) : 0 + + if (current) { + accum[pool.id] = { + address: pool.id, + feeTier, + liquidity: parseFloat(current.liquidity), + sqrtPrice: parseFloat(current.sqrtPrice), + tick: parseFloat(current.tick), + token0: { + address: current.token0.id, + name: formatTokenName(current.token0.id, current.token0.name), + symbol: formatTokenSymbol(current.token0.id, current.token0.symbol), + decimals: parseInt(current.token0.decimals), + derivedETH: parseFloat(current.token0.derivedETH), + }, + token1: { + address: current.token1.id, + name: formatTokenName(current.token1.id, current.token1.name), + symbol: formatTokenSymbol(current.token1.id, current.token1.symbol), + decimals: parseInt(current.token1.decimals), + derivedETH: parseFloat(current.token1.derivedETH), + }, + token0Price: parseFloat(current.token0Price), + token1Price: parseFloat(current.token1Price), + volumeUSD, + volumeUSDChange, + volumeUSDWeek, + tvlUSD, + tvlUSDChange, + tvlToken0, + tvlToken1, + } + } + + return accum + }, {}) + + return { + loading: anyLoading, + error: anyError, + data: formatted, + } +} From 130b51eeba0cd0f79ee55e68a0aa1df6d99107ae Mon Sep 17 00:00:00 2001 From: Mrsirdev Date: Mon, 6 Mar 2023 18:12:28 -0500 Subject: [PATCH 04/55] Add chart --- package.json | 1 + src/components/NavBar/index.tsx | 8 - src/components/Pools/PoolTable.tsx | 21 +- .../Tokens/TokenDetails/ChartSection.tsx | 27 +- src/components/swap/styleds.tsx | 23 +- .../data/__generated__/types-and-hooks.ts | 18 + src/pages/Landing/index.tsx | 2 +- src/pages/Swap/chart.tsx | 85 +++ src/pages/Swap/index.tsx | 688 ++++++++++-------- src/pages/Swap/lighweightchart.js | 117 +++ src/theme/colors.ts | 31 +- .../RadialGradientByChainUpdater.ts | 4 +- src/theme/deprecatedColors.ts | 2 +- yarn.lock | 12 + 14 files changed, 656 insertions(+), 383 deletions(-) create mode 100644 src/pages/Swap/chart.tsx create mode 100644 src/pages/Swap/lighweightchart.js diff --git a/package.json b/package.json index 5c32b5d9978..667be93ad10 100644 --- a/package.json +++ b/package.json @@ -191,6 +191,7 @@ "inter-ui": "^3.13.1", "jotai": "^1.3.7", "jsbi": "^3.1.4", + "lightweight-charts": "^4.0.0", "make-plural": "^7.0.0", "multicodec": "^3.0.1", "multihashes": "^4.0.2", diff --git a/src/components/NavBar/index.tsx b/src/components/NavBar/index.tsx index 970174c4a9a..baeff514bbe 100644 --- a/src/components/NavBar/index.tsx +++ b/src/components/NavBar/index.tsx @@ -13,8 +13,6 @@ import styled from 'styled-components/macro' import { Bag } from './Bag' import { ChainSelector } from './ChainSelector' -import { MenuDropdown } from './MenuDropdown' -import { SearchBar } from './SearchBar' import * as styles from './style.css' const Nav = styled.nav` @@ -118,12 +116,6 @@ const Navbar = () => { - - - - - - {isNftPage && (!isNftListV2 || sellPageState !== ProfilePageStateType.LISTING) && } {!isNftPage && ( diff --git a/src/components/Pools/PoolTable.tsx b/src/components/Pools/PoolTable.tsx index 34a6f3b7e5f..607445f5ff4 100644 --- a/src/components/Pools/PoolTable.tsx +++ b/src/components/Pools/PoolTable.tsx @@ -18,7 +18,7 @@ import { darkTheme } from 'theme/colors' const GreyBadge = styled(Card)` width: fit-content; border-radius: 8px; - background: ${darkTheme.background}; + background: ${darkTheme.backgroundModule}; color: ${darkTheme.textPrimary}; padding: 4px 6px; font-weight: 400; @@ -53,7 +53,7 @@ function feeTierPercent(fee: number): string { return (fee / 10000).toPrecision(1) + '%' } -const Label = styled.div<{ end?: number }>` +const Label = styled.div<{ end?: number; color?: string }>` display: flex; font-size: 16px; font-weight: 400; @@ -63,6 +63,7 @@ const Label = styled.div<{ end?: number }>` @media screen and (max-width: 640px) { font-size: 14px; } + color: ${({ color }) => (color ? color : '#ffffff')}; ` const ClickableText = styled(Label)` @@ -200,7 +201,7 @@ const DataRow = ({ poolData, index }: { poolData: PoolData; index: number }) => return ( - +