OP Sepolia Testnet

Contract

0xF36789ABc1f0F11a23B9e2184455919e437D0e3B

Overview

ETH Balance

0 ETH

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Take Debt Snapsh...107405442024-04-16 16:07:08231 days ago1713283628IN
0xF36789AB...e437D0e3B
0 ETH0.0131573939291.50000025
Take Debt Snapsh...105282212024-04-11 18:09:42236 days ago1712858982IN
0xF36789AB...e437D0e3B
0 ETH0.0134451694351.50000025
Import Excluded ...105281832024-04-11 18:08:26236 days ago1712858906IN
0xF36789AB...e437D0e3B
0 ETH0.000188883960.00010025

Advanced mode:
Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DebtCache

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 sepolia-optimism.etherscan.io on 2024-04-11
*/

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

* Synthetix: DebtCache.sol
*
* Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/DebtCache.sol
* Docs: https://docs.synthetix.io/contracts/DebtCache
*
* Contract Dependencies: 
*	- BaseDebtCache
*	- IAddressResolver
*	- IDebtCache
*	- MixinResolver
*	- MixinSystemSettings
*	- Owned
* Libraries: 
*	- SafeDecimalMath
*	- SafeMath
*
* MIT License
* ===========
*
* Copyright (c) 2024 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.0;

/**
 * @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;
    }

    // Computes `a - b`, setting the value to 0 if b > a.
    function floorsub(uint a, uint b) internal pure returns (uint) {
        return b >= a ? 0 : a - b;
    }

    /* ---------- Utilities ---------- */
    /*
     * Absolute value of the input, returned as a signed number.
     */
    function signedAbs(int x) internal pure returns (int) {
        return x < 0 ? -x : x;
    }

    /*
     * Absolute value of the input, returned as an unsigned number.
     */
    function abs(int x) internal pure returns (uint) {
        return uint(signedAbs(x));
    }
}


// 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);
}


// 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 allNetworksDebtInfo()
        external
        view
        returns (
            uint256 debt,
            uint256 sharesSupply,
            bool isStale
        );

    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 excludeOtherCollateral) external view returns (uint);

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

    function liquidationAmounts(address account, bool isSelfLiquidation)
        external
        view
        returns (
            uint totalRedeemed,
            uint debtToRemove,
            uint escrowToLiquidate,
            uint initialDebtBalance
        );

    // Restricted: used internally to Synthetix
    function addSynths(ISynth[] calldata synthsToAdd) external;

    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 burnForRedemption(
        address deprecatedSynthProxy,
        address account,
        uint balance
    ) external;

    function setCurrentPeriodId(uint128 periodId) external;

    function liquidateAccount(address account, bool isSelfLiquidation)
        external
        returns (
            uint totalRedeemed,
            uint debtRemoved,
            uint escrowToLiquidate
        );

    function issueSynthsWithoutDebt(
        bytes32 currencyKey,
        address to,
        uint amount
    ) external returns (bool rateInvalid);

    function burnSynthsWithoutDebt(
        bytes32 currencyKey,
        address to,
        uint amount
    ) external returns (bool rateInvalid);

    function burnAndIssueSynthsWithoutDebtCache(
        address account,
        bytes32 currencyKey,
        uint amountOfSynth,
        uint amountInsUSD
    ) external;

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


// 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);
}


// 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);
}


// https://docs.synthetix.io/contracts/source/interfaces/iflexiblestorage
interface IFlexibleStorage {
    // Views
    function getUIntValue(bytes32 contractName, bytes32 record) external view returns (uint);

    function getUIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (uint[] memory);

    function getIntValue(bytes32 contractName, bytes32 record) external view returns (int);

    function getIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (int[] memory);

    function getAddressValue(bytes32 contractName, bytes32 record) external view returns (address);

    function getAddressValues(bytes32 contractName, bytes32[] calldata records) external view returns (address[] memory);

    function getBoolValue(bytes32 contractName, bytes32 record) external view returns (bool);

    function getBoolValues(bytes32 contractName, bytes32[] calldata records) external view returns (bool[] memory);

    function getBytes32Value(bytes32 contractName, bytes32 record) external view returns (bytes32);

    function getBytes32Values(bytes32 contractName, bytes32[] calldata records) external view returns (bytes32[] memory);

    // Mutative functions
    function deleteUIntValue(bytes32 contractName, bytes32 record) external;

    function deleteIntValue(bytes32 contractName, bytes32 record) external;

    function deleteAddressValue(bytes32 contractName, bytes32 record) external;

    function deleteBoolValue(bytes32 contractName, bytes32 record) external;

    function deleteBytes32Value(bytes32 contractName, bytes32 record) external;

    function setUIntValue(
        bytes32 contractName,
        bytes32 record,
        uint value
    ) external;

    function setUIntValues(
        bytes32 contractName,
        bytes32[] calldata records,
        uint[] calldata values
    ) external;

    function setIntValue(
        bytes32 contractName,
        bytes32 record,
        int value
    ) external;

    function setIntValues(
        bytes32 contractName,
        bytes32[] calldata records,
        int[] calldata values
    ) external;

    function setAddressValue(
        bytes32 contractName,
        bytes32 record,
        address value
    ) external;

    function setAddressValues(
        bytes32 contractName,
        bytes32[] calldata records,
        address[] calldata values
    ) external;

    function setBoolValue(
        bytes32 contractName,
        bytes32 record,
        bool value
    ) external;

    function setBoolValues(
        bytes32 contractName,
        bytes32[] calldata records,
        bool[] calldata values
    ) external;

    function setBytes32Value(
        bytes32 contractName,
        bytes32 record,
        bytes32 value
    ) external;

    function setBytes32Values(
        bytes32 contractName,
        bytes32[] calldata records,
        bytes32[] calldata values
    ) external;
}


// Internal references


