Skip to content

Commit

Permalink
order details: use remaining amount for insufficient balance calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sehyunc committed Sep 24, 2024
1 parent dec910b commit 6c00e41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/orders/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ export const columns: ColumnDef<ExtendedOrderMetadata>[] = [
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -108,7 +109,7 @@ export function DetailsContent({ order }: { order: OrderMetadata }) {
{isOpen && (
<InsufficientWarning
withDialog
amount={order.data.amount}
amount={remainingAmount}
baseMint={order.data.base_mint}
className="text-sm font-bold tracking-tighter lg:tracking-normal"
quoteMint={order.data.quote_mint}
Expand Down

0 comments on commit 6c00e41

Please sign in to comment.