Contract Address Details

0xCa415A590A31b5aB001064992C643cBCa61339b0

Contract Name
Treasury
Creator
0x062f27–4a1ce0 at 0xa199c3–a85b4c
Balance
0 CRO ( )
Tokens
Fetching tokens...
Transactions
2,237 Transactions
Transfers
1,786 Transfers
Gas Used
571,743,913
Last Balance Update
13550930
Contract name:
Treasury




Optimization enabled
true
Compiler version
v0.6.12+commit.27d51765




Optimization runs
999
EVM Version
default




Verified at
2022-01-12T07:52:09.750899Z

Contract source code

// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow, so we distribute
        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
    }
}


/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}


/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}


/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}


/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}


/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @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() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

library Babylonian {
    function sqrt(uint256 y) internal pure returns (uint256 z) {
        if (y > 3) {
            z = y;
            uint256 x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
        // else z = 0
    }
}


/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}




/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}


contract Operator is Context, Ownable {
    address private _operator;

    event OperatorTransferred(address indexed previousOperator, address indexed newOperator);

    constructor() internal {
        _operator = _msgSender();
        emit OperatorTransferred(address(0), _operator);
    }

    function operator() public view returns (address) {
        return _operator;
    }

    modifier onlyOperator() {
        require(_operator == msg.sender, "operator: caller is not the operator");
        _;
    }

    function isOperator() public view returns (bool) {
        return _msgSender() == _operator;
    }

    function transferOperator(address newOperator_) public onlyOwner {
        _transferOperator(newOperator_);
    }

    function _transferOperator(address newOperator_) internal {
        require(newOperator_ != address(0), "operator: zero address given for new operator");
        emit OperatorTransferred(address(0), newOperator_);
        _operator = newOperator_;
    }
}

contract ContractGuard {
    mapping(uint256 => mapping(address => bool)) private _status;

    function checkSameOriginReentranted() internal view returns (bool) {
        return _status[block.number][tx.origin];
    }

    function checkSameSenderReentranted() internal view returns (bool) {
        return _status[block.number][msg.sender];
    }

    modifier onlyOneBlock() {
        require(!checkSameOriginReentranted(), "ContractGuard: one block, one function");
        require(!checkSameSenderReentranted(), "ContractGuard: one block, one function");

        _status[block.number][tx.origin] = true;
        _status[block.number][msg.sender] = true;

        _;
    }
}

interface IBasisAsset {
    function mint(address recipient, uint256 amount) external returns (bool);

    function burn(uint256 amount) external;

    function burnFrom(address from, uint256 amount) external;

    function isOperator() external returns (bool);

    function operator() external view returns (address);

    function transferOperator(address newOperator_) external;
}


interface IOracle {
    function update() external;

    function consult(address _token, uint256 _amountIn) external view returns (uint144 amountOut);

    function twap(address _token, uint256 _amountIn) external view returns (uint144 _amountOut);
}


interface IBoardroom {
    function balanceOf(address _director) external view returns (uint256);

    function earned(address _director) external view returns (uint256);

    function canWithdraw(address _director) external view returns (bool);

    function canClaimReward(address _director) external view returns (bool);

    function epoch() external view returns (uint256);

    function nextEpochPoint() external view returns (uint256);

    function getDarkPrice() external view returns (uint256);

    function setOperator(address _operator) external;

    function setReserveFund(address _reserveFund) external;

    function setStakeFee(uint256 _stakeFee) external;

    function setWithdrawFee(uint256 _withdrawFee) external;

    function setLockUp(uint256 _withdrawLockupEpochs, uint256 _rewardLockupEpochs) external;

    function stake(uint256 _amount) external;

    function withdraw(uint256 _amount) external;

    function exit() external;

    function claimReward() external;

    function allocateSeigniorage(uint256 _amount) external;

    function governanceRecoverUnsupported(address _token, uint256 _amount, address _to) external;
}


