Solvency and queue
How the protocol stays open for new coupons even when the LP is temporarily insolvent.
The protocol's LP can be temporarily insolvent. A FIFO payout queue and a parked-funds side bucket guarantee winners eventually get paid, in order, while keeping the protocol from blocking new coupons.
The model
Conceptually, the protocol has three separate accounting buckets:
treasury, the LP balance. Cannot go negative.sideBucket, pending-harvest funds parked here while the queue is non-empty.- Payout queue, a FIFO of unpaid winning coupons. Each entry:
(user, amount).
This is the Martingaler mechanism (whitepaper): instead of holding pre-funded LP that pays winners on demand, the protocol queues winners when reserves are short, and clears them as future losses replenish the LP.
What enters the queue and what doesn't
The queue holds only the profit portion of a winning coupon that exceeded the LP's available budget at settle time.
Loss/liq proceeds route to treasury (queue empty) or sideBucket (queue active). Wins pay direct from treasury when solvent, else queue. Harvest drains sideBucket into queued payouts.
Winning coupons
When a coupon settles at a profit:
- If the queue is empty and
treasury ≥ payout: pay the user immediately, debittreasury. - Otherwise: append
(user, payout)to the back of the queue.treasuryis unchanged.
Losing Coupons
When a coupon settles at a loss
- If the queue is empty: the LP-retained slice (loss minus 2% fee) credits
treasurydirectly. - If the queue is non-empty: the LP-retained slice is parked in
sideBucketinstead oftreasury. The $BET mint still fires on losses regardless; close-loss mints are gated by the queue (the Exchange skips the tokenomics call when proceeds went tosideBucket).
Harvest
A keeper periodically calls:
- Walk the queue head forward, paying out each entry
(user, amount)fromsideBucketif the funds are there. - If
sideBucketruns out before the queue is clear, stop. Future losses will refill it. - If the queue empties with
sideBucket > 0, the residual returns totreasuryas normal LP gain.
Harvest is permissionless; anyone can run it. The keeper does it on a schedule so users don't have to.