From efeee6b435afc2ae60bdf5ddd7d2d74cd0e4450d Mon Sep 17 00:00:00 2001 From: Haythem Sellami Date: Mon, 20 Apr 2020 14:52:00 +0100 Subject: [PATCH] add script to generate contracts documentation --- docs/CTokenInterface.md | 285 ++++++++++++ docs/CompoundOracleInterface.md | 84 ++++ docs/Context.md | 78 ++++ docs/Dai.md | 299 +++++++++++++ docs/ERC20.md | 345 +++++++++++++++ docs/ERC20Detailed.md | 124 ++++++ docs/ERC20Mintable.md | 63 +++ docs/IERC20.md | 179 ++++++++ docs/IOptionsExchange.md | 56 +++ docs/LibNote.md | 300 +++++++++++++ docs/Migrations.md | 100 +++++ docs/MinterRole.md | 148 +++++++ docs/MockCompoundOracle.md | 85 ++++ docs/MockUniswapFactory.md | 128 ++++++ docs/OptionsContract.md | 739 +++++++++++++++++++++++++++++++ docs/OptionsExchange.md | 219 +++++++++ docs/OptionsFactory.md | 177 ++++++++ docs/OptionsUtils.md | 89 ++++ docs/Oracle.md | 107 +++++ docs/Ownable.md | 171 +++++++ docs/Roles.md | 102 +++++ docs/SafeMath.md | 230 ++++++++++ docs/StringComparator.md | 53 +++ docs/TestImports.md | 50 +++ docs/UniswapExchangeInterface.md | 540 ++++++++++++++++++++++ docs/UniswapFactoryInterface.md | 116 +++++ docs/oToken.md | 212 +++++++++ package-lock.json | 188 ++++++++ package.json | 4 +- solidoc.json | 8 + 30 files changed, 5278 insertions(+), 1 deletion(-) create mode 100644 docs/CTokenInterface.md create mode 100644 docs/CompoundOracleInterface.md create mode 100644 docs/Context.md create mode 100644 docs/Dai.md create mode 100644 docs/ERC20.md create mode 100644 docs/ERC20Detailed.md create mode 100644 docs/ERC20Mintable.md create mode 100644 docs/IERC20.md create mode 100644 docs/IOptionsExchange.md create mode 100644 docs/LibNote.md create mode 100644 docs/Migrations.md create mode 100644 docs/MinterRole.md create mode 100644 docs/MockCompoundOracle.md create mode 100644 docs/MockUniswapFactory.md create mode 100644 docs/OptionsContract.md create mode 100644 docs/OptionsExchange.md create mode 100644 docs/OptionsFactory.md create mode 100644 docs/OptionsUtils.md create mode 100644 docs/Oracle.md create mode 100644 docs/Ownable.md create mode 100644 docs/Roles.md create mode 100644 docs/SafeMath.md create mode 100644 docs/StringComparator.md create mode 100644 docs/TestImports.md create mode 100644 docs/UniswapExchangeInterface.md create mode 100644 docs/UniswapFactoryInterface.md create mode 100644 docs/oToken.md create mode 100644 solidoc.json diff --git a/docs/CTokenInterface.md b/docs/CTokenInterface.md new file mode 100644 index 0000000..036b6cc --- /dev/null +++ b/docs/CTokenInterface.md @@ -0,0 +1,285 @@ +# CTokenInterface.sol + +View Source: [contracts/lib/CTokenInterface.sol](../contracts/lib/CTokenInterface.sol) + +**CTokenInterface** + +## Contract Members +**Constants & Variables** + +```js +address public underlying; +uint256 public initialExchangeRateMantissa; + +``` + +## Functions + +- [transfer(address dst, uint256 amount)](#transfer) +- [transferFrom(address src, address dst, uint256 amount)](#transferfrom) +- [approve(address spender, uint256 amount)](#approve) +- [allowance(address owner, address spender)](#allowance) +- [balanceOf(address owner)](#balanceof) +- [balanceOfUnderlying(address owner)](#balanceofunderlying) +- [getAccountSnapshot(address account)](#getaccountsnapshot) +- [borrowRatePerBlock()](#borrowrateperblock) +- [supplyRatePerBlock()](#supplyrateperblock) +- [totalBorrowsCurrent()](#totalborrowscurrent) +- [borrowBalanceCurrent(address account)](#borrowbalancecurrent) +- [borrowBalanceStored(address account)](#borrowbalancestored) +- [exchangeRateCurrent()](#exchangeratecurrent) +- [exchangeRateStored()](#exchangeratestored) +- [getCash()](#getcash) +- [accrueInterest()](#accrueinterest) +- [seize(address liquidator, address borrower, uint256 seizeTokens)](#seize) + +### transfer + +```js +function transfer(address dst, uint256 amount) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| dst | address | | +| amount | uint256 | | + +### transferFrom + +```js +function transferFrom(address src, address dst, uint256 amount) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| src | address | | +| dst | address | | +| amount | uint256 | | + +### approve + +```js +function approve(address spender, uint256 amount) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| spender | address | | +| amount | uint256 | | + +### allowance + +```js +function allowance(address owner, address spender) external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| owner | address | | +| spender | address | | + +### balanceOf + +```js +function balanceOf(address owner) external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| owner | address | | + +### balanceOfUnderlying + +```js +function balanceOfUnderlying(address owner) external nonpayable +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| owner | address | | + +### getAccountSnapshot + +```js +function getAccountSnapshot(address account) external view +returns(uint256, uint256, uint256, uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | + +### borrowRatePerBlock + +```js +function borrowRatePerBlock() external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### supplyRatePerBlock + +```js +function supplyRatePerBlock() external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### totalBorrowsCurrent + +```js +function totalBorrowsCurrent() external nonpayable +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### borrowBalanceCurrent + +```js +function borrowBalanceCurrent(address account) external nonpayable +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | + +### borrowBalanceStored + +```js +function borrowBalanceStored(address account) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | + +### exchangeRateCurrent + +```js +function exchangeRateCurrent() public nonpayable +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### exchangeRateStored + +```js +function exchangeRateStored() public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### getCash + +```js +function getCash() external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### accrueInterest + +```js +function accrueInterest() public nonpayable +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### seize + +```js +function seize(address liquidator, address borrower, uint256 seizeTokens) external nonpayable +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| liquidator | address | | +| borrower | address | | +| seizeTokens | uint256 | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/CompoundOracleInterface.md b/docs/CompoundOracleInterface.md new file mode 100644 index 0000000..43edc30 --- /dev/null +++ b/docs/CompoundOracleInterface.md @@ -0,0 +1,84 @@ +# CompoundOracleInterface.sol + +View Source: [contracts/lib/CompoundOracleInterface.sol](../contracts/lib/CompoundOracleInterface.sol) + +**CompoundOracleInterface** + +## Functions + +- [()](#) +- [getPrice(address asset)](#getprice) +- [getUnderlyingPrice(ERC20 cToken)](#getunderlyingprice) + +### + +```js +function () public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### getPrice + +retrieves price of an asset + +```js +function getPrice(address asset) public view +returns(uint256) +``` + +**Returns** + +uint mantissa of asset price (scaled by 1e18) or zero if unset or contract paused + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| asset | address | Asset for which to get the price | + +### getUnderlyingPrice + +```js +function getUnderlyingPrice(ERC20 cToken) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| cToken | ERC20 | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/Context.md b/docs/Context.md new file mode 100644 index 0000000..e68b57f --- /dev/null +++ b/docs/Context.md @@ -0,0 +1,78 @@ +# Context.sol + +View Source: [@openzeppelin/contracts/GSN/Context.sol](../@openzeppelin/contracts/GSN/Context.sol) + +**↘ Derived Contracts: [ERC20](ERC20.md), [MinterRole](MinterRole.md), [Ownable](Ownable.md)** + +**Context** + +## Functions + +- [()](#) +- [_msgSender()](#_msgsender) +- [_msgData()](#_msgdata) + +### + +```js +function () internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### _msgSender + +```js +function _msgSender() internal view +returns(address payable) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### _msgData + +```js +function _msgData() internal view +returns(bytes) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/Dai.md b/docs/Dai.md new file mode 100644 index 0000000..638023a --- /dev/null +++ b/docs/Dai.md @@ -0,0 +1,299 @@ +# Dai.sol + +View Source: [contracts/lib/Dai.sol](../contracts/lib/Dai.sol) + +**↗ Extends: [LibNote](LibNote.md)** + +**Dai** + +## Contract Members +**Constants & Variables** + +```js +mapping(address => uint256) public wards; +string public constant name; +string public constant symbol; +string public constant version; +uint8 public constant decimals; +uint256 public totalSupply; +mapping(address => uint256) public balanceOf; +mapping(address => mapping(address => uint256)) public allowance; +mapping(address => uint256) public nonces; +bytes32 public DOMAIN_SEPARATOR; +bytes32 public constant PERMIT_TYPEHASH; + +``` + +**Events** + +```js +event LogNote(bytes4 indexed sig, address indexed usr, bytes32 indexed arg1, bytes32 indexed arg2, bytes data); +event Approval(address indexed src, address indexed guy, uint256 wad); +event Transfer(address indexed src, address indexed dst, uint256 wad); +``` + +## Modifiers + +- [note](#note) +- [auth](#auth) + +### note + +```js +modifier note() internal +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### auth + +```js +modifier auth() internal +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Functions + +- [rely(address guy)](#rely) +- [deny(address guy)](#deny) +- [add(uint256 x, uint256 y)](#add) +- [sub(uint256 x, uint256 y)](#sub) +- [(uint256 chainId_)](#) +- [transfer(address dst, uint256 wad)](#transfer) +- [transferFrom(address src, address dst, uint256 wad)](#transferfrom) +- [mint(address usr, uint256 wad)](#mint) +- [burn(address usr, uint256 wad)](#burn) +- [approve(address usr, uint256 wad)](#approve) +- [push(address usr, uint256 wad)](#push) +- [pull(address usr, uint256 wad)](#pull) +- [move(address src, address dst, uint256 wad)](#move) +- [permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s)](#permit) + +### rely + +```js +function rely(address guy) external nonpayable note auth +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| guy | address | | + +### deny + +```js +function deny(address guy) external nonpayable note auth +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| guy | address | | + +### add + +```js +function add(uint256 x, uint256 y) internal pure +returns(z uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| x | uint256 | | +| y | uint256 | | + +### sub + +```js +function sub(uint256 x, uint256 y) internal pure +returns(z uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| x | uint256 | | +| y | uint256 | | + +### + +```js +function (uint256 chainId_) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| chainId_ | uint256 | | + +### transfer + +```js +function transfer(address dst, uint256 wad) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| dst | address | | +| wad | uint256 | | + +### transferFrom + +```js +function transferFrom(address src, address dst, uint256 wad) public nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| src | address | | +| dst | address | | +| wad | uint256 | | + +### mint + +```js +function mint(address usr, uint256 wad) external nonpayable auth +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### burn + +```js +function burn(address usr, uint256 wad) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### approve + +```js +function approve(address usr, uint256 wad) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### push + +```js +function push(address usr, uint256 wad) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### pull + +```js +function pull(address usr, uint256 wad) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### move + +```js +function move(address src, address dst, uint256 wad) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| src | address | | +| dst | address | | +| wad | uint256 | | + +### permit + +```js +function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| holder | address | | +| spender | address | | +| nonce | uint256 | | +| expiry | uint256 | | +| allowed | bool | | +| v | uint8 | | +| r | bytes32 | | +| s | bytes32 | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/ERC20.md b/docs/ERC20.md new file mode 100644 index 0000000..ef4ecb2 --- /dev/null +++ b/docs/ERC20.md @@ -0,0 +1,345 @@ +# ERC20.sol + +View Source: [@openzeppelin/contracts/token/ERC20/ERC20.sol](../@openzeppelin/contracts/token/ERC20/ERC20.sol) + +**↗ Extends: [Context](Context.md), [IERC20](IERC20.md)** +**↘ Derived Contracts: [ERC20Mintable](ERC20Mintable.md), [OptionsContract](OptionsContract.md)** + +**ERC20** + +Implementation of the {IERC20} interface. + * This implementation is agnostic to the way tokens are created. This means +that a supply mechanism has to be added in a derived contract using {_mint}. +For a generic mechanism see {ERC20Mintable}. + * TIP: For a detailed writeup see our guide +https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How +to implement supply mechanisms]. + * We have followed general OpenZeppelin guidelines: functions revert instead +of returning `false` on failure. This behavior is nonetheless conventional +and does not conflict with the expectations of ERC20 applications. + * Additionally, an {Approval} event is emitted on calls to {transferFrom}. +This allows applications to reconstruct the allowance for all accounts just +by listening to said events. Other implementations of the EIP may not emit +these events, as it isn't required by the specification. + * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} +functions have been added to mitigate the well-known issues around setting +allowances. See {IERC20-approve}. + +## Contract Members +**Constants & Variables** + +```js +mapping(address => uint256) private _balances; +mapping(address => mapping(address => uint256)) private _allowances; +uint256 private _totalSupply; + +``` + +## Functions + +- [totalSupply()](#totalsupply) +- [balanceOf(address account)](#balanceof) +- [transfer(address recipient, uint256 amount)](#transfer) +- [allowance(address owner, address spender)](#allowance) +- [approve(address spender, uint256 amount)](#approve) +- [transferFrom(address sender, address recipient, uint256 amount)](#transferfrom) +- [increaseAllowance(address spender, uint256 addedValue)](#increaseallowance) +- [decreaseAllowance(address spender, uint256 subtractedValue)](#decreaseallowance) +- [_transfer(address sender, address recipient, uint256 amount)](#_transfer) +- [_mint(address account, uint256 amount)](#_mint) +- [_burn(address account, uint256 amount)](#_burn) +- [_approve(address owner, address spender, uint256 amount)](#_approve) +- [_burnFrom(address account, uint256 amount)](#_burnfrom) + +### totalSupply + +⤾ overrides [IERC20.totalSupply](IERC20.md#totalsupply) + +See {IERC20-totalSupply}. + +```js +function totalSupply() public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### balanceOf + +⤾ overrides [IERC20.balanceOf](IERC20.md#balanceof) + +See {IERC20-balanceOf}. + +```js +function balanceOf(address account) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | + +### transfer + +⤾ overrides [IERC20.transfer](IERC20.md#transfer) + +See {IERC20-transfer}. + * Requirements: + * - `recipient` cannot be the zero address. +- the caller must have a balance of at least `amount`. + +```js +function transfer(address recipient, uint256 amount) public nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| recipient | address | | +| amount | uint256 | | + +### allowance + +⤾ overrides [IERC20.allowance](IERC20.md#allowance) + +See {IERC20-allowance}. + +```js +function allowance(address owner, address spender) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| owner | address | | +| spender | address | | + +### approve + +⤾ overrides [IERC20.approve](IERC20.md#approve) + +See {IERC20-approve}. + * Requirements: + * - `spender` cannot be the zero address. + +```js +function approve(address spender, uint256 amount) public nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| spender | address | | +| amount | uint256 | | + +### transferFrom + +⤾ overrides [IERC20.transferFrom](IERC20.md#transferfrom) + +See {IERC20-transferFrom}. + * Emits an {Approval} event indicating the updated allowance. This is not +required by the EIP. See the note at the beginning of {ERC20}; + * Requirements: +- `sender` and `recipient` cannot be the zero address. +- `sender` must have a balance of at least `amount`. +- the caller must have allowance for `sender`'s tokens of at least +`amount`. + +```js +function transferFrom(address sender, address recipient, uint256 amount) public nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| sender | address | | +| recipient | address | | +| amount | uint256 | | + +### increaseAllowance + +Atomically increases the allowance granted to `spender` by the caller. + * This is an alternative to {approve} that can be used as a mitigation for +problems described in {IERC20-approve}. + * Emits an {Approval} event indicating the updated allowance. + * Requirements: + * - `spender` cannot be the zero address. + +```js +function increaseAllowance(address spender, uint256 addedValue) public nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| spender | address | | +| addedValue | uint256 | | + +### decreaseAllowance + +Atomically decreases the allowance granted to `spender` by the caller. + * This is an alternative to {approve} that can be used as a mitigation for +problems described in {IERC20-approve}. + * Emits an {Approval} event indicating the updated allowance. + * Requirements: + * - `spender` cannot be the zero address. +- `spender` must have allowance for the caller of at least +`subtractedValue`. + +```js +function decreaseAllowance(address spender, uint256 subtractedValue) public nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| spender | address | | +| subtractedValue | uint256 | | + +### _transfer + +Moves tokens `amount` from `sender` to `recipient`. + * This is internal function is equivalent to {transfer}, and can be used to +e.g. implement automatic token fees, slashing mechanisms, etc. + * Emits a {Transfer} event. + * Requirements: + * - `sender` cannot be the zero address. +- `recipient` cannot be the zero address. +- `sender` must have a balance of at least `amount`. + +```js +function _transfer(address sender, address recipient, uint256 amount) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| sender | address | | +| recipient | address | | +| amount | uint256 | | + +### _mint + +Creates `amount` tokens and assigns them to `account`, increasing +the total supply. + * Emits a {Transfer} event with `from` set to the zero address. + * Requirements + * - `to` cannot be the zero address. + +```js +function _mint(address account, uint256 amount) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | +| amount | uint256 | | + +### _burn + +Destroys `amount` tokens from `account`, reducing the +total supply. + * Emits a {Transfer} event with `to` set to the zero address. + * Requirements + * - `account` cannot be the zero address. +- `account` must have at least `amount` tokens. + +```js +function _burn(address account, uint256 amount) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | +| amount | uint256 | | + +### _approve + +Sets `amount` as the allowance of `spender` over the `owner`s tokens. + * This is internal function is equivalent to `approve`, and can be used to +e.g. set automatic allowances for certain subsystems, etc. + * Emits an {Approval} event. + * Requirements: + * - `owner` cannot be the zero address. +- `spender` cannot be the zero address. + +```js +function _approve(address owner, address spender, uint256 amount) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| owner | address | | +| spender | address | | +| amount | uint256 | | + +### _burnFrom + +Destroys `amount` tokens from `account`.`amount` is then deducted +from the caller's allowance. + * See {_burn} and {_approve}. + +```js +function _burnFrom(address account, uint256 amount) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | +| amount | uint256 | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/ERC20Detailed.md b/docs/ERC20Detailed.md new file mode 100644 index 0000000..c3d97f6 --- /dev/null +++ b/docs/ERC20Detailed.md @@ -0,0 +1,124 @@ +# ERC20Detailed.sol + +View Source: [@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol](../@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol) + +**↗ Extends: [IERC20](IERC20.md)** + +**ERC20Detailed** + +Optional functions from the ERC20 standard. + +## Contract Members +**Constants & Variables** + +```js +string private _name; +string private _symbol; +uint8 private _decimals; + +``` + +## Functions + +- [(string name, string symbol, uint8 decimals)](#) +- [name()](#name) +- [symbol()](#symbol) +- [decimals()](#decimals) + +### + +Sets the values for `name`, `symbol`, and `decimals`. All three of +these values are immutable: they can only be set once during +construction. + +```js +function (string name, string symbol, uint8 decimals) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| name | string | | +| symbol | string | | +| decimals | uint8 | | + +### name + +Returns the name of the token. + +```js +function name() public view +returns(string) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### symbol + +Returns the symbol of the token, usually a shorter version of the +name. + +```js +function symbol() public view +returns(string) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### decimals + +Returns the number of decimals used to get its user representation. +For example, if `decimals` equals `2`, a balance of `505` tokens should +be displayed to a user as `5,05` (`505 / 10 ** 2`). + * Tokens usually opt for a value of 18, imitating the relationship between +Ether and Wei. + * NOTE: This information is only used for _display_ purposes: it in +no way affects any of the arithmetic of the contract, including +{IERC20-balanceOf} and {IERC20-transfer}. + +```js +function decimals() public view +returns(uint8) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/ERC20Mintable.md b/docs/ERC20Mintable.md new file mode 100644 index 0000000..c26e2b1 --- /dev/null +++ b/docs/ERC20Mintable.md @@ -0,0 +1,63 @@ +# ERC20Mintable.sol + +View Source: [@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol](../@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol) + +**↗ Extends: [ERC20](ERC20.md), [MinterRole](MinterRole.md)** + +**ERC20Mintable** + +Extension of {ERC20} that adds a set of accounts with the {MinterRole}, +which have permission to mint (create) new tokens as they see fit. + * At construction, the deployer of the contract is the only minter. + +## Functions + +- [mint(address account, uint256 amount)](#mint) + +### mint + +See {ERC20-_mint}. + * Requirements: + * - the caller must have the {MinterRole}. + +```js +function mint(address account, uint256 amount) public nonpayable onlyMinter +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | +| amount | uint256 | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/IERC20.md b/docs/IERC20.md new file mode 100644 index 0000000..1487a82 --- /dev/null +++ b/docs/IERC20.md @@ -0,0 +1,179 @@ +# IERC20.sol + +View Source: [@openzeppelin/contracts/token/ERC20/IERC20.sol](../@openzeppelin/contracts/token/ERC20/IERC20.sol) + +**↘ Derived Contracts: [ERC20](ERC20.md), [ERC20Detailed](ERC20Detailed.md)** + +**IERC20** + +Interface of the ERC20 standard as defined in the EIP. Does not include +the optional functions; to access them see {ERC20Detailed}. + +**Events** + +```js +event Transfer(address indexed from, address indexed to, uint256 value); +event Approval(address indexed owner, address indexed spender, uint256 value); +``` + +## Functions + +- [totalSupply()](#totalsupply) +- [balanceOf(address account)](#balanceof) +- [transfer(address recipient, uint256 amount)](#transfer) +- [allowance(address owner, address spender)](#allowance) +- [approve(address spender, uint256 amount)](#approve) +- [transferFrom(address sender, address recipient, uint256 amount)](#transferfrom) + +### totalSupply + +⤿ Overridden Implementation(s): [ERC20.totalSupply](ERC20.md#totalsupply) + +Returns the amount of tokens in existence. + +```js +function totalSupply() external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### balanceOf + +⤿ Overridden Implementation(s): [ERC20.balanceOf](ERC20.md#balanceof) + +Returns the amount of tokens owned by `account`. + +```js +function balanceOf(address account) external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | + +### transfer + +⤿ Overridden Implementation(s): [ERC20.transfer](ERC20.md#transfer) + +Moves `amount` tokens from the caller's account to `recipient`. + * Returns a boolean value indicating whether the operation succeeded. + * Emits a {Transfer} event. + +```js +function transfer(address recipient, uint256 amount) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| recipient | address | | +| amount | uint256 | | + +### allowance + +⤿ Overridden Implementation(s): [ERC20.allowance](ERC20.md#allowance) + +Returns the remaining number of tokens that `spender` will be +allowed to spend on behalf of `owner` through {transferFrom}. This is +zero by default. + * This value changes when {approve} or {transferFrom} are called. + +```js +function allowance(address owner, address spender) external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| owner | address | | +| spender | address | | + +### approve + +⤿ Overridden Implementation(s): [ERC20.approve](ERC20.md#approve) + +Sets `amount` as the allowance of `spender` over the caller's tokens. + * Returns a boolean value indicating whether the operation succeeded. + * IMPORTANT: Beware that changing an allowance with this method brings the risk +that someone may use both the old and the new allowance by unfortunate +transaction ordering. One possible solution to mitigate this race +condition is to first reduce the spender's allowance to 0 and set the +desired value afterwards: +https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + * Emits an {Approval} event. + +```js +function approve(address spender, uint256 amount) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| spender | address | | +| amount | uint256 | | + +### transferFrom + +⤿ Overridden Implementation(s): [ERC20.transferFrom](ERC20.md#transferfrom) + +Moves `amount` tokens from `sender` to `recipient` using the +allowance mechanism. `amount` is then deducted from the caller's +allowance. + * Returns a boolean value indicating whether the operation succeeded. + * Emits a {Transfer} event. + +```js +function transferFrom(address sender, address recipient, uint256 amount) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| sender | address | | +| recipient | address | | +| amount | uint256 | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/IOptionsExchange.md b/docs/IOptionsExchange.md new file mode 100644 index 0000000..024b0c3 --- /dev/null +++ b/docs/IOptionsExchange.md @@ -0,0 +1,56 @@ +# Options Exchange interface (IOptionsExchange.sol) + +View Source: [contracts/interfaces/IOptionsExchange.sol](../contracts/interfaces/IOptionsExchange.sol) + +**IOptionsExchange** + +## Functions + +- [sellOTokens(address payable receiver, address oTokenAddress, address payoutTokenAddress, uint256 oTokensToSell)](#sellotokens) + +### sellOTokens + +This function sells oTokens on Uniswap and sends back payoutTokens to the receiver + +```js +function sellOTokens(address payable receiver, address oTokenAddress, address payoutTokenAddress, uint256 oTokensToSell) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| receiver | address payable | The address to send the payout tokens back to | +| oTokenAddress | address | The address of the oToken to sell | +| payoutTokenAddress | address | The address of the token to receive the premiums in | +| oTokensToSell | uint256 | The number of oTokens to sell | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/LibNote.md b/docs/LibNote.md new file mode 100644 index 0000000..20242b8 --- /dev/null +++ b/docs/LibNote.md @@ -0,0 +1,300 @@ +# LibNote.sol + +View Source: [contracts/lib/Dai.sol](../contracts/lib/Dai.sol) + +**↗ Extends: [LibNote](LibNote.md)** +**↘ Derived Contracts: [Dai](Dai.md), [LibNote](LibNote.md)** + +**LibNote** + +## Contract Members +**Constants & Variables** + +```js +mapping(address => uint256) public wards; +string public constant name; +string public constant symbol; +string public constant version; +uint8 public constant decimals; +uint256 public totalSupply; +mapping(address => uint256) public balanceOf; +mapping(address => mapping(address => uint256)) public allowance; +mapping(address => uint256) public nonces; +bytes32 public DOMAIN_SEPARATOR; +bytes32 public constant PERMIT_TYPEHASH; + +``` + +**Events** + +```js +event LogNote(bytes4 indexed sig, address indexed usr, bytes32 indexed arg1, bytes32 indexed arg2, bytes data); +event Approval(address indexed src, address indexed guy, uint256 wad); +event Transfer(address indexed src, address indexed dst, uint256 wad); +``` + +## Modifiers + +- [note](#note) +- [auth](#auth) + +### note + +```js +modifier note() internal +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### auth + +```js +modifier auth() internal +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Functions + +- [rely(address guy)](#rely) +- [deny(address guy)](#deny) +- [add(uint256 x, uint256 y)](#add) +- [sub(uint256 x, uint256 y)](#sub) +- [(uint256 chainId_)](#) +- [transfer(address dst, uint256 wad)](#transfer) +- [transferFrom(address src, address dst, uint256 wad)](#transferfrom) +- [mint(address usr, uint256 wad)](#mint) +- [burn(address usr, uint256 wad)](#burn) +- [approve(address usr, uint256 wad)](#approve) +- [push(address usr, uint256 wad)](#push) +- [pull(address usr, uint256 wad)](#pull) +- [move(address src, address dst, uint256 wad)](#move) +- [permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s)](#permit) + +### rely + +```js +function rely(address guy) external nonpayable note auth +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| guy | address | | + +### deny + +```js +function deny(address guy) external nonpayable note auth +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| guy | address | | + +### add + +```js +function add(uint256 x, uint256 y) internal pure +returns(z uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| x | uint256 | | +| y | uint256 | | + +### sub + +```js +function sub(uint256 x, uint256 y) internal pure +returns(z uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| x | uint256 | | +| y | uint256 | | + +### + +```js +function (uint256 chainId_) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| chainId_ | uint256 | | + +### transfer + +```js +function transfer(address dst, uint256 wad) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| dst | address | | +| wad | uint256 | | + +### transferFrom + +```js +function transferFrom(address src, address dst, uint256 wad) public nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| src | address | | +| dst | address | | +| wad | uint256 | | + +### mint + +```js +function mint(address usr, uint256 wad) external nonpayable auth +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### burn + +```js +function burn(address usr, uint256 wad) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### approve + +```js +function approve(address usr, uint256 wad) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### push + +```js +function push(address usr, uint256 wad) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### pull + +```js +function pull(address usr, uint256 wad) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| usr | address | | +| wad | uint256 | | + +### move + +```js +function move(address src, address dst, uint256 wad) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| src | address | | +| dst | address | | +| wad | uint256 | | + +### permit + +```js +function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| holder | address | | +| spender | address | | +| nonce | uint256 | | +| expiry | uint256 | | +| allowed | bool | | +| v | uint8 | | +| r | bytes32 | | +| s | bytes32 | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/Migrations.md b/docs/Migrations.md new file mode 100644 index 0000000..42bf8ff --- /dev/null +++ b/docs/Migrations.md @@ -0,0 +1,100 @@ +# Migrations.sol + +View Source: [contracts/Migrations.sol](../contracts/Migrations.sol) + +**Migrations** + +## Contract Members +**Constants & Variables** + +```js +address public owner; +uint256 public last_completed_migration; + +``` + +## Modifiers + +- [restricted](#restricted) + +### restricted + +```js +modifier restricted() internal +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Functions + +- [()](#) +- [setCompleted(uint256 completed)](#setcompleted) +- [upgrade(address new_address)](#upgrade) + +### + +```js +function () public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### setCompleted + +```js +function setCompleted(uint256 completed) public nonpayable restricted +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| completed | uint256 | | + +### upgrade + +```js +function upgrade(address new_address) public nonpayable restricted +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| new_address | address | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/MinterRole.md b/docs/MinterRole.md new file mode 100644 index 0000000..4e0a035 --- /dev/null +++ b/docs/MinterRole.md @@ -0,0 +1,148 @@ +# MinterRole.sol + +View Source: [@openzeppelin/contracts/access/roles/MinterRole.sol](../@openzeppelin/contracts/access/roles/MinterRole.sol) + +**↗ Extends: [Context](Context.md)** +**↘ Derived Contracts: [ERC20Mintable](ERC20Mintable.md)** + +**MinterRole** + +## Contract Members +**Constants & Variables** + +```js +struct Roles.Role private _minters; + +``` + +**Events** + +```js +event MinterAdded(address indexed account); +event MinterRemoved(address indexed account); +``` + +## Modifiers + +- [onlyMinter](#onlyminter) + +### onlyMinter + +```js +modifier onlyMinter() internal +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Functions + +- [()](#) +- [isMinter(address account)](#isminter) +- [addMinter(address account)](#addminter) +- [renounceMinter()](#renounceminter) +- [_addMinter(address account)](#_addminter) +- [_removeMinter(address account)](#_removeminter) + +### + +```js +function () internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### isMinter + +```js +function isMinter(address account) public view +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | + +### addMinter + +```js +function addMinter(address account) public nonpayable onlyMinter +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | + +### renounceMinter + +```js +function renounceMinter() public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### _addMinter + +```js +function _addMinter(address account) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | + +### _removeMinter + +```js +function _removeMinter(address account) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| account | address | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/MockCompoundOracle.md b/docs/MockCompoundOracle.md new file mode 100644 index 0000000..2a35abf --- /dev/null +++ b/docs/MockCompoundOracle.md @@ -0,0 +1,85 @@ +# MockCompoundOracle.sol + +View Source: [contracts/lib/MockCompoundOracle.sol](../contracts/lib/MockCompoundOracle.sol) + +**MockCompoundOracle** + +## Contract Members +**Constants & Variables** + +```js +uint256 internal price; + +``` + +## Functions + +- [()](#) +- [getPrice(address asset)](#getprice) +- [updatePrice(uint256 newPrice)](#updateprice) + +### + +```js +function () public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### getPrice + +```js +function getPrice(address asset) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| asset | address | | + +### updatePrice + +```js +function updatePrice(uint256 newPrice) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| newPrice | uint256 | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/MockUniswapFactory.md b/docs/MockUniswapFactory.md new file mode 100644 index 0000000..d282835 --- /dev/null +++ b/docs/MockUniswapFactory.md @@ -0,0 +1,128 @@ +# MockUniswapFactory.sol + +View Source: [contracts/lib/MockUniswapFactory.sol](../contracts/lib/MockUniswapFactory.sol) + +**MockUniswapFactory** + +## Contract Members +**Constants & Variables** + +```js +address public exchangeTemplate; +uint256 public tokenCount; + +``` + +## Functions + +- [()](#) +- [createExchange(address token)](#createexchange) +- [getExchange(address token)](#getexchange) +- [getToken(address exchange)](#gettoken) +- [getTokenWithId(uint256 tokenId)](#gettokenwithid) +- [initializeFactory(address template)](#initializefactory) + +### + +```js +function () public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### createExchange + +```js +function createExchange(address token) external nonpayable +returns(exchange address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| token | address | | + +### getExchange + +```js +function getExchange(address token) external view +returns(exchange address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| token | address | | + +### getToken + +```js +function getToken(address exchange) external view +returns(token address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| exchange | address | | + +### getTokenWithId + +```js +function getTokenWithId(uint256 tokenId) external view +returns(token address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokenId | uint256 | | + +### initializeFactory + +```js +function initializeFactory(address template) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| template | address | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/OptionsContract.md b/docs/OptionsContract.md new file mode 100644 index 0000000..4160242 --- /dev/null +++ b/docs/OptionsContract.md @@ -0,0 +1,739 @@ +# Opyn's Options Contract (OptionsContract.sol) + +View Source: [contracts/OptionsContract.sol](../contracts/OptionsContract.sol) + +**↗ Extends: [Ownable](Ownable.md), [ERC20](ERC20.md)** +**↘ Derived Contracts: [oToken](oToken.md)** + +**OptionsContract** + +## Structs +### Number + +```js +struct Number { + uint256 value, + int32 exponent +} +``` + +### Vault + +```js +struct Vault { + uint256 collateral, + uint256 oTokensIssued, + uint256 underlying, + bool owned +} +``` + +## Contract Members +**Constants & Variables** + +```js +//public members +contract OptionsExchange public optionsExchange; +address payable[] public vaultOwners; +struct OptionsContract.Number public liquidationIncentive; +struct OptionsContract.Number public transactionFee; +struct OptionsContract.Number public liquidationFactor; +struct OptionsContract.Number public minCollateralizationRatio; +struct OptionsContract.Number public strikePrice; +struct OptionsContract.Number public oTokenExchangeRate; +uint256 public expiry; +int32 public collateralExp; +int32 public underlyingExp; +contract IERC20 public collateral; +contract IERC20 public underlying; +contract IERC20 public strike; +contract CompoundOracleInterface public COMPOUND_ORACLE; +string public name; +string public symbol; +uint8 public decimals; + +//internal members +mapping(address => struct OptionsContract.Vault) internal vaults; +uint256 internal windowSize; +uint256 internal totalFee; + +``` + +**Events** + +```js +event VaultOpened(address payable vaultOwner); +event ETHCollateralAdded(address payable vaultOwner, uint256 amount, address payer); +event ERC20CollateralAdded(address payable vaultOwner, uint256 amount, address payer); +event IssuedOTokens(address issuedTo, uint256 oTokensIssued, address payable vaultOwner); +event Liquidate(uint256 amtCollateralToPay, address payable vaultOwner, address payable liquidator); +event Exercise(uint256 amtUnderlyingToPay, uint256 amtCollateralToPay, address payable exerciser, address payable vaultExercisedFrom); +event RedeemVaultBalance(uint256 amtCollateralRedeemed, uint256 amtUnderlyingRedeemed, address payable vaultOwner); +event BurnOTokens(address payable vaultOwner, uint256 oTokensBurned); +event RemoveCollateral(uint256 amtRemoved, address payable vaultOwner); +event UpdateParameters(uint256 liquidationIncentive, uint256 liquidationFactor, uint256 transactionFee, uint256 minCollateralizationRatio, address owner); +event TransferFee(address payable to, uint256 fees); +event RemoveUnderlying(uint256 amountUnderlying, address payable vaultOwner); +``` + +## Modifiers + +- [notExpired](#notexpired) + +### notExpired + +Throws if called Options contract is expired. + +```js +modifier notExpired() internal +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Functions + +- [(IERC20 _collateral, int32 _collExp, IERC20 _underlying, int32 _underlyingExp, int32 _oTokenExchangeExp, uint256 _strikePrice, int32 _strikeExp, IERC20 _strike, uint256 _expiry, OptionsExchange _optionsExchange, address _oracleAddress, uint256 _windowSize)](#) +- [getVaultOwnersLength()](#getvaultownerslength) +- [updateParameters(uint256 _liquidationIncentive, uint256 _liquidationFactor, uint256 _transactionFee, uint256 _minCollateralizationRatio)](#updateparameters) +- [setDetails(string _name, string _symbol)](#setdetails) +- [transferFee(address payable _address)](#transferfee) +- [hasVault(address payable owner)](#hasvault) +- [openVault()](#openvault) +- [addETHCollateral(address payable vaultOwner)](#addethcollateral) +- [addERC20Collateral(address payable vaultOwner, uint256 amt)](#adderc20collateral) +- [underlyingRequiredToExercise(uint256 oTokensToExercise)](#underlyingrequiredtoexercise) +- [isExerciseWindow()](#isexercisewindow) +- [hasExpired()](#hasexpired) +- [exercise(uint256 oTokensToExercise, address payable[] vaultsToExerciseFrom)](#exercise) +- [removeUnderlying()](#removeunderlying) +- [issueOTokens(uint256 oTokensToIssue, address receiver)](#issueotokens) +- [getVault(address payable vaultOwner)](#getvault) +- [isETH(IERC20 _ierc20)](#iseth) +- [burnOTokens(uint256 amtToBurn)](#burnotokens) +- [removeCollateral(uint256 amtToRemove)](#removecollateral) +- [redeemVaultBalance()](#redeemvaultbalance) +- [maxOTokensLiquidatable(address payable vaultOwner)](#maxotokensliquidatable) +- [liquidate(address payable vaultOwner, uint256 oTokensToLiquidate)](#liquidate) +- [isUnsafe(address payable vaultOwner)](#isunsafe) +- [isWithinExponentRange(int32 val)](#iswithinexponentrange) +- [getCollateral(address payable vaultOwner)](#getcollateral) +- [getOTokensIssued(address payable vaultOwner)](#getotokensissued) +- [_exercise(uint256 oTokensToExercise, address payable vaultToExerciseFrom)](#_exercise) +- [_addCollateral(address payable vaultOwner, uint256 amt)](#_addcollateral) +- [isSafe(uint256 collateralAmt, uint256 oTokensIssued)](#issafe) +- [maxOTokensIssuable(uint256 collateralAmt)](#maxotokensissuable) +- [calculateOTokens(uint256 collateralAmt, struct OptionsContract.Number proportion)](#calculateotokens) +- [calculateCollateralToPay(uint256 _oTokens, struct OptionsContract.Number proportion)](#calculatecollateraltopay) +- [transferCollateral(address payable _addr, uint256 _amt)](#transfercollateral) +- [transferUnderlying(address payable _addr, uint256 _amt)](#transferunderlying) +- [getPrice(address asset)](#getprice) + +### + +```js +function (IERC20 _collateral, int32 _collExp, IERC20 _underlying, int32 _underlyingExp, int32 _oTokenExchangeExp, uint256 _strikePrice, int32 _strikeExp, IERC20 _strike, uint256 _expiry, OptionsExchange _optionsExchange, address _oracleAddress, uint256 _windowSize) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _collateral | IERC20 | The collateral asset | +| _collExp | int32 | The precision of the collateral (-18 if ETH) | +| _underlying | IERC20 | The asset that is being protected | +| _underlyingExp | int32 | The precision of the underlying asset | +| _oTokenExchangeExp | int32 | The precision of the `amount of underlying` that 1 oToken protects | +| _strikePrice | uint256 | The amount of strike asset that will be paid out per oToken | +| _strikeExp | int32 | The precision of the strike price. | +| _strike | IERC20 | Price The amount of strike asset that will be paid out per oToken | +| _expiry | uint256 | The time at which the insurance expires | +| _optionsExchange | OptionsExchange | The contract which interfaces with the exchange + oracle | +| _oracleAddress | address | The address of the oracle | +| _windowSize | uint256 | UNIX time. Exercise window is from `expiry - _windowSize` to `expiry`. | + +### getVaultOwnersLength + +This function gets the length of vaultOwners array + +```js +function getVaultOwnersLength() public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### updateParameters + +Can only be called by owner. Used to update the fees, minminCollateralizationRatio, etc + +```js +function updateParameters(uint256 _liquidationIncentive, uint256 _liquidationFactor, uint256 _transactionFee, uint256 _minCollateralizationRatio) public nonpayable onlyOwner +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _liquidationIncentive | uint256 | The incentive paid to liquidator. 10 is 0.01 i.e. 1% incentive. | +| _liquidationFactor | uint256 | Max amount that a Vault can be liquidated by. 500 is 0.5. | +| _transactionFee | uint256 | The fees paid to our protocol every time a execution happens. 100 is egs. 0.1 i.e. 10%. | +| _minCollateralizationRatio | uint256 | The minimum ratio of a Vault's collateral to insurance promised. 16 means 1.6. | + +### setDetails + +Can only be called by owner. Used to set the name, symbol and decimals of the contract + +```js +function setDetails(string _name, string _symbol) public nonpayable onlyOwner +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _name | string | The name of the contract | +| _symbol | string | The symbol of the contract | + +### transferFee + +Can only be called by owner. Used to take out the protocol fees from the contract. + +```js +function transferFee(address payable _address) public nonpayable onlyOwner +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _address | address payable | The address to send the fee to. | + +### hasVault + +Checks if a `owner` has already created a Vault + +```js +function hasVault(address payable owner) public view +returns(bool) +``` + +**Returns** + +true or false + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| owner | address payable | The address of the supposed owner | + +### openVault + +Creates a new empty Vault and sets the owner of the vault to be the msg.sender. + +```js +function openVault() public nonpayable notExpired +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### addETHCollateral + +If the collateral type is ETH, anyone can call this function any time before +expiry to increase the amount of collateral in a Vault. Will fail if ETH is not the +collateral asset. +Remember that adding ETH collateral even if no oTokens have been created can put the owner at a +risk of losing the collateral if an exercise event happens. +Ensure that you issue and immediately sell oTokens to allow the owner to earn premiums. +(Either call the createAndSell function in the oToken contract or batch the +addERC20Collateral, issueOTokens and sell transactions and ensure they happen atomically to protect +the end user). + +```js +function addETHCollateral(address payable vaultOwner) public payable notExpired +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| vaultOwner | address payable | the index of the Vault to which collateral will be added. | + +### addERC20Collateral + +If the collateral type is any ERC20, anyone can call this function any time before +expiry to increase the amount of collateral in a Vault. Can only transfer in the collateral asset. +Will fail if ETH is the collateral asset. +The user has to allow the contract to handle their ERC20 tokens on his behalf before these +functions are called. +Remember that adding ERC20 collateral even if no oTokens have been created can put the owner at a +risk of losing the collateral. Ensure that you issue and immediately sell the oTokens! +(Either call the createAndSell function in the oToken contract or batch the +addERC20Collateral, issueOTokens and sell transactions and ensure they happen atomically to protect +the end user). + +```js +function addERC20Collateral(address payable vaultOwner, uint256 amt) public nonpayable notExpired +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| vaultOwner | address payable | the index of the Vault to which collateral will be added. | +| amt | uint256 | the amount of collateral to be transferred in. | + +### underlyingRequiredToExercise + +Returns the amount of underlying to be transferred during an exercise call + +```js +function underlyingRequiredToExercise(uint256 oTokensToExercise) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| oTokensToExercise | uint256 | | + +### isExerciseWindow + +Returns true if exercise can be called + +```js +function isExerciseWindow() public view +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### hasExpired + +Returns true if the oToken contract has expired + +```js +function hasExpired() public view +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### exercise + +Called by anyone holding the oTokens and underlying during the +exercise window i.e. from `expiry - windowSize` time to `expiry` time. The caller +transfers in their oTokens and corresponding amount of underlying and gets +`strikePrice * oTokens` amount of collateral out. The collateral paid out is taken from +the each vault owner starting with the first and iterating until the oTokens to exercise +are found. +NOTE: This uses a for loop and hence could run out of gas if the array passed in is too big! + +```js +function exercise(uint256 oTokensToExercise, address payable[] vaultsToExerciseFrom) public payable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| oTokensToExercise | uint256 | the number of oTokens being exercised. | +| vaultsToExerciseFrom | address payable[] | the array of vaults to exercise from. | + +### removeUnderlying + +This function allows the vault owner to remove their share of underlying after an exercise + +```js +function removeUnderlying() public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### issueOTokens + +This function is called to issue the option tokens. Remember that issuing oTokens even if they +haven't been sold can put the owner at a risk of not making premiums on the oTokens. Ensure that you +issue and immidiately sell the oTokens! (Either call the createAndSell function in the oToken contract +of batch the issueOTokens transaction with a sell transaction and ensure it happens atomically). + +```js +function issueOTokens(uint256 oTokensToIssue, address receiver) public nonpayable notExpired +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| oTokensToIssue | uint256 | The number of o tokens to issue | +| receiver | address | The address to send the oTokens to | + +### getVault + +Returns the vault for a given address + +```js +function getVault(address payable vaultOwner) public view +returns(uint256, uint256, uint256, bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| vaultOwner | address payable | the owner of the Vault to return | + +### isETH + +Returns true if the given ERC20 is ETH. + +```js +function isETH(IERC20 _ierc20) public pure +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _ierc20 | IERC20 | the ERC20 asset. | + +### burnOTokens + +allows the owner to burn their oTokens to increase the collateralization ratio of +their vault. + +```js +function burnOTokens(uint256 amtToBurn) public nonpayable notExpired +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToBurn | uint256 | number of oTokens to burn | + +### removeCollateral + +allows the owner to remove excess collateral from the vault before expiry. Removing collateral lowers +the collateralization ratio of the vault. + +```js +function removeCollateral(uint256 amtToRemove) public nonpayable notExpired +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToRemove | uint256 | Amount of collateral to remove in 10^-18. | + +### redeemVaultBalance + +after expiry, each vault holder can get back their proportional share of collateral +from vaults that they own. + +```js +function redeemVaultBalance() public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### maxOTokensLiquidatable + +```js +function maxOTokensLiquidatable(address payable vaultOwner) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| vaultOwner | address payable | The index of the vault to be liquidated | + +### liquidate + +This function can be called by anyone who notices a vault is undercollateralized. +The caller gets a reward for reducing the amount of oTokens in circulation. + +```js +function liquidate(address payable vaultOwner, uint256 oTokensToLiquidate) public nonpayable notExpired +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| vaultOwner | address payable | The index of the vault to be liquidated | +| oTokensToLiquidate | uint256 | The number of oTokens being taken out of circulation | + +### isUnsafe + +checks if a vault is unsafe. If so, it can be liquidated + +```js +function isUnsafe(address payable vaultOwner) public view +returns(bool) +``` + +**Returns** + +true or false + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| vaultOwner | address payable | The number of the vault to check | + +### isWithinExponentRange + +This function returns if an -30 <= exponent <= 30 + +```js +function isWithinExponentRange(int32 val) internal pure +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| val | int32 | | + +### getCollateral + +This function calculates and returns the amount of collateral in the vault + +```js +function getCollateral(address payable vaultOwner) internal view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| vaultOwner | address payable | | + +### getOTokensIssued + +This function calculates and returns the amount of puts issued by the Vault + +```js +function getOTokensIssued(address payable vaultOwner) internal view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| vaultOwner | address payable | | + +### _exercise + +Called by anyone holding the oTokens and underlying during the +exercise window i.e. from `expiry - windowSize` time to `expiry` time. The caller +transfers in their oTokens and corresponding amount of underlying and gets +`strikePrice * oTokens` amount of collateral out. The collateral paid out is taken from +the specified vault holder. At the end of the expiry window, the vault holder can redeem their balance +of collateral. The vault owner can withdraw their underlying at any time. +The user has to allow the contract to handle their oTokens and underlying on his behalf before these functions are called. + +```js +function _exercise(uint256 oTokensToExercise, address payable vaultToExerciseFrom) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| oTokensToExercise | uint256 | the number of oTokens being exercised. | +| vaultToExerciseFrom | address payable | the address of the vaultOwner to take collateral from. | + +### _addCollateral + +adds `_amt` collateral to `vaultOwner` and returns the new balance of the vault + +```js +function _addCollateral(address payable vaultOwner, uint256 amt) internal nonpayable notExpired +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| vaultOwner | address payable | the index of the vault | +| amt | uint256 | the amount of collateral to add | + +### isSafe + +checks if a hypothetical vault is safe with the given collateralAmt and oTokensIssued + +```js +function isSafe(uint256 collateralAmt, uint256 oTokensIssued) internal view +returns(bool) +``` + +**Returns** + +true or false + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| collateralAmt | uint256 | The amount of collateral the hypothetical vault has | +| oTokensIssued | uint256 | The amount of oTokens generated by the hypothetical vault | + +### maxOTokensIssuable + +```js +function maxOTokensIssuable(uint256 collateralAmt) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| collateralAmt | uint256 | The amount of collateral against which oTokens will be issued. | + +### calculateOTokens + +This function is used to calculate the amount of tokens that can be issued. + +```js +function calculateOTokens(uint256 collateralAmt, struct OptionsContract.Number proportion) internal view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| collateralAmt | uint256 | The amount of collateral | +| proportion | struct OptionsContract.Number | The proportion of the collateral to pay out. If 100% of collateral +should be paid out, pass in Number(1, 0). The proportion might be less than 100% if +you are calculating fees. | + +### calculateCollateralToPay + +This function calculates the amount of collateral to be paid out. + +```js +function calculateCollateralToPay(uint256 _oTokens, struct OptionsContract.Number proportion) internal view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _oTokens | uint256 | The number of oTokens. | +| proportion | struct OptionsContract.Number | The proportion of the collateral to pay out. If 100% of collateral +should be paid out, pass in Number(1, 0). The proportion might be less than 100% if +you are calculating fees. | + +### transferCollateral + +This function transfers `amt` collateral to `_addr` + +```js +function transferCollateral(address payable _addr, uint256 _amt) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _addr | address payable | The address to send the collateral to | +| _amt | uint256 | The amount of the collateral to pay out. | + +### transferUnderlying + +This function transfers `amt` underlying to `_addr` + +```js +function transferUnderlying(address payable _addr, uint256 _amt) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _addr | address payable | The address to send the underlying to | +| _amt | uint256 | The amount of the underlying to pay out. | + +### getPrice + +This function gets the price ETH (wei) to asset price. + +```js +function getPrice(address asset) internal view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| asset | address | The address of the asset to get the price of | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/OptionsExchange.md b/docs/OptionsExchange.md new file mode 100644 index 0000000..b678341 --- /dev/null +++ b/docs/OptionsExchange.md @@ -0,0 +1,219 @@ +# OptionsExchange.sol + +View Source: [contracts/OptionsExchange.sol](../contracts/OptionsExchange.sol) + +**OptionsExchange** + +## Contract Members +**Constants & Variables** + +```js +//internal members +uint256 internal constant LARGE_BLOCK_SIZE; +uint256 internal constant LARGE_APPROVAL_NUMBER; + +//public members +contract UniswapFactoryInterface public UNISWAP_FACTORY; + +``` + +**Events** + +```js +event SellOTokens(address seller, address payable receiver, address oTokenAddress, address payoutTokenAddress, uint256 oTokensToSell, uint256 payoutTokensReceived); +event BuyOTokens(address buyer, address payable receiver, address oTokenAddress, address paymentTokenAddress, uint256 oTokensToBuy, uint256 premiumPaid); +``` + +## Functions + +- [(address _uniswapFactory)](#) +- [sellOTokens(address payable receiver, address oTokenAddress, address payoutTokenAddress, uint256 oTokensToSell)](#sellotokens) +- [buyOTokens(address payable receiver, address oTokenAddress, address paymentTokenAddress, uint256 oTokensToBuy)](#buyotokens) +- [premiumReceived(address oTokenAddress, address payoutTokenAddress, uint256 oTokensToSell)](#premiumreceived) +- [premiumToPay(address oTokenAddress, address paymentTokenAddress, uint256 oTokensToBuy)](#premiumtopay) +- [uniswapSellOToken(IERC20 oToken, IERC20 payoutToken, uint256 _amt, address payable _transferTo)](#uniswapsellotoken) +- [uniswapBuyOToken(IERC20 paymentToken, IERC20 oToken, uint256 _amt, address payable _transferTo)](#uniswapbuyotoken) +- [getExchange(address _token)](#getexchange) +- [isETH(IERC20 _ierc20)](#iseth) +- [()](#) + +### + +```js +function (address _uniswapFactory) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _uniswapFactory | address | | + +### sellOTokens + +This function sells oTokens on Uniswap and sends back payoutTokens to the receiver + +```js +function sellOTokens(address payable receiver, address oTokenAddress, address payoutTokenAddress, uint256 oTokensToSell) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| receiver | address payable | The address to send the payout tokens back to | +| oTokenAddress | address | The address of the oToken to sell | +| payoutTokenAddress | address | The address of the token to receive the premiums in | +| oTokensToSell | uint256 | The number of oTokens to sell | + +### buyOTokens + +This function buys oTokens on Uniswap and using paymentTokens from the receiver + +```js +function buyOTokens(address payable receiver, address oTokenAddress, address paymentTokenAddress, uint256 oTokensToBuy) public payable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| receiver | address payable | The address to send the oTokens back to | +| oTokenAddress | address | The address of the oToken to buy | +| paymentTokenAddress | address | The address of the token to pay the premiums in | +| oTokensToBuy | uint256 | The number of oTokens to buy | + +### premiumReceived + +This function calculates the amount of premiums that the seller +will receive if they sold oTokens on Uniswap + +```js +function premiumReceived(address oTokenAddress, address payoutTokenAddress, uint256 oTokensToSell) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| oTokenAddress | address | The address of the oToken to sell | +| payoutTokenAddress | address | The address of the token to receive the premiums in | +| oTokensToSell | uint256 | The number of oTokens to sell | + +### premiumToPay + +This function calculates the premiums to be paid if a buyer wants to +buy oTokens on Uniswap + +```js +function premiumToPay(address oTokenAddress, address paymentTokenAddress, uint256 oTokensToBuy) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| oTokenAddress | address | The address of the oToken to buy | +| paymentTokenAddress | address | The address of the token to pay the premiums in | +| oTokensToBuy | uint256 | The number of oTokens to buy | + +### uniswapSellOToken + +```js +function uniswapSellOToken(IERC20 oToken, IERC20 payoutToken, uint256 _amt, address payable _transferTo) internal nonpayable +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| oToken | IERC20 | | +| payoutToken | IERC20 | | +| _amt | uint256 | | +| _transferTo | address payable | | + +### uniswapBuyOToken + +```js +function uniswapBuyOToken(IERC20 paymentToken, IERC20 oToken, uint256 _amt, address payable _transferTo) public nonpayable +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| paymentToken | IERC20 | | +| oToken | IERC20 | | +| _amt | uint256 | | +| _transferTo | address payable | | + +### getExchange + +```js +function getExchange(address _token) internal view +returns(contract UniswapExchangeInterface) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _token | address | | + +### isETH + +```js +function isETH(IERC20 _ierc20) internal pure +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _ierc20 | IERC20 | | + +### + +```js +function () external payable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/OptionsFactory.md b/docs/OptionsFactory.md new file mode 100644 index 0000000..9d120af --- /dev/null +++ b/docs/OptionsFactory.md @@ -0,0 +1,177 @@ +# OptionsFactory.sol + +View Source: [contracts/OptionsFactory.sol](../contracts/OptionsFactory.sol) + +**↗ Extends: [Ownable](Ownable.md)** + +**OptionsFactory** + +## Contract Members +**Constants & Variables** + +```js +mapping(string => contract IERC20) public tokens; +address[] public optionsContracts; +contract OptionsExchange public optionsExchange; +address public oracleAddress; + +``` + +**Events** + +```js +event OptionsContractCreated(address addr); +event AssetAdded(string indexed asset, address indexed addr); +event AssetChanged(string indexed asset, address indexed addr); +event AssetDeleted(string indexed asset); +``` + +## Functions + +- [(OptionsExchange _optionsExchangeAddr, address _oracleAddress)](#) +- [createOptionsContract(string _collateralType, int32 _collateralExp, string _underlyingType, int32 _underlyingExp, int32 _oTokenExchangeExp, uint256 _strikePrice, int32 _strikeExp, string _strikeAsset, uint256 _expiry, uint256 _windowSize)](#createoptionscontract) +- [getNumberOfOptionsContracts()](#getnumberofoptionscontracts) +- [addAsset(string _asset, address _addr)](#addasset) +- [changeAsset(string _asset, address _addr)](#changeasset) +- [deleteAsset(string _asset)](#deleteasset) +- [supportsAsset(string _asset)](#supportsasset) + +### + +```js +function (OptionsExchange _optionsExchangeAddr, address _oracleAddress) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _optionsExchangeAddr | OptionsExchange | : The contract which interfaces with the exchange | +| _oracleAddress | address | Address of the oracle | + +### createOptionsContract + +creates a new Option Contract + +```js +function createOptionsContract(string _collateralType, int32 _collateralExp, string _underlyingType, int32 _underlyingExp, int32 _oTokenExchangeExp, uint256 _strikePrice, int32 _strikeExp, string _strikeAsset, uint256 _expiry, uint256 _windowSize) public nonpayable +returns(address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _collateralType | string | The collateral asset. Eg. "ETH" | +| _collateralExp | int32 | The number of decimals the collateral asset has | +| _underlyingType | string | The underlying asset. Eg. "DAI" | +| _underlyingExp | int32 | The precision of the underlying asset. Eg. (-18 if Dai) | +| _oTokenExchangeExp | int32 | Units of underlying that 1 oToken protects | +| _strikePrice | uint256 | The amount of strike asset that will be paid out | +| _strikeExp | int32 | The precision of the strike Price | +| _strikeAsset | string | The asset in which the insurance is calculated | +| _expiry | uint256 | The time at which the insurance expires | +| _windowSize | uint256 | UNIX time. Exercise window is from `expiry - _windowSize` to `expiry`. | + +### getNumberOfOptionsContracts + +The number of Option Contracts that the Factory contract has stored + +```js +function getNumberOfOptionsContracts() public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### addAsset + +The owner of the Factory Contract can add a new asset to be supported + +```js +function addAsset(string _asset, address _addr) public nonpayable onlyOwner +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _asset | string | The ticker symbol for the asset | +| _addr | address | The address of the asset | + +### changeAsset + +The owner of the Factory Contract can change an existing asset's address + +```js +function changeAsset(string _asset, address _addr) public nonpayable onlyOwner +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _asset | string | The ticker symbol for the asset | +| _addr | address | The address of the asset | + +### deleteAsset + +The owner of the Factory Contract can delete an existing asset's address + +```js +function deleteAsset(string _asset) public nonpayable onlyOwner +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _asset | string | The ticker symbol for the asset | + +### supportsAsset + +Check if the Factory contract supports a specific asset + +```js +function supportsAsset(string _asset) public view +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _asset | string | The ticker symbol for the asset | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/OptionsUtils.md b/docs/OptionsUtils.md new file mode 100644 index 0000000..501fe52 --- /dev/null +++ b/docs/OptionsUtils.md @@ -0,0 +1,89 @@ +# OptionsUtils.sol + +View Source: [contracts/OptionsUtils.sol](../contracts/OptionsUtils.sol) + +**OptionsUtils** + +## Contract Members +**Constants & Variables** + +```js +contract UniswapFactoryInterface public UNISWAP_FACTORY; +contract CompoundOracleInterface public COMPOUND_ORACLE; + +``` + +## Functions + +- [(address _uniswapFactory, address _compoundOracle)](#) +- [getExchange(address _token)](#getexchange) +- [isETH(IERC20 _ierc20)](#iseth) + +### + +```js +function (address _uniswapFactory, address _compoundOracle) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _uniswapFactory | address | | +| _compoundOracle | address | | + +### getExchange + +```js +function getExchange(address _token) public view +returns(contract UniswapExchangeInterface) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _token | address | | + +### isETH + +```js +function isETH(IERC20 _ierc20) public pure +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _ierc20 | IERC20 | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/Oracle.md b/docs/Oracle.md new file mode 100644 index 0000000..1c2377f --- /dev/null +++ b/docs/Oracle.md @@ -0,0 +1,107 @@ +# Oracle.sol + +View Source: [contracts/Oracle.sol](../contracts/Oracle.sol) + +**Oracle** + +## Contract Members +**Constants & Variables** + +```js +//internal members +mapping(address => bool) internal isCToken; +mapping(address => address) internal assetToCTokens; +address internal cETH; + +//public members +contract CompoundOracleInterface public PriceOracle; + +``` + +## Functions + +- [(address _oracleAddress)](#) +- [isCETH(address asset)](#isceth) +- [getPrice(address asset)](#getprice) +- [getPriceUnderlying(address asset)](#getpriceunderlying) + +### + +```js +function (address _oracleAddress) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _oracleAddress | address | | + +### isCETH + +```js +function isCETH(address asset) public view +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| asset | address | | + +### getPrice + +```js +function getPrice(address asset) public view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| asset | address | | + +### getPriceUnderlying + +```js +function getPriceUnderlying(address asset) internal view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| asset | address | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/Ownable.md b/docs/Ownable.md new file mode 100644 index 0000000..56edd7e --- /dev/null +++ b/docs/Ownable.md @@ -0,0 +1,171 @@ +# Ownable.sol + +View Source: [@openzeppelin/contracts/ownership/Ownable.sol](../@openzeppelin/contracts/ownership/Ownable.sol) + +**↗ Extends: [Context](Context.md)** +**↘ Derived Contracts: [OptionsContract](OptionsContract.md), [OptionsFactory](OptionsFactory.md)** + +**Ownable** + +Contract module which provides a basic access control mechanism, where +there is an account (an owner) that can be granted exclusive access to +specific functions. + * This module is used through inheritance. It will make available the modifier +`onlyOwner`, which can be applied to your functions to restrict their use to +the owner. + +## Contract Members +**Constants & Variables** + +```js +address private _owner; + +``` + +**Events** + +```js +event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); +``` + +## Modifiers + +- [onlyOwner](#onlyowner) + +### onlyOwner + +Throws if called by any account other than the owner. + +```js +modifier onlyOwner() internal +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Functions + +- [()](#) +- [owner()](#owner) +- [isOwner()](#isowner) +- [renounceOwnership()](#renounceownership) +- [transferOwnership(address newOwner)](#transferownership) +- [_transferOwnership(address newOwner)](#_transferownership) + +### + +Initializes the contract setting the deployer as the initial owner. + +```js +function () internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### owner + +Returns the address of the current owner. + +```js +function owner() public view +returns(address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### isOwner + +Returns true if the caller is the current owner. + +```js +function isOwner() public view +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### renounceOwnership + +Leaves the contract without owner. It will not be possible to call +`onlyOwner` functions anymore. Can only be called by the current owner. + * NOTE: Renouncing ownership will leave the contract without an owner, +thereby removing any functionality that is only available to the owner. + +```js +function renounceOwnership() public nonpayable onlyOwner +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### transferOwnership + +Transfers ownership of the contract to a new account (`newOwner`). +Can only be called by the current owner. + +```js +function transferOwnership(address newOwner) public nonpayable onlyOwner +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| newOwner | address | | + +### _transferOwnership + +Transfers ownership of the contract to a new account (`newOwner`). + +```js +function _transferOwnership(address newOwner) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| newOwner | address | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/Roles.md b/docs/Roles.md new file mode 100644 index 0000000..3850e45 --- /dev/null +++ b/docs/Roles.md @@ -0,0 +1,102 @@ +# Roles (Roles.sol) + +View Source: [@openzeppelin/contracts/access/Roles.sol](../@openzeppelin/contracts/access/Roles.sol) + +**Roles** + +Library for managing addresses assigned to a Role. + +## Structs +### Role + +```js +struct Role { + mapping(address => bool) bearer +} +``` + +## Functions + +- [add(struct Roles.Role role, address account)](#add) +- [remove(struct Roles.Role role, address account)](#remove) +- [has(struct Roles.Role role, address account)](#has) + +### add + +Give an account access to this role. + +```js +function add(struct Roles.Role role, address account) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| role | struct Roles.Role | | +| account | address | | + +### remove + +Remove an account's access to this role. + +```js +function remove(struct Roles.Role role, address account) internal nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| role | struct Roles.Role | | +| account | address | | + +### has + +Check if an account has this role. + +```js +function has(struct Roles.Role role, address account) internal view +returns(bool) +``` + +**Returns** + +bool + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| role | struct Roles.Role | | +| account | address | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/SafeMath.md b/docs/SafeMath.md new file mode 100644 index 0000000..33c3c55 --- /dev/null +++ b/docs/SafeMath.md @@ -0,0 +1,230 @@ +# SafeMath.sol + +View Source: [@openzeppelin/contracts/math/SafeMath.sol](../@openzeppelin/contracts/math/SafeMath.sol) + +**SafeMath** + +Wrappers over Solidity's arithmetic operations with added overflow +checks. + * Arithmetic operations in Solidity wrap on overflow. This can easily result +in bugs, because programmers usually assume that an overflow raises an +error, which is the standard behavior in high level programming languages. +`SafeMath` restores this intuition by reverting the transaction when an +operation overflows. + * Using this library instead of the unchecked operations eliminates an entire +class of bugs, so it's recommended to use it always. + +## Functions + +- [add(uint256 a, uint256 b)](#add) +- [sub(uint256 a, uint256 b)](#sub) +- [sub(uint256 a, uint256 b, string errorMessage)](#sub) +- [mul(uint256 a, uint256 b)](#mul) +- [div(uint256 a, uint256 b)](#div) +- [div(uint256 a, uint256 b, string errorMessage)](#div) +- [mod(uint256 a, uint256 b)](#mod) +- [mod(uint256 a, uint256 b, string errorMessage)](#mod) + +### add + +Returns the addition of two unsigned integers, reverting on +overflow. + * Counterpart to Solidity's `+` operator. + * Requirements: +- Addition cannot overflow. + +```js +function add(uint256 a, uint256 b) internal pure +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| a | uint256 | | +| b | uint256 | | + +### sub + +Returns the subtraction of two unsigned integers, reverting on +overflow (when the result is negative). + * Counterpart to Solidity's `-` operator. + * Requirements: +- Subtraction cannot overflow. + +```js +function sub(uint256 a, uint256 b) internal pure +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| a | uint256 | | +| b | uint256 | | + +### sub + +Returns the subtraction of two unsigned integers, reverting with custom message on +overflow (when the result is negative). + * Counterpart to Solidity's `-` operator. + * Requirements: +- Subtraction cannot overflow. + * _Available since v2.4.0._ + +```js +function sub(uint256 a, uint256 b, string errorMessage) internal pure +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| a | uint256 | | +| b | uint256 | | +| errorMessage | string | | + +### mul + +Returns the multiplication of two unsigned integers, reverting on +overflow. + * Counterpart to Solidity's `*` operator. + * Requirements: +- Multiplication cannot overflow. + +```js +function mul(uint256 a, uint256 b) internal pure +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| a | uint256 | | +| b | uint256 | | + +### div + +Returns the integer division of two unsigned integers. Reverts on +division by zero. The result is rounded towards zero. + * Counterpart to Solidity's `/` operator. Note: this function uses a +`revert` opcode (which leaves remaining gas untouched) while Solidity +uses an invalid opcode to revert (consuming all remaining gas). + * Requirements: +- The divisor cannot be zero. + +```js +function div(uint256 a, uint256 b) internal pure +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| a | uint256 | | +| b | uint256 | | + +### div + +Returns the integer division of two unsigned integers. Reverts with custom message on +division by zero. The result is rounded towards zero. + * Counterpart to Solidity's `/` operator. Note: this function uses a +`revert` opcode (which leaves remaining gas untouched) while Solidity +uses an invalid opcode to revert (consuming all remaining gas). + * Requirements: +- The divisor cannot be zero. + * _Available since v2.4.0._ + +```js +function div(uint256 a, uint256 b, string errorMessage) internal pure +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| a | uint256 | | +| b | uint256 | | +| errorMessage | string | | + +### mod + +Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), +Reverts when dividing by zero. + * Counterpart to Solidity's `%` operator. This function uses a `revert` +opcode (which leaves remaining gas untouched) while Solidity uses an +invalid opcode to revert (consuming all remaining gas). + * Requirements: +- The divisor cannot be zero. + +```js +function mod(uint256 a, uint256 b) internal pure +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| a | uint256 | | +| b | uint256 | | + +### mod + +Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), +Reverts with custom message when dividing by zero. + * Counterpart to Solidity's `%` operator. This function uses a `revert` +opcode (which leaves remaining gas untouched) while Solidity uses an +invalid opcode to revert (consuming all remaining gas). + * Requirements: +- The divisor cannot be zero. + * _Available since v2.4.0._ + +```js +function mod(uint256 a, uint256 b, string errorMessage) internal pure +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| a | uint256 | | +| b | uint256 | | +| errorMessage | string | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/StringComparator.md b/docs/StringComparator.md new file mode 100644 index 0000000..f8a0daf --- /dev/null +++ b/docs/StringComparator.md @@ -0,0 +1,53 @@ +# StringComparator.sol + +View Source: [contracts/lib/StringComparator.sol](../contracts/lib/StringComparator.sol) + +**StringComparator** + +## Functions + +- [compareStrings(string a, string b)](#comparestrings) + +### compareStrings + +```js +function compareStrings(string a, string b) public pure +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| a | string | | +| b | string | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/TestImports.md b/docs/TestImports.md new file mode 100644 index 0000000..654203f --- /dev/null +++ b/docs/TestImports.md @@ -0,0 +1,50 @@ +# TestImports.sol + +View Source: [contracts/test/TestImports.sol](../contracts/test/TestImports.sol) + +**TestImports** + +## Functions + +- [()](#) + +### + +```js +function () public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/UniswapExchangeInterface.md b/docs/UniswapExchangeInterface.md new file mode 100644 index 0000000..1eb0340 --- /dev/null +++ b/docs/UniswapExchangeInterface.md @@ -0,0 +1,540 @@ +# UniswapExchangeInterface.sol + +View Source: [contracts/lib/UniswapExchangeInterface.sol](../contracts/lib/UniswapExchangeInterface.sol) + +**UniswapExchangeInterface** + +## Contract Members +**Constants & Variables** + +```js +bytes32 public name; +bytes32 public symbol; +uint256 public decimals; + +``` + +## Functions + +- [tokenAddress()](#tokenaddress) +- [factoryAddress()](#factoryaddress) +- [addLiquidity(uint256 min_liquidity, uint256 max_tokens, uint256 deadline)](#addliquidity) +- [removeLiquidity(uint256 amount, uint256 min_eth, uint256 min_tokens, uint256 deadline)](#removeliquidity) +- [getEthToTokenInputPrice(uint256 eth_sold)](#getethtotokeninputprice) +- [getEthToTokenOutputPrice(uint256 tokens_bought)](#getethtotokenoutputprice) +- [getTokenToEthInputPrice(uint256 tokens_sold)](#gettokentoethinputprice) +- [getTokenToEthOutputPrice(uint256 eth_bought)](#gettokentoethoutputprice) +- [ethToTokenSwapInput(uint256 min_tokens, uint256 deadline)](#ethtotokenswapinput) +- [ethToTokenTransferInput(uint256 min_tokens, uint256 deadline, address recipient)](#ethtotokentransferinput) +- [ethToTokenSwapOutput(uint256 tokens_bought, uint256 deadline)](#ethtotokenswapoutput) +- [ethToTokenTransferOutput(uint256 tokens_bought, uint256 deadline, address recipient)](#ethtotokentransferoutput) +- [tokenToEthSwapInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline)](#tokentoethswapinput) +- [tokenToEthTransferInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline, address recipient)](#tokentoethtransferinput) +- [tokenToEthSwapOutput(uint256 eth_bought, uint256 max_tokens, uint256 deadline)](#tokentoethswapoutput) +- [tokenToEthTransferOutput(uint256 eth_bought, uint256 max_tokens, uint256 deadline, address recipient)](#tokentoethtransferoutput) +- [tokenToTokenSwapInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address token_addr)](#tokentotokenswapinput) +- [tokenToTokenTransferInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address recipient, address token_addr)](#tokentotokentransferinput) +- [tokenToTokenSwapOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address token_addr)](#tokentotokenswapoutput) +- [tokenToTokenTransferOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address recipient, address token_addr)](#tokentotokentransferoutput) +- [tokenToExchangeSwapInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address exchange_addr)](#tokentoexchangeswapinput) +- [tokenToExchangeTransferInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address recipient, address exchange_addr)](#tokentoexchangetransferinput) +- [tokenToExchangeSwapOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address exchange_addr)](#tokentoexchangeswapoutput) +- [tokenToExchangeTransferOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address recipient, address exchange_addr)](#tokentoexchangetransferoutput) +- [transfer(address _to, uint256 _value)](#transfer) +- [transferFrom(address _from, address _to, uint256 value)](#transferfrom) +- [approve(address _spender, uint256 _value)](#approve) +- [allowance(address _owner, address _spender)](#allowance) +- [balanceOf(address _owner)](#balanceof) +- [totalSupply()](#totalsupply) +- [setup(address token_addr)](#setup) + +### tokenAddress + +```js +function tokenAddress() external view +returns(token address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### factoryAddress + +```js +function factoryAddress() external view +returns(factory address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### addLiquidity + +```js +function addLiquidity(uint256 min_liquidity, uint256 max_tokens, uint256 deadline) external payable +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| min_liquidity | uint256 | | +| max_tokens | uint256 | | +| deadline | uint256 | | + +### removeLiquidity + +```js +function removeLiquidity(uint256 amount, uint256 min_eth, uint256 min_tokens, uint256 deadline) external nonpayable +returns(uint256, uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amount | uint256 | | +| min_eth | uint256 | | +| min_tokens | uint256 | | +| deadline | uint256 | | + +### getEthToTokenInputPrice + +```js +function getEthToTokenInputPrice(uint256 eth_sold) external view +returns(tokens_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| eth_sold | uint256 | | + +### getEthToTokenOutputPrice + +```js +function getEthToTokenOutputPrice(uint256 tokens_bought) external view +returns(eth_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_bought | uint256 | | + +### getTokenToEthInputPrice + +```js +function getTokenToEthInputPrice(uint256 tokens_sold) external view +returns(eth_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_sold | uint256 | | + +### getTokenToEthOutputPrice + +```js +function getTokenToEthOutputPrice(uint256 eth_bought) external view +returns(tokens_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| eth_bought | uint256 | | + +### ethToTokenSwapInput + +```js +function ethToTokenSwapInput(uint256 min_tokens, uint256 deadline) external payable +returns(tokens_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| min_tokens | uint256 | | +| deadline | uint256 | | + +### ethToTokenTransferInput + +```js +function ethToTokenTransferInput(uint256 min_tokens, uint256 deadline, address recipient) external payable +returns(tokens_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| min_tokens | uint256 | | +| deadline | uint256 | | +| recipient | address | | + +### ethToTokenSwapOutput + +```js +function ethToTokenSwapOutput(uint256 tokens_bought, uint256 deadline) external payable +returns(eth_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_bought | uint256 | | +| deadline | uint256 | | + +### ethToTokenTransferOutput + +```js +function ethToTokenTransferOutput(uint256 tokens_bought, uint256 deadline, address recipient) external payable +returns(eth_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_bought | uint256 | | +| deadline | uint256 | | +| recipient | address | | + +### tokenToEthSwapInput + +```js +function tokenToEthSwapInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline) external nonpayable +returns(eth_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_sold | uint256 | | +| min_eth | uint256 | | +| deadline | uint256 | | + +### tokenToEthTransferInput + +```js +function tokenToEthTransferInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline, address recipient) external nonpayable +returns(eth_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_sold | uint256 | | +| min_eth | uint256 | | +| deadline | uint256 | | +| recipient | address | | + +### tokenToEthSwapOutput + +```js +function tokenToEthSwapOutput(uint256 eth_bought, uint256 max_tokens, uint256 deadline) external nonpayable +returns(tokens_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| eth_bought | uint256 | | +| max_tokens | uint256 | | +| deadline | uint256 | | + +### tokenToEthTransferOutput + +```js +function tokenToEthTransferOutput(uint256 eth_bought, uint256 max_tokens, uint256 deadline, address recipient) external nonpayable +returns(tokens_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| eth_bought | uint256 | | +| max_tokens | uint256 | | +| deadline | uint256 | | +| recipient | address | | + +### tokenToTokenSwapInput + +```js +function tokenToTokenSwapInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address token_addr) external nonpayable +returns(tokens_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_sold | uint256 | | +| min_tokens_bought | uint256 | | +| min_eth_bought | uint256 | | +| deadline | uint256 | | +| token_addr | address | | + +### tokenToTokenTransferInput + +```js +function tokenToTokenTransferInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address recipient, address token_addr) external nonpayable +returns(tokens_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_sold | uint256 | | +| min_tokens_bought | uint256 | | +| min_eth_bought | uint256 | | +| deadline | uint256 | | +| recipient | address | | +| token_addr | address | | + +### tokenToTokenSwapOutput + +```js +function tokenToTokenSwapOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address token_addr) external nonpayable +returns(tokens_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_bought | uint256 | | +| max_tokens_sold | uint256 | | +| max_eth_sold | uint256 | | +| deadline | uint256 | | +| token_addr | address | | + +### tokenToTokenTransferOutput + +```js +function tokenToTokenTransferOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address recipient, address token_addr) external nonpayable +returns(tokens_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_bought | uint256 | | +| max_tokens_sold | uint256 | | +| max_eth_sold | uint256 | | +| deadline | uint256 | | +| recipient | address | | +| token_addr | address | | + +### tokenToExchangeSwapInput + +```js +function tokenToExchangeSwapInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address exchange_addr) external nonpayable +returns(tokens_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_sold | uint256 | | +| min_tokens_bought | uint256 | | +| min_eth_bought | uint256 | | +| deadline | uint256 | | +| exchange_addr | address | | + +### tokenToExchangeTransferInput + +```js +function tokenToExchangeTransferInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address recipient, address exchange_addr) external nonpayable +returns(tokens_bought uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_sold | uint256 | | +| min_tokens_bought | uint256 | | +| min_eth_bought | uint256 | | +| deadline | uint256 | | +| recipient | address | | +| exchange_addr | address | | + +### tokenToExchangeSwapOutput + +```js +function tokenToExchangeSwapOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address exchange_addr) external nonpayable +returns(tokens_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_bought | uint256 | | +| max_tokens_sold | uint256 | | +| max_eth_sold | uint256 | | +| deadline | uint256 | | +| exchange_addr | address | | + +### tokenToExchangeTransferOutput + +```js +function tokenToExchangeTransferOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address recipient, address exchange_addr) external nonpayable +returns(tokens_sold uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokens_bought | uint256 | | +| max_tokens_sold | uint256 | | +| max_eth_sold | uint256 | | +| deadline | uint256 | | +| recipient | address | | +| exchange_addr | address | | + +### transfer + +```js +function transfer(address _to, uint256 _value) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _to | address | | +| _value | uint256 | | + +### transferFrom + +```js +function transferFrom(address _from, address _to, uint256 value) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _from | address | | +| _to | address | | +| value | uint256 | | + +### approve + +```js +function approve(address _spender, uint256 _value) external nonpayable +returns(bool) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _spender | address | | +| _value | uint256 | | + +### allowance + +```js +function allowance(address _owner, address _spender) external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _owner | address | | +| _spender | address | | + +### balanceOf + +```js +function balanceOf(address _owner) external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _owner | address | | + +### totalSupply + +```js +function totalSupply() external view +returns(uint256) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| + +### setup + +```js +function setup(address token_addr) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| token_addr | address | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/UniswapFactoryInterface.md b/docs/UniswapFactoryInterface.md new file mode 100644 index 0000000..e812c69 --- /dev/null +++ b/docs/UniswapFactoryInterface.md @@ -0,0 +1,116 @@ +# UniswapFactoryInterface.sol + +View Source: [contracts/lib/UniswapFactoryInterface.sol](../contracts/lib/UniswapFactoryInterface.sol) + +**UniswapFactoryInterface** + +## Contract Members +**Constants & Variables** + +```js +address public exchangeTemplate; +uint256 public tokenCount; + +``` + +## Functions + +- [createExchange(address token)](#createexchange) +- [getExchange(address token)](#getexchange) +- [getToken(address exchange)](#gettoken) +- [getTokenWithId(uint256 tokenId)](#gettokenwithid) +- [initializeFactory(address template)](#initializefactory) + +### createExchange + +```js +function createExchange(address token) external nonpayable +returns(exchange address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| token | address | | + +### getExchange + +```js +function getExchange(address token) external view +returns(exchange address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| token | address | | + +### getToken + +```js +function getToken(address exchange) external view +returns(token address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| exchange | address | | + +### getTokenWithId + +```js +function getTokenWithId(uint256 tokenId) external view +returns(token address) +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| tokenId | uint256 | | + +### initializeFactory + +```js +function initializeFactory(address template) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| template | address | | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/docs/oToken.md b/docs/oToken.md new file mode 100644 index 0000000..2f5dae6 --- /dev/null +++ b/docs/oToken.md @@ -0,0 +1,212 @@ +# Opyn's Options Contract (oToken.sol) + +View Source: [contracts/oToken.sol](../contracts/oToken.sol) + +**↗ Extends: [OptionsContract](OptionsContract.md)** + +**oToken** + +## Functions + +- [(IERC20 _collateral, int32 _collExp, IERC20 _underlying, int32 _underlyingExp, int32 _oTokenExchangeExp, uint256 _strikePrice, int32 _strikeExp, IERC20 _strike, uint256 _expiry, OptionsExchange _optionsExchange, address _oracleAddress, uint256 _windowSize)](#) +- [createETHCollateralOption(uint256 amtToCreate, address receiver)](#createethcollateraloption) +- [addETHCollateralOption(uint256 amtToCreate, address receiver)](#addethcollateraloption) +- [createAndSellETHCollateralOption(uint256 amtToCreate, address payable receiver)](#createandsellethcollateraloption) +- [addAndSellETHCollateralOption(uint256 amtToCreate, address payable receiver)](#addandsellethcollateraloption) +- [createERC20CollateralOption(uint256 amtToCreate, uint256 amtCollateral, address receiver)](#createerc20collateraloption) +- [addERC20CollateralOption(uint256 amtToCreate, uint256 amtCollateral, address receiver)](#adderc20collateraloption) +- [createAndSellERC20CollateralOption(uint256 amtToCreate, uint256 amtCollateral, address payable receiver)](#createandsellerc20collateraloption) +- [addAndSellERC20CollateralOption(uint256 amtToCreate, uint256 amtCollateral, address payable receiver)](#addandsellerc20collateraloption) + +### + +```js +function (IERC20 _collateral, int32 _collExp, IERC20 _underlying, int32 _underlyingExp, int32 _oTokenExchangeExp, uint256 _strikePrice, int32 _strikeExp, IERC20 _strike, uint256 _expiry, OptionsExchange _optionsExchange, address _oracleAddress, uint256 _windowSize) public nonpayable OptionsContract +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| _collateral | IERC20 | The collateral asset | +| _collExp | int32 | The precision of the collateral (-18 if ETH) | +| _underlying | IERC20 | The asset that is being protected | +| _underlyingExp | int32 | The precision of the underlying asset | +| _oTokenExchangeExp | int32 | The precision of the `amount of underlying` that 1 oToken protects | +| _strikePrice | uint256 | The amount of strike asset that will be paid out | +| _strikeExp | int32 | The precision of the strike asset (-18 if ETH) | +| _strike | IERC20 | Price The amount of strike asset that will be paid out | +| _expiry | uint256 | The time at which the insurance expires | +| _optionsExchange | OptionsExchange | The contract which interfaces with the exchange + oracle | +| _oracleAddress | address | The address of the oracle | +| _windowSize | uint256 | UNIX time. Exercise window is from `expiry - _windowSize` to `expiry`. | + +### createETHCollateralOption + +opens a Vault, adds ETH collateral, and mints new oTokens in one step +Remember that creating oTokens can put the owner at a risk of losing the collateral +if an exercise event happens. +The sell function provides the owner a chance to earn premiums. +Ensure that you create and immediately sell oTokens atmoically. + +```js +function createETHCollateralOption(uint256 amtToCreate, address receiver) external payable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToCreate | uint256 | number of oTokens to create | +| receiver | address | address to send the Options to | + +### addETHCollateralOption + +adds ETH collateral, and mints new oTokens in one step to an existing Vault +Remember that creating oTokens can put the owner at a risk of losing the collateral +if an exercise event happens. +The sell function provides the owner a chance to earn premiums. +Ensure that you create and immediately sell oTokens atmoically. + +```js +function addETHCollateralOption(uint256 amtToCreate, address receiver) public payable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToCreate | uint256 | number of oTokens to create | +| receiver | address | address to send the Options to | + +### createAndSellETHCollateralOption + +opens a Vault, adds ETH collateral, mints new oTokens and sell in one step + +```js +function createAndSellETHCollateralOption(uint256 amtToCreate, address payable receiver) external payable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToCreate | uint256 | number of oTokens to create | +| receiver | address payable | address to receive the premiums | + +### addAndSellETHCollateralOption + +adds ETH collateral to an existing Vault, and mints new oTokens and sells the oTokens in one step + +```js +function addAndSellETHCollateralOption(uint256 amtToCreate, address payable receiver) public payable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToCreate | uint256 | number of oTokens to create | +| receiver | address payable | address to send the Options to | + +### createERC20CollateralOption + +opens a Vault, adds ERC20 collateral, and mints new oTokens in one step +Remember that creating oTokens can put the owner at a risk of losing the collateral +if an exercise event happens. +The sell function provides the owner a chance to earn premiums. +Ensure that you create and immediately sell oTokens atmoically. + +```js +function createERC20CollateralOption(uint256 amtToCreate, uint256 amtCollateral, address receiver) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToCreate | uint256 | number of oTokens to create | +| amtCollateral | uint256 | amount of collateral added | +| receiver | address | address to send the Options to | + +### addERC20CollateralOption + +adds ERC20 collateral, and mints new oTokens in one step +Remember that creating oTokens can put the owner at a risk of losing the collateral +if an exercise event happens. +The sell function provides the owner a chance to earn premiums. +Ensure that you create and immediately sell oTokens atmoically. + +```js +function addERC20CollateralOption(uint256 amtToCreate, uint256 amtCollateral, address receiver) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToCreate | uint256 | number of oTokens to create | +| amtCollateral | uint256 | amount of collateral added | +| receiver | address | address to send the Options to | + +### createAndSellERC20CollateralOption + +opens a Vault, adds ERC20 collateral, mints new oTokens and sells the oTokens in one step + +```js +function createAndSellERC20CollateralOption(uint256 amtToCreate, uint256 amtCollateral, address payable receiver) external nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToCreate | uint256 | number of oTokens to create | +| amtCollateral | uint256 | amount of collateral added | +| receiver | address payable | address to send the Options to | + +### addAndSellERC20CollateralOption + +adds ERC20 collateral, mints new oTokens and sells the oTokens in one step + +```js +function addAndSellERC20CollateralOption(uint256 amtToCreate, uint256 amtCollateral, address payable receiver) public nonpayable +``` + +**Arguments** + +| Name | Type | Description | +| ------------- |------------- | -----| +| amtToCreate | uint256 | number of oTokens to create | +| amtCollateral | uint256 | amount of collateral added | +| receiver | address payable | address to send the Options to | + +## Contracts + +* [CompoundOracleInterface](CompoundOracleInterface.md) +* [Context](Context.md) +* [CTokenInterface](CTokenInterface.md) +* [Dai](Dai.md) +* [ERC20](ERC20.md) +* [ERC20Detailed](ERC20Detailed.md) +* [ERC20Mintable](ERC20Mintable.md) +* [IERC20](IERC20.md) +* [IOptionsExchange](IOptionsExchange.md) +* [LibNote](LibNote.md) +* [Migrations](Migrations.md) +* [MinterRole](MinterRole.md) +* [MockCompoundOracle](MockCompoundOracle.md) +* [MockUniswapFactory](MockUniswapFactory.md) +* [OptionsContract](OptionsContract.md) +* [OptionsExchange](OptionsExchange.md) +* [OptionsFactory](OptionsFactory.md) +* [OptionsUtils](OptionsUtils.md) +* [Oracle](Oracle.md) +* [oToken](oToken.md) +* [Ownable](Ownable.md) +* [Roles](Roles.md) +* [SafeMath](SafeMath.md) +* [StringComparator](StringComparator.md) +* [TestImports](TestImports.md) +* [UniswapExchangeInterface](UniswapExchangeInterface.md) +* [UniswapFactoryInterface](UniswapFactoryInterface.md) diff --git a/package-lock.json b/package-lock.json index 33c8493..465187d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1597,6 +1597,26 @@ "sprintf-js": "~1.0.2" } }, + "args": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/args/-/args-5.0.1.tgz", + "integrity": "sha512-1kqmFCFsPffavQFGt8OxJdIcETti99kySRUPMpOhaGjL6mRJn8HFU1OxKY5bMqfZKUwTQc1mZkAjmGYaVOHFtQ==", + "dev": true, + "requires": { + "camelcase": "5.0.0", + "chalk": "2.4.2", + "leven": "2.1.0", + "mri": "1.1.4" + }, + "dependencies": { + "camelcase": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz", + "integrity": "sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA==", + "dev": true + } + } + }, "array-back": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", @@ -1689,6 +1709,12 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, + "atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "dev": true + }, "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -3303,6 +3329,12 @@ "integrity": "sha512-khbFLu/MlzLjEzy9Gh8oY1hNt/Dvxw3J6Rbc28cVoYWQaC1S3YI4xwkF9ZWcjDLscbZlY9hISMr66RFzZagLsA==", "dev": true }, + "dateformat": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", + "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", + "dev": true + }, "debug": { "version": "3.2.6", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", @@ -4717,6 +4749,12 @@ "micromatch": "^4.0.2" } }, + "fast-json-parse": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/fast-json-parse/-/fast-json-parse-1.0.3.tgz", + "integrity": "sha512-FRWsaZRWEJ1ESVNbDWmsAlqDk96gPQezzLghafp5J4GUKjbCz3OkAHuZs5TuPEtkbVQERysLp9xv6c24fBm8Aw==", + "dev": true + }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", @@ -4728,6 +4766,18 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fast-redact": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-2.0.0.tgz", + "integrity": "sha512-zxpkULI9W9MNTK2sJ3BpPQrTEXFNESd2X6O1tXMFpK/XM0G5c5Rll2EVYZH2TqI3xRGK/VaJ+eEOt7pnENJpeA==", + "dev": true + }, + "fast-safe-stringify": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", + "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", + "dev": true + }, "fastq": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.6.0.tgz", @@ -4856,6 +4906,12 @@ "write": "1.0.3" } }, + "flatstr": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/flatstr/-/flatstr-1.0.12.tgz", + "integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw==", + "dev": true + }, "flatted": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", @@ -5675,6 +5731,12 @@ "is-object": "^1.0.1" } }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=", + "dev": true + }, "js-sha3": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", @@ -5974,6 +6036,12 @@ } } }, + "leven": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", + "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", + "dev": true + }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -5990,6 +6058,12 @@ "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", "dev": true }, + "linq": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/linq/-/linq-3.2.2.tgz", + "integrity": "sha512-AtVkCFwg7dizILt88ent7Bng1OLAnKMWBOLo9Kh7ZPFK8OcfYGi2FEzmr66QJtV7uBYZVf19AbVs0B14rIUi+w==", + "dev": true + }, "lint-staged": { "version": "9.5.0", "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-9.5.0.tgz", @@ -6757,6 +6831,12 @@ "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.10.4.tgz", "integrity": "sha512-gDfZDLaPIvtOusbusLinfx6YSe2YpQsDT8qdP41P47dQ/NQggtkHukz7hwqgt8QvMBmAv+Z6DGmXPyb5BWX2nQ==" }, + "mri": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.1.4.tgz", + "integrity": "sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w==", + "dev": true + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -7204,6 +7284,56 @@ "pinkie": "^2.0.0" } }, + "pino": { + "version": "5.17.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-5.17.0.tgz", + "integrity": "sha512-LqrqmRcJz8etUjyV0ddqB6OTUutCgQULPFg2b4dtijRHUsucaAdBgSUW58vY6RFSX+NT8963F+q0tM6lNwGShA==", + "dev": true, + "requires": { + "fast-redact": "^2.0.0", + "fast-safe-stringify": "^2.0.7", + "flatstr": "^1.0.12", + "pino-std-serializers": "^2.4.2", + "quick-format-unescaped": "^3.0.3", + "sonic-boom": "^0.7.5" + } + }, + "pino-pretty": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-2.6.1.tgz", + "integrity": "sha512-e/CWtKLidqkr7sinfIVVcsfcHgnFVlGvuEfKuuPFnxBo+9dZZsmgF8a9Rj7SYJ5LMZ8YBxNY9Ca46eam4ajKtQ==", + "dev": true, + "requires": { + "args": "^5.0.0", + "chalk": "^2.3.2", + "dateformat": "^3.0.3", + "fast-json-parse": "^1.0.3", + "fast-safe-stringify": "^2.0.6", + "jmespath": "^0.15.0", + "pump": "^3.0.0", + "readable-stream": "^3.0.6", + "split2": "^3.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, + "pino-std-serializers": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-2.4.2.tgz", + "integrity": "sha512-WaL504dO8eGs+vrK+j4BuQQq6GLKeCCcHaMB2ItygzVURcL1CycwNEUHTD/lHFHs/NL5qAz2UKrjYWXKSf4aMQ==", + "dev": true + }, "pkg-dir": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", @@ -7366,6 +7496,12 @@ "strict-uri-encode": "^1.0.0" } }, + "quick-format-unescaped": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-3.0.3.tgz", + "integrity": "sha512-dy1yjycmn9blucmJLXOfZDx1ikZJUi6E8bBZLnhPG5gBrVhHXx2xVyqqgKBubVNEXmx51dBACMHpoMQK/N/AXQ==", + "dev": true + }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -7610,6 +7746,12 @@ } } }, + "require-all": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/require-all/-/require-all-3.0.0.tgz", + "integrity": "sha1-Rz1JcEvjEBFc4ST3c4Ox69hnExI=", + "dev": true + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -8334,6 +8476,30 @@ "integrity": "sha512-4jtxasNGmyC0midtjH/lTFPZYvTTUMy6agYcF+HoMnzW8+cqo3piFrINb4ZCzpPW+7tTVFCGa5ubP34zOzeuMg==", "dev": true }, + "solidoc": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/solidoc/-/solidoc-1.0.5.tgz", + "integrity": "sha512-6UUP66JhtnTbLBjDt/eJgIzwYLTKEwaw0ocA5073jXtpkKk49PDGjJbtVgRJQID0cHHsRLXg6b8ROdk8sOSTnw==", + "dev": true, + "requires": { + "fs-extra": "^7.0.0", + "glob": "^7.1.3", + "linq": "^3.1.0", + "pino": "^5.8.0", + "pino-pretty": "^2.2.2", + "require-all": "^3.0.0" + } + }, + "sonic-boom": { + "version": "0.7.7", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-0.7.7.tgz", + "integrity": "sha512-Ei5YOo5J64GKClHIL/5evJPgASXFVpfVYbJV9PILZQytTK6/LCwHvsZJW2Ig4p9FMC2OrBrMnXKgRN/OEoAWfg==", + "dev": true, + "requires": { + "atomic-sleep": "^1.0.0", + "flatstr": "^1.0.12" + } + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -8382,6 +8548,28 @@ "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "dev": true }, + "split2": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/split2/-/split2-3.1.1.tgz", + "integrity": "sha512-emNzr1s7ruq4N+1993yht631/JH+jaj0NYBosuKmLcq+JkGQ9MmTw1RB1fGaTCzUuseRIClrlSLHRNYGwWQ58Q==", + "dev": true, + "requires": { + "readable-stream": "^3.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", diff --git a/package.json b/package.json index f1a4941..478ea62 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "prettier-plugin-solidity": "^1.0.0-alpha.35", "solhint": "^2.3.0", "solhint-plugin-prettier": "0.0.3", + "solidoc": "^1.0.5", "truffle": "5.1.1", "truffle-assertions": "0.9.2", "truffle-hdwallet-provider-privkey": "^0.3.0", @@ -50,7 +51,8 @@ "lint:sol": "solhint 'contracts/**/*.sol'", "lint:sol:prettier:fix": "prettier --write \"contracts/**/*.sol\"", "migrate": "truffle migrate", - "deploy:kovan": "npm run build && npm run migrate -- --network kovan" + "deploy:kovan": "npm run build && npm run migrate -- --network kovan", + "docgen": "solidoc" }, "prettier": { "singleQuote": true, diff --git a/solidoc.json b/solidoc.json new file mode 100644 index 0000000..eff5459 --- /dev/null +++ b/solidoc.json @@ -0,0 +1,8 @@ +{ + "pathToRoot": "./", + "outputPath": "./docs", + "noCompilation": true, + "compiler": "truffle compile", + "language": "en" +} + \ No newline at end of file