Skip to content

Commit

Permalink
ts-sdk: fix client borrow interest rate calculation (#479)
Browse files Browse the repository at this point in the history
* bigz/fix-calculateInterestRate

* update CHANGELOG.md

---------

Co-authored-by: 0xbigz <“[email protected]”>
  • Loading branch information
0xbigz and 0xbigz authored May 25, 2023
1 parent 9f97421 commit 5cf9b27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- program: add user perp lp jit liquidity toward a target base (([#448](https://github.com/drift-labs/protocol-v2/pull/448)))
- ts-sdk: drift client will query rpc to find all markets/oracles if they're not explicitly specified (([#469](https://github.com/drift-labs/protocol-v2/pull/469)))
- ts-sdk: fix client borrow interest rate calculation (([#479](https://github.com/drift-labs/protocol-v2/pull/479)))

### Fixes

Expand Down
4 changes: 1 addition & 3 deletions sdk/src/math/spotBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ export function calculateInterestRate(bank: SpotMarketAccount): BN {
} else {
const borrowRateSlope = new BN(bank.optimalBorrowRate)
.mul(SPOT_MARKET_UTILIZATION_PRECISION)
.div(
SPOT_MARKET_UTILIZATION_PRECISION.sub(new BN(bank.optimalUtilization))
);
.div(new BN(bank.optimalUtilization));

interestRate = utilization
.mul(borrowRateSlope)
Expand Down

0 comments on commit 5cf9b27

Please sign in to comment.