@ethersproject/constants#WeiPerEther TypeScript Examples
The following examples show how to use
@ethersproject/constants#WeiPerEther.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From snapshot-strategies with MIT License | 5 votes |
async function getVaultBalance(network, provider, addresses, blockTag) {
const vaultMulti = new Multicaller(network, provider, vaultAbi, { blockTag });
vaultMulti.call(
CAKE_VAULT_ADDRESS,
CAKE_VAULT_ADDRESS,
'getPricePerFullShare'
);
addresses.forEach((address) =>
vaultMulti.call(
`${CAKE_VAULT_ADDRESS}-${address}`,
CAKE_VAULT_ADDRESS,
'userInfo',
[address]
)
);
if (blockTag >= IFO_POOL_START_BLOCK) {
vaultMulti.call(IFO_POOL_ADDRESS, IFO_POOL_ADDRESS, 'getPricePerFullShare');
addresses.forEach((address) => {
vaultMulti.call(
`${IFO_POOL_ADDRESS}-${address}`,
IFO_POOL_ADDRESS,
'userInfo',
[address]
);
});
}
const vaultMultiRes = await vaultMulti.execute();
return Object.fromEntries<BigNumber>(
addresses.map((address) => [
address,
(vaultMultiRes[CAKE_VAULT_ADDRESS] || Zero)
.mul(vaultMultiRes[`${CAKE_VAULT_ADDRESS}-${address}`]?.shares || Zero)
.div(WeiPerEther)
.add(
(vaultMultiRes[IFO_POOL_ADDRESS] || Zero)
.mul(
vaultMultiRes[`${IFO_POOL_ADDRESS}-${address}`]?.shares || Zero
)
.div(WeiPerEther)
)
])
);
}