Skip to content

Commit

Permalink
Merge pull request #112 from balancer-labs/develop
Browse files Browse the repository at this point in the history
0.1.19
  • Loading branch information
johngrantuk authored Jul 18, 2022
2 parents 4e85398 + 1a8af37 commit 3921795
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion balancer-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@balancer-labs/sdk",
"version": "0.1.18",
"version": "0.1.19",
"description": "JavaScript SDK for interacting with the Balancer Protocol V2",
"license": "GPL-3.0-only",
"homepage": "https://github.com/balancer-labs/balancer-sdk/balancer-js#readme",
Expand Down
30 changes: 28 additions & 2 deletions balancer-js/src/modules/sor/pool-data/onChainData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ export async function getOnChainBalances(
]);
multiPool.call(`${pool.id}.totalSupply`, pool.address, 'totalSupply');

// Pools with pre minted BPT
if (pool.poolType.includes('Linear') || pool.poolType === 'StablePhantom') {
multiPool.call(
`${pool.id}.virtualSupply`,
pool.address,
'getVirtualSupply'
);
}

// TO DO - Make this part of class to make more flexible?
if (
pool.poolType === 'Weighted' ||
Expand Down Expand Up @@ -110,6 +119,7 @@ export async function getOnChainBalances(
balances: string[];
};
totalSupply: string;
virtualSupply?: string;
rate?: string;
}
>;
Expand All @@ -126,6 +136,7 @@ export async function getOnChainBalances(
balances: string[];
};
totalSupply: string;
virtualSupply?: string;
rate?: string;
}
>;
Expand All @@ -137,7 +148,8 @@ export async function getOnChainBalances(

Object.entries(pools).forEach(([poolId, onchainData], index) => {
try {
const { poolTokens, swapFee, weights, totalSupply } = onchainData;
const { poolTokens, swapFee, weights, totalSupply, virtualSupply } =
onchainData;

if (
subgraphPools[index].poolType === 'Stable' ||
Expand Down Expand Up @@ -197,7 +209,21 @@ export async function getOnChainBalances(
}
});

subgraphPools[index].totalShares = formatFixed(totalSupply, 18);
// Pools with pre minted BPT
if (
subgraphPools[index].poolType.includes('Linear') ||
subgraphPools[index].poolType === 'StablePhantom'
) {
if (virtualSupply === undefined) {
console.error(
`Pool with pre-minted BPT missing Virtual Supply: ${poolId}`
);
return;
}
subgraphPools[index].totalShares = formatFixed(virtualSupply, 18);
} else {
subgraphPools[index].totalShares = formatFixed(totalSupply, 18);
}

onChainPools.push(subgraphPools[index]);
} catch (err) {
Expand Down

0 comments on commit 3921795

Please sign in to comment.