Skip to content

Commit

Permalink
Improving borrow entry logic (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanWoodard authored Aug 17, 2024
1 parent 3bf0af0 commit dd464e2
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions earn/src/components/markets/borrow/BorrowingWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
<BorrowModalUniswap
isOpen={selectedBorrows != null && selectedCollateral != null}
selectedLendingPair={
// TODO: improve this
filteredBorrowEntries.find((x) => x.token.equals(selectedBorrows))!.matchingPairs[0]
}
selectedLendingPair={borrowEntry.matchingPairs[0]}
selectedCollateral={selectedCollateral}
selectedBorrow={selectedBorrows}
setIsOpen={() => {
Expand All @@ -256,10 +255,7 @@ export default function BorrowingWidget(props: BorrowingWidgetProps) {
borrowModal = (
<BorrowModal
isOpen={selectedBorrows != null && selectedCollateral != null}
selectedLendingPair={
// TODO: improve this
filteredBorrowEntries.find((x) => x.token.equals(selectedBorrows))!.matchingPairs[0]
}
selectedLendingPair={borrowEntry.matchingPairs[0]}
selectedCollateral={selectedCollateral}
selectedBorrow={selectedBorrows}
userBalance={tokenBalances.get(selectedCollateral.address)?.gn ?? GN.zero(selectedCollateral.decimals)}
Expand Down

0 comments on commit dd464e2

Please sign in to comment.