Skip to content

Commit 49e694a

Browse files
authored
fix calc (#9)
1 parent b1abc2f commit 49e694a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/calculators/staking-roi.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import { DECIMALS } from '../consts.js';
66
// era_payout = total_issuance * inflation_per_era
77

88
export async function stakingRoi() {
9-
const lastEra = (await api.query.staking.currentEra()).toHuman() - 1;
9+
const lastEra = (await api.query.staking.currentEra()).toHuman();
1010

11-
const inflationPerEra = (await api.query.staking.erasValidatorReward(lastEra)).toJSON();
12-
const totalStaked = await api.query.staking.erasTotalStake(lastEra);
11+
const inflationPerEra = (await api.query.staking.erasValidatorReward(lastEra - 2)).toJSON();
12+
const totalStaked = await api.query.staking.erasTotalStake(lastEra - 2);
1313
const totalIssuance = await totalSupply();
1414

15-
return (totalIssuance * (inflationPerEra / 10 ** DECIMALS)) / (totalStaked / 10 ** DECIMALS) * 730;
15+
const roi = (totalIssuance * (inflationPerEra / 10 ** DECIMALS)) / (totalStaked / 10 ** DECIMALS) * 730;
16+
17+
return (roi / 10 ** 8)
1618
}

0 commit comments

Comments
 (0)