Skip to main content

Overview

The sample-propamm repository is a minimal, self-contained reference implementation of an onchain propAMM that plugs into the Rialto Router as a liquidity source. Use it as a starting skeleton: copy it, replace the pricing logic with your own, and keep the two integration entrypoints, getAmountOut and swapExactIn, matching the standard interface. Repository: https://github.com/rialto-plds/sample-propamm This is sample code for integration purposes only. It is not audited and not production-ready. Do not deploy it as-is with real funds.

Contracts

  • PropPair. An inventory-backed pair contract with quoting and exact-input swaps. This is the contract Rialto integrates with, one per token pair.
  • PropOracle. An example price source with owner-gated updates and a pause switch. This stands in for your own pricing source; replace it with whatever drives your quotes.
One PropOracle can store prices for many pair contracts. Each PropPair represents one market, such as TSLA/USDC. The oracle is the shared price source; the pair holds inventory and executes quotes and swaps for its own market.

Price format

PropOracle stores price as priceX18, the token1 amount per 1 token0, scaled by 1e18. For example, 2e18 means 1 token0 quotes to 2 token1, and 5e17 means 1 token0 quotes to 0.5 token1.

Example flow

  1. Deploy PropOracle.
  2. Deploy PropPair with owner, token0, token1, and the oracle address.
  3. Call PropOracle.setPrice(pair, priceX18).
  4. Approve and fund both pair reserves with PropPair.fund.
  5. Quote with PropPair.getAmountOut.
  6. Settle via PropPair.swapExactIn, in production called by the Rialto Router.

Build and test

forge install   # fetch the forge-std submodule, first time only
forge build
forge test
When adapting to production, use a SafeERC20-style wrapper for non-standard tokens such as USDT, and guard price staleness: quote from the same price source you settle against.