From bbd7e6a8a8d8a9e094db6af741dedeafa68b6556 Mon Sep 17 00:00:00 2001 From: picodes Date: Fri, 10 May 2024 18:02:42 +0200 Subject: [PATCH] fix: multicall dynamic --- package.json | 2 +- src/constants/index.ts | 1 - src/helpers/index.ts | 5 ++--- src/utils/providers.ts | 15 +++++++++++---- yarn.lock | 12 ++++++------ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 541ab1c..5dfeeb9 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "publish-image": "chmod +x ./scripts/publish.sh && ./scripts/publish.sh" }, "dependencies": { - "@angleprotocol/sdk": "0.26.14", + "@angleprotocol/sdk": "2.3.3", "@google-cloud/secret-manager": "^4.2.2", "@octokit/rest": "19.0.13", "@types/chai": "^4.3.6", diff --git a/src/constants/index.ts b/src/constants/index.ts index 03edfb0..87829fa 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -1,6 +1,5 @@ export const TVL_THRESHOLD = 10; export const BATCH_NUMBER = 1_000; -export const MULTICALL_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11'; export const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'; export const GITHUB_URL = `https://raw.githubusercontent.com/AngleProtocol/merkl-rewards/main/`; // TODO switch to public gcloud buckets export const ANGLE_API = `https://api.angle.money/`; diff --git a/src/helpers/index.ts b/src/helpers/index.ts index 051e9d6..f544ca9 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -1,12 +1,11 @@ -import { AMM, AMMAlgorithm, AMMAlgorithmMapping, Erc20__factory, Multicall__factory } from '@angleprotocol/sdk'; +import { AMM, AMMAlgorithm, AMMAlgorithmMapping, Erc20__factory, MULTICALL_ADDRESS, Multicall__factory } from '@angleprotocol/sdk'; -import { MULTICALL_ADDRESS } from '../constants'; import { httpProvider } from '../providers'; import { PoolInterface } from '../types'; export const fetchPoolName = async (chainId: number, pool: string, amm: AMM) => { const provider = httpProvider(chainId); - const multicall = Multicall__factory.connect(MULTICALL_ADDRESS, provider); + const multicall = Multicall__factory.connect(MULTICALL_ADDRESS(chainId), provider); const poolInterface = PoolInterface(AMMAlgorithmMapping[amm]); const erc20Interface = Erc20__factory.createInterface(); diff --git a/src/utils/providers.ts b/src/utils/providers.ts index f6a633b..de463c8 100644 --- a/src/utils/providers.ts +++ b/src/utils/providers.ts @@ -1,8 +1,14 @@ -import { ChainId, DistributionCreator__factory, MerklChainId, Multicall, Multicall__factory, registry } from '@angleprotocol/sdk'; +import { + ChainId, + DistributionCreator__factory, + MULTICALL_ADDRESS, + MerklChainId, + Multicall, + Multicall__factory, + registry, +} from '@angleprotocol/sdk'; import { providers as p } from 'ethers'; -import { MULTICALL_ADDRESS } from '../constants'; - export const providers = Object.keys(ChainId).reduce((prev, chainId) => { const url = process.env?.[`PROVIDER_${chainId}`]; if (!!url) prev[chainId] = new p.StaticJsonRpcProvider(url); @@ -14,7 +20,8 @@ export function provider(chainId: MerklChainId): p.StaticJsonRpcProvider | p.Inf } export const multicalls = Object.keys(ChainId).reduce((prev, chainId) => { - if (!!providers[chainId]) prev[chainId] = Multicall__factory.connect(MULTICALL_ADDRESS, providers[chainId]); + if (!!providers[chainId]) + prev[chainId] = Multicall__factory.connect(MULTICALL_ADDRESS(chainId as unknown as ChainId), providers[chainId]); return prev; }, {} as { [chainId in ChainId]: Multicall }); diff --git a/yarn.lock b/yarn.lock index 7812f5f..e4d155c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,10 +7,10 @@ resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== -"@angleprotocol/sdk@0.26.14": - version "0.26.14" - resolved "https://npm.pkg.github.com/download/@angleprotocol/sdk/0.26.14/06a1915797f3351011bf510ea3847aafb0183f06#06a1915797f3351011bf510ea3847aafb0183f06" - integrity sha512-amfvdAj6JM7RA0egpkZ3HhVF+7pJA68Z4UARGFwdRpBu6fQXd+JSHYGE0PqquxU5ujyp4+JdRHeOtdg6RVJ23Q== +"@angleprotocol/sdk@2.3.3": + version "2.3.3" + resolved "https://npm.pkg.github.com/download/@angleprotocol/sdk/2.3.3/d7704f15188fadd674d9b8d03753efb7b35a68aa#d7704f15188fadd674d9b8d03753efb7b35a68aa" + integrity sha512-6gqgad5OxCNl8gsTHUFtOXYM9yVD3zrFwUQGyZp4vQQKe7T0PXe6sAbRw69gCFiL0N0mf52oleZynf0YYRKQ/g== dependencies: "@apollo/client" "^3.7.17" "@typechain/ethers-v5" "^10.0.0" @@ -23,7 +23,7 @@ lodash "^4.17.21" merkletreejs "^0.3.10" tiny-invariant "^1.1.0" - typechain "^8.0.0" + typechain "^8.3.2" "@apollo/client@^3.7.17": version "3.8.9" @@ -3772,7 +3772,7 @@ type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" -typechain@^8.0.0: +typechain@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/typechain/-/typechain-8.3.2.tgz#1090dd8d9c57b6ef2aed3640a516bdbf01b00d73" integrity sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q==