Skip to main content

Module trading

Module trading 

Source
Expand description

Peer-to-peer trading and AMM constant-product pool.

Implements the exchange surface documented in Melvin Carvalho’s Practical Guide to Solid, parts 8–9: https://melvin.me/public/solid/

  • Order book (/pay/.sell, /pay/.offers, /pay/.swap): sellers post sell orders specifying amount, currency pair, and price; buyers execute atomic swaps against the order book.
  • AMM pool (/pay/.pool): constant-product x * y = k liquidity pool with configurable fee (default 30 bps / 0.3%).

All balance mutations delegate to WebLedger — this module never owns or persists balances directly. Integer-only arithmetic with u128 intermediates prevents overflow on multiply-before-divide.

Structs§

AmmPool
AMM constant-product liquidity pool (x * y = k).
Exchange
Combined exchange state: order book + AMM pool registry.
OrderBook
Order book for peer-to-peer trades.
SellOrder
A sell order on the order book.
SwapResult
Result of executing a trade (either order-book or AMM).