diff --git a/.gitignore b/.gitignore index 83bea81b7..6cbb19ee7 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ .env.development.local .env.test.local .env.production.local +.env*.local # IDE .idea diff --git a/api/_constants.ts b/api/_constants.ts index bd1a12522..c2969c1c8 100644 --- a/api/_constants.ts +++ b/api/_constants.ts @@ -1,10 +1,15 @@ import { ethers } from "ethers"; -import { constants, relayFeeCalculator, utils } from "@across-protocol/sdk-v2"; +import { relayFeeCalculator, utils } from "@across-protocol/sdk-v2"; +import * as constants from "@across-protocol/constants-v2"; + +export const TOKEN_SYMBOLS_MAP = constants.TOKEN_SYMBOLS_MAP; + +export const CHAIN_IDs = constants.CHAIN_IDs; export const maxRelayFeePct = 0.25; export const disabledL1Tokens = [ - constants.TOKEN_SYMBOLS_MAP.BADGER.addresses[constants.CHAIN_IDs.MAINNET], + TOKEN_SYMBOLS_MAP.BADGER.addresses[CHAIN_IDs.MAINNET], ].map((x) => x.toLowerCase()); const defaultRelayerFeeCapitalCostConfig: { @@ -105,22 +110,18 @@ export const SUPPORTED_CG_BASE_CURRENCIES = new Set(["eth", "usd"]); // 1:1 because we don't need to handle underlying tokens on FE export const EXTERNAL_POOL_TOKEN_EXCHANGE_RATE = utils.fixedPointAdjustment; -export const TOKEN_SYMBOLS_MAP = constants.TOKEN_SYMBOLS_MAP; - -export const CHAIN_IDS = constants.CHAIN_IDs; - export const ENABLED_POOLS_UNDERLYING_TOKENS = [ - constants.TOKEN_SYMBOLS_MAP.ETH, - constants.TOKEN_SYMBOLS_MAP.WETH, - constants.TOKEN_SYMBOLS_MAP.USDC, - constants.TOKEN_SYMBOLS_MAP.USDT, - constants.TOKEN_SYMBOLS_MAP.DAI, - constants.TOKEN_SYMBOLS_MAP.WBTC, - constants.TOKEN_SYMBOLS_MAP.BAL, - constants.TOKEN_SYMBOLS_MAP.UMA, - constants.TOKEN_SYMBOLS_MAP.ACX, - constants.TOKEN_SYMBOLS_MAP.SNX, - constants.TOKEN_SYMBOLS_MAP.POOL, + TOKEN_SYMBOLS_MAP.ETH, + TOKEN_SYMBOLS_MAP.WETH, + TOKEN_SYMBOLS_MAP.USDC, + TOKEN_SYMBOLS_MAP.USDT, + TOKEN_SYMBOLS_MAP.DAI, + TOKEN_SYMBOLS_MAP.WBTC, + TOKEN_SYMBOLS_MAP.BAL, + TOKEN_SYMBOLS_MAP.UMA, + TOKEN_SYMBOLS_MAP.ACX, + TOKEN_SYMBOLS_MAP.SNX, + TOKEN_SYMBOLS_MAP.POOL, ]; export const SECONDS_PER_YEAR = 365 * 24 * 60 * 60; diff --git a/api/_utils.ts b/api/_utils.ts index 514d68853..9dd9a51a2 100644 --- a/api/_utils.ts +++ b/api/_utils.ts @@ -24,7 +24,7 @@ import { import { StaticJsonRpcProvider } from "@ethersproject/providers"; import { VercelResponse } from "@vercel/node"; import { - CHAIN_IDS, + CHAIN_IDs, MULTICALL3_ADDRESS, DEFI_LLAMA_POOL_LOOKUP, EXTERNAL_POOL_TOKEN_EXCHANGE_RATE, @@ -41,14 +41,14 @@ const { REACT_APP_HUBPOOL_CHAINID, REACT_APP_PUBLIC_INFURA_ID, REACT_APP_COINGECKO_PRO_API_KEY, - REACT_APP_GOOGLE_SERVICE_ACCOUNT, + GOOGLE_SERVICE_ACCOUNT: _GOOGLE_SERVICE_ACCOUNT, VERCEL_ENV, GAS_MARKUP, DISABLE_DEBUG_LOGS, } = process.env; -const GOOGLE_SERVICE_ACCOUNT = REACT_APP_GOOGLE_SERVICE_ACCOUNT - ? JSON.parse(REACT_APP_GOOGLE_SERVICE_ACCOUNT) +const GOOGLE_SERVICE_ACCOUNT = _GOOGLE_SERVICE_ACCOUNT + ? JSON.parse(_GOOGLE_SERVICE_ACCOUNT) : {}; export const gasMarkup = GAS_MARKUP ? JSON.parse(GAS_MARKUP) : {}; @@ -279,8 +279,7 @@ export const makeHubPoolClientConfig = (chainId = 1) => { 1: { chainId: 1, hubPoolAddress: "0xc186fA914353c44b2E33eBE05f21846F1048bEda", - wethAddress: - TOKEN_SYMBOLS_MAP.WETH.addresses[sdk.constants.CHAIN_IDs.MAINNET], + wethAddress: TOKEN_SYMBOLS_MAP.WETH.addresses[CHAIN_IDs.MAINNET], configStoreAddress: "0x3B03509645713718B78951126E0A6de6f10043f5", acceleratingDistributorAddress: "0x9040e41eF5E8b281535a96D9a48aCb8cfaBD9a48", @@ -289,8 +288,7 @@ export const makeHubPoolClientConfig = (chainId = 1) => { 5: { chainId: 5, hubPoolAddress: "0x0e2817C49698cc0874204AeDf7c72Be2Bb7fCD5d", - wethAddress: - TOKEN_SYMBOLS_MAP.WETH.addresses[sdk.constants.CHAIN_IDs.GOERLI], + wethAddress: TOKEN_SYMBOLS_MAP.WETH.addresses[CHAIN_IDs.GOERLI], configStoreAddress: "0x3215e3C91f87081757d0c41EF0CB77738123Be83", acceleratingDistributorAddress: "0xA59CE9FDFf8a0915926C2AF021d54E58f9B207CC", @@ -329,116 +327,116 @@ export const queries: Record< number, () => sdk.relayFeeCalculator.QueryInterface > = { - [CHAIN_IDS.MAINNET]: () => + [CHAIN_IDs.MAINNET]: () => new sdk.relayFeeCalculator.EthereumQueries( - getProvider(CHAIN_IDS.MAINNET), + getProvider(CHAIN_IDs.MAINNET), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.MAINNET) + getGasMarkup(CHAIN_IDs.MAINNET) ), - [CHAIN_IDS.OPTIMISM]: () => + [CHAIN_IDs.OPTIMISM]: () => new sdk.relayFeeCalculator.OptimismQueries( - getProvider(CHAIN_IDS.OPTIMISM), + getProvider(CHAIN_IDs.OPTIMISM), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.OPTIMISM) + getGasMarkup(CHAIN_IDs.OPTIMISM) ), - [CHAIN_IDS.POLYGON]: () => + [CHAIN_IDs.POLYGON]: () => new sdk.relayFeeCalculator.PolygonQueries( - getProvider(CHAIN_IDS.POLYGON), + getProvider(CHAIN_IDs.POLYGON), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.POLYGON) + getGasMarkup(CHAIN_IDs.POLYGON) ), - [CHAIN_IDS.ARBITRUM]: () => + [CHAIN_IDs.ARBITRUM]: () => new sdk.relayFeeCalculator.ArbitrumQueries( - getProvider(CHAIN_IDS.ARBITRUM), + getProvider(CHAIN_IDs.ARBITRUM), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.ARBITRUM) + getGasMarkup(CHAIN_IDs.ARBITRUM) ), - [CHAIN_IDS.ZK_SYNC]: () => + [CHAIN_IDs.ZK_SYNC]: () => new sdk.relayFeeCalculator.ZkSyncQueries( - getProvider(CHAIN_IDS.ZK_SYNC), + getProvider(CHAIN_IDs.ZK_SYNC), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.ZK_SYNC) + getGasMarkup(CHAIN_IDs.ZK_SYNC) ), - [CHAIN_IDS.BASE]: () => + [CHAIN_IDs.BASE]: () => new sdk.relayFeeCalculator.BaseQueries( - getProvider(CHAIN_IDS.BASE), + getProvider(CHAIN_IDs.BASE), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.BASE) + getGasMarkup(CHAIN_IDs.BASE) ), /* --------------------------- Testnet queries --------------------------- */ - [CHAIN_IDS.GOERLI]: () => + [CHAIN_IDs.GOERLI]: () => new sdk.relayFeeCalculator.EthereumGoerliQueries( - getProvider(CHAIN_IDS.GOERLI), + getProvider(CHAIN_IDs.GOERLI), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.GOERLI) + getGasMarkup(CHAIN_IDs.GOERLI) ), - [CHAIN_IDS.ARBITRUM_GOERLI]: () => + [CHAIN_IDs.ARBITRUM_GOERLI]: () => new sdk.relayFeeCalculator.ArbitrumGoerliQueries( - getProvider(CHAIN_IDS.ARBITRUM_GOERLI), + getProvider(CHAIN_IDs.ARBITRUM_GOERLI), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.ARBITRUM_GOERLI) + getGasMarkup(CHAIN_IDs.ARBITRUM_GOERLI) ), - [CHAIN_IDS.ZK_SYNC_GOERLI]: () => + [CHAIN_IDs.ZK_SYNC_GOERLI]: () => new sdk.relayFeeCalculator.zkSyncGoerliQueries( - getProvider(CHAIN_IDS.ZK_SYNC_GOERLI), + getProvider(CHAIN_IDs.ZK_SYNC_GOERLI), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.ZK_SYNC_GOERLI) + getGasMarkup(CHAIN_IDs.ZK_SYNC_GOERLI) ), - [CHAIN_IDS.BASE_GOERLI]: () => + [CHAIN_IDs.BASE_GOERLI]: () => new sdk.relayFeeCalculator.BaseGoerliQueries( - getProvider(CHAIN_IDS.BASE_GOERLI), + getProvider(CHAIN_IDs.BASE_GOERLI), undefined, undefined, undefined, undefined, REACT_APP_COINGECKO_PRO_API_KEY, getLogger(), - getGasMarkup(CHAIN_IDS.BASE_GOERLI) + getGasMarkup(CHAIN_IDs.BASE_GOERLI) ), }; @@ -564,7 +562,7 @@ export const getSpokePool = (_chainId: number): SpokePool => { export const getSpokePoolAddress = (chainId: number): string => { switch (chainId) { - case CHAIN_IDS.ARBITRUM_GOERLI: + case CHAIN_IDs.ARBITRUM_GOERLI: return "0xD29C85F15DF544bA632C9E25829fd29d767d7978"; default: return sdk.utils.getDeployedAddress("SpokePool", chainId); diff --git a/api/coingecko.ts b/api/coingecko.ts index ac8ffc986..598a75842 100644 --- a/api/coingecko.ts +++ b/api/coingecko.ts @@ -9,9 +9,13 @@ import { validAddress, getBalancerV2TokenPrice, } from "./_utils"; -import { SUPPORTED_CG_BASE_CURRENCIES } from "./_constants"; +import { + SUPPORTED_CG_BASE_CURRENCIES, + CHAIN_IDs, + TOKEN_SYMBOLS_MAP, +} from "./_constants"; -import { coingecko, constants as sdkConstants } from "@across-protocol/sdk-v2"; +import { coingecko } from "@across-protocol/sdk-v2"; const { Coingecko } = coingecko; const { @@ -33,7 +37,7 @@ const getCoingeckoPrices = async ( } = {}, balancerV2PoolTokens: string[] = [] ): Promise => { - const baseCurrencyToken = Object.values(sdkConstants.TOKEN_SYMBOLS_MAP).find( + const baseCurrencyToken = Object.values(TOKEN_SYMBOLS_MAP).find( ({ symbol }) => symbol === baseCurrency.toUpperCase() ); @@ -42,7 +46,7 @@ const getCoingeckoPrices = async ( // Special case: token and base are the same. Coingecko class returns a single result in this case, so it must // be handled separately. const baseCurrentTokenAddress = - baseCurrencyToken.addresses[sdkConstants.CHAIN_IDs.MAINNET]; + baseCurrencyToken.addresses[CHAIN_IDs.MAINNET]; if (tokenAddress.toLowerCase() === baseCurrentTokenAddress.toLowerCase()) return 1; diff --git a/api/token-list.ts b/api/token-list.ts index d5c870ee8..d1962c179 100644 --- a/api/token-list.ts +++ b/api/token-list.ts @@ -1,5 +1,4 @@ import { VercelResponse } from "@vercel/node"; -import { constants } from "@across-protocol/sdk-v2"; import { getLogger, handleErrorCondition, @@ -8,6 +7,7 @@ import { DISABLED_CHAINS_FOR_AVAILABLE_ROUTES, } from "./_utils"; import { TypedVercelRequest } from "./_types"; +import { TOKEN_SYMBOLS_MAP } from "./_constants"; const handler = async (_: TypedVercelRequest<{}>, response: VercelResponse) => { const logger = getLogger(); @@ -48,10 +48,10 @@ const handler = async (_: TypedVercelRequest<{}>, response: VercelResponse) => { const enrichedTokensPerChain = Object.values(tokensPerChain).map( (token) => { const tokenInfo = - constants.TOKEN_SYMBOLS_MAP[ + TOKEN_SYMBOLS_MAP[ ["USDC.e", "USDbC"].includes(token.symbol) ? "USDC" - : (token.symbol as keyof typeof constants.TOKEN_SYMBOLS_MAP) + : (token.symbol as keyof typeof TOKEN_SYMBOLS_MAP) ]; return { ...token, diff --git a/package.json b/package.json index fa80d8a76..dae84d867 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "private": true, "license": "AGPL-3.0-only", "dependencies": { - "@across-protocol/sdk-v2": "^0.16.2", + "@across-protocol/constants-v2": "^1.0.4", + "@across-protocol/sdk-v2": "^0.16.4", "@amplitude/analytics-browser": "^1.6.6", "@amplitude/marketing-analytics-browser": "^0.3.6", "@balancer-labs/sdk": "^1.1.3", @@ -15,14 +16,16 @@ "@fortawesome/react-fontawesome": "^0.2.0", "@google-cloud/logging": "^10.1.1", "@reach/dialog": "^0.16.2", + "@safe-global/safe-apps-provider": "^0.18.0", + "@safe-global/safe-apps-sdk": "^8.1.0", "@sentry/react": "^7.37.2", "@uma/sdk": "^0.22.2", - "@web3-onboard/coinbase": "^2.2.4", - "@web3-onboard/core": "^2.20.4", - "@web3-onboard/gnosis": "^2.1.10", - "@web3-onboard/injected-wallets": "^2.10.2", - "@web3-onboard/react": "^2.8.9", - "@web3-onboard/walletconnect": "^2.4.1", + "@web3-onboard/coinbase": "^2.2.5", + "@web3-onboard/core": "^2.21.2", + "@web3-onboard/gnosis": "^2.2.0", + "@web3-onboard/injected-wallets": "^2.10.6", + "@web3-onboard/react": "^2.8.13", + "@web3-onboard/walletconnect": "^2.4.6", "axios": "^0.27.2", "bnc-notify": "^1.9.8", "copy-to-clipboard": "^3.3.3", @@ -49,7 +52,7 @@ }, "scripts": { "start": "export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && vite", - "dev": "export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && vite --port $PORT", + "dev": "export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && vite --port $PORT --host", "build": "export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && tsc && vite build", "analyze": "yarn build --stats && webpack-bundle-analyzer build/bundle-stats.json -m server -r build/bundle-stats.html", "test": "export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && jest --env jsdom src", diff --git a/patches/@web3-onboard+walletconnect+2.4.1.patch b/patches/@web3-onboard+walletconnect+2.4.1.patch deleted file mode 100644 index efb5267e3..000000000 --- a/patches/@web3-onboard+walletconnect+2.4.1.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/node_modules/@web3-onboard/walletconnect/dist/v2.js b/node_modules/@web3-onboard/walletconnect/dist/v2.js -index e24edd8..459a4ab 100644 ---- a/node_modules/@web3-onboard/walletconnect/dist/v2.js -+++ b/node_modules/@web3-onboard/walletconnect/dist/v2.js -@@ -48,7 +48,7 @@ function walletConnect(options) { - ? // @ts-ignore - // Required as WC package does not support hex numbers - requiredChains.map(chainID => parseInt(chainID)) -- : [1]; -+ : []; - // Defaults to the chains provided within the web3-onboard init chain property - const optionalChainsParsed = Array.isArray(optionalChains) && - optionalChains.length && diff --git a/src/components/Layout/Layout.tsx b/src/components/Layout/Layout.tsx deleted file mode 100644 index 3e92a81af..000000000 --- a/src/components/Layout/Layout.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from "react"; -import styled from "@emotion/styled"; - -import { COLORS } from "utils"; - -import Footer from "../Footer/Footer"; - -const Layout: React.FC = ({ children }) => ( - <> - -
{children}
-
- -