Skip to content

Commit 00e7f6f

Browse files
committed
fix: untilization
1 parent 69bbcb6 commit 00e7f6f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/core/pool.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,15 @@ export class PoolData {
210210
}
211211

212212
static calculateUtilization(expected: bigint, available: bigint) {
213-
return expected > 0
214-
? Number(((expected - available) * PERCENTAGE_FACTOR) / expected) /
215-
Number(PERCENTAGE_DECIMALS)
216-
: 0;
213+
if (expected === 0n) return 0;
214+
215+
const borrowed = expected - available;
216+
217+
const u =
218+
Number((borrowed * PERCENTAGE_FACTOR) / expected) /
219+
Number(PERCENTAGE_DECIMALS);
220+
221+
return Math.max(0, u);
217222
}
218223
}
219224

0 commit comments

Comments
 (0)