From 64bc4c56ab9e7a1693bcb425e1f3e1b771b06e13 Mon Sep 17 00:00:00 2001 From: ianwoodard <17186604+IanWoodard@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:29:06 -0700 Subject: [PATCH] Improving borrow entry logic --- .../components/markets/borrow/BorrowingWidget.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/earn/src/components/markets/borrow/BorrowingWidget.tsx b/earn/src/components/markets/borrow/BorrowingWidget.tsx index 868342d1..4e6d7a6b 100644 --- a/earn/src/components/markets/borrow/BorrowingWidget.tsx +++ b/earn/src/components/markets/borrow/BorrowingWidget.tsx @@ -234,15 +234,14 @@ export default function BorrowingWidget(props: BorrowingWidgetProps) { let borrowModal: JSX.Element | null = null; - if (selectedBorrows != null && selectedCollateral != null) { + const borrowEntry = selectedBorrows ? filteredBorrowEntries.find((x) => x.token.equals(selectedBorrows)) : null; + + if (selectedBorrows != null && selectedCollateral != null && borrowEntry?.matchingPairs.length) { if (collateralIsUniswapPosition(selectedCollateral)) { borrowModal = ( x.token.equals(selectedBorrows))!.matchingPairs[0] - } + selectedLendingPair={borrowEntry.matchingPairs[0]} selectedCollateral={selectedCollateral} selectedBorrow={selectedBorrows} setIsOpen={() => { @@ -256,10 +255,7 @@ export default function BorrowingWidget(props: BorrowingWidgetProps) { borrowModal = ( x.token.equals(selectedBorrows))!.matchingPairs[0] - } + selectedLendingPair={borrowEntry.matchingPairs[0]} selectedCollateral={selectedCollateral} selectedBorrow={selectedBorrows} userBalance={tokenBalances.get(selectedCollateral.address)?.gn ?? GN.zero(selectedCollateral.decimals)}