Skip to content

Commit

Permalink
fixed cw20 staked top stakers
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Nov 21, 2024
1 parent 0250fde commit d0a644e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/formulas/formulas/contract/voting/daoVotingCw20Staked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,24 @@ type Staker = StakerBalance & {
votingPowerPercent: number
}

export const topStakers: ContractFormula<Staker[]> = {
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)
Expand Down Expand Up @@ -210,7 +225,14 @@ export const topStakers: ContractFormula<Staker[]> = {
})

// 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) => ({
Expand Down

0 comments on commit d0a644e

Please sign in to comment.