Contract 0x4EC3570cADaAEE08Ae384779B0f3A45EF85289DE 1

Txn Hash
Method
Block
From
To
Value
0x661e3cc3426870bb74d39031918ac60d5f5fb6cbf78f7b1ce4ca4c6ff4c8185a0x85b53fc8313578812022-05-01 9:28:16152 days 12 hrs ago0xfc73d5808061164415cf72bbf53014373dd7f63b IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000118912.5
0xff032949578a6d930b5f431417fce0ae9a4c95278455831d4f911454535aa3740xa67a6a45269291092021-08-25 9:34:40401 days 12 hrs ago0x6177fe90b1908ad04f2df3b4b5aba8f811d1c091 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000189431
0x64af58d26377a89c17af2ecad1433ea9cbe18027b5561757e5cc37a46477b54e0xa67a6a45269288972021-08-25 9:13:28401 days 13 hrs ago0x6177fe90b1908ad04f2df3b4b5aba8f811d1c091 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000139891
0x08b1320869e190f3719105716754ab423787341e7f69c848b16ac86dae8eedcbAdfepixw269282662021-08-25 8:10:16401 days 14 hrs ago0x6177fe90b1908ad04f2df3b4b5aba8f811d1c091 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.00002711
0x0864ab78c2fb4041bcc1dd54c64247766cc26732c75866a07a3498b7f96d16c8Transfer267530652021-08-13 3:24:04413 days 18 hrs ago0x55555513537ec7f03a0af928bce4b200e6d677dd IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0.001391 Ether0.000105225
0xcd769bcbad53d2352cf68006bb43a9521fc69af84dd4fda9a24c23753a505c8e0xa67a6a45262732352021-07-21 14:54:52436 days 7 hrs ago0x6a8183a74dd5917ca95be737532baf78486fdbfa IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000179521
0x314346df4002f58300c1c94808823aab37fd888c801452cbf028a1ced3f5c4140xa67a6a45262732242021-07-21 14:54:08436 days 7 hrs ago0x6a8183a74dd5917ca95be737532baf78486fdbfa IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000151241
0x7603f6fb31726d8e47135444ab6d1e344374ffded8f2dd0c5e34066dd52660490xa67a6a45262725682021-07-21 14:10:24436 days 8 hrs ago0x6a8183a74dd5917ca95be737532baf78486fdbfa IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000893645
0xa8ad4bea1d275952e6c68b62a4c0c27d8ebc5af282b6fd2bd0098cd9c426153c0xa67a6a45262717482021-07-21 13:15:44436 days 9 hrs ago0x6a8183a74dd5917ca95be737532baf78486fdbfa IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000117531
0xb82097f7398cc81eec1c087ca2443dfd0fa506a9a37680c0bd07cbb088c7b8900xa67a6a45258486952021-07-01 23:02:48455 days 23 hrs ago0x7cf13015c076329b212397ffcde678046e9c0421 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000446293
0xff7fd38e6fe8faf13fac60e58b712963a6987cdf82e121552a1caa166cfdbecd0x85b53fc8258486632021-07-01 23:00:40455 days 23 hrs ago0x7cf13015c076329b212397ffcde678046e9c0421 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000142733
0xc08478a4672efe3115bab21eecb4d5c2fa694a0f6b255db5971c88c7c560935a0xa67a6a45258227672021-06-30 18:13:44457 days 4 hrs ago0x6ee6ba6697b9bd4e4091c59fe62544209567514c IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000446293
0xac571f2571c2e740fa467569923d1294e513a1e7cadec3b380effab29952ad230x85b53fc8258227342021-06-30 18:11:32457 days 4 hrs ago0x6ee6ba6697b9bd4e4091c59fe62544209567514c IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000142733
0x1914fc70fc6a39531d662bf3ab58b40595efc17bcdbeaec1eae2c672a44463340xa67a6a45258211872021-06-30 16:28:24457 days 5 hrs ago0xc783df8a850f42e7f7e57013759c285caa701eb6 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000440283
0x6c2427414505c9e923e62a321a929a816959f3521ac2925166ea47ae62eb64e30x85b53fc8258211532021-06-30 16:26:08457 days 5 hrs ago0xc783df8a850f42e7f7e57013759c285caa701eb6 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000083033
0x34d15d99e3447ffe53f0e763294cca0c04c10bd4389356826312c445b5ce90860x85b53fc8258210662021-06-30 16:20:20457 days 6 hrs ago0xc783df8a850f42e7f7e57013759c285caa701eb6 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000083033
0x3498aac99823e06fbe6f9c98cdb886b62bec36193bd6c556201ab8145d610d2d0x85b53fc8258209362021-06-30 16:11:40457 days 6 hrs ago0xc783df8a850f42e7f7e57013759c285caa701eb6 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000083033
0x8e19a45354c813e4f13a5b103c4cb6566a08d673ab009093ed63a6d3637950810x85b53fc8258209012021-06-30 16:09:20457 days 6 hrs ago0xc783df8a850f42e7f7e57013759c285caa701eb6 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000142733
0x91590f7ecb57ce4356110cf776c3ba7af08a943ef0d453ef218b83302ff1cc630x85b53fc8257731302021-06-28 11:01:40459 days 11 hrs ago0xc783df8a850f42e7f7e57013759c285caa701eb6 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.0000833
0x44b91a03526a463096ad9c5febf60adbbb1d76af4b65ebedc9a8a1b169fbc09b0xa67a6a45257729542021-06-28 10:49:56459 days 11 hrs ago0xc783df8a850f42e7f7e57013759c285caa701eb6 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000491293
0x314836c1bee77b8c8f5bc6e6f4b65d112b4755b757016efab2c3f7b91abc57170x85b53fc8257728402021-06-28 10:42:20459 days 11 hrs ago0xc783df8a850f42e7f7e57013759c285caa701eb6 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.0000833
0xd78230a973bab2d8f008dccbdf2c47d08568f191402d3880674747a171db28690x85b53fc8257727262021-06-28 10:34:44459 days 11 hrs ago0xc783df8a850f42e7f7e57013759c285caa701eb6 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.00014273
0x7bd08316536ba5adcde9d8547845f407e602ee9f80eaa365f8fa286e805d8188Initiate Flash L...257582872021-06-27 18:31:56460 days 3 hrs ago0x63de27da149ee70f8ce9ccee88d753d7f3bea073 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.0004454820
0xa3e63500b4332f4d8ef45dc1f1a79805dc9e10776b26b8f0e4398ffd774d05110xa67a6a45250090372021-05-23 5:58:00495 days 16 hrs ago0x6177fe90b1908ad04f2df3b4b5aba8f811d1c091 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000358512
0x27c5bc1846d052fa7a84b6a6082ae1ea2af92462e0ff2a694bd11e62347e11b30xa67a6a45250080432021-05-23 4:47:36495 days 17 hrs ago0x6177fe90b1908ad04f2df3b4b5aba8f811d1c091 IN  0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether0.000398172
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x2c78c5368707f2b1be9d12c948f5754d5df38870b1b52be06e1a24f2a33ca5d8335848962022-09-01 17:25:3629 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0x2c78c5368707f2b1be9d12c948f5754d5df38870b1b52be06e1a24f2a33ca5d8335848962022-09-01 17:25:3629 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0x31275c5b6811b39c438870bc9981d5a98e3b6e230 Ether
0x2c78c5368707f2b1be9d12c948f5754d5df38870b1b52be06e1a24f2a33ca5d8335848962022-09-01 17:25:3629 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0x2c78c5368707f2b1be9d12c948f5754d5df38870b1b52be06e1a24f2a33ca5d8335848962022-09-01 17:25:3629 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xe3e777529824f0394a4f9e9dc7f6970d38850d0e0 Ether
0x2c78c5368707f2b1be9d12c948f5754d5df38870b1b52be06e1a24f2a33ca5d8335848962022-09-01 17:25:3629 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0x9018629372e73c727495ae23af6ecdbd622fc8550 Ether
0x2c78c5368707f2b1be9d12c948f5754d5df38870b1b52be06e1a24f2a33ca5d8335848962022-09-01 17:25:3629 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xcfa0451d8d1f08504fa44a6f72d00f455b858a1d0 Ether
0x2c78c5368707f2b1be9d12c948f5754d5df38870b1b52be06e1a24f2a33ca5d8335848962022-09-01 17:25:3629 days 4 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0x2c78c5368707f2b1be9d12c948f5754d5df38870b1b52be06e1a24f2a33ca5d8335848962022-09-01 17:25:3629 days 4 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0x2c78c5368707f2b1be9d12c948f5754d5df38870b1b52be06e1a24f2a33ca5d8335848962022-09-01 17:25:3629 days 4 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0x2989bea770b23032ec1c42b2f8847860f19cffc28d6a4951ad7d6e0e94da7803335848722022-09-01 17:23:2829 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0x2989bea770b23032ec1c42b2f8847860f19cffc28d6a4951ad7d6e0e94da7803335848722022-09-01 17:23:2829 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0x31275c5b6811b39c438870bc9981d5a98e3b6e230 Ether
0x2989bea770b23032ec1c42b2f8847860f19cffc28d6a4951ad7d6e0e94da7803335848722022-09-01 17:23:2829 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0x2989bea770b23032ec1c42b2f8847860f19cffc28d6a4951ad7d6e0e94da7803335848722022-09-01 17:23:2829 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xe3e777529824f0394a4f9e9dc7f6970d38850d0e0 Ether
0x2989bea770b23032ec1c42b2f8847860f19cffc28d6a4951ad7d6e0e94da7803335848722022-09-01 17:23:2829 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0x9018629372e73c727495ae23af6ecdbd622fc8550 Ether
0x2989bea770b23032ec1c42b2f8847860f19cffc28d6a4951ad7d6e0e94da7803335848722022-09-01 17:23:2829 days 4 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xcfa0451d8d1f08504fa44a6f72d00f455b858a1d0 Ether
0x2989bea770b23032ec1c42b2f8847860f19cffc28d6a4951ad7d6e0e94da7803335848722022-09-01 17:23:2829 days 4 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0x2989bea770b23032ec1c42b2f8847860f19cffc28d6a4951ad7d6e0e94da7803335848722022-09-01 17:23:2829 days 4 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0x2989bea770b23032ec1c42b2f8847860f19cffc28d6a4951ad7d6e0e94da7803335848722022-09-01 17:23:2829 days 4 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0x530e8c9290144704f5dc780226bdd903027b81ebb116be78e6d9a634985a36d7335848552022-09-01 17:22:1229 days 5 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0x530e8c9290144704f5dc780226bdd903027b81ebb116be78e6d9a634985a36d7335848552022-09-01 17:22:1229 days 5 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0x530e8c9290144704f5dc780226bdd903027b81ebb116be78e6d9a634985a36d7335848552022-09-01 17:22:1229 days 5 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0x530e8c9290144704f5dc780226bdd903027b81ebb116be78e6d9a634985a36d7335848552022-09-01 17:22:1229 days 5 hrs ago 0x31275c5b6811b39c438870bc9981d5a98e3b6e23 0x4ec3570cadaaee08ae384779b0f3a45ef85289de0 Ether
0xe8498ae9b8dcd35b7ebbc2cbc9a3686ccf3239e4a163a32dedbf14049cfcbd4f335847872022-09-01 17:16:5229 days 5 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0xe8498ae9b8dcd35b7ebbc2cbc9a3686ccf3239e4a163a32dedbf14049cfcbd4f335847872022-09-01 17:16:5229 days 5 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0x31275c5b6811b39c438870bc9981d5a98e3b6e230 Ether
0xe8498ae9b8dcd35b7ebbc2cbc9a3686ccf3239e4a163a32dedbf14049cfcbd4f335847872022-09-01 17:16:5229 days 5 hrs ago 0x4ec3570cadaaee08ae384779b0f3a45ef85289de 0xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
[ Download CSV Export 
Loading
This contract contains unverified libraries: AdminImpl

Contract Source Code Verified (Exact Match)

Contract Name:
SoloMargin

Compiler Version
v0.5.7+commit.6da8b019

Optimization Enabled:
Yes with 10000 runs

Other Settings:
byzantium EvmVersion, None license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2020-08-10
*/

/*

    Copyright 2019 dYdX Trading Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

*/

pragma solidity 0.5.7;
pragma experimental ABIEncoderV2;

// File: openzeppelin-solidity/contracts/ownership/Ownable.sol

/**
 * @title Ownable
 * @dev The Ownable contract has an owner address, and provides basic authorization control
 * functions, this simplifies the implementation of "user permissions".
 */
contract Ownable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev The Ownable constructor sets the original `owner` of the contract to the sender
     * account.
     */
    constructor () internal {
        _owner = msg.sender;
        emit OwnershipTransferred(address(0), _owner);
    }

    /**
     * @return the address of the owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner());
        _;
    }

    /**
     * @return true if `msg.sender` is the owner of the contract.
     */
    function isOwner() public view returns (bool) {
        return msg.sender == _owner;
    }

    /**
     * @dev Allows the current owner to relinquish control of the contract.
     * @notice Renouncing to ownership will leave the contract without an owner.
     * It will not be possible to call the functions with the `onlyOwner`
     * modifier anymore.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Allows the current owner to transfer control of the contract to a newOwner.
     * @param newOwner The address to transfer ownership to.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers control of the contract to a newOwner.
     * @param newOwner The address to transfer ownership to.
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0));
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

// File: openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol

/**
 * @title Helps contracts guard against reentrancy attacks.
 * @author Remco Bloemen <[email protected]π.com>, Eenae <[email protected]>
 * @dev If you mark a function `nonReentrant`, you should also
 * mark it `external`.
 */
contract ReentrancyGuard {
    /// @dev counter to allow mutex lock with only one SSTORE operation
    uint256 private _guardCounter;

    constructor () internal {
        // The counter starts at one to prevent changing it from zero to a non-zero
        // value, which is a more expensive operation.
        _guardCounter = 1;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _guardCounter += 1;
        uint256 localCounter = _guardCounter;
        _;
        require(localCounter == _guardCounter);
    }
}

// File: openzeppelin-solidity/contracts/math/SafeMath.sol

/**
 * @title SafeMath
 * @dev Unsigned math operations with safety checks that revert on error
 */
library SafeMath {
    /**
    * @dev Multiplies two unsigned integers, reverts on overflow.
    */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b);

        return c;
    }

    /**
    * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
    */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
    * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
    */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a);
        uint256 c = a - b;

        return c;
    }

    /**
    * @dev Adds two unsigned integers, reverts on overflow.
    */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a);

        return c;
    }

    /**
    * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
    * reverts when dividing by zero.
    */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b != 0);
        return a % b;
    }
}

// File: contracts/protocol/lib/Require.sol

/**
 * @title Require
 * @author dYdX
 *
 * Stringifies parameters to pretty-print revert messages. Costs more gas than regular require()
 */
library Require {

    // ============ Constants ============

    uint256 constant ASCII_ZERO = 48; // '0'
    uint256 constant ASCII_RELATIVE_ZERO = 87; // 'a' - 10
    uint256 constant ASCII_LOWER_EX = 120; // 'x'
    bytes2 constant COLON = 0x3a20; // ': '
    bytes2 constant COMMA = 0x2c20; // ', '
    bytes2 constant LPAREN = 0x203c; // ' <'
    byte constant RPAREN = 0x3e; // '>'
    uint256 constant FOUR_BIT_MASK = 0xf;

    // ============ Library Functions ============

    function that(
        bool must,
        bytes32 file,
        bytes32 reason
    )
        internal
        pure
    {
        if (!must) {
            revert(
                string(
                    abi.encodePacked(
                        stringify(file),
                        COLON,
                        stringify(reason)
                    )
                )
            );
        }
    }

    function that(
        bool must,
        bytes32 file,
        bytes32 reason,
        uint256 payloadA
    )
        internal
        pure
    {
        if (!must) {
            revert(
                string(
                    abi.encodePacked(
                        stringify(file),
                        COLON,
                        stringify(reason),
                        LPAREN,
                        stringify(payloadA),
                        RPAREN
                    )
                )
            );
        }
    }

    function that(
        bool must,
        bytes32 file,
        bytes32 reason,
        uint256 payloadA,
        uint256 payloadB
    )
        internal
        pure
    {
        if (!must) {
            revert(
                string(
                    abi.encodePacked(
                        stringify(file),
                        COLON,
                        stringify(reason),
                        LPAREN,
                        stringify(payloadA),
                        COMMA,
                        stringify(payloadB),
                        RPAREN
                    )
                )
            );
        }
    }

    function that(
        bool must,
        bytes32 file,
        bytes32 reason,
        address payloadA
    )
        internal
        pure
    {
        if (!must) {
            revert(
                string(
                    abi.encodePacked(
                        stringify(file),
                        COLON,
                        stringify(reason),
                        LPAREN,
                        stringify(payloadA),
                        RPAREN
                    )
                )
            );
        }
    }

    function that(
        bool must,
        bytes32 file,
        bytes32 reason,
        address payloadA,
        uint256 payloadB
    )
        internal
        pure
    {
        if (!must) {
            revert(
                string(
                    abi.encodePacked(
                        stringify(file),
                        COLON,
                        stringify(reason),
                        LPAREN,
                        stringify(payloadA),
                        COMMA,
                        stringify(payloadB),
                        RPAREN
                    )
                )
            );
        }
    }

    function that(
        bool must,
        bytes32 file,
        bytes32 reason,
        address payloadA,
        uint256 payloadB,
        uint256 payloadC
    )
        internal
        pure
    {
        if (!must) {
            revert(
                string(
                    abi.encodePacked(
                        stringify(file),
                        COLON,
                        stringify(reason),
                        LPAREN,
                        stringify(payloadA),
                        COMMA,
                        stringify(payloadB),
                        COMMA,
                        stringify(payloadC),
                        RPAREN
                    )
                )
            );
        }
    }

    // ============ Private Functions ============

    function stringify(
        bytes32 input
    )
        private
        pure
        returns (bytes memory)
    {
        // put the input bytes into the result
        bytes memory result = abi.encodePacked(input);

        // determine the length of the input by finding the location of the last non-zero byte
        for (uint256 i = 32; i > 0; ) {
            // reverse-for-loops with unsigned integer
            /* solium-disable-next-line security/no-modify-for-iter-var */
            i--;

            // find the last non-zero byte in order to determine the length
            if (result[i] != 0) {
                uint256 length = i + 1;

                /* solium-disable-next-line security/no-inline-assembly */
                assembly {
                    mstore(result, length) // r.length = length;
                }

                return result;
            }
        }

        // all bytes are zero
        return new bytes(0);
    }

    function stringify(
        uint256 input
    )
        private
        pure
        returns (bytes memory)
    {
        if (input == 0) {
            return "0";
        }

        // get the final string length
        uint256 j = input;
        uint256 length;
        while (j != 0) {
            length++;
            j /= 10;
        }

        // allocate the string
        bytes memory bstr = new bytes(length);

        // populate the string starting with the least-significant character
        j = input;
        for (uint256 i = length; i > 0; ) {
            // reverse-for-loops with unsigned integer
            /* solium-disable-next-line security/no-modify-for-iter-var */
            i--;

            // take last decimal digit
            bstr[i] = byte(uint8(ASCII_ZERO + (j % 10)));

            // remove the last decimal digit
            j /= 10;
        }

        return bstr;
    }

    function stringify(
        address input
    )
        private
        pure
        returns (bytes memory)
    {
        uint256 z = uint256(input);

        // addresses are "0x" followed by 20 bytes of data which take up 2 characters each
        bytes memory result = new bytes(42);

        // populate the result with "0x"
        result[0] = byte(uint8(ASCII_ZERO));
        result[1] = byte(uint8(ASCII_LOWER_EX));

        // for each byte (starting from the lowest byte), populate the result with two characters
        for (uint256 i = 0; i < 20; i++) {
            // each byte takes two characters
            uint256 shift = i * 2;

            // populate the least-significant character
            result[41 - shift] = char(z & FOUR_BIT_MASK);
            z = z >> 4;

            // populate the most-significant character
            result[40 - shift] = char(z & FOUR_BIT_MASK);
            z = z >> 4;
        }

        return result;
    }

    function char(
        uint256 input
    )
        private
        pure
        returns (byte)
    {
        // return ASCII digit (0-9)
        if (input < 10) {
            return byte(uint8(input + ASCII_ZERO));
        }

        // return ASCII letter (a-f)
        return byte(uint8(input + ASCII_RELATIVE_ZERO));
    }
}

// File: contracts/protocol/lib/Math.sol

/**
 * @title Math
 * @author dYdX
 *
 * Library for non-standard Math functions
 */
library Math {
    using SafeMath for uint256;

    // ============ Constants ============

    bytes32 constant FILE = "Math";

    // ============ Library Functions ============

    /*
     * Return target * (numerator / denominator).
     */
    function getPartial(
        uint256 target,
        uint256 numerator,
        uint256 denominator
    )
        internal
        pure
        returns (uint256)
    {
        return target.mul(numerator).div(denominator);
    }

    /*
     * Return target * (numerator / denominator), but rounded up.
     */
    function getPartialRoundUp(
        uint256 target,
        uint256 numerator,
        uint256 denominator
    )
        internal
        pure
        returns (uint256)
    {
        if (target == 0 || numerator == 0) {
            // SafeMath will check for zero denominator
            return SafeMath.div(0, denominator);
        }
        return target.mul(numerator).sub(1).div(denominator).add(1);
    }

    function to128(
        uint256 number
    )
        internal
        pure
        returns (uint128)
    {
        uint128 result = uint128(number);
        Require.that(
            result == number,
            FILE,
            "Unsafe cast to uint128"
        );
        return result;
    }

    function to96(
        uint256 number
    )
        internal
        pure
        returns (uint96)
    {
        uint96 result = uint96(number);
        Require.that(
            result == number,
            FILE,
            "Unsafe cast to uint96"
        );
        return result;
    }

    function to32(
        uint256 number
    )
        internal
        pure
        returns (uint32)
    {
        uint32 result = uint32(number);
        Require.that(
            result == number,
            FILE,
            "Unsafe cast to uint32"
        );
        return result;
    }

    function min(
        uint256 a,
        uint256 b
    )
        internal
        pure
        returns (uint256)
    {
        return a < b ? a : b;
    }

    function max(
        uint256 a,
        uint256 b
    )
        internal
        pure
        returns (uint256)
    {
        return a > b ? a : b;
    }
}

// File: contracts/protocol/lib/Types.sol

/**
 * @title Types
 * @author dYdX
 *
 * Library for interacting with the basic structs used in Solo
 */
library Types {
    using Math for uint256;

    // ============ AssetAmount ============

    enum AssetDenomination {
        Wei, // the amount is denominated in wei
        Par  // the amount is denominated in par
    }

    enum AssetReference {
        Delta, // the amount is given as a delta from the current value
        Target // the amount is given as an exact number to end up at
    }

    struct AssetAmount {
        bool sign; // true if positive
        AssetDenomination denomination;
        AssetReference ref;
        uint256 value;
    }

    // ============ Par (Principal Amount) ============

    // Total borrow and supply values for a market
    struct TotalPar {
        uint128 borrow;
        uint128 supply;
    }

    // Individual principal amount for an account
    struct Par {
        bool sign; // true if positive
        uint128 value;
    }

    function zeroPar()
        internal
        pure
        returns (Par memory)
    {
        return Par({
            sign: false,
            value: 0
        });
    }

    function sub(
        Par memory a,
        Par memory b
    )
        internal
        pure
        returns (Par memory)
    {
        return add(a, negative(b));
    }

    function add(
        Par memory a,
        Par memory b
    )
        internal
        pure
        returns (Par memory)
    {
        Par memory result;
        if (a.sign == b.sign) {
            result.sign = a.sign;
            result.value = SafeMath.add(a.value, b.value).to128();
        } else {
            if (a.value >= b.value) {
                result.sign = a.sign;
                result.value = SafeMath.sub(a.value, b.value).to128();
            } else {
                result.sign = b.sign;
                result.value = SafeMath.sub(b.value, a.value).to128();
            }
        }
        return result;
    }

    function equals(
        Par memory a,
        Par memory b
    )
        internal
        pure
        returns (bool)
    {
        if (a.value == b.value) {
            if (a.value == 0) {
                return true;
            }
            return a.sign == b.sign;
        }
        return false;
    }

    function negative(
        Par memory a
    )
        internal
        pure
        returns (Par memory)
    {
        return Par({
            sign: !a.sign,
            value: a.value
        });
    }

    function isNegative(
        Par memory a
    )
        internal
        pure
        returns (bool)
    {
        return !a.sign && a.value > 0;
    }

    function isPositive(
        Par memory a
    )
        internal
        pure
        returns (bool)
    {
        return a.sign && a.value > 0;
    }

    function isZero(
        Par memory a
    )
        internal
        pure
        returns (bool)
    {
        return a.value == 0;
    }

    // ============ Wei (Token Amount) ============

    // Individual token amount for an account
    struct Wei {
        bool sign; // true if positive
        uint256 value;
    }

    function zeroWei()
        internal
        pure
        returns (Wei memory)
    {
        return Wei({
            sign: false,
            value: 0
        });
    }

    function sub(
        Wei memory a,
        Wei memory b
    )
        internal
        pure
        returns (Wei memory)
    {
        return add(a, negative(b));
    }

    function add(
        Wei memory a,
        Wei memory b
    )
        internal
        pure
        returns (Wei memory)
    {
        Wei memory result;
        if (a.sign == b.sign) {
            result.sign = a.sign;
            result.value = SafeMath.add(a.value, b.value);
        } else {
            if (a.value >= b.value) {
                result.sign = a.sign;
                result.value = SafeMath.sub(a.value, b.value);
            } else {
                result.sign = b.sign;
                result.value = SafeMath.sub(b.value, a.value);
            }
        }
        return result;
    }

    function equals(
        Wei memory a,
        Wei memory b
    )
        internal
        pure
        returns (bool)
    {
        if (a.value == b.value) {
            if (a.value == 0) {
                return true;
            }
            return a.sign == b.sign;
        }
        return false;
    }

    function negative(
        Wei memory a
    )
        internal
        pure
        returns (Wei memory)
    {
        return Wei({
            sign: !a.sign,
            value: a.value
        });
    }

    function isNegative(
        Wei memory a
    )
        internal
        pure
        returns (bool)
    {
        return !a.sign && a.value > 0;
    }

    function isPositive(
        Wei memory a
    )
        internal
        pure
        returns (bool)
    {
        return a.sign && a.value > 0;
    }

    function isZero(
        Wei memory a
    )
        internal
        pure
        returns (bool)
    {
        return a.value == 0;
    }
}

// File: contracts/protocol/lib/Account.sol

/**
 * @title Account
 * @author dYdX
 *
 * Library of structs and functions that represent an account
 */
library Account {
    // ============ Enums ============

    /*
     * Most-recently-cached account status.
     *
     * Normal: Can only be liquidated if the account values are violating the global margin-ratio.
     * Liquid: Can be liquidated no matter the account values.
     *         Can be vaporized if there are no more positive account values.
     * Vapor:  Has only negative (or zeroed) account values. Can be vaporized.
     *
     */
    enum Status {
        Normal,
        Liquid,
        Vapor
    }

    // ============ Structs ============

    // Represents the unique key that specifies an account
    struct Info {
        address owner;  // The address that owns the account
        uint256 number; // A nonce that allows a single address to control many accounts
    }

    // The complete storage for any account
    struct Storage {
        mapping (uint256 => Types.Par) balances; // Mapping from marketId to principal
        Status status;
    }

    // ============ Library Functions ============

    function equals(
        Info memory a,
        Info memory b
    )
        internal
        pure
        returns (bool)
    {
        return a.owner == b.owner && a.number == b.number;
    }
}

// File: contracts/protocol/lib/Monetary.sol

/**
 * @title Monetary
 * @author dYdX
 *
 * Library for types involving money
 */
library Monetary {

    /*
     * The price of a base-unit of an asset.
     */
    struct Price {
        uint256 value;
    }

    /*
     * Total value of an some amount of an asset. Equal to (price * amount).
     */
    struct Value {
        uint256 value;
    }
}

// File: contracts/protocol/lib/Cache.sol

/**
 * @title Cache
 * @author dYdX
 *
 * Library for caching information about markets
 */
library Cache {
    using Cache for MarketCache;
    using Storage for Storage.State;

    // ============ Structs ============

    struct MarketInfo {
        bool isClosing;
        uint128 borrowPar;
        Monetary.Price price;
    }

    struct MarketCache {
        MarketInfo[] markets;
    }

    // ============ Setter Functions ============

    /**
     * Initialize an empty cache for some given number of total markets.
     */
    function create(
        uint256 numMarkets
    )
        internal
        pure
        returns (MarketCache memory)
    {
        return MarketCache({
            markets: new MarketInfo[](numMarkets)
        });
    }

    /**
     * Add market information (price and total borrowed par if the market is closing) to the cache.
     * Return true if the market information did not previously exist in the cache.
     */
    function addMarket(
        MarketCache memory cache,
        Storage.State storage state,
        uint256 marketId
    )
        internal
        view
        returns (bool)
    {
        if (cache.hasMarket(marketId)) {
            return false;
        }
        cache.markets[marketId].price = state.fetchPrice(marketId);
        if (state.markets[marketId].isClosing) {
            cache.markets[marketId].isClosing = true;
            cache.markets[marketId].borrowPar = state.getTotalPar(marketId).borrow;
        }
        return true;
    }

    // ============ Getter Functions ============

    function getNumMarkets(
        MarketCache memory cache
    )
        internal
        pure
        returns (uint256)
    {
        return cache.markets.length;
    }

    function hasMarket(
        MarketCache memory cache,
        uint256 marketId
    )
        internal
        pure
        returns (bool)
    {
        return cache.markets[marketId].price.value != 0;
    }

    function getIsClosing(
        MarketCache memory cache,
        uint256 marketId
    )
        internal
        pure
        returns (bool)
    {
        return cache.markets[marketId].isClosing;
    }

    function getPrice(
        MarketCache memory cache,
        uint256 marketId
    )
        internal
        pure
        returns (Monetary.Price memory)
    {
        return cache.markets[marketId].price;
    }

    function getBorrowPar(
        MarketCache memory cache,
        uint256 marketId
    )
        internal
        pure
        returns (uint128)
    {
        return cache.markets[marketId].borrowPar;
    }
}

