Native Options for mango
Options are a very important and interesting derived instruments which can be used for hedging existing investments. Currently Mango has implemented spot and Perp futures market, with Options it will become the most attractive DEX. For solana hackathon I have started working on integration of Option in mango smart-contract mango-v3, I intend to continue working on it even after the hackathon if I get the opportunity. You can check my progress here: github branch feature/mango-options. I would love to have some feedbacks from the community to solve various problems during integration of option.
Let me first explain the mechanics of the options:
Mango will create an option market which will have following parameters:
Underlying token index → internal index of token which will be the underlying for the market
Quote token index → internal index of token which will be quote for the market
Expiry → time when option will expire.
Contract size → Number of underlying tokens represented by one option token
Quote amount → Number of quote tokens to be exchanged to get the underlying tokens of contract size.
Type of option (European, American)
User can play two roles:
Option writer: A writer will deposit the underlying tokens and will receive two tokens, options token and writer’s token. Writer then can sell the options token in the orderbook but has to keep the writers token till the expiry. Finally at the expiry writer can exchange the writers token for underlying tokens or the quote tokens.
Option trader: With option tokens trader has a right not an obligation to exercise the option i.e to exchange the underlying tokens of contract size with the quote amount.
Call option ETH/USDC can be created with underlying token as ETC and quote token as USDC while Put option ETH/USDC can be created with underlying token as USDC and quote token as ETH.
I will try to create a permissionless option market. This means I have to recreate the orderbook as it was done for Perp market (it cannot be reused as it is strongly coupled with perp market). I also what to have possibility to create potentially unlimited number of option markets with different parameters. I am also looking for contributors especially for frontend.
Questions to tackle:
- Who will create these options markets:
* Mango DAO
* Any User (He/she has to pay the rent)?
When a user writes an option, he will deposit underlying tokens. How will it affect its health? It should affect its health as during liquidation we cannot directly liquidate locked tokens. We have to wait till expiry to handle these tokens. But these tokens belong to the user so we cannot not take into account while calculating the health.
Will writer earn interest on the locked tokens? How will we take it into account if he exchanges it for quote tokens? Will he always earn interest in underlying tokens?
How will options affect borrowing lending? Should user be able to borrow more quote tokens to exercise them for potentially a greater number of underlying tokens which may improve his health.
Thanks to @microwavedcola for suggesting us such interesting topics for hackathon in his hackathon list.
First, Thank you for all the hard work for building up the Mango Option.
With Regards to the questiosn, I have some though.
- The option markets should be created by Mango DAO.To avoid the liquidity fragmentation, the options can not be created with all possible strike price with all possible expire date.
- The option writer after writing an option will mint option_strike position and option_no_strike position.
Like there will be 1 SOL_strike_200USD_2022_1231_call_option and 1 SOL_no_strike_200USD_2022_1231_call_option after deposit 1 Sol token. The prediction market style two token minting mechanism can help for pricing the calculating health. There will be a price for both token with enough liquidity given my first point. (This mainly get inspired by Cover protocol and FTX prediction market.) Assume both token have enough liquidity, we can just treat them as normal asset even with lending borrowing function and can be sell in liquidation.
- The locked token will receive Interest even though MangoDAO in-principle can charge fee. The underlying token could be deposit into a ( or separate) Mango DAO trading account during the lock up period (the American option can be redeem anytime). The token will represent a share of the account asset so it will receive the interest during redemption(mango can cut fee for the interest during redemption). Given the example in my second point, a user can pay 200USD with a 1 SOL_strike_200USD_2022_1231_call_option to redeem 1+interest Sol assume the price of sol is 300USD at 2022/12/31.
- Yes, the asset to write option and mint option tokens in my suggestion will go to the Mango Lending Market.
Hi @kowei ,
Thanks a lot for your reply. Great to have your feedback.
I totally agree with you Mango DAO should create options to avoid liquidity fragmentation.
I am not so much familiar with strike and no strike tokens. I was more inspired by PsyOptions and is mechanics of option tokens and writers’ tokens. Could you more elaborate on strike and no strike tokens, I cannot find the material as I cannot access cover protocol website and documentation (seems to be down).
My opinion is to incentivize the option writers (i.e users who deposit underlying tokens to create option tokens), we give the accumulated interest to the writers. When writers exchange the writers tokens at the end of the expiry he/she will either get underlying tokens + accumulated interests or quote_tokens + accumulated interests in underlying tokens.
My question was more about, should we let a user borrow more quote tokens even if he/she has a poor health to exercise their option. May be exercising the option will improve their health.
Hi @godmodegalactus ,
I think you can check the FTX prediction market (like Trump Win/Lose token for 2020).
Let me elaborate more here about the cover style two token design. (just like PsyOption design)
Cover use this design for insurance, I though this mechanism is easier to be a money lego, to have composability with the rest of the mango protocol.
For example, assume Mango Dao open a European style cover call option market for Sol, strike price at 200USD, expire at 2022/12/31. Any one now can deposit 1SOL to the corresponding contract and mint 1 strike token and 1 no_strike token.
If the price oracle is >200USD at the end of the period, the holder of 1strike token can redeem 1SOL (plus the interest) with 200USD, and 1 no _strike will be able to redeem 200USD.
On the other hand, if the the price oracle is < 200USD at the end of the period. The 1 no_strike token can redeem can redeem 1SOL(plus the interest) back, and the 1 strike token will mean nothing.
For the writer who want to sell the call option just deposit the SOL, get the two token ‘strike token and no_strike token’, and sell the strike token in the open market (need to hold the no_strike token to redeem the SOL back if option is not executed.)
In another words, in the language of PsyOption. The Option token is the Strike token in cover style. The writer token is no-Strike token in cover style. For your origin question (2), the locked asset will not be counted in the health but the writer token will also have a market price and can be count in the health.
In short, I propose any option markets should have two token markets, one for option token, one for writer token. Then the Mango Protocol can integrate both token naturally with the lending, borrowing function, can be use as collateral to open a perp and can be liquidated.
Great that sounds similar with what I am implementing right now. But this should a good idea to use these tokens to calculate the health of a portfolio. I will check if its technical feasibility.
I have finished the mechanics of options market except for few details. I have also tested the contract using extensive unit tests.
Please feel free look, review, comment, at my pull request :
I would like to discuss more about it during a dev call.
I have been looking for contributors to help me especially in frontend and alpha/beta testing of the contract.
The quote and underlying tokens will be equally distributed between all the writers.
The exchange writer tokens instruction is now permissionless.
(Inprogress) Option holders will gain margin if they hold option tokens and can be exercised for profit.
(Inprogress) Liquidation of option holders and writers.
Margin calculation for a user having options tokens:
I have adopted a way to calculate user health by taking margin tokens into account. For reason of simplicity and efficiency, the options health will directly impact the spot health. We have created a new account for each user holding option which will hold information related to option tokens and writer tokens that user owns. To calculate the margin we have following cases:
- Price of underlying tokens > strike price:
For option tokens for the user we add the underlying tokens into user health and remove the quote tokens from the health. This will effectively increase margin for the user having option tokens.
- Price of underlying tokens < strike price:
These tokens are only worth exactly as the price
Ideally for writer we must do the opposite, but as we cannot liquidate writers easily, we must use another strategy. Currently we just remove the underlying tokens from the health until the expiry. At the expiry option writer will anyways get back underlying and quote tokens by a permissionless instruction. So, the margin for option writers will reduce as soon as they write option tokens.
Liquidation of option users:
Option token holder without any writer tokens: If option can be exercised liquidator can exercise the option tokens and keep the underlying tokens which are in profit. If option cannot be exercised (i.e in loss) liquidator can sell these option tokens in the market for quote currency.
For option writers as said before we can buy equivalent number of option tokens from market and free the locked underlying by essentially burning both option tokens and writers tokens the same time. We must check if the health is improved after burning of tokens.
Call option: 1ETH@5000USDC expiry 3 months.
User X: has writes 10 options locking its 10 ETH and removing them from its margin.
User Y: Buys 5 options from user X. Current price of ETH is 4000 USDC. As ETH < STRIKE price so margin of the player remains unchanged.
After several month ETH goes to 7000 USDC. So userB margin jumps by 3000 USDC as he can now anytime exercise these options to get the profit. Beware this jump in margin only last till expiry, if the user fails to exercise the option their margin will be automatically reduced.
LIQA wants to liquidate UserX. Current price of the option is 5 USDC. UserX is nearing bankruptcy and has locked tokens which were not counted towards its margin. LIQA can buy 10 options spending 50 USDC and unlocking UserA’s underlying tokens for a liquidation fee.
LIQB wants to liquidate User Y. They can either force exercise the option tokens till the maint_health > 0. Or sell the option tokens in the market.