File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ import { DECIMALS } from '../consts.js';
6
6
// era_payout = total_issuance * inflation_per_era
7
7
8
8
export async function stakingRoi ( ) {
9
- const lastEra = ( await api . query . staking . currentEra ( ) ) . toHuman ( ) - 1 ;
9
+ const lastEra = ( await api . query . staking . currentEra ( ) ) . toHuman ( ) ;
10
10
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 ) ;
13
13
const totalIssuance = await totalSupply ( ) ;
14
14
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 )
16
18
}
You can’t perform that action at this time.
0 commit comments