BokkyPooBah’s Vanilla And Bounded Optino(tm) Crypto Options – BokkyPooBah的普通和有界Optino(tm)加密期权区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,BokkyPooBah’s Vanilla And Bounded Optino(tm) Crypto Options – BokkyPooBah的普通和有界Optino(tm)加密期权区块链毕设代写 是一篇很好的国外资料

BokkyPooBah’s Vanilla And Bounded Optino(tm) Crypto Options

Status: Work in progress

See the the smart contracts in contracts/OptinoFactory.sol.

See the Optino wiki for documentation (TODO).

The testing is in the test folder, with some sample results in test/test1results.txt.

You can test out a version of the smart contracts using MetaMask connected to the Ropsten network at https://bokkypoobah.github.io/OptinoExplorer.


Ignore everything below

Risks

  • Bugs
    • Smart contracts
    • UI
  • Manipulation of the price oracles
  • Flash loans
  • Chain splits

MakerDAO Price Feed

https://makerdao.com/en/feeds https://etherscan.io/address/0x81FE72B5A8d1A857d176C3E7d5Bd2679A9B85763

How Does This Work

e.g. ETH/DAI

Call Optino

Put Optino


Vanilla Optino Payoff Formula

Example: ETH/DAI Optinos

  • callPut0 for call, 1 for put
  • strike
  • spot
  • rateDecimalsstrike and spot decimal places

Vanilla Call Optino Payoff Formula

payoffInQuoteToken = max(0, spot - strike) payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals)

Vanilla Call Optino Collateral Payoff Formula

payoffInQuoteToken = spot - max(0, spot - strike) payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals)

Vanilla Put Optino Payoff Formula

payoffInQuoteToken = max(0, strike - spot) payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals)

Vanilla Put Optino Collateral Payoff Formula

payoffInQuoteToken = strike - max(0, strike - spot) payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals)

// —————————————————————————- // Vanilla Optino Formula // // Call optino – 10 units with strike 200, using spot of [150, 200, 250], collateral of 10 ETH // – 10 OptinoToken created // – payoffInQuoteTokenPerUnitBaseToken = max(0, spot-strike) = [0, 0, 50] DAI // – payoffInQuoteToken = 10 * [0, 0, 500] DAI // * payoffInBaseTokenPerUnitBaseToken = payoffInQuoteTokenPerUnitBaseToken / [150, 200, 250] = [0, 0, 50/250] = [0, 0, 0.2] ETH // * payoffInBaseToken = payoffInBaseTokenPerUnitBaseToken * 10 = [0 * 10, 0 * 10, 0.2 * 10] = [0, 0, 2] ETH // – 10 OptinoCollateralToken created // – payoffInQuoteTokenPerUnitBaseToken = spot – max(0, spot-strike) = [150, 200, 200] DAI // – payoffInQuoteToken = 10 * [1500, 2000, 2000] DAI // * payoffInBaseTokenPerUnitBaseToken = payoffInQuoteTokenPerUnitBaseToken / [150, 200, 250] = [1, 1, 200/250] = [1, 1, 0.8] ETH // * payoffInBaseToken = payoffInBaseTokenPerUnitBaseToken * 10 = [1 * 10, 1 * 10, 0.8 * 10] = [10, 10, 8] ETH // // Put optino – 10 units with strike 200, using spot of [150, 200, 250], collateral of 2000 DAI // – 10 OptinoToken created // * payoffInQuoteTokenPerUnitBaseToken = max(0, strike-spot) = [50, 0, 0] DAI // * payoffInQuoteToken = 10 * [500, 0, 0] DAI // – payoffInBaseTokenPerUnitBaseToken = payoffInQuoteTokenPerUnitBaseToken / [150, 200, 250] = [50/150, 0/200, 0/250] = [0.333333333, 0, 0] ETH // – payoffInBaseToken = payoffInBaseTokenPerUnitBaseToken * 10 = [0.333333333 * 10, 0 * 10, 0 * 10] = [3.333333333, 0, 0] ETH // – 10 OptinoCollateralToken created // * payoffInQuoteTokenPerUnitBaseToken = strike – max(0, strike-spot) = [150, 200, 200] DAI // * payoffInQuoteToken = 10 * [1500, 2000, 2000] DAI // – payoffInBaseTokenPerUnitBaseToken = payoffInQuoteTokenPerUnitBaseToken / spot // – payoffInBaseTokenPerUnitBaseToken = [150, 200, 200] / [150, 200, 250] = [1, 1, 200/250] = [1, 1, 0.8] ETH // – payoffInBaseToken = payoffInBaseTokenPerUnitBaseToken * 10 = [1 * 10, 1 * 10, 0.8 * 10] = [10, 10, 8] ETH // // // —————————————————————————- library VanillaOptinoFormulae { using SafeMath for uint;

