ETH Price: $3,238.31 (+1.37%)

Contract

0x067e398605E84F2D0aEEC1806e62768C5110DCc6
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Nominate New Own...115143972020-12-24 5:23:381420 days ago1608787418IN
Synthetix: Collateral Manager
0 ETH0.0044895100
Add Shortable Sy...115141252020-12-24 4:27:211421 days ago1608784041IN
Synthetix: Collateral Manager
0 ETH0.06883965150
Add Synths115141242020-12-24 4:27:171421 days ago1608784037IN
Synthetix: Collateral Manager
0 ETH0.0344997150
Add Collaterals115141112020-12-24 4:24:481421 days ago1608783888IN
Synthetix: Collateral Manager
0 ETH0.02617965150
0x670de0b6115141062020-12-24 4:23:491421 days ago1608783829IN
 Create: CollateralManager
0 ETH0.49326705150

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
211316892024-11-06 22:47:237 days ago1730933243
0x067e3986...C5110DCc6
0 ETH
211316892024-11-06 22:47:237 days ago1730933243
0x067e3986...C5110DCc6
0 ETH
211316892024-11-06 22:47:237 days ago1730933243
0x067e3986...C5110DCc6
0 ETH
211316892024-11-06 22:47:237 days ago1730933243
0x067e3986...C5110DCc6
0 ETH
211313072024-11-06 21:30:237 days ago1730928623
0x067e3986...C5110DCc6
0 ETH
211312582024-11-06 21:20:357 days ago1730928035
0x067e3986...C5110DCc6
0 ETH
211312582024-11-06 21:20:357 days ago1730928035
0x067e3986...C5110DCc6
0 ETH
211312582024-11-06 21:20:357 days ago1730928035
0x067e3986...C5110DCc6
0 ETH
211312582024-11-06 21:20:357 days ago1730928035
0x067e3986...C5110DCc6
0 ETH
211307482024-11-06 19:37:597 days ago1730921879
0x067e3986...C5110DCc6
0 ETH
211301082024-11-06 17:29:477 days ago1730914187
0x067e3986...C5110DCc6
0 ETH
210767582024-10-30 6:46:1114 days ago1730270771
0x067e3986...C5110DCc6
0 ETH
210725302024-10-29 16:37:1115 days ago1730219831
0x067e3986...C5110DCc6
0 ETH
210721652024-10-29 15:23:5915 days ago1730215439
0x067e3986...C5110DCc6
0 ETH
210721652024-10-29 15:23:5915 days ago1730215439
0x067e3986...C5110DCc6
0 ETH
210700952024-10-29 8:27:5915 days ago1730190479
0x067e3986...C5110DCc6
0 ETH
210700952024-10-29 8:27:5915 days ago1730190479
0x067e3986...C5110DCc6
0 ETH
210682022024-10-29 2:06:5916 days ago1730167619
0x067e3986...C5110DCc6
0 ETH
210672812024-10-28 23:01:5916 days ago1730156519
0x067e3986...C5110DCc6
0 ETH
210671092024-10-28 22:27:1116 days ago1730154431
0x067e3986...C5110DCc6
0 ETH
210643852024-10-28 13:19:1116 days ago1730121551
0x067e3986...C5110DCc6
0 ETH
210636872024-10-28 10:58:5916 days ago1730113139
0x067e3986...C5110DCc6
0 ETH
210626452024-10-28 7:29:3516 days ago1730100575
0x067e3986...C5110DCc6
0 ETH
210616962024-10-28 4:17:5917 days ago1730089079
0x067e3986...C5110DCc6
0 ETH
210615582024-10-28 3:50:1117 days ago1730087411
0x067e3986...C5110DCc6
0 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CollateralManager

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2020-12-24
*/

/*
   ____            __   __        __   _
  / __/__ __ ___  / /_ / /  ___  / /_ (_)__ __
 _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ /
/___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\
     /___/

* Synthetix: CollateralManager.sol
*
* Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/CollateralManager.sol
* Docs: https://docs.synthetix.io/contracts/CollateralManager
*
* Contract Dependencies: 
*	- IAddressResolver
*	- ICollateralManager
*	- MixinResolver
*	- Owned
*	- Pausable
*	- State
* Libraries: 
*	- AddressSetLib
*	- Bytes32SetLib
*	- SafeDecimalMath
*	- SafeMath
*
* MIT License
* ===========
*
* Copyright (c) 2020 Synthetix
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/



pragma solidity ^0.5.16;


// https://docs.synthetix.io/contracts/source/contracts/owned
contract Owned {
    address public owner;
    address public nominatedOwner;

    constructor(address _owner) public {
        require(_owner != address(0), "Owner address cannot be 0");
        owner = _owner;
        emit OwnerChanged(address(0), _owner);
    }

    function nominateNewOwner(address _owner) external onlyOwner {
        nominatedOwner = _owner;
        emit OwnerNominated(_owner);
    }

    function acceptOwnership() external {
        require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
        emit OwnerChanged(owner, nominatedOwner);
        owner = nominatedOwner;
        nominatedOwner = address(0);
    }

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

    function _onlyOwner() private view {
        require(msg.sender == owner, "Only the contract owner may perform this action");
    }

    event OwnerNominated(address newOwner);
    event OwnerChanged(address oldOwner, address newOwner);
}


// Inheritance


// https://docs.synthetix.io/contracts/source/contracts/pausable
contract Pausable is Owned {
    uint public lastPauseTime;
    bool public paused;

    constructor() internal {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner != address(0), "Owner must be set");
        // Paused will be false, and lastPauseTime will be 0 upon initialisation
    }

    /**
     * @notice Change the paused state of the contract
     * @dev Only the contract owner may call this.
     */
    function setPaused(bool _paused) external onlyOwner {
        // Ensure we're actually changing the state before we do anything
        if (_paused == paused) {
            return;
        }

        // Set our paused state.
        paused = _paused;

        // If applicable, set the last pause time.
        if (paused) {
            lastPauseTime = now;
        }

        // Let everyone know that our pause state has changed.
        emit PauseChanged(paused);
    }

    event PauseChanged(bool isPaused);

    modifier notPaused {
        require(!paused, "This action cannot be performed while the contract is paused");
        _;
    }
}


// https://docs.synthetix.io/contracts/source/interfaces/iaddressresolver
interface IAddressResolver {
    function getAddress(bytes32 name) external view returns (address);

    function getSynth(bytes32 key) external view returns (address);

    function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address);
}


// https://docs.synthetix.io/contracts/source/interfaces/isynth
interface ISynth {
    // Views
    function currencyKey() external view returns (bytes32);

    function transferableSynths(address account) external view returns (uint);

    // Mutative functions
    function transferAndSettle(address to, uint value) external returns (bool);

    function transferFromAndSettle(
        address from,
        address to,
        uint value
    ) external returns (bool);

    // Restricted: used internally to Synthetix
    function burn(address account, uint amount) external;

    function issue(address account, uint amount) external;
}


// https://docs.synthetix.io/contracts/source/interfaces/iissuer
interface IIssuer {
    // Views
    function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid);

    function availableCurrencyKeys() external view returns (bytes32[] memory);

    function availableSynthCount() external view returns (uint);

    function availableSynths(uint index) external view returns (ISynth);

    function canBurnSynths(address account) external view returns (bool);

    function collateral(address account) external view returns (uint);

    function collateralisationRatio(address issuer) external view returns (uint);

    function collateralisationRatioAndAnyRatesInvalid(address _issuer)
        external
        view
        returns (uint cratio, bool anyRateIsInvalid);

    function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint debtBalance);

    function issuanceRatio() external view returns (uint);

    function lastIssueEvent(address account) external view returns (uint);

    function maxIssuableSynths(address issuer) external view returns (uint maxIssuable);

    function minimumStakeTime() external view returns (uint);

    function remainingIssuableSynths(address issuer)
        external
        view
        returns (
            uint maxIssuable,
            uint alreadyIssued,
            uint totalSystemDebt
        );

    function synths(bytes32 currencyKey) external view returns (ISynth);

    function getSynths(bytes32[] calldata currencyKeys) external view returns (ISynth[] memory);

    function synthsByAddress(address synthAddress) external view returns (bytes32);

    function totalIssuedSynths(bytes32 currencyKey, bool excludeEtherCollateral) external view returns (uint);

    function transferableSynthetixAndAnyRateIsInvalid(address account, uint balance)
        external
        view
        returns (uint transferable, bool anyRateIsInvalid);

    // Restricted: used internally to Synthetix
    function issueSynths(address from, uint amount) external;

    function issueSynthsOnBehalf(
        address issueFor,
        address from,
        uint amount
    ) external;

    function issueMaxSynths(address from) external;

    function issueMaxSynthsOnBehalf(address issueFor, address from) external;

    function burnSynths(address from, uint amount) external;

    function burnSynthsOnBehalf(
        address burnForAddress,
        address from,
        uint amount
    ) external;

    function burnSynthsToTarget(address from) external;

    function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external;

    function liquidateDelinquentAccount(
        address account,
        uint susdAmount,
        address liquidator
    ) external returns (uint totalRedeemed, uint amountToLiquidate);
}


// Inheritance


// Internal references


// https://docs.synthetix.io/contracts/source/contracts/addressresolver
contract AddressResolver is Owned, IAddressResolver {
    mapping(bytes32 => address) public repository;

    constructor(address _owner) public Owned(_owner) {}

    /* ========== RESTRICTED FUNCTIONS ========== */

    function importAddresses(bytes32[] calldata names, address[] calldata destinations) external onlyOwner {
        require(names.length == destinations.length, "Input lengths must match");

        for (uint i = 0; i < names.length; i++) {
            bytes32 name = names[i];
            address destination = destinations[i];
            repository[name] = destination;
            emit AddressImported(name, destination);
        }
    }

    /* ========= PUBLIC FUNCTIONS ========== */

    function rebuildCaches(MixinResolver[] calldata destinations) external {
        for (uint i = 0; i < destinations.length; i++) {
            destinations[i].rebuildCache();
        }
    }

    /* ========== VIEWS ========== */

    function areAddressesImported(bytes32[] calldata names, address[] calldata destinations) external view returns (bool) {
        for (uint i = 0; i < names.length; i++) {
            if (repository[names[i]] != destinations[i]) {
                return false;
            }
        }
        return true;
    }

    function getAddress(bytes32 name) external view returns (address) {
        return repository[name];
    }

    function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address) {
        address _foundAddress = repository[name];
        require(_foundAddress != address(0), reason);
        return _foundAddress;
    }

    function getSynth(bytes32 key) external view returns (address) {
        IIssuer issuer = IIssuer(repository["Issuer"]);
        require(address(issuer) != address(0), "Cannot find Issuer address");
        return address(issuer.synths(key));
    }

    /* ========== EVENTS ========== */

    event AddressImported(bytes32 name, address destination);
}


// solhint-disable payable-fallback

// https://docs.synthetix.io/contracts/source/contracts/readproxy
contract ReadProxy is Owned {
    address public target;

    constructor(address _owner) public Owned(_owner) {}

    function setTarget(address _target) external onlyOwner {
        target = _target;
        emit TargetUpdated(target);
    }

    function() external {
        // The basics of a proxy read call
        // Note that msg.sender in the underlying will always be the address of this contract.
        assembly {
            calldatacopy(0, 0, calldatasize)

            // Use of staticcall - this will revert if the underlying function mutates state
            let result := staticcall(gas, sload(target_slot), 0, calldatasize, 0, 0)
            returndatacopy(0, 0, returndatasize)

            if iszero(result) {
                revert(0, returndatasize)
            }
            return(0, returndatasize)
        }
    }

    event TargetUpdated(address newTarget);
}


// Inheritance


// Internal references


// https://docs.synthetix.io/contracts/source/contracts/mixinresolver
contract MixinResolver {
    AddressResolver public resolver;

    mapping(bytes32 => address) private addressCache;

    constructor(address _resolver) internal {
        resolver = AddressResolver(_resolver);
    }

    /* ========== INTERNAL FUNCTIONS ========== */

    function combineArrays(bytes32[] memory first, bytes32[] memory second)
        internal
        pure
        returns (bytes32[] memory combination)
    {
        combination = new bytes32[](first.length + second.length);

        for (uint i = 0; i < first.length; i++) {
            combination[i] = first[i];
        }

        for (uint j = 0; j < second.length; j++) {
            combination[first.length + j] = second[j];
        }
    }

    /* ========== PUBLIC FUNCTIONS ========== */

    // Note: this function is public not external in order for it to be overridden and invoked via super in subclasses
    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {}

    function rebuildCache() public {
        bytes32[] memory requiredAddresses = resolverAddressesRequired();
        // The resolver must call this function whenver it updates its state
        for (uint i = 0; i < requiredAddresses.length; i++) {
            bytes32 name = requiredAddresses[i];
            // Note: can only be invoked once the resolver has all the targets needed added
            address destination = resolver.requireAndGetAddress(
                name,
                string(abi.encodePacked("Resolver missing target: ", name))
            );
            addressCache[name] = destination;
            emit CacheUpdated(name, destination);
        }
    }

    /* ========== VIEWS ========== */

    function isResolverCached() external view returns (bool) {
        bytes32[] memory requiredAddresses = resolverAddressesRequired();
        for (uint i = 0; i < requiredAddresses.length; i++) {
            bytes32 name = requiredAddresses[i];
            // false if our cache is invalid or if the resolver doesn't have the required address
            if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) {
                return false;
            }
        }

        return true;
    }

    /* ========== INTERNAL FUNCTIONS ========== */

    function requireAndGetAddress(bytes32 name) internal view returns (address) {
        address _foundAddress = addressCache[name];
        require(_foundAddress != address(0), string(abi.encodePacked("Missing address: ", name)));
        return _foundAddress;
    }

    /* ========== EVENTS ========== */

    event CacheUpdated(bytes32 name, address destination);
}


interface ICollateralManager {
    // Manager information
    function hasCollateral(address collateral) external view returns (bool);

