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

Commit

Permalink
fix(spool): Fix flaky data props
Browse files Browse the repository at this point in the history
  • Loading branch information
immasandwich committed Nov 16, 2023
1 parent 3d5c23d commit f585e35
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/apps/spool/ethereum/spool.staking.contract-position-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,12 @@ export class EthereumSpoolStakingContractPositionFetcher extends ContractPositio
const spoolContract = this.appToolkit.globalViemContracts.erc20(spoolToken);
const voSpoolContract = this.contractFactory.spoolVospool(voSpoolToken);

const totalStaked = await multicall.wrap(spoolContract).read.balanceOf([STAKING_ADDRESS]);
const totalStakedRaw = await multicall.wrap(spoolContract).read.balanceOf([STAKING_ADDRESS]);
const votingPowerRaw = await multicall.wrap(voSpoolContract).read.getTotalGradualVotingPower();

const spoolStaked = BigNumber.from(totalStaked).div(BigNumber.from(10).pow(spoolToken.decimals)).toNumber();
const totalAccVoSpool = BigNumber.from(votingPowerRaw)
.div(BigNumber.from(10).pow(voSpoolToken.decimals))
.toNumber();
const pricePrecision = 10 ** 10;
const tvl = BigNumber.from(pricePrecision * spoolToken.price)
.mul(totalStaked)
.div(pricePrecision)
.div(BigNumber.from(10).pow(spoolToken.decimals))
.toNumber();
const totalAccVoSpool = Number(votingPowerRaw) / 10 ** voSpoolToken.decimals;
const spoolStaked = Number(totalStakedRaw) / 10 ** spoolToken.decimals;
const tvl = spoolStaked * spoolToken.price;

return { tvl, spoolStaked, totalAccVoSpool };
}
Expand Down

0 comments on commit f585e35

Please sign in to comment.