> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rialto.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Programmable Liquidity

> How onchain market making logic defends against toxic flow and quotes tighter than an order book.

## Liquidity is a function of adverse selection

The more toxic flow a market maker faces from sophisticated takers picking off
stale quotes during price moves, the wider their spreads must be and the less size
they can show. On a price-time priority order book this becomes a latency race:
when the reference price moves, makers must cancel stale quotes and repost before a
faster trader snipes them. The industry has spent enormous sums on fiber, microwave
networks, FPGAs, and colocation chasing that edge.

## Logic inside the exchange

A propAMM places the market making logic onchain, inside the exchange's execution
environment itself. The quote is no longer a static object posted in advance; it is
a function evaluated at the moment of the trade. Book construction, fees, inventory
management, and defensive controls all react within the same transaction as the
fill.

This makes in-block defense possible. After a fill, the program can deplete the
levels just hit, widen its offsets, or withhold depth before the next trade in the
same block executes. The book defends itself as flow arrives, rather than waiting
for the maker to observe the fill and resubmit from outside. The result is that
makers can quote tighter spreads and deeper books than they otherwise safely could.

## Built-in protection from toxic flow

Because the maker's logic is the matching logic, a propAMM has defenses no order
book can offer:

* Venue scoring. The program scores the routing path an order arrives through by
  the historical quality of its flow, showing clean retail routes the full book and
  giving adverse paths wider offsets or less depth.
* Priority-fee analysis. Since oracle updates and swaps compete in the same fee
  market, a taker paying aggressively to land ahead of the next update is more
  likely picking off a stale quote, and can be priced or filtered accordingly.
* Known counterparties. Operators can decline to quote for known snipers and toxic
  addresses.
* Freshness. As the oracle ages, the program widens spreads and withholds depth
  until the next update lands.
* Inventory. When reserves drift from target, the program skews quotes to attract
  rebalancing flow and penalizes trades that push inventory further out of line.

By competing on pricing models, inventory management, and defensive logic rather
than on latency and infrastructure spend, a small team can outcompete incumbents.
