diff --git a/packages/ui/app/_components/Modal.tsx b/packages/ui/app/_components/Modal.tsx deleted file mode 100644 index c99224528..000000000 --- a/packages/ui/app/_components/Modal.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import React, { useEffect, useState } from 'react'; - -import Image from 'next/image'; - -export type ModalProps = { - children: React.ReactNode; - close: () => void; -}; - -export default function Modal({ children, close }: ModalProps) { - const [isMounted, setIsMounted] = useState(false); - - /** - * Animation - */ - useEffect(() => { - setIsMounted(true); - }, []); - - useEffect(() => { - let closeTimer: ReturnType; - - if (!isMounted) { - closeTimer = setTimeout(() => { - close(); - }, 301); - } - - return () => { - clearTimeout(closeTimer); - }; - }, [close, isMounted]); - - return ( -
-
- close setIsMounted(false)} - src="/img/assets/close.png" - width="20" - /> - - {children} -
-
- ); -} diff --git a/packages/ui/app/_components/dialogs/loop/index.tsx b/packages/ui/app/_components/dialogs/loop/index.tsx index 98822b45c..4642de872 100644 --- a/packages/ui/app/_components/dialogs/loop/index.tsx +++ b/packages/ui/app/_components/dialogs/loop/index.tsx @@ -14,6 +14,12 @@ import { } from 'viem'; import { useBalance, useChainId } from 'wagmi'; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle +} from '@ui/components/ui/dialog'; import { INFO_MESSAGES } from '@ui/constants/index'; import { useMultiIonic } from '@ui/context/MultiIonicContext'; import { useCurrentLeverageRatio } from '@ui/hooks/leverage/useCurrentLeverageRatio'; @@ -31,7 +37,6 @@ import BorrowActions from './BorrowActions'; import LoopHealthRatioDisplay from './LoopHealthRatioDisplay'; import LoopInfoDisplay from './LoopInfoDisplay'; import SupplyActions from './SupplyActions'; -import Modal from '../../Modal'; import ResultHandler from '../../ResultHandler'; import TransactionStepsHandler, { useTransactionSteps @@ -44,21 +49,21 @@ const SwapWidget = dynamic(() => import('../../markets/SwapWidget'), { }); export type LoopProps = { + isOpen: boolean; + setIsOpen: (open: boolean) => void; borrowableAssets: Address[]; - closeLoop: () => void; comptrollerAddress: Address; currentBorrowAsset?: MarketData; - isOpen: boolean; selectedCollateralAsset: MarketData; }; export default function Loop({ + isOpen, + setIsOpen, borrowableAssets, - closeLoop, comptrollerAddress, currentBorrowAsset, - selectedCollateralAsset, - isOpen + selectedCollateralAsset }: LoopProps) { const chainId = useChainId(); const [amount, setAmount] = useState(); @@ -570,82 +575,87 @@ export default function Loop({ return ( <> - {isOpen && ( - <> - setSwapWidgetOpen(false)} - open={swapWidgetOpen} - fromChain={chainId} - toChain={chainId} - toToken={selectedCollateralAsset.underlyingToken} - /> - closeLoop()}> -
- - - {selectedCollateralAsset.underlyingSymbol} -
- -
- {currentPosition - ? `Loop Position Found: ` - : 'No Loop Position Found, Create a New One'} - {currentPosition && ( - - 0x{currentPosition.address.slice(2, 4)}... - {currentPosition.address.slice(-6)} - - )} -
- + setSwapWidgetOpen(false)} + open={swapWidgetOpen} + fromChain={chainId} + toChain={chainId} + toToken={selectedCollateralAsset.underlyingToken} + /> + + + + +
+ + {selectedCollateralAsset.underlyingSymbol} +
+
+
-
-
-
+ {currentPosition + ? `Loop Position Found: ` + : 'No Loop Position Found, Create a New One'} + {currentPosition && ( + + 0x{currentPosition.address.slice(2, 4)}... + {currentPosition.address.slice(-6)} + + )} +
+ + +
+
+
+ Position Value + - Position Value - - - ${positionValueMillified} - - -
-
+ ${positionValueMillified} + + +
+
+ Net APR + - Net APR - - - {positionNetApy?.toFixed(2) ?? '0.00'}% - - -
- - {/*
+ {positionNetApy?.toFixed(2) ?? '0.00'}% + + +
+ + {/*
Annual yield @@ -653,32 +663,31 @@ export default function Loop({ TODO
*/} -
- -
- -
- - 0 || - (!!currentPositionLeverageRatio && - Math.round(currentPositionLeverageRatio) !== - currentLeverage) - ? projectedHealthRatio - : undefined - } - />
-
- -
- + +
+ + 0 || + (!!currentPositionLeverageRatio && + Math.round(currentPositionLeverageRatio) !== currentLeverage) + ? projectedHealthRatio + : undefined + } + /> +
+ +
+ +
+ - -
- -
- - + +
+ +
+ + -
- -
+ aprText={'Borrow APR'} + isLoading={isFetchingPositionInfo} + nativeAmount={borrowedAssetAmount.toFixed( + selectedBorrowAsset?.underlyingDecimals ?? 18 + )} + symbol={selectedBorrowAsset?.underlyingSymbol ?? ''} + title={'My Borrow'} + usdAmount={millify( + borrowedAssetAmount * selectedBorrowAssetUSDPrice + )} + /> +
+ +
+ + {currentPosition && ( + <> +
+ + +
+ +
+ + +
- {currentPosition && ( +
+ + )} + +
+ + +
+ +
+ + +
+ +
+ <> -
- - -
- -
- - -
- -
- - )} - -
- - -
- -
- - -
- -
- - <> - {transactionSteps.length > 0 ? ( -
- -
- ) : ( - <> - {currentPosition ? ( -
- - - -
- ) : ( + {transactionSteps.length > 0 ? ( +
+ +
+ ) : ( + <> + {currentPosition ? ( +
- )} - - )} - - -
- - - )} + + +
+ ) : ( + + )} + + )} + + +
+ +
); } diff --git a/packages/ui/app/dashboard/page.tsx b/packages/ui/app/dashboard/page.tsx index 8f2cc8428..a392100bb 100644 --- a/packages/ui/app/dashboard/page.tsx +++ b/packages/ui/app/dashboard/page.tsx @@ -174,7 +174,7 @@ export default function Dashboard() { ); const [selectedLoopBorrowData, setSelectedLoopBorrowData] = useState(); - const [loopOpen, setLoopOpen] = useState(false); + const [isLoopDialogOpen, setIsLoopDialogOpen] = useState(false); const { data: healthData, isLoading: isLoadingHealthData } = useHealthFactor( marketData?.comptroller, +chain @@ -720,7 +720,7 @@ export default function Dashboard() { usdPrice={usdPrice ?? undefined} setSelectedLoopBorrowData={setSelectedLoopBorrowData} setSelectedSymbol={setSelectedSymbol} - setLoopOpen={setLoopOpen} + setLoopOpen={setIsLoopDialogOpen} chain={+chain} /> ); @@ -739,12 +739,10 @@ export default function Dashboard() { {selectedMarketData && ( { - setLoopOpen(false); - }} + isOpen={isLoopDialogOpen} + setIsOpen={setIsLoopDialogOpen} comptrollerAddress={marketData?.comptroller ?? ('' as Address)} currentBorrowAsset={selectedLoopBorrowData} - isOpen={loopOpen} selectedCollateralAsset={selectedMarketData} /> )} diff --git a/packages/ui/app/market/page.tsx b/packages/ui/app/market/page.tsx index 37a15407b..79eb7cc12 100644 --- a/packages/ui/app/market/page.tsx +++ b/packages/ui/app/market/page.tsx @@ -293,7 +293,7 @@ export default function Market() { {loopProps && ( setIsLoopDialogOpen(false)} + setIsOpen={setIsLoopDialogOpen} isOpen={isLoopDialogOpen} /> )}