    function isSynthManaged(bytes32 currencyKey) external view returns (bool);

    // State information
    function long(bytes32 synth) external view returns (uint amount);

    function short(bytes32 synth) external view returns (uint amount);

    function totalLong() external view returns (uint susdValue, bool anyRateIsInvalid);

    function totalShort() external view returns (uint susdValue, bool anyRateIsInvalid);

    function getBorrowRate() external view returns (uint borrowRate, bool anyRateIsInvalid);

    function getShortRate(bytes32 synth) external view returns (uint shortRate, bool rateIsInvalid);

    function getRatesAndTime(uint index)
        external
        view
        returns (
            uint entryRate,
            uint lastRate,
            uint lastUpdated,
            uint newIndex
        );

    function getShortRatesAndTime(bytes32 currency, uint index)
        external
        view
        returns (
            uint entryRate,
            uint lastRate,
            uint lastUpdated,
            uint newIndex
        );

    function exceedsDebtLimit(uint amount, bytes32 currency) external view returns (bool canIssue, bool anyRateIsInvalid);

    function areSynthsAndCurrenciesSet(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys)
        external
        view
        returns (bool);

    function areShortableSynthsSet(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys)
        external
        view
        returns (bool);

    // Loans
    function getNewLoanId() external returns (uint id);

    // Manager mutative
    function addCollaterals(address[] calldata collaterals) external;

    function removeCollaterals(address[] calldata collaterals) external;

    function addSynths(bytes32[] calldata synthNamesInResolver, bytes32[] calldata synthKeys) external;

    function removeSynths(bytes32[] calldata synths, bytes32[] calldata synthKeys) external;

    function addShortableSynths(bytes32[2][] calldata requiredSynthAndInverseNamesInResolver, bytes32[] calldata synthKeys)
        external;

    function removeShortableSynths(bytes32[] calldata synths) external;

    // State mutative
    function updateBorrowRates(uint rate) external;

    function updateShortRates(bytes32 currency, uint rate) external;

    function incrementLongs(bytes32 synth, uint amount) external;

    function decrementLongs(bytes32 synth, uint amount) external;

    function incrementShorts(bytes32 synth, uint amount) external;

    function decrementShorts(bytes32 synth, uint amount) external;
}


// https://docs.synthetix.io/contracts/source/libraries/addresssetlib/
library AddressSetLib {
    struct AddressSet {
        address[] elements;
        mapping(address => uint) indices;
    }

    function contains(AddressSet storage set, address candidate) internal view returns (bool) {
        if (set.elements.length == 0) {
            return false;
        }
        uint index = set.indices[candidate];
        return index != 0 || set.elements[0] == candidate;
    }

    function getPage(
        AddressSet storage set,
        uint index,
        uint pageSize
    ) internal view returns (address[] memory) {
        // NOTE: This implementation should be converted to slice operators if the compiler is updated to v0.6.0+
        uint endIndex = index + pageSize; // The check below that endIndex <= index handles overflow.

        // If the page extends past the end of the list, truncate it.
        if (endIndex > set.elements.length) {
            endIndex = set.elements.length;
        }
        if (endIndex <= index) {
            return new address[](0);
        }

        uint n = endIndex - index; // We already checked for negative overflow.
        address[] memory page = new address[](n);
        for (uint i; i < n; i++) {
            page[i] = set.elements[i + index];
        }
        return page;
    }

    function add(AddressSet storage set, address element) internal {
        // Adding to a set is an idempotent operation.
        if (!contains(set, element)) {
            set.indices[element] = set.elements.length;
            set.elements.push(element);
        }
    }

    function remove(AddressSet storage set, address element) internal {
        require(contains(set, element), "Element not in set.");
        // Replace the removed element with the last element of the list.
        uint index = set.indices[element];
        uint lastIndex = set.elements.length - 1; // We required that element is in the list, so it is not empty.
        if (index != lastIndex) {
            // No need to shift the last element if it is the one we want to delete.
            address shiftedElement = set.elements[lastIndex];
            set.elements[index] = shiftedElement;
            set.indices[shiftedElement] = index;
        }
        set.elements.pop();
        delete set.indices[element];
    }
}


// https://docs.synthetix.io/contracts/source/libraries/bytes32setlib/
library Bytes32SetLib {
    struct Bytes32Set {
        bytes32[] elements;
        mapping(bytes32 => uint) indices;
    }

    function contains(Bytes32Set storage set, bytes32 candidate) internal view returns (bool) {
        if (set.elements.length == 0) {
            return false;
        }
        uint index = set.indices[candidate];
        return index != 0 || set.elements[0] == candidate;
    }

    function getPage(
        Bytes32Set storage set,
        uint index,
        uint pageSize
    ) internal view returns (bytes32[] memory) {
        // NOTE: This implementation should be converted to slice operators if the compiler is updated to v0.6.0+
        uint endIndex = index + pageSize; // The check below that endIndex <= index handles overflow.

        // If the page extends past the end of the list, truncate it.
        if (endIndex > set.elements.length) {
            endIndex = set.elements.length;
        }
        if (endIndex <= index) {
            return new bytes32[](0);
        }

        uint n = endIndex - index; // We already checked for negative overflow.
        bytes32[] memory page = new bytes32[](n);
        for (uint i; i < n; i++) {
            page[i] = set.elements[i + index];
        }
        return page;
    }

    function add(Bytes32Set storage set, bytes32 element) internal {
        // Adding to a set is an idempotent operation.
        if (!contains(set, element)) {
            set.indices[element] = set.elements.length;
            set.elements.push(element);
        }
    }

    function remove(Bytes32Set storage set, bytes32 element) internal {
        require(contains(set, element), "Element not in set.");
        // Replace the removed element with the last element of the list.
        uint index = set.indices[element];
        uint lastIndex = set.elements.length - 1; // We required that element is in the list, so it is not empty.
        if (index != lastIndex) {
            // No need to shift the last element if it is the one we want to delete.
            bytes32 shiftedElement = set.elements[lastIndex];
            set.elements[index] = shiftedElement;
            set.indices[shiftedElement] = index;
        }
        set.elements.pop();
        delete set.indices[element];
    }
}


/**
 * @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, 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");
        uint256 c = a - b;

        return c;
    }

    /**
     * @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) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, "SafeMath: division by zero");
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

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


// Libraries


// https://docs.synthetix.io/contracts/source/libraries/safedecimalmath
library SafeDecimalMath {
    using SafeMath for uint;

    /* Number of decimal places in the representations. */
    uint8 public constant decimals = 18;
    uint8 public constant highPrecisionDecimals = 27;

    /* The number representing 1.0. */
    uint public constant UNIT = 10**uint(decimals);

    /* The number representing 1.0 for higher fidelity numbers. */
    uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals);
    uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals);

    /**
     * @return Provides an interface to UNIT.
     */
    function unit() external pure returns (uint) {
        return UNIT;
    }

    /**
     * @return Provides an interface to PRECISE_UNIT.
     */
    function preciseUnit() external pure returns (uint) {
        return PRECISE_UNIT;
    }

    /**
     * @return The result of multiplying x and y, interpreting the operands as fixed-point
     * decimals.
     *
     * @dev A unit factor is divided out after the product of x and y is evaluated,
     * so that product must be less than 2**256. As this is an integer division,
     * the internal division always rounds down. This helps save on gas. Rounding
     * is more expensive on gas.
     */
    function multiplyDecimal(uint x, uint y) internal pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        return x.mul(y) / UNIT;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of the specified precision unit.
     *
     * @dev The operands should be in the form of a the specified unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function _multiplyDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        uint quotientTimesTen = x.mul(y) / (precisionUnit / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a precise unit.
     *
     * @dev The operands should be in the precise unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a standard unit.
     *
     * @dev The operands should be in the standard unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is a high
     * precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and UNIT must be less than 2**256. As
     * this is an integer division, the result is always rounded down.
     * This helps save on gas. Rounding is more expensive on gas.
     */
    function divideDecimal(uint x, uint y) internal pure returns (uint) {
        /* Reintroduce the UNIT factor that will be divided out by y. */
        return x.mul(UNIT).div(y);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * decimal in the precision unit specified in the parameter.
     *
     * @dev y is divided after the product of x and the specified precision unit
     * is evaluated, so the product of x and the specified precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function _divideDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        uint resultTimesTen = x.mul(precisionUnit * 10).div(y);

        if (resultTimesTen % 10 >= 5) {
            resultTimesTen += 10;
        }

        return resultTimesTen / 10;
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * standard precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and the standard precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * high precision decimal.
     *
     * @dev y is divided after the product of x and the high precision unit
     * is evaluated, so the product of x and the high precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @dev Convert a standard decimal representation to a high precision one.
     */
    function decimalToPreciseDecimal(uint i) internal pure returns (uint) {
        return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
    }

    /**
     * @dev Convert a high precision decimal to a standard decimal representation.
     */
    function preciseDecimalToDecimal(uint i) internal pure returns (uint) {
        uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }
}


// Inheritance


// https://docs.synthetix.io/contracts/source/contracts/state
contract State is Owned {
    // the address of the contract that can modify variables
    // this can only be changed by the owner of this contract
    address public associatedContract;

    constructor(address _associatedContract) internal {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner != address(0), "Owner must be set");

        associatedContract = _associatedContract;
        emit AssociatedContractUpdated(_associatedContract);
    }

    /* ========== SETTERS ========== */

    // Change the associated contract to a new address
    function setAssociatedContract(address _associatedContract) external onlyOwner {
        associatedContract = _associatedContract;
        emit AssociatedContractUpdated(_associatedContract);
    }

    /* ========== MODIFIERS ========== */

    modifier onlyAssociatedContract {
        require(msg.sender == associatedContract, "Only the associated contract can perform this action");
        _;
    }

    /* ========== EVENTS ========== */

    event AssociatedContractUpdated(address associatedContract);
}


pragma experimental ABIEncoderV2;

// Inheritance


// Libraries


contract CollateralManagerState is Owned, State {
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    struct Balance {
        uint long;
        uint short;
    }

    uint public totalLoans;

    uint[] public borrowRates;
    uint public borrowRatesLastUpdated;

    mapping(bytes32 => uint[]) public shortRates;
    mapping(bytes32 => uint) public shortRatesLastUpdated;

    // The total amount of long and short for a synth,
    mapping(bytes32 => Balance) public totalIssuedSynths;

    constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {
        borrowRates.push(0);
        borrowRatesLastUpdated = block.timestamp;
    }

    function incrementTotalLoans() external onlyAssociatedContract returns (uint) {
        totalLoans = totalLoans.add(1);
        return totalLoans;
    }

    function long(bytes32 synth) external view onlyAssociatedContract returns (uint) {
        return totalIssuedSynths[synth].long;
    }

    function short(bytes32 synth) external view onlyAssociatedContract returns (uint) {
        return totalIssuedSynths[synth].short;
    }

    function incrementLongs(bytes32 synth, uint256 amount) external onlyAssociatedContract {
        totalIssuedSynths[synth].long = totalIssuedSynths[synth].long.add(amount);
    }

    function decrementLongs(bytes32 synth, uint256 amount) external onlyAssociatedContract {
        totalIssuedSynths[synth].long = totalIssuedSynths[synth].long.sub(amount);
    }

    function incrementShorts(bytes32 synth, uint256 amount) external onlyAssociatedContract {
        totalIssuedSynths[synth].short = totalIssuedSynths[synth].short.add(amount);
    }

    function decrementShorts(bytes32 synth, uint256 amount) external onlyAssociatedContract {
        totalIssuedSynths[synth].short = totalIssuedSynths[synth].short.sub(amount);
    }

    // Borrow rates, one array here for all currencies.

    function getRateAt(uint index) public view returns (uint) {
        return borrowRates[index];
    }

    function getRatesLength() public view returns (uint) {
        return borrowRates.length;
    }

    function updateBorrowRates(uint rate) external onlyAssociatedContract {
        borrowRates.push(rate);
        borrowRatesLastUpdated = block.timestamp;
    }

    function ratesLastUpdated() public view returns (uint) {
        return borrowRatesLastUpdated;
    }

    function getRatesAndTime(uint index)
        external
        view
        returns (
            uint entryRate,
            uint lastRate,
            uint lastUpdated,
            uint newIndex
        )
    {
        newIndex = getRatesLength();
        entryRate = getRateAt(index);
        lastRate = getRateAt(newIndex - 1);
        lastUpdated = ratesLastUpdated();
    }

    // Short rates, one array per currency.

    function addShortCurrency(bytes32 currency) external onlyAssociatedContract {
        if (shortRates[currency].length > 0) {} else {
            shortRates[currency].push(0);
            shortRatesLastUpdated[currency] = block.timestamp;
        }
    }

    function removeShortCurrency(bytes32 currency) external onlyAssociatedContract {
        delete shortRates[currency];
    }

    function getShortRateAt(bytes32 currency, uint index) internal view returns (uint) {
        return shortRates[currency][index];
    }

    function getShortRatesLength(bytes32 currency) public view returns (uint) {
        return shortRates[currency].length;
    }

    function updateShortRates(bytes32 currency, uint rate) external onlyAssociatedContract {
        shortRates[currency].push(rate);
        shortRatesLastUpdated[currency] = block.timestamp;
    }

    function shortRateLastUpdated(bytes32 currency) internal view returns (uint) {
        return shortRatesLastUpdated[currency];
    }

    function getShortRatesAndTime(bytes32 currency, uint index)
        external
        view
        returns (
            uint entryRate,
            uint lastRate,
            uint lastUpdated,
            uint newIndex
        )
    {
        newIndex = getShortRatesLength(currency);
        entryRate = getShortRateAt(currency, index);
        lastRate = getShortRateAt(currency, newIndex - 1);
        lastUpdated = shortRateLastUpdated(currency);
    }
}


// https://docs.synthetix.io/contracts/source/interfaces/iexchangerates
interface IExchangeRates {
    // Structs
    struct RateAndUpdatedTime {
        uint216 rate;
        uint40 time;
    }

    struct InversePricing {
        uint entryPoint;
        uint upperLimit;
        uint lowerLimit;
        bool frozenAtUpperLimit;
        bool frozenAtLowerLimit;
    }

    // Views
    function aggregators(bytes32 currencyKey) external view returns (address);

    function aggregatorWarningFlags() external view returns (address);

    function anyRateIsInvalid(bytes32[] calldata currencyKeys) external view returns (bool);

    function canFreezeRate(bytes32 currencyKey) external view returns (bool);

    function currentRoundForRate(bytes32 currencyKey) external view returns (uint);

    function currenciesUsingAggregator(address aggregator) external view returns (bytes32[] memory);

    function effectiveValue(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external view returns (uint value);

    function effectiveValueAndRates(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    )
        external
        view
        returns (
            uint value,
            uint sourceRate,
            uint destinationRate
        );

    function effectiveValueAtRound(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        uint roundIdForSrc,
        uint roundIdForDest
    ) external view returns (uint value);

    function getCurrentRoundId(bytes32 currencyKey) external view returns (uint);

    function getLastRoundIdBeforeElapsedSecs(
        bytes32 currencyKey,
        uint startingRoundId,
        uint startingTimestamp,
        uint timediff
    ) external view returns (uint);

    function inversePricing(bytes32 currencyKey)
        external
        view
        returns (
            uint entryPoint,
            uint upperLimit,
            uint lowerLimit,
            bool frozenAtUpperLimit,
            bool frozenAtLowerLimit
        );

    function lastRateUpdateTimes(bytes32 currencyKey) external view returns (uint256);

    function oracle() external view returns (address);

    function rateAndTimestampAtRound(bytes32 currencyKey, uint roundId) external view returns (uint rate, uint time);

    function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time);

    function rateAndInvalid(bytes32 currencyKey) external view returns (uint rate, bool isInvalid);

    function rateForCurrency(bytes32 currencyKey) external view returns (uint);

    function rateIsFlagged(bytes32 currencyKey) external view returns (bool);

    function rateIsFrozen(bytes32 currencyKey) external view returns (bool);

    function rateIsInvalid(bytes32 currencyKey) external view returns (bool);

    function rateIsStale(bytes32 currencyKey) external view returns (bool);

    function rateStalePeriod() external view returns (uint);

    function ratesAndUpdatedTimeForCurrencyLastNRounds(bytes32 currencyKey, uint numRounds)
        external
        view
        returns (uint[] memory rates, uint[] memory times);

    function ratesAndInvalidForCurrencies(bytes32[] calldata currencyKeys)
        external
        view
        returns (uint[] memory rates, bool anyRateInvalid);

    function ratesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory);

    // Mutative functions
    function freezeRate(bytes32 currencyKey) external;
}


// https://docs.synthetix.io/contracts/source/interfaces/idebtcache
interface IDebtCache {
    // Views

    function cachedDebt() external view returns (uint);

    function cachedSynthDebt(bytes32 currencyKey) external view returns (uint);

    function cacheTimestamp() external view returns (uint);

    function cacheInvalid() external view returns (bool);

    function cacheStale() external view returns (bool);

    function currentSynthDebts(bytes32[] calldata currencyKeys)
        external
        view
        returns (uint[] memory debtValues, bool anyRateIsInvalid);

    function cachedSynthDebts(bytes32[] calldata currencyKeys) external view returns (uint[] memory debtValues);

    function currentDebt() external view returns (uint debt, bool anyRateIsInvalid);

    function cacheInfo()
        external
        view
        returns (
            uint debt,
            uint timestamp,
            bool isInvalid,
            bool isStale
        );

    // Mutative functions

    function takeDebtSnapshot() external;

    function updateCachedSynthDebts(bytes32[] calldata currencyKeys) external;
}


// https://docs.synthetix.io/contracts/source/interfaces/ierc20
interface IERC20 {
    // ERC20 Optional Views
    function name() external view returns (string memory);

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

    function decimals() external view returns (uint8);

    // Views
    function totalSupply() external view returns (uint);

    function balanceOf(address owner) external view returns (uint);

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

    // Mutative functions
    function transfer(address to, uint value) external returns (bool);

    function approve(address spender, uint value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint value
    ) external returns (bool);

    // Events
    event Transfer(address indexed from, address indexed to, uint value);

    event Approval(address indexed owner, address indexed spender, uint value);
}


// Inheritance


// Libraries


// Internal references


