diff options
| author | Kostya <mail@sartin.in> | 2026-09-07 16:03:14 +0300 |
|---|---|---|
| committer | Kostya <mail@sartin.in> | 2026-09-07 16:03:14 +0300 |
| commit | 8d7cecd9cf9fb2b0b45607b8efd7ca8f19a89fc6 (patch) | |
| tree | d88cfe032a7e8f632077ab439cfd0618c1e1421f /api/src/main | |
| parent | 1cf436ccd3efd45d67749102363b9a7f0d242c54 (diff) | |
| download | guess-market-8d7cecd9cf9fb2b0b45607b8efd7ca8f19a89fc6.tar.gz guess-market-8d7cecd9cf9fb2b0b45607b8efd7ca8f19a89fc6.tar.xz guess-market-8d7cecd9cf9fb2b0b45607b8efd7ca8f19a89fc6.zip | |
service: add sell orders, event lifecycle and order book matching
Carry the order side from the context through risk, the trading
mechanisms, fulfillment and settlement, so users can sell shares as
well as buy them.
The order book now matches priced limit orders from named users, rests
any unfilled remainder, and prevents self-trades. In a binary market
with minting enabled, a buy can also match a bid on the other option
to mint a new YES/NO pair, and a sell can match an ask there to merge
a pair back into the pool. LMSR gains a sell that refunds the cost
difference from the pool.
Add createEvent and openEvent to the catalog. Events start as DRAFT and
only take the market maker's subsidy when they are opened, which fails
if the market maker can't cover it. Add LocalAccountContext to expose
user ledgers.
Tighten the risk checks: reject orders from blocked accounts, on events
that aren't ACTIVE, and at prices outside (0, d). Sells need enough
unreserved shares; buys need enough balance to cover commission and
cash already committed to resting bids.
Settlement now cancels resting orders, pays out on shares still held
rather than shares ever bought, sends order book commission to the
market maker, and returns unused LMSR subsidy. Events also track
per-user cash flow, so the event detail can list participants with
their holdings, fees and P&L next to the order books.
Diffstat (limited to 'api/src/main')
0 files changed, 0 insertions, 0 deletions