Skip to content

Commit

Permalink
feat: change delegation capacity to x/20k
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash committed Jun 20, 2024
1 parent df1a486 commit 93e3499
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/lib/network/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import BigNumber from 'bignumber.js';
import { fromSqd } from './utils';

export * from './utils';

export function calculateDelegationCapacity({
totalDelegation,
capedDelegation,
}: {
capedDelegation: string;
totalDelegation: string;
}) {
const td = BigNumber(totalDelegation);
if (td.isZero()) return 0;

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

const ratio = new BigNumber(1).minus(cd.div(td));
return ratio.lt(0) ? 0 : ratio.times(100).toNumber();
return fromSqd(totalDelegation).div(20_000).times(100).toNumber();
}

0 comments on commit 93e3499

Please sign in to comment.