Skip to content

Commit

Permalink
Merge branch 'master' into feat/support-arb-tokens-on-coingecko-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Nov 18, 2024
2 parents 1cd86f3 + 7809358 commit 79716a0
Show file tree
Hide file tree
Showing 12 changed files with 1,029 additions and 81 deletions.
9 changes: 8 additions & 1 deletion api/_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ export const BLOCK_TAG_LAG = -1;
// we've decided to keep this list small for now.
export const SUPPORTED_CG_BASE_CURRENCIES = new Set(["eth", "usd"]);
// Note: this is a small set of currencies that the API will derive from the base currencies by using USD as an intermediary.
export const SUPPORTED_CG_DERIVED_CURRENCIES = new Set(["matic"]);
export const SUPPORTED_CG_DERIVED_CURRENCIES = new Set(["azero", "matic"]);
export const CG_CONTRACTS_DEFERRED_TO_ID = new Set([
TOKEN_SYMBOLS_MAP.AZERO.addresses[CHAIN_IDs.MAINNET],
]);

// 1:1 because we don't need to handle underlying tokens on FE
export const EXTERNAL_POOL_TOKEN_EXCHANGE_RATE = utils.fixedPointAdjustment;
Expand All @@ -181,6 +184,10 @@ export const ENABLED_POOLS_UNDERLYING_TOKENS = [
export const SECONDS_PER_YEAR = 365 * 24 * 60 * 60;

export const MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
export const MULTICALL3_ADDRESS_OVERRIDES = {
[CHAIN_IDs.ALEPH_ZERO]: "0x3CA11702f7c0F28e0b4e03C31F7492969862C569",
[CHAIN_IDs.ZK_SYNC]: "0xF9cda624FBC7e059355ce98a31693d299FACd963",
};

export const DEFI_LLAMA_POOL_LOOKUP: Record<string, string> = {
"0x36Be1E97eA98AB43b4dEBf92742517266F5731a3":
Expand Down
9 changes: 4 additions & 5 deletions api/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
DOMAIN_CALLDATA_DELIMITER,
EXTERNAL_POOL_TOKEN_EXCHANGE_RATE,
MULTICALL3_ADDRESS,
MULTICALL3_ADDRESS_OVERRIDES,
SECONDS_PER_YEAR,
TOKEN_SYMBOLS_MAP,
defaultRelayerAddressOverride,
Expand Down Expand Up @@ -1645,8 +1646,9 @@ export async function callViaMulticall3(
}[],
overrides: ethers.CallOverrides = {}
): Promise<ethers.utils.Result[]> {
const chainId = provider.network.chainId;
const multicall3 = new ethers.Contract(
MULTICALL3_ADDRESS,
MULTICALL3_ADDRESS_OVERRIDES[chainId] ?? MULTICALL3_ADDRESS,
MINIMAL_MULTICALL3_ABI,
provider
);
Expand Down Expand Up @@ -1929,10 +1931,7 @@ export function getCachedFillGasUsage(
);
const { nativeGasCost } = await relayerFeeCalculatorQueries.getGasCosts(
buildDepositForSimulation(deposit),
overrides?.relayerAddress,
undefined,
undefined,
true
overrides?.relayerAddress
);
return nativeGasCost;
};
Expand Down
3 changes: 2 additions & 1 deletion api/coingecko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
parseQuery,
} from "./_utils";
import {
CG_CONTRACTS_DEFERRED_TO_ID,

Check warning on line 15 in api/coingecko.ts

View workflow job for this annotation

GitHub Actions / format-and-lint

'CG_CONTRACTS_DEFERRED_TO_ID' is defined but never used
CHAIN_IDs,
SUPPORTED_CG_BASE_CURRENCIES,
SUPPORTED_CG_DERIVED_CURRENCIES,
Expand Down Expand Up @@ -130,7 +131,7 @@ const handler = async (
// date is provided, fetch historical price. Otherwise, fetch
// current price.
else {
// // If derived, we need to convert to USD first.
// If derived, we need to convert to USD first.
const modifiedBaseCurrency = isDerivedCurrency ? "usd" : baseCurrency;
if (dateStr) {
price = await coingeckoClient.getContractHistoricDayPrice(
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"private": true,
"license": "AGPL-3.0-only",
"dependencies": {
"@across-protocol/constants": "^3.1.16",
"@across-protocol/contracts": "^3.0.11",
"@across-protocol/constants": "^3.1.20",
"@across-protocol/contracts": "^3.0.16",
"@across-protocol/contracts-v3.0.6": "npm:@across-protocol/[email protected]",
"@across-protocol/sdk": "^3.2.9",
"@across-protocol/sdk": "^3.2.14",
"@amplitude/analytics-browser": "^2.3.5",
"@balancer-labs/sdk": "1.1.6-beta.16",
"@emotion/react": "^11.13.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/chain-configs/optimism-sepolia/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
},
chainId,
publicRpcUrl: "https://sepolia.optimism.io",
tokens: [],
tokens: ["ETH", "WETH", "USDC"],
enableCCTP: false,
swapTokens: [],
} as ChainConfig;
8 changes: 4 additions & 4 deletions scripts/generate-routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "@across-protocol/constants";
import { utils as sdkUtils } from "@across-protocol/sdk";

import { utils } from "ethers";
import { writeFileSync } from "fs";
import * as prettier from "prettier";
Expand Down Expand Up @@ -270,12 +271,11 @@ function transformChainConfigs(
];
}

// Handle WETH Polygon
// Handle WETH Polygon & other non-eth chains
if (
tokenSymbol === "WETH" &&
[CHAIN_IDs.POLYGON, CHAIN_IDs.POLYGON_AMOY].includes(
toChainConfig.chainId
)
!toChainConfig.tokens.includes("ETH") &&
chainConfig.tokens.includes("ETH")
) {
return ["WETH", "ETH"];
}
Expand Down
48 changes: 46 additions & 2 deletions src/data/chains_11155111.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,52 @@
"logoUrl": "https://raw.githubusercontent.com/across-protocol/frontend/master/scripts/chain-configs/optimism/assets/logo.svg",
"spokePool": "0x4e8E101924eDE233C13e2D8622DC8aED2872d505",
"spokePoolBlock": 7762656,
"inputTokens": [],
"outputTokens": []
"inputTokens": [
{
"address": "0x4200000000000000000000000000000000000006",
"symbol": "ETH",
"name": "Ether",
"decimals": 18,
"logoUrl": "https://raw.githubusercontent.com/across-protocol/frontend/master/src/assets/token-logos/eth.svg"
},
{
"address": "0x4200000000000000000000000000000000000006",
"symbol": "WETH",
"name": "Wrapped Ether",
"decimals": 18,
"logoUrl": "https://raw.githubusercontent.com/across-protocol/frontend/master/src/assets/token-logos/weth.svg"
},
{
"address": "0x5fd84259d66Cd46123540766Be93DFE6D43130D7",
"symbol": "USDC",
"name": "USD Coin",
"decimals": 6,
"logoUrl": "https://raw.githubusercontent.com/across-protocol/frontend/master/src/assets/token-logos/usdc.svg"
}
],
"outputTokens": [
{
"address": "0x4200000000000000000000000000000000000006",
"symbol": "WETH",
"name": "Wrapped Ether",
"decimals": 18,
"logoUrl": "https://raw.githubusercontent.com/across-protocol/frontend/master/src/assets/token-logos/weth.svg"
},
{
"address": "0x4200000000000000000000000000000000000006",
"symbol": "ETH",
"name": "Ether",
"decimals": 18,
"logoUrl": "https://raw.githubusercontent.com/across-protocol/frontend/master/src/assets/token-logos/eth.svg"
},
{
"address": "0x5fd84259d66Cd46123540766Be93DFE6D43130D7",
"symbol": "USDC",
"name": "USD Coin",
"decimals": 6,
"logoUrl": "https://raw.githubusercontent.com/across-protocol/frontend/master/src/assets/token-logos/usdc.svg"
}
]
},
{
"chainId": 919,
Expand Down
Loading

0 comments on commit 79716a0

Please sign in to comment.