Skip to content

Commit

Permalink
fix: inverse capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash committed Jun 7, 2024
1 parent 95ecc9e commit c3094b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/lib/network/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export function calculateDelegationCapacity({
totalDelegation: string;
}) {
const td = BigNumber(totalDelegation);
if (td.isZero()) return 100;
if (td.isZero()) return 0;

const cd = BigNumber(capedDelegation);
if (cd.isZero()) return Infinity;
if (cd.isZero()) return 0;

const ratio = cd.div(td);
return ratio.gt(1) ? 100 : ratio.times(100).toNumber();
const ratio = new BigNumber(1).minus(cd.div(td));
return ratio.lt(0) ? 0 : ratio.times(100).toNumber();
}
2 changes: 1 addition & 1 deletion src/pages/WorkersPage/WorkerDelegate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export function WorkerDelegate({
<Box>Delegation capacity</Box>
<Stack direction="row">
{isCapedDelegationLoading ? '-' : percentFormatter(delegationCapacity)}
<HelpTooltip help="Lower factor leads to lower APR" />
<HelpTooltip help="Higher capacity leads to lower APR" />
</Stack>
</Stack>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/WorkersPage/WorkerUndelegate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function WorkerUndelegate({
<Box>Delegation capacity</Box>
<Stack direction="row">
{isCapedDelegationLoading ? '-' : percentFormatter(delegationCapacity)}
<HelpTooltip help="Lower factor leads to lower APR" />
<HelpTooltip help="Higher capacity leads to lower APR" />
</Stack>
</Stack>
<BlockchainContractError error={error} />
Expand Down

0 comments on commit c3094b8

Please sign in to comment.