// https://docs.synthetix.io/contracts/source/contracts/mixinsystemsettings
contract MixinSystemSettings is MixinResolver {
    // must match the one defined SystemSettingsLib, defined in both places due to sol v0.5 limitations
    bytes32 internal constant SETTING_CONTRACT_NAME = "SystemSettings";

    bytes32 internal constant SETTING_WAITING_PERIOD_SECS = "waitingPeriodSecs";
    bytes32 internal constant SETTING_PRICE_DEVIATION_THRESHOLD_FACTOR = "priceDeviationThresholdFactor";
    bytes32 internal constant SETTING_ISSUANCE_RATIO = "issuanceRatio";
    bytes32 internal constant SETTING_FEE_PERIOD_DURATION = "feePeriodDuration";
    bytes32 internal constant SETTING_TARGET_THRESHOLD = "targetThreshold";
    bytes32 internal constant SETTING_LIQUIDATION_DELAY = "liquidationDelay";
    bytes32 internal constant SETTING_LIQUIDATION_RATIO = "liquidationRatio";
    bytes32 internal constant SETTING_LIQUIDATION_ESCROW_DURATION = "liquidationEscrowDuration";
    bytes32 internal constant SETTING_LIQUIDATION_PENALTY = "liquidationPenalty";
    bytes32 internal constant SETTING_SNX_LIQUIDATION_PENALTY = "snxLiquidationPenalty";
    bytes32 internal constant SETTING_SELF_LIQUIDATION_PENALTY = "selfLiquidationPenalty";
    bytes32 internal constant SETTING_FLAG_REWARD = "flagReward";
    bytes32 internal constant SETTING_LIQUIDATE_REWARD = "liquidateReward";
    bytes32 internal constant SETTING_RATE_STALE_PERIOD = "rateStalePeriod";
    /* ========== Exchange Fees Related ========== */
    bytes32 internal constant SETTING_EXCHANGE_FEE_RATE = "exchangeFeeRate";
    bytes32 internal constant SETTING_EXCHANGE_DYNAMIC_FEE_THRESHOLD = "exchangeDynamicFeeThreshold";
    bytes32 internal constant SETTING_EXCHANGE_DYNAMIC_FEE_WEIGHT_DECAY = "exchangeDynamicFeeWeightDecay";
    bytes32 internal constant SETTING_EXCHANGE_DYNAMIC_FEE_ROUNDS = "exchangeDynamicFeeRounds";
    bytes32 internal constant SETTING_EXCHANGE_MAX_DYNAMIC_FEE = "exchangeMaxDynamicFee";
    /* ========== End Exchange Fees Related ========== */
    bytes32 internal constant SETTING_MINIMUM_STAKE_TIME = "minimumStakeTime";
    bytes32 internal constant SETTING_AGGREGATOR_WARNING_FLAGS = "aggregatorWarningFlags";
    bytes32 internal constant SETTING_TRADING_REWARDS_ENABLED = "tradingRewardsEnabled";
    bytes32 internal constant SETTING_DEBT_SNAPSHOT_STALE_TIME = "debtSnapshotStaleTime";
    bytes32 internal constant SETTING_CROSS_DOMAIN_DEPOSIT_GAS_LIMIT = "crossDomainDepositGasLimit";
    bytes32 internal constant SETTING_CROSS_DOMAIN_ESCROW_GAS_LIMIT = "crossDomainEscrowGasLimit";
    bytes32 internal constant SETTING_CROSS_DOMAIN_REWARD_GAS_LIMIT = "crossDomainRewardGasLimit";
    bytes32 internal constant SETTING_CROSS_DOMAIN_WITHDRAWAL_GAS_LIMIT = "crossDomainWithdrawalGasLimit";
    bytes32 internal constant SETTING_CROSS_DOMAIN_FEE_PERIOD_CLOSE_GAS_LIMIT = "crossDomainCloseGasLimit";
    bytes32 internal constant SETTING_CROSS_DOMAIN_RELAY_GAS_LIMIT = "crossDomainRelayGasLimit";
    bytes32 internal constant SETTING_ETHER_WRAPPER_MAX_ETH = "etherWrapperMaxETH";
    bytes32 internal constant SETTING_ETHER_WRAPPER_MINT_FEE_RATE = "etherWrapperMintFeeRate";
    bytes32 internal constant SETTING_ETHER_WRAPPER_BURN_FEE_RATE = "etherWrapperBurnFeeRate";
    bytes32 internal constant SETTING_WRAPPER_MAX_TOKEN_AMOUNT = "wrapperMaxTokens";
    bytes32 internal constant SETTING_WRAPPER_MINT_FEE_RATE = "wrapperMintFeeRate";
    bytes32 internal constant SETTING_WRAPPER_BURN_FEE_RATE = "wrapperBurnFeeRate";
    bytes32 internal constant SETTING_INTERACTION_DELAY = "interactionDelay";
    bytes32 internal constant SETTING_COLLAPSE_FEE_RATE = "collapseFeeRate";
    bytes32 internal constant SETTING_ATOMIC_MAX_VOLUME_PER_BLOCK = "atomicMaxVolumePerBlock";
    bytes32 internal constant SETTING_ATOMIC_TWAP_WINDOW = "atomicTwapWindow";
    bytes32 internal constant SETTING_ATOMIC_EQUIVALENT_FOR_DEX_PRICING = "atomicEquivalentForDexPricing";
    bytes32 internal constant SETTING_ATOMIC_EXCHANGE_FEE_RATE = "atomicExchangeFeeRate";
    bytes32 internal constant SETTING_ATOMIC_VOLATILITY_CONSIDERATION_WINDOW = "atomicVolConsiderationWindow";
    bytes32 internal constant SETTING_ATOMIC_VOLATILITY_UPDATE_THRESHOLD = "atomicVolUpdateThreshold";
    bytes32 internal constant SETTING_PURE_CHAINLINK_PRICE_FOR_ATOMIC_SWAPS_ENABLED = "pureChainlinkForAtomicsEnabled";
    bytes32 internal constant SETTING_CROSS_SYNTH_TRANSFER_ENABLED = "crossChainSynthTransferEnabled";

    bytes32 internal constant CONTRACT_FLEXIBLESTORAGE = "FlexibleStorage";

    enum CrossDomainMessageGasLimits {Deposit, Escrow, Reward, Withdrawal, CloseFeePeriod, Relay}

    struct DynamicFeeConfig {
        uint threshold;
        uint weightDecay;
        uint rounds;
        uint maxFee;
    }

    constructor(address _resolver) internal MixinResolver(_resolver) {}

    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
        addresses = new bytes32[](1);
        addresses[0] = CONTRACT_FLEXIBLESTORAGE;
    }

    function flexibleStorage() internal view returns (IFlexibleStorage) {
        return IFlexibleStorage(requireAndGetAddress(CONTRACT_FLEXIBLESTORAGE));
    }

    function _getGasLimitSetting(CrossDomainMessageGasLimits gasLimitType) internal pure returns (bytes32) {
        if (gasLimitType == CrossDomainMessageGasLimits.Deposit) {
            return SETTING_CROSS_DOMAIN_DEPOSIT_GAS_LIMIT;
        } else if (gasLimitType == CrossDomainMessageGasLimits.Escrow) {
            return SETTING_CROSS_DOMAIN_ESCROW_GAS_LIMIT;
        } else if (gasLimitType == CrossDomainMessageGasLimits.Reward) {
            return SETTING_CROSS_DOMAIN_REWARD_GAS_LIMIT;
        } else if (gasLimitType == CrossDomainMessageGasLimits.Withdrawal) {
            return SETTING_CROSS_DOMAIN_WITHDRAWAL_GAS_LIMIT;
        } else if (gasLimitType == CrossDomainMessageGasLimits.Relay) {
            return SETTING_CROSS_DOMAIN_RELAY_GAS_LIMIT;
        } else if (gasLimitType == CrossDomainMessageGasLimits.CloseFeePeriod) {
            return SETTING_CROSS_DOMAIN_FEE_PERIOD_CLOSE_GAS_LIMIT;
        } else {
            revert("Unknown gas limit type");
        }
    }

    function getCrossDomainMessageGasLimit(CrossDomainMessageGasLimits gasLimitType) internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, _getGasLimitSetting(gasLimitType));
    }

    function getTradingRewardsEnabled() internal view returns (bool) {
        return flexibleStorage().getBoolValue(SETTING_CONTRACT_NAME, SETTING_TRADING_REWARDS_ENABLED);
    }

    function getWaitingPeriodSecs() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_WAITING_PERIOD_SECS);
    }

    function getPriceDeviationThresholdFactor() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_PRICE_DEVIATION_THRESHOLD_FACTOR);
    }

    function getIssuanceRatio() internal view returns (uint) {
        // lookup on flexible storage directly for gas savings (rather than via SystemSettings)
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ISSUANCE_RATIO);
    }

    function getFeePeriodDuration() internal view returns (uint) {
        // lookup on flexible storage directly for gas savings (rather than via SystemSettings)
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_FEE_PERIOD_DURATION);
    }

    function getTargetThreshold() internal view returns (uint) {
        // lookup on flexible storage directly for gas savings (rather than via SystemSettings)
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_TARGET_THRESHOLD);
    }

    function getLiquidationDelay() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_DELAY);
    }

    function getLiquidationRatio() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_RATIO);
    }

    function getLiquidationEscrowDuration() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_ESCROW_DURATION);
    }

    function getLiquidationPenalty() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_PENALTY);
    }

    function getSnxLiquidationPenalty() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_SNX_LIQUIDATION_PENALTY);
    }

    function getSelfLiquidationPenalty() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_SELF_LIQUIDATION_PENALTY);
    }

    function getFlagReward() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_FLAG_REWARD);
    }

    function getLiquidateReward() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATE_REWARD);
    }

    function getRateStalePeriod() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_RATE_STALE_PERIOD);
    }

    /* ========== Exchange Related Fees ========== */
    function getExchangeFeeRate(bytes32 currencyKey) internal view returns (uint) {
        return
            flexibleStorage().getUIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_EXCHANGE_FEE_RATE, currencyKey))
            );
    }

    /// @notice Get exchange dynamic fee related keys
    /// @return threshold, weight decay, rounds, and max fee
    function getExchangeDynamicFeeConfig() internal view returns (DynamicFeeConfig memory) {
        bytes32[] memory keys = new bytes32[](4);
        keys[0] = SETTING_EXCHANGE_DYNAMIC_FEE_THRESHOLD;
        keys[1] = SETTING_EXCHANGE_DYNAMIC_FEE_WEIGHT_DECAY;
        keys[2] = SETTING_EXCHANGE_DYNAMIC_FEE_ROUNDS;
        keys[3] = SETTING_EXCHANGE_MAX_DYNAMIC_FEE;
        uint[] memory values = flexibleStorage().getUIntValues(SETTING_CONTRACT_NAME, keys);
        return DynamicFeeConfig({threshold: values[0], weightDecay: values[1], rounds: values[2], maxFee: values[3]});
    }

    /* ========== End Exchange Related Fees ========== */

    function getMinimumStakeTime() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_MINIMUM_STAKE_TIME);
    }

    function getAggregatorWarningFlags() internal view returns (address) {
        return flexibleStorage().getAddressValue(SETTING_CONTRACT_NAME, SETTING_AGGREGATOR_WARNING_FLAGS);
    }

    function getDebtSnapshotStaleTime() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_DEBT_SNAPSHOT_STALE_TIME);
    }

    function getEtherWrapperMaxETH() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ETHER_WRAPPER_MAX_ETH);
    }

    function getEtherWrapperMintFeeRate() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ETHER_WRAPPER_MINT_FEE_RATE);
    }

    function getEtherWrapperBurnFeeRate() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ETHER_WRAPPER_BURN_FEE_RATE);
    }

    function getWrapperMaxTokenAmount(address wrapper) internal view returns (uint) {
        return
            flexibleStorage().getUIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_WRAPPER_MAX_TOKEN_AMOUNT, wrapper))
            );
    }

    function getWrapperMintFeeRate(address wrapper) internal view returns (int) {
        return
            flexibleStorage().getIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_WRAPPER_MINT_FEE_RATE, wrapper))
            );
    }

    function getWrapperBurnFeeRate(address wrapper) internal view returns (int) {
        return
            flexibleStorage().getIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_WRAPPER_BURN_FEE_RATE, wrapper))
            );
    }

    function getInteractionDelay(address collateral) internal view returns (uint) {
        return
            flexibleStorage().getUIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_INTERACTION_DELAY, collateral))
            );
    }

    function getCollapseFeeRate(address collateral) internal view returns (uint) {
        return
            flexibleStorage().getUIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_COLLAPSE_FEE_RATE, collateral))
            );
    }

    function getAtomicMaxVolumePerBlock() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ATOMIC_MAX_VOLUME_PER_BLOCK);
    }

    function getAtomicTwapWindow() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ATOMIC_TWAP_WINDOW);
    }

    function getAtomicEquivalentForDexPricing(bytes32 currencyKey) internal view returns (address) {
        return
            flexibleStorage().getAddressValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_ATOMIC_EQUIVALENT_FOR_DEX_PRICING, currencyKey))
            );
    }

    function getAtomicExchangeFeeRate(bytes32 currencyKey) internal view returns (uint) {
        return
            flexibleStorage().getUIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_ATOMIC_EXCHANGE_FEE_RATE, currencyKey))
            );
    }

    function getAtomicVolatilityConsiderationWindow(bytes32 currencyKey) internal view returns (uint) {
        return
            flexibleStorage().getUIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_ATOMIC_VOLATILITY_CONSIDERATION_WINDOW, currencyKey))
            );
    }

    function getAtomicVolatilityUpdateThreshold(bytes32 currencyKey) internal view returns (uint) {
        return
            flexibleStorage().getUIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_ATOMIC_VOLATILITY_UPDATE_THRESHOLD, currencyKey))
            );
    }

    function getPureChainlinkPriceForAtomicSwapsEnabled(bytes32 currencyKey) internal view returns (bool) {
        return
            flexibleStorage().getBoolValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_PURE_CHAINLINK_PRICE_FOR_ATOMIC_SWAPS_ENABLED, currencyKey))
            );
    }

    function getCrossChainSynthTransferEnabled(bytes32 currencyKey) internal view returns (uint) {
        return
            flexibleStorage().getUIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_CROSS_SYNTH_TRANSFER_ENABLED, currencyKey))
            );
    }

    function getExchangeMaxDynamicFee() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_EXCHANGE_MAX_DYNAMIC_FEE);
    }

    function getExchangeDynamicFeeRounds() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_EXCHANGE_DYNAMIC_FEE_ROUNDS);
    }

    function getExchangeDynamicFeeThreshold() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_EXCHANGE_DYNAMIC_FEE_THRESHOLD);
    }

    function getExchangeDynamicFeeWeightDecay() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_EXCHANGE_DYNAMIC_FEE_WEIGHT_DECAY);
    }
}


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 isInitialized() external view returns (bool);

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

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

    function totalNonSnxBackedDebt() external view returns (uint excludedDebt, bool isInvalid);

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

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

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

    // Mutative functions

    function updateCachedSynthDebts(bytes32[] calldata currencyKeys) external;

    function updateCachedSynthDebtWithRate(bytes32 currencyKey, uint currencyRate) external;

    function updateCachedSynthDebtsWithRates(bytes32[] calldata currencyKeys, uint[] calldata currencyRates) external;

    function updateDebtCacheValidity(bool currentlyInvalid) external;

    function purgeCachedSynthDebt(bytes32 currencyKey) external;

    function takeDebtSnapshot() external;

    function recordExcludedDebtChange(bytes32 currencyKey, int256 delta) external;

    function updateCachedsUSDDebt(int amount) external;

    function importExcludedIssuedDebts(IDebtCache prevDebtCache, IIssuer prevIssuer) external;
}


interface IVirtualSynth {
    // Views
    function balanceOfUnderlying(address account) external view returns (uint);

    function rate() external view returns (uint);

    function readyToSettle() external view returns (bool);

    function secsLeftInWaitingPeriod() external view returns (uint);

    function settled() external view returns (bool);

    function synth() external view returns (ISynth);

    // Mutative functions
    function settle(address account) external;
}


pragma experimental ABIEncoderV2;


// https://docs.synthetix.io/contracts/source/interfaces/iexchanger
interface IExchanger {
    struct ExchangeEntrySettlement {
        bytes32 src;
        uint amount;
        bytes32 dest;
        uint reclaim;
        uint rebate;
        uint srcRoundIdAtPeriodEnd;
        uint destRoundIdAtPeriodEnd;
        uint timestamp;
    }

    struct ExchangeEntry {
        uint sourceRate;
        uint destinationRate;
        uint destinationAmount;
        uint exchangeFeeRate;
        uint exchangeDynamicFeeRate;
        uint roundIdForSrc;
        uint roundIdForDest;
        uint sourceAmountAfterSettlement;
    }

    // Views
    function calculateAmountAfterSettlement(
        address from,
        bytes32 currencyKey,
        uint amount,
        uint refunded
    ) external view returns (uint amountAfterSettlement);

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

    function maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) external view returns (uint);

    function settlementOwing(address account, bytes32 currencyKey)
        external
        view
        returns (
            uint reclaimAmount,
            uint rebateAmount,
            uint numEntries
        );

    function hasWaitingPeriodOrSettlementOwing(address account, bytes32 currencyKey) external view returns (bool);

    function feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view returns (uint);

    function dynamicFeeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey)
        external
        view
        returns (uint feeRate, bool tooVolatile);

    function getAmountsForExchange(
        uint sourceAmount,
        bytes32 sourceCurrencyKey,
        bytes32 destinationCurrencyKey
    )
        external
        view
        returns (
            uint amountReceived,
            uint fee,
            uint exchangeFeeRate
        );

    function priceDeviationThresholdFactor() external view returns (uint);

    function waitingPeriodSecs() external view returns (uint);

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

    // Mutative functions
    function exchange(
        address exchangeForAddress,
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address destinationAddress,
        bool virtualSynth,
        address rewardAddress,
        bytes32 trackingCode
    ) external returns (uint amountReceived, IVirtualSynth vSynth);

    function exchangeAtomically(
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address destinationAddress,
        bytes32 trackingCode,
        uint minAmount
    ) external returns (uint amountReceived);

    function settle(address from, bytes32 currencyKey)
        external
        returns (
            uint reclaimed,
            uint refunded,
            uint numEntries
        );
}

// Used to have strongly-typed access to internal mutative functions in Synthetix
interface ISynthetixInternal {
    function emitExchangeTracking(
        bytes32 trackingCode,
        bytes32 toCurrencyKey,
        uint256 toAmount,
        uint256 fee
    ) external;

    function emitSynthExchange(
        address account,
        bytes32 fromCurrencyKey,
        uint fromAmount,
        bytes32 toCurrencyKey,
        uint toAmount,
        address toAddress
    ) external;

    function emitAtomicSynthExchange(
        address account,
        bytes32 fromCurrencyKey,
        uint fromAmount,
        bytes32 toCurrencyKey,
        uint toAmount,
        address toAddress
    ) external;

    function emitExchangeReclaim(
        address account,
        bytes32 currencyKey,
        uint amount
    ) external;

    function emitExchangeRebate(
        address account,
        bytes32 currencyKey,
        uint amount
    ) external;
}

interface IExchangerInternalDebtCache {
    function updateCachedSynthDebtsWithRates(bytes32[] calldata currencyKeys, uint[] calldata currencyRates) external;

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


// https://docs.synthetix.io/contracts/source/interfaces/IDirectIntegration
interface IDirectIntegrationManager {
    struct ParameterIntegrationSettings {
        bytes32 currencyKey;
        address dexPriceAggregator;
        address atomicEquivalentForDexPricing;
        uint atomicExchangeFeeRate;
        uint atomicTwapWindow;
        uint atomicMaxVolumePerBlock;
        uint atomicVolatilityConsiderationWindow;
        uint atomicVolatilityUpdateThreshold;
        uint exchangeFeeRate;
        uint exchangeMaxDynamicFee;
        uint exchangeDynamicFeeRounds;
        uint exchangeDynamicFeeThreshold;
        uint exchangeDynamicFeeWeightDecay;
    }

    function getExchangeParameters(address integration, bytes32 key)
        external
        view
        returns (ParameterIntegrationSettings memory settings);

    function setExchangeParameters(
        address integration,
        bytes32[] calldata currencyKeys,
        ParameterIntegrationSettings calldata params
    ) external;
}


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

    // 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 anyRateIsInvalidAtRound(bytes32[] calldata currencyKeys, uint[] calldata roundIds) external view returns (bool);

    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 effectiveValueAndRatesAtRound(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        uint roundIdForSrc,
        uint roundIdForDest
    )
        external
        view
        returns (
            uint value,
            uint sourceRate,
            uint destinationRate
        );

    function effectiveAtomicValueAndRates(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    )
        external
        view
        returns (
            uint value,
            uint systemValue,
            uint systemSourceRate,
            uint systemDestinationRate
        );

    function effectiveAtomicValueAndRates(
        IDirectIntegrationManager.ParameterIntegrationSettings calldata sourceSettings,
        uint sourceAmount,
        IDirectIntegrationManager.ParameterIntegrationSettings calldata destinationSettings,
        IDirectIntegrationManager.ParameterIntegrationSettings calldata usdSettings
    )
        external
        view
        returns (
            uint value,
            uint systemValue,
            uint systemSourceRate,
            uint systemDestinationRate
        );

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

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

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

    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 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,
        uint roundId
    ) 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);

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

    function synthTooVolatileForAtomicExchange(IDirectIntegrationManager.ParameterIntegrationSettings calldata settings)
        external
        view
        returns (bool);

    function rateWithSafetyChecks(bytes32 currencyKey)
        external
        returns (
            uint rate,
            bool broken,
            bool invalid
        );
}


// https://docs.synthetix.io/contracts/source/interfaces/isystemstatus
interface ISystemStatus {
    struct Status {
        bool canSuspend;
        bool canResume;
    }

    struct Suspension {
        bool suspended;
        // reason is an integer code,
        // 0 => no reason, 1 => upgrading, 2+ => defined by system usage
        uint248 reason;
    }

    // Views
    function accessControl(bytes32 section, address account) external view returns (bool canSuspend, bool canResume);

    function requireSystemActive() external view;

    function systemSuspended() external view returns (bool);

    function requireIssuanceActive() external view;

    function requireExchangeActive() external view;

    function requireFuturesActive() external view;

    function requireFuturesMarketActive(bytes32 marketKey) external view;

    function requireExchangeBetweenSynthsAllowed(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view;

    function requireSynthActive(bytes32 currencyKey) external view;

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

    function requireSynthsActive(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view;

    function systemSuspension() external view returns (bool suspended, uint248 reason);

    function issuanceSuspension() external view returns (bool suspended, uint248 reason);

    function exchangeSuspension() external view returns (bool suspended, uint248 reason);

    function futuresSuspension() external view returns (bool suspended, uint248 reason);

    function synthExchangeSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason);

    function synthSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason);

    function futuresMarketSuspension(bytes32 marketKey) external view returns (bool suspended, uint248 reason);

    function getSynthExchangeSuspensions(bytes32[] calldata synths)
        external
        view
        returns (bool[] memory exchangeSuspensions, uint256[] memory reasons);

    function getSynthSuspensions(bytes32[] calldata synths)
        external
        view
        returns (bool[] memory suspensions, uint256[] memory reasons);

    function getFuturesMarketSuspensions(bytes32[] calldata marketKeys)
        external
        view
        returns (bool[] memory suspensions, uint256[] memory reasons);

    // Restricted functions
    function suspendIssuance(uint256 reason) external;

    function suspendSynth(bytes32 currencyKey, uint256 reason) external;

    function suspendFuturesMarket(bytes32 marketKey, uint256 reason) external;

    function updateAccessControl(
        bytes32 section,
        address account,
        bool canSuspend,
        bool canResume
    ) 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);
}


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[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys) external;

    function removeShortableSynths(bytes32[] calldata synths) external;

    // State mutative

    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;

    function accrueInterest(
        uint interestIndex,
        bytes32 currency,
        bool isShort
    ) external returns (uint difference, uint index);

    function updateBorrowRatesCollateral(uint rate) external;

    function updateShortRatesCollateral(bytes32 currency, uint rate) external;
}


interface IWETH {
    // 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);

    // WETH-specific functions.
    function deposit() external payable;

    function withdraw(uint amount) external;

    // Events
    event Transfer(address indexed from, address indexed to, uint value);
    event Approval(address indexed owner, address indexed spender, uint value);
    event Deposit(address indexed to, uint amount);
    event Withdrawal(address indexed to, uint amount);
}


// https://docs.synthetix.io/contracts/source/interfaces/ietherwrapper
contract IEtherWrapper {
    function mint(uint amount) external;

    function burn(uint amount) external;

    function distributeFees() external;

    function capacity() external view returns (uint);

    function getReserves() external view returns (uint);

    function totalIssuedSynths() external view returns (uint);

    function calculateMintFee(uint amount) public view returns (uint);

    function calculateBurnFee(uint amount) public view returns (uint);

    function maxETH() public view returns (uint256);

    function mintFeeRate() public view returns (uint256);

    function burnFeeRate() public view returns (uint256);

    function weth() public view returns (IWETH);
}


// https://docs.synthetix.io/contracts/source/interfaces/iwrapperfactory
interface IWrapperFactory {
    function isWrapper(address possibleWrapper) external view returns (bool);

    function createWrapper(
        IERC20 token,
        bytes32 currencyKey,
        bytes32 synthContractName
    ) external returns (address);

    function distributeFees() external;
}


interface IFuturesMarketManager {
    function markets(uint index, uint pageSize) external view returns (address[] memory);

    function markets(
        uint index,
        uint pageSize,
        bool proxiedMarkets
    ) external view returns (address[] memory);

    function numMarkets() external view returns (uint);

    function numMarkets(bool proxiedMarkets) external view returns (uint);

    function allMarkets() external view returns (address[] memory);

    function allMarkets(bool proxiedMarkets) external view returns (address[] memory);

    function marketForKey(bytes32 marketKey) external view returns (address);

    function marketsForKeys(bytes32[] calldata marketKeys) external view returns (address[] memory);

    function totalDebt() external view returns (uint debt, bool isInvalid);

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

    function allEndorsedAddresses() external view returns (address[] memory);

    function addEndorsedAddresses(address[] calldata addresses) external;

    function removeEndorsedAddresses(address[] calldata addresses) external;
}


interface IDynamicSynthRedeemer {
    function suspendRedemption() external;

    function resumeRedemption() external;

    // Rate applied to chainlink price for redemptions
    function getDiscountRate() external view returns (uint);

    function redeem(bytes32 currencyKey) external;

    function redeemAll(bytes32[] calldata currencyKeys) external;

    function redeemPartial(bytes32 currencyKey, uint amountOfSynth) external;
}


// Inheritance


// Libraries


// Internal references


// https://docs.synthetix.io/contracts/source/contracts/debtcache
contract BaseDebtCache is Owned, MixinSystemSettings, IDebtCache {
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    uint internal _cachedDebt;
    mapping(bytes32 => uint) internal _cachedSynthDebt;
    mapping(bytes32 => uint) internal _excludedIssuedDebt;
    uint internal _cacheTimestamp;
    bool internal _cacheInvalid = true;

    // flag to ensure importing excluded debt is invoked only once
    bool public isInitialized = false; // public to avoid needing an event

    /* ========== ENCODED NAMES ========== */

    bytes32 internal constant sUSD = "sUSD";
    bytes32 internal constant sETH = "sETH";

    /* ========== ADDRESS RESOLVER CONFIGURATION ========== */

    bytes32 private constant CONTRACT_ISSUER = "Issuer";
    bytes32 private constant CONTRACT_EXCHANGER = "Exchanger";
    bytes32 private constant CONTRACT_EXRATES = "ExchangeRates";
    bytes32 private constant CONTRACT_SYSTEMSTATUS = "SystemStatus";
    bytes32 private constant CONTRACT_COLLATERALMANAGER = "CollateralManager";
    bytes32 private constant CONTRACT_ETHER_WRAPPER = "EtherWrapper";
    bytes32 private constant CONTRACT_FUTURESMARKETMANAGER = "FuturesMarketManager";
    bytes32 private constant CONTRACT_WRAPPER_FACTORY = "WrapperFactory";
    bytes32 private constant CONTRACT_DYNAMICSYNTHREDEEMER = "DynamicSynthRedeemer";

    constructor(address _owner, address _resolver) public Owned(_owner) MixinSystemSettings(_resolver) {}

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

    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
        bytes32[] memory existingAddresses = MixinSystemSettings.resolverAddressesRequired();
        bytes32[] memory newAddresses = new bytes32[](9);
        newAddresses[0] = CONTRACT_ISSUER;
        newAddresses[1] = CONTRACT_EXCHANGER;
        newAddresses[2] = CONTRACT_EXRATES;
        newAddresses[3] = CONTRACT_SYSTEMSTATUS;
        newAddresses[4] = CONTRACT_COLLATERALMANAGER;
        newAddresses[5] = CONTRACT_WRAPPER_FACTORY;
        newAddresses[6] = CONTRACT_ETHER_WRAPPER;
        newAddresses[7] = CONTRACT_FUTURESMARKETMANAGER;
        newAddresses[8] = CONTRACT_DYNAMICSYNTHREDEEMER;
        addresses = combineArrays(existingAddresses, newAddresses);
    }

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

    function exchanger() internal view returns (IExchanger) {
        return IExchanger(requireAndGetAddress(CONTRACT_EXCHANGER));
    }

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

    function systemStatus() internal view returns (ISystemStatus) {
        return ISystemStatus(requireAndGetAddress(CONTRACT_SYSTEMSTATUS));
    }

    function collateralManager() internal view returns (ICollateralManager) {
        return ICollateralManager(requireAndGetAddress(CONTRACT_COLLATERALMANAGER));
    }

    function etherWrapper() internal view returns (IEtherWrapper) {
        return IEtherWrapper(requireAndGetAddress(CONTRACT_ETHER_WRAPPER));
    }

    function futuresMarketManager() internal view returns (IFuturesMarketManager) {
        return IFuturesMarketManager(requireAndGetAddress(CONTRACT_FUTURESMARKETMANAGER));
    }

    function wrapperFactory() internal view returns (IWrapperFactory) {
        return IWrapperFactory(requireAndGetAddress(CONTRACT_WRAPPER_FACTORY));
    }

    function dynamicSynthRedeemer() internal view returns (IDynamicSynthRedeemer) {
        return IDynamicSynthRedeemer(requireAndGetAddress(CONTRACT_DYNAMICSYNTHREDEEMER));
    }

    function debtSnapshotStaleTime() external view returns (uint) {
        return getDebtSnapshotStaleTime();
    }

    function cachedDebt() external view returns (uint) {
        return _cachedDebt;
    }

    function cachedSynthDebt(bytes32 currencyKey) external view returns (uint) {
        return _cachedSynthDebt[currencyKey];
    }

    function cacheTimestamp() external view returns (uint) {
        return _cacheTimestamp;
    }

    function cacheInvalid() external view returns (bool) {
        return _cacheInvalid;
    }

    function _cacheStale(uint timestamp) internal view returns (bool) {
        // Note a 0 timestamp means that the cache is uninitialised.
        // We'll keep the check explicitly in case the stale time is
        // ever set to something higher than the current unix time (e.g. to turn off staleness).
        return getDebtSnapshotStaleTime() < block.timestamp - timestamp || timestamp == 0;
    }

    function cacheStale() external view returns (bool) {
        return _cacheStale(_cacheTimestamp);
    }

    function _issuedSynthValues(bytes32[] memory currencyKeys, uint[] memory rates)
        internal
        view
        returns (uint[] memory values)
    {
        uint numValues = currencyKeys.length;
        values = new uint[](numValues);
        ISynth[] memory synths = issuer().getSynths(currencyKeys);
        uint discountRate = dynamicSynthRedeemer().getDiscountRate();

        for (uint i = 0; i < numValues; i++) {
            address synthAddress = address(synths[i]);
            require(synthAddress != address(0), "Synth does not exist");
            uint supply = IERC20(synthAddress).totalSupply();
            uint value = supply.multiplyDecimalRound(rates[i]);
            uint multiplier = (synths[i].currencyKey() != sUSD) ? discountRate : SafeDecimalMath.unit();
            values[i] = value.multiplyDecimalRound(multiplier);
        }

        return (values);
    }

    function _currentSynthDebts(bytes32[] memory currencyKeys)
        internal
        view
        returns (
            uint[] memory snxIssuedDebts,
            uint _futuresDebt,
            uint _excludedDebt,
            bool anyRateIsInvalid
        )
    {
        (uint[] memory rates, bool isInvalid) = exchangeRates().ratesAndInvalidForCurrencies(currencyKeys);
        uint[] memory values = _issuedSynthValues(currencyKeys, rates);
        (uint excludedDebt, bool isAnyNonSnxDebtRateInvalid) = _totalNonSnxBackedDebt(currencyKeys, rates, isInvalid);
        (uint futuresDebt, bool futuresDebtIsInvalid) = futuresMarketManager().totalDebt();

        return (values, futuresDebt, excludedDebt, isInvalid || futuresDebtIsInvalid || isAnyNonSnxDebtRateInvalid);
    }

    function currentSynthDebts(bytes32[] calldata currencyKeys)
        external
        view
        returns (
            uint[] memory debtValues,
            uint futuresDebt,
            uint excludedDebt,
            bool anyRateIsInvalid
        )
    {
        return _currentSynthDebts(currencyKeys);
    }

    function _cachedSynthDebts(bytes32[] memory currencyKeys) internal view returns (uint[] memory) {
        uint numKeys = currencyKeys.length;
        uint[] memory debts = new uint[](numKeys);
        for (uint i = 0; i < numKeys; i++) {
            debts[i] = _cachedSynthDebt[currencyKeys[i]];
        }
        return debts;
    }

    function cachedSynthDebts(bytes32[] calldata currencyKeys) external view returns (uint[] memory snxIssuedDebts) {
        return _cachedSynthDebts(currencyKeys);
    }

    function _excludedIssuedDebts(bytes32[] memory currencyKeys) internal view returns (uint[] memory) {
        uint numKeys = currencyKeys.length;
        uint[] memory debts = new uint[](numKeys);
        for (uint i = 0; i < numKeys; i++) {
            debts[i] = _excludedIssuedDebt[currencyKeys[i]];
        }
        return debts;
    }

    function excludedIssuedDebts(bytes32[] calldata currencyKeys) external view returns (uint[] memory excludedDebts) {
        return _excludedIssuedDebts(currencyKeys);
    }

    /// used when migrating to new DebtCache instance in order to import the excluded debt records
    /// If this method is not run after upgrading the contract, the debt will be
    /// incorrect w.r.t to wrapper factory assets until the values are imported from
    /// previous instance of the contract
    /// Also, in addition to this method it's possible to use recordExcludedDebtChange since
    /// it's accessible to owner in case additional adjustments are required
    function importExcludedIssuedDebts(IDebtCache prevDebtCache, IIssuer prevIssuer) external onlyOwner {
        // this can only be run once so that recorded debt deltas aren't accidentally
        // lost or double counted
        require(!isInitialized, "already initialized");
        isInitialized = true;

        // get the currency keys from **previous** issuer, in case current issuer
        // doesn't have all the synths at this point
        // warning: if a synth won't be added to the current issuer before the next upgrade of this contract,
        // its entry will be lost (because it won't be in the prevIssuer for next time).
        // if for some reason this is a problem, it should be possible to use recordExcludedDebtChange() to amend
        bytes32[] memory keys = prevIssuer.availableCurrencyKeys();

        require(keys.length > 0, "previous Issuer has no synths");

        // query for previous debt records
        uint[] memory debts = prevDebtCache.excludedIssuedDebts(keys);

        // store the values
        for (uint i = 0; i < keys.length; i++) {
            if (debts[i] > 0) {
                // adding the values instead of overwriting in case some deltas were recorded in this
                // contract already (e.g. if the upgrade was not atomic)
                _excludedIssuedDebt[keys[i]] = _excludedIssuedDebt[keys[i]].add(debts[i]);
            }
        }
    }

    // Returns the total sUSD debt backed by non-SNX collateral.
    function totalNonSnxBackedDebt() external view returns (uint excludedDebt, bool isInvalid) {
        bytes32[] memory currencyKeys = issuer().availableCurrencyKeys();
        (uint[] memory rates, bool ratesAreInvalid) = exchangeRates().ratesAndInvalidForCurrencies(currencyKeys);

        return _totalNonSnxBackedDebt(currencyKeys, rates, ratesAreInvalid);
    }

    function _totalNonSnxBackedDebt(
        bytes32[] memory currencyKeys,
        uint[] memory rates,
        bool ratesAreInvalid
    ) internal view returns (uint excludedDebt, bool isInvalid) {
        // Calculate excluded debt.
        // 1. MultiCollateral long debt + short debt.
        (uint longValue, bool anyTotalLongRateIsInvalid) = collateralManager().totalLong();
        (uint shortValue, bool anyTotalShortRateIsInvalid) = collateralManager().totalShort();
        isInvalid = ratesAreInvalid || anyTotalLongRateIsInvalid || anyTotalShortRateIsInvalid;
        excludedDebt = longValue.add(shortValue);

        // 2. EtherWrapper.
        // Subtract sETH and sUSD issued by EtherWrapper.
        excludedDebt = excludedDebt.add(etherWrapper().totalIssuedSynths());

        // 3. WrapperFactory.
        // Get the debt issued by the Wrappers.
        for (uint i = 0; i < currencyKeys.length; i++) {
            excludedDebt = excludedDebt.add(_excludedIssuedDebt[currencyKeys[i]].multiplyDecimalRound(rates[i]));
        }

        return (excludedDebt, isInvalid);
    }

    function _currentDebt() internal view returns (uint debt, bool anyRateIsInvalid) {
        bytes32[] memory currencyKeys = issuer().availableCurrencyKeys();
        (uint[] memory rates, bool isInvalid) = exchangeRates().ratesAndInvalidForCurrencies(currencyKeys);

        // Sum all issued synth values based on their supply.
        uint[] memory values = _issuedSynthValues(currencyKeys, rates);
        (uint excludedDebt, bool isAnyNonSnxDebtRateInvalid) = _totalNonSnxBackedDebt(currencyKeys, rates, isInvalid);

        uint numValues = values.length;
        uint total;
        for (uint i; i < numValues; i++) {
            total = total.add(values[i]);
        }

        // Add in the debt accounted for by futures
        (uint futuresDebt, bool futuresDebtIsInvalid) = futuresMarketManager().totalDebt();
        total = total.add(futuresDebt);

        // Ensure that if the excluded non-SNX debt exceeds SNX-backed debt, no overflow occurs
        total = total < excludedDebt ? 0 : total.sub(excludedDebt);

        return (total, isInvalid || futuresDebtIsInvalid || isAnyNonSnxDebtRateInvalid);
    }

    function currentDebt() external view returns (uint debt, bool anyRateIsInvalid) {
        return _currentDebt();
    }

    function cacheInfo()
        external
        view
        returns (
            uint debt,
            uint timestamp,
            bool isInvalid,
            bool isStale
        )
    {
        uint time = _cacheTimestamp;
        return (_cachedDebt, time, _cacheInvalid, _cacheStale(time));
    }

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

    // Stub out all mutative functions as no-ops;
    // since they do nothing, there are no restrictions

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

    function updateCachedSynthDebtWithRate(bytes32 currencyKey, uint currencyRate) external {}

    function updateCachedSynthDebtsWithRates(bytes32[] calldata currencyKeys, uint[] calldata currencyRates) external {}

    function updateDebtCacheValidity(bool currentlyInvalid) external {}

    function purgeCachedSynthDebt(bytes32 currencyKey) external {}

    function takeDebtSnapshot() external {}

    function recordExcludedDebtChange(bytes32 currencyKey, int256 delta) external {}

    function updateCachedsUSDDebt(int amount) external {}

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

    function _requireSystemActiveIfNotOwner() internal view {
        if (msg.sender != owner) {
            systemStatus().requireSystemActive();
        }
    }

    modifier requireSystemActiveIfNotOwner() {
        _requireSystemActiveIfNotOwner();
        _;
    }

    function _onlyIssuer() internal view {
        require(msg.sender == address(issuer()), "Sender is not Issuer");
    }

    modifier onlyIssuer() {
        _onlyIssuer();
        _;
    }

    function _onlyIssuerOrExchanger() internal view {
        require(msg.sender == address(issuer()) || msg.sender == address(exchanger()), "Sender is not Issuer or Exchanger");
    }

    modifier onlyIssuerOrExchanger() {
        _onlyIssuerOrExchanger();
        _;
    }

    function _onlyDebtIssuer() internal view {
        bool isWrapper = wrapperFactory().isWrapper(msg.sender);

        // owner included for debugging and fixing in emergency situation
        bool isOwner = msg.sender == owner;

        require(isOwner || isWrapper, "Only debt issuers may call this");
    }

    modifier onlyDebtIssuer() {
        _onlyDebtIssuer();
        _;
    }
}


