diff --git a/src/hooks/useBorrowingPower.ts b/src/hooks/useBorrowingPower.ts index 2574dcd..6923948 100644 --- a/src/hooks/useBorrowingPower.ts +++ b/src/hooks/useBorrowingPower.ts @@ -8,8 +8,8 @@ import { useUserObligations } from "./useUserObligations"; // TODO: add option to decrease buying power by overcollateralization factor // TODO: add support for balance in the wallet -export function useBorrowingPower(reserveAddress: string | PublicKey, includeWallet = false, overcollateralize = true) { - const key = useMemo(() => typeof reserveAddress === 'string' ? reserveAddress : reserveAddress.toBase58(), [reserveAddress]); +export function useBorrowingPower(reserveAddress: string | PublicKey | undefined, includeWallet = false, overcollateralize = true) { + const key = useMemo(() => typeof reserveAddress === 'string' ? reserveAddress : reserveAddress?.toBase58() || '', [reserveAddress]); const reserve = useLendingReserve(key); diff --git a/src/views/borrowReserve/index.tsx b/src/views/borrowReserve/index.tsx index 1f1f2cb..0a6a809 100644 --- a/src/views/borrowReserve/index.tsx +++ b/src/views/borrowReserve/index.tsx @@ -67,14 +67,14 @@ export const BorrowReserveView = () => { - + - + { const { reserve: reserveId, obligation: obligationId } = useParams<{ @@ -17,35 +20,83 @@ export const RepayReserveView = () => { }>(); const lendingObligation = useEnrichedLendingObligation(obligationId); - const lendingReserve = useLendingReserve( - obligationId ? lendingObligation?.info.borrowReserve : reserveId - ); + const id = obligationId ? lendingObligation?.info.borrowReserve : reserveId; + const lendingReserve = useLendingReserve(id); const repayReserve = useLendingReserve( obligationId ? lendingObligation?.info.collateralReserve : reserveId ); + const { userObligations, totalInQuote: loansValue } = useUserObligations(); + const { totalInQuote: borrowingPower, utilization } = useBorrowingPower(id); + const reserve = lendingReserve?.info; if (!reserve || !lendingReserve || !lendingObligation) { return null; } + return (
-
- - -
-
- ); -}; + + + + + + + + + + + + + + + + + + + item.obligation.info.borrowedInQuote / loansValue} + name={(item) => item.obligation.info.repayName} /> + + + + + + + + + + + + ); +}