Skip to content

Commit

Permalink
APT-1513: APR calculation fix (#15)
Browse files Browse the repository at this point in the history
* apr calculation fix

* Update src/misc/stakingPoolsConfig.ts

Co-authored-by: Mark T. B. Carroll <[email protected]>

---------

Co-authored-by: Łukasz Kosiak <[email protected]>
Co-authored-by: Mark T. B. Carroll <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent 6abc4ff commit f6909d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/stakingPoolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const StakingPoolCard: React.FC<StakingPoolCardProps> = ({
: 'text-gray4'
}`}
>
VP {stakingPoolData.data.votingPower * 100}%
VP {(stakingPoolData.data.votingPower * 100).toPrecision(3)}%
</div>
) : (
<>
Expand Down
6 changes: 4 additions & 2 deletions src/misc/stakingPoolsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ async function fetchDelegatorDataFromNetwork(definition: StakingPoolDefinition,

const zilToTokenRate = 1 / parseFloat(formatUnits(zilToTokenRateWei, 18));

const commission = Number((commissionNumerator * 100n) / commissionDenominator) / 100;
const votingPower = Number(((delegatorStake * 100n) / depositTotalStake)) / 100;
const bigintDivisionPrecision = 1000000n;

const commission = Number((commissionNumerator * bigintDivisionPrecision) / commissionDenominator) / Number(bigintDivisionPrecision);
const votingPower = Number(((delegatorStake * bigintDivisionPrecision) / depositTotalStake)) / Number(bigintDivisionPrecision);
const rewardsPerYearInZil = 51000 * 24 * 365;

const delegatorYearReward = votingPower * rewardsPerYearInZil;
Expand Down

0 comments on commit f6909d8

Please sign in to comment.