From 6c00e41b0f53a6abee34c4fcb9cc51f0d7ec7b3a Mon Sep 17 00:00:00 2001 From: sehyunc <41171808+sehyunc@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:40:57 -0700 Subject: [PATCH] order details: use remaining amount for insufficient balance calculation --- app/orders/columns.tsx | 5 ++++- .../[base]/components/order-details/details-content.tsx | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/orders/columns.tsx b/app/orders/columns.tsx index 703dc9f6..e2b3d8f1 100644 --- a/app/orders/columns.tsx +++ b/app/orders/columns.tsx @@ -60,8 +60,11 @@ export const columns: ColumnDef[] = [ id: "notification", header: () => null, cell: function Cell({ row }) { + const remainingAmount = + row.original.data.amount - + row.original.fills.reduce((acc, fill) => acc + fill.amount, BigInt(0)) const { isInsufficient } = useCheckInsufficientBalancesForOrder({ - amount: row.original.data.amount, + amount: remainingAmount, baseMint: row.original.data.base_mint, quoteMint: row.original.data.quote_mint, side: row.original.data.side === "Buy" ? Side.BUY : Side.SELL, diff --git a/app/trade/[base]/components/order-details/details-content.tsx b/app/trade/[base]/components/order-details/details-content.tsx index 270bc9e8..3cd18903 100644 --- a/app/trade/[base]/components/order-details/details-content.tsx +++ b/app/trade/[base]/components/order-details/details-content.tsx @@ -47,6 +47,7 @@ export function DetailsContent({ order }: { order: OrderMetadata }) { Number(filledAmount), Number(order.data.amount), ) + const remainingAmount = order.data.amount - filledAmount const formattedTotalAmount = formatNumber( order.data.amount, @@ -108,7 +109,7 @@ export function DetailsContent({ order }: { order: OrderMetadata }) { {isOpen && (