User
Last updated
Last updated
The user calls OptionV2->buyOption()
requesting parameters:
uint256 _indexNo index ID,
uint8 _poolId option pool ID,
uint256 _position The position of options purchased,,
bool _isCall call:true,put:false,
uint256 _price option purchase price,
uint256 _datetime signature valid time,
bytes calldata _signData signature data
Before the user purchases, request the interface buy-sign
.After requesting the interface, the return parameterssignsignData
,price
,date-time
passed into the contract, and the user selects the option product to buy call/put
option to obtain index_no, poolId. _payToken, which needs to be configured inaallowPayToken
, and _signData obtained through the interface/api/defi/option/order/buy-sign
link . Please note that the signature is only valid within 2 minutes, after it is generated.
The user callsOptionV2->sellOption()
to sell the user share back to the market maker, parameter list:
uint256 _orderNo sell option contract ID
uint256 _position sell quantity
uint256 _price selling price
uint256 _datetime Signature valid time
bytes calldata _signData signature data
_price is calculated by the option pricing formula, and the final selling price needs to be multiplied by the OptionV2->sellPriceRate
rate. The pledged margin is returned to the market maker's margin balance.
The user callsOptionV2->userExercise()
to calculate the user profit and obtain it. If the share is a call option, the profit =position * (exercise_price-open_price), if it is a put option, the profit = position (exercise_price-open_price). The user's profit will be issued to the user in real time, and the market maker will liquidate through OptionV2->makerExercise()
The user calls OptionV2->userKnockOut()
for knockout liquidation. If OptionV2->knockoutRebate
>0, user profit = buy_price * knockoutRebate /1.
Before selling, the user requests the interface sell-sign
to obtain the parameters signData
,price
,datetime
;