// ------------------------------------------------------------------------ // Payoff for baseToken/quoteToken, e.g. ETH/DAI //   OptionToken: //     Call //       payoffInQuoteToken = max(0, spot - strike) //       payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals) //     Put //       payoffInQuoteToken = max(0, strike - spot) //       payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals) //   OptionCollateralToken: //     Call //       payoffInQuoteToken = spot - max(0, spot - strike) //       payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals) //     Put //       payoffInQuoteToken = strike - max(0, strike - spot) //       payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals) // // NOTE: strike and spot at rateDecimals decimal places, 18 in this contract // ------------------------------------------------------------------------ function payoff(uint _callPut, uint _strike, uint _spot, uint _baseTokens, uint _baseDecimals) internal pure returns (uint _payoffInBaseToken, uint _payoffInQuoteToken, uint _collateralPayoffInBaseToken, uint _collateralPayoffInQuoteToken) {     if (_callPut == 0) {         _payoffInQuoteToken = (_spot <= _strike) ? 0 : _spot.sub(_strike);         _collateralPayoffInQuoteToken = _spot.sub(_payoffInQuoteToken);     } else {         _payoffInQuoteToken = (_spot >= _strike) ? 0 : _strike.sub(_spot);         _collateralPayoffInQuoteToken = _strike.sub(_payoffInQuoteToken);     }     _payoffInBaseToken = _payoffInQuoteToken * 10 ** 18 / _spot;     _collateralPayoffInBaseToken = _collateralPayoffInQuoteToken * 10 ** 18 / _spot;      _payoffInBaseToken = _payoffInBaseToken * _baseTokens / 10 ** _baseDecimals;     _payoffInQuoteToken = _payoffInQuoteToken * _baseTokens / 10 ** _baseDecimals;     _collateralPayoffInBaseToken = _collateralPayoffInBaseToken * _baseTokens / 10 ** _baseDecimals;     _collateralPayoffInQuoteToken = _collateralPayoffInQuoteToken * _baseTokens / 10 ** _baseDecimals; } function payoffInDeliveryToken(uint _callPut, uint _strike, uint _spot, uint _baseTokens, uint _baseDecimals) internal pure returns (uint _payoff, uint _collateral) {     (uint _payoffInBaseToken, uint _payoffInQuoteToken, uint _collateralPayoffInBaseToken, uint _collateralPayoffInQuoteToken) = payoff(_callPut, _strike, _spot, _baseTokens, _baseDecimals);     if (_callPut == 0) {         _payoff = _payoffInBaseToken;         _collateral = _collateralPayoffInBaseToken;     } else {         _payoff = _payoffInQuoteToken;         _collateral = _collateralPayoffInQuoteToken;     } } 

}


Exotics

Capped Call

callPayoff = max(spot - strike, 0) cappedCallPayoff = max(min(spot, cap) - strike, 0) cappedCallPayoff = max(spot - strike, 0) - max(spot - cap, 0) 

Floored Put

putPayoff = max(strike - spot, 0) flooredPutPayoff = max(strike - max(spot, floor), 0) flooredPutPayoff = max(strike - spot, 0) - max(floor - spot, 0) 