contract CollateralManager is ICollateralManager, Owned, Pausable, MixinResolver {
    /* ========== LIBRARIES ========== */
    using SafeMath for uint;
    using SafeDecimalMath for uint;
    using AddressSetLib for AddressSetLib.AddressSet;
    using Bytes32SetLib for Bytes32SetLib.Bytes32Set;

    /* ========== CONSTANTS ========== */

    bytes32 private constant sUSD = "sUSD";

    uint private constant SECONDS_IN_A_YEAR = 31556926 * 1e18;

    // Flexible storage names
    bytes32 public constant CONTRACT_NAME = "CollateralManager";
    bytes32 internal constant COLLATERAL_SYNTHS = "collateralSynth";

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

    // Stores debt balances and borrow rates.
    CollateralManagerState public state;

    // The set of all collateral contracts.
    AddressSetLib.AddressSet internal _collaterals;

    // The set of all synths issuable by the various collateral contracts
    Bytes32SetLib.Bytes32Set internal _synths;

    // Map from currency key to synth contract name.
    mapping(bytes32 => bytes32) public synthsByKey;

    // The set of all synths that are shortable.
    Bytes32SetLib.Bytes32Set internal _shortableSynths;

    mapping(bytes32 => bytes32) public synthToInverseSynth;

    // The factor that will scale the utilisation ratio.
    uint public utilisationMultiplier = 1e18;

    // The maximum amount of debt in sUSD that can be issued by non snx collateral.
    uint public maxDebt;

    // The base interest rate applied to all borrows.
    uint public baseBorrowRate;

    // The base interest rate applied to all shorts.
    uint public baseShortRate;

    /* ---------- Address Resolver Configuration ---------- */

    bytes32 private constant CONTRACT_ISSUER = "Issuer";
    bytes32 private constant CONTRACT_EXRATES = "ExchangeRates";

    bytes32[24] private addressesToCache = [CONTRACT_ISSUER, CONTRACT_EXRATES];

    /* ========== CONSTRUCTOR ========== */
    constructor(
        CollateralManagerState _state,
        address _owner,
        address _resolver,
        uint _maxDebt,
        uint _baseBorrowRate,
        uint _baseShortRate
    ) public Owned(_owner) Pausable() MixinResolver(_resolver) {
        owner = msg.sender;
        state = _state;

        setMaxDebt(_maxDebt);
        setBaseBorrowRate(_baseBorrowRate);
        setBaseShortRate(_baseShortRate);

        owner = _owner;
    }

    /* ========== VIEWS ========== */

    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
        bytes32[] memory staticAddresses = new bytes32[](2);
        staticAddresses[0] = CONTRACT_ISSUER;
        staticAddresses[1] = CONTRACT_EXRATES;

        // we want to cache the name of the synth and the name of its corresponding iSynth
        bytes32[] memory shortAddresses;
        uint length = _shortableSynths.elements.length;

        if (length > 0) {
            shortAddresses = new bytes32[](length * 2);

            for (uint i = 0; i < length; i++) {
                shortAddresses[i] = _shortableSynths.elements[i];
                shortAddresses[i + length] = synthToInverseSynth[_shortableSynths.elements[i]];
            }
        }

        bytes32[] memory synthAddresses = combineArrays(shortAddresses, _synths.elements);

        if (synthAddresses.length > 0) {
            addresses = combineArrays(synthAddresses, staticAddresses);
        } else {
            addresses = staticAddresses;
        }
    }

    // helper function to check whether synth "by key" is a collateral issued by multi-collateral
    function isSynthManaged(bytes32 currencyKey) external view returns (bool) {
        return synthsByKey[currencyKey] != bytes32(0);
    }

    /* ---------- Related Contracts ---------- */

    function _issuer() internal view returns (IIssuer) {
        return IIssuer(requireAndGetAddress(CONTRACT_ISSUER));
    }

    function _exchangeRates() internal view returns (IExchangeRates) {
        return IExchangeRates(requireAndGetAddress(CONTRACT_EXRATES));
    }

    function _synth(bytes32 synthName) internal view returns (ISynth) {
        return ISynth(requireAndGetAddress(synthName));
    }

    /* ---------- Manager Information ---------- */

    function hasCollateral(address collateral) public view returns (bool) {
        return _collaterals.contains(collateral);
    }

    function hasAllCollaterals(address[] memory collaterals) public view returns (bool) {
        for (uint i = 0; i < collaterals.length; i++) {
            if (!hasCollateral(collaterals[i])) {
                return false;
            }
        }
        return true;
    }

    /* ---------- State Information ---------- */

    function long(bytes32 synth) external view returns (uint amount) {
        return state.long(synth);
    }

    function short(bytes32 synth) external view returns (uint amount) {
        return state.short(synth);
    }

    function totalLong() public view returns (uint susdValue, bool anyRateIsInvalid) {
        bytes32[] memory synths = _synths.elements;

        if (synths.length > 0) {
            for (uint i = 0; i < synths.length; i++) {
                bytes32 synth = _synth(synths[i]).currencyKey();
                if (synth == sUSD) {
                    susdValue = susdValue.add(state.long(synth));
                } else {
                    (uint rate, bool invalid) = _exchangeRates().rateAndInvalid(synth);
                    uint amount = state.long(synth).multiplyDecimal(rate);
                    susdValue = susdValue.add(amount);
                    if (invalid) {
                        anyRateIsInvalid = true;
                    }
                }
            }
        }
    }

    function totalShort() public view returns (uint susdValue, bool anyRateIsInvalid) {
        bytes32[] memory synths = _shortableSynths.elements;

        if (synths.length > 0) {
            for (uint i = 0; i < synths.length; i++) {
                bytes32 synth = _synth(synths[i]).currencyKey();
                (uint rate, bool invalid) = _exchangeRates().rateAndInvalid(synth);
                uint amount = state.short(synth).multiplyDecimal(rate);
                susdValue = susdValue.add(amount);
                if (invalid) {
                    anyRateIsInvalid = true;
                }
            }
        }
    }

    function getBorrowRate() external view returns (uint borrowRate, bool anyRateIsInvalid) {
        // get the snx backed debt.
        uint snxDebt = _issuer().totalIssuedSynths(sUSD, true);

        // now get the non snx backed debt.
        (uint nonSnxDebt, bool ratesInvalid) = totalLong();

        // the total.
        uint totalDebt = snxDebt.add(nonSnxDebt);

        // now work out the utilisation ratio, and divide through to get a per second value.
        uint utilisation = nonSnxDebt.divideDecimal(totalDebt).divideDecimal(SECONDS_IN_A_YEAR);

        // scale it by the utilisation multiplier.
        uint scaledUtilisation = utilisation.multiplyDecimal(utilisationMultiplier);

        // finally, add the base borrow rate.
        borrowRate = scaledUtilisation.add(baseBorrowRate);

        anyRateIsInvalid = ratesInvalid;
    }

    function getShortRate(bytes32 synth) external view returns (uint shortRate, bool rateIsInvalid) {
        bytes32 synthKey = _synth(synth).currencyKey();

        rateIsInvalid = _exchangeRates().rateIsInvalid(synthKey);

        // get the spot supply of the synth, its iSynth
        uint longSupply = IERC20(address(_synth(synth))).totalSupply();
        uint inverseSupply = IERC20(address(_synth(synthToInverseSynth[synth]))).totalSupply();
        // add the iSynth to supply properly reflect the market skew.
        uint shortSupply = state.short(synthKey).add(inverseSupply);

        // in this case, the market is skewed long so its free to short.
        if (longSupply > shortSupply) {
            return (0, rateIsInvalid);
        }

        // otherwise workout the skew towards the short side.
        uint skew = shortSupply.sub(longSupply);

        // divide through by the size of the market
        uint proportionalSkew = skew.divideDecimal(longSupply.add(shortSupply)).divideDecimal(SECONDS_IN_A_YEAR);

        // finally, add the base short rate.
        shortRate = proportionalSkew.add(baseShortRate);
    }

    function getRatesAndTime(uint index)
        external
        view
        returns (
            uint entryRate,
            uint lastRate,
            uint lastUpdated,
            uint newIndex
        )
    {
        (entryRate, lastRate, lastUpdated, newIndex) = state.getRatesAndTime(index);
    }

    function getShortRatesAndTime(bytes32 currency, uint index)
        external
        view
        returns (
            uint entryRate,
            uint lastRate,
            uint lastUpdated,
            uint newIndex
        )
    {
        (entryRate, lastRate, lastUpdated, newIndex) = state.getShortRatesAndTime(currency, index);
    }

    function exceedsDebtLimit(uint amount, bytes32 currency) external view returns (bool canIssue, bool anyRateIsInvalid) {
        uint usdAmount = _exchangeRates().effectiveValue(currency, amount, sUSD);

        (uint longValue, bool longInvalid) = totalLong();
        (uint shortValue, bool shortInvalid) = totalShort();

        anyRateIsInvalid = longInvalid || shortInvalid;

        return (longValue.add(shortValue).add(usdAmount) <= maxDebt, anyRateIsInvalid);
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    /* ---------- SETTERS ---------- */

    function setUtilisationMultiplier(uint _utilisationMultiplier) public onlyOwner {
        require(_utilisationMultiplier > 0, "Must be greater than 0");
        utilisationMultiplier = _utilisationMultiplier;
    }

    function setMaxDebt(uint _maxDebt) public onlyOwner {
        require(_maxDebt > 0, "Must be greater than 0");
        maxDebt = _maxDebt;
        emit MaxDebtUpdated(maxDebt);
    }

    function setBaseBorrowRate(uint _baseBorrowRate) public onlyOwner {
        baseBorrowRate = _baseBorrowRate;
        emit BaseBorrowRateUpdated(baseBorrowRate);
    }

    function setBaseShortRate(uint _baseShortRate) public onlyOwner {
        baseShortRate = _baseShortRate;
        emit BaseShortRateUpdated(baseShortRate);
    }

    /* ---------- LOANS ---------- */

    function getNewLoanId() external onlyCollateral returns (uint id) {
        id = state.incrementTotalLoans();
    }

    /* ---------- MANAGER ---------- */

    function addCollaterals(address[] calldata collaterals) external onlyOwner {
        for (uint i = 0; i < collaterals.length; i++) {
            if (!_collaterals.contains(collaterals[i])) {
                _collaterals.add(collaterals[i]);
                emit CollateralAdded(collaterals[i]);
            }
        }
    }

    function removeCollaterals(address[] calldata collaterals) external onlyOwner {
        for (uint i = 0; i < collaterals.length; i++) {
            if (_collaterals.contains(collaterals[i])) {
                _collaterals.remove(collaterals[i]);
                emit CollateralRemoved(collaterals[i]);
            }
        }
    }

    function addSynths(bytes32[] calldata synthNamesInResolver, bytes32[] calldata synthKeys) external onlyOwner {
        for (uint i = 0; i < synthNamesInResolver.length; i++) {
            if (!_synths.contains(synthNamesInResolver[i])) {
                bytes32 synthName = synthNamesInResolver[i];
                _synths.add(synthName);
                synthsByKey[synthKeys[i]] = synthName;
                emit SynthAdded(synthName);
            }
        }
    }

    function areSynthsAndCurrenciesSet(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys)
        external
        view
        returns (bool)
    {
        if (_synths.elements.length != requiredSynthNamesInResolver.length) {
            return false;
        }

        for (uint i = 0; i < requiredSynthNamesInResolver.length; i++) {
            if (!_synths.contains(requiredSynthNamesInResolver[i])) {
                return false;
            }
            if (synthsByKey[synthKeys[i]] != requiredSynthNamesInResolver[i]) {
                return false;
            }
        }

        return true;
    }

    function removeSynths(bytes32[] calldata synths, bytes32[] calldata synthKeys) external onlyOwner {
        for (uint i = 0; i < synths.length; i++) {
            if (_synths.contains(synths[i])) {
                // Remove it from the the address set lib.
                _synths.remove(synths[i]);
                delete synthsByKey[synthKeys[i]];

                emit SynthRemoved(synths[i]);
            }
        }
    }

    // When we add a shortable synth, we need to know the iSynth as well
    // This is so we can get the proper skew for the short rate.
    function addShortableSynths(bytes32[2][] calldata requiredSynthAndInverseNamesInResolver, bytes32[] calldata synthKeys)
        external
        onlyOwner
    {
        require(requiredSynthAndInverseNamesInResolver.length == synthKeys.length, "Input array length mismatch");

        for (uint i = 0; i < requiredSynthAndInverseNamesInResolver.length; i++) {
            // setting these explicitly for clarity
            // Each entry in the array is [Synth, iSynth]
            bytes32 synth = requiredSynthAndInverseNamesInResolver[i][0];
            bytes32 iSynth = requiredSynthAndInverseNamesInResolver[i][1];

            if (!_shortableSynths.contains(synth)) {
                // Add it to the address set lib.
                _shortableSynths.add(synth);

                // store the mapping to the iSynth so we can get its total supply for the borrow rate.
                synthToInverseSynth[synth] = iSynth;

                emit ShortableSynthAdded(synth);

                // now the associated synth key to the CollateralManagerState
                state.addShortCurrency(synthKeys[i]);
            }
        }

        rebuildCache();
    }

    function areShortableSynthsSet(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys)
        external
        view
        returns (bool)
    {
        require(requiredSynthNamesInResolver.length == synthKeys.length, "Input array length mismatch");

        if (_shortableSynths.elements.length != requiredSynthNamesInResolver.length) {
            return false;
        }

        // first check contract state
        for (uint i = 0; i < requiredSynthNamesInResolver.length; i++) {
            bytes32 synthName = requiredSynthNamesInResolver[i];
            if (!_shortableSynths.contains(synthName) || synthToInverseSynth[synthName] == bytes32(0)) {
                return false;
            }
        }

        // now check everything added to external state contract
        for (uint i = 0; i < synthKeys.length; i++) {
            if (state.getShortRatesLength(synthKeys[i]) == 0) {
                return false;
            }
        }

        return true;
    }

    function removeShortableSynths(bytes32[] calldata synths) external onlyOwner {
        for (uint i = 0; i < synths.length; i++) {
            if (_shortableSynths.contains(synths[i])) {
                // Remove it from the the address set lib.
                _shortableSynths.remove(synths[i]);

                bytes32 synthKey = _synth(synths[i]).currencyKey();

                state.removeShortCurrency(synthKey);

                // remove the inverse mapping.
                delete synthToInverseSynth[synths[i]];

                emit ShortableSynthRemoved(synths[i]);
            }
        }
    }

    /* ---------- STATE MUTATIONS ---------- */

    function updateBorrowRates(uint rate) external onlyCollateral {
        state.updateBorrowRates(rate);
    }

    function updateShortRates(bytes32 currency, uint rate) external onlyCollateral {
        state.updateShortRates(currency, rate);
    }

    function incrementLongs(bytes32 synth, uint amount) external onlyCollateral {
        state.incrementLongs(synth, amount);
    }

    function decrementLongs(bytes32 synth, uint amount) external onlyCollateral {
        state.decrementLongs(synth, amount);
    }

    function incrementShorts(bytes32 synth, uint amount) external onlyCollateral {
        state.incrementShorts(synth, amount);
    }

    function decrementShorts(bytes32 synth, uint amount) external onlyCollateral {
        state.decrementShorts(synth, amount);
    }

    /* ========== MODIFIERS ========== */

    modifier onlyCollateral {
        bool isMultiCollateral = hasCollateral(msg.sender);

        require(isMultiCollateral, "Only collateral contracts");
        _;
    }

    // ========== EVENTS ==========
    event MaxDebtUpdated(uint maxDebt);
    event LiquidationPenaltyUpdated(uint liquidationPenalty);
    event BaseBorrowRateUpdated(uint baseBorrowRate);
    event BaseShortRateUpdated(uint baseShortRate);

    event CollateralAdded(address collateral);
    event CollateralRemoved(address collateral);

    event SynthAdded(bytes32 synth);
    event SynthRemoved(bytes32 synth);

    event ShortableSynthAdded(bytes32 synth);
    event ShortableSynthRemoved(bytes32 synth);
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract CollateralManagerState","name":"_state","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_resolver","type":"address"},{"internalType":"uint256","name":"_maxDebt","type":"uint256"},{"internalType":"uint256","name":"_baseBorrowRate","type":"uint256"},{"internalType":"uint256","name":"_baseShortRate","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"baseBorrowRate","type":"uint256"}],"name":"BaseBorrowRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"baseShortRate","type":"uint256"}],"name":"BaseShortRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"CacheUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collateral","type":"address"}],"name":"CollateralAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collateral","type":"address"}],"name":"CollateralRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidationPenalty","type":"uint256"}],"name":"LiquidationPenaltyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxDebt","type":"uint256"}],"name":"MaxDebtUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"synth","type":"bytes32"}],"name":"ShortableSynthAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"synth","type":"bytes32"}],"name":"ShortableSynthRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"synth","type":"bytes32"}],"name":"SynthAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"synth","type":"bytes32"}],"name":"SynthRemoved","type":"event"},{"constant":true,"inputs":[],"name":"CONTRACT_NAME","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"collaterals","type":"address[]"}],"name":"addCollaterals","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[2][]","name":"requiredSynthAndInverseNamesInResolver","type":"bytes32[2][]"},{"internalType":"bytes32[]","name":"synthKeys","type":"bytes32[]"}],"name":"addShortableSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[]","name":"synthNamesInResolver","type":"bytes32[]"},{"internalType":"bytes32[]","name":"synthKeys","type":"bytes32[]"}],"name":"addSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"requiredSynthNamesInResolver","type":"bytes32[]"},{"internalType":"bytes32[]","name":"synthKeys","type":"bytes32[]"}],"name":"areShortableSynthsSet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"requiredSynthNamesInResolver","type":"bytes32[]"},{"internalType":"bytes32[]","name":"synthKeys","type":"bytes32[]"}],"name":"areSynthsAndCurrenciesSet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"baseBorrowRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"baseShortRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"synth","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"decrementLongs","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"synth","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"decrementShorts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"}],"name":"exceedsDebtLimit","outputs":[{"internalType":"bool","name":"canIssue","type":"bool"},{"internalType":"bool","name":"anyRateIsInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getBorrowRate","outputs":[{"internalType":"uint256","name":"borrowRate","type":"uint256"},{"internalType":"bool","name":"anyRateIsInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"getNewLoanId","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRatesAndTime","outputs":[{"internalType":"uint256","name":"entryRate","type":"uint256"},{"internalType":"uint256","name":"lastRate","type":"uint256"},{"internalType":"uint256","name":"lastUpdated","type":"uint256"},{"internalType":"uint256","name":"newIndex","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"synth","type":"bytes32"}],"name":"getShortRate","outputs":[{"internalType":"uint256","name":"shortRate","type":"uint256"},{"internalType":"bool","name":"rateIsInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getShortRatesAndTime","outputs":[{"internalType":"uint256","name":"entryRate","type":"uint256"},{"internalType":"uint256","name":"lastRate","type":"uint256"},{"internalType":"uint256","name":"lastUpdated","type":"uint256"},{"internalType":"uint256","name":"newIndex","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address[]","name":"collaterals","type":"address[]"}],"name":"hasAllCollaterals","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"collateral","type":"address"}],"name":"hasCollateral","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"synth","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"incrementLongs","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"synth","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"incrementShorts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"isSynthManaged","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"synth","type":"bytes32"}],"name":"long","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"collaterals","type":"address[]"}],"name":"removeCollaterals","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[]","name":"synths","type":"bytes32[]"}],"name":"removeShortableSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[]","name":"synths","type":"bytes32[]"},{"internalType":"bytes32[]","name":"synthKeys","type":"bytes32[]"}],"name":"removeSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"resolver","outputs":[{"internalType":"contract AddressResolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"resolverAddressesRequired","outputs":[{"internalType":"bytes32[]","name":"addresses","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_baseBorrowRate","type":"uint256"}],"name":"setBaseBorrowRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_baseShortRate","type":"uint256"}],"name":"setBaseShortRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_maxDebt","type":"uint256"}],"name":"setMaxDebt","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_utilisationMultiplier","type":"uint256"}],"name":"setUtilisationMultiplier","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"synth","type":"bytes32"}],"name":"short","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"state","outputs":[{"internalType":"contract CollateralManagerState","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"synthToInverseSynth","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"synthsByKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalLong","outputs":[{"internalType":"uint256","name":"susdValue","type":"uint256"},{"internalType":"bool","name":"anyRateIsInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalShort","outputs":[{"internalType":"uint256","name":"susdValue","type":"uint256"},{"internalType":"bool","name":"anyRateIsInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"rate","type":"uint256"}],"name":"updateBorrowRates","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"uint256","name":"rate","type":"uint256"}],"name":"updateShortRates","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"utilisationMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]

670de0b6b3a7640000600e5560c06040526524b9b9bab2b960d11b60809081526c45786368616e6765526174657360981b60a052620000439060129060026200030a565b503480156200005157600080fd5b5060405162003c7838038062003c7883398101604081905262000074916200039a565b83856001600160a01b038116620000a85760405162461bcd60e51b81526004016200009f90620005a9565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000f59184906200054d565b60405180910390a1506000546001600160a01b0316620001295760405162461bcd60e51b81526004016200009f9062000597565b60038054610100600160a81b0319166101006001600160a01b039384160217905560008054336001600160a01b031991821617909155600580549091169188169190911790556200017a83620001cf565b6200018e826001600160e01b036200024716565b620001a2816001600160e01b036200029116565b5050600080546001600160a01b0319166001600160a01b0394909416939093179092555062000637915050565b620001e26001600160e01b03620002db16565b60008111620002055760405162461bcd60e51b81526004016200009f9062000573565b600f8190556040517f3620cc91bd75c6d3d752b529a1b98b38789dd2b81a13ece55801abc83531a77f906200023c908390620005bb565b60405180910390a150565b6200025a6001600160e01b03620002db16565b60108190556040517f08f9599493340b8255c7698bded59e30079641f4a9531613ec02055739247004906200023c908390620005bb565b620002a46001600160e01b03620002db16565b60118190556040517fe2695216766f2a627e90e17041ac2f085fd60ea503345b039f815c69bcbcccc9906200023c908390620005bb565b6000546001600160a01b03163314620003085760405162461bcd60e51b81526004016200009f9062000585565b565b82601881019282156200033b579160200282015b828111156200033b5782518255916020019190600101906200031e565b50620003499291506200034d565b5090565b6200036a91905b8082111562000349576000815560010162000354565b90565b80516200037a8162000607565b92915050565b80516200037a8162000621565b80516200037a816200062c565b60008060008060008060c08789031215620003b457600080fd5b6000620003c2898962000380565b9650506020620003d589828a016200036d565b9550506040620003e889828a016200036d565b9450506060620003fb89828a016200038d565b93505060806200040e89828a016200038d565b92505060a06200042189828a016200038d565b9150509295509295509295565b6200043981620005fa565b82525050565b6200043981620005d4565b600062000459601683620005cb565b7f4d7573742062652067726561746572207468616e203000000000000000000000815260200192915050565b600062000494602f83620005cb565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b6000620004e7601183620005cb565b7013dddb995c881b5d5cdd081899481cd95d607a1b815260200192915050565b600062000516601983620005cb565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b62000439816200036a565b604081016200055d82856200042e565b6200056c60208301846200043f565b9392505050565b602080825281016200037a816200044a565b602080825281016200037a8162000485565b602080825281016200037a81620004d8565b602080825281016200037a8162000507565b602081016200037a828462000542565b90815260200190565b60006200037a82620005ee565b60006200037a82620005d4565b6001600160a01b031690565b60006200037a82620005e1565b6200061281620005d4565b81146200061e57600080fd5b50565b6200061281620005e1565b62000612816200036a565b61363180620006476000396000f3fe608060405234801561001057600080fd5b50600436106102d65760003560e01c806391b4ded911610182578063c88b412e116100e9578063e32261fe116100a2578063ee81f7901161007c578063ee81f790146105ec578063f0e740c3146105ff578063f53037b614610612578063ffa749cd14610625576102d6565b8063e32261fe146105b3578063e50a31b3146105c6578063eb94bbde146105d9576102d6565b8063c88b412e14610557578063c9e180151461056a578063ca969f2314610572578063d0064c0014610585578063d2f004751461058d578063e31f27c1146105a0576102d6565b8063b3b467321161013b578063b3b4673214610503578063b4d6cb401461050b578063ba1c5e801461052c578063bbb601cd14610534578063bf38668214610547578063c19d93fb1461054f576102d6565b806391b4ded9146104a757806393a72fbe146104af5780639f7eac37146104c2578063ad79a858146104d5578063af07aa9d146104dd578063b38988f7146104f0576102d6565b806353a47bb71161024157806374185360116101fa5780638471db13116101d45780638471db1314610464578063899ffef4146104775780638b173e811461048c5780638da5cb5b1461049f576102d6565b80637418536014610441578063744d646e1461044957806379ba50971461045c576102d6565b806353a47bb7146103e35780635c975abb146103f8578063614d08f8146104005780636526941b14610408578063710388d11461041b57806372e18b6a1461042e576102d6565b806323d60e2e1161029357806323d60e2e1461036d57806324620639146103805780632af64bd31461039357806338245377146103a85780634db7764c146103c85780635246f2b9146103d0576102d6565b806303f048b0146102db57806304f3bcec146103075780630c9c81a11461031c5780631627540c1461033157806316c38b3c146103445780631e33fc6b14610357575b600080fd5b6102ee6102e9366004612e42565b610638565b6040516102fe94939291906134d2565b60405180910390f35b61030f6106cf565b6040516102fe9190613413565b61032f61032a366004612e42565b6106e3565b005b61032f61033f366004612caa565b61072b565b61032f610352366004612e06565b61077e565b61035f6107f3565b6040516102fe9291906133a2565b61032f61037b366004612dcd565b610ae6565b61032f61038e366004612e7e565b610bc0565b61039b610c5c565b6040516102fe919061335d565b6103bb6103b6366004612e42565b610d79565b6040516102fe9190613386565b6103bb610d8b565b61032f6103de366004612e7e565b610d91565b6103eb610ded565b6040516102fe9190613323565b61039b610dfc565b6103bb610e05565b61032f610416366004612e42565b610e1d565b61032f610429366004612dcd565b610e7a565b61039b61043c366004612dcd565b610f42565b61032f610fdc565b61039b610457366004612d28565b611132565b61032f61117c565b61039b610472366004612e42565b611218565b61047f61122c565b6040516102fe919061334c565b61032f61049a366004612e42565b6113e4565b6103eb611421565b6103bb611430565b61039b6104bd366004612dcd565b611436565b61032f6104d0366004612e42565b611581565b61035f6115ae565b6102ee6104eb366004612e7e565b61178f565b61039b6104fe366004612caa565b61182a565b6103bb611843565b61051e610519366004612e7e565b6118fc565b6040516102fe92919061336b565b61035f6119ef565b61032f610542366004612ce6565b611b12565b6103bb611bf2565b61030f611bf8565b61032f610565366004612d5d565b611c07565b6103bb611d82565b61032f610580366004612ce6565b611d88565b6103bb611f58565b6103bb61059b366004612e42565b611f5e565b61032f6105ae366004612e7e565b611fdf565b6103bb6105c1366004612e42565b61203b565b61032f6105d4366004612e7e565b61206c565b61032f6105e7366004612e7e565b6120c8565b61035f6105fa366004612e42565b612124565b6103bb61060d366004612e42565b61243e565b61032f610620366004612e42565b612450565b61032f610633366004612ce6565b6124e0565b600554604051623f048b60e41b81526000918291829182916001600160a01b03909116906303f048b090610670908890600401613386565b60806040518083038186803b15801561068857600080fd5b505afa15801561069c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106c09190810190612ee8565b92989197509550909350915050565b60035461010090046001600160a01b031681565b6106eb612599565b60108190556040517f08f9599493340b8255c7698bded59e30079641f4a9531613ec0205573924700490610720908390613386565b60405180910390a150565b610733612599565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610720908390613323565b610786612599565b60035460ff161515811515141561079c576107f0565b6003805460ff1916821515179081905560ff16156107b957426002555b6003546040517f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5916107209160ff9091169061335d565b50565b6008805460408051602080840282018101909252828152600093849360609383018282801561084157602002820191906000526020600020905b81548152602001906001019080831161082d575b50505050509050600081511115610ae15760005b8151811015610adf57600061087c83838151811061086f57fe5b60200260200101516125c5565b6001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b1580156108b457600080fd5b505afa1580156108c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108ec9190810190612e60565b9050631cd554d160e21b8114156109935760055460405163d2f0047560e01b815261098c916001600160a01b03169063d2f004759061092f908590600401613386565b60206040518083038186803b15801561094757600080fd5b505afa15801561095b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061097f9190810190612e60565b869063ffffffff6125d016565b9450610ad6565b60008061099e6125fc565b6001600160a01b0316630c71cd23846040518263ffffffff1660e01b81526004016109c99190613386565b604080518083038186803b1580156109e057600080fd5b505afa1580156109f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a189190810190612eb8565b60055460405163d2f0047560e01b8152929450909250600091610ab39185916001600160a01b039091169063d2f0047590610a57908990600401613386565b60206040518083038186803b158015610a6f57600080fd5b505afa158015610a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610aa79190810190612e60565b9063ffffffff61261c16565b9050610ac5888263ffffffff6125d016565b97508115610ad257600196505b5050505b50600101610855565b505b509091565b610aee612599565b60005b83811015610bb957610b1f858583818110610b0857fe5b90506020020135600861264690919063ffffffff16565b610bb1576000858583818110610b3157fe5b905060200201359050610b4e81600861269690919063ffffffff16565b80600a6000868686818110610b5f57fe5b905060200201358152602001908152602001600020819055507f87f8a613724bd8be7a9139e4c83bc8d58fedee7206e2d7077849f5988d78759981604051610ba79190613386565b60405180910390a1505b600101610af1565b5050505050565b6000610bcb3361182a565b905080610bf35760405162461bcd60e51b8152600401610bea906134c2565b60405180910390fd5b600554604051632462063960e01b81526001600160a01b0390911690632462063990610c2590869086906004016133d0565b600060405180830381600087803b158015610c3f57600080fd5b505af1158015610c53573d6000803e3d6000fd5b50505050505050565b60006060610c6861122c565b905060005b8151811015610d6f576000828281518110610c8457fe5b60209081029190910181015160008181526004928390526040908190205460035491516321f8a72160e01b81529294506001600160a01b039081169361010090920416916321f8a72191610cda91869101613386565b60206040518083038186803b158015610cf257600080fd5b505afa158015610d06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d2a9190810190612cc8565b6001600160a01b0316141580610d5557506000818152600460205260409020546001600160a01b0316155b15610d665760009350505050610d76565b50600101610c6d565b5060019150505b90565b600a6020526000908152604090205481565b60115481565b6000610d9c3361182a565b905080610dbb5760405162461bcd60e51b8152600401610bea906134c2565b600554604051635246f2b960e01b81526001600160a01b0390911690635246f2b990610c2590869086906004016133d0565b6001546001600160a01b031681565b60035460ff1681565b7021b7b63630ba32b930b626b0b730b3b2b960791b81565b610e25612599565b60008111610e455760405162461bcd60e51b8152600401610bea90613492565b600f8190556040517f3620cc91bd75c6d3d752b529a1b98b38789dd2b81a13ece55801abc83531a77f90610720908390613386565b610e82612599565b60005b83811015610bb957610e9c858583818110610b0857fe5b15610f3a57610ec7858583818110610eb057fe5b9050602002013560086126ce90919063ffffffff16565b600a6000848484818110610ed757fe5b905060200201358152602001908152602001600020600090557f788aff97f65e6ddeee9246c47d08b819813066c87876a912c79baddffb138f0a858583818110610f1d57fe5b90506020020135604051610f319190613386565b60405180910390a15b600101610e85565b6008546000908414610f5657506000610fd4565b60005b84811015610fce57610f70868683818110610b0857fe5b610f7e576000915050610fd4565b858582818110610f8a57fe5b90506020020135600a6000868685818110610fa157fe5b9050602002013581526020019081526020016000205414610fc6576000915050610fd4565b600101610f59565b50600190505b949350505050565b6060610fe661122c565b905060005b815181101561112e57600082828151811061100257fe5b602002602001015190506000600360019054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016110449190613318565b6040516020818303038152906040526040518363ffffffff1660e01b81526004016110709291906133b0565b60206040518083038186803b15801561108857600080fd5b505afa15801561109c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110c09190810190612cc8565b6000838152600460205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa689061111c9084908490613394565b60405180910390a15050600101610feb565b5050565b6000805b82518110156111715761115b83828151811061114e57fe5b602002602001015161182a565b611169576000915050611177565b600101611136565b50600190505b919050565b6001546001600160a01b031633146111a65760405162461bcd60e51b8152600401610bea90613442565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c926111e9926001600160a01b0391821692911690613331565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000908152600a6020526040902054151590565b6040805160028082526060808301845292839291906020830190803883390190505090506524b9b9bab2b960d11b8160008151811061126757fe5b6020026020010181815250506c45786368616e6765526174657360981b8160018151811061129157fe5b6020908102919091010152600b54606090801561136557806002026040519080825280602002602001820160405280156112d5578160200160208202803883390190505b50915060005b8181101561136357600b8054829081106112f157fe5b906000526020600020015483828151811061130857fe5b602002602001018181525050600d6000600b600001838154811061132857fe5b9060005260206000200154815260200190815260200160002054838383018151811061135057fe5b60209081029190910101526001016112db565b505b60088054604080516020808402820181019092528281526060936113be9387938301828280156113b457602002820191906000526020600020905b8154815260200190600101908083116113a0575b50505050506127a2565b8051909150156113d9576113d281856127a2565b94506113dd565b8394505b5050505090565b6113ec612599565b60118190556040517fe2695216766f2a627e90e17041ac2f085fd60ea503345b039f815c69bcbcccc990610720908390613386565b6000546001600160a01b031681565b60025481565b60008382146114575760405162461bcd60e51b8152600401610bea90613432565b600b54841461146857506000610fd4565b60005b848110156114cf57600086868381811061148157fe5b90506020020135905061149e81600b61264690919063ffffffff16565b15806114b657506000818152600d6020526040902054155b156114c657600092505050610fd4565b5060010161146b565b5060005b82811015610fce576005546001600160a01b031663a0356f6e8585848181106114f857fe5b905060200201356040518263ffffffff1660e01b815260040161151b9190613386565b60206040518083038186803b15801561153357600080fd5b505afa158015611547573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061156b9190810190612e60565b611579576000915050610fd4565b6001016114d3565b611589612599565b600081116115a95760405162461bcd60e51b8152600401610bea90613492565b600e55565b600b80546040805160208084028201810190925282815260009384936060938301828280156115fc57602002820191906000526020600020905b8154815260200190600101908083116115e8575b50505050509050600081511115610ae15760005b8151811015610adf57600061162a83838151811061086f57fe5b6001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b15801561166257600080fd5b505afa158015611676573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061169a9190810190612e60565b90506000806116a76125fc565b6001600160a01b0316630c71cd23846040518263ffffffff1660e01b81526004016116d29190613386565b604080518083038186803b1580156116e957600080fd5b505afa1580156116fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117219190810190612eb8565b60055460405163719130ff60e11b81529294509092506000916117609185916001600160a01b039091169063e32261fe90610a57908990600401613386565b9050611772888263ffffffff6125d016565b9750811561177f57600196505b5050600190920191506116109050565b60055460405163af07aa9d60e01b81526000918291829182916001600160a01b039091169063af07aa9d906117ca90899089906004016133d0565b60806040518083038186803b1580156117e257600080fd5b505afa1580156117f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061181a9190810190612ee8565b9299919850965090945092505050565b600061183d60068363ffffffff61285e16565b92915050565b60008061184f3361182a565b90508061186e5760405162461bcd60e51b8152600401610bea906134c2565b600560009054906101000a90046001600160a01b03166001600160a01b0316638c5825036040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156118be57600080fd5b505af11580156118d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118f69190810190612e60565b91505090565b60008060006119096125fc565b6001600160a01b031663654a60ac8587631cd554d160e21b6040518463ffffffff1660e01b815260040161193f939291906133eb565b60206040518083038186803b15801561195757600080fd5b505afa15801561196b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061198f9190810190612e60565b905060008061199c6107f3565b915091506000806119ab6115ae565b9150915082806119b85750805b600f549096506119de866119d2878663ffffffff6125d016565b9063ffffffff6125d016565b1115965050505050505b9250929050565b60008060006119fc6128cb565b6001600160a01b0316637b1001b7631cd554d160e21b60016040518363ffffffff1660e01b8152600401611a319291906133a2565b60206040518083038186803b158015611a4957600080fd5b505afa158015611a5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a819190810190612e60565b9050600080611a8e6107f3565b90925090506000611aa5848463ffffffff6125d016565b90506000611ad46a1a1a7062e5185d7e380000611ac8868563ffffffff6128df16565b9063ffffffff6128df16565b90506000611aed600e548361261c90919063ffffffff16565b9050611b04601054826125d090919063ffffffff16565b989397509295505050505050565b611b1a612599565b60005b81811015611bed57611b57838383818110611b3457fe5b9050602002016020611b499190810190612caa565b60069063ffffffff61285e16565b611be557611b8d838383818110611b6a57fe5b9050602002016020611b7f9190810190612caa565b60069063ffffffff61290916565b7f7db05e63d635a68c62fd7fd8f3107ae8ab584a383e102d1bd8a40f4c977e465f838383818110611bba57fe5b9050602002016020611bcf9190810190612caa565b604051611bdc9190613323565b60405180910390a15b600101611b1d565b505050565b60105481565b6005546001600160a01b031681565b611c0f612599565b828114611c2e5760405162461bcd60e51b8152600401610bea90613432565b60005b83811015611d73576000858583818110611c4757fe5b905060400201600060028110611c5957fe5b602002013590506000868684818110611c6e57fe5b905060400201600160028110611c8057fe5b60200201359050611c98600b8363ffffffff61264616565b611d6957611cad600b8363ffffffff61269616565b6000828152600d602052604090819020829055517fa71e21d8a72d99830e0d382f042d37e6a20c8a33ec3185affcaf6586e9a0187a90611cee908490613386565b60405180910390a16005546001600160a01b031663ed039154868686818110611d1357fe5b905060200201356040518263ffffffff1660e01b8152600401611d369190613386565b600060405180830381600087803b158015611d5057600080fd5b505af1158015611d64573d6000803e3d6000fd5b505050505b5050600101611c31565b50611d7c610fdc565b50505050565b600e5481565b611d90612599565b60005b81811015611bed57611dc1838383818110611daa57fe5b90506020020135600b61264690919063ffffffff16565b15611f5057611dec838383818110611dd557fe5b90506020020135600b6126ce90919063ffffffff16565b6000611e09848484818110611dfd57fe5b905060200201356125c5565b6001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b158015611e4157600080fd5b505afa158015611e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611e799190810190612e60565b600554604051636431e0bd60e01b81529192506001600160a01b031690636431e0bd90611eaa908490600401613386565b600060405180830381600087803b158015611ec457600080fd5b505af1158015611ed8573d6000803e3d6000fd5b50505050600d6000858585818110611eec57fe5b905060200201358152602001908152602001600020600090557f23caa21d7c1015aa7051e1ae4a09f99de36dab4545dfec5f4dde3a54173a123b848484818110611f3257fe5b90506020020135604051611f469190613386565b60405180910390a1505b600101611d93565b600f5481565b60055460405163d2f0047560e01b81526000916001600160a01b03169063d2f0047590611f8f908590600401613386565b60206040518083038186803b158015611fa757600080fd5b505afa158015611fbb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061183d9190810190612e60565b6000611fea3361182a565b9050806120095760405162461bcd60e51b8152600401610bea906134c2565b60055460405163e31f27c160e01b81526001600160a01b039091169063e31f27c190610c2590869086906004016133d0565b60055460405163719130ff60e11b81526000916001600160a01b03169063e32261fe90611f8f908590600401613386565b60006120773361182a565b9050806120965760405162461bcd60e51b8152600401610bea906134c2565b60055460405163e50a31b360e01b81526001600160a01b039091169063e50a31b390610c2590869086906004016133d0565b60006120d33361182a565b9050806120f25760405162461bcd60e51b8152600401610bea906134c2565b6005546040516375ca5def60e11b81526001600160a01b039091169063eb94bbde90610c2590869086906004016133d0565b6000806000612132846125c5565b6001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b15801561216a57600080fd5b505afa15801561217e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506121a29190810190612e60565b90506121ac6125fc565b6001600160a01b0316632528f0fe826040518263ffffffff1660e01b81526004016121d79190613386565b60206040518083038186803b1580156121ef57600080fd5b505afa158015612203573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506122279190810190612e24565b91506000612234856125c5565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561226c57600080fd5b505afa158015612280573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506122a49190810190612e60565b6000868152600d6020526040812054919250906122c0906125c5565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156122f857600080fd5b505afa15801561230c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506123309190810190612e60565b60055460405163719130ff60e11b81529192506000916123bc9184916001600160a01b039091169063e32261fe9061236c908990600401613386565b60206040518083038186803b15801561238457600080fd5b505afa158015612398573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506119d29190810190612e60565b9050808311156123d457506000945061243992505050565b60006123e6828563ffffffff61295b16565b905060006124196a1a1a7062e5185d7e380000611ac861240c888763ffffffff6125d016565b859063ffffffff6128df16565b9050612430601154826125d090919063ffffffff16565b97505050505050505b915091565b600d6020526000908152604090205481565b600061245b3361182a565b90508061247a5760405162461bcd60e51b8152600401610bea906134c2565b600554604051637a981bdb60e11b81526001600160a01b039091169063f53037b6906124aa908590600401613386565b600060405180830381600087803b1580156124c457600080fd5b505af11580156124d8573d6000803e3d6000fd5b505050505050565b6124e8612599565b60005b81811015611bed57612502838383818110611b3457fe5b156125915761253983838381811061251657fe5b905060200201602061252b9190810190612caa565b60069063ffffffff61298316565b7fd89d2ee68ab04dca0193f48a4aff55e20fa5ec0429a8a8c1c51b8dad6178a59383838381811061256657fe5b905060200201602061257b9190810190612caa565b6040516125889190613323565b60405180910390a15b6001016124eb565b6000546001600160a01b031633146125c35760405162461bcd60e51b8152600401610bea906134a2565b565b600061183d82612a99565b6000828201838110156125f55760405162461bcd60e51b8152600401610bea90613452565b9392505050565b60006126176c45786368616e6765526174657360981b612a99565b905090565b6000670de0b6b3a7640000612637848463ffffffff612af616565b8161263e57fe5b049392505050565b81546000906126575750600061183d565b600082815260018401602052604090205480151580610fd45750828460000160008154811061268257fe5b906000526020600020015414949350505050565b6126a08282612646565b61112e5781546000828152600180850160209081526040832084905590830185558482529020018190555050565b6126d88282612646565b6126f45760405162461bcd60e51b8152600401610bea90613462565b600081815260018301602052604090205482546000190180821461276257600084600001828154811061272357fe5b906000526020600020015490508085600001848154811061274057fe5b6000918252602080832090910192909255918252600186019052604090208290555b835484908061276d57fe5b600190038181906000526020600020016000905590558360010160008481526020019081526020016000206000905550505050565b606081518351016040519080825280602002602001820160405280156127d2578160200160208202803883390190505b50905060005b8351811015612814578381815181106127ed57fe5b602002602001015182828151811061280157fe5b60209081029190910101526001016127d8565b5060005b82518110156128575782818151811061282d57fe5b602002602001015182828651018151811061284457fe5b6020908102919091010152600101612818565b5092915050565b815460009061286f5750600061183d565b6001600160a01b038216600090815260018401602052604090205480151580610fd45750826001600160a01b0316846000016000815481106128ad57fe5b6000918252602090912001546001600160a01b031614949350505050565b60006126176524b9b9bab2b960d11b612a99565b60006125f5826128fd85670de0b6b3a764000063ffffffff612af616565b9063ffffffff612b3016565b612913828261285e565b61112e5781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b60008282111561297d5760405162461bcd60e51b8152600401610bea90613472565b50900390565b61298d828261285e565b6129a95760405162461bcd60e51b8152600401610bea90613462565b6001600160a01b0381166000908152600183016020526040902054825460001901808214612a485760008460000182815481106129e257fe5b60009182526020909120015485546001600160a01b0390911691508190869085908110612a0b57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080612a5357fe5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b60008181526004602090815260408083205490516001600160a01b039091169182151591612ac9918691016132f8565b604051602081830303815290604052906128575760405162461bcd60e51b8152600401610bea9190613421565b600082612b055750600061183d565b82820282848281612b1257fe5b04146125f55760405162461bcd60e51b8152600401610bea906134b2565b6000808211612b515760405162461bcd60e51b8152600401610bea90613482565b6000828481612b5c57fe5b04949350505050565b803561183d816135c8565b805161183d816135c8565b60008083601f840112612b8d57600080fd5b50813567ffffffffffffffff811115612ba557600080fd5b6020830191508360208202830111156119e857600080fd5b600082601f830112612bce57600080fd5b8135612be1612bdc82613537565b613510565b91508181835260208401935060208101905083856020840282011115612c0657600080fd5b60005b83811015612c325781612c1c8882612b65565b8452506020928301929190910190600101612c09565b5050505092915050565b60008083601f840112612c4e57600080fd5b50813567ffffffffffffffff811115612c6657600080fd5b6020830191508360408202830111156119e857600080fd5b803561183d816135dc565b805161183d816135dc565b803561183d816135e5565b805161183d816135e5565b600060208284031215612cbc57600080fd5b6000610fd48484612b65565b600060208284031215612cda57600080fd5b6000610fd48484612b70565b60008060208385031215612cf957600080fd5b823567ffffffffffffffff811115612d1057600080fd5b612d1c85828601612b7b565b92509250509250929050565b600060208284031215612d3a57600080fd5b813567ffffffffffffffff811115612d5157600080fd5b610fd484828501612bbd565b60008060008060408587031215612d7357600080fd5b843567ffffffffffffffff811115612d8a57600080fd5b612d9687828801612c3c565b9450945050602085013567ffffffffffffffff811115612db557600080fd5b612dc187828801612b7b565b95989497509550505050565b60008060008060408587031215612de357600080fd5b843567ffffffffffffffff811115612dfa57600080fd5b612d9687828801612b7b565b600060208284031215612e1857600080fd5b6000610fd48484612c7e565b600060208284031215612e3657600080fd5b6000610fd48484612c89565b600060208284031215612e5457600080fd5b6000610fd48484612c94565b600060208284031215612e7257600080fd5b6000610fd48484612c9f565b60008060408385031215612e9157600080fd5b6000612e9d8585612c94565b9250506020612eae85828601612c94565b9150509250929050565b60008060408385031215612ecb57600080fd5b6000612ed78585612c9f565b9250506020612eae85828601612c89565b60008060008060808587031215612efe57600080fd5b6000612f0a8787612c9f565b9450506020612f1b87828801612c9f565b9350506040612f2c87828801612c9f565b9250506060612f3d87828801612c9f565b91505092959194509250565b6000612f558383612fce565b505060200190565b612f668161356b565b82525050565b6000612f778261355e565b612f818185613562565b9350612f8c83613558565b8060005b83811015612fba578151612fa48882612f49565b9750612faf83613558565b925050600101612f90565b509495945050505050565b612f6681613576565b612f6681610d76565b612f66612fe382610d76565b610d76565b612f6681613587565b6000612ffc8261355e565b6130068185613562565b9350613016818560208601613592565b61301f816135be565b9093019392505050565b6000613036601b83613562565b7f496e707574206172726179206c656e677468206d69736d617463680000000000815260200192915050565b600061306f603583613562565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b60006130c6601b83613562565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b60006130ff601383613562565b7222b632b6b2b73a103737ba1034b71039b2ba1760691b815260200192915050565b600061312e601e83613562565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b6000613167601a83613562565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006131a0601183611177565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006131cd601683613562565b7504d7573742062652067726561746572207468616e20360541b815260200192915050565b60006131ff602f83613562565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b6000613250602183613562565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000613293601983613562565b7f4f6e6c7920636f6c6c61746572616c20636f6e74726163747300000000000000815260200192915050565b60006132cc601983611177565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b600061330382613193565b915061330f8284612fd7565b50602001919050565b6000613303826132bf565b6020810161183d8284612f5d565b6040810161333f8285612f5d565b6125f56020830184612f5d565b602080825281016125f58184612f6c565b6020810161183d8284612fc5565b604081016133798285612fc5565b6125f56020830184612fc5565b6020810161183d8284612fce565b6040810161333f8285612fce565b604081016133798285612fce565b604081016133be8285612fce565b8181036020830152610fd48184612ff1565b604081016133de8285612fce565b6125f56020830184612fce565b606081016133f98286612fce565b6134066020830185612fce565b610fd46040830184612fce565b6020810161183d8284612fe8565b602080825281016125f58184612ff1565b6020808252810161183d81613029565b6020808252810161183d81613062565b6020808252810161183d816130b9565b6020808252810161183d816130f2565b6020808252810161183d81613121565b6020808252810161183d8161315a565b6020808252810161183d816131c0565b6020808252810161183d816131f2565b6020808252810161183d81613243565b6020808252810161183d81613286565b608081016134e08287612fce565b6134ed6020830186612fce565b6134fa6040830185612fce565b6135076060830184612fce565b95945050505050565b60405181810167ffffffffffffffff8111828210171561352f57600080fd5b604052919050565b600067ffffffffffffffff82111561354e57600080fd5b5060209081020190565b60200190565b5190565b90815260200190565b600061183d8261357b565b151590565b6001600160a01b031690565b600061183d8261356b565b60005b838110156135ad578181015183820152602001613595565b83811115611d7c5750506000910152565b601f01601f191690565b6135d18161356b565b81146107f057600080fd5b6135d181613576565b6135d181610d7656fea365627a7a7231582086139b15c2c894f5f985b303fdd27b70745c143d7fad10f0c56a854fc078a7af6c6578706572696d656e74616cf564736f6c63430005100040000000000000000000000000573e5105c4b92416d1544a188f1bf77d442bb52d000000000000000000000000de910777c787903f78c89e7a0bf7f4c435cbb1fe0000000000000000000000004e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef200000000000000000000000000000000000000000052b7d2dcc80cd2e4000000000000000000000000000000000000000000000000000000000000000971a92f000000000000000000000000000000000000000000000000000000000971a92f

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102d65760003560e01c806391b4ded911610182578063c88b412e116100e9578063e32261fe116100a2578063ee81f7901161007c578063ee81f790146105ec578063f0e740c3146105ff578063f53037b614610612578063ffa749cd14610625576102d6565b8063e32261fe146105b3578063e50a31b3146105c6578063eb94bbde146105d9576102d6565b8063c88b412e14610557578063c9e180151461056a578063ca969f2314610572578063d0064c0014610585578063d2f004751461058d578063e31f27c1146105a0576102d6565b8063b3b467321161013b578063b3b4673214610503578063b4d6cb401461050b578063ba1c5e801461052c578063bbb601cd14610534578063bf38668214610547578063c19d93fb1461054f576102d6565b806391b4ded9146104a757806393a72fbe146104af5780639f7eac37146104c2578063ad79a858146104d5578063af07aa9d146104dd578063b38988f7146104f0576102d6565b806353a47bb71161024157806374185360116101fa5780638471db13116101d45780638471db1314610464578063899ffef4146104775780638b173e811461048c5780638da5cb5b1461049f576102d6565b80637418536014610441578063744d646e1461044957806379ba50971461045c576102d6565b806353a47bb7146103e35780635c975abb146103f8578063614d08f8146104005780636526941b14610408578063710388d11461041b57806372e18b6a1461042e576102d6565b806323d60e2e1161029357806323d60e2e1461036d57806324620639146103805780632af64bd31461039357806338245377146103a85780634db7764c146103c85780635246f2b9146103d0576102d6565b806303f048b0146102db57806304f3bcec146103075780630c9c81a11461031c5780631627540c1461033157806316c38b3c146103445780631e33fc6b14610357575b600080fd5b6102ee6102e9366004612e42565b610638565b6040516102fe94939291906134d2565b60405180910390f35b61030f6106cf565b6040516102fe9190613413565b61032f61032a366004612e42565b6106e3565b005b61032f61033f366004612caa565b61072b565b61032f610352366004612e06565b61077e565b61035f6107f3565b6040516102fe9291906133a2565b61032f61037b366004612dcd565b610ae6565b61032f61038e366004612e7e565b610bc0565b61039b610c5c565b6040516102fe919061335d565b6103bb6103b6366004612e42565b610d79565b6040516102fe9190613386565b6103bb610d8b565b61032f6103de366004612e7e565b610d91565b6103eb610ded565b6040516102fe9190613323565b61039b610dfc565b6103bb610e05565b61032f610416366004612e42565b610e1d565b61032f610429366004612dcd565b610e7a565b61039b61043c366004612dcd565b610f42565b61032f610fdc565b61039b610457366004612d28565b611132565b61032f61117c565b61039b610472366004612e42565b611218565b61047f61122c565b6040516102fe919061334c565b61032f61049a366004612e42565b6113e4565b6103eb611421565b6103bb611430565b61039b6104bd366004612dcd565b611436565b61032f6104d0366004612e42565b611581565b61035f6115ae565b6102ee6104eb366004612e7e565b61178f565b61039b6104fe366004612caa565b61182a565b6103bb611843565b61051e610519366004612e7e565b6118fc565b6040516102fe92919061336b565b61035f6119ef565b61032f610542366004612ce6565b611b12565b6103bb611bf2565b61030f611bf8565b61032f610565366004612d5d565b611c07565b6103bb611d82565b61032f610580366004612ce6565b611d88565b6103bb611f58565b6103bb61059b366004612e42565b611f5e565b61032f6105ae366004612e7e565b611fdf565b6103bb6105c1366004612e42565b61203b565b61032f6105d4366004612e7e565b61206c565b61032f6105e7366004612e7e565b6120c8565b61035f6105fa366004612e42565b612124565b6103bb61060d366004612e42565b61243e565b61032f610620366004612e42565b612450565b61032f610633366004612ce6565b6124e0565b600554604051623f048b60e41b81526000918291829182916001600160a01b03909116906303f048b090610670908890600401613386565b60806040518083038186803b15801561068857600080fd5b505afa15801561069c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106c09190810190612ee8565b92989197509550909350915050565b60035461010090046001600160a01b031681565b6106eb612599565b60108190556040517f08f9599493340b8255c7698bded59e30079641f4a9531613ec0205573924700490610720908390613386565b60405180910390a150565b610733612599565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610720908390613323565b610786612599565b60035460ff161515811515141561079c576107f0565b6003805460ff1916821515179081905560ff16156107b957426002555b6003546040517f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5916107209160ff9091169061335d565b50565b6008805460408051602080840282018101909252828152600093849360609383018282801561084157602002820191906000526020600020905b81548152602001906001019080831161082d575b50505050509050600081511115610ae15760005b8151811015610adf57600061087c83838151811061086f57fe5b60200260200101516125c5565b6001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b1580156108b457600080fd5b505afa1580156108c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108ec9190810190612e60565b9050631cd554d160e21b8114156109935760055460405163d2f0047560e01b815261098c916001600160a01b03169063d2f004759061092f908590600401613386565b60206040518083038186803b15801561094757600080fd5b505afa15801561095b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061097f9190810190612e60565b869063ffffffff6125d016565b9450610ad6565b60008061099e6125fc565b6001600160a01b0316630c71cd23846040518263ffffffff1660e01b81526004016109c99190613386565b604080518083038186803b1580156109e057600080fd5b505afa1580156109f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a189190810190612eb8565b60055460405163d2f0047560e01b8152929450909250600091610ab39185916001600160a01b039091169063d2f0047590610a57908990600401613386565b60206040518083038186803b158015610a6f57600080fd5b505afa158015610a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610aa79190810190612e60565b9063ffffffff61261c16565b9050610ac5888263ffffffff6125d016565b97508115610ad257600196505b5050505b50600101610855565b505b509091565b610aee612599565b60005b83811015610bb957610b1f858583818110610b0857fe5b90506020020135600861264690919063ffffffff16565b610bb1576000858583818110610b3157fe5b905060200201359050610b4e81600861269690919063ffffffff16565b80600a6000868686818110610b5f57fe5b905060200201358152602001908152602001600020819055507f87f8a613724bd8be7a9139e4c83bc8d58fedee7206e2d7077849f5988d78759981604051610ba79190613386565b60405180910390a1505b600101610af1565b5050505050565b6000610bcb3361182a565b905080610bf35760405162461bcd60e51b8152600401610bea906134c2565b60405180910390fd5b600554604051632462063960e01b81526001600160a01b0390911690632462063990610c2590869086906004016133d0565b600060405180830381600087803b158015610c3f57600080fd5b505af1158015610c53573d6000803e3d6000fd5b50505050505050565b60006060610c6861122c565b905060005b8151811015610d6f576000828281518110610c8457fe5b60209081029190910181015160008181526004928390526040908190205460035491516321f8a72160e01b81529294506001600160a01b039081169361010090920416916321f8a72191610cda91869101613386565b60206040518083038186803b158015610cf257600080fd5b505afa158015610d06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d2a9190810190612cc8565b6001600160a01b0316141580610d5557506000818152600460205260409020546001600160a01b0316155b15610d665760009350505050610d76565b50600101610c6d565b5060019150505b90565b600a6020526000908152604090205481565b60115481565b6000610d9c3361182a565b905080610dbb5760405162461bcd60e51b8152600401610bea906134c2565b600554604051635246f2b960e01b81526001600160a01b0390911690635246f2b990610c2590869086906004016133d0565b6001546001600160a01b031681565b60035460ff1681565b7021b7b63630ba32b930b626b0b730b3b2b960791b81565b610e25612599565b60008111610e455760405162461bcd60e51b8152600401610bea90613492565b600f8190556040517f3620cc91bd75c6d3d752b529a1b98b38789dd2b81a13ece55801abc83531a77f90610720908390613386565b610e82612599565b60005b83811015610bb957610e9c858583818110610b0857fe5b15610f3a57610ec7858583818110610eb057fe5b9050602002013560086126ce90919063ffffffff16565b600a6000848484818110610ed757fe5b905060200201358152602001908152602001600020600090557f788aff97f65e6ddeee9246c47d08b819813066c87876a912c79baddffb138f0a858583818110610f1d57fe5b90506020020135604051610f319190613386565b60405180910390a15b600101610e85565b6008546000908414610f5657506000610fd4565b60005b84811015610fce57610f70868683818110610b0857fe5b610f7e576000915050610fd4565b858582818110610f8a57fe5b90506020020135600a6000868685818110610fa157fe5b9050602002013581526020019081526020016000205414610fc6576000915050610fd4565b600101610f59565b50600190505b949350505050565b6060610fe661122c565b905060005b815181101561112e57600082828151811061100257fe5b602002602001015190506000600360019054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016110449190613318565b6040516020818303038152906040526040518363ffffffff1660e01b81526004016110709291906133b0565b60206040518083038186803b15801561108857600080fd5b505afa15801561109c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110c09190810190612cc8565b6000838152600460205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa689061111c9084908490613394565b60405180910390a15050600101610feb565b5050565b6000805b82518110156111715761115b83828151811061114e57fe5b602002602001015161182a565b611169576000915050611177565b600101611136565b50600190505b919050565b6001546001600160a01b031633146111a65760405162461bcd60e51b8152600401610bea90613442565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c926111e9926001600160a01b0391821692911690613331565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000908152600a6020526040902054151590565b6040805160028082526060808301845292839291906020830190803883390190505090506524b9b9bab2b960d11b8160008151811061126757fe5b6020026020010181815250506c45786368616e6765526174657360981b8160018151811061129157fe5b6020908102919091010152600b54606090801561136557806002026040519080825280602002602001820160405280156112d5578160200160208202803883390190505b50915060005b8181101561136357600b8054829081106112f157fe5b906000526020600020015483828151811061130857fe5b602002602001018181525050600d6000600b600001838154811061132857fe5b9060005260206000200154815260200190815260200160002054838383018151811061135057fe5b60209081029190910101526001016112db565b505b60088054604080516020808402820181019092528281526060936113be9387938301828280156113b457602002820191906000526020600020905b8154815260200190600101908083116113a0575b50505050506127a2565b8051909150156113d9576113d281856127a2565b94506113dd565b8394505b5050505090565b6113ec612599565b60118190556040517fe2695216766f2a627e90e17041ac2f085fd60ea503345b039f815c69bcbcccc990610720908390613386565b6000546001600160a01b031681565b60025481565b60008382146114575760405162461bcd60e51b8152600401610bea90613432565b600b54841461146857506000610fd4565b60005b848110156114cf57600086868381811061148157fe5b90506020020135905061149e81600b61264690919063ffffffff16565b15806114b657506000818152600d6020526040902054155b156114c657600092505050610fd4565b5060010161146b565b5060005b82811015610fce576005546001600160a01b031663a0356f6e8585848181106114f857fe5b905060200201356040518263ffffffff1660e01b815260040161151b9190613386565b60206040518083038186803b15801561153357600080fd5b505afa158015611547573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061156b9190810190612e60565b611579576000915050610fd4565b6001016114d3565b611589612599565b600081116115a95760405162461bcd60e51b8152600401610bea90613492565b600e55565b600b80546040805160208084028201810190925282815260009384936060938301828280156115fc57602002820191906000526020600020905b8154815260200190600101908083116115e8575b50505050509050600081511115610ae15760005b8151811015610adf57600061162a83838151811061086f57fe5b6001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b15801561166257600080fd5b505afa158015611676573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061169a9190810190612e60565b90506000806116a76125fc565b6001600160a01b0316630c71cd23846040518263ffffffff1660e01b81526004016116d29190613386565b604080518083038186803b1580156116e957600080fd5b505afa1580156116fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117219190810190612eb8565b60055460405163719130ff60e11b81529294509092506000916117609185916001600160a01b039091169063e32261fe90610a57908990600401613386565b9050611772888263ffffffff6125d016565b9750811561177f57600196505b5050600190920191506116109050565b60055460405163af07aa9d60e01b81526000918291829182916001600160a01b039091169063af07aa9d906117ca90899089906004016133d0565b60806040518083038186803b1580156117e257600080fd5b505afa1580156117f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061181a9190810190612ee8565b9299919850965090945092505050565b600061183d60068363ffffffff61285e16565b92915050565b60008061184f3361182a565b90508061186e5760405162461bcd60e51b8152600401610bea906134c2565b600560009054906101000a90046001600160a01b03166001600160a01b0316638c5825036040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156118be57600080fd5b505af11580156118d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118f69190810190612e60565b91505090565b60008060006119096125fc565b6001600160a01b031663654a60ac8587631cd554d160e21b6040518463ffffffff1660e01b815260040161193f939291906133eb565b60206040518083038186803b15801561195757600080fd5b505afa15801561196b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061198f9190810190612e60565b905060008061199c6107f3565b915091506000806119ab6115ae565b9150915082806119b85750805b600f549096506119de866119d2878663ffffffff6125d016565b9063ffffffff6125d016565b1115965050505050505b9250929050565b60008060006119fc6128cb565b6001600160a01b0316637b1001b7631cd554d160e21b60016040518363ffffffff1660e01b8152600401611a319291906133a2565b60206040518083038186803b158015611a4957600080fd5b505afa158015611a5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a819190810190612e60565b9050600080611a8e6107f3565b90925090506000611aa5848463ffffffff6125d016565b90506000611ad46a1a1a7062e5185d7e380000611ac8868563ffffffff6128df16565b9063ffffffff6128df16565b90506000611aed600e548361261c90919063ffffffff16565b9050611b04601054826125d090919063ffffffff16565b989397509295505050505050565b611b1a612599565b60005b81811015611bed57611b57838383818110611b3457fe5b9050602002016020611b499190810190612caa565b60069063ffffffff61285e16565b611be557611b8d838383818110611b6a57fe5b9050602002016020611b7f9190810190612caa565b60069063ffffffff61290916565b7f7db05e63d635a68c62fd7fd8f3107ae8ab584a383e102d1bd8a40f4c977e465f838383818110611bba57fe5b9050602002016020611bcf9190810190612caa565b604051611bdc9190613323565b60405180910390a15b600101611b1d565b505050565b60105481565b6005546001600160a01b031681565b611c0f612599565b828114611c2e5760405162461bcd60e51b8152600401610bea90613432565b60005b83811015611d73576000858583818110611c4757fe5b905060400201600060028110611c5957fe5b602002013590506000868684818110611c6e57fe5b905060400201600160028110611c8057fe5b60200201359050611c98600b8363ffffffff61264616565b611d6957611cad600b8363ffffffff61269616565b6000828152600d602052604090819020829055517fa71e21d8a72d99830e0d382f042d37e6a20c8a33ec3185affcaf6586e9a0187a90611cee908490613386565b60405180910390a16005546001600160a01b031663ed039154868686818110611d1357fe5b905060200201356040518263ffffffff1660e01b8152600401611d369190613386565b600060405180830381600087803b158015611d5057600080fd5b505af1158015611d64573d6000803e3d6000fd5b505050505b5050600101611c31565b50611d7c610fdc565b50505050565b600e5481565b611d90612599565b60005b81811015611bed57611dc1838383818110611daa57fe5b90506020020135600b61264690919063ffffffff16565b15611f5057611dec838383818110611dd557fe5b90506020020135600b6126ce90919063ffffffff16565b6000611e09848484818110611dfd57fe5b905060200201356125c5565b6001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b158015611e4157600080fd5b505afa158015611e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611e799190810190612e60565b600554604051636431e0bd60e01b81529192506001600160a01b031690636431e0bd90611eaa908490600401613386565b600060405180830381600087803b158015611ec457600080fd5b505af1158015611ed8573d6000803e3d6000fd5b50505050600d6000858585818110611eec57fe5b905060200201358152602001908152602001600020600090557f23caa21d7c1015aa7051e1ae4a09f99de36dab4545dfec5f4dde3a54173a123b848484818110611f3257fe5b90506020020135604051611f469190613386565b60405180910390a1505b600101611d93565b600f5481565b60055460405163d2f0047560e01b81526000916001600160a01b03169063d2f0047590611f8f908590600401613386565b60206040518083038186803b158015611fa757600080fd5b505afa158015611fbb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061183d9190810190612e60565b6000611fea3361182a565b9050806120095760405162461bcd60e51b8152600401610bea906134c2565b60055460405163e31f27c160e01b81526001600160a01b039091169063e31f27c190610c2590869086906004016133d0565b60055460405163719130ff60e11b81526000916001600160a01b03169063e32261fe90611f8f908590600401613386565b60006120773361182a565b9050806120965760405162461bcd60e51b8152600401610bea906134c2565b60055460405163e50a31b360e01b81526001600160a01b039091169063e50a31b390610c2590869086906004016133d0565b60006120d33361182a565b9050806120f25760405162461bcd60e51b8152600401610bea906134c2565b6005546040516375ca5def60e11b81526001600160a01b039091169063eb94bbde90610c2590869086906004016133d0565b6000806000612132846125c5565b6001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b15801561216a57600080fd5b505afa15801561217e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506121a29190810190612e60565b90506121ac6125fc565b6001600160a01b0316632528f0fe826040518263ffffffff1660e01b81526004016121d79190613386565b60206040518083038186803b1580156121ef57600080fd5b505afa158015612203573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506122279190810190612e24565b91506000612234856125c5565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561226c57600080fd5b505afa158015612280573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506122a49190810190612e60565b6000868152600d6020526040812054919250906122c0906125c5565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156122f857600080fd5b505afa15801561230c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506123309190810190612e60565b60055460405163719130ff60e11b81529192506000916123bc9184916001600160a01b039091169063e32261fe9061236c908990600401613386565b60206040518083038186803b15801561238457600080fd5b505afa158015612398573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506119d29190810190612e60565b9050808311156123d457506000945061243992505050565b60006123e6828563ffffffff61295b16565b905060006124196a1a1a7062e5185d7e380000611ac861240c888763ffffffff6125d016565b859063ffffffff6128df16565b9050612430601154826125d090919063ffffffff16565b97505050505050505b915091565b600d6020526000908152604090205481565b600061245b3361182a565b90508061247a5760405162461bcd60e51b8152600401610bea906134c2565b600554604051637a981bdb60e11b81526001600160a01b039091169063f53037b6906124aa908590600401613386565b600060405180830381600087803b1580156124c457600080fd5b505af11580156124d8573d6000803e3d6000fd5b505050505050565b6124e8612599565b60005b81811015611bed57612502838383818110611b3457fe5b156125915761253983838381811061251657fe5b905060200201602061252b9190810190612caa565b60069063ffffffff61298316565b7fd89d2ee68ab04dca0193f48a4aff55e20fa5ec0429a8a8c1c51b8dad6178a59383838381811061256657fe5b905060200201602061257b9190810190612caa565b6040516125889190613323565b60405180910390a15b6001016124eb565b6000546001600160a01b031633146125c35760405162461bcd60e51b8152600401610bea906134a2565b565b600061183d82612a99565b6000828201838110156125f55760405162461bcd60e51b8152600401610bea90613452565b9392505050565b60006126176c45786368616e6765526174657360981b612a99565b905090565b6000670de0b6b3a7640000612637848463ffffffff612af616565b8161263e57fe5b049392505050565b81546000906126575750600061183d565b600082815260018401602052604090205480151580610fd45750828460000160008154811061268257fe5b906000526020600020015414949350505050565b6126a08282612646565b61112e5781546000828152600180850160209081526040832084905590830185558482529020018190555050565b6126d88282612646565b6126f45760405162461bcd60e51b8152600401610bea90613462565b600081815260018301602052604090205482546000190180821461276257600084600001828154811061272357fe5b906000526020600020015490508085600001848154811061274057fe5b6000918252602080832090910192909255918252600186019052604090208290555b835484908061276d57fe5b600190038181906000526020600020016000905590558360010160008481526020019081526020016000206000905550505050565b606081518351016040519080825280602002602001820160405280156127d2578160200160208202803883390190505b50905060005b8351811015612814578381815181106127ed57fe5b602002602001015182828151811061280157fe5b60209081029190910101526001016127d8565b5060005b82518110156128575782818151811061282d57fe5b602002602001015182828651018151811061284457fe5b6020908102919091010152600101612818565b5092915050565b815460009061286f5750600061183d565b6001600160a01b038216600090815260018401602052604090205480151580610fd45750826001600160a01b0316846000016000815481106128ad57fe5b6000918252602090912001546001600160a01b031614949350505050565b60006126176524b9b9bab2b960d11b612a99565b60006125f5826128fd85670de0b6b3a764000063ffffffff612af616565b9063ffffffff612b3016565b612913828261285e565b61112e5781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b60008282111561297d5760405162461bcd60e51b8152600401610bea90613472565b50900390565b61298d828261285e565b6129a95760405162461bcd60e51b8152600401610bea90613462565b6001600160a01b0381166000908152600183016020526040902054825460001901808214612a485760008460000182815481106129e257fe5b60009182526020909120015485546001600160a01b0390911691508190869085908110612a0b57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080612a5357fe5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b60008181526004602090815260408083205490516001600160a01b039091169182151591612ac9918691016132f8565b604051602081830303815290604052906128575760405162461bcd60e51b8152600401610bea9190613421565b600082612b055750600061183d565b82820282848281612b1257fe5b04146125f55760405162461bcd60e51b8152600401610bea906134b2565b6000808211612b515760405162461bcd60e51b8152600401610bea90613482565b6000828481612b5c57fe5b04949350505050565b803561183d816135c8565b805161183d816135c8565b60008083601f840112612b8d57600080fd5b50813567ffffffffffffffff811115612ba557600080fd5b6020830191508360208202830111156119e857600080fd5b600082601f830112612bce57600080fd5b8135612be1612bdc82613537565b613510565b91508181835260208401935060208101905083856020840282011115612c0657600080fd5b60005b83811015612c325781612c1c8882612b65565b8452506020928301929190910190600101612c09565b5050505092915050565b60008083601f840112612c4e57600080fd5b50813567ffffffffffffffff811115612c6657600080fd5b6020830191508360408202830111156119e857600080fd5b803561183d816135dc565b805161183d816135dc565b803561183d816135e5565b805161183d816135e5565b600060208284031215612cbc57600080fd5b6000610fd48484612b65565b600060208284031215612cda57600080fd5b6000610fd48484612b70565b60008060208385031215612cf957600080fd5b823567ffffffffffffffff811115612d1057600080fd5b612d1c85828601612b7b565b92509250509250929050565b600060208284031215612d3a57600080fd5b813567ffffffffffffffff811115612d5157600080fd5b610fd484828501612bbd565b60008060008060408587031215612d7357600080fd5b843567ffffffffffffffff811115612d8a57600080fd5b612d9687828801612c3c565b9450945050602085013567ffffffffffffffff811115612db557600080fd5b612dc187828801612b7b565b95989497509550505050565b60008060008060408587031215612de357600080fd5b843567ffffffffffffffff811115612dfa57600080fd5b612d9687828801612b7b565b600060208284031215612e1857600080fd5b6000610fd48484612c7e565b600060208284031215612e3657600080fd5b6000610fd48484612c89565b600060208284031215612e5457600080fd5b6000610fd48484612c94565b600060208284031215612e7257600080fd5b6000610fd48484612c9f565b60008060408385031215612e9157600080fd5b6000612e9d8585612c94565b9250506020612eae85828601612c94565b9150509250929050565b60008060408385031215612ecb57600080fd5b6000612ed78585612c9f565b9250506020612eae85828601612c89565b60008060008060808587031215612efe57600080fd5b6000612f0a8787612c9f565b9450506020612f1b87828801612c9f565b9350506040612f2c87828801612c9f565b9250506060612f3d87828801612c9f565b91505092959194509250565b6000612f558383612fce565b505060200190565b612f668161356b565b82525050565b6000612f778261355e565b612f818185613562565b9350612f8c83613558565b8060005b83811015612fba578151612fa48882612f49565b9750612faf83613558565b925050600101612f90565b509495945050505050565b612f6681613576565b612f6681610d76565b612f66612fe382610d76565b610d76565b612f6681613587565b6000612ffc8261355e565b6130068185613562565b9350613016818560208601613592565b61301f816135be565b9093019392505050565b6000613036601b83613562565b7f496e707574206172726179206c656e677468206d69736d617463680000000000815260200192915050565b600061306f603583613562565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b60006130c6601b83613562565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b60006130ff601383613562565b7222b632b6b2b73a103737ba1034b71039b2ba1760691b815260200192915050565b600061312e601e83613562565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b6000613167601a83613562565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006131a0601183611177565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006131cd601683613562565b7504d7573742062652067726561746572207468616e20360541b815260200192915050565b60006131ff602f83613562565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b6000613250602183613562565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000613293601983613562565b7f4f6e6c7920636f6c6c61746572616c20636f6e74726163747300000000000000815260200192915050565b60006132cc601983611177565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b600061330382613193565b915061330f8284612fd7565b50602001919050565b6000613303826132bf565b6020810161183d8284612f5d565b6040810161333f8285612f5d565b6125f56020830184612f5d565b602080825281016125f58184612f6c565b6020810161183d8284612fc5565b604081016133798285612fc5565b6125f56020830184612fc5565b6020810161183d8284612fce565b6040810161333f8285612fce565b604081016133798285612fce565b604081016133be8285612fce565b8181036020830152610fd48184612ff1565b604081016133de8285612fce565b6125f56020830184612fce565b606081016133f98286612fce565b6134066020830185612fce565b610fd46040830184612fce565b6020810161183d8284612fe8565b602080825281016125f58184612ff1565b6020808252810161183d81613029565b6020808252810161183d81613062565b6020808252810161183d816130b9565b6020808252810161183d816130f2565b6020808252810161183d81613121565b6020808252810161183d8161315a565b6020808252810161183d816131c0565b6020808252810161183d816131f2565b6020808252810161183d81613243565b6020808252810161183d81613286565b608081016134e08287612fce565b6134ed6020830186612fce565b6134fa6040830185612fce565b6135076060830184612fce565b95945050505050565b60405181810167ffffffffffffffff8111828210171561352f57600080fd5b604052919050565b600067ffffffffffffffff82111561354e57600080fd5b5060209081020190565b60200190565b5190565b90815260200190565b600061183d8261357b565b151590565b6001600160a01b031690565b600061183d8261356b565b60005b838110156135ad578181015183820152602001613595565b83811115611d7c5750506000910152565b601f01601f191690565b6135d18161356b565b81146107f057600080fd5b6135d181613576565b6135d181610d7656fea365627a7a7231582086139b15c2c894f5f985b303fdd27b70745c143d7fad10f0c56a854fc078a7af6c6578706572696d656e74616cf564736f6c63430005100040

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

