Skip to content

Commit 1f0507a

Browse files
committed
pool+batches: properly handle 0 bps batches
The first block on testnet has a clearing_price_rate of 6 and a volume of 5,000,000, which calculates to less than 1 bps. A batch with 0 bps throws an error when calculating the pct change
1 parent 40acbde commit 1f0507a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/src/store/models/batch.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ export default class Batch {
148148
this.clearingPriceRate,
149149
this.leaseDuration,
150150
);
151-
return Math.round(pct * 100 * 100);
151+
// convert the percentage to basis points. round up to prevent 0 bps
152+
// which is the case for the first batch on testnet which has a
153+
// clearingPriceRate of 6
154+
return Math.ceil(pct * 100 * 100);
152155
}
153156

154157
/** the percentage change of this batch's rate compared to the previous batch */

0 commit comments

Comments
 (0)