diff --git a/src/calculators/circulation-supply.js b/src/calculators/circulation-supply.js index 85d95fc..1da7b52 100644 --- a/src/calculators/circulation-supply.js +++ b/src/calculators/circulation-supply.js @@ -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