000000000000000000000000573e5105c4b92416d1544a188f1bf77d442bb52d000000000000000000000000de910777c787903f78c89e7a0bf7f4c435cbb1fe0000000000000000000000004e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef200000000000000000000000000000000000000000052b7d2dcc80cd2e4000000000000000000000000000000000000000000000000000000000000000971a92f000000000000000000000000000000000000000000000000000000000971a92f

-----Decoded View---------------
Arg [0] : _state (address): 0x573E5105c4B92416D1544A188F1bf77d442Bb52d
Arg [1] : _owner (address): 0xDe910777C787903F78C89e7a0bf7F4C435cBB1Fe
Arg [2] : _resolver (address): 0x4E3b31eB0E5CB73641EE1E65E7dCEFe520bA3ef2
Arg [3] : _maxDebt (uint256): 100000000000000000000000000
Arg [4] : _baseBorrowRate (uint256): 158443823
Arg [5] : _baseShortRate (uint256): 158443823

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000573e5105c4b92416d1544a188f1bf77d442bb52d
Arg [1] : 000000000000000000000000de910777c787903f78c89e7a0bf7f4c435cbb1fe
Arg [2] : 0000000000000000000000004e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef2
Arg [3] : 00000000000000000000000000000000000000000052b7d2dcc80cd2e4000000
Arg [4] : 000000000000000000000000000000000000000000000000000000000971a92f
Arg [5] : 000000000000000000000000000000000000000000000000000000000971a92f


Libraries Used


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

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