Architecture
Overview of DOPP architecture + Controller, Options Factory, and Orderbook
Overview
Controller
The Controller smart contract is the main contract with which the user interacts. Ans it’s the contract that writes orders on the matching engine and mints option tokens from the factory for buyers. It enables traders to deposit collateral, open short and long orders for whitelisted options, withdraw collateral, and exercise options. It also allows liquidators to cancel open orders of a user if the initial margin health factor is less than 1. And liquidate the user’s short positions if the maintenance margin health factor is less than 1.
Short sellers can:
- Withdraw an amount of the collateral deposited if the initial margin health factor is > 1 after withdraw
- Add collateral to avoid liquidation
- Burn option tokens
Buyers can exercise options at the strike price after the keepers wait until the expiry date.
Options Factory
It allows the minting of new under-collateralized options (call or put) and the receipt of ERC-20 OPTokens, allowing them to be traded at a premium. When a user opens a short order on the controller. Once the order is matched and filled on the order book (matching engine). The controller mints new tokens from the deployed contract and the tokens are transferred to the buyer. Every day at 8:00 a.m. UTC, the keepers or anyone can invoke the settle_options_by_expiration function to determine if the options can be exercised by examining the oracles and option characteristics. The keepers have the right to a delay in which the exercise and minting are halted so that they can invoke the function.
Orderbook
The matching engine is a CLOB
OPToken
OPToken is an ERC20 contract in which each token represents an option. All the OPTokens have 18 decimals, the name and symbol of an OPToken are determined by the underlying, strike asset, collateral, expiry and strike price. The mint and burn privilege is only granted to the Controller.