ERC-7390 ERC-20 vanilla option standard (Vanilla Options for ERC-20 Tokens)

Draft · Vaults & DeFi · created 2022-09-02

Defines a common interface for creating, buying, and exercising vanilla options, the right to buy or sell an ERC-20 token at a fixed price within a fixed period. The right is represented as an ERC-1155 token, so it can be partially purchased or transferred to someone else.

Why it is needed

Options are a financial instrument widely used to manage risk or to invest in price-movement opportunities. Many platforms selling options have also emerged in decentralized finance (DeFi), but each platform has defined and implemented options in its own different way. This creates a compatibility problem, where an option created on one platform cannot be used on another. The starting point of this proposal is that, just as fungible tokens or NFTs are usable everywhere thanks to common standards, options should likewise be compatible with each other. With a common interface, users can trade options seamlessly across multiple apps, and developers can build decentralized option platforms or more complex exotic options on top of this standard.

What to implement

In depth

Issuance units and the VanillaOptionData struct

Options are managed as units of issuance, and each issuance is distinguished by an id and independently bought, exercised, and canceled. When calling create, the issuer fills in and passes a VanillaOptionData struct. side is Call or Put, underlyingToken is the underlying token, and amount is the maximum quantity of the underlying token that can be exercised. strikeToken and strike set the exercise price, where strike is the price per one unit of the underlying token denominated in strikeToken. premiumToken and premium are the payment token and amount of the premium, where premium is set as the value for exercising the full amount of the issuance. exerciseWindowStart and exerciseWindowEnd are the exercisable period in Unix seconds, and allowed is the list of addresses permitted to buy; if empty, anyone can buy. Issuance state is stored in the OptionIssuance struct along with writer (the issuer), exercisedAmount (amount exercised), and soldAmount (amount sold).

create and the collateralization rules

create transfers collateral from the issuer to the contract, mints a new issuance, returns an id, and emits a Created event. For a call, the caller must pre-approve the underlying token equal to amount; for a put, the caller must pre-approve the exercise cost computed from strikeToken. The exercise cost (exerciseCost) is calculated at issuance time as (strike * amount) / 10^(underlying token decimals). To avoid increasing counterparty risk, it is strongly recommended that an issuance be fully collateralized at the time of create, and implementations that allow undercollateralization must define their own mechanism for replenishing collateral. The function must revert if underlyingToken or strikeToken is the zero address, if premium is nonzero but premiumToken is the zero address, if amount or strike is zero, or if exerciseWindowStart is earlier than the current time or exerciseWindowEnd is earlier than exerciseWindowStart.

buy and the ERC-1155 redeem token

buy(id, amount) is the function for purchasing amount units of an option from a given issuance. The buyer must pre-approve spending of premiumToken equal to their share of the total premium, and the premium is transferred directly to the issuer during execution of the function. If the allowed list is non-empty, the buyer's address must be on it, and the call must revert if amount is zero or exceeds the remaining sellable quantity, or if the current time is past exerciseWindowEnd. On a successful purchase, amount units of an ERC-1155 redeem token are minted to the buyer and a Bought event is emitted. Because the redeem token can be transferred between users, the right to exercise itself can be passed on, and this structure allows a single issuance to have multiple buyers.

How exercise works

exercise(id, amount) burns amount of the buyer's redeem tokens and exercises the option. For a call, the buyer pays the issuer strikeToken equal to the exercise price and receives the underlying token. For a put, the buyer transfers the underlying token to the issuer and receives strikeToken equal to the exercise price. Therefore, before exercising, the buyer must have pre-approved spending of strikeToken for a call or underlyingToken for a put. Exercise is only possible when exerciseWindowStart <= current time <= exerciseWindowEnd, and the call must revert if amount is zero or if the buyer does not hold that many redeem tokens. If only part of the position is exercised, the exercise amount is adjusted proportionally, and an Exercised event is emitted on success.

Collateral retrieval (retrieveExpiredTokens) and cancellation (cancel)

Once the current time is past exerciseWindowEnd, the issuer can call retrieveExpiredTokens(id, receiver) to retrieve the remaining, unexercised collateral to receiver. For a call this returns the underlying token, for a put it returns strikeToken, and an Expired event is emitted. An issuance that has not sold any portion at all can be canceled with cancel(id, receiver) to reclaim the collateral, emitting a Canceled event. Both functions must revert if called by an address other than the issuer, and receiver must be set to the caller's address if it is the zero address. On a successful retrieval or cancellation, an implementation MAY delete the issuance from the contract.

Updating the premium and the allowed list

The issuer can change the premium at any time with updatePremium(id, amount). Here, amount is a price based on the issuance's total amount, not the unsold remainder, and it has no effect on buyers who have already purchased. updateAllowed(id, allowed) can also be used to change the list of addresses permitted to buy; a buyer who has already purchased the option can continue to exercise it even if removed from the new list. Both functions can only be called by the issuer, must revert if the current time is past exerciseWindowEnd, and emit a PremiumUpdated or AllowedUpdated event, respectively, on success.

Oracle-free design and support for European and American style

This standard operates without an oracle, since it assumes a rational buyer will only exercise when it is profitable to do so. Premium calculation is also left to be done off-chain, for example using a Black-Scholes-type model, to save on gas costs, and the issuer can adjust it at any time to match market conditions. The two exercise window values can express both European and American style options. For European style, exerciseWindowStart is set to the expiration date and exerciseWindowEnd to some period after it; for American style, exerciseWindowStart is set to the current time so exercise is possible immediately. The allowed list can be used to prevent a third party from buying an option before it goes on-chain, which two users had already agreed to off-chain. The standard is specific to ERC-20 tokens, but it can also serve as a basis for other standards handling tokens such as ERC-721.

Proposal status and prerequisites

This proposal is still in Draft status. Its contents may change and discussion may stall, so the latest source should be checked before actual implementation. Implementations of this standard must also implement ERC-1155 to support purchasing only part of an issuance; a separate constructor is not needed, but the ERC-1155 constructor must be invoked. The underlying token, strike token, and premium token are all assumed to be ERC-20 tokens.

Things to watch out for

Original ERC · ← ERCs