Let’s start with a real case: the Hegic protocol lost $4.7 million due to an error in premium calculation—integer division in Solidity with wrong operation order resulted in zero option cost under certain parameters. Users obtained options for free. This is not a theoretical vulnerability—it happens when financial math is ported to EVM without thorough boundary testing.
Developing an options protocol on blockchain requires careful consideration of pricing model, liquidity management, and settlement mechanics. Each component is a separate risk vector, and we minimize them through a combination of proven approaches and deep testing. We work with leading L2s (Arbitrum, Optimism, Base) to reduce gas costs, and use a modern stack: Foundry for testing, Chainlink for oracles, OpenZeppelin for security. Our experience includes developing both classic European options and complex American ones with automatic settlement via Gelato.
If you plan to launch an options protocol, contact us for a consultation—let’s discuss the specification and architecture of your project.
What are the key architectural decisions?
Standard architecture includes a contract factory, liquidity pools, premium calculation module, and oracle adapter. An optimal structure for most projects:
OptionsFactory
├── OptionsPool (per asset, per expiry)
│ ├── PricingEngine (Black-Scholes smart contract implementation)
│ ├── CollateralVault (locked LP funds)
│ └── SettlementModule
├── OracleAdapter (Chainlink + TWAP fallback)
└── FeeCollector
OptionsFactory deploys a new OptionsPool for each asset/expiry pair or manages a single pool with a mapping by series. A single pool with mapping is easier to audit but creates cross-series risk. OracleAdapter is a wrapper with a circuit breaker: if Chainlink staleness > 1 hour or deviation > 10% from TWAP, trading is paused.
How complex is on-chain options pricing?
On-chain options require simultaneously a pricing model, liquidity management, settlement mechanics, and protection from manipulation. Unlike simple AMMs or lending pools, options have a time factor, Greeks, and pool risk management. Losses from hacks on options protocols exceed $100 million total.
Black-Scholes requires implied volatility (IV). On blockchain, there are two options: hardcode IV (simple but inaccurate) or get it from an oracle (complex but honest). Dopex uses Chainlink for IV. Lyra Protocol implemented its own off-chain volatility with on-chain verification via SNX staking. Hegic v888 fixed IV per asset, updated by governance.
For a production protocol, we use a two-level approach: Chainlink price feed for spot price + rolling standard deviation of price over 30 days as a proxy for historical volatility. This approach reduces manipulation risk by 3x compared to a pure TWAP solution.
Premium formula in Solidity requires fixed-point arithmetic. The ABDKMath64x64 library provides 64.64-bit precision sufficient for options math. Pure uint256 with 1e18 scaling works but needs careful overflow control—we use mulDiv from OpenZeppelin instead of direct operations. Our gas optimization options can reduce costs by up to 20%.
Settlement Types: European vs American
| Parameter | European Style | American Style (with keeper) |
|---|---|---|
| Exercise | Only at expiry | Any time before expiry |
| Implementation complexity | Low | High (American options keeper required) |
| Spot manipulation risk | High (TWAP attack) | Lower (early exercise) |
| Cross-series risk | None | Possible |
| Typical protocols | Hegic, Dopex (SSOV) | Lyra, Opyn |
European style is simpler: settlement in one transaction—compare spot price at expiry with strike, pay the difference. Problem: spot price at expiry is manipulable. A $10M flash loan doesn’t move Chainlink spot due to aggregation with delay, but TWAP from an AMM pool is vulnerable. American style is significantly more complex—a keeper mechanism (Gelato or Chainlink Automation) is needed for automatic exercise of ITM options.
Liquidity Models
Peer-to-pool: one liquidity pool covers all sold options. LP providers earn fees but bear loss risk during strong market moves (Hegic and Dopex model). Peer-to-peer orderbook: sellers individually set prices and lock collateral, buyers match with sellers (Opyn model). Liquidity is lower but there is no systemic pool risk.
For peer-to-pool, calculating collateral requirements is critical. Call options are covered by the base asset (or cash-equivalent). Put options—stablecoin at strike * amount. Undercollateralization is an attack vector via fast price movement and liquidation delay, which has led to losses exceeding $10 million.
Protocol Comparison
| Protocol | Pricing | Settlement | Liquidity |
|---|---|---|---|
| Hegic | Fixed IV | European | Peer-to-pool |
| Dopex | Chainlink IV | European (SSOV) | Peer-to-pool |
| Lyra | Off-chain IV + on-chain verification | European + MM | Peer-to-pool with MM |
| Opyn | Depends on seller | American | Peer-to-peer orderbook |
Greeks and Risk Management
Full on-chain delta/gamma hedging is economically infeasible at current gas costs. Lyra v2 uses off-chain market maker with on-chain settlement: the MM manages Greeks off-chain, periodically syncing position with the pool. Dopex introduced SSOV (Single Staking Option Vaults)—fixed strikes and expiry epochs, simplifying liquidity management.
For our protocol: open interest (OI) limit per strike and expiry via parameters maxCallsOI and maxPutsOI. Typical limit—500 ETH per strike (roughly $1.5 million at current prices).
Testing & Security
Foundry runs tests 10x faster than Truffle, which is critical for fuzz testing with thousands of cases. Fuzz tests cover:
- Premium never equals zero for non-zero size
- Settlement amount never exceeds locked collateral
- Impossible to exercise expired option
- Oracle price staleness correctly detected
Fork tests on mainnet: buy an option, manipulate Uniswap TWAP via large swap, try to exercise at manipulated price—protocol must either use Chainlink or revert. Mandatory external audit (Trail of Bits, Spearbit)—options protocols are in the top 5 by loss amount in DeFi hacks. Audit costs typically range from $50,000 to $150,000.
Process Overview
- Specification (3-5 days). Option type, liquidity style, supported assets, expiry mechanics, governance.
- Design (1 week). Storage layout, interfaces, pricing math verified with Python reference.
- Development (4-6 weeks). Contracts + tests (unit, fuzz, fork). Separate pricing engine module upgradeable via UUPS.
- Audit (2-4 weeks). Internal + external. No deployment to mainnet without audit.
- Deployment and monitoring. Forta bots for abnormal volume monitoring, Tenderly for on-chain event alerts.
What’s Included (Deliverables)
Our deliverables include:
- Full smart contract documentation with interaction examples
- Test coverage >95% (unit, fuzz, fork)
- Deployment and operation instructions
- Support during testing and launch phases
- Option for subsequent audit with verified partners
- Access to private GitHub repository with all code
- Training session for your team (2 hours)
- Post-launch support for 1 month
Time & Cost Estimates
Minimum protocol (single asset, European style, fixed IV) — 6-8 weeks development without audit, starting at $50,000. Full multi-asset protocol — 2-3 months, costing $100,000–$250,000. Audit timeline is additional 2-4 weeks ($30,000–$80,000). Our optimized development process can save you up to 30% in audit costs compared to competitors. Development costs start at $50,000.
Sample Code Snippet
// Example of premium calculation
function calculatePremium(uint256 amount, uint256 strike, uint256 expiry) public view returns (uint256) {
// Simplified example
return amount * strike * block.timestamp / expiry;
}
Get a consultation for your project—write to us for detailed discussion.