// File: contracts/protocol/lib/Decimal.sol

/**
 * @title Decimal
 * @author dYdX
 *
 * Library that defines a fixed-point number with 18 decimal places.
 */
library Decimal {
    using SafeMath for uint256;

    // ============ Constants ============

    uint256 constant BASE = 10**18;

    // ============ Structs ============

    struct D256 {
        uint256 value;
    }

    // ============ Functions ============

    function one()
        internal
        pure
        returns (D256 memory)
    {
        return D256({ value: BASE });
    }

    function onePlus(
        D256 memory d
    )
        internal
        pure
        returns (D256 memory)
    {
        return D256({ value: d.value.add(BASE) });
    }

    function mul(
        uint256 target,
        D256 memory d
    )
        internal
        pure
        returns (uint256)
    {
        return Math.getPartial(target, d.value, BASE);
    }

    function div(
        uint256 target,
        D256 memory d
    )
        internal
        pure
        returns (uint256)
    {
        return Math.getPartial(target, BASE, d.value);
    }
}

// File: contracts/protocol/lib/Time.sol

/**
 * @title Time
 * @author dYdX
 *
 * Library for dealing with time, assuming timestamps fit within 32 bits (valid until year 2106)
 */
library Time {

    // ============ Library Functions ============

    function currentTime()
        internal
        view
        returns (uint32)
    {
        return Math.to32(block.timestamp);
    }
}

// File: contracts/protocol/lib/Interest.sol

/**
 * @title Interest
 * @author dYdX
 *
 * Library for managing the interest rate and interest indexes of Solo
 */
library Interest {
    using Math for uint256;
    using SafeMath for uint256;

    // ============ Constants ============

    bytes32 constant FILE = "Interest";
    uint64 constant BASE = 10**18;

    // ============ Structs ============

    struct Rate {
        uint256 value;
    }

    struct Index {
        uint96 borrow;
        uint96 supply;
        uint32 lastUpdate;
    }

    // ============ Library Functions ============

    /**
     * Get a new market Index based on the old index and market interest rate.
     * Calculate interest for borrowers by using the formula rate * time. Approximates
     * continuously-compounded interest when called frequently, but is much more
     * gas-efficient to calculate. For suppliers, the interest rate is adjusted by the earningsRate,
     * then prorated the across all suppliers.
     *
     * @param  index         The old index for a market
     * @param  rate          The current interest rate of the market
     * @param  totalPar      The total supply and borrow par values of the market
     * @param  earningsRate  The portion of the interest that is forwarded to the suppliers
     * @return               The updated index for a market
     */
    function calculateNewIndex(
        Index memory index,
        Rate memory rate,
        Types.TotalPar memory totalPar,
        Decimal.D256 memory earningsRate
    )
        internal
        view
        returns (Index memory)
    {
        (
            Types.Wei memory supplyWei,
            Types.Wei memory borrowWei
        ) = totalParToWei(totalPar, index);

        // get interest increase for borrowers
        uint32 currentTime = Time.currentTime();
        uint256 borrowInterest = rate.value.mul(uint256(currentTime).sub(index.lastUpdate));

        // get interest increase for suppliers
        uint256 supplyInterest;
        if (Types.isZero(supplyWei)) {
            supplyInterest = 0;
        } else {
            supplyInterest = Decimal.mul(borrowInterest, earningsRate);
            if (borrowWei.value < supplyWei.value) {
                supplyInterest = Math.getPartial(supplyInterest, borrowWei.value, supplyWei.value);
            }
        }
        assert(supplyInterest <= borrowInterest);

        return Index({
            borrow: Math.getPartial(index.borrow, borrowInterest, BASE).add(index.borrow).to96(),
            supply: Math.getPartial(index.supply, supplyInterest, BASE).add(index.supply).to96(),
            lastUpdate: currentTime
        });
    }

    function newIndex()
        internal
        view
        returns (Index memory)
    {
        return Index({
            borrow: BASE,
            supply: BASE,
            lastUpdate: Time.currentTime()
        });
    }

    /*
     * Convert a principal amount to a token amount given an index.
     */
    function parToWei(
        Types.Par memory input,
        Index memory index
    )
        internal
        pure
        returns (Types.Wei memory)
    {
        uint256 inputValue = uint256(input.value);
        if (input.sign) {
            return Types.Wei({
                sign: true,
                value: inputValue.getPartial(index.supply, BASE)
            });
        } else {
            return Types.Wei({
                sign: false,
                value: inputValue.getPartialRoundUp(index.borrow, BASE)
            });
        }
    }

    /*
     * Convert a token amount to a principal amount given an index.
     */
    function weiToPar(
        Types.Wei memory input,
        Index memory index
    )
        internal
        pure
        returns (Types.Par memory)
    {
        if (input.sign) {
            return Types.Par({
                sign: true,
                value: input.value.getPartial(BASE, index.supply).to128()
            });
        } else {
            return Types.Par({
                sign: false,
                value: input.value.getPartialRoundUp(BASE, index.borrow).to128()
            });
        }
    }

    /*
     * Convert the total supply and borrow principal amounts of a market to total supply and borrow
     * token amounts.
     */
    function totalParToWei(
        Types.TotalPar memory totalPar,
        Index memory index
    )
        internal
        pure
        returns (Types.Wei memory, Types.Wei memory)
    {
        Types.Par memory supplyPar = Types.Par({
            sign: true,
            value: totalPar.supply
        });
        Types.Par memory borrowPar = Types.Par({
            sign: false,
            value: totalPar.borrow
        });
        Types.Wei memory supplyWei = parToWei(supplyPar, index);
        Types.Wei memory borrowWei = parToWei(borrowPar, index);
        return (supplyWei, borrowWei);
    }
}

// File: contracts/protocol/interfaces/IErc20.sol

/**
 * @title IErc20
 * @author dYdX
 *
 * Interface for using ERC20 Tokens. We have to use a special interface to call ERC20 functions so
 * that we don't automatically revert when calling non-compliant tokens that have no return value for
 * transfer(), transferFrom(), or approve().
 */
interface IErc20 {
    event Transfer(
        address indexed from,
        address indexed to,
        uint256 value
    );

    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );

    function totalSupply(
    )
        external
        view
        returns (uint256);

    function balanceOf(
        address who
    )
        external
        view
        returns (uint256);

    function allowance(
        address owner,
        address spender
    )
        external
        view
        returns (uint256);

    function transfer(
        address to,
        uint256 value
    )
        external;

    function transferFrom(
        address from,
        address to,
        uint256 value
    )
        external;

    function approve(
        address spender,
        uint256 value
    )
        external;

    function name()
        external
        view
        returns (string memory);

    function symbol()
        external
        view
        returns (string memory);

    function decimals()
        external
        view
        returns (uint8);
}

// File: contracts/protocol/lib/Token.sol

/**
 * @title Token
 * @author dYdX
 *
 * This library contains basic functions for interacting with ERC20 tokens. Modified to work with
 * tokens that don't adhere strictly to the ERC20 standard (for example tokens that don't return a
 * boolean value on success).
 */
library Token {

    // ============ Constants ============

    bytes32 constant FILE = "Token";

    // ============ Library Functions ============

    function balanceOf(
        address token,
        address owner
    )
        internal
        view
        returns (uint256)
    {
        return IErc20(token).balanceOf(owner);
    }

    function allowance(
        address token,
        address owner,
        address spender
    )
        internal
        view
        returns (uint256)
    {
        return IErc20(token).allowance(owner, spender);
    }

    function approve(
        address token,
        address spender,
        uint256 amount
    )
        internal
    {
        IErc20(token).approve(spender, amount);

        Require.that(
            checkSuccess(),
            FILE,
            "Approve failed"
        );
    }

    function approveMax(
        address token,
        address spender
    )
        internal
    {
        approve(
            token,
            spender,
            uint256(-1)
        );
    }

    function transfer(
        address token,
        address to,
        uint256 amount
    )
        internal
    {
        if (amount == 0 || to == address(this)) {
            return;
        }

        IErc20(token).transfer(to, amount);

        Require.that(
            checkSuccess(),
            FILE,
            "Transfer failed"
        );
    }

    function transferFrom(
        address token,
        address from,
        address to,
        uint256 amount
    )
        internal
    {
        if (amount == 0 || to == from) {
            return;
        }

        IErc20(token).transferFrom(from, to, amount);

        Require.that(
            checkSuccess(),
            FILE,
            "TransferFrom failed"
        );
    }

    // ============ Private Functions ============

    /**
     * Check the return value of the previous function up to 32 bytes. Return true if the previous
     * function returned 0 bytes or 32 bytes that are not all-zero.
     */
    function checkSuccess(
    )
        private
        pure
        returns (bool)
    {
        uint256 returnValue = 0;

        /* solium-disable-next-line security/no-inline-assembly */
        assembly {
            // check number of bytes returned from last function call
            switch returndatasize

            // no bytes returned: assume success
            case 0x0 {
                returnValue := 1
            }

            // 32 bytes returned: check if non-zero
            case 0x20 {
                // copy 32 bytes into scratch space
                returndatacopy(0x0, 0x0, 0x20)

                // load those bytes into returnValue
                returnValue := mload(0x0)
            }

            // not sure what was returned: don't mark as success
            default { }
        }

        return returnValue != 0;
    }
}

// File: contracts/protocol/interfaces/IInterestSetter.sol

/**
 * @title IInterestSetter
 * @author dYdX
 *
 * Interface that Interest Setters for Solo must implement in order to report interest rates.
 */
interface IInterestSetter {

    // ============ Public Functions ============

    /**
     * Get the interest rate of a token given some borrowed and supplied amounts
     *
     * @param  token        The address of the ERC20 token for the market
     * @param  borrowWei    The total borrowed token amount for the market
     * @param  supplyWei    The total supplied token amount for the market
     * @return              The interest rate per second
     */
    function getInterestRate(
        address token,
        uint256 borrowWei,
        uint256 supplyWei
    )
        external
        view
        returns (Interest.Rate memory);
}

// File: contracts/protocol/interfaces/IPriceOracle.sol

/**
 * @title IPriceOracle
 * @author dYdX
 *
 * Interface that Price Oracles for Solo must implement in order to report prices.
 */
contract IPriceOracle {

    // ============ Constants ============

    uint256 public constant ONE_DOLLAR = 10 ** 36;

    // ============ Public Functions ============

    /**
     * Get the price of a token
     *
     * @param  token  The ERC20 token address of the market
     * @return        The USD price of a base unit of the token, then multiplied by 10^36.
     *                So a USD-stable coin with 18 decimal places would return 10^18.
     *                This is the price of the base unit rather than the price of a "human-readable"
     *                token amount. Every ERC20 may have a different number of decimals.
     */
    function getPrice(
        address token
    )
        public
        view
        returns (Monetary.Price memory);
}

// File: contracts/protocol/lib/Storage.sol

/**
 * @title Storage
 * @author dYdX
 *
 * Functions for reading, writing, and verifying state in Solo
 */
library Storage {
    using Cache for Cache.MarketCache;
    using Storage for Storage.State;
    using Math for uint256;
    using Types for Types.Par;
    using Types for Types.Wei;
    using SafeMath for uint256;

    // ============ Constants ============

    bytes32 constant FILE = "Storage";

    // ============ Structs ============

    // All information necessary for tracking a market
    struct Market {
        // Contract address of the associated ERC20 token
        address token;

        // Total aggregated supply and borrow amount of the entire market
        Types.TotalPar totalPar;

        // Interest index of the market
        Interest.Index index;

        // Contract address of the price oracle for this market
        IPriceOracle priceOracle;

        // Contract address of the interest setter for this market
        IInterestSetter interestSetter;

        // Multiplier on the marginRatio for this market
        Decimal.D256 marginPremium;

        // Multiplier on the liquidationSpread for this market
        Decimal.D256 spreadPremium;

        // Whether additional borrows are allowed for this market
        bool isClosing;
    }

    // The global risk parameters that govern the health and security of the system
    struct RiskParams {
        // Required ratio of over-collateralization
        Decimal.D256 marginRatio;

        // Percentage penalty incurred by liquidated accounts
        Decimal.D256 liquidationSpread;

        // Percentage of the borrower's interest fee that gets passed to the suppliers
        Decimal.D256 earningsRate;

        // The minimum absolute borrow value of an account
        // There must be sufficient incentivize to liquidate undercollateralized accounts
        Monetary.Value minBorrowedValue;
    }

    // The maximum RiskParam values that can be set
    struct RiskLimits {
        uint64 marginRatioMax;
        uint64 liquidationSpreadMax;
        uint64 earningsRateMax;
        uint64 marginPremiumMax;
        uint64 spreadPremiumMax;
        uint128 minBorrowedValueMax;
    }

    // The entire storage state of Solo
    struct State {
        // number of markets
        uint256 numMarkets;

        // marketId => Market
        mapping (uint256 => Market) markets;

        // owner => account number => Account
        mapping (address => mapping (uint256 => Account.Storage)) accounts;

        // Addresses that can control other users accounts
        mapping (address => mapping (address => bool)) operators;

        // Addresses that can control all users accounts
        mapping (address => bool) globalOperators;

        // mutable risk parameters of the system
        RiskParams riskParams;

        // immutable risk limits of the system
        RiskLimits riskLimits;
    }

    // ============ Functions ============

    function getToken(
        Storage.State storage state,
        uint256 marketId
    )
        internal
        view
        returns (address)
    {
        return state.markets[marketId].token;
    }

    function getTotalPar(
        Storage.State storage state,
        uint256 marketId
    )
        internal
        view
        returns (Types.TotalPar memory)
    {
        return state.markets[marketId].totalPar;
    }

    function getIndex(
        Storage.State storage state,
        uint256 marketId
    )
        internal
        view
        returns (Interest.Index memory)
    {
        return state.markets[marketId].index;
    }

    function getNumExcessTokens(
        Storage.State storage state,
        uint256 marketId
    )
        internal
        view
        returns (Types.Wei memory)
    {
        Interest.Index memory index = state.getIndex(marketId);
        Types.TotalPar memory totalPar = state.getTotalPar(marketId);

        address token = state.getToken(marketId);

        Types.Wei memory balanceWei = Types.Wei({
            sign: true,
            value: Token.balanceOf(token, address(this))
        });

        (
            Types.Wei memory supplyWei,
            Types.Wei memory borrowWei
        ) = Interest.totalParToWei(totalPar, index);

        // borrowWei is negative, so subtracting it makes the value more positive
        return balanceWei.sub(borrowWei).sub(supplyWei);
    }

    function getStatus(
        Storage.State storage state,
        Account.Info memory account
    )
        internal
        view
        returns (Account.Status)
    {
        return state.accounts[account.owner][account.number].status;
    }

    function getPar(
        Storage.State storage state,
        Account.Info memory account,
        uint256 marketId
    )
        internal
        view
        returns (Types.Par memory)
    {
        return state.accounts[account.owner][account.number].balances[marketId];
    }

    function getWei(
        Storage.State storage state,
        Account.Info memory account,
        uint256 marketId
    )
        internal
        view
        returns (Types.Wei memory)
    {
        Types.Par memory par = state.getPar(account, marketId);

        if (par.isZero()) {
            return Types.zeroWei();
        }

        Interest.Index memory index = state.getIndex(marketId);
        return Interest.parToWei(par, index);
    }

    function getLiquidationSpreadForPair(
        Storage.State storage state,
        uint256 heldMarketId,
        uint256 owedMarketId
    )
        internal
        view
        returns (Decimal.D256 memory)
    {
        uint256 result = state.riskParams.liquidationSpread.value;
        result = Decimal.mul(result, Decimal.onePlus(state.markets[heldMarketId].spreadPremium));
        result = Decimal.mul(result, Decimal.onePlus(state.markets[owedMarketId].spreadPremium));
        return Decimal.D256({
            value: result
        });
    }

    function fetchNewIndex(
        Storage.State storage state,
        uint256 marketId,
        Interest.Index memory index
    )
        internal
        view
        returns (Interest.Index memory)
    {
        Interest.Rate memory rate = state.fetchInterestRate(marketId, index);

        return Interest.calculateNewIndex(
            index,
            rate,
            state.getTotalPar(marketId),
            state.riskParams.earningsRate
        );
    }

    function fetchInterestRate(
        Storage.State storage state,
        uint256 marketId,
        Interest.Index memory index
    )
        internal
        view
        returns (Interest.Rate memory)
    {
        Types.TotalPar memory totalPar = state.getTotalPar(marketId);
        (
            Types.Wei memory supplyWei,
            Types.Wei memory borrowWei
        ) = Interest.totalParToWei(totalPar, index);

        Interest.Rate memory rate = state.markets[marketId].interestSetter.getInterestRate(
            state.getToken(marketId),
            borrowWei.value,
            supplyWei.value
        );

        return rate;
    }

    function fetchPrice(
        Storage.State storage state,
        uint256 marketId
    )
        internal
        view
        returns (Monetary.Price memory)
    {
        IPriceOracle oracle = IPriceOracle(state.markets[marketId].priceOracle);
        Monetary.Price memory price = oracle.getPrice(state.getToken(marketId));
        Require.that(
            price.value != 0,
            FILE,
            "Price cannot be zero",
            marketId
        );
        return price;
    }

    function getAccountValues(
        Storage.State storage state,
        Account.Info memory account,
        Cache.MarketCache memory cache,
        bool adjustForLiquidity
    )
        internal
        view
        returns (Monetary.Value memory, Monetary.Value memory)
    {
        Monetary.Value memory supplyValue;
        Monetary.Value memory borrowValue;

        uint256 numMarkets = cache.getNumMarkets();
        for (uint256 m = 0; m < numMarkets; m++) {
            if (!cache.hasMarket(m)) {
                continue;
            }

            Types.Wei memory userWei = state.getWei(account, m);

            if (userWei.isZero()) {
                continue;
            }

            uint256 assetValue = userWei.value.mul(cache.getPrice(m).value);
            Decimal.D256 memory adjust = Decimal.one();
            if (adjustForLiquidity) {
                adjust = Decimal.onePlus(state.markets[m].marginPremium);
            }

            if (userWei.sign) {
                supplyValue.value = supplyValue.value.add(Decimal.div(assetValue, adjust));
            } else {
                borrowValue.value = borrowValue.value.add(Decimal.mul(assetValue, adjust));
            }
        }

        return (supplyValue, borrowValue);
    }

    function isCollateralized(
        Storage.State storage state,
        Account.Info memory account,
        Cache.MarketCache memory cache,
        bool requireMinBorrow
    )
        internal
        view
        returns (bool)
    {
        // get account values (adjusted for liquidity)
        (
            Monetary.Value memory supplyValue,
            Monetary.Value memory borrowValue
        ) = state.getAccountValues(account, cache, /* adjustForLiquidity = */ true);

        if (borrowValue.value == 0) {
            return true;
        }

        if (requireMinBorrow) {
            Require.that(
                borrowValue.value >= state.riskParams.minBorrowedValue.value,
                FILE,
                "Borrow value too low",
                account.owner,
                account.number,
                borrowValue.value
            );
        }

        uint256 requiredMargin = Decimal.mul(borrowValue.value, state.riskParams.marginRatio);

        return supplyValue.value >= borrowValue.value.add(requiredMargin);
    }

    function isGlobalOperator(
        Storage.State storage state,
        address operator
    )
        internal
        view
        returns (bool)
    {
        return state.globalOperators[operator];
    }

    function isLocalOperator(
        Storage.State storage state,
        address owner,
        address operator
    )
        internal
        view
        returns (bool)
    {
        return state.operators[owner][operator];
    }

    function requireIsOperator(
        Storage.State storage state,
        Account.Info memory account,
        address operator
    )
        internal
        view
    {
        bool isValidOperator =
            operator == account.owner
            || state.isGlobalOperator(operator)
            || state.isLocalOperator(account.owner, operator);

        Require.that(
            isValidOperator,
            FILE,
            "Unpermissioned operator",
            operator
        );
    }

    /**
     * Determine and set an account's balance based on the intended balance change. Return the
     * equivalent amount in wei
     */
    function getNewParAndDeltaWei(
        Storage.State storage state,
        Account.Info memory account,
        uint256 marketId,
        Types.AssetAmount memory amount
    )
        internal
        view
        returns (Types.Par memory, Types.Wei memory)
    {
        Types.Par memory oldPar = state.getPar(account, marketId);

        if (amount.value == 0 && amount.ref == Types.AssetReference.Delta) {
            return (oldPar, Types.zeroWei());
        }

        Interest.Index memory index = state.getIndex(marketId);
        Types.Wei memory oldWei = Interest.parToWei(oldPar, index);
        Types.Par memory newPar;
        Types.Wei memory deltaWei;

        if (amount.denomination == Types.AssetDenomination.Wei) {
            deltaWei = Types.Wei({
                sign: amount.sign,
                value: amount.value
            });
            if (amount.ref == Types.AssetReference.Target) {
                deltaWei = deltaWei.sub(oldWei);
            }
            newPar = Interest.weiToPar(oldWei.add(deltaWei), index);
        } else { // AssetDenomination.Par
            newPar = Types.Par({
                sign: amount.sign,
                value: amount.value.to128()
            });
            if (amount.ref == Types.AssetReference.Delta) {
                newPar = oldPar.add(newPar);
            }
            deltaWei = Interest.parToWei(newPar, index).sub(oldWei);
        }

        return (newPar, deltaWei);
    }

    function getNewParAndDeltaWeiForLiquidation(
        Storage.State storage state,
        Account.Info memory account,
        uint256 marketId,
        Types.AssetAmount memory amount
    )
        internal
        view
        returns (Types.Par memory, Types.Wei memory)
    {
        Types.Par memory oldPar = state.getPar(account, marketId);

        Require.that(
            !oldPar.isPositive(),
            FILE,
            "Owed balance cannot be positive",
            account.owner,
            account.number,
            marketId
        );

        (
            Types.Par memory newPar,
            Types.Wei memory deltaWei
        ) = state.getNewParAndDeltaWei(
            account,
            marketId,
            amount
        );

        // if attempting to over-repay the owed asset, bound it by the maximum
        if (newPar.isPositive()) {
            newPar = Types.zeroPar();
            deltaWei = state.getWei(account, marketId).negative();
        }

        Require.that(
            !deltaWei.isNegative() && oldPar.value >= newPar.value,
            FILE,
            "Owed balance cannot increase",
            account.owner,
            account.number,
            marketId
        );

        // if not paying back enough wei to repay any par, then bound wei to zero
        if (oldPar.equals(newPar)) {
            deltaWei = Types.zeroWei();
        }

        return (newPar, deltaWei);
    }

    function isVaporizable(
        Storage.State storage state,
        Account.Info memory account,
        Cache.MarketCache memory cache
    )
        internal
        view
        returns (bool)
    {
        bool hasNegative = false;
        uint256 numMarkets = cache.getNumMarkets();
        for (uint256 m = 0; m < numMarkets; m++) {
            if (!cache.hasMarket(m)) {
                continue;
            }
            Types.Par memory par = state.getPar(account, m);
            if (par.isZero()) {
                continue;
            } else if (par.sign) {
                return false;
            } else {
                hasNegative = true;
            }
        }
        return hasNegative;
    }

    // =============== Setter Functions ===============

    function updateIndex(
        Storage.State storage state,
        uint256 marketId
    )
        internal
        returns (Interest.Index memory)
    {
        Interest.Index memory index = state.getIndex(marketId);
        if (index.lastUpdate == Time.currentTime()) {
            return index;
        }
        return state.markets[marketId].index = state.fetchNewIndex(marketId, index);
    }

    function setStatus(
        Storage.State storage state,
        Account.Info memory account,
        Account.Status status
    )
        internal
    {
        state.accounts[account.owner][account.number].status = status;
    }

    function setPar(
        Storage.State storage state,
        Account.Info memory account,
        uint256 marketId,
        Types.Par memory newPar
    )
        internal
    {
        Types.Par memory oldPar = state.getPar(account, marketId);

        if (Types.equals(oldPar, newPar)) {
            return;
        }

        // updateTotalPar
        Types.TotalPar memory totalPar = state.getTotalPar(marketId);

        // roll-back oldPar
        if (oldPar.sign) {
            totalPar.supply = uint256(totalPar.supply).sub(oldPar.value).to128();
        } else {
            totalPar.borrow = uint256(totalPar.borrow).sub(oldPar.value).to128();
        }

        // roll-forward newPar
        if (newPar.sign) {
            totalPar.supply = uint256(totalPar.supply).add(newPar.value).to128();
        } else {
            totalPar.borrow = uint256(totalPar.borrow).add(newPar.value).to128();
        }

        state.markets[marketId].totalPar = totalPar;
        state.accounts[account.owner][account.number].balances[marketId] = newPar;
    }

    /**
     * Determine and set an account's balance based on a change in wei
     */
    function setParFromDeltaWei(
        Storage.State storage state,
        Account.Info memory account,
        uint256 marketId,
        Types.Wei memory deltaWei
    )
        internal
    {
        if (deltaWei.isZero()) {
            return;
        }
        Interest.Index memory index = state.getIndex(marketId);
        Types.Wei memory oldWei = state.getWei(account, marketId);
        Types.Wei memory newWei = oldWei.add(deltaWei);
        Types.Par memory newPar = Interest.weiToPar(newWei, index);
        state.setPar(
            account,
            marketId,
            newPar
        );
    }
}

// File: contracts/protocol/State.sol

/**
 * @title State
 * @author dYdX
 *
 * Base-level contract that holds the state of Solo
 */
contract State
{
    Storage.State g_state;
}

// File: contracts/protocol/impl/AdminImpl.sol

/**
 * @title AdminImpl
 * @author dYdX
 *
 * Administrative functions to keep the protocol updated
 */
