SeriesController.mintOptionscan be used to mint onchain Call and Put options. The call to
Xamount of collateral token to a Series and in return mints
wTokento the caller. This
bTokencan then be sold at its premium to those wishing to purchase
ERC20options, and if after expiry the Series is in the money then the
bTokencan be redeemed for a portion of the
Series'locked collateral. The
wTokencan be kept until the Series expires at which point the remaining locked collateral can be claimed. The
SeriesControllerexposes functions for redeeming the
Xcollateral token [^1], there is a function
SeriesController.closePositionwhich acts like the inverse of
wTokencan be burned in return for the
Xcollateral token locked in the Series.
SeriesController.createSeries. Each Series uses a monotonically incrementing
uint64as an index into the array of Series. To read the fields of any single Series struct, use the
8, which is the number of leading 0's in all of the oracle price values used by the
SeriesController. More specifically, all of the current market prices returned by
8leading decimals. For example, if the current price of
WBTC[TODO glossary] is $34,000, then the value returned by
WBTCCall Series would be
34_000 * 1e8.
block.timestampis before the Series' expiration date, then it is in the state
OPEN, otherwise it is in the state
EXPIRED. Only certain functions can be executed when the state is
OPEN, and some only when the state is
SeriesController.exerciseOption](#exerciseOption) so you can see what the payout will be prior to exercising thebToken`.
bTokenholder's option is ITM, and for Puts this is the price below which the
bTokenholder's option is ITM. The strike price always has 8 decimals. For example, a
3400000000000indicates the price is $34,000.
OPENstate and can mint options and close positions, but cannot redeem option tokens. At and after this date the Series is in the
EXPIREDstate and can redeem option tokens, but can no longer mint or close out positions.
ERC20token whose price determines the (glossary.md#moneyness) of the Series. For example, both WBTC Call option series and WBTC Put option series share WBTC as their underlying token, because the price of WBTC determines whether the Series is in or out of the money. If this is a Call Series then this will be the same token as the collateralToken.
SeriesController.mintOptionsand decreases with every call to
SeriesController.closePosition. This function is also useful for calculating part of the TVL (Total Value Locked) in the protocol.
_optionTokenAmountof option tokens. For Call options this is simply equal to
wTokenare backed by 1 collateral token. However, for Puts it's slightly more complicated. Because a Put option gives the
bTokenholder the right to sell the underlying token at the strike price, 1
wTokenmust be backed by
1 * strike_price * decimals_coefficientamount of collateral token. The
decimals_coefficientis term which divides out the price token and underlying token decimals, leaving only the correct decimals of the collateral token remaining.
0if it has not been set yet. A Series' settlement price is set by an offchain bot as soon as that Series expires. The settlement price will have 8 decimals, and use the same units as the priceToken. For example, if the settlement price of a certain Series is $34,000, then
settlement_price = 34_000 * 1e8.
0if the current block timestamp is prior to the Series expiration date. It's also possible the settlement date will be equal to
0for a small amount of time (1-15 minutes) after the expiration date. This is because the EVM does not provide any functionality for automatically calling contract functions on a predefined schedule (such as cron), and so an offchain process must send a transaction calling
PriceOracle.setSettlementPriceand set the current underlying token's price manually. The EVM gives no guarantees on when a transaction will be included in the blockchain, so the protocol cannot guarantee the settlement price will be set exactly at the Series' expiration date.
WBTC[TODO glossary] was $34,000, then the value returned by
WBTCSeries would be
34_000 * 1e8. This price is fetched via the
PriceOracle, which in turn fetches it from an onchain oracle.
ERC20token the Series will be for (i.e. the token whose price movements will determine the long and short payouts). The priceToken will be the token used to denominate the price in (e.g. for a WBTC option denominated in USDC, the underlying token will be WBTC and the price token will be USDC, but for a WBTC option denominated in ETH, the underlying token will be WBTC and the price token will be ETH). The collateralToken determines the
ERC20token used to underwrite the covered options. For Put options the
collateralTokenmust be equal to the
priceToken, and for Call options the
collateralTokenmust be equal to the
collateralTokenfor these Series
_optionTokenAmountamount of a given Series's
bTokensby locking collateral in that Series. The option tokens are transferred to the caller. One of the fundamental formulas for the SIREN protocol is:
X collateralToken ==> X wToken and X bToken
SeriesController.getCollateralPerOptionTokenfor more details on computing the exact amount of collateral needed to mint a given amount of option tokens.
bTokenand transfers the
bToken's payout to the caller. The SIREN protocol are cash-settled, so the payout for
bTokensis calculated as some fraction of the collateral token locked in the Series. The payout of the
bTokendepends on the Series' strike price and the price of the underlying token. For Puts, the payout increases as the underlying token's price decreases and for Calls the payout increases as the underlying tokne's price increases. See the section [Protocol Math](TODO link) for the details on how the protocol calculates
trueif you want this function call to revert if the Series is OTM,
falseif you want it to continue executing even if it's OTM. Passing
truewill save gas but will require the calling context to handle the error (possibly resulting in the entire transaction reverting). Passing
falsewill use more gas, but will effectively be a no-op and preclude the calling context from worrying about their transaction reverting
wTokenand transfers the
wToken's payout to the caller. The SIREN protocol are cash-settled, so the payout for
wTokensis calculated as some fraction of the collateral token locked in the Series. The payout of the
wTokendepends on the Series' strike price and the price of the underlying token. For Puts, the payout decreases as the underlying token's price decreases and for Calls the payout decreases as the underlying token's price increases. See the section [Protocol Math](TODO link) for the details on how the protocol calculates
bToken, then transfers the equivalent amount of collateral token to the caller. For Calls the amount of collateral token received will be equal to
_optionTokenAmount, and for Puts the amount of collateral token received will be equal to
_optionTokenAmount * strikePrice(see the getCollateralPerOptionToken function for more details on this calculations).
SeriesController's logic contract. The SIREN protocol's contracts use the EIP-1822 standard for implementing upgradeable contracts. This allows us to update vulnerable contracts and keep LP's liquidity and the collateral locked in Series safe. When the SIREN protocol has reached a certain level of stability, we can remove these safety guards and ensure no one on the Siren team can swap out the smart contract functionality.
SeriesController's function implementations