Preview Fills
Simulate a fill before committing — see the exact contract count, collateral required, and price per contract without sending any transaction.
Why preview first?
For OptionBook orders, availableAmount on the order is the maker's collateral budget, not the number of contracts you receive. The actual contract count depends on the option type and its collateral formula. Without previewing, you cannot know what you are actually buying.
previewFillOrder() runs the exact formula the on-chain contract will use, so there are no surprises at fill time.
Collateral Formulas by Option Type
Vanilla PUT
1
(collateral × 1e8) / strike
10,000 USDC at $95k strike = 0.105 contracts
Inverse CALL
1
collateral / 1e12
1 WETH = 1 contract
SPREAD
2
(collateral × 1e8) / spreadWidth
10,000 USDC / $10k spread = 1 contract
BUTTERFLY
3
(collateral × 1e8) / maxSpread
Based on widest strike range
CONDOR
4
(collateral × 1e8) / maxSpread
Based on widest strike range
Why this matters for a PUT: A $95,000 strike PUT where the maker budgets 10,000 USDC:
(10,000 × 1e8) / 95,000 = ~0.105 contractsYou are buying 0.105 contracts, not 10,000
previewFillOrder()
Dry-run a fill. Safe to call without a signer — no chain state is modified.
Parameters
orderWithSig
OrderWithSignature
Order from client.api.fetchOrders()
usdcAmount
bigint?
Collateral to spend (6 decimals). Omit to preview a max fill
referrer
string?
Referrer address. Falls back to client-level referrer or zero address
Return value
Full preview-to-fill pattern
Checking order expiry before preview
On-chain pre-flight (callStatic)
previewFillOrder() runs the math locally. If you also want to confirm the contract itself would not revert under current state (allowance, nonce reuse, order cancellation, transient reverts) without paying gas, use the callStatic helpers — they execute the call against the node and return the would-be result or the revert reason.
Both methods return a CallStaticResult ({ ok: true, value } or { ok: false, error }). Useful inside form UIs to disable the submit button when the chain says the call would fail.
See Also
Last updated

