合约快速指南

欢迎通过调取helmet合约为您的协议资产搭建保险功能

以下指南内容被完全硬编码在Helemet智能合约中,Helmet平台的各项资产参数完全市场化决定,依靠合约自动执行。非紧急情况下,Helmet团队不会干预定价或修改合约

Helmet.insurance的智能合约有内核和周边两个部分组成,期权交易逻辑被编码在内核合约,包含OptionFactory, LongOption, ShortOption合约;周边则用于执行保单买卖和资金费率以及挖矿,由OptionOrder, HELMET Token Farm contracts合约组成。

OptionFactory 用来实现创造保单、挖矿、烧毁保单、出险和结算功能。

  • LongOption 是保单购买者的权证

  • ShortOption 是保单售卖者的权证,用于记录创造保单和结算资产

  • OptionOrder 是保单市场,实现买卖双方互相交易

OptionFactory 主要函数:

function createOption(bool _private, address _collateral, address _underlying, uint _strikePrice, uint _expiry) public returns (address long, address short);

function mint(bool _private, address _collateral, address _underlying, uint _strikePrice, uint _expiry, uint volume) public returns (address long, address short, uint vol);

function burn(address _creator, address _collateral, address _underlying, uint _strikePrice, uint _expiry, uint volume) public returns (address long, address short, uint vol);

function calcExerciseAmount(address _long, uint volume) public view returns (uint);

function exercise(address _long, uint volume, address[] memory path) public returns (uint vol, uint fee, uint amt);

function settleable(address short, uint volume) public view returns (uint vol, uint col, uint fee, uint und);

function settle(address short, uint volume) public returns (uint vol, uint col, uint fee, uint und);

LongOption 主要函数:

function exercise(uint volume, address[] memory path) public returns (uint vol, uint fee, uint amt);

ShortOption 主要函数:

function settleable(address seller) public view returns (uint vol, uint col, uint fee, uint und);

function settle(uint volume) external returns (uint vol, uint col, uint fee, uint und);

OptionOrder 主要函数:

function sell(bool _private, address _collateral, address _underlying, uint _strikePrice, uint _expiry, uint volume, address settleToken, uint price) virtual public returns (uint askID);

function reprice(uint askID, uint newPrice) virtual external returns (uint newAskID);

function cancel(uint askID) virtual external returns (uint vol);

function buy(uint askID, uint volume) virtual public returns (uint bidID, uint vol, uint amt);

function exercise(uint bidID, uint volume, address[] memory path) virtual public returns (uint vol, uint fee, uint amt);

function waive(uint bidID, uint volume) virtual public returns (uint vol);

买&卖保单

卖一份保单

调用OptionOrder合约的 sell function 函数

 function sell(
     bool _private, 
     address _collateral, 
     address _underlying, 
     uint _strikePrice, 
     uint _expiry, 
     uint volume, 
     address settleToken, 
     uint price
 ) 
     virtual 
     public 
     returns (uint askID);

举例

计价资产

抵押

保单价格

保费

保单数量

过期日

BNB

HELMET

0.1BNB

0.2 Helmet

10 BNB

2021/1/1 0:0:0 UMT

OptionOrder.sell(
    false, 
    0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c, 
    0x4E76DfeA6Fb3726e9A77628AAa23839E3298BC37, 
    10000000000000000000, 
    1609459200, 
    123000000000000000000, 
    0x4E76DfeA6Fb3726e9A77628AAa23839E3298BC37, 
    200000000000000000);

买一份保单

调用OptionOrder合约的 buy function 函数

function buy(uint askID, uint volume) 
    virtual 
    public 
    returns (uint bidID, uint vol, uint amt);

举例

ID

保单价格

456

123 BNB

OptionOrder.buy(456, 123000000000000000000);

出险

调用OptionOrder合约的 exercise function 函数

function exercise(
    uint bidID, 
    uint volume, 
    address[] memory path
) 
    virtual 
    public 
    returns (uint vol, uint fee, uint amt);

举例

如果是看涨类保险

OptionOrder.exercise(789, 123000000000000000000, []);

如果是沽空类保险

OptionOrder.exercise(
    789, 
    123000000000000000000, 
    [0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c,
    0x4E76DfeA6Fb3726e9A77628AAa23839E3298BC37]);

结算

调用OptionFactory合约的 settle function 参数

function settle(
    address _creator, 
    address _collateral, 
    address _underlying, 
    uint _strikePrice, 
    uint _expiry, 
    uint volume
) 
    external 
    returns (uint vol, uint col, uint fee, uint und);

举例

OptionFactory.settle(
    address(0), 
    0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c, 
    0x4E76DfeA6Fb3726e9A77628AAa23839E3298BC37, 
    10000000000000000000, 
    1609459200, 
    123000000000000000000);

最后更新于