Skip to content

Commit 7780c94

Browse files
committed
util: update types in the util functions
1 parent 680b749 commit 7780c94

File tree

2 files changed

+159
-167
lines changed

2 files changed

+159
-167
lines changed

app/src/util/bigmath.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import Big from 'big.js';
1111
export const percentage = (portion: Big, whole: Big, decimals = 0): number => {
1212
if (whole.eq(0)) return 0;
1313

14-
// needed because RoundingMode.RoundDown is a `const enum` which we cannot use
15-
// with '--isolatedModules'
16-
const roundDown = 0;
17-
return +portion.mul(100).div(whole).round(decimals, roundDown);
14+
return +portion.mul(100).div(whole).round(decimals, Big.roundDown);
1815
};
1916

2017
/**
@@ -35,11 +32,6 @@ export const toBasisPoints = (value: number) => Math.round(toPercent(value) * 10
3532
* @param premium the premium being paid for the loan
3633
* @param termInDays the term of the loan in days
3734
*/
38-
export const annualPercentRate = (
39-
principal: number,
40-
premium: number,
41-
termInDays: number,
42-
) => {
43-
const apr = (premium / principal / termInDays) * 365;
44-
return apr;
35+
export const annualPercentRate = (principal: Big, premium: Big, termInDays: number) => {
36+
return +premium.div(principal).div(termInDays).mul(365);
4537
};

0 commit comments

Comments
 (0)