contract Treasury is ContractGuard {
    using SafeERC20 for IERC20;
    using Address for address;
    using SafeMath for uint256;


    uint256 public constant PERIOD = 8 hours;

    /* ========== STATE VARIABLES ========== */

    // governance
    address public operator;

    // flags
    bool public initialized = false;

    // epoch
    uint256 public startTime;
    uint256 public epoch = 0;
    uint256 public epochSupplyContractionLeft = 0;

    // exclusions from total supply
    address[] public excludedFromTotalSupply = [
        address(0x28d81863438F25b6EC4c9DA28348445FC5E44196) // DarkRewardPool
    ];

    // core components
    address public dark;
    address public light;
    address public sky;

    address public boardroom;
    address public darkOracle;

    uint256 public boardroomWithdrawFee;
    uint256 public boardroomStakeFee;

    // price
    uint256 public darkPriceOne;
    uint256 public darkPriceCeiling;

    uint256 public seigniorageSaved;

    uint256 public darkSupplyTarget;

    uint256 public maxSupplyExpansionPercent;
    uint256 public bondDepletionFloorPercent;
    uint256 public seigniorageExpansionFloorPercent;
    uint256 public maxSupplyContractionPercent;
    uint256 public maxDebtRatioPercent;

    // 21 first epochs (1 week) with 3.5% expansion regardless of DARK price
    uint256 public bootstrapEpochs;
    uint256 public bootstrapSupplyExpansionPercent;

    /* =================== Added variables =================== */
    uint256 public previousEpochDarkPrice;
    uint256 public allocateSeigniorageSalary;
    uint256 public maxDiscountRate; // when purchasing bond
    uint256 public maxPremiumRate; // when redeeming bond
    uint256 public discountPercent;
    uint256 public premiumThreshold;
    uint256 public premiumPercent;
    uint256 public mintingFactorForPayingDebt; // print extra DARK during debt phase

    // 45% for Stakers in boardroom (THIS)
    // 45% for DAO fund
    // 2% for DEV fund
    // 8% for INSURANCE fund
    address public daoFund;
    uint256 public daoFundSharedPercent;

    address public devFund;
    uint256 public devFundSharedPercent;

    address public insuranceFund;
    uint256 public insuranceFundSharedPercent;

    /* =================== Events =================== */

    event Initialized(address indexed executor, uint256 at);
    event BurnedBonds(address indexed from, uint256 bondAmount);
    event RedeemedBonds(address indexed from, uint256 darkAmount, uint256 bondAmount);
    event BoughtBonds(address indexed from, uint256 darkAmount, uint256 bondAmount);
    event TreasuryFunded(uint256 timestamp, uint256 seigniorage);
    event BoardroomFunded(uint256 timestamp, uint256 seigniorage);
    event DaoFundFunded(uint256 timestamp, uint256 seigniorage);
    event DevFundFunded(uint256 timestamp, uint256 seigniorage);
    event InsuranceFundFunded(uint256 timestamp, uint256 seigniorage);
    event Seigniorage(uint256 epoch, uint256 twap, uint256 expansion);

    /* =================== Modifier =================== */

    modifier onlyOperator() {
        require(operator == msg.sender, "Treasury: caller is not the operator");
        _;
    }

    modifier checkCondition {
        require(now >= startTime, "Treasury: not started yet");

        _;
    }

    modifier checkEpoch {
        require(now >= nextEpochPoint(), "Treasury: not opened yet");

        _;

        epoch = epoch.add(1);
        epochSupplyContractionLeft = (getDarkPrice() > darkPriceCeiling) ? 0 : getDarkCirculatingSupply().mul(maxSupplyContractionPercent).div(10000);
    }

    modifier checkOperator {
        require(
            IBasisAsset(dark).operator() == address(this) &&
                IBasisAsset(light).operator() == address(this) &&
                IBasisAsset(sky).operator() == address(this) &&
                Operator(boardroom).operator() == address(this),
            "Treasury: need more permission"
        );

        _;
    }

    modifier notInitialized {
        require(!initialized, "Treasury: already initialized");

        _;
    }

    /* ========== VIEW FUNCTIONS ========== */

    function isInitialized() public view returns (bool) {
        return initialized;
    }

    // epoch
    function nextEpochPoint() public view returns (uint256) {
        return startTime.add(epoch.mul(PERIOD));
    }

    // oracle
    function getDarkPrice() public view returns (uint256 darkPrice) {
        try IOracle(darkOracle).consult(dark, 1e18) returns (uint144 price) {
            return uint256(price);
        } catch {
            revert("Treasury: failed to consult DARK price from the oracle");
        }
    }

    function getDarkUpdatedPrice() public view returns (uint256 _darkPrice) {
        try IOracle(darkOracle).twap(dark, 1e18) returns (uint144 price) {
            return uint256(price);
        } catch {
            revert("Treasury: failed to consult DARK price from the oracle");
        }
    }

    // budget
    function getReserve() public view returns (uint256) {
        return seigniorageSaved;
    }

    function getBurnableDarkLeft() public view returns (uint256 _burnableDarkLeft) {
        uint256 _darkPrice = getDarkPrice();
        if (_darkPrice <= darkPriceOne) {
            uint256 _darkSupply = getDarkCirculatingSupply();
            uint256 _bondMaxSupply = _darkSupply.mul(maxDebtRatioPercent).div(10000);
            uint256 _bondSupply = IERC20(light).totalSupply();
            if (_bondMaxSupply > _bondSupply) {
                uint256 _maxMintableBond = _bondMaxSupply.sub(_bondSupply);
                uint256 _maxBurnableDark = _maxMintableBond.mul(_darkPrice).div(1e18);
                _burnableDarkLeft = Math.min(epochSupplyContractionLeft, _maxBurnableDark);
            }
        }
    }

    function getRedeemableBonds() public view returns (uint256 _redeemableBonds) {
        uint256 _darkPrice = getDarkPrice();
        if (_darkPrice > darkPriceCeiling) {
            uint256 _totalDark = IERC20(dark).balanceOf(address(this));
            uint256 _rate = getBondPremiumRate();
            if (_rate > 0) {
                _redeemableBonds = _totalDark.mul(1e18).div(_rate);
            }
        }
    }

    function getBondDiscountRate() public view returns (uint256 _rate) {
        uint256 _darkPrice = getDarkPrice();
        if (_darkPrice <= darkPriceOne) {
            if (discountPercent == 0) {
                // no discount
                _rate = darkPriceOne;
            } else {
                uint256 _bondAmount = darkPriceOne.mul(1e18).div(_darkPrice); // to burn 1 DARK
                uint256 _discountAmount = _bondAmount.sub(darkPriceOne).mul(discountPercent).div(10000);
                _rate = darkPriceOne.add(_discountAmount);
                if (maxDiscountRate > 0 && _rate > maxDiscountRate) {
                    _rate = maxDiscountRate;
                }
            }
        }
    }

    function getBondPremiumRate() public view returns (uint256 _rate) {
        uint256 _darkPrice = getDarkPrice();
        if (_darkPrice > darkPriceCeiling) {
            uint256 _darkPricePremiumThreshold = darkPriceOne.mul(premiumThreshold).div(100);
            if (_darkPrice >= _darkPricePremiumThreshold) {
                //Price > 1.10
                uint256 _premiumAmount = _darkPrice.sub(darkPriceOne).mul(premiumPercent).div(10000);
                _rate = darkPriceOne.add(_premiumAmount);
                if (maxPremiumRate > 0 && _rate > maxPremiumRate) {
                    _rate = maxPremiumRate;
                }
            } else {
                // no premium bonus
                _rate = darkPriceOne;
            }
        }
    }

    /* ========== GOVERNANCE ========== */

    function initialize(
        address _dark,
        address _light,
        address _sky,
        address _darkOracle,
        address _boardroom,
        uint256 _startTime
    ) public notInitialized {
        dark = _dark;
        light = _light;
        sky = _sky;
        darkOracle = _darkOracle;
        boardroom = _boardroom;
        startTime = _startTime;

        darkPriceOne = 10**18;
        darkPriceCeiling = darkPriceOne.mul(101).div(100);

        darkSupplyTarget = 1000000 ether;

        maxSupplyExpansionPercent = 350; // Upto 3.5% supply for expansion

        boardroomWithdrawFee = 2; // 2% withdraw fee when under peg

        bondDepletionFloorPercent = 10000; // 100% of Bond supply for depletion floor
        seigniorageExpansionFloorPercent = 3500; // At least 35% of expansion reserved for boardroom
        maxSupplyContractionPercent = 300; // Upto 3.0% supply for contraction (to burn DARK and mint LIGHT)
        maxDebtRatioPercent = 3500; // Upto 35% supply of LIGHT to purchase

        premiumThreshold = 110;
        premiumPercent = 7000;

        allocateSeigniorageSalary = 0.2 ether;

        // First 21 epochs with 4.5% expansion
        bootstrapEpochs = 21;
        bootstrapSupplyExpansionPercent = 450;

        // set seigniorageSaved to it's balance
        seigniorageSaved = IERC20(dark).balanceOf(address(this));

        initialized = true;
        operator = msg.sender;
        emit Initialized(msg.sender, block.number);
    }

    function setOperator(address _operator) external onlyOperator {
        operator = _operator;
    }

    function setBoardroom(address _boardroom) external onlyOperator {
        boardroom = _boardroom;
    }

    function setBoardroomWithdrawFee(uint256 _boardroomWithdrawFee) external onlyOperator {
        require(_boardroomWithdrawFee <= 20, "Max withdraw fee is 20%");
        boardroomWithdrawFee = _boardroomWithdrawFee;
    }

    function setBoardroomStakeFee(uint256 _boardroomStakeFee) external onlyOperator {
        require(_boardroomStakeFee <= 5, "Max stake fee is 5%");
        boardroomStakeFee = _boardroomStakeFee;
        IBoardroom(boardroom).setStakeFee(boardroomStakeFee);
    }

    function setDarkOracle(address _darkOracle) external onlyOperator {
        darkOracle = _darkOracle;
    }

    function setDarkPriceCeiling(uint256 _darkPriceCeiling) external onlyOperator {
        require(_darkPriceCeiling >= darkPriceOne && _darkPriceCeiling <= darkPriceOne.mul(120).div(100), "out of range"); // [$1.0, $1.2]
        darkPriceCeiling = _darkPriceCeiling;
    }

    function setMaxSupplyExpansionPercents(uint256 _maxSupplyExpansionPercent) external onlyOperator {
        require(_maxSupplyExpansionPercent >= 10 && _maxSupplyExpansionPercent <= 1000, "_maxSupplyExpansionPercent: out of range"); // [0.1%, 10%]
        maxSupplyExpansionPercent = _maxSupplyExpansionPercent;
    }

    function setBondDepletionFloorPercent(uint256 _bondDepletionFloorPercent) external onlyOperator {
        require(_bondDepletionFloorPercent >= 500 && _bondDepletionFloorPercent <= 10000, "out of range"); // [5%, 100%]
        bondDepletionFloorPercent = _bondDepletionFloorPercent;
    }

    function setMaxSupplyContractionPercent(uint256 _maxSupplyContractionPercent) external onlyOperator {
        require(_maxSupplyContractionPercent >= 100 && _maxSupplyContractionPercent <= 1500, "out of range"); // [0.1%, 15%]
        maxSupplyContractionPercent = _maxSupplyContractionPercent;
    }

    function setMaxDebtRatioPercent(uint256 _maxDebtRatioPercent) external onlyOperator {
        require(_maxDebtRatioPercent >= 1000 && _maxDebtRatioPercent <= 10000, "out of range"); // [10%, 100%]
        maxDebtRatioPercent = _maxDebtRatioPercent;
    }

    function setBootstrap(uint256 _bootstrapEpochs, uint256 _bootstrapSupplyExpansionPercent) external onlyOperator {
        require(_bootstrapEpochs <= 90, "_bootstrapEpochs: out of range"); // <= 1 month
        require(_bootstrapSupplyExpansionPercent >= 100 && _bootstrapSupplyExpansionPercent <= 1000, "_bootstrapSupplyExpansionPercent: out of range"); // [1%, 10%]
        bootstrapEpochs = _bootstrapEpochs;
        bootstrapSupplyExpansionPercent = _bootstrapSupplyExpansionPercent;
    }

    function setExtraFunds(
        address _daoFund,
        uint256 _daoFundSharedPercent,
        address _devFund,
        uint256 _devFundSharedPercent,
        address _insuranceFund,
        uint256 _insuranceFundSharedPercent
    ) external onlyOperator {
        require(_daoFund != address(0), "zero");
        require(_daoFundSharedPercent <= 5000, "out of range"); // <= 50%
        require(_devFund != address(0), "zero");
        require(_devFundSharedPercent <= 1000, "out of range"); // <= 10%
        require(_insuranceFund != address(0), "zero");
        require(_insuranceFundSharedPercent <= 1000, "out of range"); // <= 10%

        daoFund = _daoFund;
        daoFundSharedPercent = _daoFundSharedPercent;

        devFund = _devFund;
        devFundSharedPercent = _devFundSharedPercent;

        insuranceFund = _insuranceFund;
        insuranceFundSharedPercent = _insuranceFundSharedPercent;
    }

    function setAllocateSeigniorageSalary(uint256 _allocateSeigniorageSalary) external onlyOperator {
        require(_allocateSeigniorageSalary <= 10 ether, "Treasury: dont pay too much");
        allocateSeigniorageSalary = _allocateSeigniorageSalary;
    }

    function setMaxDiscountRate(uint256 _maxDiscountRate) external onlyOperator {
        maxDiscountRate = _maxDiscountRate;
    }

    function setMaxPremiumRate(uint256 _maxPremiumRate) external onlyOperator {
        maxPremiumRate = _maxPremiumRate;
    }

    function setDiscountPercent(uint256 _discountPercent) external onlyOperator {
        require(_discountPercent <= 20000, "_discountPercent is over 200%");
        discountPercent = _discountPercent;
    }

    function setPremiumThreshold(uint256 _premiumThreshold) external onlyOperator {
        require(_premiumThreshold >= darkPriceCeiling, "_premiumThreshold exceeds darkPriceCeiling");
        require(_premiumThreshold <= 150, "_premiumThreshold is higher than 1.5");
        premiumThreshold = _premiumThreshold;
    }

    function setPremiumPercent(uint256 _premiumPercent) external onlyOperator {
        require(_premiumPercent <= 20000, "_premiumPercent is over 200%");
        premiumPercent = _premiumPercent;
    }

    function setMintingFactorForPayingDebt(uint256 _mintingFactorForPayingDebt) external onlyOperator {
        require(_mintingFactorForPayingDebt >= 10000 && _mintingFactorForPayingDebt <= 20000, "_mintingFactorForPayingDebt: out of range"); // [100%, 200%]
        mintingFactorForPayingDebt = _mintingFactorForPayingDebt;
    }

    function setDarkSupplyTarget(uint256 _darkSupplyTarget) external onlyOperator {
        require(_darkSupplyTarget > getDarkCirculatingSupply(), "too small"); // >= current circulating supply
        darkSupplyTarget = _darkSupplyTarget;
    }

    /* ========== MUTABLE FUNCTIONS ========== */

    function _updateDarkPrice() internal {
        try IOracle(darkOracle).update() {} catch {}
    }

    function getDarkCirculatingSupply() public view returns (uint256) {
        IERC20 darkErc20 = IERC20(dark);
        uint256 totalSupply = darkErc20.totalSupply();
        uint256 balanceExcluded = 0;
        for (uint8 entryId = 0; entryId < excludedFromTotalSupply.length; ++entryId) {
            balanceExcluded = balanceExcluded.add(darkErc20.balanceOf(excludedFromTotalSupply[entryId]));
        }
        return totalSupply.sub(balanceExcluded);
    }

    function buyBonds(uint256 _darkAmount, uint256 targetPrice) external onlyOneBlock checkCondition checkOperator {
        require(_darkAmount > 0, "Treasury: cannot purchase bonds with zero amount");

        uint256 darkPrice = getDarkPrice();
        require(darkPrice == targetPrice, "Treasury: DARK price moved");
        require(
            darkPrice < darkPriceOne, // price < $1
            "Treasury: darkPrice not eligible for bond purchase"
        );

        require(_darkAmount <= epochSupplyContractionLeft, "Treasury: not enough bond left to purchase");

        uint256 _rate = getBondDiscountRate();
        require(_rate > 0, "Treasury: invalid bond rate");

        uint256 _bondAmount = _darkAmount.mul(_rate).div(1e18);
        uint256 darkSupply = getDarkCirculatingSupply();
        uint256 newBondSupply = IERC20(light).totalSupply().add(_bondAmount);
        require(newBondSupply <= darkSupply.mul(maxDebtRatioPercent).div(10000), "over max debt ratio");

        IBasisAsset(dark).burnFrom(msg.sender, _darkAmount);
        IBasisAsset(light).mint(msg.sender, _bondAmount);

        epochSupplyContractionLeft = epochSupplyContractionLeft.sub(_darkAmount);
        _updateDarkPrice();

        emit BoughtBonds(msg.sender, _darkAmount, _bondAmount);
    }

    function redeemBonds(uint256 _bondAmount, uint256 targetPrice) external onlyOneBlock checkCondition checkOperator {
        require(_bondAmount > 0, "Treasury: cannot redeem bonds with zero amount");

        uint256 darkPrice = getDarkPrice();
        require(darkPrice == targetPrice, "Treasury: DARK price moved");
        require(
            darkPrice > darkPriceCeiling, // price > $1.01
            "Treasury: darkPrice not eligible for bond purchase"
        );

        uint256 _rate = getBondPremiumRate();
        require(_rate > 0, "Treasury: invalid bond rate");

        uint256 _darkAmount = _bondAmount.mul(_rate).div(1e18);
        require(IERC20(dark).balanceOf(address(this)) >= _darkAmount, "Treasury: treasury has no more budget");

        seigniorageSaved = seigniorageSaved.sub(Math.min(seigniorageSaved, _darkAmount));

        IBasisAsset(light).burnFrom(msg.sender, _bondAmount);
        IERC20(dark).safeTransfer(msg.sender, _darkAmount);

        _updateDarkPrice();

        emit RedeemedBonds(msg.sender, _darkAmount, _bondAmount);
    }

    function _sendToBoardroom(uint256 _amount) internal {
        IBasisAsset(dark).mint(address(this), _amount);

        uint256 _daoFundSharedAmount = 0;
        if (daoFundSharedPercent > 0) {
            _daoFundSharedAmount = _amount.mul(daoFundSharedPercent).div(10000);
            IERC20(dark).transfer(daoFund, _daoFundSharedAmount);
            emit DaoFundFunded(now, _daoFundSharedAmount);
        }

        uint256 _devFundSharedAmount = 0;
        if (devFundSharedPercent > 0) {
            _devFundSharedAmount = _amount.mul(devFundSharedPercent).div(10000);
            IERC20(dark).transfer(devFund, _devFundSharedAmount);
            emit DevFundFunded(now, _devFundSharedAmount);
        }

        uint256 _insuranceFundSharedAmount = 0;
        if (insuranceFundSharedPercent > 0) {
            _insuranceFundSharedAmount = _amount.mul(insuranceFundSharedPercent).div(10000);
            IERC20(dark).transfer(insuranceFund, _insuranceFundSharedAmount);
            emit InsuranceFundFunded(now, _insuranceFundSharedAmount);
        }

        _amount = _amount.sub(_daoFundSharedAmount).sub(_devFundSharedAmount).sub(_insuranceFundSharedAmount);

        IERC20(dark).safeApprove(boardroom, 0);
        IERC20(dark).safeApprove(boardroom, _amount);
        IBoardroom(boardroom).allocateSeigniorage(_amount);
        emit BoardroomFunded(now, _amount);
    }

    function _calculateMaxSupplyExpansionPercent(uint256 _darkSupply) internal returns (uint256) {
        if (_darkSupply >= darkSupplyTarget) {
            darkSupplyTarget = darkSupplyTarget.mul(12500).div(10000); // +25%
            maxSupplyExpansionPercent = maxSupplyExpansionPercent.mul(9500).div(10000); // -5%
            if (maxSupplyExpansionPercent < 10) {
                maxSupplyExpansionPercent = 10; // min 0.1%
            }
        }
        return maxSupplyExpansionPercent;
    }

    function getDarkExpansionRate() public view returns (uint256 _rate) {
        if (epoch < bootstrapEpochs) { // 21 first epochs with 3.5% expansion
            _rate = bootstrapSupplyExpansionPercent;
        } else {
            uint256 _twap = getDarkPrice();
            if (_twap >= darkPriceCeiling) {
                uint256 _percentage = _twap.sub(darkPriceOne); // 1% = 1e16
                uint256 _mse = maxSupplyExpansionPercent.mul(1e14);
                if (_percentage > _mse) {
                    _percentage = _mse;
                }
                _rate = _percentage.div(1e14);
            }
        }
    }

    function getDarkExpansionAmount() external view returns (uint256) {
        uint256 darkSupply = getDarkCirculatingSupply().sub(seigniorageSaved);
        uint256 bondSupply = IERC20(light).totalSupply();
        uint256 _rate = getDarkExpansionRate();
        if (seigniorageSaved >= bondSupply.mul(bondDepletionFloorPercent).div(10000)) {
            // saved enough to pay debt, mint as usual rate
            return darkSupply.mul(_rate).div(10000);
        } else {
            // have not saved enough to pay debt, mint more
            uint256 _seigniorage = darkSupply.mul(_rate).div(10000);
            return _seigniorage.mul(seigniorageExpansionFloorPercent).div(10000);
        }
    }

    function allocateSeigniorage() external onlyOneBlock checkCondition checkEpoch checkOperator {
        _updateDarkPrice();
        previousEpochDarkPrice = getDarkPrice();
        uint256 darkSupply = getDarkCirculatingSupply().sub(seigniorageSaved);
        if (epoch < bootstrapEpochs) {
            // 21 first epochs with 3.5% expansion
            _sendToBoardroom(darkSupply.mul(bootstrapSupplyExpansionPercent).div(10000));
            emit Seigniorage(epoch, previousEpochDarkPrice, darkSupply.mul(bootstrapSupplyExpansionPercent).div(10000));
        } else {
            if (previousEpochDarkPrice >= darkPriceCeiling) {
                IBoardroom(boardroom).setWithdrawFee(0);
                // Expansion ($DARK Price > 1 $CRO): there is some seigniorage to be allocated
                uint256 bondSupply = IERC20(light).totalSupply();
                uint256 _percentage = previousEpochDarkPrice.sub(darkPriceOne);
                uint256 _savedForBond;
                uint256 _savedForBoardroom;
                uint256 _mse = _calculateMaxSupplyExpansionPercent(darkSupply).mul(1e14);
                if (_percentage > _mse) {
                    _percentage = _mse;
                }
                if (seigniorageSaved >= bondSupply.mul(bondDepletionFloorPercent).div(10000)) {
                    // saved enough to pay debt, mint as usual rate
                    _savedForBoardroom = darkSupply.mul(_percentage).div(1e18);
                } else {
                    // have not saved enough to pay debt, mint more
                    uint256 _seigniorage = darkSupply.mul(_percentage).div(1e18);
                    _savedForBoardroom = _seigniorage.mul(seigniorageExpansionFloorPercent).div(10000);
                    _savedForBond = _seigniorage.sub(_savedForBoardroom);
                    if (mintingFactorForPayingDebt > 0) {
                        _savedForBond = _savedForBond.mul(mintingFactorForPayingDebt).div(10000);
                    }
                }
                if (_savedForBoardroom > 0) {
                    _sendToBoardroom(_savedForBoardroom);
                }
                if (_savedForBond > 0) {
                    seigniorageSaved = seigniorageSaved.add(_savedForBond);
                    IBasisAsset(dark).mint(address(this), _savedForBond);
                    emit TreasuryFunded(now, _savedForBond);
                }
                emit Seigniorage(epoch, previousEpochDarkPrice, _savedForBoardroom);
            } else {
                IBoardroom(boardroom).setWithdrawFee(boardroomWithdrawFee);
                emit Seigniorage(epoch, previousEpochDarkPrice, 0);
            }
        }
        if (allocateSeigniorageSalary > 0) {
            IBasisAsset(dark).mint(address(msg.sender), allocateSeigniorageSalary);
        }
    }

    function governanceRecoverUnsupported(
        IERC20 _token,
        uint256 _amount,
        address _to
    ) external onlyOperator {
        // do not allow to drain core tokens
        require(address(_token) != address(dark), "dark");
        require(address(_token) != address(light), "light");
        require(address(_token) != address(sky), "share");
        _token.safeTransfer(_to, _amount);
    }

    function boardroomSetOperator(address _operator) external onlyOperator {
        IBoardroom(boardroom).setOperator(_operator);
    }

    function boardroomSetReserveFund(address _reserveFund) external onlyOperator {
        IBoardroom(boardroom).setReserveFund(_reserveFund);
    }

    function boardroomSetLockUp(uint256 _withdrawLockupEpochs, uint256 _rewardLockupEpochs) external onlyOperator {
        IBoardroom(boardroom).setLockUp(_withdrawLockupEpochs, _rewardLockupEpochs);
    }

    function boardroomAllocateSeigniorage(uint256 amount) external onlyOperator {
        IBoardroom(boardroom).allocateSeigniorage(amount);
    }

    function boardroomGovernanceRecoverUnsupported(
        address _token,
        uint256 _amount,
        address _to
    ) external onlyOperator {
        IBoardroom(boardroom).governanceRecoverUnsupported(_token, _amount, _to);
    }
}
        