Enjoy!

(c) BokkyPooBah / Bok Consulting Pty Ltd – Jan 26 2020. The MIT Licence.


BokkyPooBah的Vanilla And Bounded Optino(tm)加密期权

状态:在制品

查看合同中的智能合约/OptinoFactory.sol公司.

请参阅Optino wiki for documentation(TODO)。

测试在test文件夹中,在test/test1中有一些示例结果结果.txt.

您可以使用连接到Ropsten网络的MetaMask测试智能合约的版本https://bokkypoobah.github.io/OptinoExplorer。


忽略下面的一切

风险

  • 链拆分
  • 即期
  • 利率小数点-执行和即期小数点位
  • Chain splits

这是如何工作的

https://makerdao.com/en/feedshttps://etherscan.io/address/0x81FE72B5A8d1A857d176C3E7d5Bd2679A9B85763

看涨期权

例如ETH/DAI

看跌期权

普通Optino支付公式Optino抵押品支付公式贷款
  • 链拆分
  • 看涨期权为0,卖出期权为1
  • 执行
  • 即期
  • 利率小数点-执行和即期小数点位

  • Vanilla Optino Payoff Formula

    示例:ETH/DAI Optinos

    • callPut0 for call, 1 for put
    • strike
    • spot
    • rateDecimalsstrike and spot decimal places

    Vanilla Call Optino Payoff Formula

    payoffInQuoteToken = max(0, spot - strike) payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals)

    Vanilla Call Optino Collateral Payoff Formula

    payoffInQuoteToken = spot - max(0, spot - strike) payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals)

    Vanilla Put Optino Payoff Formula

    payoffInQuoteToken = max(0, strike - spot) payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals)

    Vanilla Put Optino Collateral Payoff Formula

    payoffInQuoteToken = strike - max(0, strike - spot) payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals)

    //——————————————————————————-//普通Optino公式///Call Optino-10个单位,删除200,使用[150,200,250]点,10 ETH//-10 OptinoToken的抵押品创建//-payoffinkotetoken=max(0,spot strike)=[0,0,50]DAI//-payoffinbasetoken=10*[0,0,500]DAI//*payoffinebasetoken=payoffinetokenperUnitBaseToken/[150,200,250]=[0,0,50/250]=[0,0,50/250]=[0,0,0.2]ETH//*payoffInBaseToken=payoffInBaseToken=payoffInBaseToken*10=[0*10,0*10,0.2*10]=[0,0,2]ETH//-10创建的OptinoCollateralToken//-payoffinquetokenperUnitBaseToken=spot-max(0,点击)=[150,200,200]DAI//-payoffInBaseToken=10*[1500,2000,2000]DAI//*payoffInBaseTokenPerUnitBaseToken=1/200,10/200,10/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/250/1/200/1/200,2000 DAI//-10 optionNotoken创建的抵押品//*payoffinkotetokenperUnitBaseToken=max(0,打击点)=[50,0,0]DAI//payoffinquetoken=10*[500,0,0]DAI//-payoffInBaseTokenPerUnitBaseToken=PayofInQuoteTokenPerUnitBaseToken/[150,200,250]=[50/150,0/200,0/250]=[0.333333333,0,0]ETH//-payoffInBaseToken=payofinbasetokenperUnitBaseToken*10=[0.333333*10,0*10,0*10]=[3.333333333,0,0]ETH//-10创建的optionNoCollateralToken//*payoffinquetokenperUnitBaseToken=strike-max(0,罢工点)=[150,200,200]DAI//*PayoffinQuentokeToken=10*[1500,2000,2000]DAI//-payoffInBaseToken=payoffInBaseTokenPerUnitBaseToken/spot//-payoffInBaseTokenPerUnitBaseToken=[150,200,200]/[150,200,250]=[1,1,200/250]=[1,1,0.8]ETH//-payoffInBaseToken=payoffbasetokenPerUnitBaseToken*10=[1*10,1*10,0.8*10]=[10,10,8] ETH//////——————————————————————-库vanillaoptinoformulas{使用SafeMath for uint;

    // ------------------------------------------------------------------------ // Payoff for baseToken/quoteToken, e.g. ETH/DAI //   OptionToken: //     Call //       payoffInQuoteToken = max(0, spot - strike) //       payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals) //     Put //       payoffInQuoteToken = max(0, strike - spot) //       payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals) //   OptionCollateralToken: //     Call //       payoffInQuoteToken = spot - max(0, spot - strike) //       payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals) //     Put //       payoffInQuoteToken = strike - max(0, strike - spot) //       payoffInBaseToken = payoffInQuoteToken / (spot / 10^rateDecimals) // // NOTE: strike and spot at rateDecimals decimal places, 18 in this contract // ------------------------------------------------------------------------ function payoff(uint _callPut, uint _strike, uint _spot, uint _baseTokens, uint _baseDecimals) internal pure returns (uint _payoffInBaseToken, uint _payoffInQuoteToken, uint _collateralPayoffInBaseToken, uint _collateralPayoffInQuoteToken) {     if (_callPut == 0) {         _payoffInQuoteToken = (_spot <= _strike) ? 0 : _spot.sub(_strike);         _collateralPayoffInQuoteToken = _spot.sub(_payoffInQuoteToken);     } else {         _payoffInQuoteToken = (_spot >= _strike) ? 0 : _strike.sub(_spot);         _collateralPayoffInQuoteToken = _strike.sub(_payoffInQuoteToken);     }     _payoffInBaseToken = _payoffInQuoteToken * 10 ** 18 / _spot;     _collateralPayoffInBaseToken = _collateralPayoffInQuoteToken * 10 ** 18 / _spot;      _payoffInBaseToken = _payoffInBaseToken * _baseTokens / 10 ** _baseDecimals;     _payoffInQuoteToken = _payoffInQuoteToken * _baseTokens / 10 ** _baseDecimals;     _collateralPayoffInBaseToken = _collateralPayoffInBaseToken * _baseTokens / 10 ** _baseDecimals;     _collateralPayoffInQuoteToken = _collateralPayoffInQuoteToken * _baseTokens / 10 ** _baseDecimals; } function payoffInDeliveryToken(uint _callPut, uint _strike, uint _spot, uint _baseTokens, uint _baseDecimals) internal pure returns (uint _payoff, uint _collateral) {     (uint _payoffInBaseToken, uint _payoffInQuoteToken, uint _collateralPayoffInBaseToken, uint _collateralPayoffInQuoteToken) = payoff(_callPut, _strike, _spot, _baseTokens, _baseDecimals);     if (_callPut == 0) {         _payoff = _payoffInBaseToken;         _collateral = _collateralPayoffInBaseToken;     } else {         _payoff = _payoffInQuoteToken;         _collateral = _collateralPayoffInQuoteToken;     } } 

    }


    Exotics

    Capped Call

    callPayoff = max(spot - strike, 0) cappedCallPayoff = max(min(spot, cap) - strike, 0) cappedCallPayoff = max(spot - strike, 0) - max(spot - cap, 0) 

    Floored Put

    putPayoff = max(strike - spot, 0) flooredPutPayoff = max(strike - max(spot, floor), 0) flooredPutPayoff = max(strike - spot, 0) - max(floor - spot, 0) 

    享受吧!

    (c)BokkyPooBah/Bok Consulting Pty Ltd-2020年1月26日。麻省理工学院的执照。

    部分转自网络,侵权联系删除区块链源码网

    www.interchains.cc

    https://www.interchains.cc/17299.html

    区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
    区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » BokkyPooBah’s Vanilla And Bounded Optino(tm) Crypto Options – BokkyPooBah的普通和有界Optino(tm)加密期权区块链毕设代写

    提供最优质的资源集合

    立即查看 了解详情