library AdminImpl {
    using Storage for Storage.State;
    using Token for address;
    using Types for Types.Wei;

    // ============ Constants ============

    bytes32 constant FILE = "AdminImpl";

    // ============ Events ============

    event LogWithdrawExcessTokens(
        address token,
        uint256 amount
    );

    event LogAddMarket(
        uint256 marketId,
        address token
    );

    event LogSetIsClosing(
        uint256 marketId,
        bool isClosing
    );

    event LogSetPriceOracle(
        uint256 marketId,
        address priceOracle
    );

    event LogSetInterestSetter(
        uint256 marketId,
        address interestSetter
    );

    event LogSetMarginPremium(
        uint256 marketId,
        Decimal.D256 marginPremium
    );

    event LogSetSpreadPremium(
        uint256 marketId,
        Decimal.D256 spreadPremium
    );

    event LogSetMarginRatio(
        Decimal.D256 marginRatio
    );

    event LogSetLiquidationSpread(
        Decimal.D256 liquidationSpread
    );

    event LogSetEarningsRate(
        Decimal.D256 earningsRate
    );

    event LogSetMinBorrowedValue(
        Monetary.Value minBorrowedValue
    );

    event LogSetGlobalOperator(
        address operator,
        bool approved
    );

    // ============ Token Functions ============

    function ownerWithdrawExcessTokens(
        Storage.State storage state,
        uint256 marketId,
        address recipient
    )
        public
        returns (uint256)
    {
        _validateMarketId(state, marketId);
        Types.Wei memory excessWei = state.getNumExcessTokens(marketId);

        Require.that(
            !excessWei.isNegative(),
            FILE,
            "Negative excess"
        );

        address token = state.getToken(marketId);

        uint256 actualBalance = token.balanceOf(address(this));
        if (excessWei.value > actualBalance) {
            excessWei.value = actualBalance;
        }

        token.transfer(recipient, excessWei.value);

        emit LogWithdrawExcessTokens(token, excessWei.value);

        return excessWei.value;
    }

    function ownerWithdrawUnsupportedTokens(
        Storage.State storage state,
        address token,
        address recipient
    )
        public
        returns (uint256)
    {
        _requireNoMarket(state, token);

        uint256 balance = token.balanceOf(address(this));
        token.transfer(recipient, balance);

        emit LogWithdrawExcessTokens(token, balance);

        return balance;
    }

    // ============ Market Functions ============

    function ownerAddMarket(
        Storage.State storage state,
        address token,
        IPriceOracle priceOracle,
        IInterestSetter interestSetter,
        Decimal.D256 memory marginPremium,
        Decimal.D256 memory spreadPremium
    )
        public
    {
        _requireNoMarket(state, token);

        uint256 marketId = state.numMarkets;

        state.numMarkets++;
        state.markets[marketId].token = token;
        state.markets[marketId].index = Interest.newIndex();

        emit LogAddMarket(marketId, token);

        _setPriceOracle(state, marketId, priceOracle);
        _setInterestSetter(state, marketId, interestSetter);
        _setMarginPremium(state, marketId, marginPremium);
        _setSpreadPremium(state, marketId, spreadPremium);
    }

    function ownerSetIsClosing(
        Storage.State storage state,
        uint256 marketId,
        bool isClosing
    )
        public
    {
        _validateMarketId(state, marketId);
        state.markets[marketId].isClosing = isClosing;
        emit LogSetIsClosing(marketId, isClosing);
    }

    function ownerSetPriceOracle(
        Storage.State storage state,
        uint256 marketId,
        IPriceOracle priceOracle
    )
        public
    {
        _validateMarketId(state, marketId);
        _setPriceOracle(state, marketId, priceOracle);
    }

    function ownerSetInterestSetter(
        Storage.State storage state,
        uint256 marketId,
        IInterestSetter interestSetter
    )
        public
    {
        _validateMarketId(state, marketId);
        _setInterestSetter(state, marketId, interestSetter);
    }

    function ownerSetMarginPremium(
        Storage.State storage state,
        uint256 marketId,
        Decimal.D256 memory marginPremium
    )
        public
    {
        _validateMarketId(state, marketId);
        _setMarginPremium(state, marketId, marginPremium);
    }

    function ownerSetSpreadPremium(
        Storage.State storage state,
        uint256 marketId,
        Decimal.D256 memory spreadPremium
    )
        public
    {
        _validateMarketId(state, marketId);
        _setSpreadPremium(state, marketId, spreadPremium);
    }

    // ============ Risk Functions ============

    function ownerSetMarginRatio(
        Storage.State storage state,
        Decimal.D256 memory ratio
    )
        public
    {
        Require.that(
            ratio.value <= state.riskLimits.marginRatioMax,
            FILE,
            "Ratio too high"
        );
        Require.that(
            ratio.value > state.riskParams.liquidationSpread.value,
            FILE,
            "Ratio cannot be <= spread"
        );
        state.riskParams.marginRatio = ratio;
        emit LogSetMarginRatio(ratio);
    }

    function ownerSetLiquidationSpread(
        Storage.State storage state,
        Decimal.D256 memory spread
    )
        public
    {
        Require.that(
            spread.value <= state.riskLimits.liquidationSpreadMax,
            FILE,
            "Spread too high"
        );
        Require.that(
            spread.value < state.riskParams.marginRatio.value,
            FILE,
            "Spread cannot be >= ratio"
        );
        state.riskParams.liquidationSpread = spread;
        emit LogSetLiquidationSpread(spread);
    }

    function ownerSetEarningsRate(
        Storage.State storage state,
        Decimal.D256 memory earningsRate
    )
        public
    {
        Require.that(
            earningsRate.value <= state.riskLimits.earningsRateMax,
            FILE,
            "Rate too high"
        );
        state.riskParams.earningsRate = earningsRate;
        emit LogSetEarningsRate(earningsRate);
    }

    function ownerSetMinBorrowedValue(
        Storage.State storage state,
        Monetary.Value memory minBorrowedValue
    )
        public
    {
        Require.that(
            minBorrowedValue.value <= state.riskLimits.minBorrowedValueMax,
            FILE,
            "Value too high"
        );
        state.riskParams.minBorrowedValue = minBorrowedValue;
        emit LogSetMinBorrowedValue(minBorrowedValue);
    }

    // ============ Global Operator Functions ============

    function ownerSetGlobalOperator(
        Storage.State storage state,
        address operator,
        bool approved
    )
        public
    {
        state.globalOperators[operator] = approved;

        emit LogSetGlobalOperator(operator, approved);
    }

    // ============ Private Functions ============

    function _setPriceOracle(
        Storage.State storage state,
        uint256 marketId,
        IPriceOracle priceOracle
    )
        private
    {
        // require oracle can return non-zero price
        address token = state.markets[marketId].token;

        Require.that(
            priceOracle.getPrice(token).value != 0,
            FILE,
            "Invalid oracle price"
        );

        state.markets[marketId].priceOracle = priceOracle;

        emit LogSetPriceOracle(marketId, address(priceOracle));
    }

    function _setInterestSetter(
        Storage.State storage state,
        uint256 marketId,
        IInterestSetter interestSetter
    )
        private
    {
        // ensure interestSetter can return a value without reverting
        address token = state.markets[marketId].token;
        interestSetter.getInterestRate(token, 0, 0);

        state.markets[marketId].interestSetter = interestSetter;

        emit LogSetInterestSetter(marketId, address(interestSetter));
    }

    function _setMarginPremium(
        Storage.State storage state,
        uint256 marketId,
        Decimal.D256 memory marginPremium
    )
        private
    {
        Require.that(
            marginPremium.value <= state.riskLimits.marginPremiumMax,
            FILE,
            "Margin premium too high"
        );
        state.markets[marketId].marginPremium = marginPremium;

        emit LogSetMarginPremium(marketId, marginPremium);
    }

    function _setSpreadPremium(
        Storage.State storage state,
        uint256 marketId,
        Decimal.D256 memory spreadPremium
    )
        private
    {
        Require.that(
            spreadPremium.value <= state.riskLimits.spreadPremiumMax,
            FILE,
            "Spread premium too high"
        );
        state.markets[marketId].spreadPremium = spreadPremium;

        emit LogSetSpreadPremium(marketId, spreadPremium);
    }

    function _requireNoMarket(
        Storage.State storage state,
        address token
    )
        private
        view
    {
        uint256 numMarkets = state.numMarkets;

        bool marketExists = false;

        for (uint256 m = 0; m < numMarkets; m++) {
            if (state.markets[m].token == token) {
                marketExists = true;
                break;
            }
        }

        Require.that(
            !marketExists,
            FILE,
            "Market exists"
        );
    }

    function _validateMarketId(
        Storage.State storage state,
        uint256 marketId
    )
        private
        view
    {
        Require.that(
            marketId < state.numMarkets,
            FILE,
            "Market OOB",
            marketId
        );
    }
}

// File: contracts/protocol/Admin.sol

/**
 * @title Admin
 * @author dYdX
 *
 * Public functions that allow the privileged owner address to manage Solo
 */
contract Admin is
    State,
    Ownable,
    ReentrancyGuard
{
    // ============ Token Functions ============

    /**
     * Withdraw an ERC20 token for which there is an associated market. Only excess tokens can be
     * withdrawn. The number of excess tokens is calculated by taking the current number of tokens
     * held in Solo, adding the number of tokens owed to Solo by borrowers, and subtracting the
     * number of tokens owed to suppliers by Solo.
     */
    function ownerWithdrawExcessTokens(
        uint256 marketId,
        address recipient
    )
        public
        onlyOwner
        nonReentrant
        returns (uint256)
    {
        return AdminImpl.ownerWithdrawExcessTokens(
            g_state,
            marketId,
            recipient
        );
    }

    /**
     * Withdraw an ERC20 token for which there is no associated market.
     */
    function ownerWithdrawUnsupportedTokens(
        address token,
        address recipient
    )
        public
        onlyOwner
        nonReentrant
        returns (uint256)
    {
        return AdminImpl.ownerWithdrawUnsupportedTokens(
            g_state,
            token,
            recipient
        );
    }

    // ============ Market Functions ============

    /**
     * Add a new market to Solo. Must be for a previously-unsupported ERC20 token.
     */
    function ownerAddMarket(
        address token,
        IPriceOracle priceOracle,
        IInterestSetter interestSetter,
        Decimal.D256 memory marginPremium,
        Decimal.D256 memory spreadPremium
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerAddMarket(
            g_state,
            token,
            priceOracle,
            interestSetter,
            marginPremium,
            spreadPremium
        );
    }

    /**
     * Set (or unset) the status of a market to "closing". The borrowedValue of a market cannot
     * increase while its status is "closing".
     */
    function ownerSetIsClosing(
        uint256 marketId,
        bool isClosing
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetIsClosing(
            g_state,
            marketId,
            isClosing
        );
    }

    /**
     * Set the price oracle for a market.
     */
    function ownerSetPriceOracle(
        uint256 marketId,
        IPriceOracle priceOracle
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetPriceOracle(
            g_state,
            marketId,
            priceOracle
        );
    }

    /**
     * Set the interest-setter for a market.
     */
    function ownerSetInterestSetter(
        uint256 marketId,
        IInterestSetter interestSetter
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetInterestSetter(
            g_state,
            marketId,
            interestSetter
        );
    }

    /**
     * Set a premium on the minimum margin-ratio for a market. This makes it so that any positions
     * that include this market require a higher collateralization to avoid being liquidated.
     */
    function ownerSetMarginPremium(
        uint256 marketId,
        Decimal.D256 memory marginPremium
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetMarginPremium(
            g_state,
            marketId,
            marginPremium
        );
    }

    /**
     * Set a premium on the liquidation spread for a market. This makes it so that any liquidations
     * that include this market have a higher spread than the global default.
     */
    function ownerSetSpreadPremium(
        uint256 marketId,
        Decimal.D256 memory spreadPremium
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetSpreadPremium(
            g_state,
            marketId,
            spreadPremium
        );
    }

    // ============ Risk Functions ============

    /**
     * Set the global minimum margin-ratio that every position must maintain to prevent being
     * liquidated.
     */
    function ownerSetMarginRatio(
        Decimal.D256 memory ratio
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetMarginRatio(
            g_state,
            ratio
        );
    }

    /**
     * Set the global liquidation spread. This is the spread between oracle prices that incentivizes
     * the liquidation of risky positions.
     */
    function ownerSetLiquidationSpread(
        Decimal.D256 memory spread
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetLiquidationSpread(
            g_state,
            spread
        );
    }

    /**
     * Set the global earnings-rate variable that determines what percentage of the interest paid
     * by borrowers gets passed-on to suppliers.
     */
    function ownerSetEarningsRate(
        Decimal.D256 memory earningsRate
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetEarningsRate(
            g_state,
            earningsRate
        );
    }

    /**
     * Set the global minimum-borrow value which is the minimum value of any new borrow on Solo.
     */
    function ownerSetMinBorrowedValue(
        Monetary.Value memory minBorrowedValue
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetMinBorrowedValue(
            g_state,
            minBorrowedValue
        );
    }

    // ============ Global Operator Functions ============

    /**
     * Approve (or disapprove) an address that is permissioned to be an operator for all accounts in
     * Solo. Intended only to approve smart-contracts.
     */
    function ownerSetGlobalOperator(
        address operator,
        bool approved
    )
        public
        onlyOwner
        nonReentrant
    {
        AdminImpl.ownerSetGlobalOperator(
            g_state,
            operator,
            approved
        );
    }
}

// File: contracts/protocol/Getters.sol

/**
 * @title Getters
 * @author dYdX
 *
 * Public read-only functions that allow transparency into the state of Solo
 */
contract Getters is
    State
{
    using Cache for Cache.MarketCache;
    using Storage for Storage.State;
    using Types for Types.Par;

    // ============ Constants ============

    bytes32 FILE = "Getters";

    // ============ Getters for Risk ============

    /**
     * Get the global minimum margin-ratio that every position must maintain to prevent being
     * liquidated.
     *
     * @return  The global margin-ratio
     */
    function getMarginRatio()
        public
        view
        returns (Decimal.D256 memory)
    {
        return g_state.riskParams.marginRatio;
    }

    /**
     * Get the global liquidation spread. This is the spread between oracle prices that incentivizes
     * the liquidation of risky positions.
     *
     * @return  The global liquidation spread
     */
    function getLiquidationSpread()
        public
        view
        returns (Decimal.D256 memory)
    {
        return g_state.riskParams.liquidationSpread;
    }

    /**
     * Get the global earnings-rate variable that determines what percentage of the interest paid
     * by borrowers gets passed-on to suppliers.
     *
     * @return  The global earnings rate
     */
    function getEarningsRate()
        public
        view
        returns (Decimal.D256 memory)
    {
        return g_state.riskParams.earningsRate;
    }

    /**
     * Get the global minimum-borrow value which is the minimum value of any new borrow on Solo.
     *
     * @return  The global minimum borrow value
     */
    function getMinBorrowedValue()
        public
        view
        returns (Monetary.Value memory)
    {
        return g_state.riskParams.minBorrowedValue;
    }

    /**
     * Get all risk parameters in a single struct.
     *
     * @return  All global risk parameters
     */
    function getRiskParams()
        public
        view
        returns (Storage.RiskParams memory)
    {
        return g_state.riskParams;
    }

    /**
     * Get all risk parameter limits in a single struct. These are the maximum limits at which the
     * risk parameters can be set by the admin of Solo.
     *
     * @return  All global risk parameter limnits
     */
    function getRiskLimits()
        public
        view
        returns (Storage.RiskLimits memory)
    {
        return g_state.riskLimits;
    }

    // ============ Getters for Markets ============

    /**
     * Get the total number of markets.
     *
     * @return  The number of markets
     */
    function getNumMarkets()
        public
        view
        returns (uint256)
    {
        return g_state.numMarkets;
    }

    /**
     * Get the ERC20 token address for a market.
     *
     * @param  marketId  The market to query
     * @return           The token address
     */
    function getMarketTokenAddress(
        uint256 marketId
    )
        public
        view
        returns (address)
    {
        _requireValidMarket(marketId);
        return g_state.getToken(marketId);
    }

    /**
     * Get the total principal amounts (borrowed and supplied) for a market.
     *
     * @param  marketId  The market to query
     * @return           The total principal amounts
     */
    function getMarketTotalPar(
        uint256 marketId
    )
        public
        view
        returns (Types.TotalPar memory)
    {
        _requireValidMarket(marketId);
        return g_state.getTotalPar(marketId);
    }

    /**
     * Get the most recently cached interest index for a market.
     *
     * @param  marketId  The market to query
     * @return           The most recent index
     */
    function getMarketCachedIndex(
        uint256 marketId
    )
        public
        view
        returns (Interest.Index memory)
    {
        _requireValidMarket(marketId);
        return g_state.getIndex(marketId);
    }

    /**
     * Get the interest index for a market if it were to be updated right now.
     *
     * @param  marketId  The market to query
     * @return           The estimated current index
     */
    function getMarketCurrentIndex(
        uint256 marketId
    )
        public
        view
        returns (Interest.Index memory)
    {
        _requireValidMarket(marketId);
        return g_state.fetchNewIndex(marketId, g_state.getIndex(marketId));
    }

    /**
     * Get the price oracle address for a market.
     *
     * @param  marketId  The market to query
     * @return           The price oracle address
     */
    function getMarketPriceOracle(
        uint256 marketId
    )
        public
        view
        returns (IPriceOracle)
    {
        _requireValidMarket(marketId);
        return g_state.markets[marketId].priceOracle;
    }

    /**
     * Get the interest-setter address for a market.
     *
     * @param  marketId  The market to query
     * @return           The interest-setter address
     */
    function getMarketInterestSetter(
        uint256 marketId
    )
        public
        view
        returns (IInterestSetter)
    {
        _requireValidMarket(marketId);
        return g_state.markets[marketId].interestSetter;
    }

    /**
     * Get the margin premium for a market. A margin premium makes it so that any positions that
     * include the market require a higher collateralization to avoid being liquidated.
     *
     * @param  marketId  The market to query
     * @return           The market's margin premium
     */
    function getMarketMarginPremium(
        uint256 marketId
    )
        public
        view
        returns (Decimal.D256 memory)
    {
        _requireValidMarket(marketId);
        return g_state.markets[marketId].marginPremium;
    }

    /**
     * Get the spread premium for a market. A spread premium makes it so that any liquidations
     * that include the market have a higher spread than the global default.
     *
     * @param  marketId  The market to query
     * @return           The market's spread premium
     */
    function getMarketSpreadPremium(
        uint256 marketId
    )
        public
        view
        returns (Decimal.D256 memory)
    {
        _requireValidMarket(marketId);
        return g_state.markets[marketId].spreadPremium;
    }

    /**
     * Return true if a particular market is in closing mode. Additional borrows cannot be taken
     * from a market that is closing.
     *
     * @param  marketId  The market to query
     * @return           True if the market is closing
     */
    function getMarketIsClosing(
        uint256 marketId
    )
        public
        view
        returns (bool)
    {
        _requireValidMarket(marketId);
        return g_state.markets[marketId].isClosing;
    }

    /**
     * Get the price of the token for a market.
     *
     * @param  marketId  The market to query
     * @return           The price of each atomic unit of the token
     */
    function getMarketPrice(
        uint256 marketId
    )
        public
        view
        returns (Monetary.Price memory)
    {
        _requireValidMarket(marketId);
        return g_state.fetchPrice(marketId);
    }

    /**
     * Get the current borrower interest rate for a market.
     *
     * @param  marketId  The market to query
     * @return           The current interest rate
     */
    function getMarketInterestRate(
        uint256 marketId
    )
        public
        view
        returns (Interest.Rate memory)
    {
        _requireValidMarket(marketId);
        return g_state.fetchInterestRate(
            marketId,
            g_state.getIndex(marketId)
        );
    }

    /**
     * Get the adjusted liquidation spread for some market pair. This is equal to the global
     * liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
     *
     * @param  heldMarketId  The market for which the account has collateral
     * @param  owedMarketId  The market for which the account has borrowed tokens
     * @return               The adjusted liquidation spread
     */
    function getLiquidationSpreadForPair(
        uint256 heldMarketId,
        uint256 owedMarketId
    )
        public
        view
        returns (Decimal.D256 memory)
    {
        _requireValidMarket(heldMarketId);
        _requireValidMarket(owedMarketId);
        return g_state.getLiquidationSpreadForPair(heldMarketId, owedMarketId);
    }

    /**
     * Get basic information about a particular market.
     *
     * @param  marketId  The market to query
     * @return           A Storage.Market struct with the current state of the market
     */
    function getMarket(
        uint256 marketId
    )
        public
        view
        returns (Storage.Market memory)
    {
        _requireValidMarket(marketId);
        return g_state.markets[marketId];
    }

    /**
     * Get comprehensive information about a particular market.
     *
     * @param  marketId  The market to query
     * @return           A tuple containing the values:
     *                    - A Storage.Market struct with the current state of the market
     *                    - The current estimated interest index
     *                    - The current token price
     *                    - The current market interest rate
     */
    function getMarketWithInfo(
        uint256 marketId
    )
        public
        view
        returns (
            Storage.Market memory,
            Interest.Index memory,
            Monetary.Price memory,
            Interest.Rate memory
        )
    {
        _requireValidMarket(marketId);
        return (
            getMarket(marketId),
            getMarketCurrentIndex(marketId),
            getMarketPrice(marketId),
            getMarketInterestRate(marketId)
        );
    }

    /**
     * Get the number of excess tokens for a market. The number of excess tokens is calculated
     * by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
     * by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
     *
     * @param  marketId  The market to query
     * @return           The number of excess tokens
     */
    function getNumExcessTokens(
        uint256 marketId
    )
        public
        view
        returns (Types.Wei memory)
    {
        _requireValidMarket(marketId);
        return g_state.getNumExcessTokens(marketId);
    }

    // ============ Getters for Accounts ============

    /**
     * Get the principal value for a particular account and market.
     *
     * @param  account   The account to query
     * @param  marketId  The market to query
     * @return           The principal value
     */
    function getAccountPar(
        Account.Info memory account,
        uint256 marketId
    )
        public
        view
        returns (Types.Par memory)
    {
        _requireValidMarket(marketId);
        return g_state.getPar(account, marketId);
    }

    /**
     * Get the token balance for a particular account and market.
     *
     * @param  account   The account to query
     * @param  marketId  The market to query
     * @return           The token amount
     */
    function getAccountWei(
        Account.Info memory account,
        uint256 marketId
    )
        public
        view
        returns (Types.Wei memory)
    {
        _requireValidMarket(marketId);
        return Interest.parToWei(
            g_state.getPar(account, marketId),
            g_state.fetchNewIndex(marketId, g_state.getIndex(marketId))
        );
    }

    /**
     * Get the status of an account (Normal, Liquidating, or Vaporizing).
     *
     * @param  account  The account to query
     * @return          The account's status
     */
    function getAccountStatus(
        Account.Info memory account
    )
        public
        view
        returns (Account.Status)
    {
        return g_state.getStatus(account);
    }

    /**
     * Get the total supplied and total borrowed value of an account.
     *
     * @param  account  The account to query
     * @return          The following values:
     *                   - The supplied value of the account
     *                   - The borrowed value of the account
     */
    function getAccountValues(
        Account.Info memory account
    )
        public
        view
        returns (Monetary.Value memory, Monetary.Value memory)
    {
        return getAccountValuesInternal(account, /* adjustForLiquidity = */ false);
    }

    /**
     * Get the total supplied and total borrowed values of an account adjusted by the marginPremium
     * of each market. Supplied values are divided by (1 + marginPremium) for each market and
     * borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
     * adjusted values gives the margin-ratio of the account which will be compared to the global
     * margin-ratio when determining if the account can be liquidated.
     *
     * @param  account  The account to query
     * @return          The following values:
     *                   - The supplied value of the account (adjusted for marginPremium)
     *                   - The borrowed value of the account (adjusted for marginPremium)
     */
    function getAdjustedAccountValues(
        Account.Info memory account
    )
        public
        view
        returns (Monetary.Value memory, Monetary.Value memory)
    {
        return getAccountValuesInternal(account, /* adjustForLiquidity = */ true);
    }

    /**
     * Get an account's summary for each market.
     *
     * @param  account  The account to query
     * @return          The following values:
     *                   - The ERC20 token address for each market
     *                   - The account's principal value for each market
     *                   - The account's (supplied or borrowed) number of tokens for each market
     */
    function getAccountBalances(
        Account.Info memory account
    )
        public
        view
        returns (
            address[] memory,
            Types.Par[] memory,
            Types.Wei[] memory
        )
    {
        uint256 numMarkets = g_state.numMarkets;
        address[] memory tokens = new address[](numMarkets);
        Types.Par[] memory pars = new Types.Par[](numMarkets);
        Types.Wei[] memory weis = new Types.Wei[](numMarkets);

        for (uint256 m = 0; m < numMarkets; m++) {
            tokens[m] = getMarketTokenAddress(m);
            pars[m] = getAccountPar(account, m);
            weis[m] = getAccountWei(account, m);
        }

        return (
            tokens,
            pars,
            weis
        );
    }

    // ============ Getters for Permissions ============

    /**
     * Return true if a particular address is approved as an operator for an owner's accounts.
     * Approved operators can act on the accounts of the owner as if it were the operator's own.
     *
     * @param  owner     The owner of the accounts
     * @param  operator  The possible operator
     * @return           True if operator is approved for owner's accounts
     */
    function getIsLocalOperator(
        address owner,
        address operator
    )
        public
        view
        returns (bool)
    {
        return g_state.isLocalOperator(owner, operator);
    }

    /**
     * Return true if a particular address is approved as a global operator. Such an address can
     * act on any account as if it were the operator's own.
     *
     * @param  operator  The address to query
     * @return           True if operator is a global operator
     */
    function getIsGlobalOperator(
        address operator
    )
        public
        view
        returns (bool)
    {
        return g_state.isGlobalOperator(operator);
    }

    // ============ Private Helper Functions ============

    /**
     * Revert if marketId is invalid.
     */
    function _requireValidMarket(
        uint256 marketId
    )
        private
        view
    {
        Require.that(
            marketId < g_state.numMarkets,
            FILE,
            "Market OOB"
        );
    }

    /**
     * Private helper for getting the monetary values of an account.
     */
    function getAccountValuesInternal(
        Account.Info memory account,
        bool adjustForLiquidity
    )
        private
        view
        returns (Monetary.Value memory, Monetary.Value memory)
    {
        uint256 numMarkets = g_state.numMarkets;

        // populate cache
        Cache.MarketCache memory cache = Cache.create(numMarkets);
        for (uint256 m = 0; m < numMarkets; m++) {
            if (!g_state.getPar(account, m).isZero()) {
                cache.addMarket(g_state, m);
            }
        }

        return g_state.getAccountValues(account, cache, adjustForLiquidity);
    }
}

// File: contracts/protocol/interfaces/IAutoTrader.sol

/**
 * @title IAutoTrader
 * @author dYdX
 *
 * Interface that Auto-Traders for Solo must implement in order to approve trades.
 */
contract IAutoTrader {

    // ============ Public Functions ============

    /**
     * Allows traders to make trades approved by this smart contract. The active trader's account is
     * the takerAccount and the passive account (for which this contract approves trades
     * on-behalf-of) is the makerAccount.
     *
     * @param  inputMarketId   The market for which the trader specified the original amount
     * @param  outputMarketId  The market for which the trader wants the resulting amount specified
     * @param  makerAccount    The account for which this contract is making trades
     * @param  takerAccount    The account requesting the trade
     * @param  oldInputPar     The old principal amount for the makerAccount for the inputMarketId
     * @param  newInputPar     The new principal amount for the makerAccount for the inputMarketId
     * @param  inputWei        The change in token amount for the makerAccount for the inputMarketId
     * @param  data            Arbitrary data passed in by the trader
     * @return                 The AssetAmount for the makerAccount for the outputMarketId
     */
    function getTradeCost(
        uint256 inputMarketId,
        uint256 outputMarketId,
        Account.Info memory makerAccount,
        Account.Info memory takerAccount,
        Types.Par memory oldInputPar,
        Types.Par memory newInputPar,
        Types.Wei memory inputWei,
        bytes memory data
    )
        public
        returns (Types.AssetAmount memory);
}

// File: contracts/protocol/interfaces/ICallee.sol

/**
 * @title ICallee
 * @author dYdX
 *
 * Interface that Callees for Solo must implement in order to ingest data.
 */
contract ICallee {

    // ============ Public Functions ============

    /**
     * Allows users to send this contract arbitrary data.
     *
     * @param  sender       The msg.sender to Solo
     * @param  accountInfo  The account from which the data is being sent
     * @param  data         Arbitrary data given by the sender
     */
    function callFunction(
        address sender,
        Account.Info memory accountInfo,
        bytes memory data
    )
        public;
}

// File: contracts/protocol/lib/Actions.sol

/**
 * @title Actions
 * @author dYdX
 *
 * Library that defines and parses valid Actions
 */
library Actions {

    // ============ Constants ============

    bytes32 constant FILE = "Actions";

    // ============ Enums ============

    enum ActionType {
        Deposit,   // supply tokens
        Withdraw,  // borrow tokens
        Transfer,  // transfer balance between accounts
        Buy,       // buy an amount of some token (externally)
        Sell,      // sell an amount of some token (externally)
        Trade,     // trade tokens against another account
        Liquidate, // liquidate an undercollateralized or expiring account
        Vaporize,  // use excess tokens to zero-out a completely negative account
        Call       // send arbitrary data to an address
    }

    enum AccountLayout {
        OnePrimary,
        TwoPrimary,
        PrimaryAndSecondary
    }

    enum MarketLayout {
        ZeroMarkets,
        OneMarket,
        TwoMarkets
    }

    // ============ Structs ============

    /*
     * Arguments that are passed to Solo in an ordered list as part of a single operation.
     * Each ActionArgs has an actionType which specifies which action struct that this data will be
     * parsed into before being processed.
     */
    struct ActionArgs {
        ActionType actionType;
        uint256 accountId;
        Types.AssetAmount amount;
        uint256 primaryMarketId;
        uint256 secondaryMarketId;
        address otherAddress;
        uint256 otherAccountId;
        bytes data;
    }

    // ============ Action Types ============

    /*
     * Moves tokens from an address to Solo. Can either repay a borrow or provide additional supply.
     */
    struct DepositArgs {
        Types.AssetAmount amount;
        Account.Info account;
        uint256 market;
        address from;
    }

    /*
     * Moves tokens from Solo to another address. Can either borrow tokens or reduce the amount
     * previously supplied.
     */
    struct WithdrawArgs {
        Types.AssetAmount amount;
        Account.Info account;
        uint256 market;
        address to;
    }

    /*
     * Transfers balance between two accounts. The msg.sender must be an operator for both accounts.
     * The amount field applies to accountOne.
     * This action does not require any token movement since the trade is done internally to Solo.
     */
    struct TransferArgs {
        Types.AssetAmount amount;
        Account.Info accountOne;
        Account.Info accountTwo;
        uint256 market;
    }

    /*
     * Acquires a certain amount of tokens by spending other tokens. Sends takerMarket tokens to the
     * specified exchangeWrapper contract and expects makerMarket tokens in return. The amount field
     * applies to the makerMarket.
     */
    struct BuyArgs {
        Types.AssetAmount amount;
        Account.Info account;
        uint256 makerMarket;
        uint256 takerMarket;
        address exchangeWrapper;
        bytes orderData;
    }

    /*
     * Spends a certain amount of tokens to acquire other tokens. Sends takerMarket tokens to the
     * specified exchangeWrapper and expects makerMarket tokens in return. The amount field applies
     * to the takerMarket.
     */
    struct SellArgs {
        Types.AssetAmount amount;
        Account.Info account;
        uint256 takerMarket;
        uint256 makerMarket;
        address exchangeWrapper;
        bytes orderData;
    }

    /*
     * Trades balances between two accounts using any external contract that implements the
     * AutoTrader interface. The AutoTrader contract must be an operator for the makerAccount (for
     * which it is trading on-behalf-of). The amount field applies to the makerAccount and the
     * inputMarket. This proposed change to the makerAccount is passed to the AutoTrader which will
     * quote a change for the makerAccount in the outputMarket (or will disallow the trade).
     * This action does not require any token movement since the trade is done internally to Solo.
     */
    struct TradeArgs {
        Types.AssetAmount amount;
        Account.Info takerAccount;
        Account.Info makerAccount;
        uint256 inputMarket;
        uint256 outputMarket;
        address autoTrader;
        bytes tradeData;
    }

    /*
     * Each account must maintain a certain margin-ratio (specified globally). If the account falls
     * below this margin-ratio, it can be liquidated by any other account. This allows anyone else
     * (arbitrageurs) to repay any borrowed asset (owedMarket) of the liquidating account in
     * exchange for any collateral asset (heldMarket) of the liquidAccount. The ratio is determined
     * by the price ratio (given by the oracles) plus a spread (specified globally). Liquidating an
     * account also sets a flag on the account that the account is being liquidated. This allows
     * anyone to continue liquidating the account until there are no more borrows being taken by the
     * liquidating account. Liquidators do not have to liquidate the entire account all at once but
     * can liquidate as much as they choose. The liquidating flag allows liquidators to continue
     * liquidating the account even if it becomes collateralized through partial liquidation or
     * price movement.
     */
    struct LiquidateArgs {
        Types.AssetAmount amount;
        Account.Info solidAccount;
        Account.Info liquidAccount;
        uint256 owedMarket;
        uint256 heldMarket;
    }

    /*
     * Similar to liquidate, but vaporAccounts are accounts that have only negative balances
     * remaining. The arbitrageur pays back the negative asset (owedMarket) of the vaporAccount in
     * exchange for a collateral asset (heldMarket) at a favorable spread. However, since the
     * liquidAccount has no collateral assets, the collateral must come from Solo's excess tokens.
     */
    struct VaporizeArgs {
        Types.AssetAmount amount;
        Account.Info solidAccount;
        Account.Info vaporAccount;
        uint256 owedMarket;
        uint256 heldMarket;
    }

    /*
     * Passes arbitrary bytes of data to an external contract that implements the Callee interface.
     * Does not change any asset amounts. This function may be useful for setting certain variables
     * on layer-two contracts for certain accounts without having to make a separate Ethereum
     * transaction for doing so. Also, the second-layer contracts can ensure that the call is coming
     * from an operator of the particular account.
     */
    struct CallArgs {
        Account.Info account;
        address callee;
        bytes data;
    }

    // ============ Helper Functions ============

    function getMarketLayout(
        ActionType actionType
    )
        internal
        pure
        returns (MarketLayout)
    {
        if (
            actionType == Actions.ActionType.Deposit
            || actionType == Actions.ActionType.Withdraw
            || actionType == Actions.ActionType.Transfer
        ) {
            return MarketLayout.OneMarket;
        }
        else if (actionType == Actions.ActionType.Call) {
            return MarketLayout.ZeroMarkets;
        }
        return MarketLayout.TwoMarkets;
    }

    function getAccountLayout(
        ActionType actionType
    )
        internal
        pure
        returns (AccountLayout)
    {
        if (
            actionType == Actions.ActionType.Transfer
            || actionType == Actions.ActionType.Trade
        ) {
            return AccountLayout.TwoPrimary;
        } else if (
            actionType == Actions.ActionType.Liquidate
            || actionType == Actions.ActionType.Vaporize
        ) {
            return AccountLayout.PrimaryAndSecondary;
        }
        return AccountLayout.OnePrimary;
    }

    // ============ Parsing Functions ============

    function parseDepositArgs(
        Account.Info[] memory accounts,
        ActionArgs memory args
    )
        internal
        pure
        returns (DepositArgs memory)
    {
        assert(args.actionType == ActionType.Deposit);
        return DepositArgs({
            amount: args.amount,
            account: accounts[args.accountId],
            market: args.primaryMarketId,
            from: args.otherAddress
        });
    }

    function parseWithdrawArgs(
        Account.Info[] memory accounts,
        ActionArgs memory args
    )
        internal
        pure
        returns (WithdrawArgs memory)
    {
        assert(args.actionType == ActionType.Withdraw);
        return WithdrawArgs({
            amount: args.amount,
            account: accounts[args.accountId],
            market: args.primaryMarketId,
            to: args.otherAddress
        });
    }

    function parseTransferArgs(
        Account.Info[] memory accounts,
        ActionArgs memory args
    )
        internal
        pure
        returns (TransferArgs memory)
    {
        assert(args.actionType == ActionType.Transfer);
        return TransferArgs({
            amount: args.amount,
            accountOne: accounts[args.accountId],
            accountTwo: accounts[args.otherAccountId],
            market: args.primaryMarketId
        });
    }

    function parseBuyArgs(
        Account.Info[] memory accounts,
        ActionArgs memory args
    )
        internal
        pure
        returns (BuyArgs memory)
    {
        assert(args.actionType == ActionType.Buy);
        return BuyArgs({
            amount: args.amount,
            account: accounts[args.accountId],
            makerMarket: args.primaryMarketId,
            takerMarket: args.secondaryMarketId,
            exchangeWrapper: args.otherAddress,
            orderData: args.data
        });
    }

    function parseSellArgs(
        Account.Info[] memory accounts,
        ActionArgs memory args
    )
        internal
        pure
        returns (SellArgs memory)
    {
        assert(args.actionType == ActionType.Sell);
        return SellArgs({
            amount: args.amount,
            account: accounts[args.accountId],
            takerMarket: args.primaryMarketId,
            makerMarket: args.secondaryMarketId,
            exchangeWrapper: args.otherAddress,
            orderData: args.data
        });
    }

    function parseTradeArgs(
        Account.Info[] memory accounts,
        ActionArgs memory args
    )
        internal
        pure
        returns (TradeArgs memory)
    {
        assert(args.actionType == ActionType.Trade);
        return TradeArgs({
            amount: args.amount,
            takerAccount: accounts[args.accountId],
            makerAccount: accounts[args.otherAccountId],
            inputMarket: args.primaryMarketId,
            outputMarket: args.secondaryMarketId,
            autoTrader: args.otherAddress,
            tradeData: args.data
        });
    }

    function parseLiquidateArgs(
        Account.Info[] memory accounts,
        ActionArgs memory args
    )
        internal
        pure
        returns (LiquidateArgs memory)
    {
        assert(args.actionType == ActionType.Liquidate);
        return LiquidateArgs({
            amount: args.amount,
            solidAccount: accounts[args.accountId],
            liquidAccount: accounts[args.otherAccountId],
            owedMarket: args.primaryMarketId,
            heldMarket: args.secondaryMarketId
        });
    }

    function parseVaporizeArgs(
        Account.Info[] memory accounts,
        ActionArgs memory args
    )
        internal
        pure
        returns (VaporizeArgs memory)
    {
        assert(args.actionType == ActionType.Vaporize);
        return VaporizeArgs({
            amount: args.amount,
            solidAccount: accounts[args.accountId],
            vaporAccount: accounts[args.otherAccountId],
            owedMarket: args.primaryMarketId,
            heldMarket: args.secondaryMarketId
        });
    }

    function parseCallArgs(
        Account.Info[] memory accounts,
        ActionArgs memory args
    )
        internal
        pure
        returns (CallArgs memory)
    {
        assert(args.actionType == ActionType.Call);
        return CallArgs({
            account: accounts[args.accountId],
            callee: args.otherAddress,
            data: args.data
        });
    }
}

