diff --git a/apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongsTable/ManageLongsButton.tsx b/apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongsTable/ManageLongsButton.tsx new file mode 100644 index 000000000..9fb17337f --- /dev/null +++ b/apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongsTable/ManageLongsButton.tsx @@ -0,0 +1,58 @@ +import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig"; +import { Cog8ToothIcon } from "@heroicons/react/20/solid"; +import { Link } from "@tanstack/react-router"; +import { ReactElement, useRef, useState } from "react"; +import { useClickAway } from "react-use"; +import { MARKET_DETAILS_ROUTE } from "src/ui/markets/routes"; + +export function ManageLongsButton({ + hyperdrive, + assetId, +}: { + hyperdrive: HyperdriveConfig; + assetId: bigint; +}): ReactElement { + const [isOpen, setIsOpen] = useState(false); + const dropdownRef = useRef(null); + useClickAway(dropdownRef, () => setIsOpen(false)); + return ( +
+ + {isOpen && ( + + )} +
+ ); +} diff --git a/apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongsTable/OpenLongsTableDesktopTwo.tsx b/apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongsTable/OpenLongsTableDesktop.tsx similarity index 94% rename from apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongsTable/OpenLongsTableDesktopTwo.tsx rename to apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongsTable/OpenLongsTableDesktop.tsx index 5beb62d5a..49bd88650 100644 --- a/apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongsTable/OpenLongsTableDesktopTwo.tsx +++ b/apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongsTable/OpenLongsTableDesktop.tsx @@ -9,7 +9,6 @@ import { calculateAprFromPrice, OpenLongPositionReceived, } from "@delvtech/hyperdrive-viem"; -import { Cog8ToothIcon } from "@heroicons/react/20/solid"; import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline"; import { Link } from "@tanstack/react-router"; import { @@ -37,6 +36,7 @@ import { StatusCell } from "src/ui/hyperdrive/longs/OpenLongsTable/StatusCell"; import { TotalOpenLongsValue } from "src/ui/hyperdrive/longs/OpenLongsTable/TotalOpenLongsValue"; import { usePortfolioLongsData } from "src/ui/portfolio/usePortfolioLongsData"; import { useAccount } from "wagmi"; +import { ManageLongsButton } from "./ManageLongsButton"; export function OpenLongsContainer(): ReactElement { const { address: account } = useAccount(); @@ -99,7 +99,7 @@ export function OpenLongsContainer(): ReactElement { const openLongs = openLongPositions?.find( (position) => position.hyperdrive.address === hyperdrive.address && - position.hyperdrive.chainId === hyperdrive.chainId, + position.hyperdrive.chainId === hyperdrive.chainId )?.openLongs; const baseToken = findBaseToken({ hyperdriveChainId: hyperdrive.chainId, @@ -142,7 +142,7 @@ export function OpenLongsContainer(): ReactElement { - @@ -153,7 +153,7 @@ export function OpenLongsContainer(): ReactElement { ); } -export function OpenLongsTableDesktopTwo({ +export function OpenLongsTableDesktop({ hyperdrive, openLongs, }: { @@ -217,7 +217,7 @@ export function OpenLongsTableDesktopTwo({
{flexRender( header.column.columnDef.header, - header.getContext(), + header.getContext() )} {{ asc: , @@ -248,7 +248,7 @@ export function OpenLongsTableDesktopTwo({ "left-0 right-0": headerIndex !== 0 && headerIndex !== headerGroup.headers.length - 1, // Full-width border for other header cells - }, + } )} /> @@ -274,7 +274,7 @@ export function OpenLongsTableDesktopTwo({ "rounded-br-box": isLastRow && cellIndex === row.getVisibleCells().length - 1, - }, + } )} key={cell.id} > @@ -291,7 +291,7 @@ export function OpenLongsTableDesktopTwo({ "left-0 right-0": cellIndex !== 0 && cellIndex !== row.getVisibleCells().length - 1, // Full width border for other cells - }, + } )} /> )} @@ -365,14 +365,14 @@ function getColumns({ amountBefore: rowA.original.details?.baseAmountPaid || 0n, amountAfter: rowA.original.details?.bondAmount || 0n, days: convertMillisecondsToDays( - Number(hyperdrive.poolConfig.positionDuration * 1000n), + Number(hyperdrive.poolConfig.positionDuration * 1000n) ), }); const bFixedRate = calculateAnnualizedPercentageChange({ amountBefore: rowB.original.details?.baseAmountPaid || 0n, amountAfter: rowB.original.details?.bondAmount || 0n, days: convertMillisecondsToDays( - Number(hyperdrive.poolConfig.positionDuration * 1000n), + Number(hyperdrive.poolConfig.positionDuration * 1000n) ), }); return aFixedRate - bFixedRate; @@ -412,20 +412,11 @@ function getColumns({ id: "go-to-market", cell: ({ row }) => { return ( -
- -
+ ); }, }), diff --git a/apps/hyperdrive-trading/src/ui/hyperdrive/lp/LpAndWithdrawalSharesTable/LpAndWithdrawalSharesTable.tsx b/apps/hyperdrive-trading/src/ui/hyperdrive/lp/LpAndWithdrawalSharesTable/LpAndWithdrawalSharesTable.tsx index 9197eb044..0d2dd656e 100644 --- a/apps/hyperdrive-trading/src/ui/hyperdrive/lp/LpAndWithdrawalSharesTable/LpAndWithdrawalSharesTable.tsx +++ b/apps/hyperdrive-trading/src/ui/hyperdrive/lp/LpAndWithdrawalSharesTable/LpAndWithdrawalSharesTable.tsx @@ -17,13 +17,13 @@ import { convertMillisecondsToDays } from "src/base/convertMillisecondsToDays"; import LoadingState from "src/ui/base/components/LoadingState"; import { NonIdealState } from "src/ui/base/components/NonIdealState"; import { ConnectWalletButton } from "src/ui/compliance/ConnectWallet"; +import { LpCurrentValueCell } from "src/ui/hyperdrive/lp/LpAndWithdrawalSharesTable/LpCurrentValueCell"; +import { ManageLpAndWithdrawalSharesButton } from "src/ui/hyperdrive/lp/LpAndWithdrawalSharesTable/ManageLpAndWithdrawalSharesButton"; +import { SizeAndPoolShareCell } from "src/ui/hyperdrive/lp/LpAndWithdrawalSharesTable/SizeAndPoolShareCell"; +import { WithdrawalQueueCell } from "src/ui/hyperdrive/lp/LpAndWithdrawalSharesTable/WithdrawalQueueCell"; import { AssetStack } from "src/ui/markets/AssetStack"; import { usePortfolioLpData } from "src/ui/portfolio/usePortfolioLpData"; import { useAccount } from "wagmi"; -import { LpCurrentValueCell } from "./LpCurrentValueCell"; -import { ManageLpAndWithdrawalSharesButton } from "./ManageLpAndWithdrawalSharesButton"; -import { SizeAndPoolShareCell } from "./SizeAndPoolShareCell"; -import { WithdrawalQueueCell } from "./WithdrawalQueueCell"; export function LpAndWithdrawalSharesContainer(): ReactElement { const { openLpPositions, openLpPositionStatus } = usePortfolioLpData(); @@ -61,7 +61,7 @@ export function LpAndWithdrawalSharesContainer(): ReactElement { } const hasOpenPositions = openLpPositions?.some( - (position) => position.lpShares > 0n || position.withdrawalShares > 0n, + (position) => position.lpShares > 0n || position.withdrawalShares > 0n ); if (!hasOpenPositions) { @@ -99,7 +99,7 @@ export function LpAndWithdrawalSharesContainer(): ReactElement { const openLpPosition = openLpPositions?.find( (position) => position.hyperdrive.address === hyperdrive.address && - position.hyperdrive.chainId === hyperdrive.chainId, + position.hyperdrive.chainId === hyperdrive.chainId ) ?? { lpShares: 0n, withdrawalShares: 0n, @@ -154,7 +154,7 @@ export function OpenLpTableDesktop({ const columns = useMemo( () => getColumns({ hyperdrive, appConfig }), - [hyperdrive, appConfig], + [hyperdrive, appConfig] ); const data = useMemo(() => [openLpPosition], [openLpPosition]); const tableInstance = useReactTable({ @@ -195,7 +195,7 @@ export function OpenLpTableDesktop({
{flexRender( header.column.columnDef.header, - header.getContext(), + header.getContext() )}
{/* Custom border with inset for the first and last header cells */} @@ -221,7 +221,7 @@ export function OpenLpTableDesktop({ "left-0 right-0": headerIndex !== 0 && headerIndex !== headerGroup.headers.length - 1, // Full-width border for other header cells - }, + } )} /> @@ -289,7 +289,7 @@ function getColumns({ cell: () => (
{convertMillisecondsToDays( - Number(hyperdrive.poolConfig.positionDuration * 1000n), + Number(hyperdrive.poolConfig.positionDuration * 1000n) )} {"-"}Day
diff --git a/apps/hyperdrive-trading/src/ui/portfolio/Portfolio.tsx b/apps/hyperdrive-trading/src/ui/portfolio/Portfolio.tsx index ab357a801..f297546ed 100644 --- a/apps/hyperdrive-trading/src/ui/portfolio/Portfolio.tsx +++ b/apps/hyperdrive-trading/src/ui/portfolio/Portfolio.tsx @@ -1,10 +1,10 @@ import { useNavigate, useSearch } from "@tanstack/react-router"; import { ReactElement } from "react"; import { TabsTwo } from "src/ui/base/components/Tabs/TabsTwo"; -import { OpenLongsContainer } from "src/ui/hyperdrive/longs/OpenLongsTable/OpenLongsTableDesktopTwo"; +import { OpenLongsContainer } from "src/ui/hyperdrive/longs/OpenLongsTable/OpenLongsTableDesktop"; import { LpAndWithdrawalSharesContainer } from "src/ui/hyperdrive/lp/LpAndWithdrawalSharesTable/LpAndWithdrawalSharesTable"; import { OpenShortsContainer } from "src/ui/hyperdrive/shorts/OpenShortsTable/OpenShortsTableDesktopTwo"; -import { PORTFOLIO_ROUTE } from "./routes"; +import { PORTFOLIO_ROUTE } from "src/ui/portfolio/routes"; export function Portfolio(): ReactElement { const { position } = useSearch({ from: PORTFOLIO_ROUTE });