IOptionPS

Git Source

Inherits: IERC1155Base, IERC1155Enumerable

Functions

name

Returns the name of the physically settled option token

function name() external view returns (string memory);

symbol

Returns the symbol of the physically settled option token

function symbol() external view returns (string memory);

getSettings

Returns the pair infos for this option

function getSettings() external view returns (address base, address quote, bool isCall);

underwrite

Underwrite an option by depositing collateral

function underwrite(UD60x18 strike, uint64 maturity, address longReceiver, UD60x18 contractSize) external;

Parameters

NameTypeDescription
strikeUD60x18the option strike price (18 decimals)
maturityuint64the option maturity timestamp
longReceiveraddressthe address that will receive the long tokens
contractSizeUD60x18number of long tokens to mint (18 decimals)

annihilate

Burn longs and shorts, to recover collateral of the option

function annihilate(UD60x18 strike, uint64 maturity, UD60x18 contractSize) external;

Parameters

NameTypeDescription
strikeUD60x18the option strike price (18 decimals)
maturityuint64the option maturity timestamp
contractSizeUD60x18number of contracts to annihilate (18 decimals)

getExerciseCost

Returns the amount of exerciseToken to pay to exercise the given amount of contracts

function getExerciseCost(UD60x18 strike, UD60x18 contractSize)
    external
    view
    returns (uint256 totalExerciseCost, uint256 fee);

Parameters

NameTypeDescription
strikeUD60x18the option strike price (18 decimals)
contractSizeUD60x18number of long tokens to exercise (18 decimals)

Returns

NameTypeDescription
totalExerciseCostuint256the total amount of exerciseToken to pay, including fee (exerciseToken decimals)
feeuint256the amount of exerciseToken to pay as fee (exerciseToken decimals)

getExerciseValue

Returns the amount of collateral that would be received for a given amount of long tokens

function getExerciseValue(UD60x18 strike, UD60x18 contractSize) external view returns (uint256);

Parameters

NameTypeDescription
strikeUD60x18the option strike price (18 decimals)
contractSizeUD60x18number of long tokens to exercise (18 decimals)

Returns

NameTypeDescription
<none>uint256the amount of collateral (collateral decimals)

exercise

Pay the exercise cost for a given amount contracts. The exercise value will be claimable after maturity.

function exercise(UD60x18 strike, uint64 maturity, UD60x18 contractSize) external;

Parameters

NameTypeDescription
strikeUD60x18the option strike price (18 decimals)
maturityuint64the option maturity timestamp
contractSizeUD60x18amount of long tokens to exercise (18 decimals)

cancelExercise

Cancel an exercise before maturity, and recover the exerciseToken paid. (The fee paid during exercise is not recovered.

function cancelExercise(UD60x18 strike, uint64 maturity, UD60x18 contractSize) external;

Parameters

NameTypeDescription
strikeUD60x18the option strike price (18 decimals)
maturityuint64the option maturity timestamp
contractSizeUD60x18amount of long tokens for which cancel exercise (18 decimals)

settleLong

Settle the exercised long options held by the caller.

function settleLong(UD60x18 strike, uint64 maturity, UD60x18 contractSize) external returns (uint256 exerciseValue);

Parameters

NameTypeDescription
strikeUD60x18the option strike price (18 decimals)
maturityuint64the option maturity timestamp
contractSizeUD60x18number of long tokens to settle (18 decimals)

Returns

NameTypeDescription
exerciseValueuint256the amount of tokens transferred to the caller

settleShort

Settles the short options held by the caller.

function settleShort(UD60x18 strike, uint64 maturity, UD60x18 contractSize)
    external
    returns (uint256 collateralAmount, uint256 exerciseTokenAmount);

Parameters

NameTypeDescription
strikeUD60x18the option strike price (18 decimals)
maturityuint64the option maturity timestamp
contractSizeUD60x18number of short tokens to settle (18 decimals)

Returns

NameTypeDescription
collateralAmountuint256the amount of collateral transferred to the caller (base for calls, quote for puts)
exerciseTokenAmountuint256the amount of exerciseToken transferred to the caller (quote for calls, base for puts)

getTokenIds

Returns the list of existing tokenIds with non zero balance

function getTokenIds() external view returns (uint256[] memory);

Returns

NameTypeDescription
<none>uint256[]tokenIds The list of existing tokenIds

Events

Exercise

event Exercise(
    address indexed user, UD60x18 strike, uint256 maturity, UD60x18 contractSize, UD60x18 exerciseCost, UD60x18 fee
);

CancelExercise

event CancelExercise(
    address indexed user, UD60x18 strike, uint256 maturity, UD60x18 contractSize, UD60x18 exerciseCostRefunded
);

SettleLong

event SettleLong(address indexed user, UD60x18 strike, uint256 maturity, UD60x18 contractSize, UD60x18 exerciseValue);

SettleShort

event SettleShort(
    address indexed user,
    UD60x18 strike,
    uint256 maturity,
    UD60x18 contractSize,
    UD60x18 collateralAmount,
    UD60x18 exerciseTokenAmount
);

Underwrite

event Underwrite(
    address indexed underwriter, address indexed longReceiver, UD60x18 strike, uint256 maturity, UD60x18 contractSize
);

Annihilate

event Annihilate(address indexed annihilator, UD60x18 strike, uint256 maturity, UD60x18 contractSize);

Errors

OptionPS__OptionMaturityNot8UTC

error OptionPS__OptionMaturityNot8UTC(uint256 maturity);

OptionPS__OptionExpired

error OptionPS__OptionExpired(uint256 maturity);

OptionPS__OptionNotExpired

error OptionPS__OptionNotExpired(uint256 maturity);

OptionPS__StrikeNotMultipleOfStrikeInterval

error OptionPS__StrikeNotMultipleOfStrikeInterval(UD60x18 strike, UD60x18 strikeInterval);

Enums

TokenType

enum TokenType {
    Long,
    Short,
    LongExercised
}