Fixed Strike Option Teller

Contract that creates and manages the lifecycle of oTokens with a fixed strike price

Overview

Option Teller contracts handle the deployment, creation, and exercise of option tokens. oTokens are ERC20 tokens that represent the right to buy (call) or sell (put) a fixed amount of an asset (payout token) for an amount of another asset (quote token) between two timestamps (eligible and expiry). oTokens are denominated in units of the payout token and are created at a 1:1 ratio for the amount of payout tokens to buy or sell. The amount of quote tokens required to exercise (call) or collateralize (put) an oToken is called the strike price. Strike prices are denominated in units of the quote token.

The Fixed Strike Option Teller implementation creates option tokens that have a fixed strike price that is set at the time of creation.

Deploy and Creating oTokens

In order to create oTokens, an issuer must deploy the specific token configuration on the teller, and then provide collateral to the teller to create option tokens. The collateral is required to guarantee that the oTokens can be exercised. The collateral required depends on the option type.

  • For call options, the collateral required is an amount of payout tokens equivalent to the amount of option tokens being minted.

  • For put options, the collateral required is an amount of quote tokens equivalent to the amount of option tokens being minted multiplied by the strike price.

As the name "option" suggests, the holder of an option token has the right, but not the obligation, to exercise the oToken within the eligible time window. If the oToken is not exercised, the designated "receiver" of the oToken exercise proceeds can reclaim the collateral after the expiry timestamp. If an oToken is exercised, the holder receives the collateral and the receiver receives the exercise proceeds.

FixedStrikeOptionTeller

Git Source

State Variables

protocolFee

Fee paid to protocol when options are exercised in basis points (3 decimal places).

uint48 public protocolFee;

FEE_DECIMALS

Base value used to scale fees. 1e5 = 100%

uint48 public constant FEE_DECIMALS = 1e5;

optionTokenImplementation

FixedStrikeOptionToken reference implementation (deployed on creation to clone from)

FixedStrikeOptionToken public immutable optionTokenImplementation;

minOptionDuration

Minimum duration an option must be eligible to exercise (in seconds)

uint48 public minOptionDuration;

fees

Fees earned by protocol, by token

mapping(ERC20 => uint256) public fees;

optionTokens

Fixed strike option tokens (hash of parameters to address)

mapping(bytes32 => FixedStrikeOptionToken) public optionTokens;

collateralClaimed

Whether the receiver of an option token has reclaimed the collateral

mapping(FixedStrikeOptionToken => bool) public collateralClaimed;

User Functions

deploy

Deploy a new ERC20 fixed strike option token and return its address

If an option token already exists for the parameters, it returns that address

function deploy(
    ERC20 payoutToken_,
    ERC20 quoteToken_,
    uint48 eligible_,
    uint48 expiry_,
    address receiver_,
    bool call_,
    uint256 strikePrice_
) external override nonReentrant returns (FixedStrikeOptionToken);

Parameters

Returns

create

Deposit an ERC20 token and mint an ERC20 fixed strike option token

function create(FixedStrikeOptionToken optionToken_, uint256 amount_) external override nonReentrant;

Parameters

exercise

Exercise an ERC20 fixed strike option token. Provide required quote tokens and receive amount of payout tokens.

Amount of quote tokens required to exercise is return from the exerciseCost() function

function exercise(FixedStrikeOptionToken optionToken_, uint256 amount_) external override nonReentrant;

Parameters

reclaim

Reclaim collateral from expired option tokens

function reclaim(FixedStrikeOptionToken optionToken_) external override nonReentrant;

Parameters

View Functions

exerciseCost

Get the cost to exercise an amount of fixed strike option tokens

function exerciseCost(FixedStrikeOptionToken optionToken_, uint256 amount_) external view returns (ERC20, uint256);

Parameters

Returns

getOptionToken

Get the FixedStrikeOptionToken contract corresponding to the params, reverts if no token exists

function getOptionToken(
    ERC20 payoutToken_,
    ERC20 quoteToken_,
    uint48 eligible_,
    uint48 expiry_,
    address receiver_,
    bool call_,
    uint256 strikePrice_
) public view returns (FixedStrikeOptionToken);

Parameters

Returns

getOptionTokenHash

Get the hash ID of the fixed strike option token with these parameters

function getOptionTokenHash(
    ERC20 payoutToken_,
    ERC20 quoteToken_,
    uint48 eligible_,
    uint48 expiry_,
    address receiver_,
    bool call_,
    uint256 strikePrice_
) external pure returns (bytes32);

Parameters

Returns

Admin Functions

setMinOptionDuration

Set minimum duration to exercise option

Absolute minimum is 1 day (86400 seconds) due to timestamp rounding of eligible and expiry parameters

function setMinOptionDuration(uint48 duration_) external override requiresAuth;

Parameters

setProtocolFee

Set protocol fee

function setProtocolFee(uint48 fee_) external override requiresAuth;

Parameters

claimFees

Claim fees accrued by protocol in the input tokens and sends them to the provided address

function claimFees(ERC20[] memory tokens_, address to_) external override nonReentrant requiresAuth;

Parameters

Events

WroteOption

event WroteOption(uint256 indexed id, address indexed referrer, uint256 amount, uint256 payout);

OptionTokenCreated

event OptionTokenCreated(
    FixedStrikeOptionToken optionToken,
    ERC20 indexed payoutToken,
    ERC20 quoteToken,
    uint48 eligible,
    uint48 indexed expiry,
    address indexed receiver,
    bool call,
    uint256 strikePrice
);

Errors

Teller_NotAuthorized

error Teller_NotAuthorized();

Teller_TokenDoesNotExist

error Teller_TokenDoesNotExist(bytes32 optionHash);

Teller_UnsupportedToken

error Teller_UnsupportedToken(address token);

Teller_InvalidParams

error Teller_InvalidParams(uint256 index, bytes value);

Teller_OptionExpired

error Teller_OptionExpired(uint48 expiry);

Teller_NotEligible

error Teller_NotEligible(uint48 eligible);

Teller_NotExpired

error Teller_NotExpired(uint48 expiry);

Teller_AlreadyReclaimed

error Teller_AlreadyReclaimed(FixedStrikeOptionToken optionToken);

Teller_PriceOutOfBounds

error Teller_PriceOutOfBounds();

Teller_InvalidAmount

error Teller_InvalidAmount();