Skip to content

Commit

Permalink
Merge branch 'master' into dong-ha/acx-1546-missing-fe-gas-padding-on…
Browse files Browse the repository at this point in the history
…-nativegas-token-deposits
  • Loading branch information
dohaki committed Oct 12, 2023
2 parents 58cff99 + 81f8989 commit 29b4299
Show file tree
Hide file tree
Showing 39 changed files with 818 additions and 569 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
.env.development.local
.env.test.local
.env.production.local
.env*.local

# IDE
.idea
Expand Down
35 changes: 18 additions & 17 deletions api/_constants.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down Expand Up @@ -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;
Expand Down
76 changes: 37 additions & 39 deletions api/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) : {};
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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)
),
};

Expand Down Expand Up @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions api/coingecko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -33,7 +37,7 @@ const getCoingeckoPrices = async (
} = {},
balancerV2PoolTokens: string[] = []
): Promise<number> => {
const baseCurrencyToken = Object.values(sdkConstants.TOKEN_SYMBOLS_MAP).find(
const baseCurrencyToken = Object.values(TOKEN_SYMBOLS_MAP).find(
({ symbol }) => symbol === baseCurrency.toUpperCase()
);

Expand All @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions api/token-list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { VercelResponse } from "@vercel/node";
import { constants } from "@across-protocol/sdk-v2";
import {
getLogger,
handleErrorCondition,
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
13 changes: 0 additions & 13 deletions patches/@web3-onboard+walletconnect+2.4.1.patch

This file was deleted.

Loading

0 comments on commit 29b4299

Please sign in to comment.