EIPs Explained

ERC-7390 · Draft · ERC · 2022-09-02

ERC-7390: Vanilla Options for ERC-20 Tokens

A standard interface for fully collateralized call and put options on ERC-20 tokens, with buyer positions represented as transferable ERC-1155 redeem tokens.

What problem does it solve?

Options give the right, but not the obligation, to buy (call) or sell (put) an asset at a set price during a set window. Several DeFi platforms sell options, but each defines "an option" in its own way, so positions from one protocol cannot be read, traded or reused by another.

ERC-7390 proposes a common interface for vanilla options (the plain call/put kind) on ERC-20 tokens, so wallets, marketplaces and aggregators can work with any compliant options contract.

How it works

One contract holds many issuances, each with its own id. A writer creates an issuance by filling a VanillaOptionData struct:

Field Meaning
side Call or Put
underlyingToken, amount The asset and the maximum quantity that can be exercised
strikeToken, strike Price per one underlying token, in the strike token
premiumToken, premium What buyers pay the writer, for the whole amount
exerciseWindowStart / End Unix timestamps bounding when exercise is allowed
allowed Optional allow-list of buyers (empty = anyone)

Lifecycle:

  1. create pulls the collateral into the contract: the underlying for a call, the strike tokens for a put. Returns the issuance id.
  2. buy(id, amount) pays a pro-rated premium directly to the writer and mints amount ERC-1155 redeem tokens to the buyer. Buyers can buy fractions, and redeem tokens can be transferred.
  3. exercise(id, amount) works only inside the window and burns redeem tokens. Call: the buyer pays strike and receives underlying. Put: the buyer delivers underlying and receives strike tokens.
  4. After the window, retrieveExpiredTokens returns unexercised collateral to the writer. Before anything is sold, cancel does the same.

The writer may also call updatePremium and updateAllowed until expiry; neither affects options already bought.

Sample code

Writing and buying a call option (ethers v6). The contract must be approved for the collateral and premium first:

import { Contract, parseUnits } from "ethers";

const abi = [
  "function create((uint8 side,address underlyingToken,uint256 amount,address strikeToken,uint256 strike,address premiumToken,uint256 premium,uint256 exerciseWindowStart,uint256 exerciseWindowEnd,address[] allowed)) returns (uint256)",
  "function buy(uint256 id, uint256 amount)",
  "function exercise(uint256 id, uint256 amount)",
  "event Created(uint256 indexed id)",
];
const options = new Contract(OPTIONS_ADDRESS, abi, writer);

const now = Math.floor(Date.now() / 1000);
const tx = await options.create({
  side: 0,                                   // Call
  underlyingToken: TOKEN_A, amount: parseUnits("8", 18),
  strikeToken: TOKEN_B,     strike: parseUnits("25", 18),   // 25 B per 1 A
  premiumToken: TOKEN_C,    premium: parseUnits("10", 18),  // for all 8 A
  exerciseWindowStart: now + 86400,
  exerciseWindowEnd: now + 3 * 86400,
  allowed: [],
});
await tx.wait();

// a buyer takes half the issuance (pays 5 C), then exercises inside the window
await options.connect(buyer).buy(id, parseUnits("4", 18));

Things to know

  • Status: Draft. The interface may still change; do not assume compatibility between implementations.
  • Watch decimals: strike is the price of one whole underlying token, and the contract scales payments by the underlying's decimals.
  • The standard only describes fully collateralized options; it defines no way to top up collateral for under-collateralized designs.
  • Premium is paid straight to the writer at purchase. The writer can change it at any time, so buyers should check the current premium before approving.

#defi #options #derivatives #erc20 #erc1155

Details

Authors
Ewan Humbert (@Xeway) <[email protected]>, Lassi Maksimainen (@mlalma) <[email protected]>
Status
Draft
Type
Standards Track / ERC
Created
2022-09-02
Requires

Machine-readable: Markdown · JSON