Skip to content

    Press / to search, [ and ] for the previous and next page.

    How it actually works

    Solvency & queue

    The LP can be temporarily insolvent. A first-in, first-out payout queue and a side bucket of parked funds make sure winners are paid, in order, without ever blocking new trades.

    The model

    The Exchange keeps its LP accounting in a few buckets:

    • LP cash: the part of the Exchange’s USDC that nobody else is owed. Take everything it holds, subtract every account’s free balance, the margin locked in open positions and the accrued fees; what remains is LP cash. It cannot go negative. Builder fees not yet claimed stay inside LP cash as a debt of the LP: the tracked LP value already counts them as paid, and a builder’s claim is paid from LP cash, or queued when it cannot be.
    • Side bucket: loss proceeds that arrived while claims were queued, earmarked inside LP cash for the queue. Harvests drain it first.
    • Payout queue: a first-in, first-out list of unpaid wins, each an account and an amount.
    • Debt in positions: margin of open positions that was funded from queued claims.

    Instead of an LP funded in advance that pays winners on demand, the protocol queues winners when cash is short and pays them as later losses refill the LP. The number the token’s mint rate follows, the tracked LP, is tied to the buckets by an identity that every operation preserves:

    tracked LP = LP cash − queued claims − debt in positions
    

    It can be negative: that is the temporarily insolvent state the queue exists for.

    What enters the queue is only what the LP owes on a close but cannot pay at that moment: the payout after the win fee on a position funded from your balance, or the surviving claim on a position funded from the queue. Three things stay out:

    • Your margin on a position funded from your balance: it returns to your free balance at once, and you can withdraw or reuse it.
    • Fees ahead of queued winners: every winner pays the win fee, but it reaches stakers and the team only when the queue is empty and LP cash covers it too; otherwise it stays in the LP. Loss and liquidation fees are waived while anything is queued. A builder fee comes off with the win or loss fee and follows the same rules.
    • Losses while claims are queued: they are earmarked in the side bucket instead of becoming free LP cash. They still raise the tracked LP in full when they settle.
    Where each dollar goesLosses and liquidations credit LP cash, or the side bucket while claims are queued. Wins are paid from LP cash, or join the payout queue. Harvests move side-bucket cash to the front of the queue.Loss or liquidationWinning closequeue empty?cash enough?yesnoyesnoLP cashside bucketearmarked for the queuepaid to youpayout queueunbacked claimsharvesttracked LP = LP cash − queued claims − debt in positions
    Where each dollar goes. Losses and liquidations credit LP cash, or the side bucket while claims are queued. Wins are paid from LP cash, or join the payout queue. Harvests move side-bucket cash to the front of the queue.

    Winning closes

    The win fee of 2% comes off the payout whatever the LP’s state. Then:

    1. The queue is empty: you are paid from LP cash, up to the payout. The fee goes to stakers and the team only if LP cash covers it as well; otherwise it stays in the LP.
    2. Whatever LP cash could not pay, or the whole payout when claims are already queued, is appended to the back of the queue in your name. LP cash does not change for the queued part.

    A position funded from queued claims settles the same way, except that the LP owes its whole surviving claim: the margin plus the payout on a win, or the margin minus the loss on a losing close. The claim it used at open was collateral, not money you held.

    Losing closes & liquidations

    A position funded from your balance that closes at a loss or is liquidated:

    1. The queue is empty: the loss minus the fee (2% on a close, 2% of the margin on a liquidation) becomes LP cash.
    2. Claims are queued: the proceeds stay in the Exchange but go to the side bucket for queued winners, and no fee is charged. They still count toward the tracked LP when they settle, and TOKEN is still minted for them.

    A loss on a position funded from queued claims brings in no cash: the destroyed part of the claim simply stops being owed, so nothing reaches LP cash or the side bucket. On a losing close the surviving claim is paid or queued like a win, and the loss fee is charged only when the queue is empty and LP cash covers the claim plus the fee. A liquidation destroys the whole claim and charges no fee.

    Harvest

    A harvest pays queued claims from the front:

    1. Walk the queue from the head, paying each claim from the cash available to the queue; the last claim reached may be paid partly.
    2. Debit the side bucket first for what was paid. If the cash runs out before the queue is clear, stop; later losses fund later harvests.
    3. When the queue empties with something left in the side bucket, release the rest to ordinary LP cash. Neither the harvest nor the release changes the tracked LP: a queued claim was already counted against it.

    Harvesting is permissionless and the caller is not paid. One call pays at most 64 claims; our keeper calls it with 32 whenever there is cash to pay out, so nobody has to.

    If you already own the newest claim when another of your wins is queued, the two are merged into one claim; the order of payment does not change. An open funded from queued claims uses your newest claims first, walking back through at most 50 of them, and a claim emptied this way leaves a gap that harvests skip.

    Invariants

    • LP cash and the side bucket are unsigned, so neither can go negative.
    • The cash available for new payouts is zero whenever anything is queued, so a new winner can never be paid ahead of an earlier one.
    • The tracked LP equals LP cash minus queued claims minus debt in positions. It can go negative: that is temporary insolvency by design.
    • A staker distribution takes the stakers’ fees, which are always backed, plus any LP value above $10,000,000; that excess is paid from LP cash when nothing is queued, and queued in the staking contract’s name otherwise.

    The indexer checks these identities after every block and stops serving data if one fails.

    What the user sees

    Opening a position does not depend on the queue, apart from the usual open-interest caps and the limit on how many claims one open may use. A winning close either pays you at once or queues you, depending on the LP. The app shows an available balance (paid) and a queued balance (waiting for a harvest); both can fund new positions, because queued claims can serve as margin.

    Last updated: