{"constructor_args":null,"is_partially_verified":true,"is_changed_bytecode":false,"abi":[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveTotal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"commission","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"interests","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reservePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocCommissionValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"btcMarkup","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocMarkup","type":"uint256"},{"indexed":false,"internalType":"address","name":"vendorAccount","type":"address"}],"name":"FreeStableTokenRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveTotal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"commission","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reservePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocCommissionValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"btcMarkup","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocMarkup","type":"uint256"},{"indexed":false,"internalType":"address","name":"vendorAccount","type":"address"}],"name":"RiskProMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveTotal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"commission","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reservePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocCommissionValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"btcMarkup","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocMarkup","type":"uint256"},{"indexed":false,"internalType":"address","name":"vendorAccount","type":"address"}],"name":"RiskProRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"riskProTecPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"riskProDiscountPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RiskProWithDiscountMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveTotal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"commission","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reservePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocCommissionValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"btcMarkup","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocMarkup","type":"uint256"},{"indexed":false,"internalType":"address","name":"vendorAccount","type":"address"}],"name":"StableTokenMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveTotal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"commission","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reservePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocCommissionValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"btcMarkup","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mocMarkup","type":"uint256"},{"indexed":false,"internalType":"address","name":"vendorAccount","type":"address"}],"name":"StableTokenRedeem","type":"event"},{"constant":true,"inputs":[],"name":"BUCKET_C0","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"BUCKET_X2","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint8","name":"txTypeFeesMOC","type":"uint8"},{"internalType":"uint8","name":"txTypeFeesRBTC","type":"uint8"},{"internalType":"address","name":"vendorAccount","type":"address"}],"internalType":"struct MoCExchange.CommissionParamsStruct","name":"params","type":"tuple"}],"name":"calculateCommissionsWithPrices","outputs":[{"components":[{"internalType":"uint256","name":"btcCommission","type":"uint256"},{"internalType":"uint256","name":"mocCommission","type":"uint256"},{"internalType":"uint256","name":"btcPrice","type":"uint256"},{"internalType":"uint256","name":"mocPrice","type":"uint256"},{"internalType":"uint256","name":"btcMarkup","type":"uint256"},{"internalType":"uint256","name":"mocMarkup","type":"uint256"}],"internalType":"struct MoCExchange.CommissionReturnStruct","name":"ret","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"connector","outputs":[{"internalType":"contract MoCConnector","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getDayPrecision","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"getMoCTokenBalance","outputs":[{"internalType":"uint256","name":"mocBalance","type":"uint256"},{"internalType":"uint256","name":"mocAllowance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getMocPrecision","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getReservePrecision","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"connectorAddress","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"btcAmount","type":"uint256"},{"internalType":"address","name":"vendorAccount","type":"address"}],"name":"mintBPro","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"btcToMint","type":"uint256"},{"internalType":"address","name":"vendorAccount","type":"address"}],"name":"mintDoc","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"origin","type":"address"},{"internalType":"address payable","name":"destination","type":"address"}],"name":"redeemAllDoc","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"bproAmount","type":"uint256"},{"internalType":"address","name":"vendorAccount","type":"address"}],"name":"redeemBPro","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"docAmount","type":"uint256"},{"internalType":"address","name":"vendorAccount","type":"address"}],"name":"redeemFreeDoc","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}],"conflicting_implementations":null,"certified":false,"additional_sources":[{"file_path":"npm/money-on-chain@0.1.14/contracts/interface/IMoCVendors.sol","source_code":"pragma solidity ^0.5.8;\n\ninterface IMoCVendors {\n    function resetTotalPaidInMoC() external;\n\n    function getIsActive(address account) external view\n    returns (bool);\n\n    function getTotalPaidInMoC(address account) external view\n    returns (uint256);\n\n    function getStaking(address account) external view\n    returns (uint256);\n\n    function getMarkup(address account) external view\n    returns (uint256);\n\n    function updatePaidMarkup(address account, uint256 mocAmount, uint256 rbtcAmount) external\n    returns(bool);\n}"},{"file_path":"npm/money-on-chain@0.1.14/contracts/token/OwnerBurnableToken.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol\";\nimport \"openzeppelin-solidity/contracts/ownership/Ownable.sol\";\n\n/**\n * @title Owner Burnable Token\n * @dev Token that allows the owner to irreversibly burned (destroyed) any token.\n */\ncontract OwnerBurnableToken is Ownable, ERC20Mintable {\n  /**\n   * @dev Burns a specific amount of tokens for the address.\n   * @param who who's tokens are gona be burned\n   * @param value The amount of token to be burned.\n   */\n  function burn(address who, uint256 value) public onlyOwner {\n    _burn(who, value);\n  }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/MoCBucketContainer.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"openzeppelin-solidity/contracts/math/Math.sol\";\nimport \"./base/MoCBase.sol\";\nimport \"moc-governance/contracts/Governance/Governed.sol\";\n\ncontract MoCBucketContainer is MoCBase, Governed {\n  using SafeMath for uint256;\n  using Math for uint256;\n\n  struct BProxBalance {\n    uint256 value;\n    uint index; // Index start in 1, zero is reserved for NULL\n  }\n\n  struct MoCBucket {\n    bytes32 name;\n    bool isBase;\n    uint256 nDoc;\n    uint256 nBPro;\n    uint256 nBTC;\n    uint256 cobj;\n    // Should only be used in L buckets\n    mapping(address => BProxBalance) bproxBalances;\n    address payable[] activeBalances;\n    uint256 activeBalancesLength;\n    // Should only be used in Base buckets (C0)\n    uint256 inrateBag;\n    bool available;\n  }\n\n  event BucketMovement(\n    bytes32 from,\n    bytes32 to,\n    uint256 reserves,\n    uint256 stableTokens\n  );\n\n  event BucketCreation(\n    bytes32 name,\n    uint256 cobj\n  );\n\n  event BucketStateUpdate(\n    bytes32 name,\n    uint256 nReserve,\n    uint256 nStable,\n    uint256 nRiskProx,\n    uint256 inrateBag\n  );\n\n  mapping(bytes32 => MoCBucket) internal mocBuckets;\n\n   /**\n   GETTERS\n   */\n  function getBucketNBTC(bytes32 bucket) public view returns(uint256) {\n    return mocBuckets[bucket].nBTC;\n  }\n\n  function getBucketNBPro(bytes32 bucket) public view returns(uint256) {\n    return mocBuckets[bucket].nBPro;\n  }\n\n  function getBucketNDoc(bytes32 bucket) public view returns(uint256) {\n    return mocBuckets[bucket].nDoc;\n  }\n\n  function getBucketCobj(bytes32 bucket) public view returns(uint256) {\n    return mocBuckets[bucket].cobj;\n  }\n\n  function getInrateBag(bytes32 bucket) external pure returns(uint256) {\n    return 0;\n  }\n\n  /**\n   * @dev Sets the objective coverage (cobj) on an specficied bucket.\n   * @param  _bucket - name of the bucket\n   * @param  _cobj - new value of cobj\n   */\n  function setBucketCobj(bytes32 _bucket, uint256 _cobj) public onlyAuthorizedChanger(){\n    //TODO: It is necessary to analyze the impact in the model it has when changing X2. This\n    mocBuckets[_bucket].cobj = _cobj;\n  }\n\n  /**\n    @dev returns true if the bucket is a base bucket\n    @param bucket Name of the bucket\n  */\n  function isBucketBase(bytes32 bucket) public view returns(bool){\n    return mocBuckets[bucket].isBase;\n  }\n\n  /**\n    @dev returns true if the bucket have docs in it\n    @param bucket Name of the bucket\n  */\n  function isBucketEmpty(bytes32 bucket) public view returns(bool) {\n    return mocBuckets[bucket].nDoc == 0;\n  }\n\n  /**\n    @dev Returns all the address that currently have bprox position for this bucket\n    @param bucket bucket of the active address\n  */\n  function getActiveAddresses(bytes32 bucket) public view returns(address payable[] memory) {\n    return mocBuckets[bucket].activeBalances;\n  }\n\n  /**\n    @dev Returns all the address that currently have bprox position for this bucket\n    @param bucket bucket of the active address\n  */\n  function getActiveAddressesCount(bytes32 bucket) public view returns(uint256 count) {\n    return mocBuckets[bucket].activeBalancesLength;\n  }\n\n  /**\n    @dev Add values to all variables of the bucket\n    @param bucketName Name of the bucket\n    @param btc BTC amount [using reservePrecision]\n    @param doc Doc amount [using mocPrecision]\n    @param bprox BPro amount [using mocPrecision]\n  */\n  function addValuesToBucket(bytes32 bucketName, uint256 btc, uint256 doc, uint256 bprox)\n  public onlyWhitelisted(msg.sender) {\n    MoCBucket storage bucket = mocBuckets[bucketName];\n\n    bucket.nBTC = bucket.nBTC.add(btc);\n    bucket.nDoc = bucket.nDoc.add(doc);\n    bucket.nBPro = bucket.nBPro.add(bprox);\n  }\n\n  /**\n    @dev Substract values to all variables of the bucket\n    @param bucketName Name of the bucket\n    @param btc BTC amount [using reservePrecision]\n    @param doc Doc amount [using mocPrecision]\n    @param bprox BPro amount [using mocPrecision]\n  */\n  function substractValuesFromBucket(bytes32 bucketName, uint256 btc, uint256 doc, uint256 bprox)\n  public onlyWhitelisted(msg.sender)  {\n    MoCBucket storage bucket = mocBuckets[bucketName];\n\n    bucket.nBTC = bucket.nBTC.sub(btc);\n    bucket.nDoc = bucket.nDoc.sub(doc);\n    bucket.nBPro = bucket.nBPro.sub(bprox);\n  }\n\n  /**\n    @dev Move Btcs and Docs from one bucket to another\n    @param from Name of bucket from where the BTCs will be removed\n    @param to Name of bucket from where the BTCs will be added\n    @param btc BTCs amount [using reservePrecision]\n    @param docs Docs amount [using mocPrecision]\n  */\n  function moveBtcAndDocs(bytes32 from, bytes32 to, uint256 btc, uint256 docs) public\n  onlyWhitelisted(msg.sender) bucketStateUpdate(from) bucketStateUpdate(to) {\n    MoCBucket storage bucketFrom = mocBuckets[from];\n    MoCBucket storage bucketTo = mocBuckets[to];\n\n    bucketFrom.nBTC = bucketFrom.nBTC.sub(btc);\n    bucketTo.nBTC = bucketTo.nBTC.add(btc);\n\n    bucketFrom.nDoc = bucketFrom.nDoc.sub(docs);\n    bucketTo.nDoc = bucketTo.nDoc.add(docs);\n\n    emit BucketMovement(from, to, btc, docs);\n  }\n\n  /**\n    @dev Clears completely the origin bucket, removing all Docs, RBTCs and bproxs\n    @param toLiquidate Bucket to be cleared out\n    @param destination Bucket that will receive the Docs and RBTCs\n   */\n  function liquidateBucket(bytes32 toLiquidate, bytes32 destination) public onlyWhitelisted(msg.sender) {\n    require(!isBucketBase(toLiquidate), \"Cannot liquidate a base bucket\");\n\n    clearBucketBalances(toLiquidate);\n    emptyBucket(toLiquidate, destination);\n  }\n\n  /**\n    @dev Clears Docs and BTC from bucket origin and sends them to destination bucket\n    @param origin Bucket to clear out\n    @param destination Destination bucket\n  */\n  function emptyBucket(bytes32 origin, bytes32 destination) public onlyWhitelisted(msg.sender) {\n    moveBtcAndDocs(origin, destination, mocBuckets[origin].nBTC, mocBuckets[origin].nDoc);\n  }\n\n  /**\n   * @dev checks if a bucket exists\n   * @param bucket name of the bucket\n   */\n  function isAvailableBucket(bytes32 bucket) public view returns(bool) {\n    return mocBuckets[bucket].available;\n  }\n\n  /**\n    @dev Put all bucket BProx balances in zero\n    @param bucketName Bucket to clear out\n   */\n  function clearBucketBalances(bytes32 bucketName) public onlyWhitelisted(msg.sender) {\n    MoCBucket storage bucket = mocBuckets[bucketName];\n    bucket.nBPro = 0;\n    bucket.activeBalancesLength = 0;\n  }\n\n  /**\n    @dev Creates bucket\n    @param name Name of the bucket\n    @param cobj Target Coverage of the bucket\n    @param isBase Indicates if it is a base bucket (true) or not (false)\n  */\n  function createBucket(bytes32 name, uint256 cobj, bool isBase) internal {\n    mocBuckets[name].name = name;\n    mocBuckets[name].nDoc = 0;\n    mocBuckets[name].nBPro = 0;\n    mocBuckets[name].nBTC = 0;\n    mocBuckets[name].cobj = cobj;\n    mocBuckets[name].isBase = isBase;\n    mocBuckets[name].available = true;\n    emit BucketCreation(name, cobj);\n  }\n\n  modifier onlyBaseBucket(bytes32 bucket) {\n    require(isBucketBase(bucket), \"Bucket should be a base type bucket\");\n    _;\n  }\n\n  modifier bucketStateUpdate(bytes32 bucket) {\n    _;\n    emit BucketStateUpdate(\n      bucket,\n      mocBuckets[bucket].nBTC,\n      mocBuckets[bucket].nDoc,\n      mocBuckets[bucket].nBPro,\n      mocBuckets[bucket].inrateBag\n      );\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/token/ERC20/ERC20.sol","source_code":"pragma solidity ^0.5.0;\n\nimport \"./IERC20.sol\";\nimport \"../../math/SafeMath.sol\";\n\n/**\n * @dev Implementation of the `IERC20` interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using `_mint`.\n * For a generic mechanism see `ERC20Mintable`.\n *\n * *For a detailed writeup see our guide [How to implement supply\n * mechanisms](https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226).*\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an `Approval` event is emitted on calls to `transferFrom`.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard `decreaseAllowance` and `increaseAllowance`\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See `IERC20.approve`.\n */\ncontract ERC20 is IERC20 {\n    using SafeMath for uint256;\n\n    mapping (address => uint256) private _balances;\n\n    mapping (address => mapping (address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    /**\n     * @dev See `IERC20.totalSupply`.\n     */\n    function totalSupply() public view returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See `IERC20.balanceOf`.\n     */\n    function balanceOf(address account) public view returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See `IERC20.transfer`.\n     *\n     * Requirements:\n     *\n     * - `recipient` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address recipient, uint256 amount) public returns (bool) {\n        _transfer(msg.sender, recipient, amount);\n        return true;\n    }\n\n    /**\n     * @dev See `IERC20.allowance`.\n     */\n    function allowance(address owner, address spender) public view returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See `IERC20.approve`.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 value) public returns (bool) {\n        _approve(msg.sender, spender, value);\n        return true;\n    }\n\n    /**\n     * @dev See `IERC20.transferFrom`.\n     *\n     * Emits an `Approval` event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of `ERC20`;\n     *\n     * Requirements:\n     * - `sender` and `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `value`.\n     * - the caller must have allowance for `sender`'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {\n        _transfer(sender, recipient, amount);\n        _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to `approve` that can be used as a mitigation for\n     * problems described in `IERC20.approve`.\n     *\n     * Emits an `Approval` event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {\n        _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to `approve` that can be used as a mitigation for\n     * problems described in `IERC20.approve`.\n     *\n     * Emits an `Approval` event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {\n        _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));\n        return true;\n    }\n\n    /**\n     * @dev Moves tokens `amount` from `sender` to `recipient`.\n     *\n     * This is internal function is equivalent to `transfer`, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a `Transfer` event.\n     *\n     * Requirements:\n     *\n     * - `sender` cannot be the zero address.\n     * - `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     */\n    function _transfer(address sender, address recipient, uint256 amount) internal {\n        require(sender != address(0), \"ERC20: transfer from the zero address\");\n        require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n        _balances[sender] = _balances[sender].sub(amount);\n        _balances[recipient] = _balances[recipient].add(amount);\n        emit Transfer(sender, recipient, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a `Transfer` event with `from` set to the zero address.\n     *\n     * Requirements\n     *\n     * - `to` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _totalSupply = _totalSupply.add(amount);\n        _balances[account] = _balances[account].add(amount);\n        emit Transfer(address(0), account, amount);\n    }\n\n     /**\n     * @dev Destoys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a `Transfer` event with `to` set to the zero address.\n     *\n     * Requirements\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 value) internal {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _totalSupply = _totalSupply.sub(value);\n        _balances[account] = _balances[account].sub(value);\n        emit Transfer(account, address(0), value);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.\n     *\n     * This is internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an `Approval` event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(address owner, address spender, uint256 value) internal {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = value;\n        emit Approval(owner, spender, value);\n    }\n\n    /**\n     * @dev Destoys `amount` tokens from `account`.`amount` is then deducted\n     * from the caller's allowance.\n     *\n     * See `_burn` and `_approve`.\n     */\n    function _burnFrom(address account, uint256 amount) internal {\n        _burn(account, amount);\n        _approve(account, msg.sender, _allowances[account][msg.sender].sub(amount));\n    }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/interface/IMoCInrate.sol","source_code":"pragma solidity ^0.5.8;\n\ninterface IMoCInrate {\n    // Transaction types\n    function MINT_BPRO_FEES_RBTC() external view returns(uint8);\n    function REDEEM_BPRO_FEES_RBTC() external view returns(uint8);\n    function MINT_DOC_FEES_RBTC() external view returns(uint8);\n    function REDEEM_DOC_FEES_RBTC() external view returns(uint8);\n    function MINT_BTCX_FEES_RBTC() external view returns(uint8);\n    function REDEEM_BTCX_FEES_RBTC() external view returns(uint8);\n    function MINT_BPRO_FEES_MOC() external view returns(uint8);\n    function REDEEM_BPRO_FEES_MOC() external view returns(uint8);\n    function MINT_DOC_FEES_MOC() external view returns(uint8);\n    function REDEEM_DOC_FEES_MOC() external view returns(uint8);\n    function MINT_BTCX_FEES_MOC() external view returns(uint8);\n    function REDEEM_BTCX_FEES_MOC() external view returns(uint8);\n\n    function payBitProHoldersInterestPayment() external returns(uint256);\n\n    function calculateBitProHoldersInterest() external view returns(uint256, uint256);\n\n    function getBitProInterestAddress() external view returns(address payable);\n\n    function getBitProRate() external view returns(uint256);\n\n    function getBitProInterestBlockSpan() external view returns(uint256);\n\n    function isDailyEnabled() external view returns(bool);\n\n    function isBitProInterestEnabled() external view returns(bool);\n\n    function commissionsAddress() external view returns(address payable);\n\n    function calcCommissionValue(uint256 rbtcAmount, uint8 txType) external view returns(uint256);\n\n    function calculateVendorMarkup(address vendorAccount, uint256 amount) external view returns (uint256 markup);\n\n    function setBitProInterestBlockSpan(uint256 newBitProBlockSpan) external;\n}"},{"file_path":"project/contracts/compat/DeployableMoCInrate.sol","source_code":"// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.5.17;\npragma experimental ABIEncoderV2;\n\nimport { MoCInrate } from \"@moc/rbtc/contracts/MoCInrate.sol\";\n\ncontract DeployableMoCInrate is MoCInrate {}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/MoCSettlement.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/math/Math.sol\";\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"./base/MoCBase.sol\";\nimport \"./token/DocToken.sol\";\nimport \"./interface/IMoCState.sol\";\nimport \"./interface/IMoCExchange.sol\";\nimport \"./MoCBProxManager.sol\";\nimport \"./PartialExecution.sol\";\nimport \"moc-governance/contracts/Governance/Governed.sol\";\nimport \"moc-governance/contracts/Governance/IGovernor.sol\";\nimport \"./interface/IMoCVendors.sol\";\nimport \"./interface/IMoCSettlement.sol\";\n\ncontract MoCSettlementEvents {\n  event SettlementCompleted(uint256 commissionsPayed);\n}\n\ncontract MoCSettlement is\nMoCSettlementEvents,\nMoCBase,\nPartialExecution,\nGoverned,\nIMoCSettlement\n{\n  using Math for uint256;\n  using SafeMath for uint256;\n\n  bytes32 public constant DOC_REDEMPTION_TASK = keccak256(\"DocRedemption\");\n  bytes32 public constant DELEVERAGING_TASK = keccak256(\"Deleveraging\");\n  bytes32 public constant SETTLEMENT_TASK = keccak256(\"Settlement\");\n\n  struct RedeemRequest {\n    address payable who;\n    uint256 amount;\n  }\n\n  struct UserRedeemRequest {\n    uint256 index;\n    bool activeRedeemer;\n  }\n\n  // All necessary data for Settlement execution\n  struct SettlementInfo {\n    uint256 btcPrice;\n    uint256 btcxPrice;\n    uint256 docRedeemCount;\n    uint256 deleveragingCount;\n    uint256 bproxAmount;\n    uint256 partialCommissionAmount;\n    uint256 finalCommissionAmount;\n    uint256 leverage;\n    uint256 startBlockNumber;\n    bool isProtectedMode;\n  }\n\n  // Contracts\n  IMoCState internal mocState;\n  IMoCExchange internal mocExchange;\n  DocToken internal docToken;\n  MoCBProxManager internal bproxManager;\n\n  /**\n  @dev Block Number of the last successful execution\n  */\n  uint256 internal lastProcessedBlock;\n  /**\n  @dev Min number of blocks settlement should be re evaluated on\n  */\n  uint256 internal blockSpan;\n  /**\n  @dev Information for Settlement execution\n  */\n  SettlementInfo internal settlementInfo;\n  /**\n  @dev Redeem queue\n  */\n  RedeemRequest[] private redeemQueue;\n  uint256 private redeemQueueLength;\n\n  mapping(address => UserRedeemRequest) private redeemMapping;\n\n  /**\n    @dev Initializes the contract\n    @param connectorAddress MoCConnector contract address\n    @param _governor Governor contract address\n    @param _blockSpan Blockspan configuration blockspan of settlement\n  */\n  function initialize(\n    address connectorAddress,\n    address _governor,\n    uint256 _blockSpan\n  ) public initializer {\n    initializeBase(connectorAddress);\n    initializeContracts();\n    initializeValues(_governor, _blockSpan);\n  }\n\n  /**\n   *  @dev Set the blockspan configuration blockspan of settlement\n   */\n  function setBlockSpan(uint256 bSpan) public onlyAuthorizedChanger() {\n    blockSpan = bSpan;\n  }\n\n  /**\n    @dev Gets the RedeemRequest at the queue index position\n    @return redeemer's address and amount he submitted\n  */\n  function getRedeemRequestAt(uint256 /*_index*/)\n  public\n  pure\n  returns (address payable, uint256)\n  {\n    return (address(0), 0);\n  }\n\n  /**\n    @dev Gets the number of blocks the settlemnet will be allowed to run\n  */\n  function getBlockSpan() public view returns (uint256) {\n    return blockSpan;\n  }\n\n  /**\n    @dev Returns the current redeem request queue's length\n  */\n  function redeemQueueSize() public pure returns (uint256) {\n    return 0;\n  }\n\n  /**\n    @dev Returns true if blockSpan number of blocks has pass since last execution\n  */\n  function isSettlementEnabled() public view returns (bool) {\n    return nextSettlementBlock() <= block.number;\n  }\n\n  /**\n    @dev Returns the next block from which settlement is possible\n  */\n  function nextSettlementBlock() public view returns (uint256) {\n    return lastProcessedBlock.add(blockSpan);\n  }\n\n  /**\n    @dev returns the total amount of Docs in the redeem queue for _who\n    @return total amount of Docs in the redeem queue for _who [using mocPrecision]\n  */\n  function docAmountToRedeem(address /*_who*/) public pure returns (uint256) {\n    return 0;\n  }\n\n  /**\n    @dev Runs settlement process in steps\n    @return The commissions collected in the executed steps\n  */\n  function runSettlement(uint256 /*steps*/)\n  public\n  onlyWhitelisted(msg.sender)\n  isTime()\n  returns (uint256)\n  {\n    lastProcessedBlock = block.number;\n    // Reset total paid in MoC for every vendor\n    IMoCVendors mocVendors = IMoCVendors(mocState.getMoCVendors());\n    mocVendors.resetTotalPaidInMoC();\n    emit SettlementCompleted(0);\n    return 0;\n  }\n\n  function initializeContracts() internal {\n    docToken = DocToken(connector.docToken());\n    bproxManager = MoCBProxManager(connector.bproxManager());\n    mocState = IMoCState(connector.mocState());\n    mocExchange = IMoCExchange(connector.mocExchange());\n  }\n\n  function initializeValues(address _governor, uint256 _blockSpan) internal {\n    governor = IGovernor(_governor);\n    blockSpan = _blockSpan;\n    lastProcessedBlock = block.number;\n  }\n\n\n  modifier isTime() {\n    require(isSettlementEnabled(), \"Settlement not yet enabled\");\n    _;\n  }\n\n  /**************************************************/\n  /******************** TASKS ***********************/\n  /**************************************************/\n\n/**\n  @dev Returns the amount of steps for the Deleveraging task\n  which is the amount of active BProx addresses\n*/\n  function deleveragingStepCount() internal pure returns (uint256) {\n    return 0;\n  }\n\n  /**\n  @dev Returns the amount of steps for the Doc Redemption task\n  which is the amount of redeem requests in the queue\n*/\n  function docRedemptionStepCount() internal pure returns (uint256) {\n    return 0;\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/token/DocToken.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol\";\nimport \"./OwnerBurnableToken.sol\";\n\ncontract DocToken is ERC20Detailed, OwnerBurnableToken {\n\n  string private _name = \"Dollar on Chain\";\n  string private _symbol = \"DOC\";\n  uint8 private _decimals = 18;\n\n  /**\n    @dev Constructor\n  */\n  constructor() Ownable() ERC20Detailed(_name, _symbol, _decimals) public {\n\n  }\n\n  /**\n    @dev Fallback function\n  */\n  function() external {\n  }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/base/MoCWhitelist.sol","source_code":"pragma solidity ^0.5.8;\n\n/**\n  @dev Provides access control between all MoC Contracts\n */\ncontract MoCWhitelist {\n  mapping(address => bool) whitelist;\n\n  /**\n   * @dev Check if an account is whitelisted\n   * @return Bool\n   */\n  function isWhitelisted(address account)\n    public\n    view\n    returns (bool)\n  {\n    require(account != address(0), \"Account must not be 0x0\");\n    return whitelist[account];\n  }\n\n  /**\n   * @dev Add account to whitelist\n   */\n  function add(address account) internal {\n    require(account != address(0), \"Account must not be 0x0\");\n    require(!isWhitelisted(account), \"Account not allowed to add accounts into white list\");\n    whitelist[account] = true;\n  }\n\n  /**\n   * @dev Remove account from whitelist\n   */\n  function remove(address account) internal {\n    require(account != address(0), \"Account must not be 0x0\");\n    require(isWhitelisted(account), \"Account is not allowed to remove address from the white list\");\n\n    whitelist[account] = false;\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"project/contracts/compat/DeployableMoCExchange.sol","source_code":"// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.5.17;\npragma experimental ABIEncoderV2;\n\nimport { MoCExchange } from \"@moc/rbtc/contracts/MoCExchange.sol\";\n\ncontract DeployableMoCExchange is MoCExchange {}\n"},{"file_path":"project/contracts/compat/DeployableMoCBProxManager.sol","source_code":"// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.5.17;\npragma experimental ABIEncoderV2;\n\nimport { MoCBProxManager } from \"@moc/rbtc/contracts/MoCBProxManager.sol\";\n\ncontract DeployableMoCBProxManager is MoCBProxManager {}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/base/MoCConstants.sol","source_code":"pragma solidity ^0.5.8;\n\n/**\n * @dev Defines special constants to use along all the MoC System\n */\ncontract MoCConstants {\n  bytes32 constant public BUCKET_X2 = \"X2\";\n  bytes32 constant public BUCKET_C0 = \"C0\";\n}"},{"file_path":"project/contracts/compat/DeployableMoCState.sol","source_code":"// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.5.17;\npragma experimental ABIEncoderV2;\n\nimport { MoCState } from \"@moc/rbtc/contracts/MoCState.sol\";\n\ncontract DeployableMoCState is MoCState {}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/base/MoCConnector.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"zos-lib/contracts/Initializable.sol\";\n\nimport \"./MoCWhitelist.sol\";\n\n/**\n  @dev Provides access control between all MoC Contracts\n */\ncontract MoCConnector is MoCWhitelist, Initializable {\n  // References\n  address payable public moc;\n  address public docToken;\n  address public bproToken;\n  address public bproxManager;\n  address public mocState;\n  /** DEPRECATED **/\n  // solium-disable-next-line mixedcase\n  address public DEPRECATED_mocConverter;\n  address public mocSettlement;\n  address public mocExchange;\n  address public mocInrate;\n  /** DEPRECATED mocBurnout **/\n  address public mocBurnout;\n\n  bool internal initialized;\n\n  /**\n    @dev Initializes the contract\n    @param mocAddress MoC contract address\n    @param docAddress DoCToken contract address\n    @param bproAddress BProToken contract address\n    @param bproxAddress BProxManager contract address\n    @param stateAddress MoCState contract address\n    @param settlementAddress MoCSettlement contract address\n    @param exchangeAddress MoCExchange contract address\n    @param inrateAddress MoCInrate contract address\n    @param burnoutBookAddress (DEPRECATED) MoCBurnout contract address. DO NOT USE.\n  */\n  function initialize(\n    address payable mocAddress,\n    address docAddress,\n    address bproAddress,\n    address bproxAddress,\n    address stateAddress,\n    address settlementAddress,\n    address exchangeAddress,\n    address inrateAddress,\n    address burnoutBookAddress\n  ) public initializer {\n    moc = mocAddress;\n    docToken = docAddress;\n    bproToken = bproAddress;\n    bproxManager = bproxAddress;\n    mocState = stateAddress;\n    mocSettlement = settlementAddress;\n    mocExchange = exchangeAddress;\n    mocInrate = inrateAddress;\n    mocBurnout = burnoutBookAddress;\n\n    // Add to Whitelist\n    add(mocAddress);\n    add(docAddress);\n    add(bproAddress);\n    add(bproxAddress);\n    add(stateAddress);\n    add(settlementAddress);\n    add(exchangeAddress);\n    add(inrateAddress);\n    add(burnoutBookAddress);\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}"},{"file_path":"npm/moc-governance@0.1.0/contracts/Governance/ChangeContract.sol","source_code":"pragma solidity ^0.5.8;\n\n/**\n  @title ChangeContract\n  @notice This interface is the one used by the governance system.\n  @dev If you plan to do some changes to a system governed by this project you should write a contract\n  that does those changes, like a recipe. This contract MUST not have ANY kind of public or external function\n  that modifies the state of this ChangeContract, otherwise you could run into front-running issues when the governance\n  system is fully in place.\n */\ninterface ChangeContract {\n\n  /**\n    @notice Override this function with a recipe of the changes to be done when this ChangeContract\n    is executed\n   */\n  function execute() external;\n}\n"},{"file_path":"npm/moc-governance@0.1.0/contracts/Stopper/Stoppable.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"../Governance/Governed.sol\";\n\n\n/**\n  @title Stoppable\n  @notice Allow a contract to be paused through the stopper subsystem. This contracts\n  is able to disable the stoppability feature through governance.\n  @dev This contract was heavily based on the _Pausable_ contract of openzeppelin-eth but\n  it was modified in order to being able to turn on and off its stopability\n */\ncontract Stoppable is Governed {\n\n  event Paused(address account);\n  event Unpaused(address account);\n\n  bool public stoppable;\n  bool private _paused;\n  address public stopper;\n  string private constant UNSTOPPABLE = \"unstoppable\";\n  string private constant CONTRACT_IS_ACTIVE = \"contract_is_active\";\n  string private constant CONTRACT_IS_PAUSED = \"contract_is_paused\";\n  string private constant NOT_STOPPER = \"not_stopper\";\n\n\n  /**\n    @notice Modifier to make a function callable only when the contract is enable\n    to be paused\n  */\n  modifier whenStoppable() {\n    require(stoppable, UNSTOPPABLE);\n    _;\n  }\n\n  /**\n    @notice Modifier to make a function callable only when the contract is not paused\n  */\n  modifier whenNotPaused() {\n    require(!_paused, CONTRACT_IS_PAUSED);\n    _;\n  }\n\n  /**\n    @notice Modifier to make a function callable only when the contract is paused\n    */\n  modifier whenPaused() {\n    require(_paused, CONTRACT_IS_ACTIVE);\n    _;\n  }\n\n  /**\n    @notice  Modifier to make a function callable only by the pauser\n   */\n  modifier onlyPauser() {\n    require(stopper == msg.sender, NOT_STOPPER);\n    _;\n  }\n\n  /**\n    @notice Initialize the contract with the basic settings\n    @dev This initialize replaces the constructor but it is not called automatically.\n    It is necessary because of the upgradeability of the contracts. Either this function or the next can be used\n    @param _stopper The address that is authorized to stop this contract\n    @param _governor The address that will define when a change contract is authorized to do this unstoppable/stoppable again\n   */\n  function initialize(address _stopper, IGovernor _governor) public initializer {\n    initialize(_stopper, _governor, true);\n  }\n\n  /**\n    @notice Initialize the contract with the basic settings\n    @dev This initialize replaces the constructor but it is not called automatically.\n    It is necessary because of the upgradeability of the contracts. Either this function or the previous can be used\n    @param _stopper The address that is authorized to stop this contract\n    @param _governor The address that will define when a change contract is authorized to do this unstoppable/stoppable again\n    @param _stoppable Define if the contract starts being unstoppable or not\n   */\n  function initialize(address _stopper, IGovernor _governor, bool _stoppable) public initializer {\n    stoppable = _stoppable;\n    stopper = _stopper;\n    Governed.initialize(_governor);\n  }\n\n  /**\n    @notice Returns true if paused\n   */\n  function paused() public view returns (bool) {\n    return _paused;\n  }\n  /**\n    @notice Called by the owner to pause, triggers stopped state\n    @dev Should only be called by the pauser and when it is stoppable\n   */\n  function pause() public whenStoppable onlyPauser whenNotPaused {\n    _paused = true;\n    emit Paused(msg.sender);\n  }\n\n  /**\n    @notice Called by the owner to unpause, returns to normal state\n   */\n  function unpause() public onlyPauser whenPaused {\n    _paused = false;\n    emit Unpaused(msg.sender);\n  }\n\n\n  /**\n    @notice Switches OFF the stoppability of the contract; if the contract was paused\n    it will no longer be so\n    @dev Should be called through governance\n   */\n  function makeUnstoppable() public onlyAuthorizedChanger {\n    stoppable = false;\n  }\n\n\n  /**\n    @notice Switches ON the stoppability of the contract; if the contract was paused\n    before making it unstoppable it will be paused again after calling this function\n    @dev Should be called through governance\n   */\n  function makeStoppable() public onlyAuthorizedChanger {\n    stoppable = true;\n  }\n\n  /**\n    @notice Changes the address which is enable to stop this contract\n    @param newStopper Address of the newStopper\n    @dev Should be called through governance\n   */\n  function setStopper(address newStopper) public onlyAuthorizedChanger {\n    stopper = newStopper;\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/token/BProToken.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol\";\nimport \"openzeppelin-solidity/contracts/token/ERC20/ERC20Pausable.sol\";\nimport \"./OwnerBurnableToken.sol\";\n\ncontract BProToken is ERC20Detailed, ERC20Pausable, OwnerBurnableToken {\n\n  string private _name = \"BitPRO\";\n  string private _symbol = \"BITP\";\n  uint8 private _decimals = 18;\n\n  /**\n    @dev Constructor\n  */\n  constructor() Ownable() ERC20Detailed(_name, _symbol, _decimals) public {\n  }\n\n  /**\n    @dev Fallback function\n  */\n  function() external {\n  }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/token/MoCToken.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol\";\nimport \"./OwnerBurnableToken.sol\";\n\ncontract MoCToken is ERC20Detailed, OwnerBurnableToken {\n\n  string private _name = \"MoC\";\n  string private _symbol = \"MOC\";\n  uint8 private _decimals = 18;\n\n  /**\n    @dev Constructor\n  */\n  constructor() Ownable() ERC20Detailed(_name, _symbol, _decimals) public {\n\n  }\n\n  /**\n    @dev Fallback function\n  */\n  function() external {\n  }\n}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/token/ERC20/ERC20Detailed.sol","source_code":"pragma solidity ^0.5.0;\n\nimport \"./IERC20.sol\";\n\n/**\n * @dev Optional functions from the ERC20 standard.\n */\ncontract ERC20Detailed is IERC20 {\n    string private _name;\n    string private _symbol;\n    uint8 private _decimals;\n\n    /**\n     * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of\n     * these values are immutable: they can only be set once during\n     * construction.\n     */\n    constructor (string memory name, string memory symbol, uint8 decimals) public {\n        _name = name;\n        _symbol = symbol;\n        _decimals = decimals;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei.\n     *\n     * > Note that this information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * `IERC20.balanceOf` and `IERC20.transfer`.\n     */\n    function decimals() public view returns (uint8) {\n        return _decimals;\n    }\n}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/token/ERC20/ERC20Pausable.sol","source_code":"pragma solidity ^0.5.0;\n\nimport \"./ERC20.sol\";\nimport \"../../lifecycle/Pausable.sol\";\n\n/**\n * @title Pausable token\n * @dev ERC20 modified with pausable transfers.\n */\ncontract ERC20Pausable is ERC20, Pausable {\n    function transfer(address to, uint256 value) public whenNotPaused returns (bool) {\n        return super.transfer(to, value);\n    }\n\n    function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) {\n        return super.transferFrom(from, to, value);\n    }\n\n    function approve(address spender, uint256 value) public whenNotPaused returns (bool) {\n        return super.approve(spender, value);\n    }\n\n    function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool) {\n        return super.increaseAllowance(spender, addedValue);\n    }\n\n    function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool) {\n        return super.decreaseAllowance(spender, subtractedValue);\n    }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/MoCState.sol","source_code":"pragma solidity ^0.5.8;\npragma experimental ABIEncoderV2;\n\nimport \"openzeppelin-solidity/contracts/math/Math.sol\";\nimport \"./interface/PriceProvider.sol\";\nimport \"./MoCEMACalculator.sol\";\nimport \"./base/MoCBase.sol\";\nimport \"./MoCLibConnection.sol\";\nimport \"./MoCBProxManager.sol\";\nimport \"./token/DocToken.sol\";\nimport \"./token/BProToken.sol\";\nimport \"./token/MoCToken.sol\";\nimport \"./interface/IMoCSettlement.sol\";\nimport \"moc-governance/contracts/Governance/Governed.sol\";\nimport \"moc-governance/contracts/Governance/IGovernor.sol\";\nimport \"./interface/IMoCState.sol\";\n\ncontract MoCState is MoCLibConnection, MoCBase, MoCEMACalculator, IMoCState {\n  using Math for uint256;\n  using SafeMath for uint256;\n\n  struct InitializeParams {\n    address connectorAddress;\n    address governor;\n    address btcPriceProvider;\n    uint256 liq;\n    uint256 utpdu;\n    uint256 maxDiscRate;\n    uint256 dayBlockSpan;\n    uint256 ema;\n    uint256 smoothFactor;\n    uint256 emaBlockSpan;\n    uint256 maxMintBPro;\n    address mocPriceProvider;\n    address mocTokenAddress;\n    address mocVendorsAddress;\n    bool liquidationEnabled;\n    uint256 protected;\n  }\n\n  // This is the current state.\n  States public state;\n\n  event StateTransition(States newState);\n  event BtcPriceProviderUpdated(address oldAddress, address newAddress);\n\n  // Contracts\n  PriceProvider internal btcPriceProvider;\n  IMoCSettlement internal mocSettlement;\n  /** DEPRECATED **/\n  // solium-disable-next-line mixedcase\n  address internal DEPRECATED_mocConverter;\n  DocToken internal docToken;\n  BProToken internal bproToken;\n  MoCBProxManager internal bproxManager;\n\n  // One Day based on 15 seconds blocks\n  uint256 public dayBlockSpan;\n  // Relation between DOC and dollar\n  uint256 public peg;\n  // DEPRECATED: kept only for backward compatibility (external getters/governance flow)\n  // BPro max discount rate (legacy discount flow disabled)\n  uint256 public bproMaxDiscountRate;\n  // Liquidation limit\n  // [using mocPrecision]\n  uint256 public liq;\n  // DEPRECATED: kept only for backward compatibility (external getters/governance flow)\n  // BPro with discount limit [using mocPrecision] (legacy discount flow disabled)\n  uint256 public utpdu;\n  // Complete amount of Bitcoin in the system\n  // this represents basically MoC Balance\n  uint256 public rbtcInSystem;\n  // Price to use at doc redemption at\n  // liquidation event\n  uint256 public liquidationPrice;\n  // Liquidation enabled\n  bool public liquidationEnabled;\n  // Protected limit\n  // [using mocPrecision]\n  uint256 public protected;\n\n  /**\n    @dev Initializes the contract\n    @param params Params defined in InitializeParams struct\n  */\n  function initialize(InitializeParams memory params) public initializer {\n    initializePrecisions();\n    initializeBase(params.connectorAddress);\n    initializeContracts(params.mocTokenAddress, params.mocVendorsAddress);\n    initializeValues(\n      params.governor,\n      params.btcPriceProvider,\n      params.liq,\n      params.utpdu,\n      params.maxDiscRate,\n      params.dayBlockSpan,\n      params.maxMintBPro,\n      params.mocPriceProvider,\n      params.liquidationEnabled,\n      params.protected);\n    initializeMovingAverage(params.ema, params.smoothFactor, params.emaBlockSpan);\n  }\n\n  /**\n   @dev Sets the max discount rate.\n   @param rate Discount rate at liquidation level [using mocPrecision]\n  */\n  function setMaxDiscountRate(uint256 rate) public onlyAuthorizedChanger() {\n    require(rate < mocLibConfig.mocPrecision, \"rate is lower than mocPrecision\");\n\n    bproMaxDiscountRate = rate;\n  }\n\n  /**\n   @dev Returns the value of the BPro max discount rate configuration param\n   @return bproMaxDiscountRate BPro max discount rate\n  */\n  function getMaxDiscountRate() public view returns(uint256) {\n    return bproMaxDiscountRate;\n  }\n\n  /**\n    @dev Defines how many blocks there are in a day\n    @param blockSpan blocks there are in a day\n  */\n  function setDayBlockSpan(uint256 blockSpan) public onlyAuthorizedChanger() {\n    dayBlockSpan = blockSpan;\n  }\n\n  /**\n   @dev Sets a new BTCProvider contract\n   @param btcProviderAddress address of the BTC price provider contract\n  */\n  function setBtcPriceProvider(address btcProviderAddress) public onlyAuthorizedChanger() {\n    address oldBtcPriceProviderAddress = address(btcPriceProvider);\n    btcPriceProvider = PriceProvider(btcProviderAddress);\n    emit BtcPriceProviderUpdated(oldBtcPriceProviderAddress, address(btcPriceProvider));\n  }\n\n  /**\n   @dev Gets the BTCPriceProviderAddress\n   @return address of the BTC price provider contract\n  */\n  function getBtcPriceProvider() public view returns(address) {\n    return address(btcPriceProvider);\n  }\n\n  /**\n   @dev Gets how many blocks there are in a day\n   @return blocks there are in a day\n  */\n  function getDayBlockSpan() public view returns(uint256) {\n    return dayBlockSpan;\n  }\n\n  /**\n   @dev Subtract the btc amount passed by parameter to the total Bitcoin Amount\n   @param btcAmount Amount that will be subtract to rbtcInSystem\n  */\n  function subtractRbtcFromSystem(uint256 btcAmount) public onlyWhitelisted(msg.sender) {\n    rbtcInSystem = rbtcInSystem.sub(btcAmount);\n  }\n\n  /**\n   @dev btcAmount Add the btc amount passed by parameter to the total Bitcoin Amount\n   @param btcAmount Amount that will be added to rbtcInSystem\n  */\n  function addToRbtcInSystem(uint256 btcAmount) public onlyWhitelisted(msg.sender) {\n    rbtcInSystem = rbtcInSystem.add(btcAmount);\n  }\n\n  /**\n    @dev All BPros in circulation\n   */\n  function bproTotalSupply() public view returns(uint256) {\n    return bproToken.totalSupply();\n  }\n\n  /**\n    @dev All docs in circulation\n   */\n  function docTotalSupply() public view returns(uint256) {\n    return docToken.totalSupply();\n  }\n\n  /**\n    @dev Target coverage for complete system\n  */\n  function cobj() public view returns(uint256) {\n    return bproxManager.getBucketCobj(BUCKET_C0);\n  }\n\n  /**\n    @dev Amount of Bitcoins in the system\n    @dev BTCx (leveraged positions) have been permanently disabled and BUCKET_X2 nBPro is always 0\n  */\n  function collateralRbtcInSystem() public view returns(uint256) {\n    return rbtcInSystem;\n  }\n\n  /**\n    @dev GLOBAL Coverage\n    @return coverage [using mocPrecision]\n  */\n  function globalCoverage() public view returns(uint256) {\n    uint256 lB = globalLockedBitcoin();\n\n    return mocLibConfig.coverage(collateralRbtcInSystem(), lB);\n  }\n\n  /**\n   @dev BUCKET lockedBitcoin\n   @param bucket Name of the bucket used\n   @return lockedBitcoin amount [using reservePrecision]\n  */\n  function lockedBitcoin(bytes32 bucket) public view returns(uint256) {\n    uint256 nDoc = bproxManager.getBucketNDoc(bucket);\n\n    return mocLibConfig.lockedBitcoin(getBitcoinPrice(), nDoc, peg);\n  }\n\n  /**\n   @dev Gets RBTC in BitPro within specified bucket\n   @param bucket Name of the bucket used\n   @return Bitcoin amount of BitPro in Bucket [using reservePrecision]\n  */\n  function getRbtcInBitPro(bytes32 bucket) public view returns(uint256) {\n    uint256 nB = bproxManager.getBucketNBTC(bucket);\n    uint256 lB = lockedBitcoin(bucket);\n\n    if ( lB >= nB ){\n      return 0;\n    }\n\n    return nB.sub(lB);\n  }\n\n  /**\n   @dev Gets the RBTC in the contract that not corresponds to Doc collateral\n   @return RBTC remainder [using reservePrecision]\n  */\n  function getRbtcRemainder() public view returns(uint256) {\n    uint256 lB = globalLockedBitcoin();\n\n    if ( lB >= rbtcInSystem ){\n      return 0;\n    }\n\n    return rbtcInSystem.sub(lB);\n  }\n\n  /**\n   @dev BUCKET Coverage\n   @param bucket Name of the bucket used\n   @return coverage [using coveragePrecision]\n  */\n  function coverage(bytes32 bucket) public view returns(uint256) {\n    if (!bproxManager.isBucketBase(bucket) && bproxManager.isBucketEmpty(bucket)) {\n      return bproxManager.getBucketCobj(bucket);\n    }\n\n    uint256 nB = bproxManager.getBucketNBTC(bucket);\n    uint256 lB = lockedBitcoin(bucket);\n\n    return mocLibConfig.coverage(nB, lB);\n  }\n\n  /**\n   @dev Abundance ratio, receives tha amount of doc to use the value of doc0 and Doc total supply\n   @return abundance ratio [using mocPrecision]\n  */\n  function abundanceRatio(uint256 doc0) public view returns(uint256) {\n    return mocLibConfig.abundanceRatio(doc0, docTotalSupply());\n  }\n\n  /**\n   @dev Relation between docs in bucket 0 and Doc total supply\n   @return abundance ratio [using mocPrecision]\n  */\n  function currentAbundanceRatio() public view returns(uint256) {\n    return abundanceRatio(getBucketNDoc(BUCKET_C0));\n  }\n\n  /**\n   @dev BUCKET Leverage\n   @param bucket Name of the bucket used\n   @return coverage [using mocPrecision]\n  */\n  function leverage(bytes32 bucket) public view returns(uint256) {\n    uint256 cov = coverage(bucket);\n\n    return mocLibConfig.leverageFromCoverage(cov);\n  }\n\n  /**\n   @dev GLOBAL maxDoc\n   @return abundance ratio [using mocPrecision]\n  */\n  function globalMaxDoc() public view returns(uint256) {\n    return mocLibConfig.maxDoc(collateralRbtcInSystem(), cobj(), docTotalSupply(), peg, getBitcoinPrice(), getBcons());\n  }\n\n  /**\n   @dev Returns the amount of DoCs in bucket 0, that can be redeemed outside of settlement\n   @return amount of docs in bucket 0, that can be redeemed outside of settlement [using mocPrecision]\n  */\n  function freeDoc() public view returns(uint256) {\n    return bproxManager.getBucketNDoc(BUCKET_C0);\n  }\n\n  /**\n   @dev BUCKET maxDoc\n   @return abundance ratio [using mocPrecision]\n  */\n  function maxDoc(bytes32 bucket) public view returns(uint256) {\n    uint256 nB = bproxManager.getBucketNBTC(bucket);\n    uint256 nDoc = bproxManager.getBucketNDoc(bucket);\n    uint256 bktCobj = bproxManager.getBucketCobj(bucket);\n\n    return mocLibConfig.maxDoc(nB, bktCobj, nDoc, peg, getBitcoinPrice(), getBcons());\n  }\n\n  /**\n   @dev GLOBAL maxBPro\n   @return maxBPro for redeem [using reservePrecision]\n  */\n  function globalMaxBPro() public view returns(uint256) {\n    uint256 bproPrice = bproUsdPrice();\n\n    return mocLibConfig.maxBPro(\n      collateralRbtcInSystem(), cobj(), docTotalSupply(), peg, getBitcoinPrice(), getBcons(), bproPrice\n    );\n  }\n\n  /**\n   @dev ABSOLUTE maxDoc\n   @return maxDoc to issue [using mocPrecision]\n  */\n  function absoluteMaxDoc() public view returns(uint256) {\n    return Math.min(globalMaxDoc(), maxDoc(BUCKET_C0));\n  }\n\n  /**\n    @dev BUCKET maxBPro to redeem / mint\n    @param bucket Name of the bucket used\n    @return maxBPro for redeem [using mocPrecision]\n  */\n  function maxBPro(bytes32 bucket) public view returns(uint256) {\n    uint256 nB = bproxManager.getBucketNBTC(bucket);\n    uint256 nDoc = bproxManager.getBucketNDoc(bucket);\n    uint256 bproPrice = bproUsdPrice();\n    uint256 bktCobj = bproxManager.getBucketCobj(bucket);\n\n    return mocLibConfig.maxBPro(\n      nB, bktCobj, nDoc, peg, getBitcoinPrice(), getBcons(), bproPrice\n    );\n  }\n\n  /**\n   @dev GLOBAL max bprox to mint\n   @param bucket Name of the bucket used\n   @return maxBProx [using reservePrecision]\n  */\n  function maxBProx(bytes32 bucket) public view returns(uint256) {\n    uint256 maxBtc = maxBProxBtcValue(bucket);\n\n    return mocLibConfig.maxBProWithBtc(maxBtc, bucketBProTecPrice(bucket));\n  }\n\n  /**\n   @dev GLOBAL max bprox to mint\n   @param bucket Name of the bucket used\n   @return maxBProx BTC value to mint [using reservePrecision]\n  */\n  function maxBProxBtcValue(bytes32 bucket) public view returns(uint256) {\n    uint256 nDoc0 = bproxManager.getBucketNDoc(BUCKET_C0);\n    uint256 bucketLev = leverage(bucket);\n\n    return mocLibConfig.maxBProxBtcValue(nDoc0, peg, getBitcoinPrice(), bucketLev);\n  }\n\n  /**\n   @dev ABSOLUTE maxBPro\n   @return maxDoc to issue [using mocPrecision]\n  */\n  function absoluteMaxBPro() public view returns(uint256) {\n    return Math.min(globalMaxBPro(), maxBPro(BUCKET_C0));\n  }\n\n  /**\n   @dev DISCOUNT maxBPro\n   @return maxBPro for mint with discount [using mocPrecision]\n  */\n  function maxBProWithDiscount() public view returns(uint256) {\n    return 0;\n  }\n\n  /**\n   @dev GLOBAL lockedBitcoin\n   @return lockedBitcoin amount [using reservePrecision]\n  */\n  function globalLockedBitcoin() public view returns(uint256) {\n    return mocLibConfig.lockedBitcoin(getBitcoinPrice(), docTotalSupply(), peg);\n  }\n\n  /**\n   @dev BTC price of BPro\n   @return the BPro Tec Price [using reservePrecision]\n  */\n  function bproTecPrice() public view returns(uint256) {\n    return bucketBProTecPrice(BUCKET_C0);\n  }\n\n  /**\n   @dev BUCKET BTC price of BPro\n   @param bucket Name of the bucket used\n   @return the BPro Tec Price [using reservePrecision]\n  */\n  function bucketBProTecPrice(bytes32 bucket) public view returns(uint256) {\n    uint256 cov = globalCoverage();\n    uint256 coverageThreshold = uint256(1).mul(mocLibConfig.mocPrecision);\n\n    // If Protected Mode is reached and below threshold\n    if (bucket == BUCKET_C0 && cov <= getProtected() && cov < coverageThreshold) {\n      return 1; // wei\n    }\n\n    return bucketBProTecPriceHelper(bucket);\n  }\n\n  /**\n   @dev BUCKET BTC price of BPro (helper)\n   @param bucket Name of the bucket used\n   @return the BPro Tec Price [using reservePrecision]\n  */\n  function bucketBProTecPriceHelper(bytes32 bucket) public view returns(uint256) {\n    uint256 nBPro = bproxManager.getBucketNBPro(bucket);\n    uint256 lb = lockedBitcoin(bucket);\n    uint256 nB = bproxManager.getBucketNBTC(bucket);\n\n    return mocLibConfig.bproTecPrice(nB, lb, nBPro);\n  }\n\n  /**\n   @dev BTC price of BPro with spot discount applied\n   @return the BPro Tec Price [using reservePrecision]\n  */\n  function bproDiscountPrice() public view returns(uint256) {\n    return bproTecPrice();\n  }\n\n  /**\n   @dev BPro USD PRICE\n   @return the BPro USD Price [using mocPrecision]\n  */\n  function bproUsdPrice() public view returns(uint256) {\n    uint256 bproBtcPrice = bproTecPrice();\n    uint256 btcPrice = getBitcoinPrice();\n\n    return btcPrice.mul(bproBtcPrice).div(mocLibConfig.reservePrecision);\n  }\n\n /**\n   @dev GLOBAL max bprox to mint\n   @param bucket Name of the bucket used\n   @return max BPro allowed to be spent to mint BProx [using reservePrecision]\n  */\n  function maxBProxBProValue(bytes32 bucket) public view returns(uint256) {\n    uint256 btcValue = maxBProxBtcValue(bucket);\n\n    return mocLibConfig.maxBProWithBtc(btcValue, bproTecPrice());\n  }\n\n  /**\n   @dev BUCKET BProx price in BPro\n   @param bucket Name of the bucket used\n   @return BProx BPro Price [using mocPrecision]\n  */\n  function bproxBProPrice(bytes32 bucket) public view returns(uint256) {\n    // Otherwise, it reverts.\n    if (state == States.Liquidated) {\n      return 0;\n    }\n\n    uint256 bproxBtcPrice = bucketBProTecPrice(bucket);\n    uint256 bproBtcPrice = bproTecPrice();\n\n    return mocLibConfig.bproxBProPrice(bproxBtcPrice, bproBtcPrice);\n  }\n\n  /**\n   @dev GLOBAL BTC Discount rate to apply to BProPrice.\n   @return BPro discount rate [using DISCOUNT_PRECISION].\n  */\n  function bproSpotDiscountRate() public view returns(uint256) {\n    return 0;\n  }\n\n  /**\n    @dev Calculates the number of days to next settlement based dayBlockSpan\n    @return days to next settlement\n  */\n  function daysToSettlement() public view returns(uint256) {\n    return blocksToSettlement().mul(mocLibConfig.dayPrecision).div(dayBlockSpan);\n  }\n\n  /**\n    @dev Calculates the number of blocks to settlement\n    @return Number of blocks to settlement\n  */\n  function blocksToSettlement() public view returns(uint256) {\n    if (mocSettlement.nextSettlementBlock() <= block.number) {\n      return 0;\n    }\n\n    return mocSettlement.nextSettlementBlock().sub(block.number);\n  }\n\n  /**\n    @dev Verifies if forced liquidation is reached checking if globalCoverage <= liquidation (currently 1.04)\n     and if liquidation is enabled\n    @return true if liquidation state is reached, false otherwise\n   */\n  function isLiquidationReached() public view returns(bool) {\n    uint256 cov = globalCoverage();\n    if (state != States.Liquidated && cov <= liq && liquidationEnabled)\n      return true;\n    return false;\n  }\n\n  /**\n    @dev Gets the price to use for doc redeem in a liquidation event\n    @return price to use for doc redeem in a liquidation event\n  */\n  function getLiquidationPrice() public view returns(uint256) {\n    return liquidationPrice;\n  }\n\n  function getBucketNBTC(bytes32 bucket) public view returns(uint256) {\n    return bproxManager.getBucketNBTC(bucket);\n  }\n\n  function getBucketNBPro(bytes32 bucket) public view returns(uint256) {\n    return bproxManager.getBucketNBPro(bucket);\n  }\n\n  function getBucketNDoc(bytes32 bucket) public view returns(uint256) {\n    return bproxManager.getBucketNDoc(bucket);\n  }\n\n  function getBucketCobj(bytes32 bucket) public view returns(uint256) {\n    return bproxManager.getBucketCobj(bucket);\n  }\n\n  function getInrateBag(bytes32 bucket) external pure returns(uint256) {\n    return 0;\n  }\n\n  /**********************\n    BTC PRICE PROVIDER\n   *********************/\n\n  function getBcons() public view returns(uint256) {\n    return Math.min(getBitcoinPrice(), getBitcoinMovingAverage());\n  }\n\n  function getBitcoinPrice() public view returns(uint256) {\n    (bytes32 price, bool has) = btcPriceProvider.peek();\n    require(has, \"Oracle have no Bitcoin Price\");\n\n    return uint256(price);\n  }\n\n\n  function calculateBitcoinMovingAverage() public {\n    setBitcoinMovingAverage(getBitcoinPrice());\n  }\n\n\n\n  /**\n   @dev return the value of the liq threshold configuration param\n   @return liq threshold, currently 1.04\n  */\n  function getLiq() public view returns(uint256) {\n    return liq;\n  }\n\n  /**\n   @dev sets the value of the liq threshold configuration param\n   @param _liq liquidation threshold\n  */\n  function setLiq(uint _liq) public onlyAuthorizedChanger(){\n    liq = _liq;\n  }\n\n  /**\n    @dev return the value of the utpdu threshold configuration param\n    @return utpdu Universal TPro discount sales coverage threshold\n  */\n  function getUtpdu() public view returns(uint256) {\n    return utpdu;\n  }\n\n  /**\n   @dev sets the value of the utpdu threshold configuration param\n   @param _utpdu Universal TPro discount sales coverage threshold\n  */\n  function setUtpdu(uint _utpdu) public onlyAuthorizedChanger(){\n    utpdu = _utpdu;\n  }\n\n  /**\n   @dev returns the relation between DOC and dollar. By default it is 1.\n   @return peg relation between DOC and dollar\n  */\n  function getPeg() public view returns(uint256) {\n    return peg;\n  }\n\n  /**\n   @dev sets the relation between DOC and dollar. By default it is 1.\n   @param _peg relation between DOC and dollar\n  */\n  function setPeg(uint _peg) public onlyAuthorizedChanger(){\n    peg = _peg;\n  }\n\n  /**\n   @dev return the value of the protected threshold configuration param\n   @return protected threshold, currently 1.5\n  */\n  function getProtected() public view returns(uint256) {\n    return protected;\n  }\n\n  /**\n   @dev sets the value of the protected threshold configuration param\n   @param _protected protected threshold\n  */\n  function setProtected(uint _protected) public onlyAuthorizedChanger() {\n    protected = _protected;\n  }\n\n  /**\n   @dev returns if is liquidation enabled.\n   @return liquidationEnabled is liquidation enabled\n  */\n  function getLiquidationEnabled() public view returns(bool) {\n    return liquidationEnabled;\n  }\n\n  /**\n   @dev returns if is liquidation enabled.\n   @param _liquidationEnabled is liquidation enabled\n  */\n  function setLiquidationEnabled(bool _liquidationEnabled) public onlyAuthorizedChanger() {\n    liquidationEnabled = _liquidationEnabled;\n  }\n\n  /**\n   @dev Transitions to next state.\n  */\n  function nextState() public {\n    // There is no coming back from Liquidation\n    if (state == States.Liquidated)\n      return;\n\n    States prevState = state;\n    calculateBitcoinMovingAverage();\n    uint256 cov = globalCoverage();\n    if (cov <= liq && liquidationEnabled) {\n      setLiquidationPrice();\n      state = States.Liquidated;\n    } else if (cov <= cobj()) {\n      state = States.BelowCobj;\n    } else {\n      state = States.AboveCobj;\n    }\n\n    if (prevState != state)\n      emit StateTransition(state);\n  }\n\n  /************************************/\n  /***** UPGRADE v017       ***********/\n  /************************************/\n\n  /** START UPDATE V017: 01/11/2019 **/\n  /** Public functions **/\n\n  /**\n   @dev Sets max mint BPro value\n   @param _maxMintBPro [using mocPrecision]\n  */\n  function setMaxMintBPro(uint256 _maxMintBPro) public onlyAuthorizedChanger() {\n    maxMintBPro = _maxMintBPro;\n  }\n\n  /**\n    @dev return Max value posible to mint of BPro\n    @return maxMintBPro\n  */\n  function getMaxMintBPro() public view returns(uint256) {\n    return maxMintBPro;\n  }\n\n  /** END UPDATE V017: 01/11/2019 **/\n\n  /************************************/\n  /***** UPGRADE v0110      ***********/\n  /************************************/\n\n  /** START UPDATE V0112: 24/09/2020  **/\n  /** Upgrade to support multiple commission rates **/\n  /** and rename price interfaces **/\n  /** Public functions **/\n\n  /**********************\n    MoC PRICE PROVIDER\n   *********************/\n\n  /**\n   @dev Sets a new MoCProvider contract\n   @param mocProviderAddress MoC price provider address\n  */\n  function setMoCPriceProvider(address mocProviderAddress) public onlyAuthorizedChanger() {\n    address oldMoCPriceProviderAddress = address(mocPriceProvider);\n    mocPriceProvider = PriceProvider(mocProviderAddress);\n    emit MoCPriceProviderUpdated(oldMoCPriceProviderAddress, address(mocPriceProvider));\n  }\n\n  /**\n   @dev Gets the MoCPriceProviderAddress\n   @return MoC price provider address\n  */\n  function getMoCPriceProvider() public view returns(address) {\n    return address(mocPriceProvider);\n  }\n\n  /**\n   @dev Gets the MoCPrice\n   @return MoC price\n  */\n  function getMoCPrice() public view returns(uint256) {\n    (bytes32 price, bool has) = mocPriceProvider.peek();\n    require(has, \"Oracle have no MoC Price\");\n\n    return uint256(price);\n  }\n\n  /**********************\n    Ex MoCConverter\n   *********************/\n\n   /**\n  * @dev BTC equivalent for the amount of bpros given\n  * @param amount Amount of BPro to calculate the total price\n  * @return total BTC Price of the amount BPros [using reservePrecision]\n  */\n  function bproToBtc(uint256 amount) public view returns(uint256) {\n    uint256 tecPrice = bproTecPrice();\n\n    return mocLibConfig.totalBProInBtc(amount, tecPrice);\n  }\n\n  function docsToBtc(uint256 docAmount) public view returns(uint256) {\n    return mocLibConfig.docsBtcValue(docAmount, peg, getBitcoinPrice());\n  }\n\n  function btcToDoc(uint256 btcAmount) public view returns(uint256) {\n    return mocLibConfig.maxDocsWithBtc(btcAmount, getBitcoinPrice());\n  }\n\n  function bproxToBtc(uint256 bproxAmount, bytes32 bucket) public view returns(uint256) {\n    return mocLibConfig.bproBtcValue(bproxAmount, bucketBProTecPrice(bucket));\n  }\n\n  function btcToBProx(uint256 btcAmount, bytes32 bucket) public view returns(uint256) {\n    return mocLibConfig.maxBProWithBtc(btcAmount, bucketBProTecPrice(bucket));\n  }\n\n\n  /**********************\n    MoC TOKEN\n   *********************/\n\n  /**\n   @dev Sets the MoC token contract address\n   @param mocTokenAddress MoC token contract address\n  */\n  // TODO: Suggestion: create a \"MoCConnectorChanger\" contract and whitelist the address\n  function setMoCToken(address mocTokenAddress) public onlyAuthorizedChanger() {\n    setMoCTokenInternal(mocTokenAddress);\n  }\n\n  /**\n   @dev Gets the MoC token contract address\n   @return MoC token contract address\n  */\n  function getMoCToken() public view returns(address) {\n    return address(mocToken);\n  }\n\n  /**********************\n    MoC VENDORS\n   *********************/\n\n  // TODO: Suggestion: create a \"MoCConnectorChanger\" contract and whitelist the address\n  /**\n   @dev Sets the MoCVendors contract address\n   @param mocVendorsAddress MoCVendors contract address\n  */\n  function setMoCVendors(address mocVendorsAddress) public onlyAuthorizedChanger() {\n    setMoCVendorsInternal(mocVendorsAddress);\n  }\n\n  /**\n   @dev Gets the MoCVendors contract addfress\n   @return MoCVendors contract address\n  */\n  function getMoCVendors() public view returns(address) {\n    return mocVendors;\n  }\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  /************************************/\n  /***** UPGRADE v0110      ***********/\n  /************************************/\n\n  /** START UPDATE V0112: 24/09/2020  **/\n  /** Upgrade to support multiple commission rates **/\n  /** and rename price interfaces **/\n  /** Internal functions **/\n\n  /**********************\n    MoC TOKEN\n   *********************/\n\n  /**\n   @dev Sets the MoC token contract address (internal function)\n   @param mocTokenAddress MoC token contract address\n  */\n  function setMoCTokenInternal(address mocTokenAddress) internal {\n    mocToken = MoCToken(mocTokenAddress);\n\n    emit MoCTokenChanged(mocTokenAddress);\n  }\n\n  /**********************\n    MoC VENDORS\n   *********************/\n\n  /**\n   @dev Sets the MoCVendors contract address (internal function)\n   @param mocVendorsAddress MoCVendors contract address\n  */\n  function setMoCVendorsInternal(address mocVendorsAddress) internal {\n    mocVendors = mocVendorsAddress;\n\n    emit MoCVendorsChanged(mocVendorsAddress);\n  }\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  /**\n    @dev Calculates price at liquidation event as the relation between\n    the doc total supply and the amount of RBTC available to distribute\n  */\n  function setLiquidationPrice() internal {\n    // When coverage is below 1, the amount to\n    // distribute is all the RBTC in the contract\n    uint256 rbtcAvailable = Math.min(globalLockedBitcoin(), rbtcInSystem);\n\n    liquidationPrice = mocLibConfig.liquidationPrice(rbtcAvailable, docTotalSupply());\n  }\n\n  function initializeValues(\n    address _governor,\n    address _btcPriceProvider,\n    uint256 _liq,\n    uint256 _utpdu,\n    uint256 _maxDiscRate,\n    uint256 _dayBlockSpan,\n    uint256 _maxMintBPro,\n    address _mocPriceProvider,\n    bool _liquidationEnabled,\n    uint256 _protected) internal {\n    liq = _liq;\n    utpdu = _utpdu;\n    bproMaxDiscountRate = _maxDiscRate;\n    dayBlockSpan = _dayBlockSpan;\n    governor = IGovernor(_governor);\n    btcPriceProvider = PriceProvider(_btcPriceProvider);\n    // Default values\n    state = States.AboveCobj;\n    peg = 1;\n    maxMintBPro = _maxMintBPro;\n    mocPriceProvider = PriceProvider(_mocPriceProvider);\n    liquidationEnabled = _liquidationEnabled;\n    protected = _protected;\n  }\n\n  function initializeContracts(address _mocTokenAddress, address _mocVendorsAddress) internal  {\n    mocSettlement = IMoCSettlement(connector.mocSettlement());\n    docToken = DocToken(connector.docToken());\n    bproToken = BProToken(connector.bproToken());\n    bproxManager = MoCBProxManager(connector.bproxManager());\n    setMoCTokenInternal(_mocTokenAddress);\n    setMoCVendorsInternal(_mocVendorsAddress);\n  }\n\n  /************************************/\n  /***** UPGRADE v017       ***********/\n  /************************************/\n\n  /** START UPDATE V017: 01/11/2019 **/\n  /** Variables **/\n\n  // Max value posible to mint of BPro\n  uint256 public maxMintBPro;\n\n  /** END UPDATE V017: 01/11/2019 **/\n\n  /************************************/\n  /***** UPGRADE v0110      ***********/\n  /************************************/\n\n  /** START UPDATE V0112: 24/09/2020  **/\n  /** Upgrade to support multiple commission rates **/\n  /** and rename price interfaces **/\n  /** Variables and events **/\n\n  PriceProvider internal mocPriceProvider;\n  MoCToken internal mocToken;\n  address internal mocVendors;\n\n  event MoCPriceProviderUpdated(\n    address oldAddress,\n    address newAddress\n  );\n\n  event MoCTokenChanged (\n    address mocTokenAddress\n  );\n\n  event MoCVendorsChanged (\n    address mocVendorsAddress\n  );\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/interface/IMoCSettlement.sol","source_code":"pragma solidity ^0.5.8;\n\ninterface IMoCSettlement {\n    function getRedeemRequestAt(uint256 _index) external pure returns (address payable, uint256);\n\n    function redeemQueueSize() external pure returns (uint256);\n\n    function docAmountToRedeem(address _who) external pure returns (uint256);\n\n    function isSettlementEnabled() external view returns (bool);\n\n    function runSettlement(uint256 steps) external returns (uint256);\n\n    function nextSettlementBlock() external view returns (uint256);\n}"},{"file_path":"npm/money-on-chain@0.1.14/contracts/interface/IMoCState.sol","source_code":"pragma solidity ^0.5.8;\n\ninterface IMoCState {\n\n     /******STATE MACHINE*********/\n    enum States {\n        // State 0\n        Liquidated,\n        // State 1\n        BProDiscount,\n        // State 2\n        BelowCobj,\n        // State 3\n        AboveCobj\n    }\n\n\n    function addToRbtcInSystem(uint256 btcAmount) external;\n\n    function subtractRbtcFromSystem(uint256 btcAmount) external;\n\n    function coverage(bytes32 bucket) external view returns(uint256);\n\n    function getRbtcRemainder() external view returns(uint256);\n\n    function liq() external view returns(uint256);\n\n    function state() external view returns(States);\n\n    function peg() external view returns(uint256);\n\n    function dayBlockSpan() external view returns(uint256);\n\n    function getBitcoinPrice() external view returns(uint256);\n\n    function getMoCPrice() external view returns(uint256);\n\n    function getProtected() external view returns(uint256);\n\n    function globalCoverage() external view returns(uint256);\n\n    function getMoCVendors() external view returns(address);\n\n    function getMoCToken() external view returns(address);\n\n    function nextState() external;\n\n    function maxBProWithDiscount() external view returns(uint256);\n\n    function absoluteMaxBPro() external view returns(uint256);\n\n    function absoluteMaxDoc() external view returns(uint256);\n\n    function freeDoc() external view returns(uint256);\n\n    function bproTecPrice() external view returns(uint256);\n\n    function bproSpotDiscountRate() external view returns(uint256);\n\n    function bproDiscountPrice() external view returns(uint256);\n\n    function bucketBProTecPrice(bytes32 bucket) external view returns(uint256);\n\n    function currentAbundanceRatio() external view returns(uint256);\n\n    function abundanceRatio(uint256 doc0) external view returns(uint256);\n\n    function daysToSettlement() external view returns(uint256);\n\n    function leverage(bytes32 bucket) external view returns(uint256);\n\n    function getBucketNBTC(bytes32 bucket) external view returns(uint256);\n\n    function getLiquidationPrice() external view returns(uint256);\n\n    function maxBProxBtcValue(bytes32 bucket) external view returns(uint256);\n\n    function bucketBProTecPriceHelper(bytes32 bucket) external view returns(uint256);\n\n    // Ex Mocconverter\n    function docsToBtc(uint256 docAmount) external view returns(uint256);\n    function btcToDoc(uint256 btcAmount) external view returns(uint256);\n    function bproxToBtc(uint256 bproxAmount, bytes32 bucket) external view returns(uint256);\n    function btcToBProx(uint256 btcAmount, bytes32 bucket) external view returns(uint256);\n\n\n}"},{"file_path":"project/contracts/compat/DeployableMoCSettlement.sol","source_code":"// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.5.17;\npragma experimental ABIEncoderV2;\n\nimport { MoCSettlement } from \"@moc/rbtc/contracts/MoCSettlement.sol\";\n\ncontract DeployableMoCSettlement is MoCSettlement {}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/access/Roles.sol","source_code":"pragma solidity ^0.5.0;\n\n/**\n * @title Roles\n * @dev Library for managing addresses assigned to a Role.\n */\nlibrary Roles {\n    struct Role {\n        mapping (address => bool) bearer;\n    }\n\n    /**\n     * @dev Give an account access to this role.\n     */\n    function add(Role storage role, address account) internal {\n        require(!has(role, account), \"Roles: account already has role\");\n        role.bearer[account] = true;\n    }\n\n    /**\n     * @dev Remove an account's access to this role.\n     */\n    function remove(Role storage role, address account) internal {\n        require(has(role, account), \"Roles: account does not have role\");\n        role.bearer[account] = false;\n    }\n\n    /**\n     * @dev Check if an account has this role.\n     * @return bool\n     */\n    function has(Role storage role, address account) internal view returns (bool) {\n        require(account != address(0), \"Roles: account is the zero address\");\n        return role.bearer[account];\n    }\n}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/token/ERC20/IERC20.sol","source_code":"pragma solidity ^0.5.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP. Does not include\n * the optional functions; to access them see `ERC20Detailed`.\n */\ninterface IERC20 {\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a `Transfer` event.\n     */\n    function transfer(address recipient, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through `transferFrom`. This is\n     * zero by default.\n     *\n     * This value changes when `approve` or `transferFrom` are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * > Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an `Approval` event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `sender` to `recipient` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a `Transfer` event.\n     */\n    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to `approve`. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/access/roles/MinterRole.sol","source_code":"pragma solidity ^0.5.0;\n\nimport \"../Roles.sol\";\n\ncontract MinterRole {\n    using Roles for Roles.Role;\n\n    event MinterAdded(address indexed account);\n    event MinterRemoved(address indexed account);\n\n    Roles.Role private _minters;\n\n    constructor () internal {\n        _addMinter(msg.sender);\n    }\n\n    modifier onlyMinter() {\n        require(isMinter(msg.sender), \"MinterRole: caller does not have the Minter role\");\n        _;\n    }\n\n    function isMinter(address account) public view returns (bool) {\n        return _minters.has(account);\n    }\n\n    function addMinter(address account) public onlyMinter {\n        _addMinter(account);\n    }\n\n    function renounceMinter() public {\n        _removeMinter(msg.sender);\n    }\n\n    function _addMinter(address account) internal {\n        _minters.add(account);\n        emit MinterAdded(account);\n    }\n\n    function _removeMinter(address account) internal {\n        _minters.remove(account);\n        emit MinterRemoved(account);\n    }\n}\n"},{"file_path":"npm/moc-governance@0.1.0/contracts/Governance/Governed.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"./IGovernor.sol\";\nimport \"zos-lib/contracts/Initializable.sol\";\n\n/**\n  @title Governed\n  @notice Base contract to be inherited by governed contracts\n  @dev This contract is not usable on its own since it does not have any _productive useful_ behaviour\n  The only purpose of this contract is to define some useful modifiers and functions to be used on the\n  governance aspect of the child contract\n  */\ncontract Governed is Initializable {\n\n  /**\n    @notice The address of the contract which governs this one\n   */\n  IGovernor public governor;\n\n  string constant private NOT_AUTHORIZED_CHANGER = \"not_authorized_changer\";\n\n  /**\n    @notice Modifier that protects the function\n    @dev You should use this modifier in any function that should be called through\n    the governance system\n   */\n  modifier onlyAuthorizedChanger() {\n    require(governor.isAuthorizedChanger(msg.sender), NOT_AUTHORIZED_CHANGER);\n    _;\n  }\n\n  /**\n    @notice Initialize the contract with the basic settings\n    @dev This initialize replaces the constructor but it is not called automatically.\n    It is necessary because of the upgradeability of the contracts\n    @param _governor Governor address\n   */\n  function initialize(IGovernor _governor) public initializer {\n    governor = _governor;\n  }\n\n  /**\n    @notice Change the contract's governor. Should be called through the old governance system\n    @param newIGovernor New governor address\n   */\n  function changeIGovernor(IGovernor newIGovernor) public onlyAuthorizedChanger {\n    governor = newIGovernor;\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/interface/IMoC.sol","source_code":"pragma solidity ^0.5.8;\n\ninterface IMoC {\n    function() external payable;\n\n    function sendToAddress(address payable receiver, uint256 btcAmount) external returns(bool);\n}"},{"file_path":"npm/money-on-chain@0.1.14/contracts/MoCBProxManager.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"./base/MoCBase.sol\";\nimport \"./MoCBucketContainer.sol\";\n\ncontract MoCBProxManager is MoCBucketContainer {\n  using SafeMath for uint256;\n  uint256 constant MIN_ALLOWED_BALANCE = 0;\n\n  /**\n    @dev Initializes the contract\n    @param connectorAddress MoCConnector contract address\n    @param _governor Governor contract address\n    @param _c0Cobj Bucket C0 objective coverage\n    @param _x2Cobj Bucket X2 objective coverage\n  */\n  function initialize(\n    address connectorAddress,\n    address _governor,\n    uint256 _c0Cobj,\n    uint256 _x2Cobj\n  ) public initializer {\n    initializeBase(connectorAddress);\n    initializeValues(_governor);\n    createBucket(BUCKET_C0, _c0Cobj, true);\n    createBucket(BUCKET_X2, _x2Cobj, false);\n  }\n\n  /**\n    @dev returns user balance\n    @param bucket BProx corresponding bucket to get balance from\n    @param userAddress user address to get balance from\n    @return total balance for the userAddress\n  */\n  function bproxBalanceOf(bytes32 bucket, address userAddress) public view returns(uint256) {\n    BProxBalance memory userBalance = mocBuckets[bucket].bproxBalances[userAddress];\n    if (!hasValidBalance(bucket, userAddress, userBalance.index)) return 0;\n    return userBalance.value;\n  }\n\n  /**\n    @dev verifies that this user has assigned balance for the given bucket\n    @param bucket corresponding Leveraged bucket to get balance from\n    @param userAddress user address to verify balance for\n    @param index index, starting from 1, where the address of the user is being kept\n    @return true if the user has assigned balance\n  */\n  function hasValidBalance(bytes32 bucket, address userAddress, uint index) public view returns(bool) {\n    return (index != 0) &&\n      (index <= getActiveAddressesCount(bucket)) &&\n      (mocBuckets[bucket].activeBalances[index - 1] == userAddress);\n  }\n\n  /**\n    @dev  Assigns the amount of BProx\n    @param bucket bucket from which the BProx will be removed\n    @param account user address to redeem for\n    @param bproxAmount bprox amount to redeem [using mocPresicion]\n    @param totalCost btc value of bproxAmount [using reservePrecision]\n  */\n  function assignBProx(bytes32 bucket, address payable account, uint256 bproxAmount, uint256 totalCost)\n  public onlyWhitelisted(msg.sender) {\n    uint256 currentBalance = bproxBalanceOf(bucket, account);\n\n    setBProxBalanceOf(bucket, account, currentBalance.add(bproxAmount));\n    addValuesToBucket(bucket, totalCost, 0, bproxAmount);\n  }\n\n  /**\n    @dev Removes the amount of BProx and substract BTC cost from bucket\n    @param bucket bucket from which the BProx will be removed\n    @param userAddress user address to redeem for\n    @param bproxAmount bprox amount to redeem [using mocPresicion]\n    @param totalCost btc value of bproxAmount [using reservePrecision]\n  */\n  function removeBProx(bytes32 bucket, address payable userAddress, uint256 bproxAmount, uint256 totalCost)\n  public onlyWhitelisted(msg.sender) {\n    uint256 currentBalance = bproxBalanceOf(bucket, userAddress);\n\n    setBProxBalanceOf(bucket, userAddress, currentBalance.sub(bproxAmount));\n    substractValuesFromBucket(bucket, totalCost, 0, bproxAmount);\n  }\n\n  /**\n    @dev Sets the amount of BProx\n    @param bucket bucket from which the BProx will be setted\n    @param userAddress user address to redeem for\n    @param value bprox amount to redeem [using mocPresicion]\n  */\n  function setBProxBalanceOf(bytes32 bucket, address payable userAddress, uint256 value) public onlyWhitelisted(msg.sender) {\n    mocBuckets[bucket].bproxBalances[userAddress].value = value;\n    uint256 index = mocBuckets[bucket].bproxBalances[userAddress].index;\n    if (!hasValidBalance(bucket, userAddress, index))\n      index = 0;\n\n    bool hasBalance = value > MIN_ALLOWED_BALANCE;\n    // The address is not in the array\n    if (index == 0) {\n      if (hasBalance) {\n        if (mocBuckets[bucket].activeBalances.length == mocBuckets[bucket].activeBalancesLength) {\n          mocBuckets[bucket].activeBalances.length += 1;\n        }\n        uint256 currentIndex = mocBuckets[bucket].activeBalancesLength++;\n        mocBuckets[bucket].activeBalances[currentIndex] = userAddress;\n        mocBuckets[bucket].bproxBalances[userAddress].index = mocBuckets[bucket].activeBalancesLength;\n      }\n    } else {\n      if (!hasBalance) {\n        // We need to delete this address from the tracker\n        uint256 lastActiveIndex = mocBuckets[bucket].activeBalancesLength;\n        address payable keyToMove = mocBuckets[bucket].activeBalances[lastActiveIndex - 1];\n        mocBuckets[bucket].activeBalances[index - 1] = keyToMove;\n        // Alternative index and array decreases lenght to prevent gas limit\n        mocBuckets[bucket].activeBalancesLength--;\n        // Update moved key index\n        mocBuckets[bucket].bproxBalances[keyToMove].index = index;\n        // Disable empty account index (0 == NULL)\n        mocBuckets[bucket].bproxBalances[userAddress].index = 0;\n      }\n    }\n  }\n\n  /**\n   @dev intializes values of the contract\n   @param _governor Governor contract address\n  */\n  function initializeValues(address _governor) internal {\n    governor = IGovernor(_governor);\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/MoCEMACalculator.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"moc-governance/contracts/Governance/Governed.sol\";\nimport \"moc-governance/contracts/Governance/IGovernor.sol\";\n\ncontract MoCEMACalculator is Governed {\n  using SafeMath for uint256;\n\n  event MovingAverageCalculation (\n    uint256 price,\n    uint256 movingAverage\n  );\n\n  uint256 internal bitcoinMovingAverage;\n  uint256 public smoothingFactor;\n  uint256 public lastEmaCalculation;\n  uint256 public emaCalculationBlockSpan;\n\n  uint256 constant public PRICE_PRECISION =  10 ** 18;\n  uint256 constant public FACTOR_PRECISION = 10 ** 18;\n\n  function getBitcoinMovingAverage() public view returns(uint256) {\n    return bitcoinMovingAverage;\n  }\n\n  function getSmoothingFactor() public view returns(uint256) {\n    return smoothingFactor;\n  }\n\n  function setSmoothingFactor(uint256 factor) public onlyAuthorizedChanger() {\n    _doSetSmoothingFactor(factor);\n  }\n\n  function getGovernorAddress() public view returns(address){\n    return address(governor);\n  }\n\n  function getEmaCalculationBlockSpan() public view returns(uint256){\n    return emaCalculationBlockSpan;\n  }\n\n  /**\n  * @param blockSpan Defines how many blocks should pass between BMA calculations\n  **/\n  function setEmaCalculationBlockSpan(uint256 blockSpan) public onlyAuthorizedChanger() {\n    emaCalculationBlockSpan = blockSpan;\n  }\n\n  function shouldCalculateEma() public view returns(bool) {\n    return block.number >= lastEmaCalculation.add(emaCalculationBlockSpan);\n  }\n\n  function getLastEmaCalculation() public view returns(uint256) {\n    return lastEmaCalculation;\n  }\n\n  /**\n    @dev Provides Bitcoin's Price and Moving average.\n     More information of EMA calculation https://en.wikipedia.org/wiki/Exponential_smoothing\n    * @param initialEma Initial ema value\n    * @param smoothFactor Weight coefficient for EMA calculation.\n    * @param emaBlockSpan Block count in a period for EMA calculation\n  */\n  function initializeMovingAverage(uint256 initialEma, uint256 smoothFactor, uint256 emaBlockSpan) internal {\n    _doSetSmoothingFactor(smoothFactor);\n    lastEmaCalculation = block.number;\n    bitcoinMovingAverage = initialEma;\n    emaCalculationBlockSpan = emaBlockSpan;\n  }\n\n  /**\n    @dev Calculates a EMA of the price.\n     More information of EMA calculation https://en.wikipedia.org/wiki/Exponential_smoothing\n    @param btcPrice Current price.\n  */\n  function setBitcoinMovingAverage(uint256 btcPrice) internal {\n    if (shouldCalculateEma()) {\n      uint256 weightedPrice = btcPrice.mul(smoothingFactor);\n      uint256 currentEma = bitcoinMovingAverage.mul(coefficientComp()).add(weightedPrice)\n        .div(FACTOR_PRECISION);\n\n      lastEmaCalculation = block.number;\n      bitcoinMovingAverage = currentEma;\n\n      emit MovingAverageCalculation(btcPrice, currentEma);\n    }\n  }\n\n  /**\n    @dev Calculates the smoothing factor complement\n  */\n  function coefficientComp() internal view returns(uint256) {\n    return FACTOR_PRECISION.sub(smoothingFactor);\n  }\n\n  function initializeGovernor(address _governor) internal {\n    governor = IGovernor(_governor);\n  }\n\n  function _doSetSmoothingFactor(uint256 factor) private {\n    require(factor <= FACTOR_PRECISION, \"Invalid smoothing factor\");\n    smoothingFactor = factor;\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/MoCHelperLib.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\n\nlibrary MoCHelperLib {\n\n  struct MocLibConfig {\n    uint256 reservePrecision;\n    uint256 dayPrecision;\n    uint256 mocPrecision;\n  }\n\n  using SafeMath for uint256;\n\n  uint256 constant UINT256_MAX = ~uint256(0);\n\n  /**\n    @dev Returns max uint256 value constant.\n    @return max uint256 value constant\n  */\n  function getMaxInt(MocLibConfig storage /*config*/) public pure returns(uint256) {\n    return UINT256_MAX;\n  }\n\n  /**\n    @dev Calculates average interest using integral function: T =  Rate = a * (x ** b) + c\n    @param tMax maxInterestRate [using mocPrecision]\n    @param power factor [using noPrecision]\n    @param tMin minInterestRate C0 doc amount [using mocPrecision]\n    @param abRat1 initial abundance ratio [using mocPrecision]\n    @param abRat2 final abundance ratio [using mocPrecision]\n    @return average interest rate [using mocPrecision]\n  */\n  function inrateAvg(MocLibConfig storage config, uint256 tMax, uint256 power, uint256 tMin, uint256 abRat1, uint256 abRat2)\n  public view returns(uint256) {\n    require(tMax > tMin, \"Max inrate should be bigger than Min inrate\");\n    uint256 abRat1Comp = config.mocPrecision.sub(abRat1);\n    uint256 abRat2Comp = config.mocPrecision.sub(abRat2);\n\n    if (abRat1 == abRat2) {\n      return potential(config, tMax, power, tMin, abRat1Comp);\n    }\n    else if (abRat2 < abRat1) {\n      return avgInt(config, tMax, power, tMin, abRat1Comp, abRat2Comp);\n    }\n    else {\n      return avgInt(config, tMax, power, tMin, abRat2Comp, abRat1Comp);\n    }\n  }\n\n  /**\n    @dev Calculates spot interest rate that BProx owners should pay to BPro owners: Rate = tMax * (abRatio ** power) + tMin\n    @param tMin min interest rate [using mocPrecision]\n    @param power power to use in the formula [using NoPrecision]\n    @param tMax max interest rate [using mocPrecision]\n    @param abRatio bucket C0  abundance Ratio [using mocPrecision]\n   */\n  function spotInrate(\n    MocLibConfig storage config, uint256 tMax, uint256 power, uint256 tMin, uint256 abRatio\n  ) public view returns(uint256) {\n    uint256 abRatioComp = config.mocPrecision.sub(abRatio);\n\n    return potential(config, tMax, power, tMin, abRatioComp);\n  }\n\n  /**\n    @dev Calculates potential interests function with given parameters: Rate = a * (x ** b) + c\n    @param a maxInterestRate [using mocPrecision]\n    @param b factor [using NoPrecision]\n    @param c minInterestRate C0 doc amount [using mocPrecision]\n    @param value global doc amount [using mocPrecision]\n  */\n  function potential(MocLibConfig storage config, uint256 a, uint256 b, uint256 c, uint256 value)\n  public view returns(uint256) {\n    // value ** b\n    // [MOC] ** [] = [MOC]\n    uint256 aux1 = pow(value, b, config.mocPrecision);\n    // (a * aux1) + c\n    // [MOC] [MOC] / [MOC] + [MOC] = [MOC]\n    return a.mul(aux1).div(config.mocPrecision).add(c);\n  }\n\n  /**\n    @dev Calculates average of the integral function:\n     T = (\n              (c * xf + ((a * (xf ** (b + 1))) / (b + 1))) -\n              (c * xi + ((a * (xi ** (b + 1))) / (b + 1)))\n             ) / (xf - xi)\n    @param a maxInterestRate [using mocPrecision]\n    @param b factor [using NoPrecision]\n    @param c minInterestRate C0 doc amount [using mocPrecision]\n    @param value1 value to put in the function [using mocPrecision]\n    @param value2 value to put in the function [using mocPrecision]\n    @return average interest rate [using mocPrecision]\n  */\n  function avgInt(MocLibConfig storage config, uint256 a, uint256 b, uint256 c, uint256 value1, uint256 value2)\n  public view returns(uint256) {\n    // value2 - value1\n    // [MOC]\n    uint256 diff = value2.sub(value1);\n    // ((c * (1 - value1) + ((a * ((1 - value1) ** (b + 1))) / (b + 1)))\n    uint256 intV1 = integral(config, a, b, c, value1);\n    // ((c * (1 - value2) + ((a * ((1 - value2) ** (b + 1))) / (b + 1)))\n    uint256 intV2 = integral(config,  a, b, c, value2);\n    // (secOp - first) / diff\n    // ([MOC][MOC] - [MOC][MOC]) / [MOC] = [MOC]\n    return intV2.sub(intV1).div(diff);\n  }\n\n  /**\n    @dev Calculates integral of the exponential function: T = c * (value) + (a * value ** (b + 1)) / (b + 1))\n    @param a maxInterestRate [using mocPrecision]\n    @param b factor [using NoPrecision]\n    @param c minInterestRate C0 doc amount [using mocPrecision]\n    @param value value to put in the function [using mocPrecision]\n    @return integration result [using mocPrecision]\n  */\n  function integral(MocLibConfig storage config, uint256 a, uint256 b, uint256 c, uint256 value)\n  public view returns(uint256) {\n    // b + 1\n    // [NONE]\n    uint256 b2 = b.add(1);\n    // c * value\n    // [MOC][MOC]\n    uint256 firstOp = c.mul(value);\n    // [MOC]\n    uint256 pow = pow(value, b2, config.mocPrecision);\n    // (a * value ** b2) / b2)\n    // [MOC][MOC]\n    uint256 secOp = a.mul(pow).div(b2);\n    // (firstOp + secOp)\n    // [MOC][MOC] + [MOC][MOC] = [MOC][MOC]\n    return firstOp.add(secOp);\n  }\n\n  /**\n  * @dev Relation between docs in bucket 0 and Doc total supply\n  * @param doc0 doc count in bucket 0 [using mocPrecision]\n  * @param doct total doc supply [using mocPrecision]\n  * @return abundance ratio [using mocPrecision]\n  */\n  function abundanceRatio(MocLibConfig storage config, uint256 doc0, uint256 doct)\n  public view returns(uint256) {\n    if (doct == 0) {\n      return config.mocPrecision;\n    }\n    // [DOC] [MOC] / [DOC] = [MOC]\n    return doc0.mul(config.mocPrecision).div(doct);\n  }\n\n  /**\n    @dev Returns the Ratio to apply to BPro Price in discount situations: SpotDiscountRate = TPD * (utpdu - cob) / (uptdu -liq)\n    @param bproLiqDiscountRate Discount rate applied at Liquidation level coverage [using mocPrecision]\n    @param liq Liquidation coverage threshold [using mocPrecision]\n    @param utpdu Discount coverage threshold [using mocPrecision]\n    @param cov Actual global Coverage threshold [using mocPrecision]\n    @return Spot discount rate [using mocPrecision]\n  */\n  function bproSpotDiscountRate(\n    MocLibConfig storage libConfig, uint256 bproLiqDiscountRate,\n    uint256 liq, uint256 utpdu, uint256 cov\n  ) public view returns(uint256) {\n    require(bproLiqDiscountRate < libConfig.mocPrecision, \"Discount rate should be lower than 1\");\n\n    if (cov >= utpdu) {\n      return 0;\n    }\n\n    // utpdu - liq\n    // [MOC] - [MOC] = [MOC]\n    uint256 utpduLiqDiff = utpdu.sub(liq);\n\n    // utpdu - cov\n    // [MOC] - [MOC] = [MOC]\n    uint256 utpduCovDiff = utpdu.sub(cov);\n\n    // TPD * utpduCovDiff / utpduLiqDiff\n    // [MOC] * [MOC] / [MOC] = [MOC]\n    return bproLiqDiscountRate.mul(utpduCovDiff).div(utpduLiqDiff);\n  }\n\n  /**\n    @dev Max amount of BPro to available with discount: MaxBProWithDiscount = (uTPDU * nDOC * PEG - (nBTC * B)) / (TPusd * TPD)\n    @param nB Total BTC amount [using reservePrecision]\n    @param nDoc DOC amount [using mocPrecision]\n    @param utpdu Discount coverage threshold [using mocPrecision]\n    @param peg peg value\n    @param btcPrice BTC price [using mocPrecision]\n    @param bproUsdPrice bproUsdPrice [using mocPrecision]\n    @param spotDiscount spot discount [using mocPrecision]\n    @return Total BPro amount [using mocPrecision]\n  */\n  function maxBProWithDiscount(\n    MocLibConfig storage libConfig, uint256 nB, uint256 nDoc, uint256 utpdu,\n    uint256 peg, uint256 btcPrice, uint256 bproUsdPrice, uint256 spotDiscount\n  ) public view returns(uint256)  {\n    require(spotDiscount < libConfig.mocPrecision, \"Discount Rate should be lower than 1\");\n\n    if (spotDiscount == 0) {\n      return 0;\n    }\n\n    // nBTC * B\n    // [RES] * [MOC] / [RES] = [MOC]\n    uint256 nbUsdValue = nB.mul(btcPrice).div(libConfig.reservePrecision);\n\n    // (TPusd * (1 - TPD))\n    // [MOC] * [MOC] / [MOC] = [MOC]\n    uint256 bproDiscountPrice = bproUsdPrice.mul(libConfig.mocPrecision.sub(spotDiscount))\n      .div(libConfig.mocPrecision);\n\n    return maxBProWithDiscountAux(libConfig, nbUsdValue, nDoc, utpdu, peg, bproDiscountPrice);\n  }\n\n  /**\n    @dev Max amount of BPro to available with discount: MaxBProWithDiscount = (uTPDU * nDOC * PEG - (nBTC * B)) / (TPusd * TPD)\n    @param nbUsdValue Total amount of BTC in USD [using mocPrecision]\n    @param nDoc DOC amount [using mocPrecision]\n    @param utpdu Discount coverage threshold [using mocPrecision]\n    @param bproDiscountPrice bproUsdPrice with discount applied [using mocPrecision]\n    @param peg peg value\n    @return Total BPro amount [using mocPrecision]\n  */\n  function maxBProWithDiscountAux(\n    MocLibConfig storage libConfig, uint256 nbUsdValue, uint256 nDoc,\n    uint256 utpdu, uint256 peg, uint256 bproDiscountPrice\n  ) internal view returns(uint256) {\n\n    // uTPDU * nDOC * PEG\n    // [MOC] * [MOC] / [MOC] = [MOC]\n    uint256 coverageUSDAmount = utpdu.mul(nDoc).mul(peg).div(libConfig.mocPrecision);\n\n    // This case only occurs with Coverage below 1\n    if (coverageUSDAmount <= nbUsdValue) {\n      return 0;\n    }\n\n    // ([MOC] - [MOC]) * [RES] / [MOC] = [RES]\n    return coverageUSDAmount.sub(nbUsdValue).mul(libConfig.reservePrecision).div(bproDiscountPrice);\n  }\n\n  /**\n    @dev Calculates Locked bitcoin\n    @param btcPrice BTC price [using mocPrecision]\n    @param nDoc Docs amount [using mocPrecision]\n    @param peg peg value\n    @return Locked bitcoin [using reservePrecision]\n  */\n  function lockedBitcoin(\n    MocLibConfig storage libConfig, uint256 btcPrice, uint256 nDoc, uint256 peg\n  ) public view returns(uint256) {\n    return nDoc.mul(peg).mul(libConfig.reservePrecision).div(btcPrice);\n  }\n\n  /**\n    @dev Calculates price at liquidation event as a relation between the doc total supply\n    and the amount of RBTC available to distribute\n    @param rbtcAmount RBTC to distribute [using reservePrecision]\n    @param nDoc Docs amount [using mocPrecision]\n    @return Price at liquidation event [using mocPrecision]\n  */\n  function liquidationPrice(MocLibConfig storage libConfig, uint256 rbtcAmount, uint256 nDoc)\n  public view returns(uint256) {\n    // [MOC] * [RES] / [RES]\n    return nDoc.mul(libConfig.reservePrecision).div(rbtcAmount);\n  }\n\n  /**\n    @dev Calculates BPro BTC price: TPbtc = (nB-LB) / nTP\n    @param nB Total BTC amount [using reservePrecision]\n    @param lb Locked bitcoins amount [using reservePrecision]\n    @param nTP BPro amount [using mocPrecision]\n    @return BPro BTC price [using reservePrecision]\n  */\n  function bproTecPrice(MocLibConfig storage libConfig, uint256 nB, uint256 lb, uint256 nTP)\n    public view returns(uint256) {\n    // Liquidation happens before this condition turns true\n    if (nB < lb) {\n      return 0;\n    }\n\n    if (nTP == 0) {\n      return libConfig.mocPrecision;\n    }\n    // ([RES] - [RES]) * [MOC] / [MOC]\n    return nB.sub(lb).mul(libConfig.mocPrecision).div(nTP);\n  }\n\n  /**\n    @dev Calculates BPro BTC price: BProxInBPro = bproxTecPrice / bproPrice\n    @param bproxTecPrice BProx BTC price [using reservePrecision]\n    @param bproPrice Trog BTC price [using reservePrecision]\n    @return BProx price in BPro [using mocPrecision]\n  */\n  function bproxBProPrice(\n    MocLibConfig storage libConfig, uint256 bproxTecPrice, uint256 bproPrice\n  ) public view returns(uint256) {\n    // [RES] * [MOC] / [RES] = [MOC]\n    return bproxTecPrice.mul(libConfig.mocPrecision).div(bproPrice);\n  }\n\n  /**\n    @dev Returns a new value with the discountRate applied: TPbtc = (price)* (1 - discountRate)\n    @param price Price [using SomePrecision]\n    @param discountRate Discount rate to apply [using mocPrecision]\n    @return Price with discount applied [using SomePrecision]\n  */\n  function applyDiscountRate(MocLibConfig storage libConfig, uint256 price, uint256 discountRate)\n    public view returns(uint256) {\n\n    uint256 discountCoeff = libConfig.mocPrecision.sub(discountRate);\n\n    return price.mul(discountCoeff).div(libConfig.mocPrecision);\n  }\n\n  /**\n    @dev Returns the amount of interest to pay: TPbtc = price * interestRate\n    @param value Cost to apply interest [using SomePrecision]\n    @param interestRate Interest rate to apply [using mocPrecision]\n    @return Interest cost based on the value and interestRate [using SomePrecision]\n  */\n  function getInterestCost(MocLibConfig storage libConfig, uint256 value, uint256 interestRate)\n    public view returns(uint256) {\n    // [ORIGIN] * [MOC] / [MOC] = [ORIGIN]\n    return value.mul(interestRate).div(libConfig.mocPrecision);\n  }\n\n  /**\n    @dev Calculates Coverage: Coverage = nB / LB\n    @param nB Total BTC amount [using reservePrecision]\n    @param lB Locked bitcoins amount [using reservePrecision]\n    @return Coverage [using mocPrecision]\n  */\n  function coverage(MocLibConfig storage libConfig, uint256 nB, uint256 lB) public view\n    returns(uint256) {\n    if (lB == 0) {\n      return UINT256_MAX;\n    }\n\n    return nB.mul(libConfig.mocPrecision).div(lB);\n  }\n\n /**\n    @dev Calculates Leverage from Coverage: Leverage = C / (C - 1)\n    @param cov Coverage [using mocPrecision]\n    @return Leverage [using mocPrecision]\n  */\n  function leverageFromCoverage(MocLibConfig storage libConfig, uint256 cov)\n  public view returns(uint256) {\n    if (cov == UINT256_MAX) {\n      return libConfig.mocPrecision;\n    }\n\n    if (cov <= libConfig.mocPrecision) {\n      return UINT256_MAX;\n    }\n\n    return cov.mul(libConfig.mocPrecision).div(cov.sub(libConfig.mocPrecision));\n  }\n\n /**\n    @dev Calculates Leverage: Leverage = nB / (nB - lB)\n    @param nB Total BTC amount [using reservePrecision]\n    @param lB Locked bitcoins amount [using reservePrecision]\n    @return Leverage [using mocPrecision]\n  */\n  function leverage(MocLibConfig storage libConfig, uint256 nB,uint256 lB)\n  public view returns(uint256) {\n    if (lB == 0) {\n      return libConfig.mocPrecision;\n    }\n\n    if (nB <= lB) {\n      return UINT256_MAX;\n    }\n\n    return nB.mul(libConfig.mocPrecision).div(nB.sub(lB));\n  }\n\n  /**\n    @dev Price in BTC of the amount of Docs\n    @param amount Total BTC amount [using reservePrecision]\n    @param btcPrice BTC price [using mocPrecision]\n    @return Total value [using reservePrecision]\n  */\n  function docsBtcValue(\n    MocLibConfig storage libConfig, uint256 amount,uint256 peg, uint256 btcPrice\n  ) public view returns(uint256) {\n    require(btcPrice > 0,\"Bitcoin price should be more than zero\");\n    require(libConfig.reservePrecision > 0, \"Precision should be more than zero\");\n    //Total = amount / satoshi price\n    //Total = amount / (btcPrice / precision)\n    // [RES] * [MOC] / [MOC]\n    uint256 docBtcTotal = amount.mul(libConfig.mocPrecision).mul(peg).div(btcPrice);\n\n    return docBtcTotal;\n  }\n\n /**\n    @dev Price in RBTC of the amount of BPros\n    @param bproAmount amount of BPro [using mocPrecision]\n    @param bproBtcPrice BPro price in RBTC [using reservePrecision]\n    @return Total value [using reservePrecision]\n  */\n  function bproBtcValue(MocLibConfig storage libConfig, uint256 bproAmount, uint256 bproBtcPrice)\n    public view returns(uint256) {\n    require(libConfig.reservePrecision > 0, \"Precision should be more than zero\");\n\n    // [MOC] * [RES] / [MOC] =  [RES]\n    uint256 bproBtcTotal = bproAmount.mul(bproBtcPrice).div(libConfig.mocPrecision);\n\n    return bproBtcTotal;\n  }\n\n  /**\n    @dev Max amount of Docs to issue: MaxDoc = ((nB*B)-(Cobj*B/Bcons*nDoc*PEG))/(PEG*(Cobj*B/BCons-1))\n    @param nB Total BTC amount [using reservePrecision]\n    @param cobj Target Coverage [using mocPrecision]\n    @param nDoc DOC amount [using mocPrecision]\n    @param peg peg value\n    @param btcPrice BTC price [using mocPrecision]\n    @param bCons BTC conservative price [using mocPrecision]\n    @return Total Docs amount [using mocPrecision]\n  */\n  function maxDoc(\n    MocLibConfig storage libConfig, uint256 nB,\n    uint256 cobj, uint256 nDoc, uint256 peg, uint256 btcPrice, uint256 bCons\n  ) public view returns(uint256) {\n    require(libConfig.reservePrecision > 0, \"Invalid Precision\");\n    require(libConfig.mocPrecision > 0, \"Invalid Precision\");\n\n    // If cobj is less than 1, just return zero\n    if (cobj < libConfig.mocPrecision)\n      return 0;\n\n    // Cobj * B / BCons\n    // [MOC] * [MOC] / [MOC] = [MOC]\n    uint256 adjCobj = cobj.mul(btcPrice).div(bCons);\n\n    return maxDocAux(libConfig, nB, adjCobj, nDoc, peg, btcPrice);\n  }\n\n  function maxDocAux(MocLibConfig storage libConfig, uint256 nB, uint256 adjCobj, uint256 nDoc, uint256 peg, uint256 btcPrice)\n  internal view returns(uint256) {\n    // (nB*B)\n    // [RES] [MOC] [MOC] / [RES] = [MOC] [MOC]\n    uint256 firstOperand = nB.mul(btcPrice).mul(libConfig.mocPrecision).div(libConfig.reservePrecision);\n    // (adjCobj*nDoc*PEG)\n    // [MOC] [MOC]\n    uint256 secOperand = adjCobj.mul(nDoc).mul(peg);\n    // (PEG*(adjCobj-1)\n    // [MOC]\n    uint256 denom = adjCobj.sub(libConfig.mocPrecision).mul(peg);\n\n    if (firstOperand <= secOperand)\n      return 0;\n\n    // ([MOC][MOC] - [MOC][MOC]) / [MOC] = [MOC]\n    return (firstOperand.sub(secOperand)).div(denom);\n  }\n\n  /**\n    @dev Max amount of BPro to redeem: MaxBPro = ((nB*B)-(Cobj*nDoc*PEG))/TPusd\n    @param nB Total BTC amount [using reservePrecision]\n    @param cobj Target Coverage [using mocPrecision]\n    @param nDoc Target Coverage [using mocPrecision]\n    @param peg peg value\n    @param btcPrice BTC price [using mocPrecision]\n    @param bCons BTC conservative price [using mocPrecision]\n    @param bproUsdPrice bproUsdPrice [using mocPrecision]\n    @return Total BPro amount [using mocPrecision]\n  */\n  function maxBPro(\n    MocLibConfig storage libConfig, uint256 nB, uint256 cobj,\n    uint256 nDoc, uint256 peg, uint256 btcPrice, uint256 bCons, uint256 bproUsdPrice\n  ) public view returns(uint256) {\n    require(libConfig.reservePrecision > 0, \"Invalid Precision\");\n    require(libConfig.mocPrecision > 0, \"Invalid Precision\");\n\n    // Cobj * btcPrice / BCons\n    // [MOC] * [MOC] / [MOC] = [MOC]\n    uint256 adjCobj = cobj.mul(btcPrice).div(bCons);\n    // (nB * btcPrice)\n    // [RES] * [MOC] * [MOC] / [RES] = [MOC] [MOC]\n    uint256 firstOperand = nB.mul(btcPrice)\n      .mul(libConfig.mocPrecision)\n      .div(libConfig.reservePrecision);\n    // (adjCobj * nDoc * PEG)\n    // [MOC] * [MOC]\n    uint256 secOperand = adjCobj.mul(nDoc).mul(peg);\n\n    if (firstOperand <= secOperand)\n      return 0;\n\n    // ([MOC][MOC] - [MOC][MOC]) / [MOC] = [MOC]\n    return (firstOperand.sub(secOperand)).div(bproUsdPrice);\n  }\n\n  /**\n    @dev Calculates the total BTC price of the amount of BPros\n    @param amount Amount of BPro [using mocPrecision]\n    @param bproPrice BPro BTC Price [using reservePrecision]\n    @return BPro total value in BTC [using reservePrecision]\n  */\n  function totalBProInBtc(\n    MocLibConfig storage libConfig, uint256 amount, uint256 bproPrice\n  ) public view returns(uint256) {\n    // [RES] * [MOC] / [MOC] = [RES]\n    return bproPrice.mul(amount).div(libConfig.mocPrecision);\n  }\n\n  /**\n    @dev Calculates the equivalent in Docs of the btcAmount\n    @param btcAmount BTC  amount [using reservePrecision]\n    @param btcPrice BTC price [using mocPrecision]\n    @return Equivalent Doc amount [using mocPrecision]\n  */\n  function maxDocsWithBtc(\n    MocLibConfig storage libConfig, uint256 btcAmount, uint256 btcPrice\n  ) public view returns(uint256) {\n    // [RES] * [MOC] / [RES] = [MOC]\n    return btcAmount.mul(btcPrice).div(libConfig.reservePrecision);\n  }\n\n  /**\n    @dev Calculates the equivalent in BPro of the btcAmount\n    @param btcAmount BTC amount [using reservePrecision]\n    @param bproPrice BPro BTC price [using reservePrecision]\n    @return Equivalent Bpro amount [using mocPrecision]\n  */\n  function maxBProWithBtc(\n    MocLibConfig storage libConfig, uint256 btcAmount, uint256 bproPrice\n  ) public view returns(uint256) {\n    if (bproPrice == 0) {\n      return 0;\n    }\n\n    // [RES] * [MOC] / [RES]\n    return btcAmount.mul(libConfig.mocPrecision).div(bproPrice);\n  }\n\n  /**\n    @dev Calculates the Btc amount to move from C0 bucket to: toMove = btcAmount * (lev - 1)\n    an L bucket when a BProx minting occurs\n    @param btcAmount Total BTC amount [using reservePrecision]\n    @param lev L bucket leverage [using mocPrecision]\n    @return btc to move [using reservePrecision]\n  */\n  function bucketTransferAmount(\n    MocLibConfig storage libConfig, uint256 btcAmount, uint256 lev\n  ) public view returns(uint256) {\n    require(lev > libConfig.mocPrecision, \"Leverage should be more than 1\");\n\n    if (lev == UINT256_MAX || btcAmount == 0) {\n      return 0;\n    }\n\n    // (lev-1)\n    uint256 levSubOne = lev.sub(libConfig.mocPrecision);\n\n    // Intentionally avaoid SafeMath\n    // [RES] * [MOC]\n    uint256 transferAmount = btcAmount * levSubOne;\n    if (transferAmount / btcAmount != levSubOne)\n      return 0;\n\n    // [RES] * [MOC] / [MOC] = [RES]\n    return transferAmount.div(libConfig.mocPrecision);\n  }\n\n  /**\n    @dev Max amount of BTC allowed to be used to mint bprox: Maxbprox = nDOC/ (PEG*B*(lev-1))\n    @param nDoc number of DOC [using mocPrecision]\n    @param peg peg value\n    @param btcPrice BTC price [using mocPrecision]\n    @param lev leverage [using mocPrecision]\n    @return Max bprox BTC value [using reservePrecision]\n  */\n  function maxBProxBtcValue(\n    MocLibConfig storage libConfig, uint256 nDoc, uint256 peg, uint256 btcPrice, uint256 lev\n  ) public view returns(uint256)  {\n    require(libConfig.reservePrecision > 0, \"Invalid Precision\");\n    require(libConfig.mocPrecision > 0, \"Invalid Precision\");\n\n    if (lev <= libConfig.mocPrecision) {\n      return 0;\n    }\n    // (lev-1)\n    // [MOC]\n    uint256 levSubOne = lev.sub(libConfig.mocPrecision);\n\n    // PEG * BtcPrice\n    // [MOC]\n    uint256 pegTimesPrice = peg.mul(btcPrice);\n\n    // This intentionally avoid using safeMath to handle overflow case\n    // PEG * BtcPrice * (lev - 1)\n    // [MOC] * [MOC]\n    uint256 dividend = pegTimesPrice * levSubOne;\n\n    if (dividend / pegTimesPrice != levSubOne)\n      return 0; // INFINIT dividend means 0\n\n    // nDoc adjusted with precisions\n    // [MOC] [RES]\n    uint256 divider = nDoc.mul(libConfig.reservePrecision);\n\n    // [MOC] [RES] [MOC] / [MOC] [MOC]\n    return divider.mul(libConfig.mocPrecision).div(dividend);\n  }\n\n  /**\n    @dev Calculates the equivalent in MoC of the btcAmount\n    @param btcAmount BTC  amount\n    @param btcPrice BTC price\n    @param mocPrice MoC price\n    @return Equivalent MoC amount\n  */\n  function maxMoCWithBtc(\n    MocLibConfig storage /*libConfig*/, uint256 btcAmount, uint256 btcPrice, uint256 mocPrice\n  ) public pure returns(uint256) {\n    return btcPrice.mul(btcAmount).div(mocPrice);\n  }\n\n  /**\n    @dev Calculates the equivalent in BTC of the MoC amount\n    @param amount BTC  amount\n    @param btcPrice BTC price\n    @param mocPrice MoC price\n    @return Equivalent MoC amount\n  */\n  function mocBtcValue(\n    MocLibConfig storage /*libConfig*/, uint256 amount, uint256 btcPrice, uint256 mocPrice\n  ) public pure returns(uint256) {\n    require(btcPrice > 0,\"Bitcoin price should be more than zero\");\n    require(mocPrice > 0,\"MoC price should be more than zero\");\n\n    uint256 mocBtcTotal = amount.mul(mocPrice).div(btcPrice);\n\n    return mocBtcTotal;\n  }\n\n  /**\n    @dev Transform an address to payable address\n    @param account Address to transform to payable\n    @return Payable address for account\n  */\n  function getPayableAddress(\n    MocLibConfig storage /*libConfig*/, address account\n  ) public pure\n  returns (address payable) {\n    return address(uint160(account));\n  }\n\n  /**\n    @dev Rounding product adapted from DSMath but with custom precision\n    @param x Multiplicand\n    @param y Multiplier\n    @return Product\n  */\n  function mulr(uint x, uint y, uint256 precision) internal pure returns (uint z) {\n    return x.mul(y).add(precision.div(2)).div(precision);\n  }\n\n  /**\n    @dev Potentiation by squaring adapted from DSMath but with custom precision\n    @param x Base\n    @param n Exponent\n    @return power\n  */\n  function pow(uint256 x, uint256 n, uint256 precision) internal pure returns (uint z) {\n    uint256 x2 = x;\n    z = n % 2 != 0 ? x : precision;\n\n    for (n /= 2; n != 0; n /= 2) {\n      x2 = mulr(x2, x2, precision);\n\n      if (n % 2 != 0) {\n        z = mulr(z, x2, precision);\n      }\n    }\n  }\n}\n"},{"file_path":"npm/moc-governance@0.1.0/contracts/Governance/IGovernor.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"./ChangeContract.sol\";\n\n/**\n  @title Governor\n  @notice Governor interface. This functions should be overwritten to\n  enable the comunnication with the rest of the system\n  */\ninterface IGovernor{\n\n  /**\n    @notice Function to be called to make the changes in changeContract\n    @dev This function should be protected somehow to only execute changes that\n    benefit the system. This decision process is independent of this architechture\n    therefore is independent of this interface too\n    @param changeContract Address of the contract that will execute the changes\n   */\n  function executeChange(ChangeContract changeContract) external;\n\n  /**\n    @notice Function to be called to make the changes in changeContract\n    @param _changer Address of the contract that will execute the changes\n   */\n  function isAuthorizedChanger(address _changer) external view returns (bool);\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/interface/PriceProvider.sol","source_code":"pragma solidity ^0.5.8;\n\ninterface PriceProvider {\n  function peek() external view returns (bytes32, bool);\n}"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/lifecycle/Pausable.sol","source_code":"pragma solidity ^0.5.0;\n\nimport \"../access/roles/PauserRole.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\ncontract Pausable is PauserRole {\n    /**\n     * @dev Emitted when the pause is triggered by a pauser (`account`).\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by a pauser (`account`).\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state. Assigns the Pauser role\n     * to the deployer.\n     */\n    constructor () internal {\n        _paused = false;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     */\n    modifier whenNotPaused() {\n        require(!_paused, \"Pausable: paused\");\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     */\n    modifier whenPaused() {\n        require(_paused, \"Pausable: not paused\");\n        _;\n    }\n\n    /**\n     * @dev Called by a pauser to pause, triggers stopped state.\n     */\n    function pause() public onlyPauser whenNotPaused {\n        _paused = true;\n        emit Paused(msg.sender);\n    }\n\n    /**\n     * @dev Called by a pauser to unpause, returns to normal state.\n     */\n    function unpause() public onlyPauser whenPaused {\n        _paused = false;\n        emit Unpaused(msg.sender);\n    }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/interface/IMoCExchange.sol","source_code":"pragma solidity ^0.5.8;\n\ninterface IMoCExchange {\n    function getMoCTokenBalance(address owner, address spender) external view\n    returns (uint256 mocBalance, uint256 mocAllowance);\n\n    function mintBPro(address account, uint256 btcAmount, address vendorAccount) external\n    returns (uint256, uint256, uint256, uint256, uint256);\n\n    function redeemBPro(address account, uint256 bproAmount, address vendorAccount) external\n    returns (uint256, uint256, uint256, uint256, uint256);\n\n    function mintDoc(address account, uint256 btcToMint, address vendorAccount) external\n    returns (uint256, uint256, uint256, uint256, uint256);\n\n    function redeemFreeDoc(address account, uint256 docAmount, address vendorAccount) external\n    returns (uint256, uint256, uint256, uint256, uint256);\n\n    function redeemAllDoc(address origin, address payable destination) external\n    returns (uint256);\n}"},{"file_path":"npm/money-on-chain@0.1.14/contracts/base/MoCBase.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"zos-lib/contracts/Initializable.sol\";\n\nimport \"./MoCConnector.sol\";\nimport \"./MoCConstants.sol\";\n\n/**\n  @dev General usefull modifiers and functions\n */\ncontract MoCBase is MoCConstants, Initializable {\n  // Contracts\n  MoCConnector public connector;\n\n  bool internal initialized;\n\n  function initializeBase(address connectorAddress) internal initializer {\n    connector = MoCConnector(connectorAddress);\n  }\n\n  modifier onlyWhitelisted(address account) {\n    require(connector.isWhitelisted(account), \"Address is not whitelisted\");\n    _;\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/zos-lib@2.3.1/contracts/Initializable.sol","source_code":"pragma solidity >=0.4.24 <0.6.0;\n\n\n/**\n * @title Initializable\n *\n * @dev Helper contract to support initializer functions. To use it, replace\n * the constructor with a function that has the `initializer` modifier.\n * WARNING: Unlike constructors, initializer functions must be manually\n * invoked. This applies both to deploying an Initializable contract, as well\n * as extending an Initializable contract via inheritance.\n * WARNING: When used with inheritance, manual care must be taken to not invoke\n * a parent initializer twice, or ensure that all initializers are idempotent,\n * because this is not dealt with automatically as with constructors.\n */\ncontract Initializable {\n\n  /**\n   * @dev Indicates that the contract has been initialized.\n   */\n  bool private initialized;\n\n  /**\n   * @dev Indicates that the contract is in the process of being initialized.\n   */\n  bool private initializing;\n\n  /**\n   * @dev Modifier to use in the initializer function of a contract.\n   */\n  modifier initializer() {\n    require(initializing || isConstructor() || !initialized, \"Contract instance has already been initialized\");\n\n    bool isTopLevelCall = !initializing;\n    if (isTopLevelCall) {\n      initializing = true;\n      initialized = true;\n    }\n\n    _;\n\n    if (isTopLevelCall) {\n      initializing = false;\n    }\n  }\n\n  /// @dev Returns true if and only if the function is running in the constructor\n  function isConstructor() private view returns (bool) {\n    // extcodesize checks the size of the code stored in an address, and\n    // address returns the current address. Since the code is still not\n    // deployed when running a constructor, any checks on its code size will\n    // yield zero, making it an effective way to detect if a contract is\n    // under construction or not.\n    uint256 cs;\n    assembly { cs := extcodesize(address) }\n    return cs == 0;\n  }\n\n  // Reserved storage space to allow for layout changes in the future.\n  uint256[50] private ______gap;\n}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/token/ERC20/ERC20Mintable.sol","source_code":"pragma solidity ^0.5.0;\n\nimport \"./ERC20.sol\";\nimport \"../../access/roles/MinterRole.sol\";\n\n/**\n * @dev Extension of `ERC20` that adds a set of accounts with the `MinterRole`,\n * which have permission to mint (create) new tokens as they see fit.\n *\n * At construction, the deployer of the contract is the only minter.\n */\ncontract ERC20Mintable is ERC20, MinterRole {\n    /**\n     * @dev See `ERC20._mint`.\n     *\n     * Requirements:\n     *\n     * - the caller must have the `MinterRole`.\n     */\n    function mint(address account, uint256 amount) public onlyMinter returns (bool) {\n        _mint(account, amount);\n        return true;\n    }\n}\n"},{"file_path":"project/contracts/compat/DeployableMoC.sol","source_code":"// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.5.17;\npragma experimental ABIEncoderV2;\n\nimport { MoC } from \"@moc/rbtc/contracts/MoC.sol\";\n\ncontract DeployableMoC is MoC {}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/access/roles/PauserRole.sol","source_code":"pragma solidity ^0.5.0;\n\nimport \"../Roles.sol\";\n\ncontract PauserRole {\n    using Roles for Roles.Role;\n\n    event PauserAdded(address indexed account);\n    event PauserRemoved(address indexed account);\n\n    Roles.Role private _pausers;\n\n    constructor () internal {\n        _addPauser(msg.sender);\n    }\n\n    modifier onlyPauser() {\n        require(isPauser(msg.sender), \"PauserRole: caller does not have the Pauser role\");\n        _;\n    }\n\n    function isPauser(address account) public view returns (bool) {\n        return _pausers.has(account);\n    }\n\n    function addPauser(address account) public onlyPauser {\n        _addPauser(account);\n    }\n\n    function renouncePauser() public {\n        _removePauser(msg.sender);\n    }\n\n    function _addPauser(address account) internal {\n        _pausers.add(account);\n        emit PauserAdded(account);\n    }\n\n    function _removePauser(address account) internal {\n        _pausers.remove(account);\n        emit PauserRemoved(account);\n    }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/MoC.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"openzeppelin-solidity/contracts/lifecycle/Pausable.sol\";\nimport \"./MoCBProxManager.sol\";\nimport \"./interface/IMoCState.sol\";\nimport \"./MoCLibConnection.sol\";\nimport \"./interface/IMoCSettlement.sol\";\nimport \"./interface/IMoCExchange.sol\";\nimport \"./base/MoCBase.sol\";\nimport \"moc-governance/contracts/Stopper/Stoppable.sol\";\nimport \"moc-governance/contracts/Governance/IGovernor.sol\";\nimport \"openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\";\nimport \"./interface/IMoCVendors.sol\";\nimport \"./interface/IMoCInrate.sol\";\nimport \"./interface/IMoC.sol\";\n\ncontract MoCEvents {\n  event BucketLiquidation(bytes32 bucket);\n  event ContractLiquidated(address mocAddress);\n}\n\ncontract MoC is MoCEvents, MoCLibConnection, MoCBase, Stoppable, IMoC {\n  using SafeMath for uint256;\n\n  /// @dev Contracts.\n  address internal docToken;\n  address internal bproToken;\n  MoCBProxManager internal bproxManager;\n  IMoCState internal mocState;\n  /** DEPRECATED **/\n  // solium-disable-next-line mixedcase\n  address internal DEPRECATED_mocConverter;\n  IMoCSettlement internal settlement;\n  IMoCExchange internal mocExchange;\n  IMoCInrate internal mocInrate;\n  /// @dev 'MoCBurnout' is deprecated. DO NOT use this variable.\n  /** DEPRECATED **/\n  // solium-disable-next-line mixedcase\n  address public DEPRECATED_mocBurnout;\n\n  /// @dev Indicates if Rbtc remainder was sent and BProToken was paused\n  bool internal liquidationExecuted;\n\n  //TODO: We must research if fallback function is really needed.\n  /**\n    @dev Fallback function\n  */\n  function() external payable whenNotPaused() transitionState() {\n    bproxManager.addValuesToBucket(BUCKET_C0, msg.value, 0, 0);\n    mocState.addToRbtcInSystem(msg.value);\n  }\n\n  /**\n    @dev Initializes the contract\n    @param connectorAddress MoCConnector contract address\n    @param governorAddress Governor contract address\n    @param stopperAddress Stopper contract address\n    @param startStoppable Indicates if the contract starts being unstoppable or not\n    @param maxGasPrice_ gas price limit to mint and redeem operations\n  */\n  function initialize(\n    address connectorAddress,\n    address governorAddress,\n    address stopperAddress,\n    bool startStoppable,\n    uint256 maxGasPrice_\n  ) public initializer {\n    initializePrecisions();\n    initializeBase(connectorAddress);\n    //initializeContracts\n    docToken = connector.docToken();\n    bproToken = connector.bproToken();\n    bproxManager = MoCBProxManager(connector.bproxManager());\n    mocState = IMoCState(connector.mocState());\n    settlement = IMoCSettlement(connector.mocSettlement());\n    mocExchange = IMoCExchange(connector.mocExchange());\n    mocInrate = IMoCInrate(connector.mocInrate());\n    //initializeGovernanceContracts\n    Stoppable.initialize(stopperAddress, IGovernor(governorAddress), startStoppable);\n    maxGasPrice = maxGasPrice_;\n  }\n\n  /****************************INTERFACE*******************************************/\n\n  /**\n    @dev Gets the BProx balance of an address\n    @param bucket Name of the bucket\n    @param account Address\n    @return BProx balance of the address\n  */\n  function bproxBalanceOf(bytes32 bucket, address account) public view returns(uint256) {\n    return bproxManager.bproxBalanceOf(bucket, account);\n  }\n\n  /**\n    @dev Gets the RedeemRequest at the queue index position\n    @param index queue position to get\n    @return redeemer's address and amount he submitted\n  */\n  function getRedeemRequestAt(uint256 index) public view returns(address, uint256) {\n    return settlement.getRedeemRequestAt(index);\n  }\n\n  /**\n    @dev Returns current redeem queue size\n    @return redeem queue size\n   */\n  function redeemQueueSize() public view returns(uint256) {\n    return settlement.redeemQueueSize();\n  }\n\n  /**\n    @dev Returns the total amount of Docs in the redeem queue for redeemer\n    @param redeemer address for which ^ is computed\n    @return total amount of Docs in the redeem queue for redeemer\n   */\n  function docAmountToRedeem(address redeemer) public view returns(uint256) {\n    return settlement.docAmountToRedeem(redeemer);\n  }\n\n\n  /**\n  * @dev Creates or updates the amount of a Doc redeem Request from the msg.sender\n  * @param docAmount Amount of Docs to redeem on settlement [using mocPrecision]\n  */\n  function redeemDocRequest(uint256 docAmount) public {\n    // Do nothing. Feature removed\n  }\n\n  /**\n    @dev Alters the redeem amount position for the redeemer\n    @param isAddition true if adding amount to redeem, false to substract.\n    @param delta the amount to add/substract to current position\n  */\n  function alterRedeemRequestAmount(bool isAddition, uint256 delta) public {\n    // Do nothing. Feature removed\n  }\n\n  /**\n    @dev Mints BPRO and pays the comissions of the operation (retrocompatible function).\n    @dev Retrocompatible function.\n    @param btcToMint Amount in BTC to mint\n   */\n  function mintBPro(uint256 btcToMint)\n  public payable {\n    mintBProVendors(btcToMint, address(0));\n  }\n\n  /**\n    @dev Mints BPRO and pays the comissions of the operation.\n    @param btcToMint Amount in BTC to mint\n    @param vendorAccount Vendor address\n   */\n  function mintBProVendors(uint256 btcToMint, address payable vendorAccount)\n  public payable\n  nonReentrant whenNotPaused() transitionStateWithRefund() notInProtectionMode() isValidGasPrice() {\n    /** UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n    (uint256 totalBtcSpent,\n    uint256 btcCommission,\n    uint256 mocCommission,\n    uint256 btcMarkup,\n    uint256 mocMarkup) = mocExchange.mintBPro(msg.sender, btcToMint, vendorAccount);\n\n    transferCommissions(\n      msg.sender,\n      msg.value,\n      totalBtcSpent,\n      btcCommission,\n      mocCommission,\n      vendorAccount,\n      btcMarkup,\n      mocMarkup\n    );\n    /** END UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n  }\n\n  /**\n    @dev Redeems Bpro Tokens and pays the comissions of the operation (retrocompatible function).\n    @param bproAmount Amount in Bpro\n  */\n  function redeemBPro(uint256 bproAmount)\n  public {\n    redeemBProVendors(bproAmount, address(0));\n  }\n\n  /**\n    @dev Redeems Bpro Tokens and pays the comissions of the operation\n    @param bproAmount Amount in Bpro\n    @param vendorAccount Vendor address\n  */\n  function redeemBProVendors(uint256 bproAmount, address payable vendorAccount)\n  public\n  nonReentrant whenNotPaused() transitionState() atLeastState(IMoCState.States.AboveCobj) isValidGasPrice() {\n    /** UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n    (uint256 btcAmount,\n    uint256 btcCommission,\n    uint256 mocCommission,\n    uint256 btcMarkup,\n    uint256 mocMarkup) = mocExchange.redeemBPro(msg.sender, bproAmount, vendorAccount);\n\n    redeemWithCommission(\n      msg.sender,\n      btcAmount,\n      btcCommission,\n      mocCommission,\n      vendorAccount,\n      btcMarkup,\n      mocMarkup\n    );\n    /** END UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n  }\n\n  /**\n    @dev Mint Doc tokens and pays the commisions of the operation (retrocompatible function).\n    @dev Retrocompatible function.\n    @param btcToMint Amount in RBTC to mint\n  */\n  function mintDoc(uint256 btcToMint)\n  public payable {\n    mintDocVendors(btcToMint, address(0));\n  }\n\n  /**\n   * @dev Mint Doc tokens and pays the commisions of the operation\n   * @param btcToMint Amount in RBTC to mint\n   * @param vendorAccount Vendor address\n   */\n  function mintDocVendors(uint256 btcToMint, address payable vendorAccount)\n  public payable\n  nonReentrant whenNotPaused() transitionStateWithRefund() atLeastState(IMoCState.States.AboveCobj) isValidGasPrice() {\n    /** UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n    (uint256 totalBtcSpent,\n    uint256 btcCommission,\n    uint256 mocCommission,\n    uint256 btcMarkup,\n    uint256 mocMarkup) = mocExchange.mintDoc(msg.sender, btcToMint, vendorAccount);\n\n    transferCommissions(\n      msg.sender,\n      msg.value,\n      totalBtcSpent,\n      btcCommission,\n      mocCommission,\n      vendorAccount,\n      btcMarkup,\n      mocMarkup\n    );\n    /** END UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n  }\n\n  /**\n    @dev Redeems Bprox Tokens and pays the comissions of the operation in RBTC (retrocompatible function).\n    @dev Retrocompatible function.\n    @param bucket Bucket to reedem, for example X2\n    @param bproxAmount Amount in Bprox\n  */\n  function redeemBProx(bytes32 bucket, uint256 bproxAmount) public {\n    redeemBProxVendors(bucket, bproxAmount, address(0));\n  }\n\n  /**\n    @dev Redeems Bprox Tokens and pays the comissions of the operation in RBTC\n    @param bucket Bucket to reedem, for example X2\n  */\n  function redeemBProxVendors(bytes32 bucket, uint256 /*bproxAmount*/, address payable /*vendorAccount*/) public\n  whenNotPaused() availableBucket(bucket) notBaseBucket(bucket)\n  transitionState() bucketStateTransition(bucket) {\n    /** UPDATE V0114: 31/01/2023 - Removal of leveraged positions. Please take a look at http://bit.ly/3XPiKUA **/\n    revert(\"Redeem Leveraged position is disabled. See: http://bit.ly/3XPiKUA\");\n  }\n\n  /**\n    @dev BUCKET bprox minting (retrocompatible function).\n    @dev Retrocompatible function.\n    @param bucket Name of the bucket used\n    @param btcToMint amount to mint on RBTC\n  */\n  function mintBProx(bytes32 bucket, uint256 btcToMint) public payable {\n    mintBProxVendors(bucket, btcToMint, address(0));\n  }\n\n  /**\n    @dev BUCKET bprox minting\n    @param bucket Name of the bucket used\n  */\n  function mintBProxVendors(bytes32 bucket, uint256 /*btcToMint*/, address payable /*vendorAccount*/) public payable\n  whenNotPaused() availableBucket(bucket) notBaseBucket(bucket)\n  transitionState() bucketStateTransition(bucket) {\n    /** UPDATE V0114: 31/01/2023 - Removal of leveraged positions. Please take a look at http://bit.ly/3XPiKUA **/\n    revert(\"Mint Leveraged position is disabled. See: http://bit.ly/3XPiKUA\");\n  }\n\n  /**\n    @dev Redeems the requested amount for the msg.sender, or the max amount of free docs possible (retrocompatible function).\n    @dev Retrocompatible function.\n    @param docAmount Amount of Docs to redeem.\n  */\n  function redeemFreeDoc(uint256 docAmount)\n  public {\n    redeemFreeDocVendors(docAmount, address(0));\n  }\n\n  /**\n    @dev Redeems the requested amount for the msg.sender, or the max amount of free docs possible.\n    @param docAmount Amount of Docs to redeem.\n    @param vendorAccount Vendor address\n  */\n  function redeemFreeDocVendors(uint256 docAmount, address payable vendorAccount)\n  public\n  nonReentrant whenNotPaused() transitionState() notInProtectionMode() isValidGasPrice() {\n    /** UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n    (uint256 btcAmount,\n    uint256 btcCommission,\n    uint256 mocCommission,\n    uint256 btcMarkup,\n    uint256 mocMarkup) = mocExchange.redeemFreeDoc(msg.sender, docAmount, vendorAccount);\n\n    redeemWithCommission(\n      msg.sender,\n      btcAmount,\n      btcCommission,\n      mocCommission,\n      vendorAccount,\n      btcMarkup,\n      mocMarkup\n    );\n    /** END UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n  }\n\n  /**\n    @dev Allow redeem on liquidation state, user DoCs get burned and he receives\n    the equivalent BTCs if can be covered, or the maximum available\n  */\n  function redeemAllDoc() public atState(IMoCState.States.Liquidated) {\n    mocExchange.redeemAllDoc(msg.sender, msg.sender);\n  }\n\n  /**\n    @dev Pays the BitPro interest and transfers it to the address mocInrate.bitProInterestAddress\n    BitPro interests = Nb (bucket 0) * bitProRate.\n  */\n  function payBitProHoldersInterestPayment() public nonReentrant whenNotPaused() {\n    uint256 toPay = mocInrate.payBitProHoldersInterestPayment();\n    if (doSend(mocInrate.getBitProInterestAddress(), toPay)) {\n      bproxManager.substractValuesFromBucket(BUCKET_C0, toPay, 0, 0);\n    }\n  }\n\n  /**\n    @dev Calculates BitPro holders holder interest by taking the total amount of RBTCs available on Bucket 0.\n    BitPro interests = Nb (bucket 0) * bitProRate.\n  */\n  function calculateBitProHoldersInterest() public view returns(uint256, uint256) {\n    return mocInrate.calculateBitProHoldersInterest();\n  }\n\n  /**\n    @dev Gets the target address to transfer BitPro Holders rate\n    @return Target address to transfer BitPro Holders interest\n  */\n  function getBitProInterestAddress() public view returns(address payable) {\n    return mocInrate.getBitProInterestAddress();\n  }\n\n  /**\n    @dev Gets the rate for BitPro Holders\n    @return BitPro Rate\n  */\n  function getBitProRate() public view returns(uint256) {\n    return mocInrate.getBitProRate();\n  }\n\n  /**\n    @dev Gets the blockspan of BPRO that represents the frecuency of BitPro holders interest payment\n    @return returns power of bitProInterestBlockSpan\n  */\n  function getBitProInterestBlockSpan() public view returns(uint256) {\n    return mocInrate.getBitProInterestBlockSpan();\n  }\n\n  function isDailyEnabled() external pure returns(bool) {\n    return false;\n  }\n\n  function isBitProInterestEnabled() public view returns(bool) {\n    return mocInrate.isBitProInterestEnabled();\n  }\n\n  /**\n    @dev Indicates if settlement is enabled\n    @return Returns true if blockSpan number of blocks has passed since last execution; otherwise false\n  */\n  function isSettlementEnabled() public view returns(bool) {\n    return settlement.isSettlementEnabled();\n  }\n\n  /**\n    @dev Checks if bucket liquidation is reached.\n    @param bucket Name of bucket.\n    @return true if bucket liquidation is reached, false otherwise\n  */\n  function isBucketLiquidationReached(bytes32 bucket) public view returns(bool) {\n    if (mocState.coverage(bucket) <= mocState.liq()) {\n      return true;\n    }\n    return false;\n  }\n\n  function evalBucketLiquidation(bytes32 bucket) public availableBucket(bucket) notBaseBucket(bucket) {\n    if (isBucketLiquidationReached(bucket)) {\n      bproxManager.liquidateBucket(bucket, BUCKET_C0);\n\n      emit BucketLiquidation(bucket);\n    }\n  }\n\n  /**\n    @dev Evaluates if liquidation state has been reached and runs liq if that's the case\n  */\n  function evalLiquidation() public transitionState() {\n    // DO NOTHING. Everything is handled in transitionState() modifier.\n  }\n\n  /**\n    @dev Runs all settlement process\n    @param steps Number of steps\n  */\n  function runSettlement(uint256 steps) public whenNotPaused() transitionState() {\n    settlement.runSettlement(steps);\n  }\n\n  /**\n    @dev Send RBTC to a user and update RbtcInSystem in MoCState\n    @param receiver address of receiver\n    @param btcAmount amount to transfer\n    @return result of the transaction\n  */\n  function sendToAddress(address payable receiver, uint256 btcAmount) public nonReentrant onlyWhitelisted(msg.sender) returns(bool) {\n    if (btcAmount == 0) {\n      return true;\n    }\n    return doSend(receiver, btcAmount);\n  }\n\n  function liquidate() internal {\n    if (!liquidationExecuted) {\n      //pauseBProToken\n      if (!Pausable(bproToken).paused()) {\n        Pausable(bproToken).pause();\n      }\n      //sendRbtcRemainder\n      doTransfer(mocInrate.commissionsAddress(), mocState.getRbtcRemainder());\n      liquidationExecuted = true;\n\n      emit ContractLiquidated(connector.moc());\n    }\n  }\n\n  /************************************/\n  /***** UPGRADE v0110      ***********/\n  /************************************/\n\n  /** START UPDATE V0112: 24/09/2020  **/\n  /** Upgrade to support multiple commission rates **/\n  /** Internal functions **/\n\n  /**\n    @dev Transfer mint operation fees (commissions + vendor markup)\n    @param sender address of msg.sender\n    @param value amount of msg.value\n    @param totalBtcSpent amount in RBTC spent\n    @param btcCommission commission amount in RBTC\n    @param mocCommission commission amount in MoC\n    @param vendorAccount address of vendor\n    @param btcMarkup vendor markup in RBTC\n    @param mocMarkup vendor markup in MoC\n  */\n  // solium-disable-next-line security/no-assign-params\n  function transferCommissions(\n    address payable sender,\n    uint256 value,\n    uint256 totalBtcSpent,\n    uint256 btcCommission,\n    uint256 mocCommission,\n    address payable vendorAccount,\n    uint256 btcMarkup,\n    uint256 mocMarkup\n  )\n  internal {\n    uint256 totalBtcWithFees = totalBtcSpent;\n    if (mocCommission.add(mocMarkup) == 0) {\n      totalBtcWithFees = totalBtcSpent.add(btcCommission).add(btcMarkup);\n    }\n    require(totalBtcWithFees <= value, \"amount is not enough\");\n\n    // Need to update general State\n    mocState.addToRbtcInSystem(totalBtcSpent);\n\n    transferMocCommission(sender, mocCommission, vendorAccount, mocMarkup);\n\n    transferBtcCommission(vendorAccount, btcCommission, btcMarkup);\n\n    // Calculate change\n    safeTransferRbtc(sender, value.sub(totalBtcWithFees));\n  }\n\n  /**\n    @dev Transfer operation fees in MoC (commissions + vendor markup)\n    @param sender address of msg.sender\n    @param mocCommission commission amount in MoC\n    @param vendorAccount address of vendor\n    @param mocMarkup vendor markup in MoC\n  */\n  // solium-disable-next-line security/no-assign-params\n  function transferMocCommission(\n    address sender,\n    uint256 mocCommission,\n    address vendorAccount,\n    uint256 mocMarkup\n  ) internal {\n    // If commission and markup are paid in MoC\n    uint256 totalMoCFee = mocCommission.add(mocMarkup);\n    if (totalMoCFee > 0) {\n      IMoCVendors mocVendors = IMoCVendors(mocState.getMoCVendors());\n      // Transfer MoC from sender to this contract\n      IERC20 mocToken = IERC20(mocState.getMoCToken());\n\n      // Transfer vendor markup in MoC\n      if (mocVendors.updatePaidMarkup(vendorAccount, mocMarkup, 0)) {\n        // Transfer MoC to vendor address\n        mocToken.transferFrom(sender, vendorAccount, mocMarkup);\n        // Transfer MoC to commissions address\n        mocToken.transferFrom(sender, mocInrate.commissionsAddress(), mocCommission);\n      } else {\n        // Transfer MoC to commissions address\n        mocToken.transferFrom(sender, mocInrate.commissionsAddress(), totalMoCFee);\n      }\n    }\n  }\n\n  /**\n    @dev Transfer redeem operation fees (commissions + vendor markup)\n    @param sender address of msg.sender\n    @param btcCommission commission amount in RBTC\n    @param mocCommission commission amount in MoC\n    @param vendorAccount address of vendor\n    @param btcMarkup vendor markup in RBTC\n    @param mocMarkup vendor markup in MoC\n  */\n  function redeemWithCommission(\n    address payable sender,\n    uint256 btcAmount,\n    uint256 btcCommission,\n    uint256 mocCommission,\n    address payable vendorAccount,\n    uint256 btcMarkup,\n    uint256 mocMarkup\n  )\n   internal {\n    mocState.subtractRbtcFromSystem(btcAmount.add(btcMarkup).add(btcCommission));\n\n    transferMocCommission(sender, mocCommission, vendorAccount, mocMarkup);\n\n    transferBtcCommission(vendorAccount, btcCommission, btcMarkup);\n\n    safeTransferRbtc(sender, btcAmount);\n  }\n\n  /**\n    @dev Transfer operation fees in RBTC (commissions + vendor markup)\n    @param vendorAccount address of vendor\n    @param btcCommission commission amount in RBTC\n    @param btcMarkup vendor markup in RBTC\n  */\n  function transferBtcCommission(address payable vendorAccount, uint256 btcCommission, uint256 btcMarkup) internal {\n\n    uint256 totalBtcFee = btcCommission.add(btcMarkup);\n\n    if (totalBtcFee > 0) {\n      IMoCVendors mocVendors = IMoCVendors(mocState.getMoCVendors());\n      // Transfer vendor markup in MoC\n      if (mocVendors.updatePaidMarkup(vendorAccount, 0, btcMarkup)) {\n        // Transfer RBTC to vendor address\n        safeTransferRbtc(vendorAccount, btcMarkup);\n        // Transfer RBTC to commissions address\n        safeTransferRbtc(mocInrate.commissionsAddress(), btcCommission);\n      } else {\n        // Transfer MoC to commissions address\n        safeTransferRbtc(mocInrate.commissionsAddress(), totalBtcFee);\n      }\n    }\n  }\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  /**\n    @dev Transfer using transfer function and updates global RBTC register in MoCState\n    @param receiver address of receiver\n    @param btcAmount amount in RBTC\n  */\n  function doTransfer(address payable receiver, uint256 btcAmount) private {\n    mocState.subtractRbtcFromSystem(btcAmount);\n    safeTransferRbtc(receiver, btcAmount);\n  }\n\n  /**\n    @dev Safe RBTC transfer that is compatible with EIP-1884 gas cost changes\n    @param receiver address of receiver\n    @param amount amount in RBTC\n  */\n  function safeTransferRbtc(address payable receiver, uint256 amount) private {\n    // solium-disable-next-line security/no-call-value\n    (bool success, ) = receiver.call.value(amount)(\"\");\n    require(success, \"RBTC transfer failed\");\n  }\n\n  /**\n    @dev Transfer using call and updates global RBTC register in MoCState only on success\n    @param receiver address of receiver\n    @param btcAmount amount in RBTC\n    @return Execution result\n  */\n  function doSend(address payable receiver, uint256 btcAmount) private returns(bool) {\n    // solium-disable-next-line security/no-call-value\n    (bool result, ) = receiver.call.value(btcAmount)(\"\");\n\n    if (result) {\n      mocState.subtractRbtcFromSystem(btcAmount);\n    }\n\n    return result;\n  }\n\n  /***** STATE MODIFIERS *****/\n\n  modifier nonReentrant() {\n    require(!_reentrancyLock, \"reentrancy not allowed\");\n    _reentrancyLock = true;\n    _;\n    _reentrancyLock = false;\n  }\n\n  modifier atState(IMoCState.States _state) {\n    require(mocState.state() == _state, \"Function cannot be called at this state.\");\n    _;\n  }\n\n  modifier atLeastState(IMoCState.States _state) {\n    require(mocState.state() >= _state, \"Function cannot be called at this state.\");\n    _;\n  }\n\n  modifier atMostState(IMoCState.States _state) {\n    require(mocState.state() <= _state, \"Function cannot be called at this state.\");\n    _;\n  }\n\n  modifier notInProtectionMode() {\n    require(mocState.globalCoverage() > mocState.getProtected(), \"Function cannot be called at protection mode.\");\n    _;\n  }\n\n  modifier bucketStateTransition(bytes32 bucket) {\n    evalBucketLiquidation(bucket);\n    _;\n  }\n\n  modifier availableBucket(bytes32 bucket) {\n    require (bproxManager.isAvailableBucket(bucket), \"Bucket is not available\");\n    _;\n  }\n\n  modifier notBaseBucket(bytes32 bucket) {\n    require(!bproxManager.isBucketBase(bucket), \"Bucket should not be a base type bucket\");\n    _;\n  }\n\n  modifier transitionState()\n  {\n    mocState.nextState();\n    if (mocState.state() == IMoCState.States.Liquidated) {\n      liquidate();\n    }\n    else\n      _;\n  }\n\n  modifier transitionStateWithRefund()\n  {\n    mocState.nextState();\n    if (mocState.state() == IMoCState.States.Liquidated) {\n      liquidate();\n      if (msg.value > 0) {\n        safeTransferRbtc(msg.sender, msg.value);\n      }\n    }\n    else\n      _;\n  }\n\n  /**\n   * @notice validate that the given gas price is less or equal to the gas price limit\n   */\n  modifier isValidGasPrice() {\n    require(tx.gasprice <= maxGasPrice, \"gas price is above the max allowed\");\n    _;\n  }\n\n  /**\n   * @notice allows the pauser or an authorized changer to update the gas price limit\n   *  The pauser is a multisig that could be used in this case to speed up the max gas price\n   *  change if it is necessary\n   * @param maxGasPrice_ new gas price limit\n   */\n  function setMaxGasPrice(uint256 maxGasPrice_) external {\n    require(stopper == msg.sender || governor.isAuthorizedChanger(msg.sender), \"not authorized changer or stopper\");\n    maxGasPrice = maxGasPrice_;\n  }\n\n  uint256 public maxGasPrice;\n  bool private _reentrancyLock;\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[48] private upgradeGap;\n}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/ownership/Ownable.sol","source_code":"pragma solidity ^0.5.0;\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be aplied to your functions to restrict their use to\n * the owner.\n */\ncontract Ownable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor () internal {\n        _owner = msg.sender;\n        emit OwnershipTransferred(address(0), _owner);\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(isOwner(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Returns true if the caller is the current owner.\n     */\n    function isOwner() public view returns (bool) {\n        return msg.sender == _owner;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * > Note: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public onlyOwner {\n        emit OwnershipTransferred(_owner, address(0));\n        _owner = address(0);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public onlyOwner {\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     */\n    function _transferOwnership(address newOwner) internal {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        emit OwnershipTransferred(_owner, newOwner);\n        _owner = newOwner;\n    }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/MoCLibConnection.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"./MoCHelperLib.sol\";\n\n/**\n  @dev Interface with MocHelperLib\n */\ncontract MoCLibConnection {\n  using MoCHelperLib for MoCHelperLib.MocLibConfig;\n  MoCHelperLib.MocLibConfig internal mocLibConfig;\n\n  /*\n  * Precision getters\n  */\n  function getMocPrecision() public view returns(uint256) {\n    return mocLibConfig.mocPrecision;\n  }\n\n  function getReservePrecision() public view returns(uint256) {\n    return mocLibConfig.reservePrecision;\n  }\n\n  function getDayPrecision() public view returns(uint256) {\n    return mocLibConfig.dayPrecision;\n  }\n\n  function initializePrecisions() internal {\n    mocLibConfig = MoCHelperLib.MocLibConfig({\n      reservePrecision: 10 ** 18,\n      mocPrecision: 10 ** 18,\n      dayPrecision: 1\n    });\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/math/SafeMath.sol","source_code":"pragma solidity ^0.5.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a, \"SafeMath: addition overflow\");\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b <= a, \"SafeMath: subtraction overflow\");\n        uint256 c = a - b;\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n        if (a == 0) {\n            return 0;\n        }\n\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: multiplication overflow\");\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers. Reverts on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        // Solidity only automatically asserts when dividing by 0\n        require(b > 0, \"SafeMath: division by zero\");\n        uint256 c = a / b;\n        // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * Reverts when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b != 0, \"SafeMath: modulo by zero\");\n        return a % b;\n    }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/PartialExecution.sol","source_code":"pragma solidity ^0.5.8;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"openzeppelin-solidity/contracts/math/Math.sol\";\n\n\ncontract PartialExecutionData {\n  enum ExecutionState {Ready, Running, Finished}\n\n  struct TaskGroup {\n    bytes32 id;\n    ExecutionState state;\n    bytes32[] subTasks;\n    function() internal onStart;\n    function() internal onFinish;\n    bool autoRestart;\n  }\n\n  struct Task {\n    bytes32 id;\n    function() internal returns (uint256) getStepCount;\n    function(uint256) internal stepFunction;\n    function() internal onStart;\n    function() internal onFinish;\n    uint256 currentStep;\n    uint256 stepCount;\n    ExecutionState state;\n  }\n}\n\n\n/**\n  @dev Brings basic data structures and functions for partial execution.\n  The main data structures are:\n    Task: Represents a function that needs to be executed by steps.\n    TaskGroup: Represents a function that contains several functions that needs to be executed by steps.\n  Tasks and Tasks groups can be executed specifying the amount of steps to run.\n*/\ncontract PartialExecution is PartialExecutionData {\n  using SafeMath for uint256;\n  using Math for uint256;\n  mapping(bytes32 => Task) internal tasks;\n  mapping(bytes32 => TaskGroup) internal taskGroups;\n\n  /**\n   @dev Auxiliar function for tasks with no onFinish function\n */\n  function noFunction() internal {}\n\n\n  /**\n   @dev Reset pointers a task group\n   @param _groupId Id of the task group\n   @param _subtasks Tasks to execute when executing the task group\n   @param _onFinish Function to execute when all tasks of the group are completed\n */\n  function resetTaskGroupPointers(\n    bytes32 _groupId,\n    bytes32[] memory _subtasks,\n    function() _onStart,\n    function() _onFinish,\n    bool _autoRestart\n  ) internal {\n    taskGroups[_groupId].id = _groupId;\n    taskGroups[_groupId].subTasks = _subtasks;\n    taskGroups[_groupId].onStart = _onStart;\n    taskGroups[_groupId].onFinish = _onFinish;\n    taskGroups[_groupId].autoRestart = _autoRestart;\n\n  }\n\n  /**\n   @dev Creates a task\n   @param taskId Id of the task\n   @param _getStepCount Function executed before starting the task\n   Should return the step count of the execution\n   @param _stepFunction Function to execute at each step\n   @param _onStart Function to execute before task execution\n   @param _onFinish Function to execute when all steps are completed\n */\n  function resetTaskPointers(\n    bytes32 taskId,\n    function() internal returns (uint256) _getStepCount,\n    function(uint256) internal _stepFunction,\n    function() internal _onStart,\n    function() internal _onFinish\n  ) internal {\n    tasks[taskId].id = taskId;\n    tasks[taskId].getStepCount = _getStepCount;\n    tasks[taskId].stepFunction = _stepFunction;\n    tasks[taskId].onStart = _onStart;\n    tasks[taskId].onFinish = _onFinish;\n  }\n\n\n\n  /**\n   @dev Creates a task group\n   @param _groupId Id of the task group\n   @param _subtasks Tasks to execute when executing the task group\n   @param _onFinish Function to execute when all tasks of the group are completed\n */\n  function createTaskGroup(\n    bytes32 _groupId,\n    bytes32[] memory _subtasks,\n    function() _onStart,\n    function() _onFinish,\n    bool _autoRestart\n  ) internal {\n    taskGroups[_groupId].id = _groupId;\n    taskGroups[_groupId].subTasks = _subtasks;\n    taskGroups[_groupId].onStart = _onStart;\n    taskGroups[_groupId].onFinish = _onFinish;\n    taskGroups[_groupId].state = ExecutionState.Ready;\n    taskGroups[_groupId].autoRestart = _autoRestart;\n  }\n\n  /**\n   @dev Creates a task\n   @param taskId Id of the task\n   @param _getStepCount Function executed before starting the task\n   Should return the step count of the execution\n   @param _stepFunction Function to execute at each step\n   @param _onStart Function to execute before task execution\n   @param _onFinish Function to execute when all steps are completed\n */\n  function createTask(\n    bytes32 taskId,\n    function() internal returns (uint256) _getStepCount,\n    function(uint256) internal _stepFunction,\n    function() internal _onStart,\n    function() internal _onFinish\n  ) internal {\n    tasks[taskId].id = taskId;\n    tasks[taskId].getStepCount = _getStepCount;\n    tasks[taskId].stepFunction = _stepFunction;\n    tasks[taskId].onStart = _onStart;\n    tasks[taskId].onFinish = _onFinish;\n    tasks[taskId].state = ExecutionState.Ready;\n  }\n\n  /**\n   @dev Executes all tasks of the group in order using the step count passed as parameter\n   @param groupId Id of the task group\n   @param stepCount Step count to execute\n */\n  function executeGroup(bytes32 groupId, uint256 stepCount) internal {\n    TaskGroup storage group = taskGroups[groupId];\n\n    if (group.state == ExecutionState.Ready) {\n      group.onStart();\n      group.state = ExecutionState.Running;\n    }\n\n    uint256 leftSteps = stepCount;\n\n    for (uint256 i = 0; i < group.subTasks.length && leftSteps > 0; i++) {\n      uint256 consumed = executeTask(group.subTasks[i], leftSteps);\n      leftSteps = leftSteps.sub(consumed);\n    }\n\n    if (groupFinished(groupId)) {\n      group.state = ExecutionState.Finished;\n      group.onFinish();\n      if (group.autoRestart) {\n        resetGroup(groupId);\n      }\n    }\n  }\n\n  /**\n   @dev Creates a task\n   @param taskId Id of the task\n   @param steps Step count to execute\n   @return The amount of steps consumed in the execution\n */\n  function executeTask(bytes32 taskId, uint256 steps)\n  internal\n  returns (uint256)\n  {\n    Task storage task = tasks[taskId];\n    uint256 initialStep = task.currentStep;\n\n    if (task.state == ExecutionState.Finished) {\n      // No execution\n      return 0;\n    }\n    if (task.state == ExecutionState.Ready) {\n      task.stepCount = task.getStepCount();\n      task.onStart();\n      task.state = ExecutionState.Running;\n    }\n    if (task.state == ExecutionState.Running) {\n      uint256 endStep = Math.min(\n        task.currentStep.add(steps),\n        task.stepCount\n      );\n\n      for (\n        task.currentStep;\n        task.currentStep < endStep;\n        task.currentStep++\n      ) {\n        task.stepFunction(task.currentStep);\n      }\n\n      if (task.currentStep == task.stepCount) {\n        task.state = ExecutionState.Finished;\n        task.onFinish();\n      }\n    }\n\n    return task.currentStep.sub(initialStep);\n  }\n\n  /**\n   @dev Put task in Ready to run state and reset currentStep value\n   @param taskId Id of the task\n */\n  function resetTask(bytes32 taskId) internal {\n    tasks[taskId].state = ExecutionState.Ready;\n    tasks[taskId].currentStep = 0;\n  }\n\n  /**\n  @dev Reset all tasks in a group. Used at the completion of a task group execution\n  @param groupId Id of the task group\n*/\n  function resetTasks(bytes32 groupId) internal {\n    TaskGroup storage group = taskGroups[groupId];\n\n    for (uint256 i = 0; i < group.subTasks.length; i++) {\n      resetTask(group.subTasks[i]);\n    }\n  }\n\n  /**\n  @dev Set if a Group should be automatically set to Ready state\n  after Finnished State is reached\n  @param groupId Id of the task group\n*/\n  function setAutoRestart(bytes32 groupId, bool _autoRestart) internal {\n    taskGroups[groupId].autoRestart = _autoRestart;\n  }\n\n  /**\n  @dev Set Group in Ready state. Reset all sub-task.\n  @param groupId Id of the task group\n*/\n  function resetGroup(bytes32 groupId) internal {\n    TaskGroup storage group = taskGroups[groupId];\n    group.state = ExecutionState.Ready;\n\n    resetTasks(groupId);\n  }\n\n  /**\n   @dev Returns true if the last task of the group was completed\n   @param groupId Id of the task group\n   @return boolean\n */\n  function groupFinished(bytes32 groupId) internal view returns (bool) {\n    TaskGroup storage group = taskGroups[groupId];\n    bytes32 taskId = group.subTasks[group.subTasks.length.sub(1)];\n    Task storage lastTask = tasks[taskId];\n\n    return lastTask.state == ExecutionState.Finished;\n  }\n\n  /**\n   @dev Returns true if the group is currently un Running state\n   @param groupId Id of the task group\n   @return boolean\n */\n  function isGroupRunning(bytes32 groupId) internal view returns (bool) {\n    return taskGroups[groupId].state == ExecutionState.Running;\n  }\n\n  /**\n   @dev Returns true if the group is currently in Ready state\n   @param groupId Id of the task group\n   @return boolean\n */\n  function isGroupReady(bytes32 groupId) internal view returns (bool) {\n    return taskGroups[groupId].state == ExecutionState.Ready;\n  }\n\n  /**\n   @dev Returns true if the task is currently un Running state\n   @param taskId Id of the task\n   @return boolean\n */\n  function isTaskRunning(bytes32 taskId) internal view returns (bool) {\n    return tasks[taskId].state == ExecutionState.Running;\n  }\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"},{"file_path":"npm/openzeppelin-solidity@2.3.0/contracts/math/Math.sol","source_code":"pragma solidity ^0.5.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a >= b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow, so we distribute\n        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);\n    }\n}\n"},{"file_path":"npm/money-on-chain@0.1.14/contracts/MoCInrate.sol","source_code":"pragma solidity ^0.5.8;\npragma experimental ABIEncoderV2;\n\nimport \"moc-governance/contracts/Governance/Governed.sol\";\nimport \"moc-governance/contracts/Governance/IGovernor.sol\";\nimport \"./MoCLibConnection.sol\";\nimport \"./interface/IMoCState.sol\";\nimport \"./MoCBProxManager.sol\";\nimport \"./base/MoCBase.sol\";\nimport \"./interface/IMoCVendors.sol\";\nimport \"./interface/IMoCInrate.sol\";\n\ncontract MoCInrateEvents {\n  event RiskProHoldersInterestPay(uint256 amount, uint256 nReserveBucketC0BeforePay);\n}\n\ncontract MoCInrateStructs {\n  struct InrateParams {\n    uint256 tMax;\n    uint256 tMin;\n    uint256 power;\n  }\n\n  InrateParams btcxParams = InrateParams({\n    tMax: 261157876067800,\n    tMin: 0,\n    power: 1\n  });\n\n  struct InitializeParams {\n    // MoCConnector contract address\n    address connectorAddress;\n    // Governor contract address\n    address governor;\n    // Minimum interest rate [using mocPrecision]\n    uint256 btcxTmin;\n    // Power is a parameter for interest rate calculation [using noPrecision]\n    uint256 btcxPower;\n    // Maximun interest rate [using mocPrecision]\n    uint256 btcxTmax;\n    // BitPro holder interest rate [using mocPrecision]\n    uint256 bitProRate;\n    // BitPro blockspan to configure payments periods[using mocPrecision]\n    uint256 blockSpanBitPro;\n    // Target address to transfer the weekly BitPro holders interest\n    address payable bitProInterestTargetAddress;\n    // Target address to transfer commissions of mint/redeem\n    address payable commissionsAddressTarget;\n    //uint256 commissionRateParam,\n    // Upgrade to support red doc inrate parameter\n    uint256 docTmin;\n    // Upgrade to support red doc inrate parameter\n    uint256 docPower;\n    // Upgrade to support red doc inrate parameter\n    uint256 docTmax;\n  }\n}\n\n\ncontract MoCInrate is MoCInrateEvents, MoCInrateStructs, MoCBase, MoCLibConnection, Governed, IMoCInrate {\n  using SafeMath for uint256;\n\n  // Last block when a payment was executed\n  uint256 public lastDailyPayBlock;\n  // Absolute  BitPro holders rate for the given bitProInterestBlockSpan time span. [using mocPrecision]\n  uint256 public bitProRate;\n  // Target address to transfer BitPro holders interests\n  address payable public bitProInterestAddress;\n  // Last block when an BitPro holders instereste was calculated\n  uint256 public lastBitProInterestBlock;\n  // BitPro interest Blockspan to configure blocks between payments\n  uint256 public bitProInterestBlockSpan;\n\n  // Target addres to transfer commissions of mint/redeem\n  address payable public commissionsAddress;\n  /** UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n  /** DEPRECATED **/\n  // commissionRate [using mocPrecision]\n  // solium-disable-next-line mixedcase\n  uint256 public DEPRECATED_commissionRate;\n\n  /**CONTRACTS**/\n  IMoCState internal mocState;\n  /** DEPRECATED **/\n  // solium-disable-next-line mixedcase\n  address internal DEPRECATED_mocConverter;\n  MoCBProxManager internal bproxManager;\n\n  /************************************/\n  /***** UPGRADE v017       ***********/\n  /************************************/\n\n  /** START UPDATE V017: 01/11/2019 **/\n\n  // Upgrade to support red doc inrate parameter\n  uint256 public docTmin;\n  uint256 public docPower;\n  uint256 public docTmax;\n\n  function setDoCTmin(uint256 _docTmin) public onlyAuthorizedChanger() {\n    docTmin = _docTmin;\n  }\n\n  function setDoCTmax(uint256 _docTmax) public onlyAuthorizedChanger() {\n    docTmax = _docTmax;\n  }\n\n  function setDoCPower(uint256 _docPower) public onlyAuthorizedChanger(){\n    docPower = _docPower;\n  }\n\n  function getDoCTmin() public view returns(uint256) {\n    return docTmin;\n  }\n\n  function getDoCTmax() public view returns(uint256) {\n    return docTmax;\n  }\n\n  function getDoCPower() public view returns(uint256) {\n    return docPower;\n  }\n\n  /** END UPDATE V017: 01/11/2019 **/\n\n  /**\n    @dev Initializes the contract\n    @param params Params defined in InitializeParams struct\n  */\n  function initialize(InitializeParams memory params) public initializer {\n    initializePrecisions();\n    initializeBase(params.connectorAddress);\n    initializeContracts();\n    initializeValues(\n      params.governor,\n      params.btcxTmin,\n      params.btcxPower,\n      params.btcxTmax,\n      params.bitProRate,\n      params.commissionsAddressTarget,\n      //commissionRateParam,\n      params.blockSpanBitPro,\n      params.bitProInterestTargetAddress,\n      params.docTmin,\n      params.docPower,\n      params.docTmax\n    );\n  }\n\n  /**\n   * @dev gets tMin param of BTCX tokens\n   * @return returns tMin of BTCX\n   */\n  function getBtcxTmin() public view returns(uint256) {\n    return btcxParams.tMin;\n  }\n\n  /**\n   * @dev gets tMax param of BTCX tokens\n   * @return returns tMax of BTCX\n   */\n  function getBtcxTmax() public view returns(uint256) {\n    return btcxParams.tMax;\n  }\n\n  /**\n   * @dev gets power param of BTCX tokens\n   * @return returns power of BTCX\n   */\n  function getBtcxPower() public view returns(uint256) {\n    return btcxParams.power;\n  }\n\n  /**\n   * @dev Gets the blockspan of BPRO that represents the frecuency of BitPro holders intereset payment\n   * @return returns power of bitProInterestBlockSpan\n   */\n  function getBitProInterestBlockSpan() public view returns(uint256) {\n    return bitProInterestBlockSpan;\n  }\n\n  /**\n   * @dev sets tMin param of BTCX tokens\n   * @param _btxcTmin tMin of BTCX\n   */\n  function setBtcxTmin(uint256 _btxcTmin) public onlyAuthorizedChanger() {\n    btcxParams.tMin = _btxcTmin;\n  }\n\n  /**\n   * @dev sets tMax param of BTCX tokens\n   * @param _btxcTax tMax of BTCX\n   */\n  function setBtcxTmax(uint256 _btxcTax) public onlyAuthorizedChanger() {\n    btcxParams.tMax = _btxcTax;\n  }\n\n  /**\n   * @dev sets power param of BTCX tokens\n   * @param _btxcPower power of BTCX\n   */\n  function setBtcxPower(uint256 _btxcPower) public onlyAuthorizedChanger(){\n    btcxParams.power = _btxcPower;\n  }\n\n  /**\n   @dev Gets the rate for BitPro Holders\n   @return BitPro Rate\n  */\n  function getBitProRate() public view returns(uint256) {\n    return bitProRate;\n  }\n\n   /**\n    @dev Sets BitPro Holders rate\n    @param newBitProRate New BitPro rate\n   */\n  function setBitProRate(uint256 newBitProRate) public onlyAuthorizedChanger() {\n    bitProRate = newBitProRate;\n  }\n\n   /**\n    @dev Sets the blockspan BitPro Intereset rate payment is enable to be executed\n    @param newBitProBlockSpan New BitPro Block span\n   */\n  function setBitProInterestBlockSpan(uint256 newBitProBlockSpan) public onlyAuthorizedChanger() {\n    bitProInterestBlockSpan = newBitProBlockSpan;\n  }\n\n  /**\n   @dev Gets the target address to transfer BitPro Holders rate\n   @return Target address to transfer BitPro Holders interest\n  */\n  function getBitProInterestAddress() public view returns(address payable) {\n    return bitProInterestAddress;\n  }\n\n  /**\n   @dev Sets the target address to transfer BitPro Holders rate\n   @param newBitProInterestAddress New BitPro rate\n  */\n  function setBitProInterestAddress(address payable newBitProInterestAddress ) public onlyAuthorizedChanger() {\n    bitProInterestAddress = newBitProInterestAddress;\n  }\n\n  /**\n   @dev Sets the target address to transfer commissions of Mint/Redeem transactions\n   @param newCommissionsAddress New commisions address\n  */\n  function setCommissionsAddress(address payable newCommissionsAddress) public onlyAuthorizedChanger() {\n    commissionsAddress = newCommissionsAddress;\n  }\n\n  /************************************/\n  /***** UPGRADE v0110      ***********/\n  /************************************/\n\n  /** START UPDATE V0112: 24/09/2020  **/\n  /** Upgrade to support multiple commission rates **/\n  /** Public functions **/\n\n  /**\n    @dev calculates the Commission rate from the passed RBTC amount and the transaction type for mint/redeem operations\n    @param rbtcAmount Total value from which apply the Commission rate [using reservePrecision]\n    @param txType Transaction type according to constant values defined in this contract\n    @return finalCommissionAmount [using reservePrecision]\n  */\n  function calcCommissionValue(uint256 rbtcAmount, uint8 txType)\n  public view returns(uint256) {\n    // Validate txType\n    require (txType > 0, \"Invalid txType\");\n\n    uint256 finalCommissionAmount = rbtcAmount.mul(commissionRatesByTxType[txType]).div(mocLibConfig.mocPrecision);\n    return finalCommissionAmount;\n  }\n\n  /**\n    @dev DEPRECATED calculates the Commission rate from the passed RBTC amount for mint/redeem operations\n    @param rbtcAmount Total value from which apply the Commission rate [using reservePrecision]\n    @return finalCommissionAmount [using reservePrecision]\n  */\n  function calcCommissionValue(uint256 rbtcAmount)\n  external view returns(uint256) {\n    // solium-disable-next-line mixedcase\n    uint256 finalCommissionAmount = rbtcAmount.mul(commissionRatesByTxType[MINT_BPRO_FEES_RBTC]).div(mocLibConfig.mocPrecision);\n    return finalCommissionAmount;\n  }\n\n  /**\n    @dev calculates the vendor markup rate from the passed vendor account and amount\n    @param vendorAccount Vendor address\n    @param amount Total value from which apply the vendor markup rate [using reservePrecision]\n    @return finalCommissionAmount [using reservePrecision]\n  */\n  function calculateVendorMarkup(address vendorAccount, uint256 amount) public view\n    returns (uint256 markup) {\n    // Calculate according to vendor markup\n    if (vendorAccount != address(0)) {\n      IMoCVendors mocVendors = IMoCVendors(mocState.getMoCVendors());\n\n      markup = amount.mul(mocVendors.getMarkup(vendorAccount)).div(mocLibConfig.mocPrecision);\n    }\n\n    return markup;\n  }\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  function isDailyEnabled() public view returns(bool) {\n    return false;\n  }\n\n  function isBitProInterestEnabled() public view returns(bool) {\n    return lastBitProInterestBlock == 0 || block.number > (lastBitProInterestBlock + bitProInterestBlockSpan);\n  }\n\n  /**\n   * @dev Calculates BitPro Holders interest rates\n   * @return toPay interest in RBTC [using RBTCPrecsion]\n   * @return bucketBtnc0 RTBC on bucket0 used to calculate de interest [using RBTCPrecsion]\n   */\n  function calculateBitProHoldersInterest() public view returns(uint256, uint256) {\n    uint256 bucketBtnc0 = bproxManager.getBucketNBTC(BUCKET_C0);\n    uint256 toPay = (bucketBtnc0.mul(bitProRate).div(mocLibConfig.mocPrecision));\n    return (toPay, bucketBtnc0);\n  }\n\n  /**\n   * @dev Pays the BitPro Holders interest rates\n   * @return interest payed in RBTC [using RBTCPrecsion]\n   */\n  function payBitProHoldersInterestPayment() public\n  onlyWhitelisted(msg.sender)\n  onlyWhenBitProInterestsIsEnabled() returns(uint256) {\n    (uint256 bitProInterest, uint256 bucketBtnc0) = calculateBitProHoldersInterest();\n    lastBitProInterestBlock = block.number;\n    emit RiskProHoldersInterestPay(bitProInterest, bucketBtnc0);\n    return bitProInterest;\n  }\n\n  /************************************/\n  /***** UPGRADE v0110      ***********/\n  /************************************/\n\n  /** START UPDATE V0112: 24/09/2020  **/\n  /** Upgrade to support multiple commission rates **/\n  /** Public functions **/\n  /**\n    @dev Sets the commission rate to a particular transaction type\n    @param txType Transaction type according to constant values defined in this contract\n    @param value Commission rate\n  */\n  function setCommissionRateByTxType(uint8 txType, uint256 value) public onlyAuthorizedChanger() {\n    commissionRatesByTxType[txType] = value;\n  }\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  modifier onlyWhenBitProInterestsIsEnabled() {\n    require(isBitProInterestEnabled(), \"Interest rate of BitPro holders already payed this week\");\n    _;\n  }\n\n  /**\n   * @dev Initialize the contracts with which it interacts\n   */\n  function initializeContracts() internal {\n    bproxManager = MoCBProxManager(connector.bproxManager());\n    mocState = IMoCState(connector.mocState());\n  }\n\n  /**\n   * @dev Initialize the parameters of the contract\n   * @param _governor the address of the IGovernor contract\n   * @param btcxMin Minimum interest rate [using mocPrecision]\n   * @param btcxPower Power is a parameter for interest rate calculation [using noPrecision]\n   * @param btcxMax Maximun interest rate [using mocPrecision]\n   * @param _bitProRate BitPro holder interest rate [using mocPrecision]\n   * @param blockSpanBitPro BitPro blockspan to configure payments periods[using mocPrecision]\n   * @param bitProInterestsTarget Target address to transfer the weekly BitPro holders interest\n   */\n  function initializeValues(\n    address _governor,\n    uint256 btcxMin,\n    uint256 btcxPower,\n    uint256 btcxMax,\n    uint256 _bitProRate,\n    address payable commissionsAddressTarget,\n    //uint256 commissionRateParam,\n    uint256 blockSpanBitPro,\n    address payable bitProInterestsTarget,\n    uint256 _docTmin,\n    uint256 _docPower,\n    uint256 _docTmax\n  ) internal {\n    governor = IGovernor(_governor);\n    btcxParams.tMin = btcxMin;\n    btcxParams.power = btcxPower;\n    btcxParams.tMax = btcxMax;\n    bitProRate = _bitProRate;\n    bitProInterestAddress = bitProInterestsTarget;\n    bitProInterestBlockSpan = blockSpanBitPro;\n    //commissionRate = commissionRateParam;\n    commissionsAddress = commissionsAddressTarget;\n    docTmin = _docTmin;\n    docPower = _docPower;\n    docTmax = _docTmax;\n  }\n\n  /************************************/\n  /***** UPGRADE v0110      ***********/\n  /************************************/\n\n  /** START UPDATE V0112: 24/09/2020  **/\n  /** Upgrade to support multiple commission rates **/\n\n  // Transaction types\n  uint8 public constant MINT_BPRO_FEES_RBTC = 1;\n  uint8 public constant REDEEM_BPRO_FEES_RBTC = 2;\n  uint8 public constant MINT_DOC_FEES_RBTC = 3;\n  uint8 public constant REDEEM_DOC_FEES_RBTC = 4;\n  uint8 public constant MINT_BTCX_FEES_RBTC = 5;\n  uint8 public constant REDEEM_BTCX_FEES_RBTC = 6;\n  uint8 public constant MINT_BPRO_FEES_MOC = 7;\n  uint8 public constant REDEEM_BPRO_FEES_MOC = 8;\n  uint8 public constant MINT_DOC_FEES_MOC = 9;\n  uint8 public constant REDEEM_DOC_FEES_MOC = 10;\n  uint8 public constant MINT_BTCX_FEES_MOC = 11;\n  uint8 public constant REDEEM_BTCX_FEES_MOC = 12;\n\n  mapping(uint8 => uint256) public commissionRatesByTxType;\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n"}],"is_verified_via_sourcify":false,"can_be_visualized_via_sol2uml":true,"evm_version":"byzantium","language":"solidity","is_verified_via_eth_bytecode_db":false,"is_fully_verified":false,"license_type":"none","is_blueprint":false,"name":"MoCExchange","creation_bytecode":"0x608060405234801561001057600080fd5b5061375a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100ee5760003560e060020a90048063a62c25c711610090578063d524a1681161006a578063d524a168146101e1578063e22155f6146101f4578063e2414a73146101fc578063f715e29314610204576100ee565b8063a62c25c714610198578063b02ff016146101ab578063c4d66de8146101cc576100ee565b806357a13a16116100cc57806357a13a16146101485780637e7cafda146101505780637f2c0b471461016357806383f3084f14610183576100ee565b806306bdce8c146100f35780631a5e89861461011157806345e2c5a614610135575b600080fd5b6100fb61020c565b60405161010891906132fe565b60405180910390f35b61012461011f366004612f2b565b610212565b604051610108959493929190613594565b6100fb610143366004612efb565b6105e3565b6100fb610a78565b61012461015e366004612f2b565b610a9c565b610176610171366004612f96565b611169565b604051610108919061340d565b61018b61166a565b604051610108919061337f565b6101246101a6366004612f2b565b611679565b6101be6101b9366004612efb565b611ac6565b60405161010892919061346b565b6101df6101da366004612eb7565b611cae565b005b6101246101ef366004612f2b565b611d4e565b6100fb61230e565b6100fb61231a565b6100fb612320565b60665490565b60335460405160e060020a633af32abf02815260009182918291829182913391600160a060020a0390911690633af32abf906102529084906004016132ba565b60206040518083038186803b15801561026a57600080fd5b505afa15801561027e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506102a29190810190612f78565b6102ca5760405160e560020a62461bcd0281526004016102c1906133bd565b60405180910390fd5b6102d2612cf4565b609b60009054906101000a9004600160a060020a0316600160a060020a03166308c36d9e6040518163ffffffff1660e060020a02815260040160206040518083038186803b15801561032357600080fd5b505afa158015610337573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061035b9190810190612fb4565b8152600060c082018190526020820152881561043a57606673592b84710955c9561008d137a5403e1dd9a222d86366a4c71890916103a684602001518d61232690919063ffffffff16565b845160405160e060020a63ffffffff86160281526103c99392919060040161341b565b60206040518083038186803b1580156103e157600080fd5b505af41580156103f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104199190810190612fb4565b6080820181905260c08201516104349163ffffffff61235616565b60c08201525b610442612d3e565b600160a060020a03808c16825260208083018c905260a054604080517f49ed3637000000000000000000000000000000000000000000000000000000008152905191909316926349ed3637926004808301939192829003018186803b1580156104aa57600080fd5b505afa1580156104be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104e29190810190612fd2565b60ff1660408083019190915260a05481517f3e2153010000000000000000000000000000000000000000000000000000000081529151600160a060020a0390911691633e215301916004808301926020929190829003018186803b15801561054957600080fd5b505afa15801561055d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105819190810190612fd2565b60ff166060820152600160a060020a03891660808201526105a181611169565b60e08301526105b28b8b848c612385565b5060e0015180516020820151608083015160a0909301518b9950919750955090935091505b50939792965093509350565b60335460405160e060020a633af32abf0281526000913391600160a060020a0390911690633af32abf9061061b9084906004016132ba565b60206040518083038186803b15801561063357600080fd5b505afa158015610647573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061066b9190810190612f78565b61068a5760405160e560020a62461bcd0281526004016102c1906133bd565b609f546040517f70a08231000000000000000000000000000000000000000000000000000000008152600091600160a060020a0316906370a08231906106d49088906004016132ba565b60206040518083038186803b1580156106ec57600080fd5b505afa158015610700573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107249190810190612fb4565b905080610735576000925050610a71565b609b54604080517f46558d1b0000000000000000000000000000000000000000000000000000000081529051600092600160a060020a0316916346558d1b916004808301926020929190829003018186803b15801561079357600080fd5b505afa1580156107a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107cb9190810190612fb4565b90506000606673592b84710955c9561008d137a5403e1dd9a222d86382981718909185609b60009054906101000a9004600160a060020a0316600160a060020a0316631f1cb62b6040518163ffffffff1660e060020a02815260040160206040518083038186803b15801561083f57600080fd5b505afa158015610853573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108779190810190612fb4565b866040518563ffffffff1660e060020a02815260040161089a9493929190613443565b60206040518083038186803b1580156108b257600080fd5b505af41580156108c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108ea9190810190612fb4565b60a1546040517f3debd2d8000000000000000000000000000000000000000000000000000000008152919250600160a060020a031690633debd2d89061093690899085906004016132c8565b602060405180830381600087803b15801561095057600080fd5b505af1158015610964573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109889190810190612f78565b15610a6957609f546040517f9dc29fac000000000000000000000000000000000000000000000000000000008152600160a060020a0390911690639dc29fac906109d8908a9087906004016132c8565b600060405180830381600087803b1580156109f257600080fd5b505af1158015610a06573d6000803e3d6000fd5b5050505086600160a060020a03167f16922e9a6cbcce4767d759c44585dd5644eb4b70adda075f4db974c6fe24bc1f84836000866000806000806000604051610a5799989796959493929190613479565b60405180910390a29350610a71915050565b600094505050505b5092915050565b7f583200000000000000000000000000000000000000000000000000000000000081565b60335460405160e060020a633af32abf02815260009182918291829182913391600160a060020a0390911690633af32abf90610adc9084906004016132ba565b60206040518083038186803b158015610af457600080fd5b505afa158015610b08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b2c9190810190612f78565b610b4b5760405160e560020a62461bcd0281526004016102c1906133bd565b610b53612d6c565b881561115157609b54604080517f8300df490000000000000000000000000000000000000000000000000000000081529051600092600160a060020a031691638300df49916004808301926020929190829003018186803b158015610bb757600080fd5b505afa158015610bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610bef9190810190612fb4565b6040517f6108a7ef00000000000000000000000000000000000000000000000000000000815290915073592b84710955c9561008d137a5403e1dd9a222d890636108a7ef90610c47906066908e90869060040161341b565b60206040518083038186803b158015610c5f57600080fd5b505af4158015610c73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c979190810190612fb4565b808352609b54604080517f133374bd0000000000000000000000000000000000000000000000000000000081529051610d379392600160a060020a03169163133374bd916004808301926020929190829003018186803b158015610cfa57600080fd5b505afa158015610d0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d329190810190612fb4565b61252d565b60208301819052825114610e6957606673592b84710955c9561008d137a5403e1dd9a222d8638298171890918460200151609b60009054906101000a9004600160a060020a0316600160a060020a0316631f1cb62b6040518163ffffffff1660e060020a02815260040160206040518083038186803b158015610db957600080fd5b505afa158015610dcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610df19190810190612fb4565b856040518563ffffffff1660e060020a028152600401610e149493929190613443565b60206040518083038186803b158015610e2c57600080fd5b505af4158015610e40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e649190810190612fb4565b610e6b565b895b604080840191909152609f54602084015191517f40c10f19000000000000000000000000000000000000000000000000000000008152600160a060020a03909116916340c10f1991610ec1918f916004016132c8565b602060405180830381600087803b158015610edb57600080fd5b505af1158015610eef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610f139190810190612f78565b50609d54604080840151602085015191517fab9757c0000000000000000000000000000000000000000000000000000000008152600160a060020a039093169263ab9757c092610f759260f460020a610433029290919060009060040161334a565b600060405180830381600087803b158015610f8f57600080fd5b505af1158015610fa3573d6000803e3d6000fd5b50505050610faf612d3e565b600160a060020a03808d16825260408085015160208085019190915260a05482517f64f9c31f00000000000000000000000000000000000000000000000000000000815292519316926364f9c31f926004808201939291829003018186803b15801561101a57600080fd5b505afa15801561102e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110529190810190612fd2565b60ff1660408083019190915260a05481517f960abe610000000000000000000000000000000000000000000000000000000081529151600160a060020a039091169163960abe61916004808301926020929190829003018186803b1580156110b957600080fd5b505afa1580156110cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110f19190810190612fd2565b60ff166060820152600160a060020a038a16608082015261111181611169565b60608401526111218c848c612543565b5050604081015160609091015180516020820151608083015160a0909301519399509097509550935091506105d7565b506000998a9950899850889750879650945050505050565b611171612d90565b609b60009054906101000a9004600160a060020a0316600160a060020a0316638300df496040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156111c257600080fd5b505afa1580156111d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111fa9190810190612fb4565b604080830191909152609b5481517f9a80d4210000000000000000000000000000000000000000000000000000000081529151600160a060020a0390911691639a80d421916004808301926020929190829003018186803b15801561125e57600080fd5b505afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112969190810190612fb4565b606082015260408101516112bf5760405160e560020a62461bcd0281526004016102c19061339d565b60008160600151116112e65760405160e560020a62461bcd0281526004016102c19061338d565b60a054608083015160208401516040517f0e20ead1000000000000000000000000000000000000000000000000000000008152600093600160a060020a031692630e20ead192611338926004016132c8565b60206040518083038186803b15801561135057600080fd5b505afa158015611364573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113889190810190612fb4565b835160a15491925060009182916113a791600160a060020a0316611ac6565b9150915080600014806113b8575081155b1561146e5760a054602086015160608701516040517fb978cff3000000000000000000000000000000000000000000000000000000008152600160a060020a039093169263b978cff392611410929091600401613658565b60206040518083038186803b15801561142857600080fd5b505afa15801561143c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114609190810190612fb4565b845250506080820152611665565b60a054602086015160408088015190517fb978cff3000000000000000000000000000000000000000000000000000000008152600093600160a060020a03169263b978cff3926114c092600401613658565b60206040518083038186803b1580156114d857600080fd5b505afa1580156114ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115109190810190612fb4565b905061153d85606001516115318388604001516125be90919063ffffffff16565b9063ffffffff6125fb16565b6020860152606085015160408601516115619190611531908763ffffffff6125be16565b60a086018190526020860151600091611580919063ffffffff61235616565b90508084101580156115925750808310155b158061159c575081155b1561165f576000602080880182905260a08089019290925290549088015160608901516040517fb978cff3000000000000000000000000000000000000000000000000000000008152600160a060020a039093169263b978cff392611605929091600401613658565b60206040518083038186803b15801561161d57600080fd5b505afa158015611631573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116559190810190612fb4565b8652608086018590525b50505050505b919050565b603354600160a060020a031681565b60335460405160e060020a633af32abf02815260009182918291829182913391600160a060020a0390911690633af32abf906116b99084906004016132ba565b60206040518083038186803b1580156116d157600080fd5b505afa1580156116e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117099190810190612f78565b6117285760405160e560020a62461bcd0281526004016102c1906133bd565b6000881161174557600095508594508493508392508291506105d7565b61174d612d6c565b61183989610d32609b60009054906101000a9004600160a060020a0316600160a060020a031663a8ba1d186040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156117a557600080fd5b505afa1580156117b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117dd9190810190612fb4565b609f60009054906101000a9004600160a060020a0316600160a060020a03166370a082318f6040518263ffffffff1660e060020a02815260040161182191906132ba565b60206040518083038186803b158015610cfa57600080fd5b808252609b546040517f408d3aad000000000000000000000000000000000000000000000000000000008152600092600160a060020a039092169163408d3aad9161188791906004016132fe565b60206040518083038186803b15801561189f57600080fd5b505afa1580156118b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118d79190810190612fb4565b6020830181905290506118e8612d3e565b600160a060020a03808d1682526020808501518184015260a054604080517f72690459000000000000000000000000000000000000000000000000000000008152905191909316926372690459926004808301939192829003018186803b15801561195257600080fd5b505afa158015611966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061198a9190810190612fd2565b60ff1660408083019190915260a05481517fbfac83c20000000000000000000000000000000000000000000000000000000081529151600160a060020a039091169163bfac83c2916004808301926020929190829003018186803b1580156119f157600080fd5b505afa158015611a05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a299190810190612fd2565b60ff166060820152600160a060020a038a166080820152611a4981611169565b60608401528251611a5c908d9084612633565b611a678c848c61273f565b6060830151608081015190516020850151611a999291611a8d919063ffffffff61232616565b9063ffffffff61232616565b60609093015180516020820151608083015160a090930151959b50909950975095509193506105d7915050565b609b54604080517f7f13cb06000000000000000000000000000000000000000000000000000000008152905160009283928392600160a060020a0390921691637f13cb0691600480820192602092909190829003018186803b158015611b2b57600080fd5b505afa158015611b3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b639190810190612edd565b9050600160a060020a03811615611ca6576040517f70a08231000000000000000000000000000000000000000000000000000000008152600160a060020a038216906370a0823190611bb99088906004016132ba565b60206040518083038186803b158015611bd157600080fd5b505afa158015611be5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611c099190810190612fb4565b6040517fdd62ed3e000000000000000000000000000000000000000000000000000000008152909350600160a060020a0382169063dd62ed3e90611c5390889088906004016132e3565b60206040518083038186803b158015611c6b57600080fd5b505afa158015611c7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611ca39190810190612fb4565b91505b509250929050565b600054610100900460ff1680611cc75750611cc76127b0565b80611cd5575060005460ff16155b611cf45760405160e560020a62461bcd0281526004016102c1906133fd565b600054610100900460ff16158015611d1f576000805460ff1961ff0019909116610100171660011790555b611d276127b6565b611d30826127e9565b611d3861288a565b8015611d4a576000805461ff00191690555b5050565b60335460405160e060020a633af32abf02815260009182918291829182913391600160a060020a0390911690633af32abf90611d8e9084906004016132ba565b60206040518083038186803b158015611da657600080fd5b505afa158015611dba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611dde9190810190612f78565b611dfd5760405160e560020a62461bcd0281526004016102c1906133bd565b611e05612dc6565b609e546040517f70a08231000000000000000000000000000000000000000000000000000000008152600091600160a060020a0316906370a0823190611e4f908e906004016132ba565b60206040518083038186803b158015611e6757600080fd5b505afa158015611e7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611e9f9190810190612fb4565b90506000611ead8b8361252d565b9050611f0481609b60009054906101000a9004600160a060020a0316600160a060020a031663fa8ba4906040518163ffffffff1660e060020a02815260040160206040518083038186803b158015610cfa57600080fd5b808452609b54604080517f08c36d9e000000000000000000000000000000000000000000000000000000008152905160009373592b84710955c9561008d137a5403e1dd9a222d893636ef454cf93606693600160a060020a03909216916308c36d9e91600480820192602092909190829003018186803b158015611f8757600080fd5b505afa158015611f9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611fbf9190810190612fb4565b6040518463ffffffff1660e060020a028152600401611fe09392919061341b565b60206040518083038186803b158015611ff857600080fd5b505af415801561200c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506120309190810190612fb4565b905061203a612d3e565b600160a060020a03808f168252602080830184905260a054604080517f1cabe3bf00000000000000000000000000000000000000000000000000000000815290519190931692631cabe3bf926004808301939192829003018186803b1580156120a257600080fd5b505afa1580156120b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506120da9190810190612fd2565b60ff1660408083019190915260a05481517f691e7d900000000000000000000000000000000000000000000000000000000081529151600160a060020a039091169163691e7d90916004808301926020929190829003018186803b15801561214157600080fd5b505afa158015612155573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506121799190810190612fd2565b60ff166060820152600160a060020a038c16608082015261219981611169565b8560400181905250609e60009054906101000a9004600160a060020a0316600160a060020a0316639dc29fac8f87600001516040518363ffffffff1660e060020a0281526004016121eb9291906132c8565b600060405180830381600087803b15801561220557600080fd5b505af1158015612219573d6000803e3d6000fd5b5050609d5487516040517f119e2ad6000000000000000000000000000000000000000000000000000000008152600160a060020a03909216935063119e2ad692506122769160f460020a610433029187916000919060040161330c565b600060405180830381600087803b15801561229057600080fd5b505af11580156122a4573d6000803e3d6000fd5b5050506040860151608081015190516122c99250611a8d90859063ffffffff61232616565b60208601526122d98e868e612c87565b50505050602081810151604090920151805191810151608082015160a090920151939d929c509a509850909650945050505050565b60f460020a6104330281565b60675490565b60685490565b60008282111561234b5760405160e560020a62461bcd0281526004016102c1906133cd565b508082035b92915050565b60008282018381101561237e5760405160e560020a62461bcd0281526004016102c1906133ad565b9392505050565b609e5460c08301516040517f40c10f19000000000000000000000000000000000000000000000000000000008152600160a060020a03909216916340c10f19916123d4918891906004016132c8565b602060405180830381600087803b1580156123ee57600080fd5b505af1158015612402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124269190810190612f78565b50609d5460c08301516040517fab9757c0000000000000000000000000000000000000000000000000000000008152600160a060020a039092169163ab9757c0916124839160f460020a610433029188916000919060040161330c565b600060405180830381600087803b15801561249d57600080fd5b505af11580156124b1573d6000803e3d6000fd5b50505060c083015160e0840151805160408083015160208401516060850151608086015160a0909601519351600160a060020a038d1698507f95edf7037d7a5b55fc522aa5b9e90d56fa4d260db85134e27b7d90cb060ae2149761251f9790968d9690959493928c906135e0565b60405180910390a250505050565b600081831061253c578161237e565b5090919050565b6020808301516040808501516060808701518051818501519682015192820151608083015160a0909301519551600160a060020a038c16987f76ca2c798b889609c917b5182a786a588c12d26e23239692ec9f26d5a793b9e7986125b1989097969495919493928c906135e0565b60405180910390a2505050565b6000826125cd57506000612350565b828202828482816125da57fe5b041461237e5760405160e560020a62461bcd0281526004016102c1906133ed565b600080821161261f5760405160e560020a62461bcd0281526004016102c1906133dd565b600082848161262a57fe5b04949350505050565b609f546040517f9dc29fac000000000000000000000000000000000000000000000000000000008152600160a060020a0390911690639dc29fac9061267e90869086906004016132c8565b600060405180830381600087803b15801561269857600080fd5b505af11580156126ac573d6000803e3d6000fd5b5050609d546040517f119e2ad6000000000000000000000000000000000000000000000000000000008152600160a060020a03909116925063119e2ad691506127089060f460020a61043302908590879060009060040161334a565b600060405180830381600087803b15801561272257600080fd5b505af1158015612736573d6000803e3d6000fd5b50505050505050565b815160208084015160608086015180516040808301519583015193830151608084015160a0909401519151600160a060020a038c16987fc20403d07f634f7fe3f9b2a1602b210f43bf3954955fe06a18dbe71cd765a3b6986125b19891979196600095919492939091908d906134ff565b303b1590565b60408051606081018252670de0b6b3a7640000808252600160208301819052919092018290526066829055606755606855565b600054610100900460ff168061280257506128026127b0565b80612810575060005460ff16155b61282f5760405160e560020a62461bcd0281526004016102c1906133fd565b600054610100900460ff1615801561285a576000805460ff1961ff0019909116610100171660011790555b60338054600160a060020a031916600160a060020a0384161790558015611d4a576000805461ff00191690555050565b603360009054906101000a9004600160a060020a0316600160a060020a031663534282536040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156128db57600080fd5b505afa1580156128ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506129139190810190612edd565b60a18054600160a060020a031916600160a060020a03928316179055603354604080517f99c6fe73000000000000000000000000000000000000000000000000000000008152905191909216916399c6fe73916004808301926020929190829003018186803b15801561298557600080fd5b505afa158015612999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506129bd9190810190612edd565b609f8054600160a060020a031916600160a060020a03928316179055603354604080517fd31cc8310000000000000000000000000000000000000000000000000000000081529051919092169163d31cc831916004808301926020929190829003018186803b158015612a2f57600080fd5b505afa158015612a43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a679190810190612edd565b609e8054600160a060020a031916600160a060020a03928316179055603354604080517f955b570a0000000000000000000000000000000000000000000000000000000081529051919092169163955b570a916004808301926020929190829003018186803b158015612ad957600080fd5b505afa158015612aed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612b119190810190612edd565b609d8054600160a060020a031916600160a060020a03928316179055603354604080517f12529f1f000000000000000000000000000000000000000000000000000000008152905191909216916312529f1f916004808301926020929190829003018186803b158015612b8357600080fd5b505afa158015612b97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612bbb9190810190612edd565b609b8054600160a060020a031916600160a060020a03928316179055603354604080517fffb691300000000000000000000000000000000000000000000000000000000081529051919092169163ffb69130916004808301926020929190829003018186803b158015612c2d57600080fd5b505afa158015612c41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612c659190810190612edd565b60a08054600160a060020a031916600160a060020a0392909216919091179055565b8151602080840151604080860151805181830151948201516060830151608084015160a0909401519451600160a060020a038c16987fb68ac1b7654fd8a98182c5df375de6fb43e94a616e123ed82e2b87955a673934986125b19891979196909493929091908c906135e0565b60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001612d39612d90565b905290565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040518060800160405280600081526020016000815260200160008152602001612d395b6040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180606001604052806000815260200160008152602001612d39612d90565b8035612350816136e5565b8051612350816136e5565b8051612350816136fc565b600060a08284031215612e1a57600080fd5b612e2460a0613673565b90506000612e328484612de7565b8252506020612e4384848301612e8b565b6020830152506040612e5784828501612ea1565b6040830152506060612e6b84828501612ea1565b6060830152506080612e7f84828501612de7565b60808301525092915050565b803561235081613705565b805161235081613705565b80356123508161370e565b80516123508161370e565b600060208284031215612ec957600080fd5b6000612ed58484612de7565b949350505050565b600060208284031215612eef57600080fd5b6000612ed58484612df2565b60008060408385031215612f0e57600080fd5b6000612f1a8585612de7565b9250506020611ca385828601612de7565b600080600060608486031215612f4057600080fd5b6000612f4c8686612de7565b9350506020612f5d86828701612e8b565b9250506040612f6e86828701612de7565b9150509250925092565b600060208284031215612f8a57600080fd5b6000612ed58484612dfd565b600060a08284031215612fa857600080fd5b6000612ed58484612e08565b600060208284031215612fc657600080fd5b6000612ed58484612e96565b600060208284031215612fe457600080fd5b6000612ed58484612eac565b612ff9816136c8565b82525050565b612ff9816136a3565b612ff9816136b3565b612ff9816136cf565b612ff9816136da565b6000613030600e8361369a565b7f4d6f43207072696365207a65726f000000000000000000000000000000000000815260200192915050565b6000613069600e8361369a565b7f425443207072696365207a65726f000000000000000000000000000000000000815260200192915050565b60006130a2601b8361369a565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b60006130db601a8361369a565b7f41646472657373206973206e6f742077686974656c6973746564000000000000815260200192915050565b6000613114601e8361369a565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b600061314d601a8361369a565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b600061318660218361369a565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f81527f7700000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b60006131e5602e8361369a565b7f436f6e747261637420696e7374616e63652068617320616c726561647920626581527f656e20696e697469616c697a6564000000000000000000000000000000000000602082015260400192915050565b805160c08301906132488482613008565b50602082015161325b6020850182613008565b50604082015161326e6040850182613008565b5060608201516132816060850182613008565b5060808201516132946080850182613008565b5060a08201516132a760a0850182613008565b50505050565b9052565b612ff9816136c2565b602081016123508284612fff565b604081016132d68285612fff565b61237e6020830184613008565b604081016132f18285612fff565b61237e6020830184612fff565b602081016123508284613008565b6080810161331a8287613008565b6133276020830186613008565b613334604083018561301a565b6133416060830184613008565b95945050505050565b608081016133588287613008565b6133656020830186613008565b6133726040830185613008565b613341606083018461301a565b602081016123508284613011565b6020808252810161235081613023565b602080825281016123508161305c565b6020808252810161235081613095565b60208082528101612350816130ce565b6020808252810161235081613107565b6020808252810161235081613140565b6020808252810161235081613179565b60208082528101612350816131d8565b60c081016123508284613237565b6060810161342982866132ad565b6134366020830185613008565b612ed56040830184613008565b6080810161345182876132ad565b61345e6020830186613008565b6133346040830185613008565b604081016132d68285613008565b6101208101613488828c613008565b613495602083018b613008565b6134a2604083018a61301a565b6134af6060830189613008565b6134bc608083018861301a565b6134c960a083018761301a565b6134d660c083018661301a565b6134e360e083018561301a565b6134f1610100830184612ff0565b9a9950505050505050505050565b610140810161350e828d613008565b61351b602083018c613008565b613528604083018b613008565b613535606083018a61301a565b6135426080830189613008565b61354f60a0830188613008565b61355c60c0830187613008565b61356960e0830186613008565b613577610100830185613008565b613585610120830184612fff565b9b9a5050505050505050505050565b60a081016135a28288613008565b6135af6020830187613008565b6135bc6040830186613008565b6135c96060830185613008565b6135d66080830184613008565b9695505050505050565b61012081016135ef828c613008565b6135fc602083018b613008565b613609604083018a613008565b6136166060830189613008565b6136236080830188613008565b61363060a0830187613008565b61363d60c0830186613008565b61364a60e0830185613008565b6134f1610100830184612fff565b604081016136668285613008565b61237e60208301846132b1565b60405181810167ffffffffffffffff8111828210171561369257600080fd5b604052919050565b90815260200190565b6000612350826136b6565b151590565b90565b600160a060020a031690565b60ff1690565b6000612350825b6000612350826136a3565b6000612350826136b3565b6136ee816136a3565b81146136f957600080fd5b50565b6136ee816136ae565b6136ee816136b3565b6136ee816136c256fea365627a7a72315820ca73216f72b64443434bfca063c9cd172cceba4fb19e6a958e694eb2db235b026c6578706572696d656e74616cf564736f6c63430005110040","external_libraries":[{"name":"npm/money-on-chain@0.1.14/contracts/MoCHelperLib.sol:MoCHelperLib","address_hash":"0x592B84710955C9561008D137A5403e1DD9A222d8"}],"proxy_type":null,"implementations":[],"verified_at":"2026-06-24T14:08:51.811874Z","is_verified_via_verifier_alliance":false,"compiler_version":"v0.5.17+commit.d19bba13","decoded_constructor_args":null,"sourcify_repo_url":null,"optimization_runs":200,"compiler_settings":{"evmVersion":"byzantium","libraries":{},"optimizer":{"enabled":true,"runs":200},"outputSelection":{"*":{"":["*"],"*":["*"]}},"remappings":["npm/moc-governance@0.1.0/:zos-lib/=npm/zos-lib@2.3.1/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:moc-governance/=npm/moc-governance@0.1.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:openzeppelin-solidity/=npm/openzeppelin-solidity@2.3.0/","npm/money-on-chain@0.1.14/:zos-lib/=npm/zos-lib@2.3.1/","npm/money-on-chain@0.1.14/:zos-lib/=npm/zos-lib@2.3.1/","project/:@moc/rbtc/=npm/money-on-chain@0.1.14/","project/:@moc/rbtc/=npm/money-on-chain@0.1.14/","project/:@moc/rbtc/=npm/money-on-chain@0.1.14/","project/:@moc/rbtc/=npm/money-on-chain@0.1.14/","project/:@moc/rbtc/=npm/money-on-chain@0.1.14/","project/:@moc/rbtc/=npm/money-on-chain@0.1.14/"]},"is_verified":true,"verified_twin_address_hash":null,"optimization_enabled":true,"deployed_bytecode":"0x608060405234801561001057600080fd5b50600436106100ee5760003560e060020a90048063a62c25c711610090578063d524a1681161006a578063d524a168146101e1578063e22155f6146101f4578063e2414a73146101fc578063f715e29314610204576100ee565b8063a62c25c714610198578063b02ff016146101ab578063c4d66de8146101cc576100ee565b806357a13a16116100cc57806357a13a16146101485780637e7cafda146101505780637f2c0b471461016357806383f3084f14610183576100ee565b806306bdce8c146100f35780631a5e89861461011157806345e2c5a614610135575b600080fd5b6100fb61020c565b60405161010891906132fe565b60405180910390f35b61012461011f366004612f2b565b610212565b604051610108959493929190613594565b6100fb610143366004612efb565b6105e3565b6100fb610a78565b61012461015e366004612f2b565b610a9c565b610176610171366004612f96565b611169565b604051610108919061340d565b61018b61166a565b604051610108919061337f565b6101246101a6366004612f2b565b611679565b6101be6101b9366004612efb565b611ac6565b60405161010892919061346b565b6101df6101da366004612eb7565b611cae565b005b6101246101ef366004612f2b565b611d4e565b6100fb61230e565b6100fb61231a565b6100fb612320565b60665490565b60335460405160e060020a633af32abf02815260009182918291829182913391600160a060020a0390911690633af32abf906102529084906004016132ba565b60206040518083038186803b15801561026a57600080fd5b505afa15801561027e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506102a29190810190612f78565b6102ca5760405160e560020a62461bcd0281526004016102c1906133bd565b60405180910390fd5b6102d2612cf4565b609b60009054906101000a9004600160a060020a0316600160a060020a03166308c36d9e6040518163ffffffff1660e060020a02815260040160206040518083038186803b15801561032357600080fd5b505afa158015610337573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061035b9190810190612fb4565b8152600060c082018190526020820152881561043a57606673592b84710955c9561008d137a5403e1dd9a222d86366a4c71890916103a684602001518d61232690919063ffffffff16565b845160405160e060020a63ffffffff86160281526103c99392919060040161341b565b60206040518083038186803b1580156103e157600080fd5b505af41580156103f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104199190810190612fb4565b6080820181905260c08201516104349163ffffffff61235616565b60c08201525b610442612d3e565b600160a060020a03808c16825260208083018c905260a054604080517f49ed3637000000000000000000000000000000000000000000000000000000008152905191909316926349ed3637926004808301939192829003018186803b1580156104aa57600080fd5b505afa1580156104be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104e29190810190612fd2565b60ff1660408083019190915260a05481517f3e2153010000000000000000000000000000000000000000000000000000000081529151600160a060020a0390911691633e215301916004808301926020929190829003018186803b15801561054957600080fd5b505afa15801561055d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105819190810190612fd2565b60ff166060820152600160a060020a03891660808201526105a181611169565b60e08301526105b28b8b848c612385565b5060e0015180516020820151608083015160a0909301518b9950919750955090935091505b50939792965093509350565b60335460405160e060020a633af32abf0281526000913391600160a060020a0390911690633af32abf9061061b9084906004016132ba565b60206040518083038186803b15801561063357600080fd5b505afa158015610647573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061066b9190810190612f78565b61068a5760405160e560020a62461bcd0281526004016102c1906133bd565b609f546040517f70a08231000000000000000000000000000000000000000000000000000000008152600091600160a060020a0316906370a08231906106d49088906004016132ba565b60206040518083038186803b1580156106ec57600080fd5b505afa158015610700573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107249190810190612fb4565b905080610735576000925050610a71565b609b54604080517f46558d1b0000000000000000000000000000000000000000000000000000000081529051600092600160a060020a0316916346558d1b916004808301926020929190829003018186803b15801561079357600080fd5b505afa1580156107a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107cb9190810190612fb4565b90506000606673592b84710955c9561008d137a5403e1dd9a222d86382981718909185609b60009054906101000a9004600160a060020a0316600160a060020a0316631f1cb62b6040518163ffffffff1660e060020a02815260040160206040518083038186803b15801561083f57600080fd5b505afa158015610853573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108779190810190612fb4565b866040518563ffffffff1660e060020a02815260040161089a9493929190613443565b60206040518083038186803b1580156108b257600080fd5b505af41580156108c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108ea9190810190612fb4565b60a1546040517f3debd2d8000000000000000000000000000000000000000000000000000000008152919250600160a060020a031690633debd2d89061093690899085906004016132c8565b602060405180830381600087803b15801561095057600080fd5b505af1158015610964573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109889190810190612f78565b15610a6957609f546040517f9dc29fac000000000000000000000000000000000000000000000000000000008152600160a060020a0390911690639dc29fac906109d8908a9087906004016132c8565b600060405180830381600087803b1580156109f257600080fd5b505af1158015610a06573d6000803e3d6000fd5b5050505086600160a060020a03167f16922e9a6cbcce4767d759c44585dd5644eb4b70adda075f4db974c6fe24bc1f84836000866000806000806000604051610a5799989796959493929190613479565b60405180910390a29350610a71915050565b600094505050505b5092915050565b7f583200000000000000000000000000000000000000000000000000000000000081565b60335460405160e060020a633af32abf02815260009182918291829182913391600160a060020a0390911690633af32abf90610adc9084906004016132ba565b60206040518083038186803b158015610af457600080fd5b505afa158015610b08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b2c9190810190612f78565b610b4b5760405160e560020a62461bcd0281526004016102c1906133bd565b610b53612d6c565b881561115157609b54604080517f8300df490000000000000000000000000000000000000000000000000000000081529051600092600160a060020a031691638300df49916004808301926020929190829003018186803b158015610bb757600080fd5b505afa158015610bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610bef9190810190612fb4565b6040517f6108a7ef00000000000000000000000000000000000000000000000000000000815290915073592b84710955c9561008d137a5403e1dd9a222d890636108a7ef90610c47906066908e90869060040161341b565b60206040518083038186803b158015610c5f57600080fd5b505af4158015610c73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c979190810190612fb4565b808352609b54604080517f133374bd0000000000000000000000000000000000000000000000000000000081529051610d379392600160a060020a03169163133374bd916004808301926020929190829003018186803b158015610cfa57600080fd5b505afa158015610d0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d329190810190612fb4565b61252d565b60208301819052825114610e6957606673592b84710955c9561008d137a5403e1dd9a222d8638298171890918460200151609b60009054906101000a9004600160a060020a0316600160a060020a0316631f1cb62b6040518163ffffffff1660e060020a02815260040160206040518083038186803b158015610db957600080fd5b505afa158015610dcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610df19190810190612fb4565b856040518563ffffffff1660e060020a028152600401610e149493929190613443565b60206040518083038186803b158015610e2c57600080fd5b505af4158015610e40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e649190810190612fb4565b610e6b565b895b604080840191909152609f54602084015191517f40c10f19000000000000000000000000000000000000000000000000000000008152600160a060020a03909116916340c10f1991610ec1918f916004016132c8565b602060405180830381600087803b158015610edb57600080fd5b505af1158015610eef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610f139190810190612f78565b50609d54604080840151602085015191517fab9757c0000000000000000000000000000000000000000000000000000000008152600160a060020a039093169263ab9757c092610f759260f460020a610433029290919060009060040161334a565b600060405180830381600087803b158015610f8f57600080fd5b505af1158015610fa3573d6000803e3d6000fd5b50505050610faf612d3e565b600160a060020a03808d16825260408085015160208085019190915260a05482517f64f9c31f00000000000000000000000000000000000000000000000000000000815292519316926364f9c31f926004808201939291829003018186803b15801561101a57600080fd5b505afa15801561102e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110529190810190612fd2565b60ff1660408083019190915260a05481517f960abe610000000000000000000000000000000000000000000000000000000081529151600160a060020a039091169163960abe61916004808301926020929190829003018186803b1580156110b957600080fd5b505afa1580156110cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110f19190810190612fd2565b60ff166060820152600160a060020a038a16608082015261111181611169565b60608401526111218c848c612543565b5050604081015160609091015180516020820151608083015160a0909301519399509097509550935091506105d7565b506000998a9950899850889750879650945050505050565b611171612d90565b609b60009054906101000a9004600160a060020a0316600160a060020a0316638300df496040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156111c257600080fd5b505afa1580156111d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111fa9190810190612fb4565b604080830191909152609b5481517f9a80d4210000000000000000000000000000000000000000000000000000000081529151600160a060020a0390911691639a80d421916004808301926020929190829003018186803b15801561125e57600080fd5b505afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112969190810190612fb4565b606082015260408101516112bf5760405160e560020a62461bcd0281526004016102c19061339d565b60008160600151116112e65760405160e560020a62461bcd0281526004016102c19061338d565b60a054608083015160208401516040517f0e20ead1000000000000000000000000000000000000000000000000000000008152600093600160a060020a031692630e20ead192611338926004016132c8565b60206040518083038186803b15801561135057600080fd5b505afa158015611364573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113889190810190612fb4565b835160a15491925060009182916113a791600160a060020a0316611ac6565b9150915080600014806113b8575081155b1561146e5760a054602086015160608701516040517fb978cff3000000000000000000000000000000000000000000000000000000008152600160a060020a039093169263b978cff392611410929091600401613658565b60206040518083038186803b15801561142857600080fd5b505afa15801561143c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114609190810190612fb4565b845250506080820152611665565b60a054602086015160408088015190517fb978cff3000000000000000000000000000000000000000000000000000000008152600093600160a060020a03169263b978cff3926114c092600401613658565b60206040518083038186803b1580156114d857600080fd5b505afa1580156114ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115109190810190612fb4565b905061153d85606001516115318388604001516125be90919063ffffffff16565b9063ffffffff6125fb16565b6020860152606085015160408601516115619190611531908763ffffffff6125be16565b60a086018190526020860151600091611580919063ffffffff61235616565b90508084101580156115925750808310155b158061159c575081155b1561165f576000602080880182905260a08089019290925290549088015160608901516040517fb978cff3000000000000000000000000000000000000000000000000000000008152600160a060020a039093169263b978cff392611605929091600401613658565b60206040518083038186803b15801561161d57600080fd5b505afa158015611631573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116559190810190612fb4565b8652608086018590525b50505050505b919050565b603354600160a060020a031681565b60335460405160e060020a633af32abf02815260009182918291829182913391600160a060020a0390911690633af32abf906116b99084906004016132ba565b60206040518083038186803b1580156116d157600080fd5b505afa1580156116e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117099190810190612f78565b6117285760405160e560020a62461bcd0281526004016102c1906133bd565b6000881161174557600095508594508493508392508291506105d7565b61174d612d6c565b61183989610d32609b60009054906101000a9004600160a060020a0316600160a060020a031663a8ba1d186040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156117a557600080fd5b505afa1580156117b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117dd9190810190612fb4565b609f60009054906101000a9004600160a060020a0316600160a060020a03166370a082318f6040518263ffffffff1660e060020a02815260040161182191906132ba565b60206040518083038186803b158015610cfa57600080fd5b808252609b546040517f408d3aad000000000000000000000000000000000000000000000000000000008152600092600160a060020a039092169163408d3aad9161188791906004016132fe565b60206040518083038186803b15801561189f57600080fd5b505afa1580156118b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118d79190810190612fb4565b6020830181905290506118e8612d3e565b600160a060020a03808d1682526020808501518184015260a054604080517f72690459000000000000000000000000000000000000000000000000000000008152905191909316926372690459926004808301939192829003018186803b15801561195257600080fd5b505afa158015611966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061198a9190810190612fd2565b60ff1660408083019190915260a05481517fbfac83c20000000000000000000000000000000000000000000000000000000081529151600160a060020a039091169163bfac83c2916004808301926020929190829003018186803b1580156119f157600080fd5b505afa158015611a05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a299190810190612fd2565b60ff166060820152600160a060020a038a166080820152611a4981611169565b60608401528251611a5c908d9084612633565b611a678c848c61273f565b6060830151608081015190516020850151611a999291611a8d919063ffffffff61232616565b9063ffffffff61232616565b60609093015180516020820151608083015160a090930151959b50909950975095509193506105d7915050565b609b54604080517f7f13cb06000000000000000000000000000000000000000000000000000000008152905160009283928392600160a060020a0390921691637f13cb0691600480820192602092909190829003018186803b158015611b2b57600080fd5b505afa158015611b3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b639190810190612edd565b9050600160a060020a03811615611ca6576040517f70a08231000000000000000000000000000000000000000000000000000000008152600160a060020a038216906370a0823190611bb99088906004016132ba565b60206040518083038186803b158015611bd157600080fd5b505afa158015611be5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611c099190810190612fb4565b6040517fdd62ed3e000000000000000000000000000000000000000000000000000000008152909350600160a060020a0382169063dd62ed3e90611c5390889088906004016132e3565b60206040518083038186803b158015611c6b57600080fd5b505afa158015611c7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611ca39190810190612fb4565b91505b509250929050565b600054610100900460ff1680611cc75750611cc76127b0565b80611cd5575060005460ff16155b611cf45760405160e560020a62461bcd0281526004016102c1906133fd565b600054610100900460ff16158015611d1f576000805460ff1961ff0019909116610100171660011790555b611d276127b6565b611d30826127e9565b611d3861288a565b8015611d4a576000805461ff00191690555b5050565b60335460405160e060020a633af32abf02815260009182918291829182913391600160a060020a0390911690633af32abf90611d8e9084906004016132ba565b60206040518083038186803b158015611da657600080fd5b505afa158015611dba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611dde9190810190612f78565b611dfd5760405160e560020a62461bcd0281526004016102c1906133bd565b611e05612dc6565b609e546040517f70a08231000000000000000000000000000000000000000000000000000000008152600091600160a060020a0316906370a0823190611e4f908e906004016132ba565b60206040518083038186803b158015611e6757600080fd5b505afa158015611e7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611e9f9190810190612fb4565b90506000611ead8b8361252d565b9050611f0481609b60009054906101000a9004600160a060020a0316600160a060020a031663fa8ba4906040518163ffffffff1660e060020a02815260040160206040518083038186803b158015610cfa57600080fd5b808452609b54604080517f08c36d9e000000000000000000000000000000000000000000000000000000008152905160009373592b84710955c9561008d137a5403e1dd9a222d893636ef454cf93606693600160a060020a03909216916308c36d9e91600480820192602092909190829003018186803b158015611f8757600080fd5b505afa158015611f9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611fbf9190810190612fb4565b6040518463ffffffff1660e060020a028152600401611fe09392919061341b565b60206040518083038186803b158015611ff857600080fd5b505af415801561200c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506120309190810190612fb4565b905061203a612d3e565b600160a060020a03808f168252602080830184905260a054604080517f1cabe3bf00000000000000000000000000000000000000000000000000000000815290519190931692631cabe3bf926004808301939192829003018186803b1580156120a257600080fd5b505afa1580156120b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506120da9190810190612fd2565b60ff1660408083019190915260a05481517f691e7d900000000000000000000000000000000000000000000000000000000081529151600160a060020a039091169163691e7d90916004808301926020929190829003018186803b15801561214157600080fd5b505afa158015612155573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506121799190810190612fd2565b60ff166060820152600160a060020a038c16608082015261219981611169565b8560400181905250609e60009054906101000a9004600160a060020a0316600160a060020a0316639dc29fac8f87600001516040518363ffffffff1660e060020a0281526004016121eb9291906132c8565b600060405180830381600087803b15801561220557600080fd5b505af1158015612219573d6000803e3d6000fd5b5050609d5487516040517f119e2ad6000000000000000000000000000000000000000000000000000000008152600160a060020a03909216935063119e2ad692506122769160f460020a610433029187916000919060040161330c565b600060405180830381600087803b15801561229057600080fd5b505af11580156122a4573d6000803e3d6000fd5b5050506040860151608081015190516122c99250611a8d90859063ffffffff61232616565b60208601526122d98e868e612c87565b50505050602081810151604090920151805191810151608082015160a090920151939d929c509a509850909650945050505050565b60f460020a6104330281565b60675490565b60685490565b60008282111561234b5760405160e560020a62461bcd0281526004016102c1906133cd565b508082035b92915050565b60008282018381101561237e5760405160e560020a62461bcd0281526004016102c1906133ad565b9392505050565b609e5460c08301516040517f40c10f19000000000000000000000000000000000000000000000000000000008152600160a060020a03909216916340c10f19916123d4918891906004016132c8565b602060405180830381600087803b1580156123ee57600080fd5b505af1158015612402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124269190810190612f78565b50609d5460c08301516040517fab9757c0000000000000000000000000000000000000000000000000000000008152600160a060020a039092169163ab9757c0916124839160f460020a610433029188916000919060040161330c565b600060405180830381600087803b15801561249d57600080fd5b505af11580156124b1573d6000803e3d6000fd5b50505060c083015160e0840151805160408083015160208401516060850151608086015160a0909601519351600160a060020a038d1698507f95edf7037d7a5b55fc522aa5b9e90d56fa4d260db85134e27b7d90cb060ae2149761251f9790968d9690959493928c906135e0565b60405180910390a250505050565b600081831061253c578161237e565b5090919050565b6020808301516040808501516060808701518051818501519682015192820151608083015160a0909301519551600160a060020a038c16987f76ca2c798b889609c917b5182a786a588c12d26e23239692ec9f26d5a793b9e7986125b1989097969495919493928c906135e0565b60405180910390a2505050565b6000826125cd57506000612350565b828202828482816125da57fe5b041461237e5760405160e560020a62461bcd0281526004016102c1906133ed565b600080821161261f5760405160e560020a62461bcd0281526004016102c1906133dd565b600082848161262a57fe5b04949350505050565b609f546040517f9dc29fac000000000000000000000000000000000000000000000000000000008152600160a060020a0390911690639dc29fac9061267e90869086906004016132c8565b600060405180830381600087803b15801561269857600080fd5b505af11580156126ac573d6000803e3d6000fd5b5050609d546040517f119e2ad6000000000000000000000000000000000000000000000000000000008152600160a060020a03909116925063119e2ad691506127089060f460020a61043302908590879060009060040161334a565b600060405180830381600087803b15801561272257600080fd5b505af1158015612736573d6000803e3d6000fd5b50505050505050565b815160208084015160608086015180516040808301519583015193830151608084015160a0909401519151600160a060020a038c16987fc20403d07f634f7fe3f9b2a1602b210f43bf3954955fe06a18dbe71cd765a3b6986125b19891979196600095919492939091908d906134ff565b303b1590565b60408051606081018252670de0b6b3a7640000808252600160208301819052919092018290526066829055606755606855565b600054610100900460ff168061280257506128026127b0565b80612810575060005460ff16155b61282f5760405160e560020a62461bcd0281526004016102c1906133fd565b600054610100900460ff1615801561285a576000805460ff1961ff0019909116610100171660011790555b60338054600160a060020a031916600160a060020a0384161790558015611d4a576000805461ff00191690555050565b603360009054906101000a9004600160a060020a0316600160a060020a031663534282536040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156128db57600080fd5b505afa1580156128ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506129139190810190612edd565b60a18054600160a060020a031916600160a060020a03928316179055603354604080517f99c6fe73000000000000000000000000000000000000000000000000000000008152905191909216916399c6fe73916004808301926020929190829003018186803b15801561298557600080fd5b505afa158015612999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506129bd9190810190612edd565b609f8054600160a060020a031916600160a060020a03928316179055603354604080517fd31cc8310000000000000000000000000000000000000000000000000000000081529051919092169163d31cc831916004808301926020929190829003018186803b158015612a2f57600080fd5b505afa158015612a43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a679190810190612edd565b609e8054600160a060020a031916600160a060020a03928316179055603354604080517f955b570a0000000000000000000000000000000000000000000000000000000081529051919092169163955b570a916004808301926020929190829003018186803b158015612ad957600080fd5b505afa158015612aed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612b119190810190612edd565b609d8054600160a060020a031916600160a060020a03928316179055603354604080517f12529f1f000000000000000000000000000000000000000000000000000000008152905191909216916312529f1f916004808301926020929190829003018186803b158015612b8357600080fd5b505afa158015612b97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612bbb9190810190612edd565b609b8054600160a060020a031916600160a060020a03928316179055603354604080517fffb691300000000000000000000000000000000000000000000000000000000081529051919092169163ffb69130916004808301926020929190829003018186803b158015612c2d57600080fd5b505afa158015612c41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612c659190810190612edd565b60a08054600160a060020a031916600160a060020a0392909216919091179055565b8151602080840151604080860151805181830151948201516060830151608084015160a0909401519451600160a060020a038c16987fb68ac1b7654fd8a98182c5df375de6fb43e94a616e123ed82e2b87955a673934986125b19891979196909493929091908c906135e0565b60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001612d39612d90565b905290565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040518060800160405280600081526020016000815260200160008152602001612d395b6040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180606001604052806000815260200160008152602001612d39612d90565b8035612350816136e5565b8051612350816136e5565b8051612350816136fc565b600060a08284031215612e1a57600080fd5b612e2460a0613673565b90506000612e328484612de7565b8252506020612e4384848301612e8b565b6020830152506040612e5784828501612ea1565b6040830152506060612e6b84828501612ea1565b6060830152506080612e7f84828501612de7565b60808301525092915050565b803561235081613705565b805161235081613705565b80356123508161370e565b80516123508161370e565b600060208284031215612ec957600080fd5b6000612ed58484612de7565b949350505050565b600060208284031215612eef57600080fd5b6000612ed58484612df2565b60008060408385031215612f0e57600080fd5b6000612f1a8585612de7565b9250506020611ca385828601612de7565b600080600060608486031215612f4057600080fd5b6000612f4c8686612de7565b9350506020612f5d86828701612e8b565b9250506040612f6e86828701612de7565b9150509250925092565b600060208284031215612f8a57600080fd5b6000612ed58484612dfd565b600060a08284031215612fa857600080fd5b6000612ed58484612e08565b600060208284031215612fc657600080fd5b6000612ed58484612e96565b600060208284031215612fe457600080fd5b6000612ed58484612eac565b612ff9816136c8565b82525050565b612ff9816136a3565b612ff9816136b3565b612ff9816136cf565b612ff9816136da565b6000613030600e8361369a565b7f4d6f43207072696365207a65726f000000000000000000000000000000000000815260200192915050565b6000613069600e8361369a565b7f425443207072696365207a65726f000000000000000000000000000000000000815260200192915050565b60006130a2601b8361369a565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b60006130db601a8361369a565b7f41646472657373206973206e6f742077686974656c6973746564000000000000815260200192915050565b6000613114601e8361369a565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b600061314d601a8361369a565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b600061318660218361369a565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f81527f7700000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b60006131e5602e8361369a565b7f436f6e747261637420696e7374616e63652068617320616c726561647920626581527f656e20696e697469616c697a6564000000000000000000000000000000000000602082015260400192915050565b805160c08301906132488482613008565b50602082015161325b6020850182613008565b50604082015161326e6040850182613008565b5060608201516132816060850182613008565b5060808201516132946080850182613008565b5060a08201516132a760a0850182613008565b50505050565b9052565b612ff9816136c2565b602081016123508284612fff565b604081016132d68285612fff565b61237e6020830184613008565b604081016132f18285612fff565b61237e6020830184612fff565b602081016123508284613008565b6080810161331a8287613008565b6133276020830186613008565b613334604083018561301a565b6133416060830184613008565b95945050505050565b608081016133588287613008565b6133656020830186613008565b6133726040830185613008565b613341606083018461301a565b602081016123508284613011565b6020808252810161235081613023565b602080825281016123508161305c565b6020808252810161235081613095565b60208082528101612350816130ce565b6020808252810161235081613107565b6020808252810161235081613140565b6020808252810161235081613179565b60208082528101612350816131d8565b60c081016123508284613237565b6060810161342982866132ad565b6134366020830185613008565b612ed56040830184613008565b6080810161345182876132ad565b61345e6020830186613008565b6133346040830185613008565b604081016132d68285613008565b6101208101613488828c613008565b613495602083018b613008565b6134a2604083018a61301a565b6134af6060830189613008565b6134bc608083018861301a565b6134c960a083018761301a565b6134d660c083018661301a565b6134e360e083018561301a565b6134f1610100830184612ff0565b9a9950505050505050505050565b610140810161350e828d613008565b61351b602083018c613008565b613528604083018b613008565b613535606083018a61301a565b6135426080830189613008565b61354f60a0830188613008565b61355c60c0830187613008565b61356960e0830186613008565b613577610100830185613008565b613585610120830184612fff565b9b9a5050505050505050505050565b60a081016135a28288613008565b6135af6020830187613008565b6135bc6040830186613008565b6135c96060830185613008565b6135d66080830184613008565b9695505050505050565b61012081016135ef828c613008565b6135fc602083018b613008565b613609604083018a613008565b6136166060830189613008565b6136236080830188613008565b61363060a0830187613008565b61363d60c0830186613008565b61364a60e0830185613008565b6134f1610100830184612fff565b604081016136668285613008565b61237e60208301846132b1565b60405181810167ffffffffffffffff8111828210171561369257600080fd5b604052919050565b90815260200190565b6000612350826136b6565b151590565b90565b600160a060020a031690565b60ff1690565b6000612350825b6000612350826136a3565b6000612350826136b3565b6136ee816136a3565b81146136f957600080fd5b50565b6136ee816136ae565b6136ee816136b3565b6136ee816136c256fea365627a7a72315820ca73216f72b64443434bfca063c9cd172cceba4fb19e6a958e694eb2db235b026c6578706572696d656e74616cf564736f6c63430005110040","source_code":"pragma solidity ^0.5.8;\npragma experimental ABIEncoderV2;\n\nimport \"./MoCLibConnection.sol\";\nimport \"./token/BProToken.sol\";\nimport \"./token/DocToken.sol\";\nimport \"./interface/IMoCInrate.sol\";\nimport \"./base/MoCBase.sol\";\nimport \"./token/MoCToken.sol\";\nimport \"./MoCBProxManager.sol\";\nimport \"openzeppelin-solidity/contracts/math/Math.sol\";\nimport \"./interface/IMoC.sol\";\nimport \"./interface/IMoCExchange.sol\";\nimport \"./interface/IMoCState.sol\";\n\ncontract MoCExchangeEvents {\n  event RiskProMint(\n    address indexed account,\n    uint256 amount,\n    uint256 reserveTotal,\n    uint256 commission,\n    uint256 reservePrice,\n    uint256 mocCommissionValue,\n    uint256 mocPrice,\n    uint256 btcMarkup,\n    uint256 mocMarkup,\n    address vendorAccount\n  );\n  // Kept for ABI/backward compatibility, discount mint path is disabled.\n  event RiskProWithDiscountMint(\n    uint256 riskProTecPrice,\n    uint256 riskProDiscountPrice,\n    uint256 amount\n  );\n  event RiskProRedeem(\n    address indexed account,\n    uint256 amount,\n    uint256 reserveTotal,\n    uint256 commission,\n    uint256 reservePrice,\n    uint256 mocCommissionValue,\n    uint256 mocPrice,\n    uint256 btcMarkup,\n    uint256 mocMarkup,\n    address vendorAccount\n  );\n  event StableTokenMint(\n    address indexed account,\n    uint256 amount,\n    uint256 reserveTotal,\n    uint256 commission,\n    uint256 reservePrice,\n    uint256 mocCommissionValue,\n    uint256 mocPrice,\n    uint256 btcMarkup,\n    uint256 mocMarkup,\n    address vendorAccount\n  );\n  event StableTokenRedeem(\n    address indexed account,\n    uint256 amount,\n    uint256 reserveTotal,\n    uint256 commission,\n    uint256 reservePrice,\n    uint256 mocCommissionValue,\n    uint256 mocPrice,\n    uint256 btcMarkup,\n    uint256 mocMarkup,\n    address vendorAccount\n  );\n  event FreeStableTokenRedeem(\n    address indexed account,\n    uint256 amount,\n    uint256 reserveTotal,\n    uint256 commission,\n    uint256 interests,\n    uint256 reservePrice,\n    uint256 mocCommissionValue,\n    uint256 mocPrice,\n    uint256 btcMarkup,\n    uint256 mocMarkup,\n    address vendorAccount\n  );\n}\n\n\ncontract MoCExchange is MoCExchangeEvents, MoCBase, MoCLibConnection, IMoCExchange {\n  using Math for uint256;\n  using SafeMath for uint256;\n\n  // Contracts\n  IMoCState internal mocState;\n  /** DEPRECATED **/\n  // solium-disable-next-line mixedcase\n  address internal DEPRECATED_mocConverter;\n  MoCBProxManager internal bproxManager;\n  BProToken internal bproToken;\n  DocToken internal docToken;\n  IMoCInrate internal mocInrate;\n  IMoC internal moc;\n\n  /**\n    @dev Initializes the contract\n    @param connectorAddress MoCConnector contract address\n  */\n  function initialize(address connectorAddress) public initializer {\n    initializePrecisions();\n    initializeBase(connectorAddress);\n    initializeContracts();\n  }\n\n  /************************************/\n  /***** UPGRADE v0110      ***********/\n  /************************************/\n\n  /** START UPDATE V0112: 24/09/2020  **/\n  /** Upgrade to support multiple commission rates **/\n  /** Public functions **/\n\n  /**\n   @dev Converts MoC commission from RBTC to MoC price\n   @param owner address of token owner\n   @param spender address of token spender\n   @return MoC balance of owner and MoC allowance of spender\n  */\n  function getMoCTokenBalance(address owner, address spender) public view\n  returns (uint256 mocBalance, uint256 mocAllowance) {\n    mocBalance = 0;\n    mocAllowance = 0;\n\n    MoCToken mocToken = MoCToken(mocState.getMoCToken());\n\n    if (address(mocToken) != address(0)) {\n      // Get balance and allowance from sender\n      mocBalance = mocToken.balanceOf(owner);\n      mocAllowance = mocToken.allowance(owner, spender);\n    }\n\n    return (mocBalance, mocAllowance);\n  }\n\n  /**\n   @dev Calculates commissions in MoC and BTC\n   @param params Params defined in CommissionParamsStruct\n   @return Commissions calculated in MoC price and bitcoin price; and Bitcoin and MoC prices\n  */\n  function calculateCommissionsWithPrices(CommissionParamsStruct memory params)\n  public view\n  returns (CommissionReturnStruct memory ret) {\n    ret.btcPrice = mocState.getBitcoinPrice();\n    ret.mocPrice = mocState.getMoCPrice();\n    require(ret.btcPrice > 0, \"BTC price zero\");\n    require(ret.mocPrice > 0, \"MoC price zero\");\n    // Calculate vendor markup\n    uint256 btcMarkup = mocInrate.calculateVendorMarkup(params.vendorAccount, params.amount);\n\n    // Get balance and allowance from sender\n    (uint256 mocBalance, uint256 mocAllowance) = getMoCTokenBalance(params.account, address(moc));\n    if (mocAllowance == 0 || mocBalance == 0) {\n      // Check commission rate in RBTC according to transaction type\n      ret.btcCommission = mocInrate.calcCommissionValue(params.amount, params.txTypeFeesRBTC);\n      ret.btcMarkup = btcMarkup;\n      return ret;\n      // Implicitly mocCommission = 0 and mocMarkup = 0\n    }\n\n    // Check commission rate in MoC according to transaction type\n    uint256 mocCommissionInBtc = mocInrate.calcCommissionValue(params.amount, params.txTypeFeesMOC);\n\n    // Calculate amount in MoC\n    ret.mocCommission = ret.btcPrice.mul(mocCommissionInBtc).div(ret.mocPrice);\n    // Implicitly btcCommission = 0\n    ret.mocMarkup = ret.btcPrice.mul(btcMarkup).div(ret.mocPrice);\n    // Implicitly btcMarkup = 0\n\n    uint256 totalMoCFee = ret.mocCommission.add(ret.mocMarkup);\n\n    // Check if there is enough balance of MoC\n    if ((!(mocBalance >= totalMoCFee && mocAllowance >= totalMoCFee)) || (mocCommissionInBtc == 0)) {\n      // Insufficient funds\n      ret.mocCommission = 0;\n      ret.mocMarkup = 0;\n\n      // Check commission rate in RBTC according to transaction type\n      ret.btcCommission = mocInrate.calcCommissionValue(params.amount, params.txTypeFeesRBTC);\n      ret.btcMarkup = btcMarkup;\n    }\n\n    return ret;\n  }\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  /**\n   @dev Mint BPros and give it to the msg.sender\n   @param account Address of minter\n   @param btcAmount Amount in BTC to mint\n   @param vendorAccount Vendor address\n  */\n  function mintBPro(address account, uint256 btcAmount, address vendorAccount)\n    external\n    onlyWhitelisted(msg.sender)\n    returns (uint256, uint256, uint256, uint256, uint256)\n  {\n    RiskProMintStruct memory details;\n\n    details.bproRegularPrice = mocState.bproTecPrice();\n    details.finalBProAmount = 0;\n    details.btcValue = 0;\n\n    if (btcAmount != details.btcValue) {\n      // Converts BTC to BPro\n      details.regularBProAmount = mocLibConfig.maxBProWithBtc(\n        btcAmount.sub(details.btcValue),\n        details.bproRegularPrice\n      );\n      details.finalBProAmount = details.finalBProAmount.add(details.regularBProAmount);\n    }\n\n    /** UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n    CommissionParamsStruct memory params;\n    params.account = account;\n    params.amount = btcAmount;\n    params.txTypeFeesMOC = mocInrate.MINT_BPRO_FEES_MOC();\n    params.txTypeFeesRBTC = mocInrate.MINT_BPRO_FEES_RBTC();\n    params.vendorAccount = vendorAccount;\n\n    (details.commission) = calculateCommissionsWithPrices(params);\n\n    mintBProInternal(account, btcAmount, details, vendorAccount);\n\n    return (\n      btcAmount,\n      details.commission.btcCommission,\n      details.commission.mocCommission,\n      details.commission.btcMarkup,\n      details.commission.mocMarkup\n    );\n    /** END UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n  }\n\n  /**\n   @dev Sender burns his BProS and redeems the equivalent BTCs\n   @param account Address of the redeeemer\n   @param bproAmount Amount of BPros to be redeemed\n   @param vendorAccount Vendor address\n   @return bitcoins to transfer to the redeemer and commission spent (in BTC and MoC), using [using reservePrecision]\n  */\n  function redeemBPro(address account, uint256 bproAmount, address vendorAccount)\n    public\n    onlyWhitelisted(msg.sender)\n    returns (uint256, uint256, uint256, uint256, uint256)\n  {\n    RiskProRedeemStruct memory details;\n\n    uint256 userBalance = bproToken.balanceOf(account);\n    uint256 userAmount = Math.min(bproAmount, userBalance);\n\n    details.bproFinalAmount = Math.min(userAmount, mocState.absoluteMaxBPro());\n    uint256 totalBtc = mocLibConfig.totalBProInBtc(details.bproFinalAmount, mocState.bproTecPrice());\n\n    /** UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n    CommissionParamsStruct memory params;\n    params.account = account;\n    params.amount = totalBtc;\n    params.txTypeFeesMOC = mocInrate.REDEEM_BPRO_FEES_MOC();\n    params.txTypeFeesRBTC = mocInrate.REDEEM_BPRO_FEES_RBTC();\n    params.vendorAccount = vendorAccount;\n\n    (details.commission) = calculateCommissionsWithPrices(params);\n    /** END UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n\n    // Mint token\n    bproToken.burn(account, details.bproFinalAmount);\n\n    // Update Buckets\n    bproxManager.substractValuesFromBucket(\n      BUCKET_C0,\n      totalBtc,\n      0,\n      details.bproFinalAmount\n    );\n\n    details.btcTotalWithoutCommission = totalBtc.sub(details.commission.btcCommission).sub(details.commission.btcMarkup);\n\n    redeemBProInternal(account, details, vendorAccount);\n\n    return (\n      details.btcTotalWithoutCommission,\n      details.commission.btcCommission,\n      details.commission.mocCommission,\n      details.commission.btcMarkup,\n      details.commission.mocMarkup\n    );\n  }\n\n  /**\n   @dev Redeems the requested amount for the account, or the max amount of free docs possible.\n   @param account Address of the redeeemer\n   @param docAmount Amount of Docs to redeem [using mocPrecision]\n   @param vendorAccount Vendor address\n   @return bitcoins to transfer to the redeemer and commission spent (in BTC and MoC), using [using reservePrecision]\n  */\n  function redeemFreeDoc(address account, uint256 docAmount, address vendorAccount)\n    public\n    onlyWhitelisted(msg.sender)\n    returns (uint256, uint256, uint256, uint256, uint256)\n  {\n    if (docAmount <= 0) {\n      return (0, 0, 0, 0, 0);\n    } else {\n      FreeStableTokenRedeemStruct memory details;\n      details.finalDocAmount = Math.min(\n        docAmount,\n        Math.min(mocState.freeDoc(), docToken.balanceOf(account))\n      );\n      uint256 docsBtcValue = mocState.docsToBtc(details.finalDocAmount);\n\n      details.finalBtcAmount = docsBtcValue;\n\n      /** UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n      CommissionParamsStruct memory params;\n      params.account = account;\n      params.amount = details.finalBtcAmount;\n      params.txTypeFeesMOC = mocInrate.REDEEM_DOC_FEES_MOC();\n      params.txTypeFeesRBTC = mocInrate.REDEEM_DOC_FEES_RBTC();\n      params.vendorAccount = vendorAccount;\n\n      (details.commission) = calculateCommissionsWithPrices(params);\n\n      /** END UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n\n      doDocRedeem(account, details.finalDocAmount, docsBtcValue);\n\n      redeemFreeDocInternal(account, details, vendorAccount);\n\n      return (details.finalBtcAmount.sub(details.commission.btcCommission).sub(details.commission.btcMarkup), details.commission.btcCommission, details.commission.mocCommission, details.commission.btcMarkup, details.commission.mocMarkup);\n    }\n  }\n\n  /**\n   @dev Mint Max amount of Docs and give it to the msg.sender\n   @param account minter user address\n   @param btcToMint btc amount the user intents to convert to DoC [using rbtPresicion]\n   @param vendorAccount Vendor address\n   @return the actual amount of btc used and the btc commission (in BTC and MoC) for them [using rbtPresicion]\n  */\n  function mintDoc(address account, uint256 btcToMint, address vendorAccount)\n    public\n    onlyWhitelisted(msg.sender)\n    returns (uint256, uint256, uint256, uint256, uint256)\n  {\n    StableTokenMintStruct memory details;\n\n    // Docs to issue with tx value amount\n    if (btcToMint > 0) {\n      uint256 btcPrice = mocState.getBitcoinPrice();\n      details.docs = mocLibConfig.maxDocsWithBtc(btcToMint, btcPrice); //btc to doc\n      details.docAmount = Math.min(details.docs, mocState.absoluteMaxDoc());\n      details.totalCost = details.docAmount == details.docs\n        ? btcToMint\n        : mocLibConfig.docsBtcValue(details.docAmount, mocState.peg(), btcPrice); //docs to btc\n\n      // Mint Token\n      docToken.mint(account, details.docAmount);\n\n      // Update Buckets\n      bproxManager.addValuesToBucket(BUCKET_C0, details.totalCost, details.docAmount, 0);\n\n      /** UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n      CommissionParamsStruct memory params;\n      params.account = account;\n      params.amount = details.totalCost;\n      params.txTypeFeesMOC = mocInrate.MINT_DOC_FEES_MOC();\n      params.txTypeFeesRBTC = mocInrate.MINT_DOC_FEES_RBTC();\n      params.vendorAccount = vendorAccount;\n\n      (details.commission) = calculateCommissionsWithPrices(params);\n\n      mintDocInternal(account, details, vendorAccount);\n\n      /** END UPDATE V0112: 24/09/2020 - Upgrade to support multiple commission rates **/\n\n      return (details.totalCost, details.commission.btcCommission, details.commission.mocCommission, details.commission.btcMarkup, details.commission.mocMarkup);\n    }\n\n    return (0, 0, 0, 0, 0);\n  }\n\n  /**\n   @dev Allow redeem on liquidation state, user DoCs get burned and he receives\n   the equivalent RBTCs according to liquidationPrice\n   @param origin address owner of the DoCs\n   @param destination address to send the RBTC\n   @return The amount of RBTC in sent for the redemption or 0 if send does not succed\n  */\n  function redeemAllDoc(address origin, address payable destination)\n    public\n    onlyWhitelisted(msg.sender)\n    returns (uint256)\n  {\n    uint256 userDocBalance = docToken.balanceOf(origin);\n    if (userDocBalance == 0) return 0;\n\n    uint256 liqPrice = mocState.getLiquidationPrice();\n    // [USD * RBTC / USD]\n    uint256 totalRbtc = mocLibConfig.docsBtcValue(userDocBalance, mocState.peg(), liqPrice); //docs to btc\n\n    // If send fails we don't burn the tokens\n    if (moc.sendToAddress(destination, totalRbtc)) {\n      docToken.burn(origin, userDocBalance);\n      emit StableTokenRedeem(\n        origin,\n        userDocBalance,\n        totalRbtc,\n        0,\n        liqPrice,\n        0,\n        0,\n        0,\n        0,\n        address(0)\n      );\n\n      return totalRbtc;\n    } else {\n      return 0;\n    }\n  }\n\n  /**\n   @dev Internal function to avoid stack too deep errors\n  */\n  function mintBProInternal(address account, uint256 btcAmount, RiskProMintStruct memory details, address vendorAccount) internal {\n    bproToken.mint(account, details.finalBProAmount);\n    bproxManager.addValuesToBucket(BUCKET_C0, btcAmount, 0, details.finalBProAmount);\n\n    emit RiskProMint(\n      account,\n      details.finalBProAmount,\n      btcAmount,\n      details.commission.btcCommission,\n      details.commission.btcPrice,\n      details.commission.mocCommission,\n      details.commission.mocPrice,\n      details.commission.btcMarkup,\n      details.commission.mocMarkup,\n      vendorAccount\n    );\n  }\n\n  /**\n   @dev Internal function to avoid stack too deep errors\n  */\n  function mintDocInternal(address account, StableTokenMintStruct memory details, address vendorAccount) internal {\n    emit StableTokenMint(\n      account,\n      details.docAmount,\n      details.totalCost,\n      details.commission.btcCommission,\n      details.commission.btcPrice,\n      details.commission.mocCommission,\n      details.commission.mocPrice,\n      details.commission.btcMarkup,\n      details.commission.mocMarkup,\n      vendorAccount\n    );\n  }\n\n  /**\n   @dev Internal function to avoid stack too deep errors\n  */\n  function redeemFreeDocInternal(address account, FreeStableTokenRedeemStruct memory details, address vendorAccount) internal {\n    emit FreeStableTokenRedeem(\n      account,\n      details.finalDocAmount,\n      details.finalBtcAmount,\n      details.commission.btcCommission,\n      0,\n      details.commission.btcPrice,\n      details.commission.mocCommission,\n      details.commission.mocPrice,\n      details.commission.btcMarkup,\n      details.commission.mocMarkup,\n      vendorAccount\n    );\n  }\n\n  /**\n   @dev Internal function to avoid stack too deep errors\n  */\n  function redeemBProInternal(address account, RiskProRedeemStruct memory details, address vendorAccount) internal {\n    emit RiskProRedeem(\n      account,\n      details.bproFinalAmount,\n      details.btcTotalWithoutCommission,\n      details.commission.btcCommission,\n      details.commission.btcPrice,\n      details.commission.mocCommission,\n      details.commission.mocPrice,\n      details.commission.btcMarkup,\n      details.commission.mocMarkup,\n      vendorAccount\n    );\n  }\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  function doDocRedeem(address userAddress, uint256 docAmount, uint256 totalBtc)\n    internal\n  {\n    docToken.burn(userAddress, docAmount);\n    bproxManager.substractValuesFromBucket(BUCKET_C0, totalBtc, docAmount, 0);\n  }\n\n  function initializeContracts() internal {\n    moc = IMoC(connector.moc());\n    docToken = DocToken(connector.docToken());\n    bproToken = BProToken(connector.bproToken());\n    bproxManager = MoCBProxManager(connector.bproxManager());\n    mocState = IMoCState(connector.mocState());\n    mocInrate = IMoCInrate(connector.mocInrate());\n  }\n\n\n  /************************************/\n  /***** UPGRADE v0110      ***********/\n  /************************************/\n\n  /** START UPDATE V0112: 24/09/2020  **/\n  /** Upgrade to support multiple commission rates **/\n  /** Structs **/\n\n  struct RiskProRedeemStruct{\n    uint256 bproFinalAmount;\n    uint256 btcTotalWithoutCommission;\n    CommissionReturnStruct commission;\n  }\n\n  struct FreeStableTokenRedeemStruct{\n    uint256 finalDocAmount;\n    uint256 finalBtcAmount;\n    uint256 btcInterestAmount;\n    CommissionReturnStruct commission;\n  }\n\n  struct RiskProMintStruct{\n    uint256 bproRegularPrice;\n    uint256 btcValue;\n    uint256 discountPrice;\n    uint256 bproDiscountAmount;\n    uint256 regularBProAmount;\n    uint256 availableBPro;\n    uint256 finalBProAmount;\n    CommissionReturnStruct commission;\n  }\n\n  struct StableTokenMintStruct{\n    uint256 docs;\n    uint256 docAmount;\n    uint256 totalCost;\n    CommissionReturnStruct commission;\n  }\n\n  struct CommissionParamsStruct{\n    address account; // Address of the user doing the transaction\n    uint256 amount; // Amount from which commissions are calculated\n    uint8 txTypeFeesMOC; // Transaction type if fees are paid in MoC\n    uint8 txTypeFeesRBTC; // Transaction type if fees are paid in RBTC\n    address vendorAccount; // Vendor address\n  }\n\n  struct CommissionReturnStruct{\n    uint256 btcCommission;\n    uint256 mocCommission;\n    uint256 btcPrice;\n    uint256 mocPrice;\n    uint256 btcMarkup;\n    uint256 mocMarkup;\n  }\n\n  struct StableTokenRedeemStruct{\n    uint256 reserveTotal;\n    uint256 btcToRedeem;\n    uint256 totalBtc;\n    CommissionReturnStruct commission;\n  }\n\n  /** END UPDATE V0112: 24/09/2020 **/\n\n  // Leave a gap betweeen inherited contracts variables in order to be\n  // able to add more variables in them later\n  uint256[50] private upgradeGap;\n}\n","creation_status":"success","file_path":"npm/money-on-chain@0.1.14/contracts/MoCExchange.sol"}