Skip to content

Commit

Permalink
🐛 installments: use deposit and borrow totals for utilizations
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed Apr 17, 2024
1 parent c61051a commit 3f975f6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions hooks/useInstallmentsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@ export default function useInstallmentsData({
const getDetails = useCallback(
(amount: bigint, installments_: bigint, firstMaturity: bigint) => {
if (amount === 0n || irmParameters === undefined || marketAccount === undefined) return;
const { floatingUtilization, floatingAssets, floatingDebt, floatingBackupBorrowed, fixedPools } = marketAccount;
const {
floatingUtilization,
totalFloatingBorrowAssets,
totalFloatingDepositAssets,
floatingBackupBorrowed,
fixedPools,
} = marketAccount;
const fixedPoolsUtilizations = fixedPools
.filter(({ maturity }) => maturity >= firstMaturity && maturity < firstMaturity + installments_ * INTERVAL)
.map(({ supplied, borrowed }) => fixedUtilization(supplied, borrowed, floatingAssets));
.map(({ supplied, borrowed }) => fixedUtilization(supplied, borrowed, totalFloatingDepositAssets));
const timestamp = Math.round(Date.now() / 1000);
const parameters = [
floatingAssets,
totalFloatingDepositAssets,
Number(firstMaturity),
Number(installments_),
fixedPoolsUtilizations,
floatingUtilization,
globalUtilization(floatingAssets, floatingDebt, floatingBackupBorrowed),
globalUtilization(totalFloatingDepositAssets, totalFloatingBorrowAssets, floatingBackupBorrowed),
irmParameters,
timestamp,
] as const;
Expand Down

0 comments on commit 3f975f6

Please sign in to comment.