Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
feat(uniswap-v2): Adjust helper to prevent batch size bottleneck of M…
Browse files Browse the repository at this point in the history
…ulticall from affecting batch size of DataLoader (#983)
  • Loading branch information
immasandwich authored Aug 1, 2022
1 parent 24aaf7f commit 65268d9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/apps/uniswap-v2/helpers/uniswap-v2.pool.token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ export class UniswapV2PoolTokenHelper {
resolvePoolContract,
}).catch(() => []);

const poolTokens = await Promise.all(
// NB: Token addresses are resolved first because of a Multicall batch size of 250
// This allows DL to use its max batch size of 1000+ in the next loop
const poolTokensWithAddresses = await Promise.all(
poolAddresses.map(async address => {
const type = ContractType.APP_TOKEN;
const poolContract = resolvePoolContract({ address, network });
const [token0AddressRaw, token1AddressRaw] = await resolvePoolUnderlyingTokenAddresses({
multicall,
Expand All @@ -141,6 +142,15 @@ export class UniswapV2PoolTokenHelper {
const token1Address = token1AddressRaw.toLowerCase();
if (hiddenTokens.includes(token0Address) || hiddenTokens.includes(token1Address)) return null;

return { address, token0Address, token1Address };
}),
);

const poolTokens = await Promise.all(
compact(poolTokensWithAddresses).map(async ({ address, token0Address, token1Address }) => {
const type = ContractType.APP_TOKEN;
const poolContract = resolvePoolContract({ address, network });

const resolvedTokens = await Promise.all(
[token0Address, token1Address].map(async tokenAddress => {
let underlyingToken: AppTokenPosition | BaseTokenPrice | null = appTokensByAddress[tokenAddress];
Expand Down

0 comments on commit 65268d9

Please sign in to comment.