quote
to represent the unit of pricing a base
asset that is having options traded against it.liquidityPool.deposit(500_000);
optionMarket.createOptionBoard(now() + MONTH_SEC, 1, [1500, 2000, 2500], [0.9, 1, 1.1]);
openPosition(uint _listingId, bool isLong, bool isCall, uint amount)
_listingId
refers to the relevant listing.isLong
refers to whether the user is buying from the market (long) or selling to the market (short)isCall
refers to whether or not the user is trading a call or a put.amount
is the number of options the user wants to trade._listingId
would be 1
, since it is the first listing we created. We want isLong
to be true, since we are buying from the market, and isCall
to be true, since we want a call option. For the amount
variable, we are going to just buy 1 option.optionMarket.openPosition(1, true, true, 1);
_listingId
and the address of the trader.optionMarket.getListingToUserToCallAmount(1, accountAddress);
OptionMarket.closePosition
.openPosition
. Since we bought 1 option, we would pass 1 in as the amount to close.optionMarket.closePosition(1, true, true, 1);
optionMarket.getListingToUserToCallAmount(1, accountAddress);
openPosition()
, a number of steps occur to allow the AMM to correctly price options.OptionPricer
. Before going further, it is important to note that pricing does not distinguish whether a position is being opened or closed, but rather which way the option is flowing. I.e.isBuy = true
signifies that a long is being opened OR a short is being closed. Option are flowing from the system to user.isBuy = false
signifies that a short is being opened OR a long is being closed. Options are flowing from the user to system.netDelta
and netStdVega
positions of the system are stored in the OptionGreekCache
contract.LiquidityPool
. In the event that the option finishes in the money, the profits will be distributed from this collateral.OptionMarket
. This gives the system the right to exercise its option, should it expire in the money.amount
baseAsset. This is converted from quoteAsset.amount
in baseAsset. This is converted to quoteAsset.spot > strike
:amount * (spot - strike)
quoteAsset is reserved per option to pay out to the useramount * strike
in quoteAsset.amount * strike
in quoteAsset.strike > spot
:amount * (strike - spot)
quoteAsset is reserved per option to pay out to the useramount
baseAsset to the OptionMarketamount
of baseAsset from the OptionMarketspot > strike
:amount * (spot - strike)
quoteAsset is sent to the LP from the user's collateral (a portion of the baseAsset collateral is sold)amount
baseAsset is reserved to pay back to the user per optionamount * strike
in quoteAsset to the OptionMarket as collateralamount * strike
in quoteAsset from the OptionMarketstrike > spot
amount * (strike - spot)
quoteAsset per option is taken from the user's collateralamount * spot
is reserved for the user in quoteAssetamount * strike
is reserved for the user in quoteAsset