Search
K

AlphaOptionHandler.sol

AlphaOptionHandler

executeOrder(orderId) external Direct NonTrustedAccessible

This function gets a custom order using a orderId, this will revert if the sender is not the authorised buyer of the order. First the spot price will be checked against the customOrderBounds to make sure there hasnt been a big spot price move. If the order falls outside any of the allowed bounds then the transaction will revert. If all conditions are met then the option will be minted to the buyer. At the end of the transaction the order is invalidated.

executeBuyBackOrder(orderId) external Direct NonTrustedAccessible

This function gets a custom order using a orderId, this will revert if the sender is not the authorised buyer of the order. First the spot price will be checked against the customOrderBounds to make sure there hasnt been a big spot price move. If the order falls outside any of the allowed bounds then the transaction will revert. If all conditions are met then the option will be burned and usdc will be returned to the buyer. At the end of the transaction the order is invalidated.

executeStrangle(orderId1, orderId2) external Direct NonTrustedAccessible

This function executes two order executions and is intended for use with a strangle.

createOrder() external onlyRole

This function creates a custom option order receipt which contains the option series, the amount, the price at which the order is settled at, the time after which the custom order expires and the authorised buyer of the custom order. This is managed by a manager and governance and is used for large market orders with participants such as market makers. This returns an orderId which is used by the market participant to access their custom order in executeOrder. Create order also requires passing in whether the order is a buyback or not.

createStrangle() external onlyRole

This function creates two custom orders, one put order and one call order. This is so delta neutral positions can be sold to certain market participants.
Contract used for all user facing options interactions
Interacts with liquidityPool to write options and quote their prices.

liquidityPool

contract ILiquidityPool liquidityPool
immutable variables ///

protocol

contract Protocol protocol

strikeAsset

address strikeAsset

underlyingAsset

address underlyingAsset

collateralAsset

address collateralAsset

orderIdCounter

uint256 orderIdCounter
dynamic variables ///

orderStores

mapping(uint256 => struct Types.Order) orderStores

customOrderBounds

struct AlphaOptionHandler.CustomOrderBounds customOrderBounds
governance settable variables ///

MAX_BPS

uint256 MAX_BPS
constant variables ///

maxOrderExpiry

uint256 maxOrderExpiry

CustomOrderBounds

struct CustomOrderBounds {
uint128 callMinDelta;
uint128 callMaxDelta;
int128 putMinDelta;
int128 putMaxDelta;
uint256 maxPriceRange;
}

OrderCreated

event OrderCreated(uint256 orderId)

OrderExecuted

event OrderExecuted(uint256 orderId)

constructor

constructor(address _authority, address _protocol, address _liquidityPool) public

setCustomOrderBounds

function setCustomOrderBounds(uint128 _callMinDelta, uint128 _callMaxDelta, int128 _putMinDelta, int128 _putMaxDelta, uint32 _maxPriceRange) external
set new custom order parameters
Name
Type
Description
_callMinDelta
uint128
the minimum delta value a sold custom call option can have (e18 format - for 0.05 enter 5e16). Must be positive or 0.
_callMaxDelta
uint128
the maximum delta value a sold custom call option can have. Must be positive and have greater magnitude than _callMinDelta.
_putMinDelta
int128
the minimum delta value a sold custom put option can have. Must be negative and have greater magnitude than _putMaxDelta
_putMaxDelta
int128
the maximum delta value a sold custom put option can have. Must be negative or 0.
_maxPriceRange
uint32
the max percentage below the LP calculated premium that the order may be sold for. Measured in BPS - for 10% enter 1000

createOrder

function createOrder(struct Types.OptionSeries _optionSeries, uint256 _amount, uint256 _price, uint256 _orderExpiry, address _buyerAddress, bool _isBuyBack, uint256[2] _spotMovementRange) public returns (uint256)
creates an order for a number of options from the pool to a specified user. The function is intended to be used to issue options to market makers/ OTC market participants in order to have flexibility and customisability on option issuance and market participant UX.
Name
Type
Description
_optionSeries
struct Types.OptionSeries
the option token series to issue - strike in e18
_amount
uint256
the number of options to issue - e18
_price
uint256
the price per unit to issue at - in e18
_orderExpiry
uint256
the expiry of the custom order, after which the buyer cannot use this order (if past the order is redundant)
_buyerAddress
address
the agreed upon buyer address
_isBuyBack
bool
whether the order being created is buy back
_spotMovementRange
uint256[2]
min and max amount that the spot price can move during the order
Name
Type
Description
[0]
uint256
orderId the unique id of the order

createStrangle

function createStrangle(struct Types.OptionSeries _optionSeriesCall, struct Types.OptionSeries _optionSeriesPut, uint256 _amountCall, uint256 _amountPut, uint256 _priceCall, uint256 _pricePut, uint256 _orderExpiry, address _buyerAddress, uint256[2] _callSpotMovementRange, uint256[2] _putSpotMovementRange) external returns (uint256, uint256)
creates a strangle order. One custom put and one custom call order to be executed simultaneously.
Name
Type
Description
_optionSeriesCall
struct Types.OptionSeries
the option token series to issue for the call part of the strangle - strike in e18
_optionSeriesPut
struct Types.OptionSeries
the option token series to issue for the put part of the strangle - strike in e18
_amountCall
uint256
the number of call options to issue
_amountPut
uint256
the number of put options to issue
_priceCall
uint256
the price per unit to issue calls at
_pricePut
uint256
the price per unit to issue puts at
_orderExpiry
uint256
the expiry of the order (if past the order is redundant)
_buyerAddress
address
the agreed upon buyer address
_callSpotMovementRange
uint256[2]
min and max amount that the spot price can move during the order for the call
_putSpotMovementRange
uint256[2]
min and max amount that the spot price can move during the order for the call
Name
Type
Description
[0]
uint256
putOrderId the unique id of the put part of the strangle
[1]
uint256
callOrderId the unique id of the call part of the strangle

executeOrder

function executeOrder(uint256 _orderId) public
fulfills an order for a number of options from the pool to a specified user. The function is intended to be used to issue options to market makers/ OTC market participants in order to have flexibility and customisability on option issuance and market participant UX.
Name
Type
Description
_orderId
uint256
the id of the order for options purchase

executeBuyBackOrder

function executeBuyBackOrder(uint256 _orderId) public
fulfills a buyback order for a number of options from the pool to a specified user. The function is intended to be used to issue options to market makers/ OTC market participants in order to have flexibility and customisability on option issuance and market participant UX.
Name
Type
Description
_orderId
uint256
the id of the order for options purchase

executeStrangle

function executeStrangle(uint256 _orderId1, uint256 _orderId2) external
fulfills a stored strangle order consisting of a stores call and a stored put. This is intended to be called by market makers/OTC market participants.

getOptionRegistry

function getOptionRegistry() internal view returns (contract IOptionRegistry)
get the option registry used for storing and managing the options
Name
Type
Description
[0]
contract IOptionRegistry
the option registry contract

getPortfolioValuesFeed

function getPortfolioValuesFeed() internal view returns (contract IPortfolioValuesFeed)
get the portfolio values feed used by the liquidity pool
Name
Type
Description
[0]
contract IPortfolioValuesFeed
the portfolio values feed contract

_getUnderlyingPrice

function _getUnderlyingPrice(address underlying, address _strikeAsset) internal view returns (uint256)
get the underlying price with just the underlying asset and strike asset
Name
Type
Description
underlying
address
the asset that is used as the reference asset
_strikeAsset
address
the asset that the underlying value is denominated in
Name
Type
Description
[0]
uint256
the underlying price