Trading Dev AcademyFree quant education

Free lesson · On-chain markets

Minimum output and ordering risk

Open interactive lessonPractice calculationsExplore labs

Start with the idea

Between signing and inclusion, other trades can change the pool. Minimum-output protection limits the executed outcome but does not guarantee that your transaction succeeds.

Symbols, units & horizon
  • y_min: minimum acceptable output token units
  • y_quote: output quoted at a recorded state
  • s: allowed output reduction fraction
  • one attempted swap
  • integer rounding convention must be stated for an actual transaction

When and why to use this

Define a reproducible swap-protection policy and measure both successful fills and paid failures.

Between signing and inclusion, other trades can change the pool. Minimum-output protection limits the executed outcome but does not guarantee that your transaction succeeds.

A slippage setting is usually relative to a quoted output, not a promise that the market price will stay within that percentage. Exact semantics depend on router and token behavior.

Transaction ordering creates economic exposure, including adverse execution and failed inclusion. Study observable outcomes and protective execution constraints; a public transaction is not necessarily executed in the order a user first saw it.

ymin⁡=yquote(1−s)
Model assumptions, derivation and arithmetic

Minimum output and ordering risk

  1. Record quoted output and its block/state reference.
  2. Multiply by one minus tolerated output reduction.
  3. Compare actual output with this threshold, handling token-unit rounding conservatively.
Work it by hand

Quoted output 1,000 tokens and tolerance .005 gives minimum output 995. A later state producing 994 would fail under this modeled constraint.

Apply it in a strategy

  • Define a reproducible swap-protection policy and measure both successful fills and paid failures.
  • Record the input timestamp, executable quantity, currency and horizon. Reconcile the result with a cash-flow or state table.
  • Stress this failure condition: Loose output limits permit adverse fills; tight limits can raise failure costs. Neither solves all ordering or availability risks.

Research deliverable

Build and explain a minimum output and ordering risk worksheet. Define a reproducible swap-protection policy and measure both successful fills and paid failures.

Evidence boundary: Synthetic arithmetic and scenarios illustrate mechanics. They are not historical returns, a paper replication, or evidence of an executable edge. Research sources and their access limitations are recorded at the end of this module.

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

# Python 3.10+; standard library unless NumPy is imported below.
# Inputs and outputs use the units defined in this lesson. Synthetic teaching example.
def minimum_output(quoted,slippage):
    if quoted<0 or not 0<=slippage<1: raise ValueError("Invalid output constraint")
    return quoted*(1-slippage)

print(minimum_output(1000,.005))

Continue learning

On-Chain Markets: Data, Oracles and Execution — all lessons
  1. Raw token amounts and economic event types
  2. Transaction gas in a reporting currency
  3. Minimum output and ordering risk
  4. Time-weighted reference prices
  5. Stale oracle health versus executable collateral value
  6. Bridge fragmentation and capital lock-up
  7. Inclusion, finality and conditional loss scenarios
  8. A reproducible on-chain economics study

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations