Skip to content

Commit 235a1b4

Browse files
committed
fix: division by zero at backing ratio
1 parent 47e484b commit 235a1b4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/fasset-indexer-api/src/analytics/dashboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {
1818

1919
const add = (x: bigint, y: bigint) => x + y
2020
const sub = (x: bigint, y: bigint) => x - y
21-
const rat = (x: bigint, y: bigint) => Number(MAX_BIPS * x / y) / Number(MAX_BIPS)
21+
const rat = (x: bigint, y: bigint) => y == BigInt(0) ? 0 : Number(MAX_BIPS * x / y) / Number(MAX_BIPS)
2222

2323
/**
2424
* DashboardAnalytics provides a set of analytics functions for the FAsset UI's dashboard.

0 commit comments

Comments
 (0)