Contract ABI

[{"type":"event","name":"BoardroomFunded","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false},{"type":"uint256","name":"seigniorage","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"BoughtBonds","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"uint256","name":"darkAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"bondAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"BurnedBonds","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"uint256","name":"bondAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DaoFundFunded","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false},{"type":"uint256","name":"seigniorage","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DevFundFunded","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false},{"type":"uint256","name":"seigniorage","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"address","name":"executor","internalType":"address","indexed":true},{"type":"uint256","name":"at","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"InsuranceFundFunded","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false},{"type":"uint256","name":"seigniorage","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RedeemedBonds","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"uint256","name":"darkAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"bondAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Seigniorage","inputs":[{"type":"uint256","name":"epoch","internalType":"uint256","indexed":false},{"type":"uint256","name":"twap","internalType":"uint256","indexed":false},{"type":"uint256","name":"expansion","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TreasuryFunded","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false},{"type":"uint256","name":"seigniorage","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PERIOD","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"allocateSeigniorage","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allocateSeigniorageSalary","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"boardroom","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"boardroomAllocateSeigniorage","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"boardroomGovernanceRecoverUnsupported","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_to","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"boardroomSetLockUp","inputs":[{"type":"uint256","name":"_withdrawLockupEpochs","internalType":"uint256"},{"type":"uint256","name":"_rewardLockupEpochs","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"boardroomSetOperator","inputs":[{"type":"address","name":"_operator","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"boardroomSetReserveFund","inputs":[{"type":"address","name":"_reserveFund","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"boardroomStakeFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"boardroomWithdrawFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"bondDepletionFloorPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"bootstrapEpochs","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"bootstrapSupplyExpansionPercent","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"buyBonds","inputs":[{"type":"uint256","name":"_darkAmount","internalType":"uint256"},{"type":"uint256","name":"targetPrice","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"daoFund","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"daoFundSharedPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"dark","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"darkOracle","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"darkPriceCeiling","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"darkPriceOne","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"darkSupplyTarget","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"devFund","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"devFundSharedPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"discountPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"epoch","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"epochSupplyContractionLeft","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"excludedFromTotalSupply","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_rate","internalType":"uint256"}],"name":"getBondDiscountRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_rate","internalType":"uint256"}],"name":"getBondPremiumRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_burnableDarkLeft","internalType":"uint256"}],"name":"getBurnableDarkLeft","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getDarkCirculatingSupply","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getDarkExpansionAmount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_rate","internalType":"uint256"}],"name":"getDarkExpansionRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"darkPrice","internalType":"uint256"}],"name":"getDarkPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_darkPrice","internalType":"uint256"}],"name":"getDarkUpdatedPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_redeemableBonds","internalType":"uint256"}],"name":"getRedeemableBonds","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getReserve","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"governanceRecoverUnsupported","inputs":[{"type":"address","name":"_token","internalType":"contract IERC20"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_to","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_dark","internalType":"address"},{"type":"address","name":"_light","internalType":"address"},{"type":"address","name":"_sky","internalType":"address"},{"type":"address","name":"_darkOracle","internalType":"address"},{"type":"address","name":"_boardroom","internalType":"address"},{"type":"uint256","name":"_startTime","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"initialized","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"insuranceFund","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"insuranceFundSharedPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isInitialized","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"light","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxDebtRatioPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxDiscountRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxPremiumRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxSupplyContractionPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxSupplyExpansionPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"mintingFactorForPayingDebt","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nextEpochPoint","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"operator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"premiumPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"premiumThreshold","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"previousEpochDarkPrice","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"redeemBonds","inputs":[{"type":"uint256","name":"_bondAmount","internalType":"uint256"},{"type":"uint256","name":"targetPrice","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"seigniorageExpansionFloorPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"seigniorageSaved","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAllocateSeigniorageSalary","inputs":[{"type":"uint256","name":"_allocateSeigniorageSalary","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBoardroom","inputs":[{"type":"address","name":"_boardroom","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBoardroomStakeFee","inputs":[{"type":"uint256","name":"_boardroomStakeFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBoardroomWithdrawFee","inputs":[{"type":"uint256","name":"_boardroomWithdrawFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBondDepletionFloorPercent","inputs":[{"type":"uint256","name":"_bondDepletionFloorPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBootstrap","inputs":[{"type":"uint256","name":"_bootstrapEpochs","internalType":"uint256"},{"type":"uint256","name":"_bootstrapSupplyExpansionPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDarkOracle","inputs":[{"type":"address","name":"_darkOracle","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDarkPriceCeiling","inputs":[{"type":"uint256","name":"_darkPriceCeiling","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDarkSupplyTarget","inputs":[{"type":"uint256","name":"_darkSupplyTarget","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDiscountPercent","inputs":[{"type":"uint256","name":"_discountPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setExtraFunds","inputs":[{"type":"address","name":"_daoFund","internalType":"address"},{"type":"uint256","name":"_daoFundSharedPercent","internalType":"uint256"},{"type":"address","name":"_devFund","internalType":"address"},{"type":"uint256","name":"_devFundSharedPercent","internalType":"uint256"},{"type":"address","name":"_insuranceFund","internalType":"address"},{"type":"uint256","name":"_insuranceFundSharedPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxDebtRatioPercent","inputs":[{"type":"uint256","name":"_maxDebtRatioPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxDiscountRate","inputs":[{"type":"uint256","name":"_maxDiscountRate","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxPremiumRate","inputs":[{"type":"uint256","name":"_maxPremiumRate","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxSupplyContractionPercent","inputs":[{"type":"uint256","name":"_maxSupplyContractionPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxSupplyExpansionPercents","inputs":[{"type":"uint256","name":"_maxSupplyExpansionPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMintingFactorForPayingDebt","inputs":[{"type":"uint256","name":"_mintingFactorForPayingDebt","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setOperator","inputs":[{"type":"address","name":"_operator","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPremiumPercent","inputs":[{"type":"uint256","name":"_premiumPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPremiumThreshold","inputs":[{"type":"uint256","name":"_premiumThreshold","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"sky","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"startTime","inputs":[]}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061058b5760003560e01c806378e97925116102e2578063b658e3c511610191578063dea08e58116100ee578063f4f102c1116100a2578063f9fba3431161007c578063f9fba34314610b6d578063fcb6f00814610b75578063feaa798f14610b7d5761058b565b8063f4f102c114610b3a578063f8cd4d7214610b42578063f92f254214610b655761058b565b8063e90b2454116100d3578063e90b245414610b04578063ec20966814610b0c578063f14698de14610b325761058b565b8063dea08e5814610adf578063e388ac1014610ae75761058b565b8063c8f987f311610145578063d1ce75d41161012a578063d1ce75d414610ac7578063d98f249514610acf578063da3ed41914610ad75761058b565b8063c8f987f314610aa2578063cecce38e14610aaa5761058b565b8063b8a878f911610176578063b8a878f914610a8a578063c5967c2614610a92578063c8412d0214610a9a5761058b565b8063b658e3c514610a7a578063b790230314610a825761058b565b806391bbfed51161023f578063b06ce14a116101f3578063b3ffc777116101d8578063b3ffc77714610a2f578063b4d1d79514610a55578063b5e8dabe14610a5d5761058b565b8063b06ce14a146109e3578063b3ab15fb14610a095761058b565b806398b762a11161022457806398b762a114610973578063a204452b14610990578063a3ec30fe146109ad5761058b565b806391bbfed51461090457806395b6ef0c146109275761058b565b80638c664db6116102965780638d934f741161027b5780638d934f74146108ec5780638f0e0e51146108f4578063900cf0cf146108fc5761058b565b80638c664db6146108c75780638c6909f7146108e45761058b565b806382cad838116102c757806382cad8381461089a578063860c3177146108b7578063874106cc146108bf5761058b565b806378e979251461088a57806381d11eaf146108925761058b565b806340af7ba51161043e57806359bf5d391161039b57806364dbe78c1161034f5780636a537164116103345780636a53716414610872578063700cda561461087a57806372c054f9146108825761058b565b806364dbe78c14610862578063692318041461086a5761058b565b80635b756179116103805780635b7561791461084a5780635c59f76e146108525780635e02c51e1461085a5761058b565b806359bf5d391461083a5780635a0fc79c146108425761058b565b806354b6e11e116103f257806355ebdeef116103d757806355ebdeef1461080d578063570ca73514610815578063591663e11461081d5761058b565b806354b6e11e146107e257806354f04a11146107ea5761058b565b80634390d2a8116104235780634390d2a81461076b578063499f3f191461078f57806354575af4146107ac5761058b565b806340af7ba51461074657806340b8dc0b146107635761058b565b8063158ef93e116104ec57806329ef1919116104a0578063392e53cd11610485578063392e53cd146107195780633e6e2298146107215780634013a08e1461073e5761058b565b806329ef1919146107095780632e9c7b65146107115761058b565b80631e2ba237116104d15780631e2ba237146106c75780631eda563a146106e457806322f832cd146107015761058b565b8063158ef93e146106635780631b0fb35f1461067f5761058b565b80630cf6017511610543578063118ebbf911610528578063118ebbf91461061b57806311aa7c981461063e578063154ec2db146106465761058b565b80630cf601751461060b5780630db7eb0b146106135761058b565b806304e5c7b11161057457806304e5c7b1146105c95780630a74c543146105e65780630b5bcec7146105ee5761058b565b806301a937831461059057806303be7e76146105af575b600080fd5b6105ad600480360360208110156105a657600080fd5b5035610ba3565b005b6105b7610c54565b60408051918252519081900360200190f35b6105ad600480360360208110156105df57600080fd5b5035610c5a565b6105b7610d29565b6105ad6004803603602081101561060457600080fd5b5035610d2f565b6105b7610dcb565b6105b7610e7d565b6105ad6004803603604081101561063157600080fd5b5080359060200135610f1f565b6105b7611580565b6105ad6004803603602081101561065c57600080fd5b5035611609565b61066b6116ae565b604080519115158252519081900360200190f35b6105ad600480360360c081101561069557600080fd5b506001600160a01b03813581169160208101359160408201358116916060810135916080820135169060a001356116be565b6105ad600480360360208110156106dd57600080fd5b50356118f4565b6105ad600480360360208110156106fa57600080fd5b503561199f565b6105b7611aa9565b6105b7611aaf565b6105b7611ab5565b61066b611abb565b6105ad6004803603602081101561073757600080fd5b5035611acb565b6105b7611b85565b6105ad6004803603602081101561075c57600080fd5b5035611b8b565b6105b7611c30565b610773611d26565b604080516001600160a01b039092168252519081900360200190f35b6105ad600480360360208110156107a557600080fd5b5035611d35565b6105ad600480360360608110156107c257600080fd5b506001600160a01b03813581169160208101359160409091013516611dd2565b6105b7611f5f565b6105ad6004803603604081101561080057600080fd5b5080359060200135612066565b6105b76127b3565b6107736127b9565b6105ad6004803603602081101561083357600080fd5b50356127c8565b6105b761286a565b6105b7612870565b6105ad612876565b6105b761317f565b6107736131fa565b610773613209565b610773613218565b6105b7613227565b6105b761322d565b6105b7613233565b6105b76132eb565b6105b76132f1565b610773600480360360208110156108b057600080fd5b50356132f7565b6105b761331e565b6105b7613324565b6105ad600480360360208110156108dd57600080fd5b503561332a565b6107736133cc565b6107736133db565b6107736133ea565b6105b76133f9565b6105ad6004803603604081101561091a57600080fd5b50803590602001356133ff565b6105ad600480360360c081101561093d57600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101358216916080820135169060a001356134f7565b6105ad6004803603602081101561098957600080fd5b503561371a565b6105ad600480360360208110156109a657600080fd5b5035613768565b6105ad600480360360608110156109c357600080fd5b506001600160a01b038135811691602081013591604090910135166137b6565b6105ad600480360360208110156109f957600080fd5b50356001600160a01b0316613892565b6105ad60048036036020811015610a1f57600080fd5b50356001600160a01b0316613942565b6105ad60048036036020811015610a4557600080fd5b50356001600160a01b03166139ad565b6105b7613a18565b6105ad60048036036020811015610a7357600080fd5b5035613a1e565b6105b7613ac7565b610773613bdb565b6105b7613bea565b6105b7613bf0565b6105b7613c1a565b6105b7613c20565b6105ad60048036036020811015610ac057600080fd5b5035613c26565b6105b7613cc7565b6105b7613ccd565b6105b7613cd3565b6105b7613cd9565b6105ad60048036036020811015610afd57600080fd5b5035613e4a565b6105b7613eee565b6105ad60048036036020811015610b2257600080fd5b50356001600160a01b0316613ef4565b6105b7613f5f565b6105b7613f65565b6105ad60048036036040811015610b5857600080fd5b5080359060200135613f6b565b6105b761403d565b6105b7614043565b6105b7614049565b6105ad60048036036020811015610b9357600080fd5b50356001600160a01b031661404f565b6001546001600160a01b03163314610bec5760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600954604080516397ffe1d760e01b81526004810184905290516001600160a01b03909216916397ffe1d79160248082019260009290919082900301818387803b158015610c3957600080fd5b505af1158015610c4d573d6000803e3d6000fd5b5050505050565b60235481565b6001546001600160a01b03163314610ca35760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600e54811015610ce45760405162461bcd60e51b815260040180806020018281038252602a815260200180614c88602a913960400191505060405180910390fd5b6096811115610d245760405162461bcd60e51b8152600401808060200182810382526024815260200180614d126024913960400191505060405180910390fd5b601d55565b60105481565b6001546001600160a01b03163314610d785760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600a8110158015610d8b57506103e88111155b610dc65760405162461bcd60e51b8152600401808060200182810382526028815260200180614dfb6028913960400191505060405180910390fd5b601155565b600080610dd661317f565b9050600d548111610e7957601c54610df257600d549150610e79565b6000610e1b82610e15670de0b6b3a7640000600d546140ff90919063ffffffff16565b90614161565b90506000610e46612710610e15601c54610e40600d54876141c890919063ffffffff16565b906140ff565b600d54909150610e569082614225565b93506000601a54118015610e6b5750601a5484115b15610e7657601a5493505b50505b5090565b600080610e8861317f565b9050600e54811115610e79576000610eb26064610e15601d54600d546140ff90919063ffffffff16565b9050808210610f14576000610ede612710610e15601e54610e40600d54886141c890919063ffffffff16565b600d54909150610eee9082614225565b93506000601b54118015610f035750601b5484115b15610f0e57601b5493505b50610f1a565b600d5492505b505090565b610f2761427f565b15610f635760405162461bcd60e51b8152600401808060200182810382526026815260200180614e716026913960400191505060405180910390fd5b610f6b61429e565b15610fa75760405162461bcd60e51b8152600401808060200182810382526026815260200180614e716026913960400191505060405180910390fd5b436000908152602081815260408083203284529091528082208054600160ff1991821681179092553384529190922080549091169091179055600254421015611037576040805162461bcd60e51b815260206004820152601960248201527f54726561737572793a206e6f7420737461727465642079657400000000000000604482015290519081900360640190fd5b6006546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b15801561107b57600080fd5b505afa15801561108f573d6000803e3d6000fd5b505050506040513d60208110156110a557600080fd5b50516001600160a01b031614801561113357506007546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b1580156110fc57600080fd5b505afa158015611110573d6000803e3d6000fd5b505050506040513d602081101561112657600080fd5b50516001600160a01b0316145b80156111b557506008546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b15801561117e57600080fd5b505afa158015611192573d6000803e3d6000fd5b505050506040513d60208110156111a857600080fd5b50516001600160a01b0316145b801561123757506009546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b15801561120057600080fd5b505afa158015611214573d6000803e3d6000fd5b505050506040513d602081101561122a57600080fd5b50516001600160a01b0316145b611288576040805162461bcd60e51b815260206004820152601e60248201527f54726561737572793a206e656564206d6f7265207065726d697373696f6e0000604482015290519081900360640190fd5b600082116112c75760405162461bcd60e51b815260040180806020018281038252602e815260200180614ce4602e913960400191505060405180910390fd5b60006112d161317f565b9050818114611327576040805162461bcd60e51b815260206004820152601a60248201527f54726561737572793a204441524b207072696365206d6f766564000000000000604482015290519081900360640190fd5b600e5481116113675760405162461bcd60e51b8152600401808060200182810382526032815260200180614cb26032913960400191505060405180910390fd5b6000611371610e7d565b9050600081116113c8576040805162461bcd60e51b815260206004820152601b60248201527f54726561737572793a20696e76616c696420626f6e6420726174650000000000604482015290519081900360640190fd5b60006113e0670de0b6b3a7640000610e1587856140ff565b600654604080516370a0823160e01b8152306004820152905192935083926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561143057600080fd5b505afa158015611444573d6000803e3d6000fd5b505050506040513d602081101561145a57600080fd5b505110156114995760405162461bcd60e51b8152600401808060200182810382526025815260200180614d5c6025913960400191505060405180910390fd5b6114b16114a8600f54836142bd565b600f54906141c8565b600f556007546040805163079cc67960e41b81523360048201526024810188905290516001600160a01b03909216916379cc67909160448082019260009290919082900301818387803b15801561150757600080fd5b505af115801561151b573d6000803e3d6000fd5b505060065461153792506001600160a01b0316905033836142d3565b61153f61433a565b6040805182815260208101879052815133927f51e0d16595cabc591e64da08e45bb223577e5b9a39cd947b4ddc3472b2dd8878928290030190a25050505050565b600060165460035410156115975750601754611606565b60006115a161317f565b9050600e548110610e795760006115c3600d54836141c890919063ffffffff16565b905060006115e2655af3107a40006011546140ff90919063ffffffff16565b9050808211156115f0578091505b61160082655af3107a4000614161565b93505050505b90565b6001546001600160a01b031633146116525760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b614e208111156116a9576040805162461bcd60e51b815260206004820152601d60248201527f5f646973636f756e7450657263656e74206973206f7665722032303025000000604482015290519081900360640190fd5b601c55565b600154600160a01b900460ff1681565b6001546001600160a01b031633146117075760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b6001600160a01b03861661174b576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b611388851115611791576040805162461bcd60e51b815260206004820152600c60248201526b6f7574206f662072616e676560a01b604482015290519081900360640190fd5b6001600160a01b0384166117d5576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b6103e883111561181b576040805162461bcd60e51b815260206004820152600c60248201526b6f7574206f662072616e676560a01b604482015290519081900360640190fd5b6001600160a01b03821661185f576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b6103e88111156118a5576040805162461bcd60e51b815260206004820152600c60248201526b6f7574206f662072616e676560a01b604482015290519081900360640190fd5b602080546001600160a01b03199081166001600160a01b039889161790915560219590955560228054861694871694909417909355602391909155602480549093169316929092179055602555565b6001546001600160a01b0316331461193d5760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b678ac7230489e8000081111561199a576040805162461bcd60e51b815260206004820152601b60248201527f54726561737572793a20646f6e742070617920746f6f206d7563680000000000604482015290519081900360640190fd5b601955565b6001546001600160a01b031633146119e85760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b6005811115611a3e576040805162461bcd60e51b815260206004820152601360248201527f4d6178207374616b652066656520697320352500000000000000000000000000604482015290519081900360640190fd5b600c819055600954604080517fe2d7bee40000000000000000000000000000000000000000000000000000000081526004810184905290516001600160a01b039092169163e2d7bee49160248082019260009290919082900301818387803b158015610c3957600080fd5b60135481565b601c5481565b601b5481565b600154600160a01b900460ff1690565b6001546001600160a01b03163314611b145760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600d548110158015611b405750611b3c6064610e156078600d546140ff90919063ffffffff16565b8111155b611b80576040805162461bcd60e51b815260206004820152600c60248201526b6f7574206f662072616e676560a01b604482015290519081900360640190fd5b600e55565b601f5481565b6001546001600160a01b03163314611bd45760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b614e20811115611c2b576040805162461bcd60e51b815260206004820152601c60248201527f5f7072656d69756d50657263656e74206973206f766572203230302500000000604482015290519081900360640190fd5b601e55565b600a54600654604080517f6808a1280000000000000000000000000000000000000000000000000000000081526001600160a01b039283166004820152670de0b6b3a7640000602482015290516000939290921691636808a12891604480820192602092909190829003018186803b158015611cab57600080fd5b505afa925050508015611cd057506040513d6020811015611ccb57600080fd5b505160015b611d0b5760405162461bcd60e51b8152600401808060200182810382526036815260200180614c526036913960400191505060405180910390fd5b71ffffffffffffffffffffffffffffffffffff169050611606565b6022546001600160a01b031681565b6001546001600160a01b03163314611d7e5760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b6127108110158015611d925750614e208111155b611dcd5760405162461bcd60e51b8152600401808060200182810382526029815260200180614dd26029913960400191505060405180910390fd5b601f55565b6001546001600160a01b03163314611e1b5760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b6006546001600160a01b0384811691161415611e80576040805162461bcd60e51b8152602060048083019190915260248201527f6461726b00000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6007546001600160a01b0384811691161415611ee3576040805162461bcd60e51b815260206004820152600560248201527f6c69676874000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6008546001600160a01b0384811691161415611f46576040805162461bcd60e51b815260206004820152600560248201527f7368617265000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611f5a6001600160a01b03841682846142d3565b505050565b600080611f6a61317f565b9050600d548111610e79576000611f7f613cd9565b90506000611f9e612710610e15601554856140ff90919063ffffffff16565b90506000600760009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ff057600080fd5b505afa158015612004573d6000803e3d6000fd5b505050506040513d602081101561201a57600080fd5b505190508082111561205f57600061203283836141c8565b9050600061204c670de0b6b3a7640000610e1584896140ff565b905061205a600454826142bd565b965050505b5050505090565b61206e61427f565b156120aa5760405162461bcd60e51b8152600401808060200182810382526026815260200180614e716026913960400191505060405180910390fd5b6120b261429e565b156120ee5760405162461bcd60e51b8152600401808060200182810382526026815260200180614e716026913960400191505060405180910390fd5b436000908152602081815260408083203284529091528082208054600160ff199182168117909255338452919092208054909116909117905560025442101561217e576040805162461bcd60e51b815260206004820152601960248201527f54726561737572793a206e6f7420737461727465642079657400000000000000604482015290519081900360640190fd5b6006546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b1580156121c257600080fd5b505afa1580156121d6573d6000803e3d6000fd5b505050506040513d60208110156121ec57600080fd5b50516001600160a01b031614801561227a57506007546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b15801561224357600080fd5b505afa158015612257573d6000803e3d6000fd5b505050506040513d602081101561226d57600080fd5b50516001600160a01b0316145b80156122fc57506008546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b1580156122c557600080fd5b505afa1580156122d9573d6000803e3d6000fd5b505050506040513d60208110156122ef57600080fd5b50516001600160a01b0316145b801561237e57506009546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b15801561234757600080fd5b505afa15801561235b573d6000803e3d6000fd5b505050506040513d602081101561237157600080fd5b50516001600160a01b0316145b6123cf576040805162461bcd60e51b815260206004820152601e60248201527f54726561737572793a206e656564206d6f7265207065726d697373696f6e0000604482015290519081900360640190fd5b6000821161240e5760405162461bcd60e51b8152600401808060200182810382526030815260200180614da26030913960400191505060405180910390fd5b600061241861317f565b905081811461246e576040805162461bcd60e51b815260206004820152601a60248201527f54726561737572793a204441524b207072696365206d6f766564000000000000604482015290519081900360640190fd5b600d5481106124ae5760405162461bcd60e51b8152600401808060200182810382526032815260200180614cb26032913960400191505060405180910390fd5b6004548311156124ef5760405162461bcd60e51b815260040180806020018281038252602a815260200180614ecd602a913960400191505060405180910390fd5b60006124f9610dcb565b905060008111612550576040805162461bcd60e51b815260206004820152601b60248201527f54726561737572793a20696e76616c696420626f6e6420726174650000000000604482015290519081900360640190fd5b6000612568670de0b6b3a7640000610e1587856140ff565b90506000612574613cd9565b905060006125fc83600760009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156125ca57600080fd5b505afa1580156125de573d6000803e3d6000fd5b505050506040513d60208110156125f457600080fd5b505190614225565b9050612619612710610e15601554856140ff90919063ffffffff16565b81111561266d576040805162461bcd60e51b815260206004820152601360248201527f6f766572206d6178206465627420726174696f00000000000000000000000000604482015290519081900360640190fd5b6006546040805163079cc67960e41b8152336004820152602481018a905290516001600160a01b03909216916379cc67909160448082019260009290919082900301818387803b1580156126c057600080fd5b505af11580156126d4573d6000803e3d6000fd5b5050600754604080516340c10f1960e01b81523360048201526024810188905290516001600160a01b0390921693506340c10f1992506044808201926020929091908290030181600087803b15801561272c57600080fd5b505af1158015612740573d6000803e3d6000fd5b505050506040513d602081101561275657600080fd5b505060045461276590886141c8565b60045561277061433a565b6040805188815260208101859052815133927f73017f1b70789e2e66759eeb3c7ec11f59e6eedb55d921cfaec5410dd42a4799928290030190a250505050505050565b60215481565b6001546001600160a01b031681565b6001546001600160a01b031633146128115760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b6103e8811015801561282557506127108111155b612865576040805162461bcd60e51b815260206004820152600c60248201526b6f7574206f662072616e676560a01b604482015290519081900360640190fd5b601555565b600f5490565b600f5481565b61287e61427f565b156128ba5760405162461bcd60e51b8152600401808060200182810382526026815260200180614e716026913960400191505060405180910390fd5b6128c261429e565b156128fe5760405162461bcd60e51b8152600401808060200182810382526026815260200180614e716026913960400191505060405180910390fd5b436000908152602081815260408083203284529091528082208054600160ff199182168117909255338452919092208054909116909117905560025442101561298e576040805162461bcd60e51b815260206004820152601960248201527f54726561737572793a206e6f7420737461727465642079657400000000000000604482015290519081900360640190fd5b612996613bf0565b4210156129ea576040805162461bcd60e51b815260206004820152601860248201527f54726561737572793a206e6f74206f70656e6564207965740000000000000000604482015290519081900360640190fd5b6006546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b158015612a2e57600080fd5b505afa158015612a42573d6000803e3d6000fd5b505050506040513d6020811015612a5857600080fd5b50516001600160a01b0316148015612ae657506007546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b158015612aaf57600080fd5b505afa158015612ac3573d6000803e3d6000fd5b505050506040513d6020811015612ad957600080fd5b50516001600160a01b0316145b8015612b6857506008546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b158015612b3157600080fd5b505afa158015612b45573d6000803e3d6000fd5b505050506040513d6020811015612b5b57600080fd5b50516001600160a01b0316145b8015612bea57506009546040805163570ca73560e01b8152905130926001600160a01b03169163570ca735916004808301926020929190829003018186803b158015612bb357600080fd5b505afa158015612bc7573d6000803e3d6000fd5b505050506040513d6020811015612bdd57600080fd5b50516001600160a01b0316145b612c3b576040805162461bcd60e51b815260206004820152601e60248201527f54726561737572793a206e656564206d6f7265207065726d697373696f6e0000604482015290519081900360640190fd5b612c4361433a565b612c4b61317f565b601855600f54600090612c6690612c60613cd9565b906141c8565b90506016546003541015612cfb57612c97612c92612710610e15601754856140ff90919063ffffffff16565b61439e565b7f94a896583ef35ce156f07410cc5a289d003c9a2200539d5282f2557769becb4a600354601854612cd9612710610e15601754876140ff90919063ffffffff16565b60408051938452602084019290925282820152519081900360600190a16130b0565b600e54601854106130005760095460408051635b56321560e11b815260006004820181905291516001600160a01b039093169263b6ac642a9260248084019391929182900301818387803b158015612d5257600080fd5b505af1158015612d66573d6000803e3d6000fd5b505050506000600760009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015612dba57600080fd5b505afa158015612dce573d6000803e3d6000fd5b505050506040513d6020811015612de457600080fd5b5051600d54601854919250600091612dfb916141c8565b90506000806000612e15655af3107a4000610e40886147ca565b905080841115612e23578093505b612e3e612710610e15601254886140ff90919063ffffffff16565b600f5410612e6357612e5c670de0b6b3a7640000610e1588876140ff565b9150612ecf565b6000612e7b670de0b6b3a7640000610e1589886140ff565b9050612e98612710610e15601354846140ff90919063ffffffff16565b9250612ea481846141c8565b601f5490945015612ecd57612eca612710610e15601f54876140ff90919063ffffffff16565b93505b505b8115612ede57612ede8261439e565b8215612fb057600f54612ef19084614225565b600f55600654604080516340c10f1960e01b81523060048201526024810186905290516001600160a01b03909216916340c10f19916044808201926020929091908290030181600087803b158015612f4857600080fd5b505af1158015612f5c573d6000803e3d6000fd5b505050506040513d6020811015612f7257600080fd5b5050604080514281526020810185905281517ff705142bf09f04297640495ddf7c59b7fd6f51894c5aea9602d631cf05f0efc2929181900390910190a15b600354601854604080519283526020830191909152818101849052517f94a896583ef35ce156f07410cc5a289d003c9a2200539d5282f2557769becb4a9181900360600190a150505050506130b0565b600954600b5460408051635b56321560e11b81526004810192909252516001600160a01b039092169163b6ac642a9160248082019260009290919082900301818387803b15801561305057600080fd5b505af1158015613064573d6000803e3d6000fd5b5050600354601854604080519283526020830191909152600082820152517f94a896583ef35ce156f07410cc5a289d003c9a2200539d5282f2557769becb4a9350908190036060019150a15b6019541561313c57600654601954604080516340c10f1960e01b81523360048201526024810192909252516001600160a01b03909216916340c10f19916044808201926020929091908290030181600087803b15801561310f57600080fd5b505af1158015613123573d6000803e3d6000fd5b505050506040513d602081101561313957600080fd5b50505b5060035461314b906001614225565b600355600e5461315961317f565b1161317757613172612710610e15601454610e40613cd9565b61317a565b60005b600455565b600a54600654604080517f3ddac9530000000000000000000000000000000000000000000000000000000081526001600160a01b039283166004820152670de0b6b3a7640000602482015290516000939290921691633ddac95391604480820192602092909190829003018186803b158015611cab57600080fd5b6009546001600160a01b031681565b6007546001600160a01b031681565b6008546001600160a01b031681565b600e5481565b60195481565b60008061323e61317f565b9050600e54811115610e7957600654604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561329557600080fd5b505afa1580156132a9573d6000803e3d6000fd5b505050506040513d60208110156132bf57600080fd5b5051905060006132cd610e7d565b90508015610e765761160081610e1584670de0b6b3a76400006140ff565b60025481565b60125481565b6005818154811061330457fe5b6000918252602090912001546001600160a01b0316905081565b60255481565b60175481565b6001546001600160a01b031633146133735760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b6101f4811015801561338757506127108111155b6133c7576040805162461bcd60e51b815260206004820152600c60248201526b6f7574206f662072616e676560a01b604482015290519081900360640190fd5b601255565b600a546001600160a01b031681565b6020546001600160a01b031681565b6006546001600160a01b031681565b60035481565b6001546001600160a01b031633146134485760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b605a82111561349e576040805162461bcd60e51b815260206004820152601e60248201527f5f626f6f74737472617045706f6368733a206f7574206f662072616e67650000604482015290519081900360640190fd5b606481101580156134b157506103e88111155b6134ec5760405162461bcd60e51b815260040180806020018281038252602e815260200180614ef7602e913960400191505060405180910390fd5b601691909155601755565b600154600160a01b900460ff1615613556576040805162461bcd60e51b815260206004820152601d60248201527f54726561737572793a20616c726561647920696e697469616c697a6564000000604482015290519081900360640190fd5b600680546001600160a01b03199081166001600160a01b0389811691909117909255600780548216888416179055600880548216878416179055600a80548216868416179055600980549091169184169190911790556002819055670de0b6b3a7640000600d8190556135d190606490610e159060656140ff565b600e5569d3c21bcecceda100000060105561015e6011556002600b55612710601255610dac601381905561012c6014556015908155606e601d55611b58601e556702c68af0bb1400006019556016556101c2601755600654604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561367157600080fd5b505afa158015613685573d6000803e3d6000fd5b505050506040513d602081101561369b57600080fd5b5051600f55600180546001600160a01b03197fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909116600160a01b1716339081179091556040805143815290517f25ff68dd81b34665b5ba7e553ee5511bf6812e12adb4a7e2c0d9e26b3099ce799181900360200190a2505050505050565b6001546001600160a01b031633146137635760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b601a55565b6001546001600160a01b031633146137b15760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b601b55565b6001546001600160a01b031633146137ff5760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600954604080517f54575af40000000000000000000000000000000000000000000000000000000081526001600160a01b038681166004830152602482018690528481166044830152915191909216916354575af491606480830192600092919082900301818387803b15801561387557600080fd5b505af1158015613889573d6000803e3d6000fd5b50505050505050565b6001546001600160a01b031633146138db5760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600954604080517fb3ab15fb0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301529151919092169163b3ab15fb91602480830192600092919082900301818387803b158015610c3957600080fd5b6001546001600160a01b0316331461398b5760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146139f65760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600980546001600160a01b0319166001600160a01b0392909216919091179055565b61708081565b6001546001600160a01b03163314613a675760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b613a6f613cd9565b8111613ac2576040805162461bcd60e51b815260206004820152600960248201527f746f6f20736d616c6c0000000000000000000000000000000000000000000000604482015290519081900360640190fd5b601055565b600080613ad8600f54612c60613cd9565b90506000600760009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015613b2a57600080fd5b505afa158015613b3e573d6000803e3d6000fd5b505050506040513d6020811015613b5457600080fd5b505190506000613b62611580565b9050613b7f612710610e15601254856140ff90919063ffffffff16565b600f5410613ba157613b97612710610e1585846140ff565b9350505050611606565b6000613bb3612710610e1586856140ff565b9050613bd0612710610e15601354846140ff90919063ffffffff16565b945050505050611606565b6024546001600160a01b031681565b601a5481565b6000613c15613c0c6170806003546140ff90919063ffffffff16565b60025490614225565b905090565b601e5481565b601d5481565b6001546001600160a01b03163314613c6f5760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b60648110158015613c8257506105dc8111155b613cc2576040805162461bcd60e51b815260206004820152600c60248201526b6f7574206f662072616e676560a01b604482015290519081900360640190fd5b601455565b600b5481565b60115481565b60155481565b600654604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b031691839183916318160ddd916004808301926020929190829003018186803b158015613d3b57600080fd5b505afa158015613d4f573d6000803e3d6000fd5b505050506040513d6020811015613d6557600080fd5b505190506000805b60055460ff82161015613e3f57613e35846001600160a01b03166370a0823160058460ff1681548110613d9c57fe5b60009182526020918290200154604080517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b0390921660048301525160248083019392829003018186803b158015613e0257600080fd5b505afa158015613e16573d6000803e3d6000fd5b505050506040513d6020811015613e2c57600080fd5b50518390614225565b9150600101613d6d565b5061160082826141c8565b6001546001600160a01b03163314613e935760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b6014811115613ee9576040805162461bcd60e51b815260206004820152601760248201527f4d61782077697468647261772066656520697320323025000000000000000000604482015290519081900360640190fd5b600b55565b60145481565b6001546001600160a01b03163314613f3d5760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b60165481565b600c5481565b6001546001600160a01b03163314613fb45760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600954604080517f2ffaaa09000000000000000000000000000000000000000000000000000000008152600481018590526024810184905290516001600160a01b0390921691632ffaaa099160448082019260009290919082900301818387803b15801561402157600080fd5b505af1158015614035573d6000803e3d6000fd5b505050505050565b600d5481565b60185481565b60045481565b6001546001600160a01b031633146140985760405162461bcd60e51b8152600401808060200182810382526024815260200180614e236024913960400191505060405180910390fd5b600954604080517ff498d8a60000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301529151919092169163f498d8a691602480830192600092919082900301818387803b158015610c3957600080fd5b60008261410e5750600061415b565b8282028284828161411b57fe5b04146141585760405162461bcd60e51b8152600401808060200182810382526021815260200180614d816021913960400191505060405180910390fd5b90505b92915050565b60008082116141b7576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816141c057fe5b049392505050565b60008282111561421f576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082820183811015614158576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b4360009081526020818152604080832032845290915290205460ff1690565b4360009081526020818152604080832033845290915290205460ff1690565b60008183106142cc5781614158565b5090919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b179052611f5a908490614827565b600a60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561438a57600080fd5b505af192505050801561439b575060015b50565b600654604080516340c10f1960e01b81523060048201526024810184905290516001600160a01b03909216916340c10f19916044808201926020929091908290030181600087803b1580156143f257600080fd5b505af1158015614406573d6000803e3d6000fd5b505050506040513d602081101561441c57600080fd5b50506021546000901561450457614444612710610e15602154856140ff90919063ffffffff16565b600654602080546040805163a9059cbb60e01b81526001600160a01b03928316600482015260248101869052905194955092169263a9059cbb9260448082019392918290030181600087803b15801561449c57600080fd5b505af11580156144b0573d6000803e3d6000fd5b505050506040513d60208110156144c657600080fd5b5050604080514281526020810183905281517fcb3f34aaa3445b461e6da5492dc89e5c257a59fa598131f3b6bbc97a3638e409929181900390910190a15b602354600090156145ed5761452a612710610e15602354866140ff90919063ffffffff16565b6006546022546040805163a9059cbb60e01b81526001600160a01b03928316600482015260248101859052905193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561458557600080fd5b505af1158015614599573d6000803e3d6000fd5b505050506040513d60208110156145af57600080fd5b5050604080514281526020810183905281517fdc8b715b18523e58b7fd0da53259dfa91efd91df4a854d94b136e3333a3b9395929181900390910190a15b602554600090156146d657614613612710610e15602554876140ff90919063ffffffff16565b600654602480546040805163a9059cbb60e01b81526001600160a01b039283166004820152928301859052519394509091169163a9059cbb916044808201926020929091908290030181600087803b15801561466e57600080fd5b505af1158015614682573d6000803e3d6000fd5b505050506040513d602081101561469857600080fd5b5050604080514281526020810183905281517f3cdb297d43aaa0da840fd0a1f52eadd12f655a7a0002fb2eab8cf8172febc42c929181900390910190a15b6146e681612c60848188886141c8565b600954600654919550614707916001600160a01b03908116911660006148d8565b600954600654614724916001600160a01b039182169116866148d8565b600954604080516397ffe1d760e01b81526004810187905290516001600160a01b03909216916397ffe1d79160248082019260009290919082900301818387803b15801561477157600080fd5b505af1158015614785573d6000803e3d6000fd5b5050604080514281526020810188905281517f03ca7276ab7799bf73fb79d27ff0610cd7049574f2508ef8445162833d439aea9450908190039091019150a150505050565b6000601054821061481f576147f2612710610e156130d46010546140ff90919063ffffffff16565b60105560115461480c9061271090610e159061251c6140ff565b6011819055600a111561481f57600a6011555b505060115490565b606061487c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614a329092919063ffffffff16565b805190915015611f5a5780806020019051602081101561489b57600080fd5b5051611f5a5760405162461bcd60e51b815260040180806020018281038252602a815260200180614e47602a913960400191505060405180910390fd5b8015806149775750604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561494957600080fd5b505afa15801561495d573d6000803e3d6000fd5b505050506040513d602081101561497357600080fd5b5051155b6149b25760405162461bcd60e51b8152600401808060200182810382526036815260200180614e976036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052611f5a908490614827565b6060614a418484600085614a4b565b90505b9392505050565b606082471015614a8c5760405162461bcd60e51b8152600401808060200182810382526026815260200180614d366026913960400191505060405180910390fd5b614a9585614ba7565b614ae6576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310614b255780518252601f199092019160209182019101614b06565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614b87576040519150601f19603f3d011682016040523d82523d6000602084013e614b8c565b606091505b5091509150614b9c828286614bad565b979650505050505050565b3b151590565b60608315614bbc575081614a44565b825115614bcc5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614c16578181015183820152602001614bfe565b50505050905090810190601f168015614c435780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe54726561737572793a206661696c656420746f20636f6e73756c74204441524b2070726963652066726f6d20746865206f7261636c655f7072656d69756d5468726573686f6c642065786365656473206461726b50726963654365696c696e6754726561737572793a206461726b5072696365206e6f7420656c696769626c6520666f7220626f6e6420707572636861736554726561737572793a2063616e6e6f742072656465656d20626f6e64732077697468207a65726f20616d6f756e745f7072656d69756d5468726573686f6c6420697320686967686572207468616e20312e35416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c54726561737572793a20747265617375727920686173206e6f206d6f726520627564676574536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7754726561737572793a2063616e6e6f7420707572636861736520626f6e64732077697468207a65726f20616d6f756e745f6d696e74696e67466163746f72466f72506179696e67446562743a206f7574206f662072616e67655f6d6178537570706c79457870616e73696f6e50657263656e743a206f7574206f662072616e676554726561737572793a2063616c6c6572206973206e6f7420746865206f70657261746f725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564436f6e747261637447756172643a206f6e6520626c6f636b2c206f6e652066756e6374696f6e5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e636554726561737572793a206e6f7420656e6f75676820626f6e64206c65667420746f2070757263686173655f626f6f747374726170537570706c79457870616e73696f6e50657263656e743a206f7574206f662072616e6765a26469706673582212202ba620915f0f001fe0eaa87191a133ce26982b8749a43c57db1470cf5064b1d164736f6c634300060c0033