Skip to content

Commit

Permalink
fix: divide by zero issue
Browse files Browse the repository at this point in the history
  • Loading branch information
SarjuHansaliya committed Nov 9, 2023
1 parent 16f77eb commit 304b223
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/handlers/pangolin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ export const aprChefMultiple: Handler = async (_, context) => {
liquidityUSD = liquidityUSD.add(Math.floor(reserveUSD));
}

const fees = swapVolumeUSD.mul(365).div(pairDayDatas.length).mul(3).div(1000);
const averageLiquidityUSD = liquidityUSD.div(pairDayDatas.length);
const fees = swapVolumeUSD.mul(365).div(pairDayDatas.length || 1).mul(3).div(1000);

Check failure on line 328 in src/handlers/pangolin.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `.mul(365).div(pairDayDatas.length·||·1).mul(3)` with `⏎······.mul(365)⏎······.div(pairDayDatas.length·||·1)⏎······.mul(3)⏎······`

Check failure on line 328 in src/handlers/pangolin.ts

View workflow job for this annotation

GitHub Actions / Lint

Use `.length > 0` when checking length is not zero.
const averageLiquidityUSD = liquidityUSD.div(pairDayDatas.length || 1);

Check failure on line 329 in src/handlers/pangolin.ts

View workflow job for this annotation

GitHub Actions / Lint

Use `.length > 0` when checking length is not zero.
const swapFeeAPR = averageLiquidityUSD.isZero() ? ZERO : fees.mul(100).div(averageLiquidityUSD);

aprs.push({
Expand Down

0 comments on commit 304b223

Please sign in to comment.