A Universal Option to Trade (Part 2 of 4)

Birthday Research
Birthday Research
Published in
7 min readAug 19, 2022

This is part 2 of 4 articles in a technical series on Wrytes, a leading on-chain decentralized options protocol with automated premium pricing, shared liquidity pools and fractionalized options.

Wrytes is developed by Birthday Research, the Research & Development (R&D) arm of Cake DeFi, and will be launched in Q3 2022.

Find out more about Wrytes in this article.
Read Part 1 of 4:
Decentralizing Options — A New Approach

Introduction

The first article discussed the current landscape of decentralized options and provided a brief overview on two commonly used option protocols: Opyn and Hegic. Based on the existing landscape, a new approach to decentralizing options, Wrytes, was introduced. Wrytes is an on-chain decentralized options protocol with automated premium pricing, shared liquidity pools and fractionalized options. The article then went deeper into the first feature — the premium price strategy — which includes various factors such as the strike price versus the current price, time to expiry and the market demand.

This is the second article of the 4-part series, and will introduce another feature of Wrytes: The ability to be resold in the secondary options market.

Revisiting the current landscape

The two names mentioned above in the decentralized options protocol space allows for their options to be traded, to a certain degree.

Opyn’s Gamma Protocol relies on their options being fungible and can therefore be traded in an open market where their premium price is determined. The Opyn options are essentially ERC-20 Tokens that are indistinguishable from each other as long as the Tokens are minted from the same vault.

Hegic’s V8888 Protocol does not have a unique vault architecture and thus relies on a single pool to provide option liquidity to all the options which are sold in the same type and currency (for example, a single ETH Call options pool is able to sell options with a variety of strike prices and expiry dates). The options are minted as an ERC-721 Token and have metadata mainly for accounting purposes. This also means that each option may be slightly different from their counterpart, be it its strike price, expiry or even the amount of option being held in the ERC-721.

It is possible for the options from Hegic to change hands, however it is not possible to fractionalize it and sell only a portion of its held amount to willing buyers, which can become an inconvenience. Unlike Opyn, Hegic combines the liquidity into a single pool which is a benefit as a larger pool liquidity will allow more options to be sold at the same time. Therefore, option buyers have the flexibility to purchase options with the specific expiry and strike price that they desire.

The best of both worlds

Wrytes aims to provide users with a universal option pool (like Hegic) that allows a variety of options of differing strike prices and expiries to be sold in our implementation, alongside an easy way to trade options (like Opyn).

Universal option pool

In each option class, the pool accepts liquidity in the form of the underlying tokens for call options, or stable coins in general for put options.

Each liquidity provider will be minted a Tranche ERC-721 for accounting purposes. The tranche records the timestamp for providing liquidity to the owner, how much liquidity was provided initially, as well as the proportion of the pool this tranche owns.

/**
* @param state The state of the liquidity tranche: Invalid, Open, Closed
* @param share The liquidity provider's share in the pool
* @param amount The size of liquidity provided
* @param creationTimestamp The liquidity deposit timestamp
**/
struct Tranche {
TrancheState state;
uint256 share;
uint256 amount;
uint256 creationTimestamp;
}

The tranches are stored in an array with and the index of the array will serve as the id of the tranche. The liquidity provider will need to provide the id of the tranche in order to withdraw. It is therefore the responsibility of liquidity providers to keep track of their own ids.

Should a user misplace his/her id, it is possible to rely on indexing services or block explorers to retrieve the tranche id from the event logs.

Tranche[] public tranches;

The creationTimestamp is used to keep a record for when the liquidity was deposited. lockupPeriodForTranches is also introduced which requires liquidity providers to stay in the pool for a certain length of period, which can be managed by the admin. This is a first line of defense which helps to mitigate the likelihood that the pool has no profit to pay out to options that have been exercised ITM. The second line of defense will be the collateralizationRatio which is used to lock a certain amount of liquidity. This ensures that the pool will maintain a minimum amount to pay off the profits by option exercisers.

As the premium is automatically reinvested into the pool, the share will help to determine the proportion of profits gained or losses suffered in the pool. An additional point to note is that a liquidity provider reward will also be introduced, which will be covered in the following articles.

Finally, the amount is used for accounting purposes related to liquidity provider reward.

Making it Trade-able!

A game changing property of options is the ability to trade them as if they were fungible to each other. This means that options of the same type (token, call/put, strike price and expiry) are at least treated equally with one another.

In order to achieve this, each of the same type is issued a unique ERC-20 Token. The code snippet below demonstrates the ability to deploy a minimal proxy ERC-20 contract if the type does not exist in its ERC-20 token form yet.

IOptionErc20 optionErc20 = optionErc20s[expiry][strike];
// deploy this optionErc20 if not found
if (address(optionErc20) == address(0)) {
optionErc20 = deployOptionErc20(expiry, strike);
}

The precision of OptionErc20 is the same as the precision of the underlying token of the pool. As such, if 10 wei of underlying token is specified as the amount, 10 wei of OptionErc20 will be minted to represent the option. Therefore, the option can be traded in a minuscule manner.

Also, the OptionErc20 contract is written in such a way that it is compliant with the ERC-20 standards with familiar mechanisms such as approvaland transferFrom.

Expired options

Wrytes is developed as European options whereby options can only be exercised after expiration. In the world of EVM, a state transition will require a transaction. Therefore, after the option has expired, anyone is able to call the unlock function on behalf of the option owner, and the profit is determined by the current price from the Chainlink price feed oracle at the time of unlocking.

The premium that is held by the option is released upon unlock and any profit is awarded to the option holder whilst the corresponding OptionErc20 is burnt.

Furthermore, a lockedAmount concept exists, whereby a certain amount of liquidity will be used as collateral until the option has been unlocked. This ensures that the pool will have a minimum amount of funds to pay out the profit to option holders. (Recall the second line of defense.)

function _calculateLockedAmount(uint256 amount)
internal
virtual
returns (uint256) {
return (amount * collateralizationRatio) / 100;
}

However, this can pose a problem as the option holder will need to wait indefinitely and hope that no one exercises the option on their behalf, only unlocking when the current price is favorable and when a profit can be gained.

The pool is at risk of 1) locked up liquidity and 2) higher risk of being exercised against.

Although anyone is able to call the unlock function, it can be gas inefficient to perform such an operation for all users.

Therefore, a concept of expiryThreshold has been introduced, whereby during a certain period after the expiry, anyone is able to call the unlockOptionErc20 to effectively invalidate the entire OptionErc20 of the specific type and unlock all its lockedAmounts and premiums.

Performing this operation will also mean all option holders will be voided of their profits. This will encourage liquidity providers to spend the extra gas to free up the funds that are locked up in the option. It will also serve as an economic incentive for options holders to exercise their own options especially if they have gained a profit.

To sum it up

This second article explores the strategy to make Wrytes ‘universally tradeable’. It also introduces a strategy to safeguard liquidity providers in the form of a forced unlock for all functions.

In the next article (3 of 4), the reward mechanism for Wrytes will be introduced and since everyone loves rewards, be sure to keep a lookout for that.

About Birthday Research

Birthday Research is the blockchain R&D arm of Cake DeFi that develops best-in-class blockchain innovations, with the mission of enabling the next bound of Web3 through open-source blockchain research and development.

Birthday Research’s work spans cryptographic research, deep blockchain consensus development, and smart contracts development — with a laser-sharp focus on pushing the industry frontier while tackling the most demanding DeFi challenges of today.

--

--

Birthday Research
Birthday Research

Birthday Research is the Blockchain Research and Development arm of Cake DeFi, a Singapore-based blockchain and fintech company.