Full-StackSolidityReactethers.jsDeFiChainlink

UZH Options

DeFi options market on a testnet with a self-hosted Chainlink oracle for real-world price feeds

2022
2 min read
Daniel Lutziger, D.S., V.V.
UZH Options

UZH Options: DeFi Options Trading with a Chainlink Oracle

Overview

We built an end-to-end DeFi options market on the UZHETH testnet. Users connect a wallet, mint USDUZH (a USD-pegged stablecoin we created) by exchanging UZHETH at the live ETH/USD rate, and use that stablecoin to write and exercise covered calls and cash-covered puts on UZHETH. To get real-world prices on-chain we deployed our own Chainlink node and built the contract architecture around it. I was responsible for the React + ethers.js frontend; D.S. and V.V. handled the smart contracts and the paper.

System Architecture

Solidity contracts can't make HTTP calls, so we routed every price request through Operator.sol, which submits a paid job to our self-hosted Chainlink node, which hits an external API and returns a uint256 price back to Options.sol. Five contracts (Options.sol, USDUZH.sol, Faucet.sol, Operator.sol, and the LINK fee token) were deployed and verified on UZHETH.

Final Result

The platform is live and the Chainlink node is reachable with documented credentials. A user can connect a wallet, drip LINK from the faucet, mint USDUZH against their UZHETH at the live ETH/USD rate, write a covered call by locking UZHETH as collateral, write a cash-covered put by locking USDUZH, browse open offers, and exercise positions before expiry. Every state transition on the contract (sellX, buyX, cancelX, exerciseX) has explicit checks for expiry, double-spend, correct caller, and sufficient funds.

Problem We Struggled With

The oracle problem itself: Solidity can't reach the outside world, so we had to build the whole Options.sol → Operator.sol → Chainlink node → external API round-trip ourselves, and getting the fee accounting and job configuration to line up across that chain on the first real call took a meaningful share of the project budget.