Clear Developer Guide
  • Clear Developer Guide
  • Deploy Contract
    • Quick start
    • Configure Contract
    • Contract Upgrade
    • Contract Address
  • Configure contract parameters
    • Configure Contract Parameters
  • Interact with the contract
    • OPTION
      • Market Maker
      • User
    • NOTE
      • Fund Manager
      • LP User
  • Contract reference
    • Oracle
    • Index Contract
    • Option Contract
    • Market Maker Contract
    • Note Contract
  • APIs
    • Configure
    • Price
    • User
    • Market Maker
    • Index
    • Option parameter configuration
    • Faucet
Powered by GitBook
On this page
  • User
  • 1. Buy options
  • 2.Sell options
  • 3. Exercise options at maturity
  • 4.Knock out
  1. Interact with the contract
  2. OPTION

User

PreviousMarket MakerNextNOTE

Last updated 3 years ago

User

1. Buy options

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/putoption 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.

2.Sell options

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

Close position price rule

_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.

3. Exercise options at maturity

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()

4.Knock out

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 ;

link ,
link
link
link