Skip to content

Commit

Permalink
fix total staking (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
EugenWay authored Feb 6, 2024
1 parent 25fefda commit 3cd7b85
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/calculators/circulation-supply.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,11 @@ export async function totalVesting() {
}

export async function totalStaking() {
const prefix = api.query.balances.locks.keyPrefix();
const keys = await getKeys(prefix);
const allLocks = await api.rpc.state.queryStorageAt(keys);

let total = BigInt(0);

for (const lock of allLocks) {
const withType = api.registry.createType('PalletBalancesBalanceLock', lock.toU8a().slice(2));
const currentEra = (await api.query.staking.currentEra()).toHuman();
const staking = await api.query.staking.erasTotalStake(currentEra);
const total = staking.toBigInt() / BigInt(10 ** DECIMALS)

if (withType.id.toHex() == STAKING_HEX) {
total += withType.amount.toBigInt();
}
}
const totalStaking = total / BigInt(10 ** DECIMALS);
return Number(totalStaking);
return Number(total)
}

// Get all pool addresses
Expand Down

0 comments on commit 3cd7b85

Please sign in to comment.