Skip to content

Commit

Permalink
🐛 installments: calculate installments on borrowAtMaturity only
Browse files Browse the repository at this point in the history
  • Loading branch information
franm91 committed May 6, 2024
1 parent a229043 commit a01461a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions contexts/OperationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export const OperationContextProvider: FC<PropsWithChildren<Props>> = ({ args, c
const marketContract = useMarket(marketAccount?.market);
const ETHRouterContract = useETHRouter();
const { installmentsOptions, installmentsDetails } = useInstallmentsData({
operation,
qty,
date,
symbol: marketSymbol,
Expand Down
13 changes: 11 additions & 2 deletions hooks/useInstallmentsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import globalUtilization from '@exactly/lib/esm/interest-rate-model/globalUtiliz
import useAccountData from 'hooks/useAccountData';
import { INTERVAL } from 'utils/utils';
import useIRM from 'hooks/useIRM';
import { Operation } from 'types/Operation';

export default function useInstallmentsData({
operation,
qty,
date,
symbol,
installments,
}: {
operation: Operation;
qty: string;
date?: bigint;
symbol: string;
Expand All @@ -23,7 +26,13 @@ export default function useInstallmentsData({

const getDetails = useCallback(
(amount: bigint, installments_: bigint, firstMaturity: bigint) => {
if (amount === 0n || irmParameters === undefined || marketAccount === undefined) return;
if (
amount === 0n ||
irmParameters === undefined ||
marketAccount === undefined ||
operation !== 'borrowAtMaturity'
)
return;
const {
floatingUtilization,
totalFloatingBorrowAssets,
Expand Down Expand Up @@ -66,7 +75,7 @@ export default function useInstallmentsData({
effectiveRate,
};
},
[irmParameters, marketAccount],
[irmParameters, marketAccount, operation],
);

const installmentsOptions = useMemo(() => {
Expand Down

0 comments on commit a01461a

Please sign in to comment.