From dd464e24f667e4a04059fee56c24b4ba786048c5 Mon Sep 17 00:00:00 2001 From: Ian Woodard <17186604+IanWoodard@users.noreply.github.com> Date: Sat, 17 Aug 2024 10:22:27 -0700 Subject: [PATCH] Improving borrow entry logic (#883) --- .../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)}