Skip to content

Commit

Permalink
fix: multicall dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
Picodes committed May 10, 2024
1 parent 6dd713a commit bbd7e6a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -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/`;
Expand Down
5 changes: 2 additions & 3 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
15 changes: 11 additions & 4 deletions src/utils/providers.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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 });

Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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==
Expand Down

0 comments on commit bbd7e6a

Please sign in to comment.