shadowpaperDocsTrade ↗
Open AppTrade ↗
Under the hood

Payout & queue

When the LP cannot pay a win in full, the unpaid profit waits in a first-in, first-out queue that later losses repay in order.

Accounting#

The Exchange assigns every USDT it holds to a named bucket: user balances, locked margin, queued payouts, accrued fees and the LP. The LP figure can be negative. The protocol is designed to be temporarily insolvent in aggregate while paying winners strictly in order.

Paying a winner#

When a profitable position closes:

  • Queue empty: the profit is paid from free LP cash; any unpaid remainder joins the back of the queue.
  • Queue not empty: the whole profit joins the back of the queue.

Margin is returned to the trading balance immediately in every case.

Refilling#

While the queue is active, losses and liquidations are earmarked for queued winners, and the 2% LP-side fee is waived. The public harvest function pays the queue from the front, in order, and partially pays the front entry if cash runs out. A keeper calls it whenever a queue and payable cash both exist; any account may also call it.

Example#

The LP holds 30 USDT of free cash and the queue is empty. Alice closes a win with a net profit of 86.38 USDT. Bob then closes a 60 USDT loss.

EventRuleResult
Alice closes; profit 86.38, margin 100Queue empty: pay from free cash, queue the rest30.00 paid, 56.38 queued; 100 margin returned at once
Bob loses 60Queue active: loss earmarked, no LP-side fee60.00 earmarked for the queue
harvest runsPay the queue front firstAlice receives 56.38; queue empty
RemainderUnused earmarked cash stays in the LP3.62 added to LP cash
paid now  = min(86.38, 30)       = 30.00
queued    = 86.38 − 30.00        = 56.38
harvest   = min(60, 56.38)       = 56.38   → Alice fully paid
to LP     = 60 − 56.38           = 3.62
Bob's fee = 0                    (queue active)

← Scroll sideways for long formulas

A queued winner is paid in full before any later winner, and before any LP surplus reaches stakers.

Housekeeping#

Public functions remove empty entries and merge dust entries so that payouts are not blocked.

Dividends wait#

LP surplus is not distributed to stakers while any winner is queued. Fee dividends are unaffected.

Queued balance as margin#

A trader can open a position funded by their own queued balance; up to 50 queue entries are scanned. If the position wins, the new claim joins the back of the queue. If it loses, the corresponding queued amount is cancelled. If it is liquidated, the amount is forfeited without a fee.