Stochastic.Finance Docs

Last updated 12 September 2026

Trading options

Each option leg has its own pool, paired against USDC. Buying an option means swapping USDC into that pool; selling means swapping the option token back out. The dApp page is /swaps.

How a quote is built

The AMM is a constant-product market maker, the same curve as Uniswap V2, with one addition: the fee is not fixed.

On every swap the router computes two prices:

  • the pool price, implied by the current reserves
  • the model price, from the closed-form pricing formula, using the live Chainlink price of the underlying, the strike, and the time left to expiry

The gap between them sets the fee. Trading a pool that sits close to fair value costs the 2% floor. Trading one that has drifted far away costs more, up to a 100% cap. This is what protects liquidity providers on an asset whose fair value moves continuously — see Dynamic swap fee for the curve and the reasoning.

swaps quote panel with the fee line expanded

The fee is always charged in USDC

Whichever direction you trade, the fee is taken on the USDC side, because that is what liquidity providers want to be paid in. When you buy, it is added on top of the USDC you asked to spend. When you sell, it comes out of the USDC you receive.

Choosing what to trade

Trading starts from the list of existing pools, not from a set of parameters. A pool exists for a given option leg only if someone minted that option and seeded liquidity against it, so the tradeable universe at any moment is a small subset of the grid.

The pair selector on /swaps lists every available pair with its parameters and its liquidity, and searches on any of them — type an underlying, a strike or an expiry to filter. Pick on two criteria at once:

  • Fit — how close the option's strike, expiry and type are to the view you want to express.
  • Depth — whether the pool can absorb your size without moving the price against you.

A pool that fits perfectly but holds almost nothing is worse than a near-miss with depth. If neither exists, the market you want simply hasn't been made: mint the option and seed the pool yourself.

swaps pair selector open, showing available pairs with liquidity

Buying a leg

You spend USDC and receive option units.

  1. Select the pool from the pair list.
  2. Set the direction switch to Buy and enter the USDC amount.
  3. Review the quote: option units out, the effective fee, and the maximum USDC the transaction may spend.
  4. Approve USDC for the router if you haven't already, then confirm.

The maximum USDC figure matters. Because the fee depends on the pool's divergence at the moment of execution, and that can move between your signing and your transaction landing, the router takes an explicit cap:

swapStableOnTrade(
    amountStable,      // USDC you want to spend
    maxStableAllowed,  // hard cap on total USDC pulled, fee included
    amountStableMin,   // minimum option units you'll accept (slippage guard)
    tradeToken,        // SF Options address
    tokenId,           // the leg you're buying
    to,
    deadline
)

If the live fee would push the total past maxStableAllowed, the swap reverts with ROUTER: STABLE_AMOUNT_EXCEEDS_MAX and you keep your USDC. At the fee cap the total can reach roughly twice amountStable, so a cap of 2 × amountStable accepts any fee the curve can produce, and a tighter cap is a deliberate refusal to trade an over-divergent pool.

Selling a leg

You send option units and receive USDC.

swapTradeOnStable(
    amountTrade,     // option units to sell
    amountTradeMin,  // minimum USDC out (slippage guard)
    tradeToken,
    tokenId,
    to,
    deadline
)

Selling requires ERC-1155 operator approval for the router, which the dApp prompts for once per wallet.

Rules and rejections

Condition What happens
Past the maturity timestamp Reverts, ROUTER: INCORRECT_MATURITY. Trading stops when the option expires
Amount below one cent Reverts, ROUTER: AMOUNT_BELOW_PRECISION. All amounts are whole cents
Output worse than your minimum Reverts, ROUTER: INSUFFICIENT_OUTPUT_AMOUNT
Total cost above your cap Reverts, ROUTER: STABLE_AMOUNT_EXCEEDS_MAX
deadline passed Reverts, ROUTER: EXPIRED
No pool for that leg Nothing to trade against — someone must add liquidity first

Thin pools move a lot

A large order into a shallow pool moves the price against you and raises the fee, because the price you push the pool to is further from the model price.

Trading somewhere else

Option legs are standard ERC-1155 tokens. Nothing obliges you to use SF Swap: you can transfer a leg directly to a counterparty, or trade it on any venue that supports ERC-1155. SF Swap exists because a pool per leg is the only way to get continuous two-sided liquidity on a grid this large, not because the protocol requires it.

Next

© Stochastic Finance Protocol — All Rights Reserved