Skip to content

Commit

Permalink
add apr helper
Browse files Browse the repository at this point in the history
  • Loading branch information
0xodia committed Nov 29, 2024
1 parent 3481820 commit 0819392
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion solend-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solendprotocol/solend-sdk",
"version": "0.13.32",
"version": "0.13.33",
"private": true,
"main": "src/index.ts",
"module": "src/index.ts",
Expand Down
3 changes: 2 additions & 1 deletion solend-sdk/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export * from "./actions";
export * from "./margin";
export * from "./actions";
export * from "./utils/wallet";
export * from "./rewards";
export * from "./rewards";
export * from "./utils/rates";
7 changes: 7 additions & 0 deletions solend-sdk/src/core/utils/rates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,10 @@ export const calculateSupplyInterest = (reserve: Reserve, showApy: boolean) =>

export const calculateBorrowInterest = (reserve: Reserve, showApy: boolean) =>
showApy ? calculateBorrowAPY(reserve) : calculateBorrowAPR(reserve);

export const convertAprToApy = (apr: number) =>
new BigNumber(1)
.plus(new BigNumber(apr).dividedBy(SLOTS_PER_YEAR))
.toNumber() **
SLOTS_PER_YEAR -
1;

0 comments on commit 0819392

Please sign in to comment.