THE HOUSE AND THE QUEUE LINE
//01_ THE HOUSE
The house is the counterparty to every position. No one seeds it and there are no outside liquidity providers: it starts at zero and is built from what traders lose, plus anything donated to it. Its cash is a single number in the contract, lpCash.
- Losses and liquidations add to it (minus the fee when the queue is empty).
- Wins are paid from it, together with their fee.
- Above $75,000, with nobody waiting, the excess is paid out to paper holders.
A house that starts at zero cannot pay the first winners before anyone has lost. Paperhands does not pretend otherwise: those winners are queued and paid in order. That is the queue line.
//02_ THE QUEUE LINE
When a win cannot be paid in full, the unpaid part becomes a claim: a range on a single cumulative line. Two counters describe the whole line, and both only ever go up:
- //QUEUE TAIL_
queueTail: total ever queued- //QUEUE PAID_
queuePaid: total ever paid into the line
enqueue(amount): claim = [queueTail, queueTail + amount)
queueTail += amount
inflow(x): pay = min(x, queueTail - queuePaid)
queuePaid += pay
lpCash += x - pay
paid(claim) = clamp(queuePaid - start, 0, end - start)An inflow is a loss or a liquidation made while the queue is open, or a donation. It pays the line first and only the remainder reaches the house's cash. Because queuePaid advances from the front, a claim receives nothing until every claim queued before it is whole. Strict first in, first out, with no loop over the claims and no keeper involved.
While anyone is waiting, lpCash is always zero: every inflow goes to the line before it can reach the cash. So a new winner can never be paid ahead of an earlier one. A win settled while the queue is open is queued in full, behind the others.
//03_ A WORKED LINE
A new house with no cash. Two traders win, then losses arrive. All amounts in USDG.
| EVENT | QUEUE TAIL | QUEUE PAID | LP CASH | A PAID | B PAID | NET EQUITY |
|---|---|---|---|---|---|---|
| A wins, $300 net, queued [0, 300) | 300 | 0 | 0 | 0 | -300 | |
| B wins, $200 net, queued [300, 500) | 500 | 0 | 0 | 0 | 0 | -500 |
| A loss of $250 (no fee, queue open) | 500 | 250 | 0 | 250 | 0 | -250 |
| A donation of $100 | 500 | 350 | 0 | 300 | 50 | -150 |
| A $400 liquidation (no fee) | 500 | 500 | 250 | 300 | 200 | 250 |
After the liquidation the line is fully paid: queuePaid has caught up with queueTail, the queue is closed, and the $250 left over is the house's cash. From the next loss on, fees are charged again and wins are paid from cash.
//04_ COLLECTING
The paid part of a claim is set aside in the contract (claimsReserved) the moment the line reaches it. It belongs to the claim holder and nothing else can touch it. collectClaims() moves the paid but not yet collected part of each of your claims to your available balance. You can collect a partly paid claim and collect again later; a claim disappears once it is fully paid and collected.
Claims carry no interest and do not expire. They are tied to the wallet that won and cannot be transferred. The app shows each claim with its place in the line, the amount paid and the amount still owed.
//05_ NET HOUSE EQUITY
trackedLp = lpCash - (queueTail - queuePaid)
Net house equity is the cash minus what the line still owes. It can be negative, and at launch it will be: a negative value is the queue doing its job, not a failure. It is the number the paper mint curve reads (see paper).
//06_ DONATIONS
donate(amount) lets any address send USDG to the house. A donation is an inflow: it pays the queue line first, then adds to the cash. It mints no paper and earns nothing. It is the one way outside money can enter the house.
//07_ THE RESERVE CAP
The house does not grow without limit. When the queue is empty and lpCash is above $75,000, pushExcess() moves everything above $75,000 to paper holders, 100% of it. Anyone can call it; the keeper does about once an hour. The $75,000 cap is a constant of the contract. See rewards.
Credits: hands from Michelangelo, The Creation of Adam (detail), public domain, via Wikimedia Commons. Marks of the markets and integrations belong to their owners (sources, credits).