Skip to content

Commit

Permalink
Merge pull request #14 from TxnLab/fix/ui-calculate-max-stake
Browse files Browse the repository at this point in the history
fix(ui): fix issues with calculateMaxStake changes
  • Loading branch information
pbennett authored Apr 4, 2024
2 parents 19933bd + d5bde80 commit f14d61d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/src/components/ValidatorTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function ValidatorTable({ validators, stakesByValidator }: ValidatorTable
notation: 'compact',
}).format(currentStake)

const maxStake = calculateMaxStake(validator, constraints!, true)
const maxStake = calculateMaxStake(validator, constraints, true)
const maxStakeCompact = new Intl.NumberFormat(undefined, {
notation: 'compact',
}).format(maxStake)
Expand Down
5 changes: 4 additions & 1 deletion ui/src/utils/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,13 @@ export function getAddValidatorFormSchema(constraints: Constraints) {

export function calculateMaxStake(
validator: Validator,
constraints: Constraints,
constraints?: Constraints,
algos = false,
): number {
const { numPools } = validator.state
if (numPools === 0 || !constraints) {
return 0
}
const hardMaxDividedBetweenPools = constraints.maxAlgoPerValidator / BigInt(numPools)
let { maxAlgoPerPool } = validator.config
if (maxAlgoPerPool === 0n) {
Expand Down

0 comments on commit f14d61d

Please sign in to comment.