From d0a644e222a05ba375f45406752a1ce2bc24c159 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Thu, 21 Nov 2024 11:44:01 -0800 Subject: [PATCH] fixed cw20 staked top stakers --- .../contract/voting/daoVotingCw20Staked.ts | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/formulas/formulas/contract/voting/daoVotingCw20Staked.ts b/src/formulas/formulas/contract/voting/daoVotingCw20Staked.ts index f14411eb..eb33a333 100644 --- a/src/formulas/formulas/contract/voting/daoVotingCw20Staked.ts +++ b/src/formulas/formulas/contract/voting/daoVotingCw20Staked.ts @@ -180,9 +180,24 @@ type Staker = StakerBalance & { votingPowerPercent: number } -export const topStakers: ContractFormula = { +export const topStakers: ContractFormula< + Staker[], + { + limit?: string + } +> = { docs: { description: 'retrieves the top stakers sorted by voting power', + args: [ + { + name: 'limit', + description: 'maximum number of stakers to return', + required: false, + schema: { + type: 'integer', + }, + }, + ], }, compute: async (env) => { const stakingContractAddress = await stakingContract.compute(env) @@ -210,7 +225,14 @@ export const topStakers: ContractFormula = { }) // Get total power. - const totalVotingPower = Number(await totalPower.compute(env)) + const totalVotingPower = Number( + await totalPower.compute({ + ...env, + // Make sure to not pass height to totalPower in case it was passed to + // this formula. + args: {}, + }) + ) // Compute voting power for each staker. const stakers = topStakers.map((staker) => ({