// Libraries


// Inheritance


// https://docs.synthetix.io/contracts/source/contracts/debtcache
contract DebtCache is BaseDebtCache {
    using SafeDecimalMath for uint;

    bytes32 public constant CONTRACT_NAME = "DebtCache";

    constructor(address _owner, address _resolver) public BaseDebtCache(_owner, _resolver) {}

    bytes32 internal constant EXCLUDED_DEBT_KEY = "EXCLUDED_DEBT";
    bytes32 internal constant FUTURES_DEBT_KEY = "FUTURES_DEBT";

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

    // This function exists in case a synth is ever somehow removed without its snapshot being updated.
    function purgeCachedSynthDebt(bytes32 currencyKey) external onlyOwner {
        require(issuer().synths(currencyKey) == ISynth(0), "Synth exists");
        delete _cachedSynthDebt[currencyKey];
    }

    function takeDebtSnapshot() external requireSystemActiveIfNotOwner {
        bytes32[] memory currencyKeys = issuer().availableCurrencyKeys();
        (uint[] memory values, uint futuresDebt, uint excludedDebt, bool isInvalid) = _currentSynthDebts(currencyKeys);

        // The total SNX-backed debt is the debt of futures markets plus the debt of circulating synths.
        uint snxCollateralDebt = futuresDebt;
        _cachedSynthDebt[FUTURES_DEBT_KEY] = futuresDebt;
        uint numValues = values.length;
        for (uint i; i < numValues; i++) {
            uint value = values[i];
            snxCollateralDebt = snxCollateralDebt.add(value);
            _cachedSynthDebt[currencyKeys[i]] = value;
        }

        // Subtract out the excluded non-SNX backed debt from our total
        _cachedSynthDebt[EXCLUDED_DEBT_KEY] = excludedDebt;
        uint newDebt = snxCollateralDebt.floorsub(excludedDebt);
        _cachedDebt = newDebt;
        _cacheTimestamp = block.timestamp;
        emit DebtCacheUpdated(newDebt);
        emit DebtCacheSnapshotTaken(block.timestamp);

        // (in)validate the cache if necessary
        _updateDebtCacheValidity(isInvalid);
    }

    function updateCachedSynthDebts(bytes32[] calldata currencyKeys) external requireSystemActiveIfNotOwner {
        (uint[] memory rates, bool anyRateInvalid) = exchangeRates().ratesAndInvalidForCurrencies(currencyKeys);
        _updateCachedSynthDebtsWithRates(currencyKeys, rates, anyRateInvalid);
    }

    function updateCachedSynthDebtWithRate(bytes32 currencyKey, uint currencyRate) external onlyIssuer {
        bytes32[] memory synthKeyArray = new bytes32[](1);
        synthKeyArray[0] = currencyKey;
        uint[] memory synthRateArray = new uint[](1);
        synthRateArray[0] = currencyRate;
        _updateCachedSynthDebtsWithRates(synthKeyArray, synthRateArray, false);
    }

    function updateCachedSynthDebtsWithRates(bytes32[] calldata currencyKeys, uint[] calldata currencyRates)
        external
        onlyIssuerOrExchanger
    {
        _updateCachedSynthDebtsWithRates(currencyKeys, currencyRates, false);
    }

    function updateDebtCacheValidity(bool currentlyInvalid) external onlyIssuer {
        _updateDebtCacheValidity(currentlyInvalid);
    }

    function recordExcludedDebtChange(bytes32 currencyKey, int256 delta) external onlyDebtIssuer {
        int256 newExcludedDebt = int256(_excludedIssuedDebt[currencyKey]) + delta;

        require(newExcludedDebt >= 0, "Excluded debt cannot become negative");

        _excludedIssuedDebt[currencyKey] = uint(newExcludedDebt);
    }

    function updateCachedsUSDDebt(int amount) external onlyIssuer {
        uint delta = SafeDecimalMath.abs(amount);
        if (amount > 0) {
            _cachedSynthDebt[sUSD] = _cachedSynthDebt[sUSD].add(delta);
            _cachedDebt = _cachedDebt.add(delta);
        } else {
            _cachedSynthDebt[sUSD] = _cachedSynthDebt[sUSD].sub(delta);
            _cachedDebt = _cachedDebt.sub(delta);
        }

        emit DebtCacheUpdated(_cachedDebt);
    }

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

    function _updateDebtCacheValidity(bool currentlyInvalid) internal {
        if (_cacheInvalid != currentlyInvalid) {
            _cacheInvalid = currentlyInvalid;
            emit DebtCacheValidityChanged(currentlyInvalid);
        }
    }

    // Updated the global debt according to a rate/supply change in a subset of issued synths.
    function _updateCachedSynthDebtsWithRates(
        bytes32[] memory currencyKeys,
        uint[] memory currentRates,
        bool anyRateIsInvalid
    ) internal {
        uint numKeys = currencyKeys.length;
        require(numKeys == currentRates.length, "Input array lengths differ");

        // Compute the cached and current debt sum for the subset of synths provided.
        uint cachedSum;
        uint currentSum;
        uint[] memory currentValues = _issuedSynthValues(currencyKeys, currentRates);

        for (uint i = 0; i < numKeys; i++) {
            bytes32 key = currencyKeys[i];
            uint currentSynthDebt = currentValues[i];

            cachedSum = cachedSum.add(_cachedSynthDebt[key]);
            currentSum = currentSum.add(currentSynthDebt);

            _cachedSynthDebt[key] = currentSynthDebt;
        }

        // Apply the debt update.
        if (cachedSum != currentSum) {
            uint debt = _cachedDebt;
            // apply the delta between the cachedSum and currentSum
            // add currentSum before sub cachedSum to prevent overflow as cachedSum > debt for large amount of excluded debt
            debt = debt.add(currentSum).sub(cachedSum);
            _cachedDebt = debt;
            emit DebtCacheUpdated(debt);
        }

        // Invalidate the cache if necessary
        if (anyRateIsInvalid) {
            _updateDebtCacheValidity(anyRateIsInvalid);
        }
    }

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

    event DebtCacheUpdated(uint cachedDebt);
    event DebtCacheSnapshotTaken(uint timestamp);
    event DebtCacheValidityChanged(bool indexed isInvalid);
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"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":"uint256","name":"timestamp","type":"uint256"}],"name":"DebtCacheSnapshotTaken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"cachedDebt","type":"uint256"}],"name":"DebtCacheUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bool","name":"isInvalid","type":"bool"}],"name":"DebtCacheValidityChanged","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"},{"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":true,"inputs":[],"name":"cacheInfo","outputs":[{"internalType":"uint256","name":"debt","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"bool","name":"isInvalid","type":"bool"},{"internalType":"bool","name":"isStale","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cacheInvalid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cacheStale","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cacheTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cachedDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"cachedSynthDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"cachedSynthDebts","outputs":[{"internalType":"uint256[]","name":"snxIssuedDebts","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentDebt","outputs":[{"internalType":"uint256","name":"debt","type":"uint256"},{"internalType":"bool","name":"anyRateIsInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"currentSynthDebts","outputs":[{"internalType":"uint256[]","name":"debtValues","type":"uint256[]"},{"internalType":"uint256","name":"futuresDebt","type":"uint256"},{"internalType":"uint256","name":"excludedDebt","type":"uint256"},{"internalType":"bool","name":"anyRateIsInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"debtSnapshotStaleTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"excludedIssuedDebts","outputs":[{"internalType":"uint256[]","name":"excludedDebts","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract IDebtCache","name":"prevDebtCache","type":"address"},{"internalType":"contract IIssuer","name":"prevIssuer","type":"address"}],"name":"importExcludedIssuedDebts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"purgeCachedSynthDebt","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"int256","name":"delta","type":"int256"}],"name":"recordExcludedDebtChange","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":[],"name":"takeDebtSnapshot","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalNonSnxBackedDebt","outputs":[{"internalType":"uint256","name":"excludedDebt","type":"uint256"},{"internalType":"bool","name":"isInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"uint256","name":"currencyRate","type":"uint256"}],"name":"updateCachedSynthDebtWithRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"updateCachedSynthDebts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"},{"internalType":"uint256[]","name":"currencyRates","type":"uint256[]"}],"name":"updateCachedSynthDebtsWithRates","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"int256","name":"amount","type":"int256"}],"name":"updateCachedsUSDDebt","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"currentlyInvalid","type":"bool"}],"name":"updateDebtCacheValidity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

60806040526008805461ff001960ff199091166001171690553480156200002557600080fd5b50604051620036f0380380620036f0833981016040819052620000489162000114565b81818080836001600160a01b0381166200007f5760405162461bcd60e51b81526004016200007690620001d0565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000cc918490620001aa565b60405180910390a150600280546001600160a01b0319166001600160a01b0392909216919091179055506200022b9350505050565b80516200010e8162000211565b92915050565b600080604083850312156200012857600080fd5b600062000136858562000101565b9250506020620001498582860162000101565b9150509250929050565b6200015e81620001fd565b82525050565b6200015e81620001eb565b60006200017e601983620001e2565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b60408101620001ba828562000153565b620001c9602083018462000164565b9392505050565b602080825281016200010e816200016f565b90815260200190565b60006001600160a01b0382166200010e565b60006200010e8260006200010e82620001eb565b6200021c81620001eb565b81146200022857600080fd5b50565b6134b5806200023b6000396000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c8063741853601161010f578063af5355d8116100a2578063d0fffafd11610071578063d0fffafd146103cd578063d685743a146103d5578063e3476cd4146103e8578063fc524773146103f0576101e5565b8063af5355d81461038c578063b13cd78514610394578063b7224ec7146103a7578063cda218c7146103ba576101e5565b80638da5cb5b116100de5780638da5cb5b146103565780638dd5bfbc1461035e5780639e3b92ca14610371578063a5f27edb14610384576101e5565b80637418536014610329578063759076e51461033157806379ba509714610339578063899ffef414610341576101e5565b80632992dba21161018757806342c7b8191161015657806342c7b819146102d657806353a47bb7146102e9578063614d08f8146102fe5780636bf7c43514610306576101e5565b80632992dba21461028b5780632af64bd3146102a1578063392e53cd146102b65780633a900a2e146102be576101e5565b806307619a5f116101c357806307619a5f146102325780630fb38465146102525780631627540c1461026557806317b38db414610278576101e5565b806304bd11e5146101ea57806304f3bcec146101ff578063053932621461021d575b600080fd5b6101fd6101f8366004612a9c565b6103f8565b005b61020761040c565b604051610214919061320d565b60405180910390f35b61022561041b565b60405161021491906131b6565b6102456102403660046128fa565b610422565b6040516102149190613154565b610225610260366004612ad8565b610469565b6101fd6102733660046128b6565b61047b565b6101fd61028636600461293c565b6104d9565b610293610554565b60405161021492919061330c565b6102a961067c565b60405161021491906131a8565b6102a9610793565b6102c66107a1565b6040516102149493929190613327565b6101fd6102e4366004612ad8565b6107d2565b6102f16108ff565b60405161021491906130fa565b61022561090e565b6103196103143660046128fa565b61091e565b6040516102149493929190613165565b6101fd610971565b610293610ac7565b6101fd610ada565b610349610b7f565b6040516102149190613143565b6102f1610d44565b6101fd61036c366004612ad8565b610d53565b6101fd61037f366004612b14565b610e17565b6102a9610e66565b610225610e6f565b6102456103a23660046128fa565b610e7e565b6101fd6103b5366004612b44565b610ebc565b6101fd6103c83660046128fa565b6110d1565b6102256111aa565b6101fd6103e3366004612b14565b6111b0565b6101fd61123d565b6102a961146c565b610400611479565b610409816114b3565b50565b6002546001600160a01b031681565b6004545b90565b606061046083838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061150092505050565b90505b92915050565b60009081526005602052604090205490565b610483611590565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906104ce9083906130fa565b60405180910390a150565b6104e16115ba565b61054e8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080880282810182019093528782529093508792508691829185019084908082843760009201829052509250611615915050565b50505050565b600080606061056161175a565b6001600160a01b03166372cb051f6040518163ffffffff1660e01b815260040160006040518083038186803b15801561059957600080fd5b505afa1580156105ad573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105d591908101906129ac565b9050606060006105e361176e565b6001600160a01b031663c8e5bbd5846040518263ffffffff1660e01b815260040161060e9190613143565b60006040518083038186803b15801561062657600080fd5b505afa15801561063a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106629190810190612a4b565b91509150610671838383611789565b945094505050509091565b60006060610688610b7f565b905060005b815181101561078a5760008282815181106106a457fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a721906106f59085906004016131b6565b60206040518083038186803b15801561070d57600080fd5b505afa158015610721573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061074591908101906128dc565b6001600160a01b031614158061077057506000818152600360205260409020546001600160a01b0316155b15610781576000935050505061041f565b5060010161068d565b50600191505090565b600854610100900460ff1681565b6007546004546008546000928392839283929190829060ff166107c3826119b6565b94509450945094505090919293565b6107da611479565b60006107e5826119cf565b9050600082131561085b57631cd554d160e21b600052600560205260008051602061345383398151915254610820908263ffffffff6119da16565b631cd554d160e21b600052600560205260008051602061345383398151915255600454610853908263ffffffff6119da16565b6004556108c2565b631cd554d160e21b60005260056020526000805160206134538339815191525461088b908263ffffffff6119ff16565b631cd554d160e21b6000526005602052600080516020613453833981519152556004546108be908263ffffffff6119ff16565b6004555b7f294a7c394e53042c7d754779562747d93b41db019dd4b970dd9b531db71be5996004546040516108f391906131b6565b60405180910390a15050565b6001546001600160a01b031681565b6844656274436163686560b81b81565b60606000806000610961868680806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611a2792505050565b9299919850965090945092505050565b606061097b610b7f565b905060005b8151811015610ac357600082828151811061099757fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016109d991906130ef565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610a059291906131ed565b60206040518083038186803b158015610a1d57600080fd5b505afa158015610a31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a5591908101906128dc565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890610ab190849084906131c4565b60405180910390a15050600101610980565b5050565b600080610ad2611b85565b915091509091565b6001546001600160a01b03163314610b0d5760405162461bcd60e51b8152600401610b049061323c565b60405180910390fd5b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92610b50926001600160a01b0391821692911690613116565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b606080610b8a611dcd565b60408051600980825261014082019092529192506060919060208201610120803883390190505090506524b9b9bab2b960d11b81600081518110610bca57fe5b6020026020010181815250506822bc31b430b733b2b960b91b81600181518110610bf057fe5b6020026020010181815250506c45786368616e6765526174657360981b81600281518110610c1a57fe5b6020026020010181815250506b53797374656d53746174757360a01b81600381518110610c4357fe5b6020026020010181815250507021b7b63630ba32b930b626b0b730b3b2b960791b81600481518110610c7157fe5b6020026020010181815250506d57726170706572466163746f727960901b81600581518110610c9c57fe5b6020026020010181815250506b22ba3432b92bb930b83832b960a11b81600681518110610cc557fe5b60200260200101818152505073233aba3ab932b9a6b0b935b2ba26b0b730b3b2b960611b81600781518110610cf657fe5b60200260200101818152505073223cb730b6b4b1a9bcb73a342932b232b2b6b2b960611b81600881518110610d2757fe5b602002602001018181525050610d3d8282611e1e565b9250505090565b6000546001600160a01b031681565b610d5b611590565b6000610d6561175a565b6001600160a01b03166332608039836040518263ffffffff1660e01b8152600401610d9091906131b6565b60206040518083038186803b158015610da857600080fd5b505afa158015610dbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610de09190810190612b74565b6001600160a01b031614610e065760405162461bcd60e51b8152600401610b04906132ec565b600090815260056020526040812055565b610e1f611eda565b600082815260066020526040812054820190811215610e505760405162461bcd60e51b8152600401610b049061322c565b6000928352600660205260409092209190915550565b60085460ff1690565b6000610e79611f95565b905090565b606061046083838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061204592505050565b610ec4611590565b600854610100900460ff1615610eec5760405162461bcd60e51b8152600401610b049061327c565b6008805461ff001916610100179055604080516372cb051f60e01b815290516060916001600160a01b038416916372cb051f91600480820192600092909190829003018186803b158015610f3f57600080fd5b505afa158015610f53573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f7b91908101906129ac565b90506000815111610f9e5760405162461bcd60e51b8152600401610b04906132fc565b6040516307619a5f60e01b81526060906001600160a01b038516906307619a5f90610fcd908590600401613143565b60006040518083038186803b158015610fe557600080fd5b505afa158015610ff9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110219190810190612a16565b905060005b82518110156110ca57600082828151811061103d57fe5b602002602001015111156110c25761109782828151811061105a57fe5b60200260200101516006600086858151811061107257fe5b60200260200101518152602001908152602001600020546119da90919063ffffffff16565b600660008584815181106110a757fe5b60200260200101518152602001908152602001600020819055505b600101611026565b5050505050565b6110d96120cd565b606060006110e561176e565b6001600160a01b031663c8e5bbd585856040518363ffffffff1660e01b8152600401611112929190613131565b60006040518083038186803b15801561112a57600080fd5b505afa15801561113e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111669190810190612a4b565b9150915061054e8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508692508591506116159050565b60075490565b6111b8611479565b6040805160018082528183019092526060916020808301908038833901905050905082816000815181106111e857fe5b6020908102919091010152604080516001808252818301909252606091816020016020820280388339019050509050828160008151811061122557fe5b60200260200101818152505061054e82826000611615565b6112456120cd565b606061124f61175a565b6001600160a01b03166372cb051f6040518163ffffffff1660e01b815260040160006040518083038186803b15801561128757600080fd5b505afa15801561129b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112c391908101906129ac565b9050606060008060006112d585611a27565b6b11955515549154d7d111509560a21b600090815260056020527fb03402a6fc396b42a4a74df8120873f820800f1398191168ef707a9051d6d76e849055845194985092965090945092508491905b8181101561138e57600087828151811061133a57fe5b6020026020010151905061135781856119da90919063ffffffff16565b935080600560008b858151811061136a57fe5b60209081029190910181015182528101919091526040016000205550600101611324565b506c115610d31551115117d1115095609a1b600090815260056020527fbca14b7b4212dd98a4b255832d862779dccd9aba14592c2e2c4e62d4efc07bc78590556113de838663ffffffff61213316565b6004819055426007556040519091507f294a7c394e53042c7d754779562747d93b41db019dd4b970dd9b531db71be5999061141a9083906131b6565b60405180910390a17fc481e742c89630d4b1a5ed3a0fc624c1c41ed463bd00ac26a7e93c71e932126f4260405161145191906131b6565b60405180910390a1611462846114b3565b5050505050505050565b6000610e796007546119b6565b61148161175a565b6001600160a01b0316336001600160a01b0316146114b15760405162461bcd60e51b8152600401610b04906132dc565b565b60085460ff16151581151514610409576008805460ff19168215159081179091556040517f8eebec690c34bbf0fe0d5b93e442beaf16bdaf99052569581de2dcb3e31a53a790600090a250565b6060600082519050606081604051908082528060200260200182016040528015611534578160200160208202803883390190505b50905060005b82811015611588576006600086838151811061155257fe5b602002602001015181526020019081526020016000205482828151811061157557fe5b602090810291909101015260010161153a565b509392505050565b6000546001600160a01b031633146114b15760405162461bcd60e51b8152600401610b04906132bc565b6115c261175a565b6001600160a01b0316336001600160a01b031614806115f957506115e461214e565b6001600160a01b0316336001600160a01b0316145b6114b15760405162461bcd60e51b8152600401610b049061324c565b8251825181146116375760405162461bcd60e51b8152600401610b04906132ac565b60008060606116468787612165565b905060005b848110156116d557600088828151811061166157fe5b60200260200101519050600083838151811061167957fe5b602002602001015190506116a96005600084815260200190815260200160002054876119da90919063ffffffff16565b95506116bb858263ffffffff6119da16565b60009283526005602052604090922055925060010161164b565b5081831461174257600454611700846116f4838663ffffffff6119da16565b9063ffffffff6119ff16565b9050806004819055507f294a7c394e53042c7d754779562747d93b41db019dd4b970dd9b531db71be5998160405161173891906131b6565b60405180910390a1505b841561175157611751856114b3565b50505050505050565b6000610e796524b9b9bab2b960d11b6124f0565b6000610e796c45786368616e6765526174657360981b6124f0565b60008060008061179761254d565b6001600160a01b0316631e33fc6b6040518163ffffffff1660e01b8152600401604080518083038186803b1580156117ce57600080fd5b505afa1580156117e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118069190810190612b92565b9150915060008061181561254d565b6001600160a01b031663ad79a8586040518163ffffffff1660e01b8152600401604080518083038186803b15801561184c57600080fd5b505afa158015611860573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118849190810190612b92565b9150915086806118915750825b806118995750805b94506118ab848363ffffffff6119da16565b95506119356118b861256c565b6001600160a01b031663ee5f3f5c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156118f057600080fd5b505afa158015611904573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506119289190810190612af6565b879063ffffffff6119da16565b955060005b89518110156119a95761199f6119928a838151811061195557fe5b6020026020010151600660008e868151811061196d57fe5b602002602001015181526020019081526020016000205461258690919063ffffffff16565b889063ffffffff6119da16565b965060010161193a565b5050505050935093915050565b60008142036119c3611f95565b10806104635750501590565b60006104638261259b565b6000828201838110156104605760405162461bcd60e51b8152600401610b049061325c565b600082821115611a215760405162461bcd60e51b8152600401610b049061326c565b50900390565b6060600080600060606000611a3a61176e565b6001600160a01b031663c8e5bbd5886040518263ffffffff1660e01b8152600401611a659190613143565b60006040518083038186803b158015611a7d57600080fd5b505afa158015611a91573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ab99190810190612a4b565b915091506060611ac98884612165565b9050600080611ad98a8686611789565b91509150600080611ae86125b1565b6001600160a01b031663fc7b9c186040518163ffffffff1660e01b8152600401604080518083038186803b158015611b1f57600080fd5b505afa158015611b33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b579190810190612b92565b915091508482858880611b675750835b80611b6f5750855b9a509a509a509a50505050505050509193509193565b6000806060611b9261175a565b6001600160a01b03166372cb051f6040518163ffffffff1660e01b815260040160006040518083038186803b158015611bca57600080fd5b505afa158015611bde573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c0691908101906129ac565b905060606000611c1461176e565b6001600160a01b031663c8e5bbd5846040518263ffffffff1660e01b8152600401611c3f9190613143565b60006040518083038186803b158015611c5757600080fd5b505afa158015611c6b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c939190810190612a4b565b915091506060611ca38484612165565b9050600080611cb3868686611789565b845191935091506000805b82811015611cf657611cec868281518110611cd557fe5b6020026020010151836119da90919063ffffffff16565b9150600101611cbe565b50600080611d026125b1565b6001600160a01b031663fc7b9c186040518163ffffffff1660e01b8152600401604080518083038186803b158015611d3957600080fd5b505afa158015611d4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611d719190810190612b92565b9092509050611d86838363ffffffff6119da16565b9250858310611da457611d9f838763ffffffff6119ff16565b611da7565b60005b9250828880611db35750815b80611dbb5750855b9b509b50505050505050505050509091565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110611e0f57fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015611e4e578160200160208202803883390190505b50905060005b8351811015611e9057838181518110611e6957fe5b6020026020010151828281518110611e7d57fe5b6020908102919091010152600101611e54565b5060005b8251811015611ed357828181518110611ea957fe5b6020026020010151828286510181518110611ec057fe5b6020908102919091010152600101611e94565b5092915050565b6000611ee46125d3565b6001600160a01b031663e0aa2797336040518263ffffffff1660e01b8152600401611f0f9190613108565b60206040518083038186803b158015611f2757600080fd5b505afa158015611f3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f5f9190810190612aba565b6000549091506001600160a01b031633148080611f795750815b610ac35760405162461bcd60e51b8152600401610b049061329c565b6000611f9f6125ef565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7464656274536e617073686f745374616c6554696d6560581b6040518363ffffffff1660e01b8152600401611ff59291906131d2565b60206040518083038186803b15801561200d57600080fd5b505afa158015612021573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e799190810190612af6565b6060600082519050606081604051908082528060200260200182016040528015612079578160200160208202803883390190505b50905060005b82811015611588576005600086838151811061209757fe5b60200260200101518152602001908152602001600020548282815181106120ba57fe5b602090810291909101015260010161207f565b6000546001600160a01b031633146114b1576120e761260c565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b15801561211f57600080fd5b505afa15801561054e573d6000803e3d6000fd5b60008282101561214557818303610460565b50600092915050565b6000610e796822bc31b430b733b2b960b91b6124f0565b606060008351905080604051908082528060200260200182016040528015612197578160200160208202803883390190505b50915060606121a461175a565b6001600160a01b0316633b6afe40866040518263ffffffff1660e01b81526004016121cf9190613143565b60006040518083038186803b1580156121e757600080fd5b505afa1580156121fb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261222391908101906129e1565b9050600061222f612626565b6001600160a01b0316634c74183c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561226757600080fd5b505afa15801561227b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061229f9190810190612af6565b905060005b838110156124e65760008382815181106122ba57fe5b6020026020010151905060006001600160a01b0316816001600160a01b031614156122f75760405162461bcd60e51b8152600401610b049061328c565b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561233257600080fd5b505afa158015612346573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061236a9190810190612af6565b9050600061239489858151811061237d57fe5b60200260200101518361258690919063ffffffff16565b90506000631cd554d160e21b8786815181106123ac57fe5b60200260200101516001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b1580156123ec57600080fd5b505afa158015612400573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124249190810190612af6565b14156124ab57732ad7ccaac0eeb396c3a5fc2b73a885435688c0d563907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561246e57600080fd5b505af4158015612482573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124a69190810190612af6565b6124ad565b855b90506124bf828263ffffffff61258616565b8986815181106124cb57fe5b60209081029190910101525050600190920191506122a49050565b5050505092915050565b60008181526003602090815260408083205490516001600160a01b039091169182151591612520918691016130cf565b60405160208183030381529060405290611ed35760405162461bcd60e51b8152600401610b04919061321b565b6000610e797021b7b63630ba32b930b626b0b730b3b2b960791b6124f0565b6000610e796b22ba3432b92bb930b83832b960a11b6124f0565b60006104608383670de0b6b3a7640000612648565b60008082126125aa5781610463565b5060000390565b6000610e7973233aba3ab932b9a6b0b935b2ba26b0b730b3b2b960611b6124f0565b6000610e796d57726170706572466163746f727960901b6124f0565b6000610e796e466c657869626c6553746f7261676560881b6124f0565b6000610e796b53797374656d53746174757360a01b6124f0565b6000610e7973223cb730b6b4b1a9bcb73a342932b232b2b6b2b960611b6124f0565b600080600a830461265f868663ffffffff61268616565b8161266657fe5b0490506005600a82061061267857600a015b600a900490505b9392505050565b60008261269557506000610463565b828202828482816126a257fe5b04146104605760405162461bcd60e51b8152600401610b04906132cc565b803561046381613423565b805161046381613423565b60008083601f8401126126e857600080fd5b50813567ffffffffffffffff81111561270057600080fd5b60208301915083602082028301111561271857600080fd5b9250929050565b600082601f83011261273057600080fd5b815161274361273e82613376565b61334f565b9150818183526020840193506020810190508385602084028201111561276857600080fd5b60005b838110156124e6578161277e8882612895565b845250602092830192919091019060010161276b565b600082601f8301126127a557600080fd5b81516127b361273e82613376565b915081818352602084019350602081019050838560208402820111156127d857600080fd5b60005b838110156124e657816127ee88826128ab565b84525060209283019291909101906001016127db565b600082601f83011261281557600080fd5b815161282361273e82613376565b9150818183526020840193506020810190508385602084028201111561284857600080fd5b60005b838110156124e6578161285e8882612895565b845250602092830192919091019060010161284b565b803561046381613437565b805161046381613437565b803561046381613440565b805161046381613440565b803561046381613449565b805161046381613449565b6000602082840312156128c857600080fd5b60006128d484846126c0565b949350505050565b6000602082840312156128ee57600080fd5b60006128d484846126cb565b6000806020838503121561290d57600080fd5b823567ffffffffffffffff81111561292457600080fd5b612930858286016126d6565b92509250509250929050565b6000806000806040858703121561295257600080fd5b843567ffffffffffffffff81111561296957600080fd5b612975878288016126d6565b9450945050602085013567ffffffffffffffff81111561299457600080fd5b6129a0878288016126d6565b95989497509550505050565b6000602082840312156129be57600080fd5b815167ffffffffffffffff8111156129d557600080fd5b6128d48482850161271f565b6000602082840312156129f357600080fd5b815167ffffffffffffffff811115612a0a57600080fd5b6128d484828501612794565b600060208284031215612a2857600080fd5b815167ffffffffffffffff811115612a3f57600080fd5b6128d484828501612804565b60008060408385031215612a5e57600080fd5b825167ffffffffffffffff811115612a7557600080fd5b612a8185828601612804565b9250506020612a928582860161287f565b9150509250929050565b600060208284031215612aae57600080fd5b60006128d48484612874565b600060208284031215612acc57600080fd5b60006128d4848461287f565b600060208284031215612aea57600080fd5b60006128d4848461288a565b600060208284031215612b0857600080fd5b60006128d48484612895565b60008060408385031215612b2757600080fd5b6000612b33858561288a565b9250506020612a928582860161288a565b60008060408385031215612b5757600080fd5b6000612b6385856128a0565b9250506020612a92858286016128a0565b600060208284031215612b8657600080fd5b60006128d484846128ab565b60008060408385031215612ba557600080fd5b6000612a818585612895565b6000612bbd8383612cc6565b505060200190565b612bce816133d6565b82525050565b612bce816133af565b6000612be983856133a1565b93506001600160fb1b03831115612bff57600080fd5b602083029250612c108385846133e1565b50500190565b6000612c218261339d565b612c2b81856133a1565b9350612c3683613397565b8060005b83811015612c64578151612c4e8882612bb1565b9750612c5983613397565b925050600101612c3a565b509495945050505050565b6000612c7a8261339d565b612c8481856133a1565b9350612c8f83613397565b8060005b83811015612c64578151612ca78882612bb1565b9750612cb283613397565b925050600101612c93565b612bce816133ba565b612bce8161041f565b612bce612cdb8261041f565b61041f565b612bce816133bf565b6000612cf48261339d565b612cfe81856133a1565b9350612d0e8185602086016133ed565b612d1781613419565b9093019392505050565b6000612d2e6024836133a1565b7f4578636c7564656420646562742063616e6e6f74206265636f6d65206e6567618152637469766560e01b602082015260400192915050565b6000612d746035836133a1565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000612dcb6021836133a1565b7f53656e646572206973206e6f7420497373756572206f722045786368616e67658152603960f91b602082015260400192915050565b6000612e0e601b836133a1565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000612e47601e836133a1565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b6000612e806011836133aa565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b6000612ead6013836133a1565b72185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b815260200192915050565b6000612edc6014836133a1565b7314de5b9d1a08191bd95cc81b9bdd08195e1a5cdd60621b815260200192915050565b6000612f0c601f836133a1565b7f4f6e6c7920646562742069737375657273206d61792063616c6c207468697300815260200192915050565b6000612f45601a836133a1565b7f496e707574206172726179206c656e6774687320646966666572000000000000815260200192915050565b6000612f7e602f836133a1565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b6000612fcf6021836133a1565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b60006130126014836133a1565b7329b2b73232b91034b9903737ba1024b9b9bab2b960611b815260200192915050565b60006130426019836133aa565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b600061307b600c836133a1565b6b53796e74682065786973747360a01b815260200192915050565b60006130a3601d836133a1565b7f70726576696f75732049737375657220686173206e6f2073796e746873000000815260200192915050565b60006130da82612e73565b91506130e68284612ccf565b50602001919050565b60006130da82613035565b602081016104638284612bd4565b602081016104638284612bc5565b604081016131248285612bd4565b61267f6020830184612bd4565b602080825281016128d4818486612bdd565b602080825281016104608184612c16565b602080825281016104608184612c6f565b608080825281016131768187612c6f565b90506131856020830186612cc6565b6131926040830185612cc6565b61319f6060830184612cbd565b95945050505050565b602081016104638284612cbd565b602081016104638284612cc6565b604081016131248285612cc6565b604081016131e08285612cc6565b61267f6020830184612cc6565b604081016131fb8285612cc6565b81810360208301526128d48184612ce9565b602081016104638284612ce0565b602080825281016104608184612ce9565b6020808252810161046381612d21565b6020808252810161046381612d67565b6020808252810161046381612dbe565b6020808252810161046381612e01565b6020808252810161046381612e3a565b6020808252810161046381612ea0565b6020808252810161046381612ecf565b6020808252810161046381612eff565b6020808252810161046381612f38565b6020808252810161046381612f71565b6020808252810161046381612fc2565b6020808252810161046381613005565b602080825281016104638161306e565b6020808252810161046381613096565b6040810161331a8285612cc6565b61267f6020830184612cbd565b608081016133358287612cc6565b6133426020830186612cc6565b6131926040830185612cbd565b60405181810167ffffffffffffffff8111828210171561336e57600080fd5b604052919050565b600067ffffffffffffffff82111561338d57600080fd5b5060209081020190565b60200190565b5190565b90815260200190565b919050565b6000610463826133ca565b151590565b6000610463826133af565b6001600160a01b031690565b6000610463826133bf565b82818337506000910152565b60005b838110156134085781810151838201526020016133f0565b8381111561054e5750506000910152565b601f01601f191690565b61342c816133af565b811461040957600080fd5b61342c816133ba565b61342c8161041f565b61342c816133bf56fe74c62d09fbc50aefae0794a9a068f786a692826fbdfe63828ec23a875865823fa365627a7a72315820c9692a6ac6feab328e598aab96cad439088846572c40ebeb03dc2aee35e943d26c6578706572696d656e74616cf564736f6c6343000510004000000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9000000000000000000000000529c553ef2d0370279dc8abf19702b98b166d252

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101e55760003560e01c8063741853601161010f578063af5355d8116100a2578063d0fffafd11610071578063d0fffafd146103cd578063d685743a146103d5578063e3476cd4146103e8578063fc524773146103f0576101e5565b8063af5355d81461038c578063b13cd78514610394578063b7224ec7146103a7578063cda218c7146103ba576101e5565b80638da5cb5b116100de5780638da5cb5b146103565780638dd5bfbc1461035e5780639e3b92ca14610371578063a5f27edb14610384576101e5565b80637418536014610329578063759076e51461033157806379ba509714610339578063899ffef414610341576101e5565b80632992dba21161018757806342c7b8191161015657806342c7b819146102d657806353a47bb7146102e9578063614d08f8146102fe5780636bf7c43514610306576101e5565b80632992dba21461028b5780632af64bd3146102a1578063392e53cd146102b65780633a900a2e146102be576101e5565b806307619a5f116101c357806307619a5f146102325780630fb38465146102525780631627540c1461026557806317b38db414610278576101e5565b806304bd11e5146101ea57806304f3bcec146101ff578063053932621461021d575b600080fd5b6101fd6101f8366004612a9c565b6103f8565b005b61020761040c565b604051610214919061320d565b60405180910390f35b61022561041b565b60405161021491906131b6565b6102456102403660046128fa565b610422565b6040516102149190613154565b610225610260366004612ad8565b610469565b6101fd6102733660046128b6565b61047b565b6101fd61028636600461293c565b6104d9565b610293610554565b60405161021492919061330c565b6102a961067c565b60405161021491906131a8565b6102a9610793565b6102c66107a1565b6040516102149493929190613327565b6101fd6102e4366004612ad8565b6107d2565b6102f16108ff565b60405161021491906130fa565b61022561090e565b6103196103143660046128fa565b61091e565b6040516102149493929190613165565b6101fd610971565b610293610ac7565b6101fd610ada565b610349610b7f565b6040516102149190613143565b6102f1610d44565b6101fd61036c366004612ad8565b610d53565b6101fd61037f366004612b14565b610e17565b6102a9610e66565b610225610e6f565b6102456103a23660046128fa565b610e7e565b6101fd6103b5366004612b44565b610ebc565b6101fd6103c83660046128fa565b6110d1565b6102256111aa565b6101fd6103e3366004612b14565b6111b0565b6101fd61123d565b6102a961146c565b610400611479565b610409816114b3565b50565b6002546001600160a01b031681565b6004545b90565b606061046083838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061150092505050565b90505b92915050565b60009081526005602052604090205490565b610483611590565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906104ce9083906130fa565b60405180910390a150565b6104e16115ba565b61054e8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080880282810182019093528782529093508792508691829185019084908082843760009201829052509250611615915050565b50505050565b600080606061056161175a565b6001600160a01b03166372cb051f6040518163ffffffff1660e01b815260040160006040518083038186803b15801561059957600080fd5b505afa1580156105ad573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105d591908101906129ac565b9050606060006105e361176e565b6001600160a01b031663c8e5bbd5846040518263ffffffff1660e01b815260040161060e9190613143565b60006040518083038186803b15801561062657600080fd5b505afa15801561063a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106629190810190612a4b565b91509150610671838383611789565b945094505050509091565b60006060610688610b7f565b905060005b815181101561078a5760008282815181106106a457fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a721906106f59085906004016131b6565b60206040518083038186803b15801561070d57600080fd5b505afa158015610721573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061074591908101906128dc565b6001600160a01b031614158061077057506000818152600360205260409020546001600160a01b0316155b15610781576000935050505061041f565b5060010161068d565b50600191505090565b600854610100900460ff1681565b6007546004546008546000928392839283929190829060ff166107c3826119b6565b94509450945094505090919293565b6107da611479565b60006107e5826119cf565b9050600082131561085b57631cd554d160e21b600052600560205260008051602061345383398151915254610820908263ffffffff6119da16565b631cd554d160e21b600052600560205260008051602061345383398151915255600454610853908263ffffffff6119da16565b6004556108c2565b631cd554d160e21b60005260056020526000805160206134538339815191525461088b908263ffffffff6119ff16565b631cd554d160e21b6000526005602052600080516020613453833981519152556004546108be908263ffffffff6119ff16565b6004555b7f294a7c394e53042c7d754779562747d93b41db019dd4b970dd9b531db71be5996004546040516108f391906131b6565b60405180910390a15050565b6001546001600160a01b031681565b6844656274436163686560b81b81565b60606000806000610961868680806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611a2792505050565b9299919850965090945092505050565b606061097b610b7f565b905060005b8151811015610ac357600082828151811061099757fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016109d991906130ef565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610a059291906131ed565b60206040518083038186803b158015610a1d57600080fd5b505afa158015610a31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a5591908101906128dc565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890610ab190849084906131c4565b60405180910390a15050600101610980565b5050565b600080610ad2611b85565b915091509091565b6001546001600160a01b03163314610b0d5760405162461bcd60e51b8152600401610b049061323c565b60405180910390fd5b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92610b50926001600160a01b0391821692911690613116565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b606080610b8a611dcd565b60408051600980825261014082019092529192506060919060208201610120803883390190505090506524b9b9bab2b960d11b81600081518110610bca57fe5b6020026020010181815250506822bc31b430b733b2b960b91b81600181518110610bf057fe5b6020026020010181815250506c45786368616e6765526174657360981b81600281518110610c1a57fe5b6020026020010181815250506b53797374656d53746174757360a01b81600381518110610c4357fe5b6020026020010181815250507021b7b63630ba32b930b626b0b730b3b2b960791b81600481518110610c7157fe5b6020026020010181815250506d57726170706572466163746f727960901b81600581518110610c9c57fe5b6020026020010181815250506b22ba3432b92bb930b83832b960a11b81600681518110610cc557fe5b60200260200101818152505073233aba3ab932b9a6b0b935b2ba26b0b730b3b2b960611b81600781518110610cf657fe5b60200260200101818152505073223cb730b6b4b1a9bcb73a342932b232b2b6b2b960611b81600881518110610d2757fe5b602002602001018181525050610d3d8282611e1e565b9250505090565b6000546001600160a01b031681565b610d5b611590565b6000610d6561175a565b6001600160a01b03166332608039836040518263ffffffff1660e01b8152600401610d9091906131b6565b60206040518083038186803b158015610da857600080fd5b505afa158015610dbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610de09190810190612b74565b6001600160a01b031614610e065760405162461bcd60e51b8152600401610b04906132ec565b600090815260056020526040812055565b610e1f611eda565b600082815260066020526040812054820190811215610e505760405162461bcd60e51b8152600401610b049061322c565b6000928352600660205260409092209190915550565b60085460ff1690565b6000610e79611f95565b905090565b606061046083838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061204592505050565b610ec4611590565b600854610100900460ff1615610eec5760405162461bcd60e51b8152600401610b049061327c565b6008805461ff001916610100179055604080516372cb051f60e01b815290516060916001600160a01b038416916372cb051f91600480820192600092909190829003018186803b158015610f3f57600080fd5b505afa158015610f53573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f7b91908101906129ac565b90506000815111610f9e5760405162461bcd60e51b8152600401610b04906132fc565b6040516307619a5f60e01b81526060906001600160a01b038516906307619a5f90610fcd908590600401613143565b60006040518083038186803b158015610fe557600080fd5b505afa158015610ff9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110219190810190612a16565b905060005b82518110156110ca57600082828151811061103d57fe5b602002602001015111156110c25761109782828151811061105a57fe5b60200260200101516006600086858151811061107257fe5b60200260200101518152602001908152602001600020546119da90919063ffffffff16565b600660008584815181106110a757fe5b60200260200101518152602001908152602001600020819055505b600101611026565b5050505050565b6110d96120cd565b606060006110e561176e565b6001600160a01b031663c8e5bbd585856040518363ffffffff1660e01b8152600401611112929190613131565b60006040518083038186803b15801561112a57600080fd5b505afa15801561113e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111669190810190612a4b565b9150915061054e8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508692508591506116159050565b60075490565b6111b8611479565b6040805160018082528183019092526060916020808301908038833901905050905082816000815181106111e857fe5b6020908102919091010152604080516001808252818301909252606091816020016020820280388339019050509050828160008151811061122557fe5b60200260200101818152505061054e82826000611615565b6112456120cd565b606061124f61175a565b6001600160a01b03166372cb051f6040518163ffffffff1660e01b815260040160006040518083038186803b15801561128757600080fd5b505afa15801561129b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112c391908101906129ac565b9050606060008060006112d585611a27565b6b11955515549154d7d111509560a21b600090815260056020527fb03402a6fc396b42a4a74df8120873f820800f1398191168ef707a9051d6d76e849055845194985092965090945092508491905b8181101561138e57600087828151811061133a57fe5b6020026020010151905061135781856119da90919063ffffffff16565b935080600560008b858151811061136a57fe5b60209081029190910181015182528101919091526040016000205550600101611324565b506c115610d31551115117d1115095609a1b600090815260056020527fbca14b7b4212dd98a4b255832d862779dccd9aba14592c2e2c4e62d4efc07bc78590556113de838663ffffffff61213316565b6004819055426007556040519091507f294a7c394e53042c7d754779562747d93b41db019dd4b970dd9b531db71be5999061141a9083906131b6565b60405180910390a17fc481e742c89630d4b1a5ed3a0fc624c1c41ed463bd00ac26a7e93c71e932126f4260405161145191906131b6565b60405180910390a1611462846114b3565b5050505050505050565b6000610e796007546119b6565b61148161175a565b6001600160a01b0316336001600160a01b0316146114b15760405162461bcd60e51b8152600401610b04906132dc565b565b60085460ff16151581151514610409576008805460ff19168215159081179091556040517f8eebec690c34bbf0fe0d5b93e442beaf16bdaf99052569581de2dcb3e31a53a790600090a250565b6060600082519050606081604051908082528060200260200182016040528015611534578160200160208202803883390190505b50905060005b82811015611588576006600086838151811061155257fe5b602002602001015181526020019081526020016000205482828151811061157557fe5b602090810291909101015260010161153a565b509392505050565b6000546001600160a01b031633146114b15760405162461bcd60e51b8152600401610b04906132bc565b6115c261175a565b6001600160a01b0316336001600160a01b031614806115f957506115e461214e565b6001600160a01b0316336001600160a01b0316145b6114b15760405162461bcd60e51b8152600401610b049061324c565b8251825181146116375760405162461bcd60e51b8152600401610b04906132ac565b60008060606116468787612165565b905060005b848110156116d557600088828151811061166157fe5b60200260200101519050600083838151811061167957fe5b602002602001015190506116a96005600084815260200190815260200160002054876119da90919063ffffffff16565b95506116bb858263ffffffff6119da16565b60009283526005602052604090922055925060010161164b565b5081831461174257600454611700846116f4838663ffffffff6119da16565b9063ffffffff6119ff16565b9050806004819055507f294a7c394e53042c7d754779562747d93b41db019dd4b970dd9b531db71be5998160405161173891906131b6565b60405180910390a1505b841561175157611751856114b3565b50505050505050565b6000610e796524b9b9bab2b960d11b6124f0565b6000610e796c45786368616e6765526174657360981b6124f0565b60008060008061179761254d565b6001600160a01b0316631e33fc6b6040518163ffffffff1660e01b8152600401604080518083038186803b1580156117ce57600080fd5b505afa1580156117e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118069190810190612b92565b9150915060008061181561254d565b6001600160a01b031663ad79a8586040518163ffffffff1660e01b8152600401604080518083038186803b15801561184c57600080fd5b505afa158015611860573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118849190810190612b92565b9150915086806118915750825b806118995750805b94506118ab848363ffffffff6119da16565b95506119356118b861256c565b6001600160a01b031663ee5f3f5c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156118f057600080fd5b505afa158015611904573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506119289190810190612af6565b879063ffffffff6119da16565b955060005b89518110156119a95761199f6119928a838151811061195557fe5b6020026020010151600660008e868151811061196d57fe5b602002602001015181526020019081526020016000205461258690919063ffffffff16565b889063ffffffff6119da16565b965060010161193a565b5050505050935093915050565b60008142036119c3611f95565b10806104635750501590565b60006104638261259b565b6000828201838110156104605760405162461bcd60e51b8152600401610b049061325c565b600082821115611a215760405162461bcd60e51b8152600401610b049061326c565b50900390565b6060600080600060606000611a3a61176e565b6001600160a01b031663c8e5bbd5886040518263ffffffff1660e01b8152600401611a659190613143565b60006040518083038186803b158015611a7d57600080fd5b505afa158015611a91573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ab99190810190612a4b565b915091506060611ac98884612165565b9050600080611ad98a8686611789565b91509150600080611ae86125b1565b6001600160a01b031663fc7b9c186040518163ffffffff1660e01b8152600401604080518083038186803b158015611b1f57600080fd5b505afa158015611b33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b579190810190612b92565b915091508482858880611b675750835b80611b6f5750855b9a509a509a509a50505050505050509193509193565b6000806060611b9261175a565b6001600160a01b03166372cb051f6040518163ffffffff1660e01b815260040160006040518083038186803b158015611bca57600080fd5b505afa158015611bde573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c0691908101906129ac565b905060606000611c1461176e565b6001600160a01b031663c8e5bbd5846040518263ffffffff1660e01b8152600401611c3f9190613143565b60006040518083038186803b158015611c5757600080fd5b505afa158015611c6b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c939190810190612a4b565b915091506060611ca38484612165565b9050600080611cb3868686611789565b845191935091506000805b82811015611cf657611cec868281518110611cd557fe5b6020026020010151836119da90919063ffffffff16565b9150600101611cbe565b50600080611d026125b1565b6001600160a01b031663fc7b9c186040518163ffffffff1660e01b8152600401604080518083038186803b158015611d3957600080fd5b505afa158015611d4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611d719190810190612b92565b9092509050611d86838363ffffffff6119da16565b9250858310611da457611d9f838763ffffffff6119ff16565b611da7565b60005b9250828880611db35750815b80611dbb5750855b9b509b50505050505050505050509091565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110611e0f57fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015611e4e578160200160208202803883390190505b50905060005b8351811015611e9057838181518110611e6957fe5b6020026020010151828281518110611e7d57fe5b6020908102919091010152600101611e54565b5060005b8251811015611ed357828181518110611ea957fe5b6020026020010151828286510181518110611ec057fe5b6020908102919091010152600101611e94565b5092915050565b6000611ee46125d3565b6001600160a01b031663e0aa2797336040518263ffffffff1660e01b8152600401611f0f9190613108565b60206040518083038186803b158015611f2757600080fd5b505afa158015611f3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f5f9190810190612aba565b6000549091506001600160a01b031633148080611f795750815b610ac35760405162461bcd60e51b8152600401610b049061329c565b6000611f9f6125ef565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7464656274536e617073686f745374616c6554696d6560581b6040518363ffffffff1660e01b8152600401611ff59291906131d2565b60206040518083038186803b15801561200d57600080fd5b505afa158015612021573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e799190810190612af6565b6060600082519050606081604051908082528060200260200182016040528015612079578160200160208202803883390190505b50905060005b82811015611588576005600086838151811061209757fe5b60200260200101518152602001908152602001600020548282815181106120ba57fe5b602090810291909101015260010161207f565b6000546001600160a01b031633146114b1576120e761260c565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b15801561211f57600080fd5b505afa15801561054e573d6000803e3d6000fd5b60008282101561214557818303610460565b50600092915050565b6000610e796822bc31b430b733b2b960b91b6124f0565b606060008351905080604051908082528060200260200182016040528015612197578160200160208202803883390190505b50915060606121a461175a565b6001600160a01b0316633b6afe40866040518263ffffffff1660e01b81526004016121cf9190613143565b60006040518083038186803b1580156121e757600080fd5b505afa1580156121fb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261222391908101906129e1565b9050600061222f612626565b6001600160a01b0316634c74183c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561226757600080fd5b505afa15801561227b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061229f9190810190612af6565b905060005b838110156124e65760008382815181106122ba57fe5b6020026020010151905060006001600160a01b0316816001600160a01b031614156122f75760405162461bcd60e51b8152600401610b049061328c565b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561233257600080fd5b505afa158015612346573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061236a9190810190612af6565b9050600061239489858151811061237d57fe5b60200260200101518361258690919063ffffffff16565b90506000631cd554d160e21b8786815181106123ac57fe5b60200260200101516001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b1580156123ec57600080fd5b505afa158015612400573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124249190810190612af6565b14156124ab57732ad7ccaac0eeb396c3a5fc2b73a885435688c0d563907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561246e57600080fd5b505af4158015612482573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124a69190810190612af6565b6124ad565b855b90506124bf828263ffffffff61258616565b8986815181106124cb57fe5b60209081029190910101525050600190920191506122a49050565b5050505092915050565b60008181526003602090815260408083205490516001600160a01b039091169182151591612520918691016130cf565b60405160208183030381529060405290611ed35760405162461bcd60e51b8152600401610b04919061321b565b6000610e797021b7b63630ba32b930b626b0b730b3b2b960791b6124f0565b6000610e796b22ba3432b92bb930b83832b960a11b6124f0565b60006104608383670de0b6b3a7640000612648565b60008082126125aa5781610463565b5060000390565b6000610e7973233aba3ab932b9a6b0b935b2ba26b0b730b3b2b960611b6124f0565b6000610e796d57726170706572466163746f727960901b6124f0565b6000610e796e466c657869626c6553746f7261676560881b6124f0565b6000610e796b53797374656d53746174757360a01b6124f0565b6000610e7973223cb730b6b4b1a9bcb73a342932b232b2b6b2b960611b6124f0565b600080600a830461265f868663ffffffff61268616565b8161266657fe5b0490506005600a82061061267857600a015b600a900490505b9392505050565b60008261269557506000610463565b828202828482816126a257fe5b04146104605760405162461bcd60e51b8152600401610b04906132cc565b803561046381613423565b805161046381613423565b60008083601f8401126126e857600080fd5b50813567ffffffffffffffff81111561270057600080fd5b60208301915083602082028301111561271857600080fd5b9250929050565b600082601f83011261273057600080fd5b815161274361273e82613376565b61334f565b9150818183526020840193506020810190508385602084028201111561276857600080fd5b60005b838110156124e6578161277e8882612895565b845250602092830192919091019060010161276b565b600082601f8301126127a557600080fd5b81516127b361273e82613376565b915081818352602084019350602081019050838560208402820111156127d857600080fd5b60005b838110156124e657816127ee88826128ab565b84525060209283019291909101906001016127db565b600082601f83011261281557600080fd5b815161282361273e82613376565b9150818183526020840193506020810190508385602084028201111561284857600080fd5b60005b838110156124e6578161285e8882612895565b845250602092830192919091019060010161284b565b803561046381613437565b805161046381613437565b803561046381613440565b805161046381613440565b803561046381613449565b805161046381613449565b6000602082840312156128c857600080fd5b60006128d484846126c0565b949350505050565b6000602082840312156128ee57600080fd5b60006128d484846126cb565b6000806020838503121561290d57600080fd5b823567ffffffffffffffff81111561292457600080fd5b612930858286016126d6565b92509250509250929050565b6000806000806040858703121561295257600080fd5b843567ffffffffffffffff81111561296957600080fd5b612975878288016126d6565b9450945050602085013567ffffffffffffffff81111561299457600080fd5b6129a0878288016126d6565b95989497509550505050565b6000602082840312156129be57600080fd5b815167ffffffffffffffff8111156129d557600080fd5b6128d48482850161271f565b6000602082840312156129f357600080fd5b815167ffffffffffffffff811115612a0a57600080fd5b6128d484828501612794565b600060208284031215612a2857600080fd5b815167ffffffffffffffff811115612a3f57600080fd5b6128d484828501612804565b60008060408385031215612a5e57600080fd5b825167ffffffffffffffff811115612a7557600080fd5b612a8185828601612804565b9250506020612a928582860161287f565b9150509250929050565b600060208284031215612aae57600080fd5b60006128d48484612874565b600060208284031215612acc57600080fd5b60006128d4848461287f565b600060208284031215612aea57600080fd5b60006128d4848461288a565b600060208284031215612b0857600080fd5b60006128d48484612895565b60008060408385031215612b2757600080fd5b6000612b33858561288a565b9250506020612a928582860161288a565b60008060408385031215612b5757600080fd5b6000612b6385856128a0565b9250506020612a92858286016128a0565b600060208284031215612b8657600080fd5b60006128d484846128ab565b60008060408385031215612ba557600080fd5b6000612a818585612895565b6000612bbd8383612cc6565b505060200190565b612bce816133d6565b82525050565b612bce816133af565b6000612be983856133a1565b93506001600160fb1b03831115612bff57600080fd5b602083029250612c108385846133e1565b50500190565b6000612c218261339d565b612c2b81856133a1565b9350612c3683613397565b8060005b83811015612c64578151612c4e8882612bb1565b9750612c5983613397565b925050600101612c3a565b509495945050505050565b6000612c7a8261339d565b612c8481856133a1565b9350612c8f83613397565b8060005b83811015612c64578151612ca78882612bb1565b9750612cb283613397565b925050600101612c93565b612bce816133ba565b612bce8161041f565b612bce612cdb8261041f565b61041f565b612bce816133bf565b6000612cf48261339d565b612cfe81856133a1565b9350612d0e8185602086016133ed565b612d1781613419565b9093019392505050565b6000612d2e6024836133a1565b7f4578636c7564656420646562742063616e6e6f74206265636f6d65206e6567618152637469766560e01b602082015260400192915050565b6000612d746035836133a1565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000612dcb6021836133a1565b7f53656e646572206973206e6f7420497373756572206f722045786368616e67658152603960f91b602082015260400192915050565b6000612e0e601b836133a1565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000612e47601e836133a1565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b6000612e806011836133aa565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b6000612ead6013836133a1565b72185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b815260200192915050565b6000612edc6014836133a1565b7314de5b9d1a08191bd95cc81b9bdd08195e1a5cdd60621b815260200192915050565b6000612f0c601f836133a1565b7f4f6e6c7920646562742069737375657273206d61792063616c6c207468697300815260200192915050565b6000612f45601a836133a1565b7f496e707574206172726179206c656e6774687320646966666572000000000000815260200192915050565b6000612f7e602f836133a1565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b6000612fcf6021836133a1565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b60006130126014836133a1565b7329b2b73232b91034b9903737ba1024b9b9bab2b960611b815260200192915050565b60006130426019836133aa565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b600061307b600c836133a1565b6b53796e74682065786973747360a01b815260200192915050565b60006130a3601d836133a1565b7f70726576696f75732049737375657220686173206e6f2073796e746873000000815260200192915050565b60006130da82612e73565b91506130e68284612ccf565b50602001919050565b60006130da82613035565b602081016104638284612bd4565b602081016104638284612bc5565b604081016131248285612bd4565b61267f6020830184612bd4565b602080825281016128d4818486612bdd565b602080825281016104608184612c16565b602080825281016104608184612c6f565b608080825281016131768187612c6f565b90506131856020830186612cc6565b6131926040830185612cc6565b61319f6060830184612cbd565b95945050505050565b602081016104638284612cbd565b602081016104638284612cc6565b604081016131248285612cc6565b604081016131e08285612cc6565b61267f6020830184612cc6565b604081016131fb8285612cc6565b81810360208301526128d48184612ce9565b602081016104638284612ce0565b602080825281016104608184612ce9565b6020808252810161046381612d21565b6020808252810161046381612d67565b6020808252810161046381612dbe565b6020808252810161046381612e01565b6020808252810161046381612e3a565b6020808252810161046381612ea0565b6020808252810161046381612ecf565b6020808252810161046381612eff565b6020808252810161046381612f38565b6020808252810161046381612f71565b6020808252810161046381612fc2565b6020808252810161046381613005565b602080825281016104638161306e565b6020808252810161046381613096565b6040810161331a8285612cc6565b61267f6020830184612cbd565b608081016133358287612cc6565b6133426020830186612cc6565b6131926040830185612cbd565b60405181810167ffffffffffffffff8111828210171561336e57600080fd5b604052919050565b600067ffffffffffffffff82111561338d57600080fd5b5060209081020190565b60200190565b5190565b90815260200190565b919050565b6000610463826133ca565b151590565b6000610463826133af565b6001600160a01b031690565b6000610463826133bf565b82818337506000910152565b60005b838110156134085781810151838201526020016133f0565b8381111561054e5750506000910152565b601f01601f191690565b61342c816133af565b811461040957600080fd5b61342c816133ba565b61342c8161041f565b61342c816133bf56fe74c62d09fbc50aefae0794a9a068f786a692826fbdfe63828ec23a875865823fa365627a7a72315820c9692a6ac6feab328e598aab96cad439088846572c40ebeb03dc2aee35e943d26c6578706572696d656e74616cf564736f6c63430005100040

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

00000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9000000000000000000000000529c553ef2d0370279dc8abf19702b98b166d252

-----Decoded View---------------
Arg [0] : _owner (address): 0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9
Arg [1] : _resolver (address): 0x529C553eF2d0370279DC8AbF19702B98b166D252

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9
Arg [1] : 000000000000000000000000529c553ef2d0370279dc8abf19702b98b166d252


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
[ 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.