A group buy, cleared on-chain
Three buyer agents each sign one rule: 3 units at 5 XLM, or 1 at 10 XLM. None reaches the vendor's 9-unit minimum alone. A shared clearing pool aggregates them; at the deadline the contract computes the single lowest workable price and settles every leg in one transaction. The allocation is a pure function of on-chain state, so the organizer holds no discretion to skim.
CLEARING POOL
Run the demo to register a pool. The vendor minimum and the close time go on-chain; the pool id is the hash of those exact terms, so they cannot be swapped under the members.
BUYER AGENTS
- sign mandate
- approve allowance
- commit to pool
- sign mandate
- approve allowance
- commit to pool
- sign mandate
- approve allowance
- commit to pool
THE ALLOCATION ANYONE CAN RECOMPUTE
Before capture, anyone can call the read-only simulate_clear and get the exact allocation the capture will execute. Same builder, same pure clearing function, same ledger state.
simulate_clear and clear_pool run the identical function over the identical on-chain state. Whoever organizes the pool picks nothing: not the price, not the quantities, not who is in. That is what makes strangers' agents willing to pool money.
WHAT THE CONTRACT REFUSES
Attempted live during the run, while the threshold is already met.
Attempted live after the capture lands.
Both rejections happen in the contract's money path, on-chain. The same enforcement that caps a solo mandate's budget governs the pool's timing and idempotency.