Skip to content

Commit

Permalink
fix(perp): calculate total unrealized pnl correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
bearpong committed Sep 18, 2024
1 parent b54aeaf commit f365f3f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/perp/src/app/components/total-amount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export function TotalAmount({
const { marketPrices } = usePollPrices();
const unrealizedPnl = useMemo(() => {
const pnl = calculateUnrealizedPnl(openPositions, marketPrices);
return pnl ? BigNumber(pnl) : formatFromBaseUnit(totalUnrealizedPnl, 18);
return BigNumber(pnl ?? totalUnrealizedPnl);
}, [openPositions, marketPrices, totalUnrealizedPnl]);
const { useAccountTradingSummary } = usePollAccountTradingSummary();
const { data } = useAccountTradingSummary();
const realizedPnl = data?.pnl ?? "0";
const { data: accountTradingSummary } = useAccountTradingSummary();
const realizedPnl = accountTradingSummary?.pnl ?? "0";
const totalPnlBN = unrealizedPnl.plus(realizedPnl);

const totalRelativePnL = () => {
Expand Down

0 comments on commit f365f3f

Please sign in to comment.