Docs / The house

The house and the queue line(09)

The house is the counterparty to every trade. It is a balance inside the program, not a fund anyone deposits into. It starts at zero and grows only from traders' losses and from donations.

The state

FieldMeaning
lp_cashUSDC the house can pay winners with right now
queue_tailthe total ever queued; it only goes up
queue_paidthe total of the queue ever paid; it only goes up and never passes queue_tail
claims_reservedcash set aside for paid claims that their owners have not collected yet

The queue line is the stretch between queue_paid and queue_tail. When the two are equal, the queue is empty.

Inflows

An inflow is a loss that arrives while the queue is open, or a donation. It pays the queue first:

[ Fig. 1 ] INFLOW OF x
pay              = min(x, queue_tail − queue_paid)
queue_paid      += pay
claims_reserved += pay
lp_cash         += x − pay

While the queue is open, lp_cash is always zero: any cash that comes in goes to the front of the line, so no new winner can be paid ahead of an earlier one.

Claims

When part of a win is queued, you receive a claim {start = queue_tail, end = queue_tail + amount}, and queue_tail moves up by the amount. The paid part of your claim is:

[ Fig. 2 ] CLAIM
paid = clamp(queue_paid − start, 0, end − start)

collect_claim() moves what has been paid and not yet collected into your available balance. A claim that is fully paid and collected is closed and its rent returned. The order is strict by construction: a later claim receives nothing until every earlier claim is whole.

An example

The house holds $0 and the queue is empty. Five traders close in this order.

THE QUEUE LINE, STEP BY STEP
Eventqueue_tailqueue_paidlp_cashClaims
A wins, net $50$50$0$0A [0, 50): $0 paid
B wins, net $30$80$0$0B [50, 80): $0 paid
C loses $40$80$40$0A $40 paid, B $0
D loses $20$80$60$0A $50 paid (whole), B $10
E loses $25$80$80$5B $30 paid (whole), queue empty

C, D and E pay no fee and mint paper on their whole loss, because the queue was open when they lost. E's last $5 is the first cash the house keeps.

Net house equity

[ Fig. 3 ] NET EQUITY
tracked_lp = lp_cash − (queue_tail − queue_paid)

It can be negative. That is the queue doing its job: the house owes more than it holds, and says so in public. The paper mint rate reads this number; see Paper and the mint curve.

Reserve cap

When the queue is empty and lp_cash is above $75,000 (reserveCap), anyone can call push_excess(). The excess leaves the house and is distributed 100 % to paper holders. The house keeps what it needs to pay winners and returns the rest to the people who built it.

Donations

donate(amount) sends USDC to the house as an inflow. It pays the queue first, then adds to lp_cash. It mints no paper. Live figures for all of the above are on the house page.