Skip to content

Commit

Permalink
clean(blue-sdk): clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
oumar-fall committed Aug 7, 2024
1 parent c725ef6 commit 71c9dc4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/blue-sdk/src/maths/MathLib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ export class MathLib {
}

/**
* Converts an apr to compounded apy
* Converts an rate to compounded apy
*
* @param apr The rate to convert (in WAD)
* @param compounding The compounding basis
* @param rate The rate to convert (in WAD)
* @param period The compounding basis
*/
static rateToApy(rate: BigIntish, period: Time.PeriodLike) {
const { unit, duration } = Time.toPeriod(period);
Expand All @@ -200,14 +200,12 @@ export class MathLib {
/**
* Converts an apr to compounded apy
*
* @param apr The yearly apr to convert (in WAD)
* @param apr The apr to convert (in WAD)
* @param compounding The compounding basis
*/
static aprToApy(apr: BigIntish, compounding: Time.PeriodLike) {
const { unit, duration } = Time.toPeriod(compounding);
const factor = Time[unit].from.y(1n) / BigInt(duration);

const rate = BigInt(apr) / factor;
const rate = (BigInt(apr) * BigInt(duration)) / Time[unit].from.y(1n);

return this.rateToApy(rate, compounding);
}
Expand Down

0 comments on commit 71c9dc4

Please sign in to comment.