From f585e35906c4a7e093f7965d96d2187e78bff504 Mon Sep 17 00:00:00 2001 From: Karan Shahani Date: Thu, 16 Nov 2023 10:45:04 -0500 Subject: [PATCH] fix(spool): Fix flaky data props --- .../spool.staking.contract-position-fetcher.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/apps/spool/ethereum/spool.staking.contract-position-fetcher.ts b/src/apps/spool/ethereum/spool.staking.contract-position-fetcher.ts index e113734b0..2b38d8924 100644 --- a/src/apps/spool/ethereum/spool.staking.contract-position-fetcher.ts +++ b/src/apps/spool/ethereum/spool.staking.contract-position-fetcher.ts @@ -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 }; }