File tree Expand file tree Collapse file tree 2 files changed +159
-167
lines changed Expand file tree Collapse file tree 2 files changed +159
-167
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,7 @@ import Big from 'big.js';
11
11
export const percentage = ( portion : Big , whole : Big , decimals = 0 ) : number => {
12
12
if ( whole . eq ( 0 ) ) return 0 ;
13
13
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 ) ;
18
15
} ;
19
16
20
17
/**
@@ -35,11 +32,6 @@ export const toBasisPoints = (value: number) => Math.round(toPercent(value) * 10
35
32
* @param premium the premium being paid for the loan
36
33
* @param termInDays the term of the loan in days
37
34
*/
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 ) ;
45
37
} ;
You can’t perform that action at this time.
0 commit comments