Skip to content

Commit

Permalink
Multicall only retrieving on-chain balances.
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrantuk committed Aug 21, 2020
1 parent bb5c0e8 commit 58db325
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/multicall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,12 @@ export async function getAllPoolDataOnChain(
for (let i = 0; i < pools.pools.length; i++) {
let p = pools.pools[i];

calls.push([p.id, bPool.functions.getSwapFee.encode([])]);

// Checks all tokens for pool
p.tokens.forEach(token => {
calls.push([
p.id,
bPool.functions.getBalance.encode([token.address]),
]);
calls.push([
p.id,
bPool.functions.getDenormalizedWeight.encode([token.address]),
]);
});
}

Expand All @@ -125,19 +119,14 @@ export async function getAllPoolDataOnChain(

for (let i = 0; i < poolsCopy.length; i++) {
let p = poolsCopy[i];
p.swapFee = utils.formatEther(bmath.bnum(response[j]).toString());
j++;

p.tokens.forEach(token => {
let balance = bmath.scale(
bmath.bnum(response[j]),
-token.decimals
);
token.balance = balance.toString();
j++;
token.denormWeight = utils.formatEther(
bmath.bnum(response[j]).toString()
);
j++;
});

onChainPools.pools.push(p);
Expand Down

0 comments on commit 58db325

Please sign in to comment.