The order book
The market module is a limit-order book between any two tokens.
{ "type": "market", "op": { "kind": "place", "base": "GOLD", "quote": "TDIVI",
"side": "sell", "price": "100000000000000", "amount": "10000" } }
market/place {base, quote, side, price, amount}andmarket/cancel {order_id}.- Price is quote base units per 1 whole base token, scaled by 10^8. The example asks 0.01 TDIVI per GOLD,
so 100 GOLD (
10000) costs 1 TDIVI. An order worth less than one quote base unit is refused. - Escrow: your funds sit at
module:marketuntil the order fills or you cancel. - Matching happens when the order is placed, with price-time priority; a trade fills at the maker's price (the order already resting in the book).
- Ordering is deterministic: sorted by
(price, height, seq), whereseqis the order's sequence number.
Reading it
GET /v1/games/market?view=book&base=GOLD"e=TDIVI returns the book and ?view=trades&base="e= the
recent trades. These are plain GET requests that need no key.
The
marketmodule is specified inARCHITECTURE.mdsection 6 and implemented incrates/dg-market/src/market.rs.