From cbc838a83814dca52a176a1386963bb302b13bd7 Mon Sep 17 00:00:00 2001 From: "jrab227@gmail.com" Date: Tue, 10 Dec 2024 22:48:00 -0500 Subject: [PATCH] Adding back whitelisted tokens. --- src/Constants.ts | 24 ++++++++------- src/PriceOracle.ts | 2 +- src/constants/price_connectors.json | 46 ++++++++++++++--------------- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/Constants.ts b/src/Constants.ts index 3e24f2b..f27b948 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -3,7 +3,11 @@ import dotenv from "dotenv"; import { Web3 } from "web3"; import { optimism, base, lisk, mode } from 'viem/chains'; import { createPublicClient, http, PublicClient } from 'viem'; -import priceConnectors from "./constants/price_connectors.json"; + +import BaseWhitelistedTokens from "./constants/baseWhitelistedTokens.json"; +import OptimismWhitelistedTokens from "./constants/optimismWhitelistedTokens.json"; +import ModeWhitelistedTokens from "./constants/modeWhitelistedTokens.json"; +import LiskWhitelistedTokens from "./constants/liskWhitelistedTokens.json"; dotenv.config(); @@ -15,26 +19,26 @@ export const SECONDS_IN_AN_HOUR = BigInt(3600); export const SECONDS_IN_A_DAY = BigInt(86400); export const SECONDS_IN_A_WEEK = BigInt(604800); +type PriceConnector = { + address: string; + createdBlock: number; +}; + export const OPTIMISM_PRICE_CONNECTORS: PriceConnector[] = - priceConnectors.optimism as PriceConnector[]; + OptimismWhitelistedTokens as PriceConnector[]; export const BASE_PRICE_CONNECTORS: PriceConnector[] = - priceConnectors.base as PriceConnector[]; + BaseWhitelistedTokens as PriceConnector[]; export const MODE_PRICE_CONNECTORS: PriceConnector[] = - priceConnectors.mode as PriceConnector[]; + ModeWhitelistedTokens as PriceConnector[]; export const LISK_PRICE_CONNECTORS: PriceConnector[] = - priceConnectors.lisk as PriceConnector[]; + LiskWhitelistedTokens as PriceConnector[]; export const toChecksumAddress = (address: string) => Web3.utils.toChecksumAddress(address); -type PriceConnector = { - address: string; - block: number; -}; - // Object containing all the constants for a chain type chainConstants = { weth: string; diff --git a/src/PriceOracle.ts b/src/PriceOracle.ts index 096e8c4..c875ead 100644 --- a/src/PriceOracle.ts +++ b/src/PriceOracle.ts @@ -102,7 +102,7 @@ export async function getTokenPriceData( const SYSTEM_TOKEN_ADDRESS = CHAIN_CONSTANTS[chainId].rewardToken(blockNumber); const connectors = CHAIN_CONSTANTS[chainId].oracle.priceConnectors - .filter((connector) => connector.block <= blockNumber) + .filter((connector) => connector.createdBlock <= blockNumber) .map((connector) => connector.address) .filter((connector) => connector !== tokenAddress) .filter((connector) => connector !== WETH_ADDRESS) diff --git a/src/constants/price_connectors.json b/src/constants/price_connectors.json index 7746df8..1c93b8f 100644 --- a/src/constants/price_connectors.json +++ b/src/constants/price_connectors.json @@ -1,33 +1,33 @@ { "optimism": [ - {"address": "0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db", "block": 105896796 }, - {"address": "0x4200000000000000000000000000000000000042", "block": 6490467 }, - {"address": "0x9bcef72be871e61ed4fbbc7630889bee758eb81d", "block": 113681 }, - {"address": "0x2e3d870790dc77a83dd1d18184acc7439a53f475", "block": 2153157 }, - {"address": "0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9", "block": 1 }, - {"address": "0x1f32b1c2345538c0c6f582fcb022739c4a194ebb", "block": 17831118 }, - {"address": "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1", "block": 1 }, - {"address": "0x6c84a8f1c29108f47a79964b5fe888d4f4d0de40", "block": 89899840 }, - {"address": "0xc40f949f8a4e094d1b49a23ea9241d289b7b2819", "block": 1 }, - {"address": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58", "block": 1 }, - {"address": "0x0b2c639c533813f4aa9d7837caf62653d097ff85", "block": 10 } + {"address": "0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db", "createdBlock": 105896796 }, + {"address": "0x4200000000000000000000000000000000000042", "createdBlock": 6490467 }, + {"address": "0x9bcef72be871e61ed4fbbc7630889bee758eb81d", "createdBlock": 113681 }, + {"address": "0x2e3d870790dc77a83dd1d18184acc7439a53f475", "createdBlock": 2153157 }, + {"address": "0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9", "createdBlock": 1 }, + {"address": "0x1f32b1c2345538c0c6f582fcb022739c4a194ebb", "createdBlock": 17831118 }, + {"address": "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1", "createdBlock": 1 }, + {"address": "0x6c84a8f1c29108f47a79964b5fe888d4f4d0de40", "createdBlock": 89899840 }, + {"address": "0xc40f949f8a4e094d1b49a23ea9241d289b7b2819", "createdBlock": 1 }, + {"address": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58", "createdBlock": 1 }, + {"address": "0x0b2c639c533813f4aa9d7837caf62653d097ff85", "createdBlock": 10 } ], "base": [ - {"address" :"0x940181a94A35A4569E4529A3CDfB74e38FD98631", "block": 3200550 }, - {"address" :"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", "block": 1569598 }, - {"address" :"0x4621b7a9c75199271f773ebd9a499dbd165c3191", "block": 2361818 }, - {"address" :"0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22", "block": 1600576 }, - {"address" :"0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452", "block": 4572990 }, - {"address" :"0x60a3e35cc302bfa44cb288bc5a4f316fdb1adb42", "block": 15107859 }, - {"address" :"0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca", "block": 2062407 } + {"address" :"0x940181a94A35A4569E4529A3CDfB74e38FD98631", "createdBlock": 3200550 }, + {"address" :"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", "createdBlock": 1569598 }, + {"address" :"0x4621b7a9c75199271f773ebd9a499dbd165c3191", "createdBlock": 2361818 }, + {"address" :"0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22", "createdBlock": 1600576 }, + {"address" :"0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452", "createdBlock": 4572990 }, + {"address" :"0x60a3e35cc302bfa44cb288bc5a4f316fdb1adb42", "createdBlock": 15107859 }, + {"address" :"0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca", "createdBlock": 2062407 } ], "mode": [ - {"address" :"0xf0F161fDA2712DB8b566946122a5af183995e2eD", "block": 190688 }, - {"address" :"0xDfc7C877a950e49D2610114102175A06C2e3167a", "block": 7103932 }, - {"address" :"0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea", "block": 190669 } + {"address" :"0xf0F161fDA2712DB8b566946122a5af183995e2eD", "createdBlock": 190688 }, + {"address" :"0xDfc7C877a950e49D2610114102175A06C2e3167a", "createdBlock": 7103932 }, + {"address" :"0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea", "createdBlock": 190669 } ], "lisk": [ - {"address" :"0xac485391EB2d7D88253a7F1eF18C37f4242D1A24", "block": 568336 }, - {"address" :"0x05D032ac25d322df992303dCa074EE7392C117b9", "block": 1639961 } + {"address" :"0xac485391EB2d7D88253a7F1eF18C37f4242D1A24", "createdBlock": 568336 }, + {"address" :"0x05D032ac25d322df992303dCa074EE7392C117b9", "createdBlock": 1639961 } ] } \ No newline at end of file