// File: contracts/protocol/lib/Events.sol

/**
 * @title Events
 * @author dYdX
 *
 * Library to parse and emit logs from which the state of all accounts and indexes can be followed
 */
library Events {
    using Types for Types.Wei;
    using Storage for Storage.State;

    // ============ Events ============

    event LogIndexUpdate(
        uint256 indexed market,
        Interest.Index index
    );

    event LogOperation(
        address sender
    );

    event LogDeposit(
        address indexed accountOwner,
        uint256 accountNumber,
        uint256 market,
        BalanceUpdate update,
        address from
    );

    event LogWithdraw(
        address indexed accountOwner,
        uint256 accountNumber,
        uint256 market,
        BalanceUpdate update,
        address to
    );

    event LogTransfer(
        address indexed accountOneOwner,
        uint256 accountOneNumber,
        address indexed accountTwoOwner,
        uint256 accountTwoNumber,
        uint256 market,
        BalanceUpdate updateOne,
        BalanceUpdate updateTwo
    );

    event LogBuy(
        address indexed accountOwner,
        uint256 accountNumber,
        uint256 takerMarket,
        uint256 makerMarket,
        BalanceUpdate takerUpdate,
        BalanceUpdate makerUpdate,
        address exchangeWrapper
    );

    event LogSell(
        address indexed accountOwner,
        uint256 accountNumber,
        uint256 takerMarket,
        uint256 makerMarket,
        BalanceUpdate takerUpdate,
        BalanceUpdate makerUpdate,
        address exchangeWrapper
    );

    event LogTrade(
        address indexed takerAccountOwner,
        uint256 takerAccountNumber,
        address indexed makerAccountOwner,
        uint256 makerAccountNumber,
        uint256 inputMarket,
        uint256 outputMarket,
        BalanceUpdate takerInputUpdate,
        BalanceUpdate takerOutputUpdate,
        BalanceUpdate makerInputUpdate,
        BalanceUpdate makerOutputUpdate,
        address autoTrader
    );

    event LogCall(
        address indexed accountOwner,
        uint256 accountNumber,
        address callee
    );

    event LogLiquidate(
        address indexed solidAccountOwner,
        uint256 solidAccountNumber,
        address indexed liquidAccountOwner,
        uint256 liquidAccountNumber,
        uint256 heldMarket,
        uint256 owedMarket,
        BalanceUpdate solidHeldUpdate,
        BalanceUpdate solidOwedUpdate,
        BalanceUpdate liquidHeldUpdate,
        BalanceUpdate liquidOwedUpdate
    );

    event LogVaporize(
        address indexed solidAccountOwner,
        uint256 solidAccountNumber,
        address indexed vaporAccountOwner,
        uint256 vaporAccountNumber,
        uint256 heldMarket,
        uint256 owedMarket,
        BalanceUpdate solidHeldUpdate,
        BalanceUpdate solidOwedUpdate,
        BalanceUpdate vaporOwedUpdate
    );

    // ============ Structs ============

    struct BalanceUpdate {
        Types.Wei deltaWei;
        Types.Par newPar;
    }

    // ============ Internal Functions ============

    function logIndexUpdate(
        uint256 marketId,
        Interest.Index memory index
    )
        internal
    {
        emit LogIndexUpdate(
            marketId,
            index
        );
    }

    function logOperation()
        internal
    {
        emit LogOperation(msg.sender);
    }

    function logDeposit(
        Storage.State storage state,
        Actions.DepositArgs memory args,
        Types.Wei memory deltaWei
    )
        internal
    {
        emit LogDeposit(
            args.account.owner,
            args.account.number,
            args.market,
            getBalanceUpdate(
                state,
                args.account,
                args.market,
                deltaWei
            ),
            args.from
        );
    }

    function logWithdraw(
        Storage.State storage state,
        Actions.WithdrawArgs memory args,
        Types.Wei memory deltaWei
    )
        internal
    {
        emit LogWithdraw(
            args.account.owner,
            args.account.number,
            args.market,
            getBalanceUpdate(
                state,
                args.account,
                args.market,
                deltaWei
            ),
            args.to
        );
    }

    function logTransfer(
        Storage.State storage state,
        Actions.TransferArgs memory args,
        Types.Wei memory deltaWei
    )
        internal
    {
        emit LogTransfer(
            args.accountOne.owner,
            args.accountOne.number,
            args.accountTwo.owner,
            args.accountTwo.number,
            args.market,
            getBalanceUpdate(
                state,
                args.accountOne,
                args.market,
                deltaWei
            ),
            getBalanceUpdate(
                state,
                args.accountTwo,
                args.market,
                deltaWei.negative()
            )
        );
    }

    function logBuy(
        Storage.State storage state,
        Actions.BuyArgs memory args,
        Types.Wei memory takerWei,
        Types.Wei memory makerWei
    )
        internal
    {
        emit LogBuy(
            args.account.owner,
            args.account.number,
            args.takerMarket,
            args.makerMarket,
            getBalanceUpdate(
                state,
                args.account,
                args.takerMarket,
                takerWei
            ),
            getBalanceUpdate(
                state,
                args.account,
                args.makerMarket,
                makerWei
            ),
            args.exchangeWrapper
        );
    }

    function logSell(
        Storage.State storage state,
        Actions.SellArgs memory args,
        Types.Wei memory takerWei,
        Types.Wei memory makerWei
    )
        internal
    {
        emit LogSell(
            args.account.owner,
            args.account.number,
            args.takerMarket,
            args.makerMarket,
            getBalanceUpdate(
                state,
                args.account,
                args.takerMarket,
                takerWei
            ),
            getBalanceUpdate(
                state,
                args.account,
                args.makerMarket,
                makerWei
            ),
            args.exchangeWrapper
        );
    }

    function logTrade(
        Storage.State storage state,
        Actions.TradeArgs memory args,
        Types.Wei memory inputWei,
        Types.Wei memory outputWei
    )
        internal
    {
        BalanceUpdate[4] memory updates = [
            getBalanceUpdate(
                state,
                args.takerAccount,
                args.inputMarket,
                inputWei.negative()
            ),
            getBalanceUpdate(
                state,
                args.takerAccount,
                args.outputMarket,
                outputWei.negative()
            ),
            getBalanceUpdate(
                state,
                args.makerAccount,
                args.inputMarket,
                inputWei
            ),
            getBalanceUpdate(
                state,
                args.makerAccount,
                args.outputMarket,
                outputWei
            )
        ];

        emit LogTrade(
            args.takerAccount.owner,
            args.takerAccount.number,
            args.makerAccount.owner,
            args.makerAccount.number,
            args.inputMarket,
            args.outputMarket,
            updates[0],
            updates[1],
            updates[2],
            updates[3],
            args.autoTrader
        );
    }

    function logCall(
        Actions.CallArgs memory args
    )
        internal
    {
        emit LogCall(
            args.account.owner,
            args.account.number,
            args.callee
        );
    }

    function logLiquidate(
        Storage.State storage state,
        Actions.LiquidateArgs memory args,
        Types.Wei memory heldWei,
        Types.Wei memory owedWei
    )
        internal
    {
        BalanceUpdate memory solidHeldUpdate = getBalanceUpdate(
            state,
            args.solidAccount,
            args.heldMarket,
            heldWei.negative()
        );
        BalanceUpdate memory solidOwedUpdate = getBalanceUpdate(
            state,
            args.solidAccount,
            args.owedMarket,
            owedWei.negative()
        );
        BalanceUpdate memory liquidHeldUpdate = getBalanceUpdate(
            state,
            args.liquidAccount,
            args.heldMarket,
            heldWei
        );
        BalanceUpdate memory liquidOwedUpdate = getBalanceUpdate(
            state,
            args.liquidAccount,
            args.owedMarket,
            owedWei
        );

        emit LogLiquidate(
            args.solidAccount.owner,
            args.solidAccount.number,
            args.liquidAccount.owner,
            args.liquidAccount.number,
            args.heldMarket,
            args.owedMarket,
            solidHeldUpdate,
            solidOwedUpdate,
            liquidHeldUpdate,
            liquidOwedUpdate
        );
    }

    function logVaporize(
        Storage.State storage state,
        Actions.VaporizeArgs memory args,
        Types.Wei memory heldWei,
        Types.Wei memory owedWei,
        Types.Wei memory excessWei
    )
        internal
    {
        BalanceUpdate memory solidHeldUpdate = getBalanceUpdate(
            state,
            args.solidAccount,
            args.heldMarket,
            heldWei.negative()
        );
        BalanceUpdate memory solidOwedUpdate = getBalanceUpdate(
            state,
            args.solidAccount,
            args.owedMarket,
            owedWei.negative()
        );
        BalanceUpdate memory vaporOwedUpdate = getBalanceUpdate(
            state,
            args.vaporAccount,
            args.owedMarket,
            owedWei.add(excessWei)
        );

        emit LogVaporize(
            args.solidAccount.owner,
            args.solidAccount.number,
            args.vaporAccount.owner,
            args.vaporAccount.number,
            args.heldMarket,
            args.owedMarket,
            solidHeldUpdate,
            solidOwedUpdate,
            vaporOwedUpdate
        );
    }

    // ============ Private Functions ============

    function getBalanceUpdate(
        Storage.State storage state,
        Account.Info memory account,
        uint256 market,
        Types.Wei memory deltaWei
    )
        private
        view
        returns (BalanceUpdate memory)
    {
        return BalanceUpdate({
            deltaWei: deltaWei,
            newPar: state.getPar(account, market)
        });
    }
}

// File: contracts/protocol/interfaces/IExchangeWrapper.sol

/**
 * @title IExchangeWrapper
 * @author dYdX
 *
 * Interface that Exchange Wrappers for Solo must implement in order to trade ERC20 tokens.
 */
interface IExchangeWrapper {

    // ============ Public Functions ============

    /**
     * Exchange some amount of takerToken for makerToken.
     *
     * @param  tradeOriginator      Address of the initiator of the trade (however, this value
     *                              cannot always be trusted as it is set at the discretion of the
     *                              msg.sender)
     * @param  receiver             Address to set allowance on once the trade has completed
     * @param  makerToken           Address of makerToken, the token to receive
     * @param  takerToken           Address of takerToken, the token to pay
     * @param  requestedFillAmount  Amount of takerToken being paid
     * @param  orderData            Arbitrary bytes data for any information to pass to the exchange
     * @return                      The amount of makerToken received
     */
    function exchange(
        address tradeOriginator,
        address receiver,
        address makerToken,
        address takerToken,
        uint256 requestedFillAmount,
        bytes calldata orderData
    )
        external
        returns (uint256);

    /**
     * Get amount of takerToken required to buy a certain amount of makerToken for a given trade.
     * Should match the takerToken amount used in exchangeForAmount. If the order cannot provide
     * exactly desiredMakerToken, then it must return the price to buy the minimum amount greater
     * than desiredMakerToken
     *
     * @param  makerToken         Address of makerToken, the token to receive
     * @param  takerToken         Address of takerToken, the token to pay
     * @param  desiredMakerToken  Amount of makerToken requested
     * @param  orderData          Arbitrary bytes data for any information to pass to the exchange
     * @return                    Amount of takerToken the needed to complete the exchange
     */
    function getExchangeCost(
        address makerToken,
        address takerToken,
        uint256 desiredMakerToken,
        bytes calldata orderData
    )
        external
        view
        returns (uint256);
}

// File: contracts/protocol/lib/Exchange.sol

/**
 * @title Exchange
 * @author dYdX
 *
 * Library for transferring tokens and interacting with ExchangeWrappers by using the Wei struct
 */
library Exchange {
    using Types for Types.Wei;

    // ============ Constants ============

    bytes32 constant FILE = "Exchange";

    // ============ Library Functions ============

    function transferOut(
        address token,
        address to,
        Types.Wei memory deltaWei
    )
        internal
    {
        Require.that(
            !deltaWei.isPositive(),
            FILE,
            "Cannot transferOut positive",
            deltaWei.value
        );

        Token.transfer(
            token,
            to,
            deltaWei.value
        );
    }

    function transferIn(
        address token,
        address from,
        Types.Wei memory deltaWei
    )
        internal
    {
        Require.that(
            !deltaWei.isNegative(),
            FILE,
            "Cannot transferIn negative",
            deltaWei.value
        );

        Token.transferFrom(
            token,
            from,
            address(this),
            deltaWei.value
        );
    }

    function getCost(
        address exchangeWrapper,
        address supplyToken,
        address borrowToken,
        Types.Wei memory desiredAmount,
        bytes memory orderData
    )
        internal
        view
        returns (Types.Wei memory)
    {
        Require.that(
            !desiredAmount.isNegative(),
            FILE,
            "Cannot getCost negative",
            desiredAmount.value
        );

        Types.Wei memory result;
        result.sign = false;
        result.value = IExchangeWrapper(exchangeWrapper).getExchangeCost(
            supplyToken,
            borrowToken,
            desiredAmount.value,
            orderData
        );

        return result;
    }

    function exchange(
        address exchangeWrapper,
        address accountOwner,
        address supplyToken,
        address borrowToken,
        Types.Wei memory requestedFillAmount,
        bytes memory orderData
    )
        internal
        returns (Types.Wei memory)
    {
        Require.that(
            !requestedFillAmount.isPositive(),
            FILE,
            "Cannot exchange positive",
            requestedFillAmount.value
        );

        transferOut(borrowToken, exchangeWrapper, requestedFillAmount);

        Types.Wei memory result;
        result.sign = true;
        result.value = IExchangeWrapper(exchangeWrapper).exchange(
            accountOwner,
            address(this),
            supplyToken,
            borrowToken,
            requestedFillAmount.value,
            orderData
        );

        transferIn(supplyToken, exchangeWrapper, result);

        return result;
    }
}

// File: contracts/protocol/impl/OperationImpl.sol

/**
 * @title OperationImpl
 * @author dYdX
 *
 * Logic for processing actions
 */
library OperationImpl {
    using Cache for Cache.MarketCache;
    using SafeMath for uint256;
    using Storage for Storage.State;
    using Types for Types.Par;
    using Types for Types.Wei;

    // ============ Constants ============

    bytes32 constant FILE = "OperationImpl";

    // ============ Public Functions ============

    function operate(
        Storage.State storage state,
        Account.Info[] memory accounts,
        Actions.ActionArgs[] memory actions
    )
        public
    {
        Events.logOperation();

        _verifyInputs(accounts, actions);

        (
            bool[] memory primaryAccounts,
            Cache.MarketCache memory cache
        ) = _runPreprocessing(
            state,
            accounts,
            actions
        );

        _runActions(
            state,
            accounts,
            actions,
            cache
        );

        _verifyFinalState(
            state,
            accounts,
            primaryAccounts,
            cache
        );
    }

    // ============ Helper Functions ============

    function _verifyInputs(
        Account.Info[] memory accounts,
        Actions.ActionArgs[] memory actions
    )
        private
        pure
    {
        Require.that(
            actions.length != 0,
            FILE,
            "Cannot have zero actions"
        );

        Require.that(
            accounts.length != 0,
            FILE,
            "Cannot have zero accounts"
        );

        for (uint256 a = 0; a < accounts.length; a++) {
            for (uint256 b = a + 1; b < accounts.length; b++) {
                Require.that(
                    !Account.equals(accounts[a], accounts[b]),
                    FILE,
                    "Cannot duplicate accounts",
                    a,
                    b
                );
            }
        }
    }

    function _runPreprocessing(
        Storage.State storage state,
        Account.Info[] memory accounts,
        Actions.ActionArgs[] memory actions
    )
        private
        returns (
            bool[] memory,
            Cache.MarketCache memory
        )
    {
        uint256 numMarkets = state.numMarkets;
        bool[] memory primaryAccounts = new bool[](accounts.length);
        Cache.MarketCache memory cache = Cache.create(numMarkets);

        // keep track of primary accounts and indexes that need updating
        for (uint256 i = 0; i < actions.length; i++) {
            Actions.ActionArgs memory arg = actions[i];
            Actions.ActionType actionType = arg.actionType;
            Actions.MarketLayout marketLayout = Actions.getMarketLayout(actionType);
            Actions.AccountLayout accountLayout = Actions.getAccountLayout(actionType);

            // parse out primary accounts
            if (accountLayout != Actions.AccountLayout.OnePrimary) {
                Require.that(
                    arg.accountId != arg.otherAccountId,
                    FILE,
                    "Duplicate accounts in action",
                    i
                );
                if (accountLayout == Actions.AccountLayout.TwoPrimary) {
                    primaryAccounts[arg.otherAccountId] = true;
                } else {
                    assert(accountLayout == Actions.AccountLayout.PrimaryAndSecondary);
                    Require.that(
                        !primaryAccounts[arg.otherAccountId],
                        FILE,
                        "Requires non-primary account",
                        arg.otherAccountId
                    );
                }
            }
            primaryAccounts[arg.accountId] = true;

            // keep track of indexes to update
            if (marketLayout == Actions.MarketLayout.OneMarket) {
                _updateMarket(state, cache, arg.primaryMarketId);
            } else if (marketLayout == Actions.MarketLayout.TwoMarkets) {
                Require.that(
                    arg.primaryMarketId != arg.secondaryMarketId,
                    FILE,
                    "Duplicate markets in action",
                    i
                );
                _updateMarket(state, cache, arg.primaryMarketId);
                _updateMarket(state, cache, arg.secondaryMarketId);
            } else {
                assert(marketLayout == Actions.MarketLayout.ZeroMarkets);
            }
        }

        // get any other markets for which an account has a balance
        for (uint256 m = 0; m < numMarkets; m++) {
            if (cache.hasMarket(m)) {
                continue;
            }
            for (uint256 a = 0; a < accounts.length; a++) {
                if (!state.getPar(accounts[a], m).isZero()) {
                    _updateMarket(state, cache, m);
                    break;
                }
            }
        }

        return (primaryAccounts, cache);
    }

    function _updateMarket(
        Storage.State storage state,
        Cache.MarketCache memory cache,
        uint256 marketId
    )
        private
    {
        bool updated = cache.addMarket(state, marketId);
        if (updated) {
            Events.logIndexUpdate(marketId, state.updateIndex(marketId));
        }
    }

    function _runActions(
        Storage.State storage state,
        Account.Info[] memory accounts,
        Actions.ActionArgs[] memory actions,
        Cache.MarketCache memory cache
    )
        private
    {
        for (uint256 i = 0; i < actions.length; i++) {
            Actions.ActionArgs memory action = actions[i];
            Actions.ActionType actionType = action.actionType;

            if (actionType == Actions.ActionType.Deposit) {
                _deposit(state, Actions.parseDepositArgs(accounts, action));
            }
            else if (actionType == Actions.ActionType.Withdraw) {
                _withdraw(state, Actions.parseWithdrawArgs(accounts, action));
            }
            else if (actionType == Actions.ActionType.Transfer) {
                _transfer(state, Actions.parseTransferArgs(accounts, action));
            }
            else if (actionType == Actions.ActionType.Buy) {
                _buy(state, Actions.parseBuyArgs(accounts, action));
            }
            else if (actionType == Actions.ActionType.Sell) {
                _sell(state, Actions.parseSellArgs(accounts, action));
            }
            else if (actionType == Actions.ActionType.Trade) {
                _trade(state, Actions.parseTradeArgs(accounts, action));
            }
            else if (actionType == Actions.ActionType.Liquidate) {
                _liquidate(state, Actions.parseLiquidateArgs(accounts, action), cache);
            }
            else if (actionType == Actions.ActionType.Vaporize) {
                _vaporize(state, Actions.parseVaporizeArgs(accounts, action), cache);
            }
            else  {
                assert(actionType == Actions.ActionType.Call);
                _call(state, Actions.parseCallArgs(accounts, action));
            }
        }
    }

    function _verifyFinalState(
        Storage.State storage state,
        Account.Info[] memory accounts,
        bool[] memory primaryAccounts,
        Cache.MarketCache memory cache
    )
        private
    {
        // verify no increase in borrowPar for closing markets
        uint256 numMarkets = cache.getNumMarkets();
        for (uint256 m = 0; m < numMarkets; m++) {
            if (cache.getIsClosing(m)) {
                Require.that(
                    state.getTotalPar(m).borrow <= cache.getBorrowPar(m),
                    FILE,
                    "Market is closing",
                    m
                );
            }
        }

        // verify account collateralization
        for (uint256 a = 0; a < accounts.length; a++) {
            Account.Info memory account = accounts[a];

            // validate minBorrowedValue
            bool collateralized = state.isCollateralized(account, cache, true);

            // don't check collateralization for non-primary accounts
            if (!primaryAccounts[a]) {
                continue;
            }

            // check collateralization for primary accounts
            Require.that(
                collateralized,
                FILE,
                "Undercollateralized account",
                account.owner,
                account.number
            );

            // ensure status is normal for primary accounts
            if (state.getStatus(account) != Account.Status.Normal) {
                state.setStatus(account, Account.Status.Normal);
            }
        }
    }

    // ============ Action Functions ============

    function _deposit(
        Storage.State storage state,
        Actions.DepositArgs memory args
    )
        private
    {
        state.requireIsOperator(args.account, msg.sender);

        Require.that(
            args.from == msg.sender || args.from == args.account.owner,
            FILE,
            "Invalid deposit source",
            args.from
        );

        (
            Types.Par memory newPar,
            Types.Wei memory deltaWei
        ) = state.getNewParAndDeltaWei(
            args.account,
            args.market,
            args.amount
        );

        state.setPar(
            args.account,
            args.market,
            newPar
        );

        // requires a positive deltaWei
        Exchange.transferIn(
            state.getToken(args.market),
            args.from,
            deltaWei
        );

        Events.logDeposit(
            state,
            args,
            deltaWei
        );
    }

    function _withdraw(
        Storage.State storage state,
        Actions.WithdrawArgs memory args
    )
        private
    {
        state.requireIsOperator(args.account, msg.sender);

        (
            Types.Par memory newPar,
            Types.Wei memory deltaWei
        ) = state.getNewParAndDeltaWei(
            args.account,
            args.market,
            args.amount
        );

        state.setPar(
            args.account,
            args.market,
            newPar
        );

        // requires a negative deltaWei
        Exchange.transferOut(
            state.getToken(args.market),
            args.to,
            deltaWei
        );

        Events.logWithdraw(
            state,
            args,
            deltaWei
        );
    }

    function _transfer(
        Storage.State storage state,
        Actions.TransferArgs memory args
    )
        private
    {
        state.requireIsOperator(args.accountOne, msg.sender);
        state.requireIsOperator(args.accountTwo, msg.sender);

        (
            Types.Par memory newPar,
            Types.Wei memory deltaWei
        ) = state.getNewParAndDeltaWei(
            args.accountOne,
            args.market,
            args.amount
        );

        state.setPar(
            args.accountOne,
            args.market,
            newPar
        );

        state.setParFromDeltaWei(
            args.accountTwo,
            args.market,
            deltaWei.negative()
        );

        Events.logTransfer(
            state,
            args,
            deltaWei
        );
    }

    function _buy(
        Storage.State storage state,
        Actions.BuyArgs memory args
    )
        private
    {
        state.requireIsOperator(args.account, msg.sender);

        address takerToken = state.getToken(args.takerMarket);
        address makerToken = state.getToken(args.makerMarket);

        (
            Types.Par memory makerPar,
            Types.Wei memory makerWei
        ) = state.getNewParAndDeltaWei(
            args.account,
            args.makerMarket,
            args.amount
        );

        Types.Wei memory takerWei = Exchange.getCost(
            args.exchangeWrapper,
            makerToken,
            takerToken,
            makerWei,
            args.orderData
        );

        Types.Wei memory tokensReceived = Exchange.exchange(
            args.exchangeWrapper,
            args.account.owner,
            makerToken,
            takerToken,
            takerWei,
            args.orderData
        );

        Require.that(
            tokensReceived.value >= makerWei.value,
            FILE,
            "Buy amount less than promised",
            tokensReceived.value,
            makerWei.value
        );

        state.setPar(
            args.account,
            args.makerMarket,
            makerPar
        );

        state.setParFromDeltaWei(
            args.account,
            args.takerMarket,
            takerWei
        );

        Events.logBuy(
            state,
            args,
            takerWei,
            makerWei
        );
    }

    function _sell(
        Storage.State storage state,
        Actions.SellArgs memory args
    )
        private
    {
        state.requireIsOperator(args.account, msg.sender);

        address takerToken = state.getToken(args.takerMarket);
        address makerToken = state.getToken(args.makerMarket);

        (
            Types.Par memory takerPar,
            Types.Wei memory takerWei
        ) = state.getNewParAndDeltaWei(
            args.account,
            args.takerMarket,
            args.amount
        );

        Types.Wei memory makerWei = Exchange.exchange(
            args.exchangeWrapper,
            args.account.owner,
            makerToken,
            takerToken,
            takerWei,
            args.orderData
        );

        state.setPar(
            args.account,
            args.takerMarket,
            takerPar
        );

        state.setParFromDeltaWei(
            args.account,
            args.makerMarket,
            makerWei
        );

        Events.logSell(
            state,
            args,
            takerWei,
            makerWei
        );
    }

    function _trade(
        Storage.State storage state,
        Actions.TradeArgs memory args
    )
        private
    {
        state.requireIsOperator(args.takerAccount, msg.sender);
        state.requireIsOperator(args.makerAccount, args.autoTrader);

        Types.Par memory oldInputPar = state.getPar(
            args.makerAccount,
            args.inputMarket
        );
        (
            Types.Par memory newInputPar,
            Types.Wei memory inputWei
        ) = state.getNewParAndDeltaWei(
            args.makerAccount,
            args.inputMarket,
            args.amount
        );

        Types.AssetAmount memory outputAmount = IAutoTrader(args.autoTrader).getTradeCost(
            args.inputMarket,
            args.outputMarket,
            args.makerAccount,
            args.takerAccount,
            oldInputPar,
            newInputPar,
            inputWei,
            args.tradeData
        );

        (
            Types.Par memory newOutputPar,
            Types.Wei memory outputWei
        ) = state.getNewParAndDeltaWei(
            args.makerAccount,
            args.outputMarket,
            outputAmount
        );

        Require.that(
            outputWei.isZero() || inputWei.isZero() || outputWei.sign != inputWei.sign,
            FILE,
            "Trades cannot be one-sided"
        );

        // set the balance for the maker
        state.setPar(
            args.makerAccount,
            args.inputMarket,
            newInputPar
        );
        state.setPar(
            args.makerAccount,
            args.outputMarket,
            newOutputPar
        );

        // set the balance for the taker
        state.setParFromDeltaWei(
            args.takerAccount,
            args.inputMarket,
            inputWei.negative()
        );
        state.setParFromDeltaWei(
            args.takerAccount,
            args.outputMarket,
            outputWei.negative()
        );

        Events.logTrade(
            state,
            args,
            inputWei,
            outputWei
        );
    }

    function _liquidate(
        Storage.State storage state,
        Actions.LiquidateArgs memory args,
        Cache.MarketCache memory cache
    )
        private
    {
        state.requireIsOperator(args.solidAccount, msg.sender);

        // verify liquidatable
        if (Account.Status.Liquid != state.getStatus(args.liquidAccount)) {
            Require.that(
                !state.isCollateralized(args.liquidAccount, cache, /* requireMinBorrow = */ false),
                FILE,
                "Unliquidatable account",
                args.liquidAccount.owner,
                args.liquidAccount.number
            );
            state.setStatus(args.liquidAccount, Account.Status.Liquid);
        }

        Types.Wei memory maxHeldWei = state.getWei(
            args.liquidAccount,
            args.heldMarket
        );

        Require.that(
            !maxHeldWei.isNegative(),
            FILE,
            "Collateral cannot be negative",
            args.liquidAccount.owner,
            args.liquidAccount.number,
            args.heldMarket
        );

        (
            Types.Par memory owedPar,
            Types.Wei memory owedWei
        ) = state.getNewParAndDeltaWeiForLiquidation(
            args.liquidAccount,
            args.owedMarket,
            args.amount
        );

        (
            Monetary.Price memory heldPrice,
            Monetary.Price memory owedPrice
        ) = _getLiquidationPrices(
            state,
            cache,
            args.heldMarket,
            args.owedMarket
        );

        Types.Wei memory heldWei = _owedWeiToHeldWei(owedWei, heldPrice, owedPrice);

        // if attempting to over-borrow the held asset, bound it by the maximum
        if (heldWei.value > maxHeldWei.value) {
            heldWei = maxHeldWei.negative();
            owedWei = _heldWeiToOwedWei(heldWei, heldPrice, owedPrice);

            state.setPar(
                args.liquidAccount,
                args.heldMarket,
                Types.zeroPar()
            );
            state.setParFromDeltaWei(
                args.liquidAccount,
                args.owedMarket,
                owedWei
            );
        } else {
            state.setPar(
                args.liquidAccount,
                args.owedMarket,
                owedPar
            );
            state.setParFromDeltaWei(
                args.liquidAccount,
                args.heldMarket,
                heldWei
            );
        }

        // set the balances for the solid account
        state.setParFromDeltaWei(
            args.solidAccount,
            args.owedMarket,
            owedWei.negative()
        );
        state.setParFromDeltaWei(
            args.solidAccount,
            args.heldMarket,
            heldWei.negative()
        );

        Events.logLiquidate(
            state,
            args,
            heldWei,
            owedWei
        );
    }

    function _vaporize(
        Storage.State storage state,
        Actions.VaporizeArgs memory args,
        Cache.MarketCache memory cache
    )
        private
    {
        state.requireIsOperator(args.solidAccount, msg.sender);

        // verify vaporizable
        if (Account.Status.Vapor != state.getStatus(args.vaporAccount)) {
            Require.that(
                state.isVaporizable(args.vaporAccount, cache),
                FILE,
                "Unvaporizable account",
                args.vaporAccount.owner,
                args.vaporAccount.number
            );
            state.setStatus(args.vaporAccount, Account.Status.Vapor);
        }

        // First, attempt to refund using the same token
        (
            bool fullyRepaid,
            Types.Wei memory excessWei
        ) = _vaporizeUsingExcess(state, args);
        if (fullyRepaid) {
            Events.logVaporize(
                state,
                args,
                Types.zeroWei(),
                Types.zeroWei(),
                excessWei
            );
            return;
        }

        Types.Wei memory maxHeldWei = state.getNumExcessTokens(args.heldMarket);

        Require.that(
            !maxHeldWei.isNegative(),
            FILE,
            "Excess cannot be negative",
            args.heldMarket
        );

        (
            Types.Par memory owedPar,
            Types.Wei memory owedWei
        ) = state.getNewParAndDeltaWeiForLiquidation(
            args.vaporAccount,
            args.owedMarket,
            args.amount
        );

        (
            Monetary.Price memory heldPrice,
            Monetary.Price memory owedPrice
        ) = _getLiquidationPrices(
            state,
            cache,
            args.heldMarket,
            args.owedMarket
        );

        Types.Wei memory heldWei = _owedWeiToHeldWei(owedWei, heldPrice, owedPrice);

        // if attempting to over-borrow the held asset, bound it by the maximum
        if (heldWei.value > maxHeldWei.value) {
            heldWei = maxHeldWei.negative();
            owedWei = _heldWeiToOwedWei(heldWei, heldPrice, owedPrice);

            state.setParFromDeltaWei(
                args.vaporAccount,
                args.owedMarket,
                owedWei
            );
        } else {
            state.setPar(
                args.vaporAccount,
                args.owedMarket,
                owedPar
            );
        }

        // set the balances for the solid account
        state.setParFromDeltaWei(
            args.solidAccount,
            args.owedMarket,
            owedWei.negative()
        );
        state.setParFromDeltaWei(
            args.solidAccount,
            args.heldMarket,
            heldWei.negative()
        );

        Events.logVaporize(
            state,
            args,
            heldWei,
            owedWei,
            excessWei
        );
    }

    function _call(
        Storage.State storage state,
        Actions.CallArgs memory args
    )
        private
    {
        state.requireIsOperator(args.account, msg.sender);

        ICallee(args.callee).callFunction(
            msg.sender,
            args.account,
            args.data
        );

        Events.logCall(args);
    }

    // ============ Private Functions ============

    /**
     * For the purposes of liquidation or vaporization, get the value-equivalent amount of heldWei
     * given owedWei and the (spread-adjusted) prices of each asset.
     */
    function _owedWeiToHeldWei(
        Types.Wei memory owedWei,
        Monetary.Price memory heldPrice,
        Monetary.Price memory owedPrice
    )
        private
        pure
        returns (Types.Wei memory)
    {
        return Types.Wei({
            sign: false,
            value: Math.getPartial(owedWei.value, owedPrice.value, heldPrice.value)
        });
    }

    /**
     * For the purposes of liquidation or vaporization, get the value-equivalent amount of owedWei
     * given heldWei and the (spread-adjusted) prices of each asset.
     */
    function _heldWeiToOwedWei(
        Types.Wei memory heldWei,
        Monetary.Price memory heldPrice,
        Monetary.Price memory owedPrice
    )
        private
        pure
        returns (Types.Wei memory)
    {
        return Types.Wei({
            sign: true,
            value: Math.getPartialRoundUp(heldWei.value, heldPrice.value, owedPrice.value)
        });
    }

    /**
     * Attempt to vaporize an account's balance using the excess tokens in the protocol. Return a
     * bool and a wei value. The boolean is true if and only if the balance was fully vaporized. The
     * Wei value is how many excess tokens were used to partially or fully vaporize the account's
     * negative balance.
     */
    function _vaporizeUsingExcess(
        Storage.State storage state,
        Actions.VaporizeArgs memory args
    )
        internal
        returns (bool, Types.Wei memory)
    {
        Types.Wei memory excessWei = state.getNumExcessTokens(args.owedMarket);

        // There are no excess funds, return zero
        if (!excessWei.isPositive()) {
            return (false, Types.zeroWei());
        }

        Types.Wei memory maxRefundWei = state.getWei(args.vaporAccount, args.owedMarket);
        maxRefundWei.sign = true;

        // The account is fully vaporizable using excess funds
        if (excessWei.value >= maxRefundWei.value) {
            state.setPar(
                args.vaporAccount,
                args.owedMarket,
                Types.zeroPar()
            );
            return (true, maxRefundWei);
        }

        // The account is only partially vaporizable using excess funds
        else {
            state.setParFromDeltaWei(
                args.vaporAccount,
                args.owedMarket,
                excessWei
            );
            return (false, excessWei);
        }
    }

    /**
     * Return the (spread-adjusted) prices of two assets for the purposes of liquidation or
     * vaporization.
     */
    function _getLiquidationPrices(
        Storage.State storage state,
        Cache.MarketCache memory cache,
        uint256 heldMarketId,
        uint256 owedMarketId
    )
        internal
        view
        returns (
            Monetary.Price memory,
            Monetary.Price memory
        )
    {
        uint256 originalPrice = cache.getPrice(owedMarketId).value;
        Decimal.D256 memory spread = state.getLiquidationSpreadForPair(
            heldMarketId,
            owedMarketId
        );

        Monetary.Price memory owedPrice = Monetary.Price({
            value: originalPrice.add(Decimal.mul(originalPrice, spread))
        });

        return (cache.getPrice(heldMarketId), owedPrice);
    }
}

