Skip to content

Commit

Permalink
✨ irm: add utilization utils
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed Mar 20, 2024
1 parent 3810a91 commit a93457b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/interest-rate-model/fixedUtilization.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import WAD from "../fixed-point-math/WAD.js";

export default function fixedUtilization(supplied: bigint, borrowed: bigint, assets: bigint) {
return assets !== 0n && borrowed > supplied ? ((borrowed - supplied) * WAD - 1n) / assets + 1n : 0n;
}
5 changes: 5 additions & 0 deletions src/interest-rate-model/floatingUtilization.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import WAD from "../fixed-point-math/WAD.js";

export default function floatingUtilization(assets: bigint, debt: bigint) {
return assets !== 0n && debt !== 0n ? (debt * WAD - 1n) / assets + 1n : 0n;
}
5 changes: 5 additions & 0 deletions src/interest-rate-model/globalUtilization.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import WAD from "../fixed-point-math/WAD.js";

export default function globalUtilization(assets: bigint, debt: bigint, backupBorrowed: bigint) {
return assets !== 0n && debt + backupBorrowed !== 0n ? ((debt + backupBorrowed) * WAD - 1n) / assets + 1n : 0n;
}

0 comments on commit a93457b

Please sign in to comment.