Skip to content

Commit 6bb8cd5

Browse files
authored
Merge pull request #83 from blend-capital/add-apy
feat: add apy calcs and fix backstop take rate application
2 parents 5325b2f + 3d881f0 commit 6bb8cd5

File tree

7 files changed

+147
-243
lines changed

7 files changed

+147
-243
lines changed

package-lock.json

Lines changed: 48 additions & 202 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blend-capital/blend-sdk",
3-
"version": "3.0.0-beta.6",
3+
"version": "3.0.0-beta.7",
44
"description": "Javascript SDK for the Blend Protocol",
55
"type": "module",
66
"scripts": {

src/pool/pool.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ export class PoolV2 extends Pool {
125125
contractReserve.data,
126126
0,
127127
0,
128+
0,
129+
0,
128130
latestLedger
129131
);
130-
reserve.setAPR();
132+
reserve.setRates(BigInt(metadata.backstopRate));
131133
reserves.set(reserve.assetId, reserve);
132134
});
133135

src/pool/pool_est.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export class PoolEstimate {
1717
*/
1818
public totalBorrowed: number,
1919
/**
20-
* The average APR accrued by all borrowed tokens
20+
* The average APY accrued by all borrowed tokens
2121
*/
22-
public avgBorrowApr: number
22+
public avgBorrowApy: number
2323
) {}
2424

2525
static build(reserves: Map<string, Reserve>, poolOracle: PoolOracle): PoolEstimate {
@@ -34,11 +34,11 @@ export class PoolEstimate {
3434
const reserveLiabilitiesBase =
3535
toFloat(reserve.totalLiabilities(), reserve.config.decimals) * oraclePrice;
3636
totalBorrowed += reserveLiabilitiesBase;
37-
totalInterestInYear += reserveLiabilitiesBase * reserve.borrowApr;
37+
totalInterestInYear += reserveLiabilitiesBase * reserve.estBorrowApy;
3838
}
3939
}
40-
const avgBorrowApr = totalBorrowed != 0 ? totalInterestInYear / totalBorrowed : 0;
40+
const avgBorrowApy = totalBorrowed != 0 ? totalInterestInYear / totalBorrowed : 0;
4141

42-
return new PoolEstimate(totalSupply, totalBorrowed, avgBorrowApr);
42+
return new PoolEstimate(totalSupply, totalBorrowed, avgBorrowApy);
4343
}
4444
}

0 commit comments

Comments
 (0)