// File: contracts/protocol/Operation.sol

/**
 * @title Operation
 * @author dYdX
 *
 * Primary public function for allowing users and contracts to manage accounts within Solo
 */
contract Operation is
    State,
    ReentrancyGuard
{
    // ============ Public Functions ============

    /**
     * The main entry-point to Solo that allows users and contracts to manage accounts.
     * Take one or more actions on one or more accounts. The msg.sender must be the owner or
     * operator of all accounts except for those being liquidated, vaporized, or traded with.
     * One call to operate() is considered a singular "operation". Account collateralization is
     * ensured only after the completion of the entire operation.
     *
     * @param  accounts  A list of all accounts that will be used in this operation. Cannot contain
     *                   duplicates. In each action, the relevant account will be referred-to by its
     *                   index in the list.
     * @param  actions   An ordered list of all actions that will be taken in this operation. The
     *                   actions will be processed in order.
     */
    function operate(
        Account.Info[] memory accounts,
        Actions.ActionArgs[] memory actions
    )
        public
        nonReentrant
    {
        OperationImpl.operate(
            g_state,
            accounts,
            actions
        );
    }
}

// File: contracts/protocol/Permission.sol

/**
 * @title Permission
 * @author dYdX
 *
 * Public function that allows other addresses to manage accounts
 */
contract Permission is
    State
{
    // ============ Events ============

    event LogOperatorSet(
        address indexed owner,
        address operator,
        bool trusted
    );

    // ============ Structs ============

    struct OperatorArg {
        address operator;
        bool trusted;
    }

    // ============ Public Functions ============

    /**
     * Approves/disapproves any number of operators. An operator is an external address that has the
     * same permissions to manipulate an account as the owner of the account. Operators are simply
     * addresses and therefore may either be externally-owned Ethereum accounts OR smart contracts.
     *
     * Operators are also able to act as AutoTrader contracts on behalf of the account owner if the
     * operator is a smart contract and implements the IAutoTrader interface.
     *
     * @param  args  A list of OperatorArgs which have an address and a boolean. The boolean value
     *               denotes whether to approve (true) or revoke approval (false) for that address.
     */
    function setOperators(
        OperatorArg[] memory args
    )
        public
    {
        for (uint256 i = 0; i < args.length; i++) {
            address operator = args[i].operator;
            bool trusted = args[i].trusted;
            g_state.operators[msg.sender][operator] = trusted;
            emit LogOperatorSet(msg.sender, operator, trusted);
        }
    }
}

// File: contracts/protocol/SoloMargin.sol

/**
 * @title SoloMargin
 * @author dYdX
 *
 * Main contract that inherits from other contracts
 */
contract SoloMargin is
    State,
    Admin,
    Getters,
    Operation,
    Permission
{
    // ============ Constructor ============

    constructor(
        Storage.RiskParams memory riskParams,
        Storage.RiskLimits memory riskLimits
    )
        public
    {
        g_state.riskParams = riskParams;
        g_state.riskLimits = riskLimits;
    }
}

Contract ABI

[{"constant":false,"inputs":[{"name":"marketId","type":"uint256"},{"components":[{"name":"value","type":"uint256"}],"name":"spreadPremium","type":"tuple"}],"name":"ownerSetSpreadPremium","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"operator","type":"address"}],"name":"getIsGlobalOperator","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketTokenAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"marketId","type":"uint256"},{"name":"interestSetter","type":"address"}],"name":"ownerSetInterestSetter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"components":[{"name":"owner","type":"address"},{"name":"number","type":"uint256"}],"name":"account","type":"tuple"}],"name":"getAccountValues","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketPriceOracle","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketInterestSetter","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketSpreadPremium","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getNumMarkets","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"token","type":"address"},{"name":"recipient","type":"address"}],"name":"ownerWithdrawUnsupportedTokens","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"components":[{"name":"value","type":"uint256"}],"name":"minBorrowedValue","type":"tuple"}],"name":"ownerSetMinBorrowedValue","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"components":[{"name":"value","type":"uint256"}],"name":"spread","type":"tuple"}],"name":"ownerSetLiquidationSpread","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"components":[{"name":"value","type":"uint256"}],"name":"earningsRate","type":"tuple"}],"name":"ownerSetEarningsRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"operator","type":"address"}],"name":"getIsLocalOperator","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"components":[{"name":"owner","type":"address"},{"name":"number","type":"uint256"}],"name":"account","type":"tuple"},{"name":"marketId","type":"uint256"}],"name":"getAccountPar","outputs":[{"components":[{"name":"sign","type":"bool"},{"name":"value","type":"uint128"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"marketId","type":"uint256"},{"components":[{"name":"value","type":"uint256"}],"name":"marginPremium","type":"tuple"}],"name":"ownerSetMarginPremium","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getMarginRatio","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketCurrentIndex","outputs":[{"components":[{"name":"borrow","type":"uint96"},{"name":"supply","type":"uint96"},{"name":"lastUpdate","type":"uint32"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketIsClosing","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getRiskParams","outputs":[{"components":[{"components":[{"name":"value","type":"uint256"}],"name":"marginRatio","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"liquidationSpread","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"earningsRate","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"minBorrowedValue","type":"tuple"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"components":[{"name":"owner","type":"address"},{"name":"number","type":"uint256"}],"name":"account","type":"tuple"}],"name":"getAccountBalances","outputs":[{"name":"","type":"address[]"},{"components":[{"name":"sign","type":"bool"},{"name":"value","type":"uint128"}],"name":"","type":"tuple[]"},{"components":[{"name":"sign","type":"bool"},{"name":"value","type":"uint256"}],"name":"","type":"tuple[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getMinBorrowedValue","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"components":[{"name":"operator","type":"address"},{"name":"trusted","type":"bool"}],"name":"args","type":"tuple[]"}],"name":"setOperators","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketPrice","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"marketId","type":"uint256"},{"name":"recipient","type":"address"}],"name":"ownerWithdrawExcessTokens","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"token","type":"address"},{"name":"priceOracle","type":"address"},{"name":"interestSetter","type":"address"},{"components":[{"name":"value","type":"uint256"}],"name":"marginPremium","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"spreadPremium","type":"tuple"}],"name":"ownerAddMarket","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"components":[{"name":"owner","type":"address"},{"name":"number","type":"uint256"}],"name":"accounts","type":"tuple[]"},{"components":[{"name":"actionType","type":"uint8"},{"name":"accountId","type":"uint256"},{"components":[{"name":"sign","type":"bool"},{"name":"denomination","type":"uint8"},{"name":"ref","type":"uint8"},{"name":"value","type":"uint256"}],"name":"amount","type":"tuple"},{"name":"primaryMarketId","type":"uint256"},{"name":"secondaryMarketId","type":"uint256"},{"name":"otherAddress","type":"address"},{"name":"otherAccountId","type":"uint256"},{"name":"data","type":"bytes"}],"name":"actions","type":"tuple[]"}],"name":"operate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketWithInfo","outputs":[{"components":[{"name":"token","type":"address"},{"components":[{"name":"borrow","type":"uint128"},{"name":"supply","type":"uint128"}],"name":"totalPar","type":"tuple"},{"components":[{"name":"borrow","type":"uint96"},{"name":"supply","type":"uint96"},{"name":"lastUpdate","type":"uint32"}],"name":"index","type":"tuple"},{"name":"priceOracle","type":"address"},{"name":"interestSetter","type":"address"},{"components":[{"name":"value","type":"uint256"}],"name":"marginPremium","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"spreadPremium","type":"tuple"},{"name":"isClosing","type":"bool"}],"name":"","type":"tuple"},{"components":[{"name":"borrow","type":"uint96"},{"name":"supply","type":"uint96"},{"name":"lastUpdate","type":"uint32"}],"name":"","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"components":[{"name":"value","type":"uint256"}],"name":"ratio","type":"tuple"}],"name":"ownerSetMarginRatio","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getLiquidationSpread","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"components":[{"name":"owner","type":"address"},{"name":"number","type":"uint256"}],"name":"account","type":"tuple"},{"name":"marketId","type":"uint256"}],"name":"getAccountWei","outputs":[{"components":[{"name":"sign","type":"bool"},{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketTotalPar","outputs":[{"components":[{"name":"borrow","type":"uint128"},{"name":"supply","type":"uint128"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"heldMarketId","type":"uint256"},{"name":"owedMarketId","type":"uint256"}],"name":"getLiquidationSpreadForPair","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getNumExcessTokens","outputs":[{"components":[{"name":"sign","type":"bool"},{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketCachedIndex","outputs":[{"components":[{"name":"borrow","type":"uint96"},{"name":"supply","type":"uint96"},{"name":"lastUpdate","type":"uint32"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"components":[{"name":"owner","type":"address"},{"name":"number","type":"uint256"}],"name":"account","type":"tuple"}],"name":"getAccountStatus","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getEarningsRate","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"marketId","type":"uint256"},{"name":"priceOracle","type":"address"}],"name":"ownerSetPriceOracle","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getRiskLimits","outputs":[{"components":[{"name":"marginRatioMax","type":"uint64"},{"name":"liquidationSpreadMax","type":"uint64"},{"name":"earningsRateMax","type":"uint64"},{"name":"marginPremiumMax","type":"uint64"},{"name":"spreadPremiumMax","type":"uint64"},{"name":"minBorrowedValueMax","type":"uint128"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarket","outputs":[{"components":[{"name":"token","type":"address"},{"components":[{"name":"borrow","type":"uint128"},{"name":"supply","type":"uint128"}],"name":"totalPar","type":"tuple"},{"components":[{"name":"borrow","type":"uint96"},{"name":"supply","type":"uint96"},{"name":"lastUpdate","type":"uint32"}],"name":"index","type":"tuple"},{"name":"priceOracle","type":"address"},{"name":"interestSetter","type":"address"},{"components":[{"name":"value","type":"uint256"}],"name":"marginPremium","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"spreadPremium","type":"tuple"},{"name":"isClosing","type":"bool"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"marketId","type":"uint256"},{"name":"isClosing","type":"bool"}],"name":"ownerSetIsClosing","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"operator","type":"address"},{"name":"approved","type":"bool"}],"name":"ownerSetGlobalOperator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"components":[{"name":"owner","type":"address"},{"name":"number","type":"uint256"}],"name":"account","type":"tuple"}],"name":"getAdjustedAccountValues","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketMarginPremium","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"marketId","type":"uint256"}],"name":"getMarketInterestRate","outputs":[{"components":[{"name":"value","type":"uint256"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"name":"value","type":"uint256"}],"name":"marginRatio","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"liquidationSpread","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"earningsRate","type":"tuple"},{"components":[{"name":"value","type":"uint256"}],"name":"minBorrowedValue","type":"tuple"}],"name":"riskParams","type":"tuple"},{"components":[{"name":"marginRatioMax","type":"uint64"},{"name":"liquidationSpreadMax","type":"uint64"},{"name":"earningsRateMax","type":"uint64"},{"name":"marginPremiumMax","type":"uint64"},{"name":"spreadPremiumMax","type":"uint64"},{"name":"minBorrowedValueMax","type":"uint128"}],"name":"riskLimits","type":"tuple"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"operator","type":"address"},{"indexed":false,"name":"trusted","type":"bool"}],"name":"LogOperatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

60806040527f4765747465727300000000000000000000000000000000000000000000000000600d553480156200003557600080fd5b50604051610140806200459b833981018060405262000058919081019062000336565b600b8054600160a060020a031916331790819055604051600160a060020a0391909116906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a36001600c5581515160055560208083015151600655604080840151516007556060938401515160085582516009805493850151928501519585015167ffffffffffffffff199485166001604060020a0393841617604060020a608060020a03191668010000000000000000948416850217608060020a60c060020a0319167001000000000000000000000000000000009784169790970296909617600160c060020a0316780100000000000000000000000000000000000000000000000096831696909602959095179094556080830151600a805460a09095015194909316941693909317604060020a60c060020a0319166001608060020a03909216909202179055620003b8565b600060208284031215620001c057600080fd5b620001cc602062000376565b90506000620001dc84846200031a565b82525092915050565b600060c08284031215620001f857600080fd5b6200020460c062000376565b9050600062000214848462000328565b8252506020620002278484830162000328565b60208301525060406200023d8482850162000328565b6040830152506060620002538482850162000328565b6060830152506080620002698482850162000328565b60808301525060a06200027f8482850162000305565b60a08301525092915050565b6000608082840312156200029e57600080fd5b620002aa608062000376565b90506000620002ba8484620001ad565b8252506020620002cd84848301620001ad565b6020830152506040620002e384828501620001ad565b6040830152506060620002f984828501620001ad565b60608301525092915050565b60006200031382516200039d565b9392505050565b6000620003138251620003a9565b6000620003138251620003ac565b60008061014083850312156200034b57600080fd5b60006200035985856200028b565b92505060806200036c85828601620001e5565b9150509250929050565b6040518181016001604060020a03811182821017156200039557600080fd5b604052919050565b6001608060020a031690565b90565b6001604060020a031690565b6141d380620003c86000396000f3fe608060405234801561001057600080fd5b5060043610610348576000357c0100000000000000000000000000000000000000000000000000000000900480638928378e116101cf578063d5ecf7c511610116578063eb44fdd3116100bf578063f2fde38b11610099578063f2fde38b14610717578063f94160521461072a578063fd04b6061461073d578063fd47eda61461075057610348565b8063eb44fdd3146106d1578063ef6957d0146106f1578063f2901ae21461070457610348565b8063e5520228116100f0578063e5520228146106a1578063e8e72f75146106a9578063eb1c6e6b146106bc57610348565b8063d5ecf7c51461065b578063deec053d1461066e578063e51bfcb41461068157610348565b8063b548b89211610178578063c190c2ec11610152578063c190c2ec14610608578063cb04a34c14610628578063d24c48bc1461064857610348565b8063b548b892146105ca578063c0bb72b7146105ed578063c14609421461060057610348565b80638f6bc659116101a95780638f6bc65914610591578063982f323c146105a4578063a67a6a45146105b757610348565b80638928378e1461056e5780638da5cb5b146105815780638f32d59b1461058957610348565b8063387a498a116102935780635ac7d17c1161023c578063715018a611610216578063715018a61461054b5780637e9eaf411461055357806385b53fc81461055b57610348565b80635ac7d17c1461050157806369794795146105145780636a8194e71461052957610348565b80634be874141161026d5780634be87414146104c65780634f3c1542146104d957806356ea84b2146104e157610348565b8063387a498a146104805780633a031bf01461049357806347d1b53c146104a657610348565b8063197f0f05116102f55780632a560845116102cf5780632a560845146104475780632e822af31461045a5780633063bce21461046d57610348565b8063197f0f05146103ff5780631a7777bb14610412578063295c39a51461043257610348565b8063121fb72f11610326578063121fb72f146103ab578063124f914c146103be57806313368364146103df57610348565b8063042069d61461034d578063052f72d714610362578063062bd3e91461038b575b600080fd5b61036061035b366004613594565b610763565b005b6103756103703660046132cf565b610817565b6040516103829190613cf4565b60405180910390f35b61039e6103993660046134ea565b610831565b6040516103829190613c6a565b6103606103b9366004613564565b61084d565b6103d16103cc36600461347e565b6108be565b604051610382929190613f4a565b6103f26103ed3660046134ea565b6108e2565b6040516103829190613d02565b6103f261040d3660046134ea565b610919565b6104256104203660046134ea565b610950565b6040516103829190613d2f565b61043a610987565b6040516103829190613f66565b61043a6104553660046132ed565b61098d565b610360610468366004613460565b610a67565b61036061047b366004613460565b610b18565b61036061048e366004613460565b610b87565b6103756104a13660046132ed565b610bf6565b6104b96104b436600461349c565b610c12565b6040516103829190613d93565b6103606104d4366004613594565b610c35565b610425610ca6565b6104f46104ef3660046134ea565b610cc2565b6040516103829190613d3d565b61037561050f3660046134ea565b610cf7565b61051c610d1b565b6040516103829190613daf565b61053c61053736600461347e565b610d77565b60405161038293929190613cbb565b610360610ee5565b610425610f65565b61036061056936600461342b565b610f81565b61042561057c3660046134ea565b611064565b61039e611086565b6103756110a2565b61043a61059f366004613526565b6110c0565b6103606105b2366004613357565b611133565b6103606105c53660046133cc565b6111f0565b6105dd6105d83660046134ea565b611250565b6040516103829493929190613d5a565b6103606105fb366004613460565b6112ac565b61042561131b565b61061b61061636600461349c565b611337565b6040516103829190613f58565b61063b6106363660046134ea565b611377565b6040516103829190613f3c565b6104256106563660046135c4565b611399565b61061b6106693660046134ea565b6113c5565b6104f461067c3660046134ea565b6113e7565b61069461068f36600461347e565b611409565b6040516103829190613d10565b61042561141b565b6103606106b7366004613564565b611437565b6106c46114a8565b6040516103829190613da1565b6106e46106df3660046134ea565b61154a565b6040516103829190613d4b565b6103606106ff366004613545565b611689565b610360610712366004613327565b6116fa565b6103606107253660046132cf565b61176b565b6103d161073836600461347e565b611788565b61042561074b3660046134ea565b6117a3565b61042561075e3660046134ea565b6117da565b61076b6110a2565b61077457600080fd5b600c8054600101908190556040517f8854ab3e00000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac3990638854ab3e906107d49060009087908790600401613f14565b60006040518083038186803b1580156107ec57600080fd5b505af4158015610800573d6000803e3d6000fd5b50505050600c54811461081257600080fd5b505050565b6000610829818363ffffffff61180f16565b90505b919050565b600061083c8261183e565b61082960008363ffffffff61187116565b6108556110a2565b61085e57600080fd5b600c8054600101908190556040517faa92e34800000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac399063aa92e348906107d49060009087908790600401613eec565b6108c6612d4f565b6108ce612d4f565b6108d983600061189d565b91509150915091565b60006108ed8261183e565b5060009081526001602052604090206003015473ffffffffffffffffffffffffffffffffffffffff1690565b60006109248261183e565b5060009081526001602052604090206004015473ffffffffffffffffffffffffffffffffffffffff1690565b610958612d4f565b6109618261183e565b506000908152600160209081526040918290208251918201909252600690910154815290565b60005490565b60006109976110a2565b6109a057600080fd5b600c8054600101908190556040517fdd32998a00000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac399063dd32998a90610a009060009088908890600401613dbd565b60206040518083038186803b158015610a1857600080fd5b505af4158015610a2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a509190810190613508565b9150600c548114610a6057600080fd5b5092915050565b610a6f6110a2565b610a7857600080fd5b600c8054600101908190556040517ff9cacc4c00000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac399063f9cacc4c90610ad6906000908690600401613e9b565b60006040518083038186803b158015610aee57600080fd5b505af4158015610b02573d6000803e3d6000fd5b50505050600c548114610b1457600080fd5b5050565b610b206110a2565b610b2957600080fd5b600c8054600101908190556040517f0f44e6bc00000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac3990630f44e6bc90610ad6906000908690600401613e9b565b610b8f6110a2565b610b9857600080fd5b600c8054600101908190556040517f311401d000000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac399063311401d090610ad6906000908690600401613e9b565b6000610c0981848463ffffffff61192916565b90505b92915050565b610c1a612d62565b610c238261183e565b610c096000848463ffffffff61196916565b610c3d6110a2565b610c4657600080fd5b600c8054600101908190556040517f7335079b00000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac3990637335079b906107d49060009087908790600401613f14565b610cae612d4f565b506040805160208101909152600554815290565b610cca612d79565b610cd38261183e565b61082982610ce860008263ffffffff6119e516565b6000919063ffffffff611a6916565b6000610d028261183e565b5060009081526001602052604090206007015460ff1690565b610d23612d99565b506040805160a0810182526005546080820190815281528151602081810184526006548252808301919091528251808201845260075481528284015282519081019092526008548252606081019190915290565b6060806060600080600001549050606081604051908082528060200260200182016040528015610db1578160200160208202803883390190505b509050606082604051908082528060200260200182016040528015610df057816020015b610ddd612d62565b815260200190600190039081610dd55790505b509050606083604051908082528060200260200182016040528015610e2f57816020015b610e1c612d62565b815260200190600190039081610e145790505b50905060005b84811015610ed657610e4681610831565b848281518110610e5257fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050610e968982610c12565b838281518110610ea257fe5b6020026020010181905250610eb78982611337565b828281518110610ec357fe5b6020908102919091010152600101610e35565b50919790965090945092505050565b610eed6110a2565b610ef657600080fd5b600b5460405160009173ffffffffffffffffffffffffffffffffffffffff16907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600b80547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b610f6d612d4f565b506040805160208101909152600854815290565b60005b8151811015610b14576000828281518110610f9b57fe5b60200260200101516000015190506000838381518110610fb757fe5b60209081029190910181015181015133600081815260038452604080822073ffffffffffffffffffffffffffffffffffffffff8816835290945283902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001683151517905591519092507f4d7f317d2088d039c2a95a09fcbf9cc9191fad5905f883c937cc3d317c4a6327906110529085908590613c78565b60405180910390a25050600101610f84565b61106c612d4f565b6110758261183e565b61082960008363ffffffff611ac116565b600b5473ffffffffffffffffffffffffffffffffffffffff1690565b600b5473ffffffffffffffffffffffffffffffffffffffff16331490565b60006110ca6110a2565b6110d357600080fd5b600c8054600101908190556040517fb25328e000000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac399063b25328e090610a009060009088908890600401613eb6565b61113b6110a2565b61114457600080fd5b600c8054600101908190556040517f48d0648400000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac39906348d06484906111aa906000908a908a908a908a908a90600401613e0d565b60006040518083038186803b1580156111c257600080fd5b505af41580156111d6573d6000803e3d6000fd5b50505050600c5481146111e857600080fd5b505050505050565b600c8054600101908190556040517fbd76ecfd00000000000000000000000000000000000000000000000000000000815273cfa0451d8d1f08504fa44a6f72d00f455b858a1d9063bd76ecfd906107d49060009087908790600401613e67565b611258612dd8565b611260612d79565b611268612d4f565b611270612d4f565b6112798561183e565b6112828561154a565b61128b86610cc2565b61129487611064565b61129d886117da565b93509350935093509193509193565b6112b46110a2565b6112bd57600080fd5b600c8054600101908190556040517f54dd351600000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac39906354dd351690610ad6906000908690600401613e9b565b611323612d4f565b506040805160208101909152600654815290565b61133f612d62565b6113488261183e565b610c0961135d6000858563ffffffff61196916565b61137284610ce860008263ffffffff6119e516565b611c0a565b61137f612d62565b6113888261183e565b61082960008363ffffffff611cbb16565b6113a1612d4f565b6113aa8361183e565b6113b38261183e565b610c096000848463ffffffff611d1b16565b6113cd612d62565b6113d68261183e565b61082960008363ffffffff611db116565b6113ef612d79565b6113f88261183e565b61082960008363ffffffff6119e516565b6000610829818363ffffffff611e7716565b611423612d4f565b506040805160208101909152600754815290565b61143f6110a2565b61144857600080fd5b600c8054600101908190556040517f8c5dabd100000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac3990638c5dabd1906107d49060009087908790600401613eec565b6114b0612e4b565b506040805160c08101825260095467ffffffffffffffff808216835268010000000000000000808304821660208501527001000000000000000000000000000000008304821694840194909452780100000000000000000000000000000000000000000000000090910481166060830152600a549081166080830152919091046fffffffffffffffffffffffffffffffff1660a082015290565b611552612dd8565b61155b8261183e565b50600090815260016020818152604092839020835161010081018552815473ffffffffffffffffffffffffffffffffffffffff908116825285518087018752948301546fffffffffffffffffffffffffffffffff808216875270010000000000000000000000000000000090910416858501528184019490945284516060808201875260028401546bffffffffffffffffffffffff80821684526c01000000000000000000000000820416838701527801000000000000000000000000000000000000000000000000900463ffffffff168288015282870191909152600383015485169082015260048201549093166080840152835180830185526005820154815260a084015283519182019093526006830154815260c082015260079091015460ff16151560e082015290565b6116916110a2565b61169a57600080fd5b600c8054600101908190556040517f10c87b0600000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac39906310c87b06906107d49060009087908790600401613ed1565b6117026110a2565b61170b57600080fd5b600c8054600101908190556040517fe80f802400000000000000000000000000000000000000000000000000000000815273078d400c1a723b792de8afe240bf039b7069ac399063e80f8024906107d49060009087908790600401613de5565b6117736110a2565b61177c57600080fd5b61178581611eb9565b50565b611790612d4f565b611798612d4f565b6108d983600161189d565b6117ab612d4f565b6117b48261183e565b506000908152600160209081526040918290208251918201909252600590910154815290565b6117e2612d4f565b6117eb8261183e565b6108298261180060008263ffffffff6119e516565b6000919063ffffffff611f6716565b73ffffffffffffffffffffffffffffffffffffffff166000908152600491909101602052604090205460ff1690565b61178560008001548210600d547f4d61726b6574204f4f420000000000000000000000000000000000000000000061208e565b6000908152600191909101602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6118a5612d4f565b6118ad612d4f565b6000546118b8612e80565b6118c18261213f565b905060005b82811015611908576118e86118e36000898463ffffffff61196916565b612195565b611900576118fe8260008363ffffffff6121af16565b505b6001016118c6565b5061191c600087838863ffffffff61228916565b9350935050509250929050565b73ffffffffffffffffffffffffffffffffffffffff808316600090815260038501602090815260408083209385168352929052205460ff165b9392505050565b611971612d62565b50815173ffffffffffffffffffffffffffffffffffffffff1660009081526002840160209081526040808320828601518452825280832084845282529182902082518084019093525460ff8116151583526fffffffffffffffffffffffffffffffff61010090910416908201529392505050565b6119ed612d79565b506000908152600191909101602090815260409182902082516060810184526002909101546bffffffffffffffffffffffff80821683526c0100000000000000000000000082041692820192909252780100000000000000000000000000000000000000000000000090910463ffffffff169181019190915290565b611a71612d79565b611a79612d4f565b611a8a85858563ffffffff611f6716565b9050611ab88382611aa1888863ffffffff611cbb16565b604080516020810190915260078a015481526123dc565b95945050505050565b611ac9612d4f565b600082815260018401602052604090206003015473ffffffffffffffffffffffffffffffffffffffff16611afb612d4f565b73ffffffffffffffffffffffffffffffffffffffff82166341976e09611b27878763ffffffff61187116565b6040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401611b5f9190613c6a565b60206040518083038186803b158015611b7757600080fd5b505afa158015611b8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611baf91908101906134cc565b8051909150611c029015157f53746f72616765000000000000000000000000000000000000000000000000007f50726963652063616e6e6f74206265207a65726f00000000000000000000000087612546565b949350505050565b611c12612d62565b602083015183516fffffffffffffffffffffffffffffffff9091169015611c7e57604080518082019091526001815260208481015190820190611c739084906bffffffffffffffffffffffff16670de0b6b3a764000063ffffffff6125e416565b815250915050610c0c565b604080518082019091526000815283516020820190611c739084906bffffffffffffffffffffffff16670de0b6b3a764000063ffffffff61260616565b611cc3612d62565b506000818152600180840160209081526040928390208351808501909452909101546fffffffffffffffffffffffffffffffff8082168452700100000000000000000000000000000000909104169082015292915050565b611d23612d4f565b60068085015460008581526001870160209081526040918290208251918201909252920154825290611d5f908290611d5a90612653565b61268a565b9050611d9a81611d5a876001016000878152602001908152602001600020600601604051806020016040529081600082015481525050612653565b604080516020810190915290815295945050505050565b611db9612d62565b611dc1612d79565b611dd1848463ffffffff6119e516565b9050611ddb612d62565b611deb858563ffffffff611cbb16565b90506000611dff868663ffffffff61187116565b9050611e09612d62565b6040518060400160405280600115158152602001611e2784306126a3565b90529050611e33612d62565b611e3b612d62565b611e458587612748565b9092509050611e6a82611e5e858463ffffffff6127f016565b9063ffffffff6127f016565b9998505050505050505050565b805173ffffffffffffffffffffffffffffffffffffffff1660009081526002929092016020908152604080842092820151845291905290206001015460ff1690565b73ffffffffffffffffffffffffffffffffffffffff8116611ed957600080fd5b600b5460405173ffffffffffffffffffffffffffffffffffffffff8084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b611f6f612d4f565b611f77612d62565b611f87858563ffffffff611cbb16565b9050611f91612d62565b611f99612d62565b611fa38386612748565b91509150611faf612d4f565b600087815260018901602052604090206004015473ffffffffffffffffffffffffffffffffffffffff1663e8177dcf611fee8a8a63ffffffff61187116565b846020015186602001516040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040161203293929190613c93565b60206040518083038186803b15801561204a57600080fd5b505afa15801561205e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061208291908101906134cc565b98975050505050505050565b826108125761209c8261280a565b7f3a200000000000000000000000000000000000000000000000000000000000006120c68361280a565b6040516020016120d893929190613be4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a000000000000000000000000000000000000000000000000000000000825261213691600401613d1e565b60405180910390fd5b612147612e80565b60405180602001604052808360405190808252806020026020018201604052801561218c57816020015b612179612e93565b8152602001906001900390816121715790505b50905292915050565b602001516fffffffffffffffffffffffffffffffff161590565b60006121c1848363ffffffff61290516565b156121ce57506000611962565b6121de838363ffffffff611ac116565b84518051849081106121ec57fe5b602090810291909101810151604090810192909252600084815260018601909152206007015460ff161561227f5760018460000151838151811061222c57fe5b6020908102919091010151901515905261224c838363ffffffff611cbb16565b51845180518490811061225b57fe5b6020908102919091018101516fffffffffffffffffffffffffffffffff9092169101525b5060019392505050565b612291612d4f565b612299612d4f565b6122a1612d4f565b6122a9612d4f565b60006122b487612933565b905060005b818110156123cd576122d1888263ffffffff61290516565b6122da576123c5565b6122e2612d62565b6122f38b8b8463ffffffff61293816565b90506122fe816129a7565b1561230957506123c5565b600061233061231e8b8563ffffffff6129af16565b5160208401519063ffffffff6129d916565b905061233a612d4f565b612342612a00565b9050891561237a57600084815260018e0160209081526040918290208251918201909252600590910154815261237790612653565b90505b8251156123a35761239c61238e8383612a22565b88519063ffffffff612a3b16565b87526123c1565b6123be6123b0838361268a565b87519063ffffffff612a3b16565b86525b5050505b6001016122b9565b50919890975095505050505050565b6123e4612d79565b6123ec612d62565b6123f4612d62565b6123fe8588612748565b91509150600061240c612a4d565b905060006124446124368a6040015163ffffffff168463ffffffff16612a5d90919063ffffffff16565b89519063ffffffff6129d916565b90506000612451856129a7565b1561245e57506000612490565b612468828861268a565b90508460200151846020015110156124905761248d81856020015187602001516125e4565b90505b8181111561249a57fe5b60408051606081019091528a5181906124e3906124de906bffffffffffffffffffffffff166124d28188670de0b6b3a76400006125e4565b9063ffffffff612a3b16565b612a72565b6bffffffffffffffffffffffff908116825260208d81015192019161251a916124de91166124d28187670de0b6b3a76400006125e4565b6bffffffffffffffffffffffff1681526020018463ffffffff1681525095505050505050949350505050565b836125de576125548361280a565b7f3a2000000000000000000000000000000000000000000000000000000000000061257e8461280a565b7f203c0000000000000000000000000000000000000000000000000000000000006125a885612ad0565b6040516120d89594939291907f3e0000000000000000000000000000000000000000000000000000000000000090602001613c0c565b50505050565b6000611c02826125fa868663ffffffff6129d916565b9063ffffffff612bfe16565b6000831580612613575082155b1561262a57612623600083612bfe565b9050611962565b611c0260016124d2846125fa836126478a8a63ffffffff6129d916565b9063ffffffff612a5d16565b61265b612d4f565b60408051602081019091528251819061268290670de0b6b3a764000063ffffffff612a3b16565b905292915050565b6000610c09838360000151670de0b6b3a76400006125e4565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8416906370a08231906126f8908590600401613c6a565b60206040518083038186803b15801561271057600080fd5b505afa158015612724573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c099190810190613508565b612750612d62565b612758612d62565b612760612d62565b5060408051808201909152600181526020858101516fffffffffffffffffffffffffffffffff1690820152612793612d62565b50604080518082019091526000815285516fffffffffffffffffffffffffffffffff1660208201526127c3612d62565b6127cd8387611c0a565b90506127d7612d62565b6127e18388611c0a565b91989197509095505050505050565b6127f8612d62565b610c098361280584612c20565b612c47565b6060808260405160200161281e9190613bcf565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052905060205b80156128ee5781517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091019082908290811061288a57fe5b6020910101517f010000000000000000000000000000000000000000000000000000000000000090819004027fff0000000000000000000000000000000000000000000000000000000000000016156128e9576001018152905061082c565b612851565b505060408051600081526020810190915292915050565b60008260000151828151811061291757fe5b6020026020010151604001516000015160001415905092915050565b515190565b612940612d62565b612948612d62565b61295985858563ffffffff61196916565b905061296481612195565b1561297957612971612cd9565b915050611962565b612981612d79565b612991868563ffffffff6119e516565b905061299d8282611c0a565b9695505050505050565b602001511590565b6129b7612d4f565b82518051839081106129c557fe5b602002602001015160400151905092915050565b6000826129e857506000610c0c565b828202828482816129f557fe5b0414610c0957600080fd5b612a08612d4f565b506040805160208101909152670de0b6b3a7640000815290565b6000610c0983670de0b6b3a764000084600001516125e4565b600082820183811015610c0957600080fd5b6000612a5842612cf9565b905090565b600082821115612a6c57600080fd5b50900390565b6000816108296bffffffffffffffffffffffff821682147f4d617468000000000000000000000000000000000000000000000000000000007f556e73616665206361737420746f2075696e743936000000000000000000000061208e565b606081612b11575060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015261082c565b8160005b8115612b2957600101600a82049150612b15565b6060816040519080825280601f01601f191660200182016040528015612b56576020820181803883390190505b508593509050815b8015612bf5577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600a84066030017f010000000000000000000000000000000000000000000000000000000000000002828281518110612bbb57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350612b5e565b50949350505050565b6000808211612c0c57600080fd5b6000828481612c1757fe5b04949350505050565b612c28612d62565b5060408051808201909152815115815260208083015190820152919050565b612c4f612d62565b612c57612d62565b8251845115159015151415612c8a5783511515815260208085015190840151612c809190612a3b565b6020820152610c09565b8260200151846020015110612cb35783511515815260208085015190840151612c809190612a5d565b82511515815260208084015190850151612ccd9190612a5d565b60208201529392505050565b612ce1612d62565b50604080518082019091526000808252602082015290565b60008161082963ffffffff821682147f4d617468000000000000000000000000000000000000000000000000000000007f556e73616665206361737420746f2075696e743332000000000000000000000061208e565b6040518060200160405280600081525090565b604080518082019091526000808252602082015290565b604080516060810182526000808252602082018190529181019190915290565b6040518060800160405280612dac612d4f565b8152602001612db9612d4f565b8152602001612dc6612d4f565b8152602001612dd3612d4f565b905290565b604051806101600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001612e09612d62565b8152602001612e16612d79565b81526000602082018190526040820152606001612e31612d4f565b8152602001612e3e612d4f565b8152600060209091015290565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b6040518060200160405280606081525090565b6040805160608101825260008082526020820152908101612dd3612d4f565b6000610c098235614015565b600082601f830112612ecf57600080fd5b8135612ee2612edd82613f9b565b613f74565b81815260209384019390925082018360005b83811015612f205781358601612f0a888261308d565b8452506020928301929190910190600101612ef4565b5050505092915050565b600082601f830112612f3b57600080fd5b8135612f49612edd82613f9b565b91508181835260208401935060208101905083856040840282011115612f6e57600080fd5b60005b83811015612f205781612f84888261320b565b84525060209092019160409190910190600101612f71565b600082601f830112612fad57600080fd5b8135612fbb612edd82613f9b565b91508181835260208401935060208101905083856040840282011115612fe057600080fd5b60005b83811015612f205781612ff68882613252565b84525060209092019160409190910190600101612fe3565b6000610c098235614020565b600082601f83011261302b57600080fd5b8135613039612edd82613fbc565b9150808252602083016020830185838301111561305557600080fd5b613060838284614139565b50505092915050565b6000610c0982356140ef565b6000610c0982356140fa565b6000610c098235614109565b600061016082840312156130a057600080fd5b6130ab610100613f74565b905060006130b98484613075565b82525060206130ca848483016132b7565b60208301525060406130de84828501613169565b60408301525060c06130f2848285016132b7565b60608301525060e0613106848285016132b7565b60808301525061010061311b84828501612eb2565b60a083015250610120613130848285016132b7565b60c08301525061014082013567ffffffffffffffff81111561315157600080fd5b61315d8482850161301a565b60e08301525092915050565b60006080828403121561317b57600080fd5b6131856080613f74565b90506000613193848461300e565b82525060206131a484848301613081565b60208301525060406131b884828501613081565b60408301525060606131cc848285016132b7565b60608301525092915050565b6000602082840312156131ea57600080fd5b6131f46020613f74565b9050600061320284846132b7565b82525092915050565b60006040828403121561321d57600080fd5b6132276040613f74565b905060006132358484612eb2565b8252506020613246848483016132b7565b60208301525092915050565b60006040828403121561326457600080fd5b61326e6040613f74565b9050600061327c8484612eb2565b82525060206132468484830161300e565b60006020828403121561329f57600080fd5b6132a96020613f74565b9050600061320284846132c3565b6000610c09823561406f565b6000610c09825161406f565b6000602082840312156132e157600080fd5b6000611c028484612eb2565b6000806040838503121561330057600080fd5b600061330c8585612eb2565b925050602061331d85828601612eb2565b9150509250929050565b6000806040838503121561333a57600080fd5b60006133468585612eb2565b925050602061331d8582860161300e565b600080600080600060a0868803121561336f57600080fd5b600061337b8888612eb2565b955050602061338c88828901613069565b945050604061339d88828901613069565b93505060606133ae888289016131d8565b92505060806133bf888289016131d8565b9150509295509295909350565b600080604083850312156133df57600080fd5b823567ffffffffffffffff8111156133f657600080fd5b61340285828601612f2a565b925050602083013567ffffffffffffffff81111561341f57600080fd5b61331d85828601612ebe565b60006020828403121561343d57600080fd5b813567ffffffffffffffff81111561345457600080fd5b611c0284828501612f9c565b60006020828403121561347257600080fd5b6000611c0284846131d8565b60006040828403121561349057600080fd5b6000611c02848461320b565b600080606083850312156134af57600080fd5b60006134bb858561320b565b925050604061331d858286016132b7565b6000602082840312156134de57600080fd5b6000611c02848461328d565b6000602082840312156134fc57600080fd5b6000611c0284846132b7565b60006020828403121561351a57600080fd5b6000611c0284846132c3565b6000806040838503121561353957600080fd5b600061330c85856132b7565b6000806040838503121561355857600080fd5b600061334685856132b7565b6000806040838503121561357757600080fd5b600061358385856132b7565b925050602061331d85828601613069565b600080604083850312156135a757600080fd5b60006135b385856132b7565b925050602061331d858286016131d8565b600080604083850312156135d757600080fd5b60006135e385856132b7565b925050602061331d858286016132b7565b60006136008383613640565b505060200190565b6000610c0983836138ac565b600061362083836139e0565b505060400190565b60006136208383613a9e565b60006136208383613b91565b61364981614015565b82525050565b600061365a82614008565b613664818561400c565b935061366f83614002565b60005b8281101561369a576136858683516135f4565b955061369082614002565b9150600101613672565b5093949350505050565b60006136af82614008565b6136b9818561400c565b9350836020820285016136cb85614002565b60005b848110156137025783830388526136e6838351613608565b92506136f182614002565b6020989098019791506001016136ce565b50909695505050505050565b600061371982614008565b613723818561400c565b935061372e83614002565b60005b8281101561369a57613744868351613614565b955061374f82614002565b9150600101613731565b600061376482614008565b61376e818561400c565b935061377983614002565b60005b8281101561369a5761378f868351613628565b955061379a82614002565b915060010161377c565b60006137af82614008565b6137b9818561400c565b93506137c483614002565b60005b8281101561369a576137da868351613634565b95506137e582614002565b91506001016137c7565b61364981614020565b61364961380482614025565b61406f565b6136496138048261404a565b6136496138048261406f565b600061382c82614008565b613836818561082c565b9350613846818560208601614145565b9290920192915050565b600061385b82614008565b613865818561400c565b9350613875818560208601614145565b61387e81614171565b9093019392505050565b613649816140ef565b61364981614118565b61364981614123565b6136498161412e565b80516000906101608401906138c18582613891565b5060208301516138d46020860182613bab565b5060408301516138e7604086018261394e565b5060608301516138fa60c0860182613bab565b50608083015161390d60e0860182613bab565b5060a0830151613921610100860182613640565b5060c0830151613935610120860182613bab565b5060e0830151848203610140860152611ab88282613850565b8051608083019061395f84826137ef565b506020820151613972602085018261389a565b506040820151613985604085018261389a565b5060608201516125de6060850182613bab565b805160208301906125de8482613bab565b805160608301906139ba8482613bc6565b5060208201516139cd6020850182613bc6565b5060408201516125de6040850182613bb4565b805160408301906139f18482613640565b5060208201516125de6020850182613bab565b8051610160830190613a168482613640565b506020820151613a296020850182613b80565b506040820151613a3c60608501826139a9565b506060820151613a4f60c0850182613888565b506080820151613a6260e0850182613888565b5060a0820151613a76610100850182613998565b5060c0820151613a8a610120850182613998565b5060e08201516125de6101408501826137ef565b80516040830190613aaf84826137ef565b5060208201516125de6020850182613ba2565b805160c0830190613ad38482613bbd565b506020820151613ae66020850182613bbd565b506040820151613af96040850182613bbd565b506060820151613b0c6060850182613bbd565b506080820151613b1f6080850182613bbd565b5060a08201516125de60a0850182613ba2565b80516080830190613b438482613998565b506020820151613b566020850182613998565b506040820151613b696040850182613998565b5060608201516125de6060850182613998565b9052565b80516040830190613aaf8482613ba2565b805160408301906139f184826137ef565b6136498161409a565b6136498161406f565b613649816140c8565b613649816140d1565b613649816140de565b6000613bdb8284613815565b50602001919050565b6000613bf08286613821565b9150613bfc8285613809565b600282019150611ab88284613821565b6000613c188289613821565b9150613c248288613809565b600282019150613c348287613821565b9150613c408286613809565b600282019150613c508285613821565b9150613c5c82846137f8565b506001019695505050505050565b60208101610c0c8284613640565b60408101613c868285613640565b61196260208301846137ef565b60608101613ca18286613640565b613cae6020830185613bab565b611c026040830184613bab565b60608082528101613ccc818661364f565b90508181036020830152613ce08185613759565b90508181036040830152611ab881846137a4565b60208101610c0c82846137ef565b60208101610c0c8284613888565b60208101610c0c82846138a3565b60208082528101610c098184613850565b60208101610c0c8284613998565b60608101610c0c82846139a9565b6101608101610c0c8284613a04565b6102008101613d698287613a04565b613d776101608301866139a9565b613d856101c0830185613998565b611ab86101e0830184613998565b60408101610c0c8284613a9e565b60c08101610c0c8284613ac2565b60808101610c0c8284613b32565b60608101613dcb8286613b7c565b613dd86020830185613640565b611c026040830184613640565b60608101613df38286613b7c565b613e006020830185613640565b611c0260408301846137ef565b60c08101613e1b8289613b7c565b613e286020830188613640565b613e356040830187613888565b613e426060830186613888565b613e4f6080830185613998565b613e5c60a0830184613998565b979650505050505050565b60608101613e758286613b7c565b8181036020830152613e87818561370e565b90508181036040830152611ab881846136a4565b60408101613ea98285613b7c565b6119626020830184613998565b60608101613ec48286613b7c565b613dd86020830185613bab565b60608101613edf8286613b7c565b613e006020830185613bab565b60608101613efa8286613b7c565b613f076020830185613bab565b611c026040830184613888565b60608101613f228286613b7c565b613f2f6020830185613bab565b611c026040830184613998565b60408101610c0c8284613b80565b60408101613ea98285613998565b60408101610c0c8284613b91565b60208101610c0c8284613bab565b60405181810167ffffffffffffffff81118282101715613f9357600080fd5b604052919050565b600067ffffffffffffffff821115613fb257600080fd5b5060209081020190565b600067ffffffffffffffff821115613fd357600080fd5b506020601f919091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160190565b60200190565b5190565b90815260200190565b6000610829826140af565b151590565b7fff000000000000000000000000000000000000000000000000000000000000001690565b7fffff0000000000000000000000000000000000000000000000000000000000001690565b90565b60006009821061407e57fe5b5090565b60006002821061407e57fe5b60006003821061407e57fe5b6fffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1690565b63ffffffff1690565b67ffffffffffffffff1690565b6bffffffffffffffffffffffff1690565b600061082982614015565b60006009821061407e57600080fd5b60006002821061407e57600080fd5b600061082982614072565b600061082982614082565b60006108298261408e565b82818337506000910152565b60005b83811015614160578181015183820152602001614148565b838111156125de5750506000910152565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169056fea265627a7a7230582008995f40419ef058c1879e395376a60652d794668b2ac708a61d8c9e9857b0e36c6578706572696d656e74616cf500370000000000000000000000000000000000000000000000000214e8348c4f000000000000000000000000000000000000000000000000000000b1a2bc2ec500000000000000000000000000000000000000000000000000000c7d713b49da000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000000000000000000000000000006f05b59d3b200000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000056bc75e2d63100000

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000000000000000000000000000000214e8348c4f000000000000000000000000000000000000000000000000000000b1a2bc2ec500000000000000000000000000000000000000000000000000000c7d713b49da000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000000000000000000000000000006f05b59d3b200000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000056bc75e2d63100000

-----Decoded View---------------
Arg [0] : riskParams (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
Arg [1] : riskLimits (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000214e8348c4f0000
Arg [1] : 00000000000000000000000000000000000000000000000000b1a2bc2ec50000
Arg [2] : 0000000000000000000000000000000000000000000000000c7d713b49da0000
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [4] : 0000000000000000000000000000000000000000000000001bc16d674ec80000
Arg [5] : 00000000000000000000000000000000000000000000000006f05b59d3b20000
Arg [6] : 0000000000000000000000000000000000000000000000000de0b6b3a7640000
Arg [7] : 0000000000000000000000000000000000000000000000001bc16d674ec80000
Arg [8] : 0000000000000000000000000000000000000000000000001bc16d674ec80000
Arg [9] : 0000000000000000000000000000000000000000000000056bc75e2d63100000


Deployed ByteCode Sourcemap

153815:378:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;153815:378:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;72019:305;;;;;;;;;:::i;:::-;;90809:182;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;77590:219;;;;;;;;;:::i;:::-;;;;;;;;70982:305;;;;;;;;;:::i;87321:263::-;;;;;;;;;:::i;:::-;;;;;;;;;79341:234;;;;;;;;;:::i;:::-;;;;;;;;79763:243;;;;;;;;;:::i;80880:245::-;;;;;;;;;:::i;:::-;;;;;;;;77285:131;;;:::i;:::-;;;;;;;;69124:331;;;;;;;;;:::i;73722:269::-;;;;;;;;;:::i;72923:249::-;;;;;;;;;:::i;73347:251::-;;;;;;;;;:::i;90294:211::-;;;;;;;;;:::i;85722:265::-;;;;;;;;;:::i;:::-;;;;;;;;71508:305;;;;;;;;;:::i;75162:156::-;;;:::i;78893:266::-;;;;;;;;;:::i;:::-;;;;;;;;81398:222;;;;;;;;;:::i;76575:149::-;;;:::i;:::-;;;;;;;;89042:788;;;;;;;;;:::i;:::-;;;;;;;;;;2117:140;;;:::i;76277:168::-;;;:::i;153274:382::-;;;;;;;;;:::i;81818:228::-;;;;;;;;;:::i;1404:79::-;;;:::i;1739:92::-;;;:::i;68698:327::-;;;;;;;;;:::i;69618:488::-;;;;;;;;;:::i;151726:272::-;;;;;;;;;:::i;84260:510::-;;;;;;;;;:::i;:::-;;;;;;;;;;;72516:235;;;;;;;;;:::i;75545:168::-;;;:::i;86224:382::-;;;;;;;;;:::i;:::-;;;;;;;;78021:232;;;;;;;;;:::i;:::-;;;;;;;;82986:357;;;;;;;;;:::i;85188:235::-;;;;;;;;;:::i;78447:232::-;;;;;;;;;:::i;86807:192::-;;;;;;;;;:::i;:::-;;;;;;;;75938:158;;;:::i;70620:290::-;;;;;;;;;:::i;76966:149::-;;;:::i;:::-;;;;;;;;83567:220;;;;;;;;;:::i;:::-;;;;;;;;70277:274;;;;;;;;;:::i;74237:282::-;;;;;;;;;:::i;2434:109::-;;;;;;;;;:::i;88355:270::-;;;;;;;;;:::i;80327:245::-;;;;;;;;;:::i;82239:306::-;;;;;;;;;:::i;72019:305::-;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;72201:115;;;;;:9;;:31;;:115;;3949:13;;72269:8;;72292:13;;72201:115;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;72201:115:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;72201:115:0;;;;4061:13;;4045:12;:29;4037:38;;;;;;1637:1;72019:305;;:::o;90809:182::-;90920:4;90949:34;90920:4;90974:8;90949:34;:24;:34;:::i;:::-;90942:41;;90809:182;;;;:::o;77590:219::-;77703:7;77728:29;77748:8;77728:19;:29::i;:::-;77775:26;:7;77792:8;77775:26;:16;:26;:::i;70982:305::-;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;71162:117;;;;;:9;;:32;;:117;;3949:13;;71231:8;;71254:14;;71162:117;;;;87321:263;87440:21;;:::i;:::-;87463;;:::i;:::-;87509:67;87534:7;87570:5;87509:24;:67::i;:::-;87502:74;;;;87321:263;;;:::o;79341:234::-;79453:12;79483:29;79503:8;79483:19;:29::i;:::-;-1:-1:-1;79530:7:0;:25;;;:15;:25;;;;;:37;;;;;;79341:234::o;79763:243::-;79878:15;79911:29;79931:8;79911:19;:29::i;:::-;-1:-1:-1;79958:7:0;:25;;;:15;:25;;;;;:40;;;;;;79763:243::o;80880:245::-;80994:19;;:::i;:::-;81031:29;81051:8;81031:19;:29::i;:::-;-1:-1:-1;81078:7:0;:25;;;:15;:25;;;;;;;;;81071:46;;;;;;;;81078:39;;;;81071:46;;;;80880:245::o;77285:131::-;77358:7;77390:18;77285:131;:::o;69124:331::-;69298:7;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;69330:117;;;;;:9;;:40;;:117;;3949:13;;69407:5;;69427:9;;69330:117;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;69330:117:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;69330:117:0;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;69330:117:0;;;;;;;;;69323:124;;4061:13;;4045:12;:29;4037:38;;;;;;1637:1;69124:331;;;;:::o;73722:269::-;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;73885:98;;;;;:9;;:34;;:98;;3949:13;;73956:16;;73885:98;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;73885:98:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;73885:98:0;;;;4061:13;;4045:12;:29;4037:38;;;;;;1637:1;73722:269;:::o;72923:249::-;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;73075:89;;;;;:9;;:35;;:89;;3949:13;;73147:6;;73075:89;;;;73347:251;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;73500:90;;;;;:9;;:30;;:90;;3949:13;;73567:12;;73500:90;;;;90294:211;90428:4;90457:40;90428:4;90481:5;90488:8;90457:40;:23;:40;:::i;:::-;90450:47;;90294:211;;;;;:::o;85722:265::-;85865:16;;:::i;:::-;85899:29;85919:8;85899:19;:29::i;:::-;85946:33;:7;85961;85970:8;85946:33;:14;:33;:::i;71508:305::-;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;71690:115;;;;;:9;;:31;;:115;;3949:13;;71758:8;;71781:13;;71690:115;;;;75162:156;75236:19;;:::i;:::-;-1:-1:-1;75273:37:0;;;;;;;;;75280:18;75273:37;;;75162:156;:::o;78893:266::-;79006:21;;:::i;:::-;79045:29;79065:8;79045:19;:29::i;:::-;79092:59;79114:8;79124:26;:7;79114:8;79124:26;:16;:26;:::i;:::-;79092:7;;:59;;:21;:59;:::i;81398:222::-;81508:4;81530:29;81550:8;81530:19;:29::i;:::-;-1:-1:-1;81577:7:0;:25;;;:15;:25;;;;;:35;;;;;;81398:222::o;76575:149::-;76648:25;;:::i;:::-;-1:-1:-1;76691:25:0;;;;;;;;76698:18;76691:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;76691:25:0;;;;;;;;;;;;;;;;;;;;76575:149;:::o;89042:788::-;89177:16;89208:18;89241;89287;89308:7;:18;;;89287:39;;89337:23;89377:10;89363:25;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;89363:25:0;;89337:51;;89399:23;89441:10;89425:27;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;89399:53;;89463:23;89505:10;89489:27;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;-1:-1:-1;89463:53:0;-1:-1:-1;89534:9:0;89529:204;89553:10;89549:1;:14;89529:204;;;89597:24;89619:1;89597:21;:24::i;:::-;89585:6;89592:1;89585:9;;;;;;;;;;;;;:36;;;;;;;;;;;89646:25;89660:7;89669:1;89646:13;:25::i;:::-;89636:4;89641:1;89636:7;;;;;;;;;;;;;:35;;;;89696:25;89710:7;89719:1;89696:13;:25::i;:::-;89686:4;89691:1;89686:7;;;;;;;;;;;;;;;;;:35;89565:3;;89529:204;;;-1:-1:-1;89767:6:0;;89788:4;;-1:-1:-1;89767:6:0;;-1:-1:-1;89042:788:0;-1:-1:-1;;;89042:788:0:o;2117:140::-;1616:9;:7;:9::i;:::-;1608:18;;;;;;2200:6;;2179:40;;2216:1;;2179:40;2200:6;;2179:40;;2216:1;;2179:40;2230:6;:19;;;;;;2117:140::o;76277:168::-;76356:21;;:::i;:::-;-1:-1:-1;76395:42:0;;;;;;;;;76402:35;76395:42;;;76277:168;:::o;153274:382::-;153376:9;153371:278;153395:4;:11;153391:1;:15;153371:278;;;153428:16;153447:4;153452:1;153447:7;;;;;;;;;;;;;;:16;;;153428:35;;153478:12;153493:4;153498:1;153493:7;;;;;;;;;;;;;;;;;;;:15;;;153541:10;153523:7;:29;;;:17;:29;;;;;;;:39;;;;;;;;;;:49;;;;;;;;;;153592:45;;153493:15;;-1:-1:-1;153592:45:0;;;;153523:39;;153493:15;;153592:45;;;;;;;;;;-1:-1:-1;;153408:3:0;;153371:278;;81818:228;81924:21;;:::i;:::-;81963:29;81983:8;81963:19;:29::i;:::-;82010:28;:7;82029:8;82010:28;:18;:28;:::i;1404:79::-;1469:6;;;;1404:79;:::o;1739:92::-;1817:6;;;;1803:10;:20;;1739:92::o;68698:327::-;68870:7;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;68902:115;;;;;:9;;:35;;:115;;3949:13;;68974:8;;68997:9;;68902:115;;;;69618:488;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;69910:188;;;;;:9;;:24;;:188;;3949:13;;69971:5;;69991:11;;70017:14;;70046:13;;70074;;69910:188;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;69910:188:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;69910:188:0;;;;4061:13;;4045:12;:29;4037:38;;;;;;1637:1;69618:488;;;;;:::o;151726:272::-;3949:13;:18;;3966:1;3949:18;;;;;151891:99;;;;;:13;;:21;;:99;;3949:13;;151949:8;;151972:7;;151891:99;;;;84260:510;84383:21;;:::i;:::-;84419;;:::i;:::-;84455;;:::i;:::-;84491:20;;:::i;:::-;84539:29;84559:8;84539:19;:29::i;:::-;84601:19;84611:8;84601:9;:19::i;:::-;84635:31;84657:8;84635:21;:31::i;:::-;84681:24;84696:8;84681:14;:24::i;:::-;84720:31;84742:8;84720:21;:31::i;:::-;84579:183;;;;;;;;84260:510;;;;;:::o;72516:235::-;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;72661:82;;;;;:9;;:29;;:82;;3949:13;;72727:5;;72661:82;;;;75545:168;75625:19;;:::i;:::-;-1:-1:-1;75662:43:0;;;;;;;;;75669:36;75662:43;;;75545:168;:::o;86224:382::-;86367:16;;:::i;:::-;86401:29;86421:8;86401:19;:29::i;:::-;86448:150;86480:33;:7;86495;86504:8;86480:33;:14;:33;:::i;:::-;86528:59;86550:8;86560:26;:7;86550:8;86560:26;:16;:26;:::i;86528:59::-;86448:17;:150::i;78021:232::-;78130:21;;:::i;:::-;78169:29;78189:8;78169:19;:29::i;:::-;78216;:7;78236:8;78216:29;:19;:29;:::i;82986:357::-;83140:19;;:::i;:::-;83177:33;83197:12;83177:19;:33::i;:::-;83221;83241:12;83221:19;:33::i;:::-;83272:63;:7;83308:12;83322;83272:63;:35;:63;:::i;85188:235::-;85298:16;;:::i;:::-;85332:29;85352:8;85332:19;:29::i;:::-;85379:36;:7;85406:8;85379:36;:26;:36;:::i;78447:232::-;78559:21;;:::i;:::-;78598:29;78618:8;78598:19;:29::i;:::-;78645:26;:7;78662:8;78645:26;:16;:26;:::i;86807:192::-;86926:14;86965:26;86926:14;86983:7;86965:26;:17;:26;:::i;75938:158::-;76013:19;;:::i;:::-;-1:-1:-1;76050:38:0;;;;;;;;;76057:31;76050:38;;;75938:158;:::o;70620:290::-;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;70791:111;;;;;:9;;:29;;:111;;3949:13;;70857:8;;70880:11;;70791:111;;;;76966:149;77039:25;;:::i;:::-;-1:-1:-1;77082:25:0;;;;;;;;77089:18;77082:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;76966:149::o;83567:220::-;83668:21;;:::i;:::-;83707:29;83727:8;83707:19;:29::i;:::-;-1:-1:-1;83754:7:0;:25;;;:15;:25;;;;;;;;;83747:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;83567:220::o;70277:274::-;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;70436:107;;;;;:9;;:27;;:107;;3949:13;;70500:8;;70523:9;;70436:107;;;;74237:282;1616:9;:7;:9::i;:::-;1608:18;;;;;;3949:13;:18;;3966:1;3949:18;;;;;74400:111;;;;;:9;;:32;;:111;;3949:13;;74469:8;;74492;;74400:111;;;;2434:109;1616:9;:7;:9::i;:::-;1608:18;;;;;;2507:28;2526:8;2507:18;:28::i;:::-;2434:109;:::o;88355:270::-;88482:21;;:::i;:::-;88505;;:::i;:::-;88551:66;88576:7;88612:4;88551:24;:66::i;80327:245::-;80441:19;;:::i;:::-;80478:29;80498:8;80478:19;:29::i;:::-;-1:-1:-1;80525:7:0;:25;;;:15;:25;;;;;;;;;80518:46;;;;;;;;80525:39;;;;80518:46;;;;80327:245::o;82239:306::-;82352:20;;:::i;:::-;82390:29;82410:8;82390:19;:29::i;:::-;82437:100;82477:8;82500:26;:7;82477:8;82500:26;:16;:26;:::i;:::-;82437:7;;:100;;:25;:100;:::i;50033:216::-;50210:31;;50181:4;50210:31;;;:21;;;;;:31;;;;;;;;;50033:216::o;91117:231::-;91227:113;91265:7;:18;;;91254:8;:29;91298:4;;91227:113;:12;:113::i;42846:209::-;42986:7;43018:23;;;:13;;;;;:23;;;;;:29;;;;42846:209::o;91444:629::-;91606:21;;:::i;:::-;91629;;:::i;:::-;91668:18;91689;91747:30;;:::i;:::-;91780:24;91793:10;91780:12;:24::i;:::-;91747:57;-1:-1:-1;91820:9:0;91815:171;91839:10;91835:1;:14;91815:171;;;91876:35;:26;:7;91891;91900:1;91876:26;:14;:26;:::i;:::-;:33;:35::i;:::-;91871:104;;91932:27;:5;91948:7;91957:1;91932:27;:15;:27;:::i;:::-;;91871:104;91851:3;;91815:171;;;-1:-1:-1;92005:60:0;:7;92030;92039:5;92046:18;92005:60;:24;:60;:::i;:::-;91998:67;;;;;;91444:629;;;;;:::o;50257:240::-;50457:22;;;;50428:4;50457:22;;;:15;;;:22;;;;;;;;:32;;;;;;;;;;;;50257:240;;;;;;:::o;44608:289::-;44784:16;;:::i;:::-;-1:-1:-1;44840:13:0;;44825:29;;;;;;:14;;;:29;;;;;;;;44855:14;;;;44825:45;;;;;;;:64;;;;;;;;;44818:71;;;;;;;;;;;;;;;;;;;;;;;;;;44608:289;;;;;:::o;43300:223::-;43440:21;;:::i;:::-;-1:-1:-1;43486:23:0;;;;:13;;;;;:23;;;;;;;;;43479:36;;;;;;;43486:29;;;;43479:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;43300:223::o;45951:480::-;46134:21;;:::i;:::-;46173:25;;:::i;:::-;46201:40;:5;46225:8;46235:5;46201:40;:23;:40;:::i;:::-;46173:68;-1:-1:-1;46261:162:0;46302:5;46173:68;46341:27;:5;46359:8;46341:27;:17;:27;:::i;:::-;46261:162;;;;;;;;;46383:29;;;46261:162;;;:26;:162::i;:::-;46254:169;45951:480;-1:-1:-1;;;;;45951:480:0:o;47115:509::-;47257:21;;:::i;:::-;47296:19;47331:23;;;:13;;;:23;;;;;:35;;;;;47378:27;;:::i;:::-;47408:15;;;;47424:24;:5;47439:8;47424:24;:14;:24;:::i;:::-;47408:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;47408:41:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;47408:41:0;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;47408:41:0;;;;;;;;;47487:11;;47378:71;;-1:-1:-1;47460:133:0;;47487:16;;47518:4;47460:133;47574:8;47460:12;:133::i;:::-;47611:5;47115:509;-1:-1:-1;;;;47115:509:0:o;30965:572::-;31102:16;;:::i;:::-;31165:11;;;;31192:10;;31157:20;;;;;31188:342;;;31226:122;;;;;;;;;31261:4;31226:122;;;31313:12;;;;31226:122;;;;31291:41;;:10;;:41;;28236:6;31291:41;:21;:41;:::i;:::-;31226:122;;;31219:129;;;;;31188:342;31388:130;;;;;;;;;-1:-1:-1;31388:130:0;;31483:12;;31388:130;;;;31454:48;;:10;;:48;;28236:6;31454:48;:28;:48;:::i;43063:229::-;43206:21;;:::i;:::-;-1:-1:-1;43252:23:0;;;;:13;;;;:23;;;;;;;;;43245:39;;;;;;;;43252:32;;;43245:39;;;;;;;;;;;;;;;;43063:229;;;;:::o;45378:565::-;45572:19;;:::i;:::-;45626:34;;;;:40;45609:14;45722:27;;;45626:34;45722:13;;:27;;;;;;;;;45706:58;;;;;;;;45722:41;;45706:58;;;45626:40;45686:79;;45626:40;;45706:58;;:15;:58::i;:::-;45686:11;:79::i;:::-;45677:88;;45785:79;45797:6;45805:58;45821:5;:13;;:27;45835:12;45821:27;;;;;;;;;;;:41;;45805:58;;;;;;;;;;;;;;;;;:15;:58::i;45785:79::-;45882:53;;;;;;;;;;;;;45378:565;-1:-1:-1;;;;;45378:565:0:o;43531:810::-;43681:16;;:::i;:::-;43715:27;;:::i;:::-;43745:24;:5;43760:8;43745:24;:14;:24;:::i;:::-;43715:54;;43780:30;;:::i;:::-;43813:27;:5;43831:8;43813:27;:17;:27;:::i;:::-;43780:60;-1:-1:-1;43853:13:0;43869:24;:5;43884:8;43869:24;:14;:24;:::i;:::-;43853:40;;43906:27;;:::i;:::-;43936:106;;;;;;;;43967:4;43936:106;;;;;;43993:37;44009:5;44024:4;43993:15;:37::i;:::-;43936:106;;43906:136;-1:-1:-1;44070:26:0;;:::i;:::-;44111;;:::i;:::-;44151:39;44174:8;44184:5;44151:22;:39::i;:::-;44055:135;;-1:-1:-1;44055:135:0;-1:-1:-1;44293:40:0;44055:135;44293:25;:10;44055:135;44293:25;:14;:25;:::i;:::-;:29;:40;:29;:40;:::i;:::-;44286:47;43531:810;-1:-1:-1;;;;;;;;;43531:810:0:o;44349:251::-;44555:13;;44540:29;;44501:14;44540:29;;;:14;;;;;:29;;;;;;;;44570:14;;;;44540:45;;;;;;;:52;;;;;;44349:251::o;2693:187::-;2767:22;;;2759:31;;;;;;2827:6;;2806:38;;;;;;;2827:6;;2806:38;;2827:6;;2806:38;2855:6;:17;;;;;;;;;;;;;;;2693:187::o;46439:668::-;46626:20;;:::i;:::-;46664:30;;:::i;:::-;46697:27;:5;46715:8;46697:27;:17;:27;:::i;:::-;46664:60;;46750:26;;:::i;:::-;46791;;:::i;:::-;46831:39;46854:8;46864:5;46831:22;:39::i;:::-;46735:135;;;;46883:25;;:::i;:::-;46911:23;;;;:13;;;:23;;;;;:38;;;;;:54;46980:24;46911:5;46925:8;46980:24;:14;:24;:::i;:::-;47019:9;:15;;;47049:9;:15;;;46911:164;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;46911:164:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;46911:164:0;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;46911:164:0;;;;;;;;;46883:192;46439:668;-1:-1:-1;;;;;;;;46439:668:0:o;6743:427::-;6885:4;6880:283;;7003:15;7013:4;7003:9;:15::i;:::-;7045:5;7077:17;7087:6;7077:9;:17::i;:::-;6960:157;;;;;;;;;;;;;;;22:32:-1;26:21;;;22:32;6:49;;6960:157:0;;;;6906:245;;;;;;;;;;;;;;;;;24131:229;24233:18;;:::i;:::-;24276:76;;;;;;;;24329:10;24312:28;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;-1:-1:-1;24276:76:0;;24269:83;24131:229;-1:-1:-1;;24131:229:0:o;19263:145::-;19388:7;;;:12;;;;19263:145::o;24572:567::-;24748:4;24774:25;:5;24790:8;24774:25;:15;:25;:::i;:::-;24770:70;;;-1:-1:-1;24823:5:0;24816:12;;24770:70;24882:26;:5;24899:8;24882:26;:16;:26;:::i;:::-;24850:13;;:23;;24864:8;;24850:23;;;;;;;;;;;;;;;;;:29;;;;:58;;;;24923:23;;;;:13;;;:23;;;;:33;;;;;24919:191;;;25009:4;24973:5;:13;;;24987:8;24973:23;;;;;;;;;;;;;;;;;;:40;;;;;25064:27;:5;25082:8;25064:27;:17;:27;:::i;:::-;:34;25028:13;;:23;;25042:8;;25028:23;;;;;;;;;;;;;;;;;:70;;;;:33;;:70;24919:191;-1:-1:-1;25127:4:0;24572:567;;;;;:::o;47632:1300::-;47866:21;;:::i;:::-;47889;;:::i;:::-;47928:33;;:::i;:::-;47972;;:::i;:::-;48018:18;48039:21;:5;:19;:21::i;:::-;48018:42;-1:-1:-1;48076:9:0;48071:808;48095:10;48091:1;:14;48071:808;;;48132:18;:5;48148:1;48132:18;:15;:18;:::i;:::-;48127:68;;48171:8;;48127:68;48211:24;;:::i;:::-;48238;:5;48251:7;48260:1;48238:24;:12;:24;:::i;:::-;48211:51;;48283:16;:7;:14;:16::i;:::-;48279:65;;;48320:8;;;48279:65;48360:18;48381:42;48399:17;:5;48414:1;48399:17;:14;:17;:::i;:::-;:23;48381:13;;;;;:42;:17;:42;:::i;:::-;48360:63;;48438:26;;:::i;:::-;48467:13;:11;:13::i;:::-;48438:42;;48499:18;48495:115;;;48563:16;;;;:13;;;:16;;;;;;;;;48547:47;;;;;;;;48563:30;;;;48547:47;;;;;:15;:47::i;:::-;48538:56;;48495:115;48630:12;;48626:242;;;48683:54;48705:31;48717:10;48729:6;48705:11;:31::i;:::-;48683:17;;;:54;:21;:54;:::i;:::-;48663:74;;48626:242;;;48798:54;48820:31;48832:10;48844:6;48820:11;:31::i;:::-;48798:17;;;:54;:21;:54;:::i;:::-;48778:74;;48626:242;48071:808;;;;48107:3;;48071:808;;;-1:-1:-1;48899:11:0;;48912;;-1:-1:-1;47632:1300:0;-1:-1:-1;;;;;;47632:1300:0:o;29296:1335::-;29520:12;;:::i;:::-;29565:26;;:::i;:::-;29606;;:::i;:::-;29646:30;29660:8;29670:5;29646:13;:30::i;:::-;29550:126;;;;29737:18;29758;:16;:18::i;:::-;29737:39;;29787:22;29812:58;29827:42;29852:5;:16;;;29827:42;;29835:11;29827:20;;:24;;:42;;;;:::i;:::-;29812:10;;;:58;:14;:58;:::i;:::-;29787:83;;29931:22;29968:23;29981:9;29968:12;:23::i;:::-;29964:335;;;-1:-1:-1;30025:1:0;29964:335;;;30076:41;30088:14;30104:12;30076:11;:41::i;:::-;30059:58;;30154:9;:15;;;30136:9;:15;;;:33;30132:156;;;30207:65;30223:14;30239:9;:15;;;30256:9;:15;;;30207;:65::i;:::-;30190:82;;30132:156;30334:14;30316;:32;;30309:40;;;;30369:254;;;;;;;;;30454:12;;30369:254;;30398:76;;:69;;;;:51;:69;30428:14;28236:6;30398:15;:51::i;:::-;:55;:69;:55;:69;:::i;:::-;:74;:76::i;:::-;30369:254;;;;;;;30553:12;;;;30369:254;;;30497:76;;:69;;;:51;:69;30527:14;28236:6;30497:15;:51::i;:76::-;30369:254;;;;;;30600:11;30369:254;;;;;30362:261;;;;;;;29296:1335;;;;;;:::o;7178:566::-;7347:4;7342:395;;7465:15;7475:4;7465:9;:15::i;:::-;7507:5;7539:17;7549:6;7539:9;:17::i;:::-;7583:6;7616:19;7626:8;7616:9;:19::i;:::-;7422:269;;;;;;;;;7662:6;;7422:269;;;;7342:395;7178:566;;;;:::o;14219:238::-;14379:7;14411:38;14437:11;14411:21;:6;14422:9;14411:21;:10;:21;:::i;:::-;:25;:38;:25;:38;:::i;14549:423::-;14716:7;14745:11;;;:29;;-1:-1:-1;14760:14:0;;14745:29;14741:154;;;14855:28;14868:1;14871:11;14855:12;:28::i;:::-;14848:35;;;;14741:154;14912:52;14962:1;14912:45;14945:11;14912:28;14962:1;14912:21;:6;14923:9;14912:21;:10;:21;:::i;:::-;:25;:28;:25;:28;:::i;26864:176::-;26962:11;;:::i;:::-;26998:34;;;;;;;;;27012:7;;26998:34;;27012:17;;26569:6;27012:17;:11;:17;:::i;:::-;26998:34;;26991:41;26864:176;-1:-1:-1;;26864:176:0:o;27048:197::-;27167:7;27199:38;27215:6;27223:1;:7;;;26569:6;27199:15;:38::i;34977:194::-;35133:30;;;;;35101:7;;35133:23;;;;;;:30;;35157:5;;35133:30;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;35133:30:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;35133:30:0;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;35133:30:0;;;;;;;;32318:620;32468:16;;:::i;:::-;32486;;:::i;:::-;32520:26;;:::i;:::-;-1:-1:-1;32549:84:0;;;;;;;;;32580:4;32549:84;;;32606:15;;;;32549:84;;;;;;32644:26;;:::i;:::-;-1:-1:-1;32673:85:0;;;;;;;;;-1:-1:-1;32673:85:0;;32731:15;;32673:85;;;;;;32769:26;;:::i;:::-;32798;32807:9;32818:5;32798:8;:26::i;:::-;32769:55;;32835:26;;:::i;:::-;32864;32873:9;32884:5;32864:8;:26::i;:::-;32909:9;;;;-1:-1:-1;32318:620:0;;-1:-1:-1;;;;;;32318:620:0:o;19794:178::-;19910:10;;:::i;:::-;19945:19;19949:1;19952:11;19961:1;19952:8;:11::i;:::-;19945:3;:19::i;10522:988::-;10621:12;10699:19;10738:5;10721:23;;;;;;;;;;;;;22:32:-1;26:21;;;22:32;6:49;;10721:23:0;;;;-1:-1:-1;49:4;10853:587:0;10874:5;;10853:587;;11131:9;;11030:3;;;;;11131:6;;11030:3;;11131:9;;;;;;;;;;;;;;;;;:14;;;11127:302;;11187:1;11183:5;11317:22;;11324:6;-1:-1:-1;11400:13:0;;11127:302;10853:587;;;-1:-1:-1;;11490:12:0;;;11500:1;11490:12;;;;;;;;;11483:19;-1:-1:-1;;10522:988:0:o;25383:215::-;25521:4;25550:5;:13;;;25564:8;25550:23;;;;;;;;;;;;;;:29;;;:35;;;25589:1;25550:40;;25543:47;;25383:215;;;;:::o;25200:175::-;25347:13;:20;;25200:175::o;44905:465::-;45081:16;;:::i;:::-;45115:20;;:::i;:::-;45138:31;:5;45151:7;45160:8;45138:31;:12;:31;:::i;:::-;45115:54;;45186:12;:3;:10;:12::i;:::-;45182:67;;;45222:15;:13;:15::i;:::-;45215:22;;;;;45182:67;45261:27;;:::i;:::-;45291:24;:5;45306:8;45291:24;:14;:24;:::i;:::-;45261:54;;45333:29;45351:3;45356:5;45333:17;:29::i;:::-;45326:36;44905:465;-1:-1:-1;;;;;;44905:465:0:o;21506:145::-;21631:7;;;:12;;21506:145::o;25825:220::-;25962:21;;:::i;:::-;26008:13;;:23;;26022:8;;26008:23;;;;;;;;;;;;:29;;;26001:36;;25825:220;;;;:::o;4364:433::-;4422:7;4666:6;4662:47;;-1:-1:-1;4696:1:0;4689:8;;4662:47;4733:5;;;4737:1;4733;:5;:1;4757:5;;;;;:10;4749:19;;;;;26726:130;26791:11;;:::i;:::-;-1:-1:-1;26827:21:0;;;;;;;;;26569:6;26827:21;;26726:130;:::o;27253:197::-;27372:7;27404:38;27420:6;26569;27434:1;:7;;;27404:15;:38::i;5605:150::-;5663:7;5695:5;;;5719:6;;;;5711:15;;;;;27722:138;27795:6;27826:26;27836:15;27826:9;:26::i;:::-;27819:33;;27722:138;:::o;5369:150::-;5427:7;5460:1;5455;:6;;5447:15;;;;;;-1:-1:-1;5485:5:0;;;5369:150::o;15297:304::-;15393:6;15440;15458:111;15485:16;;;;;15516:4;15458:111;:12;:111::i;11518:949::-;11617:12;11651:10;11647:53;;-1:-1:-1;11678:10:0;;;;;;;;;;;;;;;;;;;11647:53;11764:5;11752:9;11805:72;11812:6;;11805:72;;11835:8;;11863:2;11858:7;;;;11805:72;;;11921:17;11951:6;11941:17;;;;;;;;;;;;;;;;;;;;;;;;;21:6:-1;;104:10;11941:17:0;87:34:-1;135:17;;-1:-1;11941:17:0;-1:-1:-1;12053:5:0;;-1:-1:-1;11921:37:0;-1:-1:-1;12086:6:0;12069:367;12094:5;;12069:367;;12250:3;;12349:2;12345:1;:6;6340:2;12331:21;12320:34;;12310:4;12315:1;12310:7;;;;;;;;;;;:44;;;;;;;;;;-1:-1:-1;12422:2:0;12417:7;;;;12069:367;;;-1:-1:-1;12455:4:0;11518:949;-1:-1:-1;;;;11518:949:0:o;4930:303::-;4988:7;5087:1;5083;:5;5075:14;;;;;;5100:9;5116:1;5112;:5;;;;;;;4930:303;-1:-1:-1;;;;4930:303:0:o;20951:214::-;21049:10;;:::i;:::-;-1:-1:-1;21084:73:0;;;;;;;;;21110:6;;21109:7;21084:73;;;21138:7;;;;21084:73;;;;20951:214;;;:::o;19980:632::-;20096:10;;:::i;:::-;20124:17;;:::i;:::-;20166:6;;20156;;:16;;;;;;20152:429;;;20203:6;;20189:20;;;;20252:7;;;;;20261;;;;20239:30;;20252:7;20239:12;:30::i;:::-;20224:12;;;:45;20152:429;;;20317:1;:7;;;20306:1;:7;;;:18;20302:268;;20359:6;;20345:20;;;;20412:7;;;;;20421;;;;20399:30;;20412:7;20399:12;:30::i;20302:268::-;20484:6;;20470:20;;;;20537:7;;;;;20546;;;;20524:30;;20537:7;20524:12;:30::i;:::-;20509:12;;;:45;:12;19980:632;-1:-1:-1;;;19980:632:0:o;19609:177::-;19678:10;;:::i;:::-;-1:-1:-1;19713:65:0;;;;;;;;;-1:-1:-1;19713:65:0;;;;;;;19609:177;:::o;15609:304::-;15705:6;15752;15770:111;15797:16;;;;;15828:4;15770:111;:12;:111::i;153815:378::-;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;-1:-1:-1;153815:378:0;;;;;;;;:::o;:::-;;;;;;;;;-1:-1:-1;153815:378:0;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;:::o;:::-;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;;:::o;:::-;;;;;;;;;-1:-1:-1;153815:378:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;-1:-1:-1;153815:378:0;;;;;;;;;;;;:::i;5:118:-1:-;;72:46;110:6;97:20;72:46;;166:750;;307:3;300:4;292:6;288:17;284:27;274:2;;325:1;322;315:12;274:2;362:6;349:20;384:104;399:88;480:6;399:88;;;384:104;;;516:21;;;560:4;548:17;;;;375:113;;-1:-1;573:14;;548:17;668:1;653:257;678:6;675:1;672:13;653:257;;;761:3;748:17;740:6;736:30;785:61;842:3;830:10;785:61;;;773:74;;-1:-1;870:4;861:14;;;;889;;;;;700:1;693:9;653:257;;;657:14;267:649;;;;;;;;954:761;;1089:3;1082:4;1074:6;1070:17;1066:27;1056:2;;1107:1;1104;1097:12;1056:2;1144:6;1131:20;1166:98;1181:82;1256:6;1181:82;;1166:98;1157:107;;1281:5;1306:6;1299:5;1292:21;1336:4;1328:6;1324:17;1314:27;;1358:4;1353:3;1349:14;1342:21;;1411:6;1458:3;1450:4;1442:6;1438:17;1433:3;1429:27;1426:36;1423:2;;;1475:1;1472;1465:12;1423:2;1500:1;1485:224;1510:6;1507:1;1504:13;1485:224;;;1568:3;1590:55;1641:3;1629:10;1590:55;;;1578:68;;-1:-1;1669:4;1660:14;;;;1697:4;1688:14;;;;;1532:1;1525:9;1485:224;;1763:782;;1905:3;1898:4;1890:6;1886:17;1882:27;1872:2;;1923:1;1920;1913:12;1872:2;1960:6;1947:20;1982:105;1997:89;2079:6;1997:89;;1982:105;1973:114;;2104:5;2129:6;2122:5;2115:21;2159:4;2151:6;2147:17;2137:27;;2181:4;2176:3;2172:14;2165:21;;2234:6;2281:3;2273:4;2265:6;2261:17;2256:3;2252:27;2249:36;2246:2;;;2298:1;2295;2288:12;2246:2;2323:1;2308:231;2333:6;2330:1;2327:13;2308:231;;;2391:3;2413:62;2471:3;2459:10;2413:62;;;2401:75;;-1:-1;2499:4;2490:14;;;;2527:4;2518:14;;;;;2355:1;2348:9;2308:231;;2553:112;;2617:43;2652:6;2639:20;2617:43;;2673:432;;2770:3;2763:4;2755:6;2751:17;2747:27;2737:2;;2788:1;2785;2778:12;2737:2;2825:6;2812:20;2847:60;2862:44;2899:6;2862:44;;2847:60;2838:69;;2927:6;2920:5;2913:21;2963:4;2955:6;2951:17;2996:4;2989:5;2985:16;3031:3;3022:6;3017:3;3013:16;3010:25;3007:2;;;3048:1;3045;3038:12;3007:2;3058:41;3092:6;3087:3;3082;3058:41;;;2730:375;;;;;;;;3113:166;;3204:70;3266:6;3253:20;3204:70;;3453:148;;3535:61;3588:6;3575:20;3535:61;;3608:160;;3696:67;3755:6;3742:20;3696:67;;3968:1521;;4081:5;4069:9;4064:3;4060:19;4056:31;4053:2;;;4100:1;4097;4090:12;4053:2;4118:21;4133:5;4118:21;;;4109:30;-1:-1;4195:1;4226:64;4286:3;4266:9;4226:64;;;4202:89;;-1:-1;4357:2;4390:49;4435:3;4411:22;;;4390:49;;;4383:4;4376:5;4372:16;4365:75;4312:139;4503:2;4536:73;4605:3;4596:6;4585:9;4581:22;4536:73;;;4529:4;4522:5;4518:16;4511:99;4461:160;4682:3;4716:49;4761:3;4752:6;4741:9;4737:22;4716:49;;;4709:4;4702:5;4698:16;4691:75;4631:146;4840:3;4874:49;4919:3;4910:6;4899:9;4895:22;4874:49;;;4867:4;4860:5;4856:16;4849:75;4787:148;4993:3;5027:49;5072:3;5063:6;5052:9;5048:22;5027:49;;;5020:4;5013:5;5009:16;5002:75;4945:143;5148:3;5182:49;5227:3;5218:6;5207:9;5203:22;5182:49;;;5175:4;5168:5;5164:16;5157:75;5098:145;5321:3;5310:9;5306:19;5293:33;5346:18;5338:6;5335:30;5332:2;;;5378:1;5375;5368:12;5332:2;5413:54;5463:3;5454:6;5443:9;5439:22;5413:54;;;5406:4;5399:5;5395:16;5388:80;5253:226;4047:1442;;;;;5527:797;;5640:4;5628:9;5623:3;5619:19;5615:30;5612:2;;;5658:1;5655;5648:12;5612:2;5676:20;5691:4;5676:20;;;5667:29;-1:-1;5746:1;5777:46;5819:3;5799:9;5777:46;;;5753:71;;-1:-1;5893:2;5926:70;5992:3;5968:22;;;5926:70;;;5919:4;5912:5;5908:16;5901:96;5845:163;6057:2;6090:67;6153:3;6144:6;6133:9;6129:22;6090:67;;;6083:4;6076:5;6072:16;6065:93;6018:151;6220:2;6253:49;6298:3;6289:6;6278:9;6274:22;6253:49;;;6246:4;6239:5;6235:16;6228:75;6179:135;5606:718;;;;;6357:320;;6468:4;6456:9;6451:3;6447:19;6443:30;6440:2;;;6486:1;6483;6476:12;6440:2;6504:20;6519:4;6504:20;;;6495:29;-1:-1;6575:1;6606:49;6651:3;6631:9;6606:49;;;6582:74;;-1:-1;6593:5;6434:243;-1:-1;;6434:243;6710:462;;6817:4;6805:9;6800:3;6796:19;6792:30;6789:2;;;6835:1;6832;6825:12;6789:2;6853:20;6868:4;6853:20;;;6844:29;-1:-1;6924:1;6955:49;7000:3;6980:9;6955:49;;;6931:74;;-1:-1;7068:2;7101:49;7146:3;7122:22;;;7101:49;;;7094:4;7087:5;7083:16;7076:75;7026:136;6783:389;;;;;7714:470;;7828:4;7816:9;7811:3;7807:19;7803:30;7800:2;;;7846:1;7843;7836:12;7800:2;7864:20;7879:4;7864:20;;;7855:29;-1:-1;7938:1;7969:49;8014:3;7994:9;7969:49;;;7945:74;;-1:-1;8083:2;8116:46;8158:3;8134:22;;;8116:46;;8219:343;;8342:4;8330:9;8325:3;8321:19;8317:30;8314:2;;;8360:1;8357;8350:12;8314:2;8378:20;8393:4;8378:20;;;8369:29;-1:-1;8449:1;8480:60;8536:3;8516:9;8480:60;;9301:118;;9368:46;9406:6;9393:20;9368:46;;9426:122;;9504:39;9535:6;9529:13;9504:39;;9555:241;;9659:2;9647:9;9638:7;9634:23;9630:32;9627:2;;;9675:1;9672;9665:12;9627:2;9710:1;9727:53;9772:7;9752:9;9727:53;;9803:366;;;9924:2;9912:9;9903:7;9899:23;9895:32;9892:2;;;9940:1;9937;9930:12;9892:2;9975:1;9992:53;10037:7;10017:9;9992:53;;;9982:63;;9954:97;10082:2;10100:53;10145:7;10136:6;10125:9;10121:22;10100:53;;;10090:63;;10061:98;9886:283;;;;;;10176:360;;;10294:2;10282:9;10273:7;10269:23;10265:32;10262:2;;;10310:1;10307;10300:12;10262:2;10345:1;10362:53;10407:7;10387:9;10362:53;;;10352:63;;10324:97;10452:2;10470:50;10512:7;10503:6;10492:9;10488:22;10470:50;;10543:921;;;;;;10804:3;10792:9;10783:7;10779:23;10775:33;10772:2;;;10821:1;10818;10811:12;10772:2;10856:1;10873:53;10918:7;10898:9;10873:53;;;10863:63;;10835:97;10963:2;10981:74;11047:7;11038:6;11027:9;11023:22;10981:74;;;10971:84;;10942:119;11092:2;11110:77;11179:7;11170:6;11159:9;11155:22;11110:77;;;11100:87;;11071:122;11224:2;11242:75;11309:7;11300:6;11289:9;11285:22;11242:75;;;11232:85;;11203:120;11354:3;11373:75;11440:7;11431:6;11420:9;11416:22;11373:75;;;11363:85;;11333:121;10766:698;;;;;;;;;11471:722;;;11684:2;11672:9;11663:7;11659:23;11655:32;11652:2;;;11700:1;11697;11690:12;11652:2;11735:31;;11786:18;11775:30;;11772:2;;;11818:1;11815;11808:12;11772:2;11838:96;11926:7;11917:6;11906:9;11902:22;11838:96;;;11828:106;;11714:226;11999:2;11988:9;11984:18;11971:32;12023:18;12015:6;12012:30;12009:2;;;12055:1;12052;12045:12;12009:2;12075:102;12169:7;12160:6;12149:9;12145:22;12075:102;;12200:427;;12354:2;12342:9;12333:7;12329:23;12325:32;12322:2;;;12370:1;12367;12360:12;12322:2;12405:31;;12456:18;12445:30;;12442:2;;;12488:1;12485;12478:12;12442:2;12508:103;12603:7;12594:6;12583:9;12579:22;12508:103;;12634:285;;12760:2;12748:9;12739:7;12735:23;12731:32;12728:2;;;12776:1;12773;12766:12;12728:2;12811:1;12828:75;12895:7;12875:9;12828:75;;12926:285;;13052:2;13040:9;13031:7;13027:23;13023:32;13020:2;;;13068:1;13065;13058:12;13020:2;13103:1;13120:75;13187:7;13167:9;13120:75;;13218:410;;;13361:2;13349:9;13340:7;13336:23;13332:32;13329:2;;;13377:1;13374;13367:12;13329:2;13412:1;13429:75;13496:7;13476:9;13429:75;;;13419:85;;13391:119;13541:2;13559:53;13604:7;13595:6;13584:9;13580:22;13559:53;;13635:309;;13773:2;13761:9;13752:7;13748:23;13744:32;13741:2;;;13789:1;13786;13779:12;13741:2;13824:1;13841:87;13920:7;13900:9;13841:87;;14559:241;;14663:2;14651:9;14642:7;14638:23;14634:32;14631:2;;;14679:1;14676;14669:12;14631:2;14714:1;14731:53;14776:7;14756:9;14731:53;;14807:263;;14922:2;14910:9;14901:7;14897:23;14893:32;14890:2;;;14938:1;14935;14928:12;14890:2;14973:1;14990:64;15046:7;15026:9;14990:64;;15077:366;;;15198:2;15186:9;15177:7;15173:23;15169:32;15166:2;;;15214:1;15211;15204:12;15166:2;15249:1;15266:53;15311:7;15291:9;15266:53;;15450:360;;;15568:2;15556:9;15547:7;15543:23;15539:32;15536:2;;;15584:1;15581;15574:12;15536:2;15619:1;15636:53;15681:7;15661:9;15636:53;;15817:414;;;15962:2;15950:9;15941:7;15937:23;15933:32;15930:2;;;15978:1;15975;15968:12;15930:2;16013:1;16030:53;16075:7;16055:9;16030:53;;;16020:63;;15992:97;16120:2;16138:77;16207:7;16198:6;16187:9;16183:22;16138:77;;16653:410;;;16796:2;16784:9;16775:7;16771:23;16767:32;16764:2;;;16812:1;16809;16802:12;16764:2;16847:1;16864:53;16909:7;16889:9;16864:53;;;16854:63;;16826:97;16954:2;16972:75;17039:7;17030:6;17019:9;17015:22;16972:75;;17070:366;;;17191:2;17179:9;17170:7;17166:23;17162:32;17159:2;;;17207:1;17204;17197:12;17159:2;17242:1;17259:53;17304:7;17284:9;17259:53;;;17249:63;;17221:97;17349:2;17367:53;17412:7;17403:6;17392:9;17388:22;17367:53;;17444:173;;17531:46;17573:3;17565:6;17531:46;;;-1:-1;;17606:4;17597:14;;17524:93;17626:269;;17783:106;17885:3;17877:6;17783:106;;17904:265;;18035:94;18125:3;18117:6;18035:94;;;-1:-1;;18158:4;18149:14;;18028:141;18178:241;;18297:82;18375:3;18367:6;18297:82;;18428:245;;18549:84;18629:3;18621:6;18549:84;;18681:110;18754:31;18779:5;18754:31;;;18749:3;18742:44;18736:55;;;19216:621;;19361:54;19409:5;19361:54;;;19428:86;19507:6;19502:3;19428:86;;;19421:93;;19534:56;19584:5;19534:56;;;19611:1;19596:219;19621:6;19618:1;19615:13;19596:219;;;19668:63;19727:3;19718:6;19712:13;19668:63;;;19661:70;;19748:60;19801:6;19748:60;;;19738:70;-1:-1;19643:1;19636:9;19596:219;;;-1:-1;19828:3;;19340:497;-1:-1;;;;19340:497;19912:995;;20113:78;20185:5;20113:78;;;20204:118;20315:6;20310:3;20204:118;;;20197:125;;20345:3;20387:4;20379:6;20375:17;20370:3;20366:27;20413:80;20487:5;20413:80;;;20514:1;20499:369;20524:6;20521:1;20518:13;20499:369;;;20586:9;20580:4;20576:20;20571:3;20564:33;20612:120;20727:4;20718:6;20712:13;20612:120;;;20604:128;;20749:84;20826:6;20749:84;;;20856:4;20847:14;;;;;20739:94;-1:-1;20546:1;20539:9;20499:369;;;-1:-1;20881:4;;20092:815;-1:-1;;;;;;20092:815;20970:789;;21159:72;21225:5;21159:72;;;21244:112;21349:6;21344:3;21244:112;;;21237:119;;21376:74;21444:5;21376:74;;;21471:1;21456:281;21481:6;21478:1;21475:13;21456:281;;;21528:107;21631:3;21622:6;21616:13;21528:107;;;21521:114;;21652:78;21723:6;21652:78;;;21642:88;-1:-1;21503:1;21496:9;21456:281;;21816:749;;21993:70;22057:5;21993:70;;;22076:102;22171:6;22166:3;22076:102;;;22069:109;;22198:72;22264:5;22198:72;;;22291:1;22276:267;22301:6;22298:1;22295:13;22276:267;;;22348:95;22439:3;22430:6;22424:13;22348:95;;;22341:102;;22460:76;22529:6;22460:76;;;22450:86;-1:-1;22323:1;22316:9;22276:267;;22622:757;;22801:71;22866:5;22801:71;;;22885:103;22981:6;22976:3;22885:103;;;22878:110;;23008:73;23075:5;23008:73;;;23102:1;23087:270;23112:6;23109:1;23106:13;23087:270;;;23159:97;23252:3;23243:6;23237:13;23159:97;;;23152:104;;23273:77;23343:6;23273:77;;;23263:87;-1:-1;23134:1;23127:9;23087:270;;23387:101;23454:28;23476:5;23454:28;;23855:155;23954:50;23973:30;23997:5;23973:30;;;23954:50;;24017:155;24116:50;24135:30;24159:5;24135:30;;24179:159;24280:52;24300:31;24325:5;24300:31;;24345:356;;24473:38;24505:5;24473:38;;;24523:88;24604:6;24599:3;24523:88;;;24516:95;;24616:52;24661:6;24656:3;24649:4;24642:5;24638:16;24616:52;;;24680:16;;;;;24453:248;-1:-1;;24453:248;24708:331;;24812:34;24840:5;24812:34;;;24858:68;24919:6;24914:3;24858:68;;;24851:75;;24931:52;24976:6;24971:3;24964:4;24957:5;24953:16;24931:52;;;25004:29;25026:6;25004:29;;;24995:39;;;;24792:247;-1:-1;;;24792:247;25046:164;25143:61;25198:5;25143:61;;26110:150;26204:50;26248:5;26204:50;;26267:162;26367:56;26417:5;26367:56;;26599:144;26691:46;26731:5;26691:46;;27165:1659;27388:22;;27165:1659;;27316:5;27307:15;;;27416:82;27311:3;27388:22;27416:82;;;27337:167;27581:4;27574:5;27570:16;27564:23;27593:70;27657:4;27652:3;27648:14;27635:11;27593:70;;;27514:155;27743:4;27736:5;27732:16;27726:23;27755:122;27871:4;27866:3;27862:14;27849:11;27755:122;;;27679:204;27966:4;27959:5;27955:16;27949:23;27978:70;28042:4;28037:3;28033:14;28020:11;27978:70;;;27893:161;28139:4;28132:5;28128:16;28122:23;28151:70;28215:4;28210:3;28206:14;28193:11;28151:70;;;28064:163;28307:4;28300:5;28296:16;28290:23;28319:71;28383:5;28378:3;28374:15;28361:11;28319:71;;;28237:159;28478:4;28471:5;28467:16;28461:23;28490:71;28554:5;28549:3;28545:15;28532:11;28490:71;;;28406:161;28639:4;28632:5;28628:16;28622:23;28692:3;28686:4;28682:14;28674:5;28669:3;28665:15;28658:39;28712:74;28781:4;28768:11;28712:74;;28890:843;29098:22;;29033:4;29024:14;;;29126:63;29028:3;29098:22;29126:63;;;29053:142;29275:4;29268:5;29264:16;29258:23;29287:89;29370:4;29365:3;29361:14;29348:11;29287:89;;;29205:177;29453:4;29446:5;29442:16;29436:23;29465:86;29545:4;29540:3;29536:14;29523:11;29465:86;;;29392:165;29630:4;29623:5;29619:16;29613:23;29642:70;29706:4;29701:3;29697:14;29684:11;29642:70;;29789:313;29992:22;;29926:4;29917:14;;;30020:61;29921:3;29992:22;30020:61;;30902:622;31108:22;;31041:4;31032:14;;;31136:59;31036:3;31108:22;31136:59;;;31061:140;31275:4;31268:5;31264:16;31258:23;31287:60;31341:4;31336:3;31332:14;31319:11;31287:60;;;31211:142;31431:4;31424:5;31420:16;31414:23;31443:60;31497:4;31492:3;31488:14;31475:11;31443:60;;32248:477;32445:22;;32379:4;32370:14;;;32473:69;32374:3;32445:22;32473:69;;;32399:149;32622:4;32615:5;32611:16;32605:23;32634:70;32698:4;32693:3;32689:14;32676:11;32634:70;;32785:1637;32993:22;;32926:5;32917:15;;;33021:61;32921:3;32993:22;33021:61;;;32947:141;33164:4;33157:5;33153:16;33147:23;33176:108;33278:4;33273:3;33269:14;33256:11;33176:108;;;33098:192;33363:4;33356:5;33352:16;33346:23;33375:104;33473:4;33468:3;33464:14;33451:11;33375:104;;;33300:185;33564:4;33557:5;33553:16;33547:23;33576:83;33653:4;33648:3;33644:14;33631:11;33576:83;;;33495:170;33747:4;33740:5;33736:16;33730:23;33759:86;33839:4;33834:3;33830:14;33817:11;33759:86;;;33675:176;33932:4;33925:5;33921:16;33915:23;33944:103;34040:5;34035:3;34031:15;34018:11;33944:103;;;33861:192;34134:4;34127:5;34123:16;34117:23;34146:103;34242:5;34237:3;34233:15;34220:11;34146:103;;;34063:192;34332:4;34325:5;34321:16;34315:23;34344:57;34394:5;34389:3;34385:15;34372:11;34344:57;;34472:455;34670:22;;34605:4;34596:14;;;34698:55;34600:3;34670:22;34698:55;;;34625:134;34832:4;34825:5;34821:16;34815:23;34844:62;34900:4;34895:3;34891:14;34878:11;34844:62;;36232:1150;36456:22;;36381:4;36372:14;;;36484:59;36376:3;36456:22;36484:59;;;36401:148;36637:4;36630:5;36626:16;36620:23;36649:60;36703:4;36698:3;36694:14;36681:11;36649:60;;;36559:156;36798:4;36791:5;36787:16;36781:23;36810:60;36864:4;36859:3;36855:14;36842:11;36810:60;;;36725:151;36960:4;36953:5;36949:16;36943:23;36972:60;37026:4;37021:3;37017:14;37004:11;36972:60;;;36886:152;37122:4;37115:5;37111:16;37105:23;37134:60;37188:4;37183:3;37179:14;37166:11;37134:60;;;37048:152;37287:4;37280:5;37276:16;37270:23;37299:62;37355:4;37350:3;37346:14;37333:11;37299:62;;37450:982;37671:22;;37599:4;37590:14;;;37699:101;37594:3;37671:22;37699:101;;;37619:187;37891:4;37884:5;37880:16;37874:23;37903:102;37999:4;37994:3;37990:14;37977:11;37903:102;;;37816:195;38091:4;38084:5;38080:16;38074:23;38103:102;38199:4;38194:3;38190:14;38177:11;38103:102;;;38021:190;38295:4;38288:5;38284:16;38278:23;38307:104;38405:4;38400:3;38396:14;38383:11;38307:104;;38439:122;38538:18;;38532:29;38621:474;38831:22;;38764:4;38755:14;;;38859:61;38759:3;38831:22;38859:61;;40792:457;40992:22;;40927:4;40918:14;;;41020:55;40922:3;40992:22;41020:55;;41749:110;41822:31;41847:5;41822:31;;41866:110;41939:31;41964:5;41939:31;;42370:107;42441:30;42465:5;42441:30;;42484:107;42555:30;42579:5;42555:30;;42598:107;42669:30;42693:5;42669:30;;42712:244;;42831:75;42902:3;42893:6;42831:75;;;-1:-1;42928:2;42919:12;;42819:137;-1:-1;42819:137;42963:553;;43179:93;43268:3;43259:6;43179:93;;;43172:100;;43283:73;43352:3;43343:6;43283:73;;;43378:1;43373:3;43369:11;43362:18;;43398:93;43487:3;43478:6;43398:93;;43523:978;;43837:93;43926:3;43917:6;43837:93;;;43830:100;;43941:73;44010:3;44001:6;43941:73;;;44036:1;44031:3;44027:11;44020:18;;44056:93;44145:3;44136:6;44056:93;;;44049:100;;44160:73;44229:3;44220:6;44160:73;;;44255:1;44250:3;44246:11;44239:18;;44275:93;44364:3;44355:6;44275:93;;;44268:100;;44379:73;44448:3;44439:6;44379:73;;;-1:-1;44474:1;44465:11;;43818:683;-1:-1;;;;;;43818:683;44508:213;44626:2;44611:18;;44640:71;44615:9;44684:6;44640:71;;44728:312;44868:2;44853:18;;44882:71;44857:9;44926:6;44882:71;;;44964:66;45026:2;45015:9;45011:18;45002:6;44964:66;;45047:435;45221:2;45206:18;;45235:71;45210:9;45279:6;45235:71;;;45317:72;45385:2;45374:9;45370:18;45361:6;45317:72;;;45400;45468:2;45457:9;45453:18;45444:6;45400:72;;45489:1011;45879:2;45893:47;;;45864:18;;45954:108;45864:18;46048:6;45954:108;;;45946:116;;46110:9;46104:4;46100:20;46095:2;46084:9;46080:18;46073:48;46135:140;46270:4;46261:6;46135:140;;;46127:148;;46323:9;46317:4;46313:20;46308:2;46297:9;46293:18;46286:48;46348:142;46485:4;46476:6;46348:142;;46507:201;46619:2;46604:18;;46633:65;46608:9;46671:6;46633:65;;46715:261;46857:2;46842:18;;46871:95;46846:9;46939:6;46871:95;;47245:231;47372:2;47357:18;;47386:80;47361:9;47439:6;47386:80;;47483:301;47621:2;47635:47;;;47606:18;;47696:78;47606:18;47760:6;47696:78;;47791:301;47953:2;47938:18;;47967:115;47942:9;48055:6;47967:115;;48099:305;48263:2;48248:18;;48277:117;48252:9;48367:6;48277:117;;48411:310;48577:3;48562:19;;48592:119;48566:9;48684:6;48592:119;;48728:918;49114:3;49099:19;;49129:119;49103:9;49221:6;49129:119;;;49259;49373:3;49362:9;49358:19;49349:6;49259:119;;;49389;49503:3;49492:9;49488:19;49479:6;49389:119;;;49519:117;49631:3;49620:9;49616:19;49607:6;49519:117;;49653:293;49811:2;49796:18;;49825:111;49800:9;49909:6;49825:111;;50573:326;50747:3;50732:19;;50762:127;50736:9;50862:6;50762:127;;50906:326;51080:3;51065:19;;51095:127;51069:9;51195:6;51095:127;;51239:507;51441:2;51426:18;;51455:99;51430:9;51527:6;51455:99;;;51565:80;51641:2;51630:9;51626:18;51617:6;51565:80;;;51656;51732:2;51721:9;51717:18;51708:6;51656:80;;51753:495;51949:2;51934:18;;51963:99;51938:9;52035:6;51963:99;;;52073:80;52149:2;52138:9;52134:18;52125:6;52073:80;;;52164:74;52234:2;52223:9;52219:18;52210:6;52164:74;;52255:1133;52674:3;52659:19;;52689:99;52663:9;52761:6;52689:99;;;52799:80;52875:2;52864:9;52860:18;52851:6;52799:80;;;52890:101;52987:2;52976:9;52972:18;52963:6;52890:101;;;53002:104;53102:2;53091:9;53087:18;53078:6;53002:104;;;53117:125;53237:3;53226:9;53222:19;53213:6;53117:125;;;53253;53373:3;53362:9;53358:19;53349:6;53253:125;;;52645:743;;;;;;;;;;53395:971;53781:2;53766:18;;53795:99;53770:9;53867:6;53795:99;;;53942:9;53936:4;53932:20;53927:2;53916:9;53912:18;53905:48;53967:152;54114:4;54105:6;53967:152;;;53959:160;;54167:9;54161:4;54157:20;54152:2;54141:9;54137:18;54130:48;54192:164;54351:4;54342:6;54192:164;;54373:476;54591:2;54576:18;;54605:99;54580:9;54677:6;54605:99;;;54715:124;54835:2;54824:9;54820:18;54811:6;54715:124;;55343:507;55545:2;55530:18;;55559:99;55534:9;55631:6;55559:99;;;55669:80;55745:2;55734:9;55730:18;55721:6;55669:80;;55857:495;56053:2;56038:18;;56067:99;56042:9;56139:6;56067:99;;;56177:80;56253:2;56242:9;56238:18;56229:6;56177:80;;56359:555;56585:2;56570:18;;56599:99;56574:9;56671:6;56599:99;;;56709:80;56785:2;56774:9;56770:18;56761:6;56709:80;;;56800:104;56900:2;56889:9;56885:18;56876:6;56800:104;;57477:595;57723:2;57708:18;;57737:99;57712:9;57809:6;57737:99;;;57847:80;57923:2;57912:9;57908:18;57899:6;57847:80;;;57938:124;58058:2;58047:9;58043:18;58034:6;57938:124;;58079:313;58247:2;58232:18;;58261:121;58236:9;58355:6;58261:121;;58711:508;58949:2;58934:18;;58963:117;58938:9;59053:6;58963:117;;59226:297;59386:2;59371:18;;59400:113;59375:9;59486:6;59400:113;;59530:213;59648:2;59633:18;;59662:71;59637:9;59706:6;59662:71;;59750:256;59812:2;59806:9;59838:17;;;59913:18;59898:34;;59934:22;;;59895:62;59892:2;;;59970:1;59967;59960:12;59892:2;59986;59979:22;59790:216;;-1:-1;59790:216;60013:282;;60196:18;60188:6;60185:30;60182:2;;;60228:1;60225;60218:12;60182:2;-1:-1;60257:4;60245:17;;;60275:15;;60119:176;60875:254;;61014:18;61006:6;61003:30;61000:2;;;61046:1;61043;61036:12;61000:2;-1:-1;61119:4;61090;61067:17;;;;61086:9;61063:33;61109:15;;60937:192;61138:121;61247:4;61235:17;;61216:43;61871:107;61961:12;;61945:33;63538:178;63656:19;;;63705:4;63696:14;;63649:67;65057:105;;65126:31;65151:5;65126:31;;65169:92;65242:13;65235:21;;65218:43;65268:151;65347:66;65336:78;;65319:100;65426:151;65505:66;65494:78;;65477:100;65584:79;65653:5;65636:27;65670:132;;65763:1;65756:5;65753:12;65743:2;;65769:9;65743:2;-1:-1;65792:5;65737:65;65809:138;;65908:1;65901:5;65898:12;65888:2;;65914:9;66096:128;;66185:1;66178:5;66175:12;66165:2;;66191:9;66231:120;66311:34;66300:46;;66283:68;66358:128;66438:42;66427:54;;66410:76;66579:95;66658:10;66647:22;;66630:44;66681:103;66760:18;66749:30;;66732:52;66791:111;66870:26;66859:38;;66842:60;67120:129;;67213:31;67238:5;67213:31;;67389:135;;67482:1;67475:5;67472:12;67462:2;;67498:1;67495;67488:12;67531:141;;67630:1;67623:5;67620:12;67610:2;;67646:1;67643;67636:12;68680:143;;68772:46;68812:5;68772:46;;68830:155;;68928:52;68974:5;68928:52;;69148:135;;69236:42;69272:5;69236:42;;69291:145;69372:6;69367:3;69362;69349:30;-1:-1;69428:1;69410:16;;69403:27;69342:94;69445:268;69510:1;69517:101;69531:6;69528:1;69525:13;69517:101;;;69598:11;;;69592:18;69579:11;;;69572:39;69553:2;69546:10;69517:101;;;69633:6;69630:1;69627:13;69624:2;;;-1:-1;;69698:1;69680:16;;69673:27;69494:219;69962:97;70050:2;70030:14;70046:7;70026:28;;70010:49

Swarm Source

bzzr://08995f40419ef058c1879e395376a60652d794668b2ac708a61d8c9e9857b0e3
Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.