ETH Price: $3,466.87 (-1.13%)
Gas: 3 Gwei

Contract

0xca68a3D663483515a9D434E854AB59A41b3A523c
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Nominate New Own...168837812023-03-22 14:40:11489 days ago1679496011IN
Synthetix: Issuer 3
0 ETH0.0012786826.96048546
0x60806040168837192023-03-22 14:27:35489 days ago1679495255IN
 Create: Issuer
0 ETH0.1430514226.8456809

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Issuer

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2023-03-22
*/

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

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



pragma solidity ^0.5.16;

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

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

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

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

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

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

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


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


// SPDX-License-Identifier: MIT


/**
 * @dev Wrappers over Solidity's uintXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such 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.
 *
 * Can be combined with {SafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value < 2**128, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value < 2**64, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value < 2**32, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value < 2**16, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value < 2**8, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        require(value < 2**255, "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}


/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, 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/interfaces/isynthetixdebtshare
interface ISynthetixDebtShare {
    // Views

    function currentPeriodId() external view returns (uint128);

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

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

    function balanceOfOnPeriod(address account, uint periodId) external view returns (uint);

    function totalSupply() external view returns (uint);

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

    function sharePercentOnPeriod(address account, uint periodId) external view returns (uint);

    // Mutative functions

    function takeSnapshot(uint128 id) external;

    function mintShare(address account, uint256 amount) external;

    function burnShare(address account, uint256 amount) external;

    function approve(address, uint256) external pure returns (bool);

    function transfer(address to, uint256 amount) external pure returns (bool);

    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);

    function addAuthorizedBroker(address target) external;

    function removeAuthorizedBroker(address target) external;

    function addAuthorizedToSnapshot(address target) external;

    function removeAuthorizedToSnapshot(address target) 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/idelegateapprovals
interface IDelegateApprovals {
    // Views
    function canBurnFor(address authoriser, address delegate) external view returns (bool);

    function canIssueFor(address authoriser, address delegate) external view returns (bool);

    function canClaimFor(address authoriser, address delegate) external view returns (bool);

    function canExchangeFor(address authoriser, address delegate) external view returns (bool);

    // Mutative
    function approveAllDelegatePowers(address delegate) external;

    function removeAllDelegatePowers(address delegate) external;

    function approveBurnOnBehalf(address delegate) external;

    function removeBurnOnBehalf(address delegate) external;

    function approveIssueOnBehalf(address delegate) external;

    function removeIssueOnBehalf(address delegate) external;

    function approveClaimOnBehalf(address delegate) external;

    function removeClaimOnBehalf(address delegate) external;

    function approveExchangeOnBehalf(address delegate) external;

    function removeExchangeOnBehalf(address delegate) 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/ICircuitBreaker
interface ICircuitBreaker {
    // Views
    function isInvalid(address oracleAddress, uint value) external view returns (bool);

    function priceDeviationThresholdFactor() external view returns (uint);

    function isDeviationAboveThreshold(uint base, uint comparison) external view returns (bool);

    function lastValue(address oracleAddress) external view returns (uint);

    function circuitBroken(address oracleAddress) external view returns (bool);

    // Mutative functions
    function resetLastValue(address[] calldata oracleAddresses, uint[] calldata values) external;

    function probeCircuitBreaker(address oracleAddress, uint value) external returns (bool circuitBroken);
}


// https://docs.synthetix.io/contracts/source/interfaces/ihasbalance
interface IHasBalance {
    // Views
    function balanceOf(address account) external view returns (uint);
}


// 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 ILiquidator {
    // Views
    function issuanceRatio() external view returns (uint);

    function liquidationDelay() external view returns (uint);

    function liquidationRatio() external view returns (uint);

    function liquidationEscrowDuration() external view returns (uint);

    function liquidationPenalty() external view returns (uint);

    function selfLiquidationPenalty() external view returns (uint);

    function liquidateReward() external view returns (uint);

    function flagReward() external view returns (uint);

    function liquidationCollateralRatio() external view returns (uint);

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

    function getLiquidationCallerForAccount(address account) external view returns (address);

    function isLiquidationOpen(address account, bool isSelfLiquidation) external view returns (bool);

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

    function calculateAmountToFixCollateral(
        uint debtBalance,
        uint collateral,
        uint penalty
    ) external view returns (uint);

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

    // Mutative Functions
    function flagAccountForLiquidation(address account) external;

    // Restricted: used internally to Synthetix contracts
    function removeAccountInLiquidation(address account) external;

    function checkAndRemoveAccountInLiquidation(address account) external;
}


interface ILiquidatorRewards {
    // Views

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

    // Mutative

    function getReward(address account) external;

    function notifyRewardAmount(uint256 reward) external;

    function updateEntry(address account) external;
}


interface ISynthRedeemer {
    // Rate of redemption - 0 for none
    function redemptions(address synthProxy) external view returns (uint redeemRate);

    // sUSD balance of deprecated token holder
    function balanceOf(IERC20 synthProxy, address account) external view returns (uint balanceOfInsUSD);

    // Full sUSD supply of token
    function totalSupply(IERC20 synthProxy) external view returns (uint totalSupplyInsUSD);

    function redeem(IERC20 synthProxy) external;

    function redeemAll(IERC20[] calldata synthProxies) external;

    function redeemPartial(IERC20 synthProxy, uint amountOfSynth) external;

    // Restricted to Issuer
    function deprecate(IERC20 synthProxy, uint rateToRedeem) external;
}


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


// Inheritance


// Internal references


// https://docs.synthetix.io/contracts/source/contracts/proxy
contract Proxy is Owned {
    Proxyable public target;

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

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

    function _emit(
        bytes calldata callData,
        uint numTopics,
        bytes32 topic1,
        bytes32 topic2,
        bytes32 topic3,
        bytes32 topic4
    ) external onlyTarget {
        uint size = callData.length;
        bytes memory _callData = callData;

        assembly {
            /* The first 32 bytes of callData contain its length (as specified by the abi).
             * Length is assumed to be a uint256 and therefore maximum of 32 bytes
             * in length. It is also leftpadded to be a multiple of 32 bytes.
             * This means moving call_data across 32 bytes guarantees we correctly access
             * the data itself. */
            switch numTopics
                case 0 {
                    log0(add(_callData, 32), size)
                }
                case 1 {
                    log1(add(_callData, 32), size, topic1)
                }
                case 2 {
                    log2(add(_callData, 32), size, topic1, topic2)
                }
                case 3 {
                    log3(add(_callData, 32), size, topic1, topic2, topic3)
                }
                case 4 {
                    log4(add(_callData, 32), size, topic1, topic2, topic3, topic4)
                }
        }
    }

    // solhint-disable no-complex-fallback
    function() external payable {
        // Mutable call setting Proxyable.messageSender as this is using call not delegatecall
        target.setMessageSender(msg.sender);

        assembly {
            let free_ptr := mload(0x40)
            calldatacopy(free_ptr, 0, calldatasize)

            /* We must explicitly forward ether to the underlying contract as well. */
            let result := call(gas, sload(target_slot), callvalue, free_ptr, calldatasize, 0, 0)
            returndatacopy(free_ptr, 0, returndatasize)

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

    modifier onlyTarget {
        require(Proxyable(msg.sender) == target, "Must be proxy target");
        _;
    }

    event TargetUpdated(Proxyable newTarget);
}


// Inheritance


// Internal references


// https://docs.synthetix.io/contracts/source/contracts/proxyable
contract Proxyable is Owned {
    // This contract should be treated like an abstract contract

    /* The proxy this contract exists behind. */
    Proxy public proxy;

    /* The caller of the proxy, passed through to this contract.
     * Note that every function using this member must apply the onlyProxy or
     * optionalProxy modifiers, otherwise their invocations can use stale values. */
    address public messageSender;

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

        proxy = Proxy(_proxy);
        emit ProxyUpdated(_proxy);
    }

    function setProxy(address payable _proxy) external onlyOwner {
        proxy = Proxy(_proxy);
        emit ProxyUpdated(_proxy);
    }

    function setMessageSender(address sender) external onlyProxy {
        messageSender = sender;
    }

    modifier onlyProxy {
        _onlyProxy();
        _;
    }

    function _onlyProxy() private view {
        require(Proxy(msg.sender) == proxy, "Only the proxy can call");
    }

    modifier optionalProxy {
        _optionalProxy();
        _;
    }

    function _optionalProxy() private {
        if (Proxy(msg.sender) != proxy && messageSender != msg.sender) {
            messageSender = msg.sender;
        }
    }

    modifier optionalProxy_onlyOwner {
        _optionalProxy_onlyOwner();
        _;
    }

    // solhint-disable-next-line func-name-mixedcase
    function _optionalProxy_onlyOwner() private {
        if (Proxy(msg.sender) != proxy && messageSender != msg.sender) {
            messageSender = msg.sender;
        }
        require(messageSender == owner, "Owner only function");
    }

    event ProxyUpdated(address proxyAddress);
}


interface AggregatorInterface {
  function latestAnswer() external view returns (int256);
  function latestTimestamp() external view returns (uint256);
  function latestRound() external view returns (uint256);
  function getAnswer(uint256 roundId) external view returns (int256);
  function getTimestamp(uint256 roundId) external view returns (uint256);

  event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
  event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
}


interface AggregatorV3Interface {

  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

}


/**
 * @title The V2 & V3 Aggregator Interface
 * @notice Solidity V0.5 does not allow interfaces to inherit from other
 * interfaces so this contract is a combination of v0.5 AggregatorInterface.sol
 * and v0.5 AggregatorV3Interface.sol.
 */
interface AggregatorV2V3Interface {
  //
  // V2 Interface:
  //
  function latestAnswer() external view returns (int256);
  function latestTimestamp() external view returns (uint256);
  function latestRound() external view returns (uint256);
  function getAnswer(uint256 roundId) external view returns (int256);
  function getTimestamp(uint256 roundId) external view returns (uint256);

  event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
  event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);

  //
  // V3 Interface:
  //
  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

}


// Inheritance


// Libraries


// Internal references


interface IProxy {
    function target() external view returns (address);
}

interface IIssuerInternalDebtCache {
    function updateCachedSynthDebtWithRate(bytes32 currencyKey, uint currencyRate) external;

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

    function updateDebtCacheValidity(bool currentlyInvalid) external;

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

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

    function updateCachedsUSDDebt(int amount) external;
}

// https://docs.synthetix.io/contracts/source/contracts/issuer
contract Issuer is Owned, MixinSystemSettings, IIssuer {
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    bytes32 public constant CONTRACT_NAME = "Issuer";

    // Available Synths which can be used with the system
    ISynth[] public availableSynths;
    mapping(bytes32 => ISynth) public synths;
    mapping(address => bytes32) public synthsByAddress;

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

    bytes32 internal constant sUSD = "sUSD";
    bytes32 internal constant SNX = "SNX";

    // Flexible storage names

    bytes32 internal constant LAST_ISSUE_EVENT = "lastIssueEvent";

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

    bytes32 private constant CONTRACT_SYNTHETIX = "Synthetix";
    bytes32 private constant CONTRACT_EXCHANGER = "Exchanger";
    bytes32 private constant CONTRACT_EXRATES = "ExchangeRates";
    bytes32 private constant CONTRACT_CIRCUIT_BREAKER = "CircuitBreaker";
    bytes32 private constant CONTRACT_SYNTHETIXDEBTSHARE = "SynthetixDebtShare";
    bytes32 private constant CONTRACT_FEEPOOL = "FeePool";
    bytes32 private constant CONTRACT_DELEGATEAPPROVALS = "DelegateApprovals";
    bytes32 private constant CONTRACT_REWARDESCROW_V2 = "RewardEscrowV2";
    bytes32 private constant CONTRACT_LIQUIDATOR = "Liquidator";
    bytes32 private constant CONTRACT_LIQUIDATOR_REWARDS = "LiquidatorRewards";
    bytes32 private constant CONTRACT_DEBTCACHE = "DebtCache";
    bytes32 private constant CONTRACT_SYNTHREDEEMER = "SynthRedeemer";
    bytes32 private constant CONTRACT_SYNTHETIXBRIDGETOOPTIMISM = "SynthetixBridgeToOptimism";
    bytes32 private constant CONTRACT_SYNTHETIXBRIDGETOBASE = "SynthetixBridgeToBase";
    bytes32 private constant CONTRACT_DEBT_MIGRATOR_ON_ETHEREUM = "DebtMigratorOnEthereum";
    bytes32 private constant CONTRACT_DEBT_MIGRATOR_ON_OPTIMISM = "DebtMigratorOnOptimism";

    bytes32 private constant CONTRACT_EXT_AGGREGATOR_ISSUED_SYNTHS = "ext:AggregatorIssuedSynths";
    bytes32 private constant CONTRACT_EXT_AGGREGATOR_DEBT_RATIO = "ext:AggregatorDebtRatio";

    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[](14);
        newAddresses[0] = CONTRACT_SYNTHETIX;
        newAddresses[1] = CONTRACT_EXCHANGER;
        newAddresses[2] = CONTRACT_EXRATES;
        newAddresses[3] = CONTRACT_CIRCUIT_BREAKER;
        newAddresses[4] = CONTRACT_SYNTHETIXDEBTSHARE;
        newAddresses[5] = CONTRACT_FEEPOOL;
        newAddresses[6] = CONTRACT_DELEGATEAPPROVALS;
        newAddresses[7] = CONTRACT_REWARDESCROW_V2;
        newAddresses[8] = CONTRACT_LIQUIDATOR;
        newAddresses[9] = CONTRACT_LIQUIDATOR_REWARDS;
        newAddresses[10] = CONTRACT_DEBTCACHE;
        newAddresses[11] = CONTRACT_SYNTHREDEEMER;
        newAddresses[12] = CONTRACT_EXT_AGGREGATOR_ISSUED_SYNTHS;
        newAddresses[13] = CONTRACT_EXT_AGGREGATOR_DEBT_RATIO;
        return combineArrays(existingAddresses, newAddresses);
    }

    function synthetixERC20() internal view returns (IERC20) {
        return IERC20(requireAndGetAddress(CONTRACT_SYNTHETIX));
    }

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

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

    function circuitBreaker() internal view returns (ICircuitBreaker) {
        return ICircuitBreaker(requireAndGetAddress(CONTRACT_CIRCUIT_BREAKER));
    }

    function synthetixDebtShare() internal view returns (ISynthetixDebtShare) {
        return ISynthetixDebtShare(requireAndGetAddress(CONTRACT_SYNTHETIXDEBTSHARE));
    }

    function liquidator() internal view returns (ILiquidator) {
        return ILiquidator(requireAndGetAddress(CONTRACT_LIQUIDATOR));
    }

    function liquidatorRewards() internal view returns (ILiquidatorRewards) {
        return ILiquidatorRewards(requireAndGetAddress(CONTRACT_LIQUIDATOR_REWARDS));
    }

    function delegateApprovals() internal view returns (IDelegateApprovals) {
        return IDelegateApprovals(requireAndGetAddress(CONTRACT_DELEGATEAPPROVALS));
    }

    function rewardEscrowV2() internal view returns (IHasBalance) {
        return IHasBalance(requireAndGetAddress(CONTRACT_REWARDESCROW_V2));
    }

    function debtCache() internal view returns (IIssuerInternalDebtCache) {
        return IIssuerInternalDebtCache(requireAndGetAddress(CONTRACT_DEBTCACHE));
    }

    function synthRedeemer() internal view returns (ISynthRedeemer) {
        return ISynthRedeemer(requireAndGetAddress(CONTRACT_SYNTHREDEEMER));
    }

    function allNetworksDebtInfo()
        public
        view
        returns (
            uint256 debt,
            uint256 sharesSupply,
            bool isStale
        )
    {
        (, int256 rawIssuedSynths, , uint issuedSynthsUpdatedAt, ) =
            _latestRoundData(requireAndGetAddress(CONTRACT_EXT_AGGREGATOR_ISSUED_SYNTHS));

        (uint rawRatio, uint ratioUpdatedAt) = _rawDebtRatioAndUpdatedAt();

        debt = uint(rawIssuedSynths);
        sharesSupply = rawRatio == 0 ? 0 : debt.divideDecimalRoundPrecise(uint(rawRatio));

        uint stalePeriod = getRateStalePeriod();

        isStale =
            stalePeriod < block.timestamp &&
            (block.timestamp - stalePeriod > issuedSynthsUpdatedAt || block.timestamp - stalePeriod > ratioUpdatedAt);
    }

    function issuanceRatio() external view returns (uint) {
        return getIssuanceRatio();
    }

    function _rateAndInvalid(bytes32 currencyKey) internal view returns (uint, bool) {
        return exchangeRates().rateAndInvalid(currencyKey);
    }

    function _latestRoundData(address aggregator)
        internal
        view
        returns (
            uint80,
            int256,
            uint256,
            uint256,
            uint80
        )
    {
        return AggregatorV2V3Interface(aggregator).latestRoundData();
    }

    function _rawDebtRatioAndUpdatedAt() internal view returns (uint, uint) {
        (, int256 rawRatioInt, , uint ratioUpdatedAt, ) =
            _latestRoundData(requireAndGetAddress(CONTRACT_EXT_AGGREGATOR_DEBT_RATIO));
        return (uint(rawRatioInt), ratioUpdatedAt);
    }

    function _sharesForDebt(uint debtAmount) internal view returns (uint) {
        (uint rawRatio, ) = _rawDebtRatioAndUpdatedAt();
        return rawRatio == 0 ? 0 : debtAmount.divideDecimalRoundPrecise(rawRatio);
    }

    function _debtForShares(uint sharesAmount) internal view returns (uint) {
        (uint rawRatio, ) = _rawDebtRatioAndUpdatedAt();
        return sharesAmount.multiplyDecimalRoundPrecise(rawRatio);
    }

    function _debtShareBalanceOf(address account) internal view returns (uint) {
        return synthetixDebtShare().balanceOf(account);
    }

    function _snxBalanceOf(address account) internal view returns (uint) {
        return synthetixERC20().balanceOf(account);
    }

    function _rewardEscrowBalanceOf(address account) internal view returns (uint) {
        return rewardEscrowV2().balanceOf(account);
    }

    function _availableCurrencyKeysWithOptionalSNX(bool withSNX) internal view returns (bytes32[] memory) {
        bytes32[] memory currencyKeys = new bytes32[](availableSynths.length + (withSNX ? 1 : 0));

        for (uint i = 0; i < availableSynths.length; i++) {
            currencyKeys[i] = synthsByAddress[address(availableSynths[i])];
        }

        if (withSNX) {
            currencyKeys[availableSynths.length] = SNX;
        }

        return currencyKeys;
    }

    // Returns the total value of the debt pool in currency specified by `currencyKey`.
    // To return only the SNX-backed debt, set `excludeCollateral` to true.
    function _totalIssuedSynths(bytes32 currencyKey, bool excludeCollateral)
        internal
        view
        returns (uint totalIssued, bool anyRateIsInvalid)
    {
        (uint debt, , bool cacheIsInvalid, bool cacheIsStale) = debtCache().cacheInfo();
        anyRateIsInvalid = cacheIsInvalid || cacheIsStale;

        // Add total issued synths from non snx collateral back into the total if not excluded
        if (!excludeCollateral) {
            (uint nonSnxDebt, bool invalid) = debtCache().totalNonSnxBackedDebt();
            debt = debt.add(nonSnxDebt);
            anyRateIsInvalid = anyRateIsInvalid || invalid;
        }

        if (currencyKey == sUSD) {
            return (debt, anyRateIsInvalid);
        }

        (uint currencyRate, bool currencyRateInvalid) = _rateAndInvalid(currencyKey);
        return (debt.divideDecimalRound(currencyRate), anyRateIsInvalid || currencyRateInvalid);
    }

    function _debtBalanceOfAndTotalDebt(uint debtShareBalance, bytes32 currencyKey)
        internal
        view
        returns (
            uint debtBalance,
            uint totalSystemValue,
            bool anyRateIsInvalid
        )
    {
        // What's the total value of the system excluding ETH backed synths in their requested currency?
        (uint snxBackedAmount, , bool debtInfoStale) = allNetworksDebtInfo();

        if (debtShareBalance == 0) {
            return (0, snxBackedAmount, debtInfoStale);
        }

        // existing functionality requires for us to convert into the exchange rate specified by `currencyKey`
        (uint currencyRate, bool currencyRateInvalid) = _rateAndInvalid(currencyKey);

        debtBalance = _debtForShares(debtShareBalance).divideDecimalRound(currencyRate);
        totalSystemValue = snxBackedAmount;

        anyRateIsInvalid = currencyRateInvalid || debtInfoStale;
    }

    function _canBurnSynths(address account) internal view returns (bool) {
        return now >= _lastIssueEvent(account).add(getMinimumStakeTime());
    }

    function _lastIssueEvent(address account) internal view returns (uint) {
        //  Get the timestamp of the last issue this account made
        return flexibleStorage().getUIntValue(CONTRACT_NAME, keccak256(abi.encodePacked(LAST_ISSUE_EVENT, account)));
    }

    function _remainingIssuableSynths(address _issuer)
        internal
        view
        returns (
            uint maxIssuable,
            uint alreadyIssued,
            uint totalSystemDebt,
            bool anyRateIsInvalid
        )
    {
        (alreadyIssued, totalSystemDebt, anyRateIsInvalid) = _debtBalanceOfAndTotalDebt(_debtShareBalanceOf(_issuer), sUSD);
        (uint issuable, bool isInvalid) = _maxIssuableSynths(_issuer);
        maxIssuable = issuable;
        anyRateIsInvalid = anyRateIsInvalid || isInvalid;

        if (alreadyIssued >= maxIssuable) {
            maxIssuable = 0;
        } else {
            maxIssuable = maxIssuable.sub(alreadyIssued);
        }
    }

    function _snxToUSD(uint amount, uint snxRate) internal pure returns (uint) {
        return amount.multiplyDecimalRound(snxRate);
    }

    function _usdToSnx(uint amount, uint snxRate) internal pure returns (uint) {
        return amount.divideDecimalRound(snxRate);
    }

    function _maxIssuableSynths(address _issuer) internal view returns (uint, bool) {
        // What is the value of their SNX balance in sUSD
        (uint snxRate, bool isInvalid) = _rateAndInvalid(SNX);
        uint destinationValue = _snxToUSD(_collateral(_issuer), snxRate);

        // They're allowed to issue up to issuanceRatio of that value
        return (destinationValue.multiplyDecimal(getIssuanceRatio()), isInvalid);
    }

    function _collateralisationRatio(address _issuer) internal view returns (uint, bool) {
        uint totalOwnedSynthetix = _collateral(_issuer);

        (uint debtBalance, , bool anyRateIsInvalid) = _debtBalanceOfAndTotalDebt(_debtShareBalanceOf(_issuer), SNX);

        // it's more gas intensive to put this check here if they have 0 SNX, but it complies with the interface
        if (totalOwnedSynthetix == 0) return (0, anyRateIsInvalid);

        return (debtBalance.divideDecimalRound(totalOwnedSynthetix), anyRateIsInvalid);
    }

    function _collateral(address account) internal view returns (uint) {
        return _snxBalanceOf(account).add(_rewardEscrowBalanceOf(account)).add(liquidatorRewards().earned(account));
    }

    function minimumStakeTime() external view returns (uint) {
        return getMinimumStakeTime();
    }

    function canBurnSynths(address account) external view returns (bool) {
        return _canBurnSynths(account);
    }

    function availableCurrencyKeys() external view returns (bytes32[] memory) {
        return _availableCurrencyKeysWithOptionalSNX(false);
    }

    function availableSynthCount() external view returns (uint) {
        return availableSynths.length;
    }

    function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid) {
        (, anyRateInvalid) = exchangeRates().ratesAndInvalidForCurrencies(_availableCurrencyKeysWithOptionalSNX(true));
    }

    function totalIssuedSynths(bytes32 currencyKey, bool excludeOtherCollateral) external view returns (uint totalIssued) {
        (totalIssued, ) = _totalIssuedSynths(currencyKey, excludeOtherCollateral);
    }

    function lastIssueEvent(address account) external view returns (uint) {
        return _lastIssueEvent(account);
    }

    function collateralisationRatio(address _issuer) external view returns (uint cratio) {
        (cratio, ) = _collateralisationRatio(_issuer);
    }

    function collateralisationRatioAndAnyRatesInvalid(address _issuer)
        external
        view
        returns (uint cratio, bool anyRateIsInvalid)
    {
        return _collateralisationRatio(_issuer);
    }

    function collateral(address account) external view returns (uint) {
        return _collateral(account);
    }

    function debtBalanceOf(address _issuer, bytes32 currencyKey) external view returns (uint debtBalance) {
        // What was their initial debt ownership?
        uint debtShareBalance = _debtShareBalanceOf(_issuer);

        // If it's zero, they haven't issued, and they have no debt.
        if (debtShareBalance == 0) return 0;

        (debtBalance, , ) = _debtBalanceOfAndTotalDebt(debtShareBalance, currencyKey);
    }

    function remainingIssuableSynths(address _issuer)
        external
        view
        returns (
            uint maxIssuable,
            uint alreadyIssued,
            uint totalSystemDebt
        )
    {
        (maxIssuable, alreadyIssued, totalSystemDebt, ) = _remainingIssuableSynths(_issuer);
    }

    function maxIssuableSynths(address _issuer) external view returns (uint) {
        (uint maxIssuable, ) = _maxIssuableSynths(_issuer);
        return maxIssuable;
    }

    function transferableSynthetixAndAnyRateIsInvalid(address account, uint balance)
        external
        view
        returns (uint transferable, bool anyRateIsInvalid)
    {
        // How many SNX do they have, excluding escrow?
        // Note: We're excluding escrow here because we're interested in their transferable amount
        // and escrowed SNX are not transferable.

        // How many of those will be locked by the amount they've issued?
        // Assuming issuance ratio is 20%, then issuing 20 SNX of value would require
        // 100 SNX to be locked in their wallet to maintain their collateralisation ratio
        // The locked synthetix value can exceed their balance.
        uint debtBalance;
        (debtBalance, , anyRateIsInvalid) = _debtBalanceOfAndTotalDebt(_debtShareBalanceOf(account), SNX);
        uint lockedSynthetixValue = debtBalance.divideDecimalRound(getIssuanceRatio());

        // If we exceed the balance, no SNX are transferable, otherwise the difference is.
        if (lockedSynthetixValue >= balance) {
            transferable = 0;
        } else {
            transferable = balance.sub(lockedSynthetixValue);
        }
    }

    function getSynths(bytes32[] calldata currencyKeys) external view returns (ISynth[] memory) {
        uint numKeys = currencyKeys.length;
        ISynth[] memory addresses = new ISynth[](numKeys);

        for (uint i = 0; i < numKeys; i++) {
            addresses[i] = synths[currencyKeys[i]];
        }

        return addresses;
    }

    /// @notice Provide the results that would be returned by the mutative liquidateAccount() method (that's reserved to Synthetix)
    /// @param account The account to be liquidated
    /// @param isSelfLiquidation boolean to determine if this is a forced or self-invoked liquidation
    /// @return totalRedeemed the total amount of collateral (SNX) to redeem (liquid and escrow)
    /// @return debtToRemove the amount of debt (sUSD) to burn in order to fix the account's c-ratio
    /// @return escrowToLiquidate the amount of escrow SNX that will be revoked during liquidation
    /// @return initialDebtBalance the amount of initial (sUSD) debt the account has
    function liquidationAmounts(address account, bool isSelfLiquidation)
        external
        view
        returns (
            uint totalRedeemed,
            uint debtToRemove,
            uint escrowToLiquidate,
            uint initialDebtBalance
        )
    {
        return _liquidationAmounts(account, isSelfLiquidation);
    }

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

    function _addSynth(ISynth synth) internal {
        bytes32 currencyKey = synth.currencyKey();
        require(synths[currencyKey] == ISynth(0), "Synth exists");
        require(synthsByAddress[address(synth)] == bytes32(0), "Synth address already exists");

        availableSynths.push(synth);
        synths[currencyKey] = synth;
        synthsByAddress[address(synth)] = currencyKey;

        emit SynthAdded(currencyKey, address(synth));
    }

    function addSynth(ISynth synth) external onlyOwner {
        _addSynth(synth);
        // Invalidate the cache to force a snapshot to be recomputed. If a synth were to be added
        // back to the system and it still somehow had cached debt, this would force the value to be
        // updated.
        debtCache().updateDebtCacheValidity(true);
    }

    function addSynths(ISynth[] calldata synthsToAdd) external onlyOwner {
        uint numSynths = synthsToAdd.length;
        for (uint i = 0; i < numSynths; i++) {
            _addSynth(synthsToAdd[i]);
        }

        // Invalidate the cache to force a snapshot to be recomputed.
        debtCache().updateDebtCacheValidity(true);
    }

    function _removeSynth(bytes32 currencyKey) internal {
        address synthToRemove = address(synths[currencyKey]);
        require(synthToRemove != address(0), "Synth does not exist");
        require(currencyKey != sUSD, "Cannot remove synth");

        uint synthSupply = IERC20(synthToRemove).totalSupply();

        if (synthSupply > 0) {
            (uint amountOfsUSD, uint rateToRedeem, ) =
                exchangeRates().effectiveValueAndRates(currencyKey, synthSupply, "sUSD");
            require(rateToRedeem > 0, "Cannot remove without rate");
            ISynthRedeemer _synthRedeemer = synthRedeemer();
            synths[sUSD].issue(address(_synthRedeemer), amountOfsUSD);
            // ensure the debt cache is aware of the new sUSD issued
            debtCache().updateCachedsUSDDebt(SafeCast.toInt256(amountOfsUSD));
            _synthRedeemer.deprecate(IERC20(address(Proxyable(synthToRemove).proxy())), rateToRedeem);
        }

        // Remove the synth from the availableSynths array.
        for (uint i = 0; i < availableSynths.length; i++) {
            if (address(availableSynths[i]) == synthToRemove) {
                delete availableSynths[i];

                // Copy the last synth into the place of the one we just deleted
                // If there's only one synth, this is synths[0] = synths[0].
                // If we're deleting the last one, it's also a NOOP in the same way.
                availableSynths[i] = availableSynths[availableSynths.length - 1];

                // Decrease the size of the array by one.
                availableSynths.length--;

                break;
            }
        }

        // And remove it from the synths mapping
        delete synthsByAddress[synthToRemove];
        delete synths[currencyKey];

        emit SynthRemoved(currencyKey, synthToRemove);
    }

    function removeSynth(bytes32 currencyKey) external onlyOwner {
        // Remove its contribution from the debt pool snapshot, and
        // invalidate the cache to force a new snapshot.
        IIssuerInternalDebtCache cache = debtCache();
        cache.updateCachedSynthDebtWithRate(currencyKey, 0);
        cache.updateDebtCacheValidity(true);

        _removeSynth(currencyKey);
    }

    function removeSynths(bytes32[] calldata currencyKeys) external onlyOwner {
        uint numKeys = currencyKeys.length;

        // Remove their contributions from the debt pool snapshot, and
        // invalidate the cache to force a new snapshot.
        IIssuerInternalDebtCache cache = debtCache();
        uint[] memory zeroRates = new uint[](numKeys);
        cache.updateCachedSynthDebtsWithRates(currencyKeys, zeroRates);
        cache.updateDebtCacheValidity(true);

        for (uint i = 0; i < numKeys; i++) {
            _removeSynth(currencyKeys[i]);
        }
    }

    function issueSynthsWithoutDebt(
        bytes32 currencyKey,
        address to,
        uint amount
    ) external onlyTrustedMinters returns (bool rateInvalid) {
        require(address(synths[currencyKey]) != address(0), "synth doesn't exist");
        require(amount > 0, "cannot issue 0 synths");

        // record issue timestamp
        _setLastIssueEvent(to);

        // Create their synths
        synths[currencyKey].issue(to, amount);

        // Account for the issued debt in the cache
        (uint rate, bool rateInvalid) = _rateAndInvalid(currencyKey);
        debtCache().updateCachedsUSDDebt(SafeCast.toInt256(amount.multiplyDecimal(rate)));

        // returned so that the caller can decide what to do if the rate is invalid
        return rateInvalid;
    }

    function burnSynthsWithoutDebt(
        bytes32 currencyKey,
        address from,
        uint amount
    ) external onlyTrustedMinters returns (bool rateInvalid) {
        require(address(synths[currencyKey]) != address(0), "synth doesn't exist");
        require(amount > 0, "cannot issue 0 synths");

        exchanger().settle(from, currencyKey);

        // Burn some synths
        synths[currencyKey].burn(from, amount);

        // Account for the burnt debt in the cache. If rate is invalid, the user won't be able to exchange
        (uint rate, bool rateInvalid) = _rateAndInvalid(currencyKey);
        debtCache().updateCachedsUSDDebt(-SafeCast.toInt256(amount.multiplyDecimal(rate)));

        // returned so that the caller can decide what to do if the rate is invalid
        return rateInvalid;
    }

    /**
     * SIP-237: Debt Migration
     * Function used for the one-way migration of all debt and liquid + escrowed SNX from L1 -> L2
     * @param account The address of the account that is being migrated
     * @param amount The amount of debt shares moving across layers
     */
    function modifyDebtSharesForMigration(address account, uint amount) external onlyTrustedMigrators {
        ISynthetixDebtShare sds = synthetixDebtShare();

        if (msg.sender == resolver.getAddress(CONTRACT_DEBT_MIGRATOR_ON_ETHEREUM)) {
            sds.burnShare(account, amount);
        } else if (msg.sender == resolver.getAddress(CONTRACT_DEBT_MIGRATOR_ON_OPTIMISM)) {
            sds.mintShare(account, amount);
        }
    }

    /**
     * Function used to migrate balances from the CollateralShort contract
     * @param short The address of the CollateralShort contract to be upgraded
     * @param amount The amount of sUSD collateral to be burnt
     */
    function upgradeCollateralShort(address short, uint amount) external onlyOwner {
        require(short == resolver.getAddress("CollateralShortLegacy"), "wrong address");
        require(amount > 0, "cannot burn 0 synths");

        exchanger().settle(short, sUSD);

        synths[sUSD].burn(short, amount);
    }

    function issueSynths(address from, uint amount) external onlySynthetix {
        require(amount > 0, "cannot issue 0 synths");

        _issueSynths(from, amount, false);
    }

    function issueMaxSynths(address from) external onlySynthetix {
        _issueSynths(from, 0, true);
    }

    function issueSynthsOnBehalf(
        address issueForAddress,
        address from,
        uint amount
    ) external onlySynthetix {
        _requireCanIssueOnBehalf(issueForAddress, from);
        _issueSynths(issueForAddress, amount, false);
    }

    function issueMaxSynthsOnBehalf(address issueForAddress, address from) external onlySynthetix {
        _requireCanIssueOnBehalf(issueForAddress, from);
        _issueSynths(issueForAddress, 0, true);
    }

    function burnSynths(address from, uint amount) external onlySynthetix {
        _voluntaryBurnSynths(from, amount, false);
    }

    function burnSynthsOnBehalf(
        address burnForAddress,
        address from,
        uint amount
    ) external onlySynthetix {
        _requireCanBurnOnBehalf(burnForAddress, from);
        _voluntaryBurnSynths(burnForAddress, amount, false);
    }

    function burnSynthsToTarget(address from) external onlySynthetix {
        _voluntaryBurnSynths(from, 0, true);
    }

    function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external onlySynthetix {
        _requireCanBurnOnBehalf(burnForAddress, from);
        _voluntaryBurnSynths(burnForAddress, 0, true);
    }

    function burnForRedemption(
        address deprecatedSynthProxy,
        address account,
        uint balance
    ) external onlySynthRedeemer {
        ISynth(IProxy(deprecatedSynthProxy).target()).burn(account, balance);
    }

    // SIP-148: Upgraded Liquidation Mechanism
    /// @notice This is where the core internal liquidation logic resides. This function can only be invoked by Synthetix.
    /// Reverts if liquidator().isLiquidationOpen() returns false (e.g. c-ratio is too high, delay hasn't passed,
    ///     account wasn't flagged etc)
    /// @param account The account to be liquidated
    /// @param isSelfLiquidation boolean to determine if this is a forced or self-invoked liquidation
    /// @return totalRedeemed the total amount of collateral (SNX) to redeem (liquid and escrow)
    /// @return debtRemoved the amount of debt (sUSD) to burn in order to fix the account's c-ratio
    /// @return escrowToLiquidate the amount of escrow SNX that will be revoked during liquidation
    function liquidateAccount(address account, bool isSelfLiquidation)
        external
        onlySynthetix
        returns (
            uint totalRedeemed,
            uint debtRemoved,
            uint escrowToLiquidate
        )
    {
        require(liquidator().isLiquidationOpen(account, isSelfLiquidation), "Not open for liquidation");

        // liquidationAmounts checks isLiquidationOpen for the account
        uint initialDebtBalance;
        (totalRedeemed, debtRemoved, escrowToLiquidate, initialDebtBalance) = _liquidationAmounts(
            account,
            isSelfLiquidation
        );

        // Reduce debt shares by amount to liquidate.
        _removeFromDebtRegister(account, debtRemoved, initialDebtBalance);

        if (!isSelfLiquidation) {
            // In case of forced liquidation only, remove the liquidation flag.
            liquidator().removeAccountInLiquidation(account);
        }
        // Note: To remove the flag after self liquidation, burn to target and then call Liquidator.checkAndRemoveAccountInLiquidation(account).
    }

    function _liquidationAmounts(address account, bool isSelfLiquidation)
        internal
        view
        returns (
            uint totalRedeemed,
            uint debtToRemove,
            uint escrowToLiquidate,
            uint debtBalance
        )
    {
        // Get the account's debt balance
        bool anyRateIsInvalid;
        (debtBalance, , anyRateIsInvalid) = _debtBalanceOfAndTotalDebt(_debtShareBalanceOf(account), sUSD);

        // Get the SNX rate
        (uint snxRate, bool snxRateInvalid) = _rateAndInvalid(SNX);
        _requireRatesNotInvalid(anyRateIsInvalid || snxRateInvalid);

        uint penalty;
        if (isSelfLiquidation) {
            // Get self liquidation penalty
            penalty = getSelfLiquidationPenalty();

            // Calculate the amount of debt to remove and SNX to redeem for a self liquidation
            debtToRemove = liquidator().calculateAmountToFixCollateral(
                debtBalance,
                _snxToUSD(_collateral(account), snxRate),
                penalty
            );

            // Get the minimum values for both totalRedeemed and debtToRemove
            totalRedeemed = _getMinValue(
                _usdToSnx(debtToRemove, snxRate).multiplyDecimal(SafeDecimalMath.unit().add(penalty)),
                _snxBalanceOf(account)
            );
            debtToRemove = _getMinValue(
                _snxToUSD(totalRedeemed, snxRate).divideDecimal(SafeDecimalMath.unit().add(penalty)),
                debtToRemove
            );

            // Return escrow as zero since it cannot be self liquidated
            return (totalRedeemed, debtToRemove, 0, debtBalance);
        } else {
            // In the case of forced Liquidation
            // Get the forced liquidation penalty and sum of the flag and liquidate rewards.
            penalty = getSnxLiquidationPenalty();
            uint rewardsSum = getLiquidateReward().add(getFlagReward());

            // Get the total USD value of their SNX collateral (including escrow and rewards minus the flag and liquidate rewards)
            uint collateralForAccountUSD = _snxToUSD(_collateral(account).sub(rewardsSum), snxRate);

            // Calculate the amount of debt to remove and the sUSD value of the SNX required to liquidate.
            debtToRemove = liquidator().calculateAmountToFixCollateral(debtBalance, collateralForAccountUSD, penalty);
            uint redeemTarget = _usdToSnx(debtToRemove, snxRate).multiplyDecimal(SafeDecimalMath.unit().add(penalty));

            if (redeemTarget.add(rewardsSum) >= _collateral(account)) {
                // need to wipe out the account
                debtToRemove = debtBalance;
                totalRedeemed = _collateral(account).sub(rewardsSum);
                escrowToLiquidate = _rewardEscrowBalanceOf(account);
                return (totalRedeemed, debtToRemove, escrowToLiquidate, debtBalance);
            } else {
                // normal forced liquidation
                (totalRedeemed, escrowToLiquidate) = _redeemableCollateralForTarget(account, redeemTarget, rewardsSum);
                return (totalRedeemed, debtToRemove, escrowToLiquidate, debtBalance);
            }
        }
    }

    // SIP-252
    // calculates the amount of SNX that can be force liquidated (redeemed)
    // for the various cases of transferrable & escrowed collateral
    function _redeemableCollateralForTarget(
        address account,
        uint redeemTarget,
        uint rewardsSum
    ) internal view returns (uint totalRedeemed, uint escrowToLiquidate) {
        // The balanceOf here can be considered "transferable" since it's not escrowed,
        // and it is the only SNX that can potentially be transfered if unstaked.
        uint transferable = _snxBalanceOf(account);
        if (redeemTarget.add(rewardsSum) <= transferable) {
            // transferable is enough
            return (redeemTarget, 0);
        } else {
            // if transferable is not enough
            // need only part of the escrow, add the needed part to redeemed
            escrowToLiquidate = redeemTarget.add(rewardsSum).sub(transferable);
            return (redeemTarget, escrowToLiquidate);
        }
    }

    function _getMinValue(uint x, uint y) internal pure returns (uint) {
        return x < y ? x : y;
    }

    function setCurrentPeriodId(uint128 periodId) external {
        require(msg.sender == requireAndGetAddress(CONTRACT_FEEPOOL), "Must be fee pool");

        ISynthetixDebtShare sds = synthetixDebtShare();

        if (sds.currentPeriodId() < periodId) {
            sds.takeSnapshot(periodId);
        }
    }

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

    function _requireRatesNotInvalid(bool anyRateIsInvalid) internal pure {
        require(!anyRateIsInvalid, "A synth or SNX rate is invalid");
    }

    function _requireCanIssueOnBehalf(address issueForAddress, address from) internal view {
        require(delegateApprovals().canIssueFor(issueForAddress, from), "Not approved to act on behalf");
    }

    function _requireCanBurnOnBehalf(address burnForAddress, address from) internal view {
        require(delegateApprovals().canBurnFor(burnForAddress, from), "Not approved to act on behalf");
    }

    function _issueSynths(
        address from,
        uint amount,
        bool issueMax
    ) internal {
        if (_verifyCircuitBreakers()) {
            return;
        }

        (uint maxIssuable, , , bool anyRateIsInvalid) = _remainingIssuableSynths(from);
        _requireRatesNotInvalid(anyRateIsInvalid);

        if (!issueMax) {
            require(amount <= maxIssuable, "Amount too large");
        } else {
            amount = maxIssuable;
        }

        // Keep track of the debt they're about to create
        _addToDebtRegister(from, amount);

        // record issue timestamp
        _setLastIssueEvent(from);

        // Create their synths
        synths[sUSD].issue(from, amount);

        // Account for the issued debt in the cache
        debtCache().updateCachedsUSDDebt(SafeCast.toInt256(amount));
    }

    function _burnSynths(
        address debtAccount,
        address burnAccount,
        uint amount,
        uint existingDebt
    ) internal returns (uint amountBurnt) {
        if (_verifyCircuitBreakers()) {
            return 0;
        }

        // liquidation requires sUSD to be already settled / not in waiting period

        // If they're trying to burn more debt than they actually owe, rather than fail the transaction, let's just
        // clear their debt and leave them be.
        amountBurnt = existingDebt < amount ? existingDebt : amount;

        // Remove liquidated debt from the ledger
        _removeFromDebtRegister(debtAccount, amountBurnt, existingDebt);

        // synth.burn does a safe subtraction on balance (so it will revert if there are not enough synths).
        synths[sUSD].burn(burnAccount, amountBurnt);

        // Account for the burnt debt in the cache.
        debtCache().updateCachedsUSDDebt(-SafeCast.toInt256(amountBurnt));
    }

    // If burning to target, `amount` is ignored, and the correct quantity of sUSD is burnt to reach the target
    // c-ratio, allowing fees to be claimed. In this case, pending settlements will be skipped as the user
    // will still have debt remaining after reaching their target.
    function _voluntaryBurnSynths(
        address from,
        uint amount,
        bool burnToTarget
    ) internal {
        if (_verifyCircuitBreakers()) {
            return;
        }

        if (!burnToTarget) {
            // If not burning to target, then burning requires that the minimum stake time has elapsed.
            require(_canBurnSynths(from), "Minimum stake time not reached");
            // First settle anything pending into sUSD as burning or issuing impacts the size of the debt pool
            (, uint refunded, uint numEntriesSettled) = exchanger().settle(from, sUSD);
            if (numEntriesSettled > 0) {
                amount = exchanger().calculateAmountAfterSettlement(from, sUSD, amount, refunded);
            }
        }

        (uint existingDebt, , bool anyRateIsInvalid) = _debtBalanceOfAndTotalDebt(_debtShareBalanceOf(from), sUSD);
        (uint maxIssuableSynthsForAccount, bool snxRateInvalid) = _maxIssuableSynths(from);
        _requireRatesNotInvalid(anyRateIsInvalid || snxRateInvalid);
        require(existingDebt > 0, "No debt to forgive");

        if (burnToTarget) {
            amount = existingDebt.sub(maxIssuableSynthsForAccount);
        }

        uint amountBurnt = _burnSynths(from, from, amount, existingDebt);

        // Check and remove liquidation if existingDebt after burning is <= maxIssuableSynths
        // Issuance ratio is fixed so should remove any liquidations
        if (existingDebt.sub(amountBurnt) <= maxIssuableSynthsForAccount) {
            liquidator().removeAccountInLiquidation(from);
        }
    }

    function _setLastIssueEvent(address account) internal {
        // Set the timestamp of the last issueSynths
        flexibleStorage().setUIntValue(
            CONTRACT_NAME,
            keccak256(abi.encodePacked(LAST_ISSUE_EVENT, account)),
            block.timestamp
        );
    }

    function _addToDebtRegister(address from, uint amount) internal {
        // important: this has to happen before any updates to user's debt shares
        liquidatorRewards().updateEntry(from);

        ISynthetixDebtShare sds = synthetixDebtShare();

        // it is possible (eg in tests, system initialized with extra debt) to have issued debt without any shares issued
        // in which case, the first account to mint gets the debt. yw.
        uint debtShares = _sharesForDebt(amount);
        if (debtShares == 0) {
            sds.mintShare(from, amount);
        } else {
            sds.mintShare(from, debtShares);
        }
    }

    function _removeFromDebtRegister(
        address from,
        uint debtToRemove,
        uint existingDebt
    ) internal {
        // important: this has to happen before any updates to user's debt shares
        liquidatorRewards().updateEntry(from);

        ISynthetixDebtShare sds = synthetixDebtShare();

        uint currentDebtShare = _debtShareBalanceOf(from);

        if (debtToRemove == existingDebt) {
            sds.burnShare(from, currentDebtShare);
        } else {
            uint sharesToRemove = _sharesForDebt(debtToRemove);
            sds.burnShare(from, sharesToRemove < currentDebtShare ? sharesToRemove : currentDebtShare);
        }
    }

    // trips the breaker and returns boolean, where true means the breaker has tripped state
    function _verifyCircuitBreakers() internal returns (bool) {
        address debtRatioAggregator = requireAndGetAddress(CONTRACT_EXT_AGGREGATOR_DEBT_RATIO);
        (, int256 rawRatio, , , ) = AggregatorV2V3Interface(debtRatioAggregator).latestRoundData();
        (, bool broken, ) = exchangeRates().rateWithSafetyChecks(SNX);

        return circuitBreaker().probeCircuitBreaker(debtRatioAggregator, uint(rawRatio)) || broken;
    }

    /* ========== MODIFIERS ========== */
    modifier onlySynthetix() {
        require(msg.sender == address(synthetixERC20()), "Only Synthetix");
        _;
    }

    modifier onlyTrustedMinters() {
        address bridgeL1 = resolver.getAddress(CONTRACT_SYNTHETIXBRIDGETOOPTIMISM);
        address bridgeL2 = resolver.getAddress(CONTRACT_SYNTHETIXBRIDGETOBASE);
        address feePool = resolver.getAddress(CONTRACT_FEEPOOL);
        require(msg.sender == bridgeL1 || msg.sender == bridgeL2 || msg.sender == feePool, "only trusted minters");
        _;
    }

    modifier onlyTrustedMigrators() {
        address migratorL1 = resolver.getAddress(CONTRACT_DEBT_MIGRATOR_ON_ETHEREUM);
        address migratorL2 = resolver.getAddress(CONTRACT_DEBT_MIGRATOR_ON_OPTIMISM);
        require(msg.sender == migratorL1 || msg.sender == migratorL2, "only trusted migrators");
        require(migratorL1 == address(0) || migratorL2 == address(0), "one migrator must be 0x0");
        _;
    }

    function _onlySynthRedeemer() internal view {
        require(msg.sender == address(synthRedeemer()), "Only SynthRedeemer");
    }

    modifier onlySynthRedeemer() {
        _onlySynthRedeemer();
        _;
    }

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

    event SynthAdded(bytes32 currencyKey, address synth);
    event SynthRemoved(bytes32 currencyKey, address synth);
}

Contract Security Audit

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":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"address","name":"synth","type":"address"}],"name":"SynthAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"address","name":"synth","type":"address"}],"name":"SynthRemoved","type":"event"},{"constant":true,"inputs":[],"name":"CONTRACT_NAME","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract ISynth","name":"synth","type":"address"}],"name":"addSynth","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract ISynth[]","name":"synthsToAdd","type":"address[]"}],"name":"addSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"allNetworksDebtInfo","outputs":[{"internalType":"uint256","name":"debt","type":"uint256"},{"internalType":"uint256","name":"sharesSupply","type":"uint256"},{"internalType":"bool","name":"isStale","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"anySynthOrSNXRateIsInvalid","outputs":[{"internalType":"bool","name":"anyRateInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"availableCurrencyKeys","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"availableSynthCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"availableSynths","outputs":[{"internalType":"contract ISynth","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"deprecatedSynthProxy","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"}],"name":"burnForRedemption","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"burnForAddress","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnSynthsOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"}],"name":"burnSynthsToTarget","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"burnForAddress","type":"address"},{"internalType":"address","name":"from","type":"address"}],"name":"burnSynthsToTargetOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnSynthsWithoutDebt","outputs":[{"internalType":"bool","name":"rateInvalid","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"canBurnSynths","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"collateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_issuer","type":"address"}],"name":"collateralisationRatio","outputs":[{"internalType":"uint256","name":"cratio","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_issuer","type":"address"}],"name":"collateralisationRatioAndAnyRatesInvalid","outputs":[{"internalType":"uint256","name":"cratio","type":"uint256"},{"internalType":"bool","name":"anyRateIsInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_issuer","type":"address"},{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"debtBalanceOf","outputs":[{"internalType":"uint256","name":"debtBalance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"getSynths","outputs":[{"internalType":"contract ISynth[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"issuanceRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"}],"name":"issueMaxSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"issueForAddress","type":"address"},{"internalType":"address","name":"from","type":"address"}],"name":"issueMaxSynthsOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"issueSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"issueForAddress","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"issueSynthsOnBehalf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"issueSynthsWithoutDebt","outputs":[{"internalType":"bool","name":"rateInvalid","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"lastIssueEvent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"isSelfLiquidation","type":"bool"}],"name":"liquidateAccount","outputs":[{"internalType":"uint256","name":"totalRedeemed","type":"uint256"},{"internalType":"uint256","name":"debtRemoved","type":"uint256"},{"internalType":"uint256","name":"escrowToLiquidate","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"isSelfLiquidation","type":"bool"}],"name":"liquidationAmounts","outputs":[{"internalType":"uint256","name":"totalRedeemed","type":"uint256"},{"internalType":"uint256","name":"debtToRemove","type":"uint256"},{"internalType":"uint256","name":"escrowToLiquidate","type":"uint256"},{"internalType":"uint256","name":"initialDebtBalance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_issuer","type":"address"}],"name":"maxIssuableSynths","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minimumStakeTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"modifyDebtSharesForMigration","outputs":[],"payable":false,"stateMutability":"nonpayable","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":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_issuer","type":"address"}],"name":"remainingIssuableSynths","outputs":[{"internalType":"uint256","name":"maxIssuable","type":"uint256"},{"internalType":"uint256","name":"alreadyIssued","type":"uint256"},{"internalType":"uint256","name":"totalSystemDebt","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"removeSynth","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"removeSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"resolver","outputs":[{"internalType":"contract AddressResolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"resolverAddressesRequired","outputs":[{"internalType":"bytes32[]","name":"addresses","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint128","name":"periodId","type":"uint128"}],"name":"setCurrentPeriodId","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"synths","outputs":[{"internalType":"contract ISynth","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"synthsByAddress","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"bool","name":"excludeOtherCollateral","type":"bool"}],"name":"totalIssuedSynths","outputs":[{"internalType":"uint256","name":"totalIssued","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"}],"name":"transferableSynthetixAndAnyRateIsInvalid","outputs":[{"internalType":"uint256","name":"transferable","type":"uint256"},{"internalType":"bool","name":"anyRateIsInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"short","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"upgradeCollateralShort","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5060405162006099380380620060998339810160408190526200003491620000fc565b8080836001600160a01b038116620000695760405162461bcd60e51b81526004016200006090620001b8565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000b691849062000192565b60405180910390a150600280546001600160a01b0319166001600160a01b03929092169190911790555062000213915050565b8051620000f681620001f9565b92915050565b600080604083850312156200011057600080fd5b60006200011e8585620000e9565b92505060206200013185828601620000e9565b9150509250929050565b6200014681620001e5565b82525050565b6200014681620001d3565b600062000166601983620001ca565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b60408101620001a282856200013b565b620001b160208301846200014c565b9392505050565b60208082528101620000f68162000157565b90815260200190565b60006001600160a01b038216620000f6565b6000620000f6826000620000f682620001d3565b6200020481620001d3565b81146200021057600080fd5b50565b615e7680620002236000396000f3fe608060405234801561001057600080fd5b50600436106102bb5760003560e01c806372c6581611610182578063a311c7c2116100e9578063c81ff8fa116100a2578063d686c06c1161007c578063d686c06c1461061d578063dbf6334014610630578063dd3d2b2e14610638578063fd864ccf1461064b576102bb565b8063c81ff8fa146105e4578063c8977132146105f7578063d37c4d8b1461060a576102bb565b8063a311c7c21461057d578063a5fdc5de14610590578063ae3bbbbb146105a3578063b06e8c65146105b6578063b410a034146105c9578063bff4fdfc146105d1576102bb565b8063835e119c1161013b578063835e119c14610521578063849cf58814610534578063890235d414610547578063899ffef41461055a5780638da5cb5b146105625780639a5154b41461056a576102bb565b806372c65816146104c357806372cb051f146104d657806374185360146104eb57806379ba5097146104f35780637b1001b7146104fb57806380aa6a911461050e576102bb565b806331e6da5a116102265780634e99bda9116101df5780634e99bda91461044757806353a47bb71461044f5780635e887fe914610464578063614d08f8146104875780636bed04151461048f5780637168d2c2146104b0576102bb565b806331e6da5a146103c857806332608039146103db5780633b6afe40146103ee57806344ec6b621461040e57806347a9b6db14610421578063497d704a14610434576102bb565b80631627540c116102785780631627540c1461035f57806316b2213f146103725780631b3ba4d014610385578063242df9e1146103985780632af64bd3146103a05780632b3f41aa146103b5576102bb565b8063042e0688146102c057806304f3bcec146102d557806305b3c1c9146102f35780630b887dae146103135780631137aedf146103265780631313e6ca14610348575b600080fd5b6102d36102ce366004614ce5565b61065e565b005b6102dd6106cf565b6040516102ea9190615a85565b60405180910390f35b610306610301366004614bf2565b6106de565b6040516102ea91906159d1565b6102d3610321366004614dbc565b6106f4565b610339610334366004614bf2565b6107d2565b6040516102ea939291906159fb565b6103506107ee565b6040516102ea93929190615c9b565b6102d361036d366004614bf2565b610895565b610306610380366004614bf2565b6108f3565b6102d3610393366004614ce5565b610905565b610306610af1565b6103a8610b01565b6040516102ea91906159c3565b6102d36103c3366004614c2e565b610c18565b6102d36103d6366004614e74565b610c67565b6102dd6103e9366004614dbc565b610d6c565b6104016103fc366004614d15565b610d87565b6040516102ea91906159b2565b6102d361041c366004614c68565b610e35565b6102d361042f366004614d15565b610e88565b6102d3610442366004614bf2565b610f39565b6103a8610f81565b610457611013565b6040516102ea91906158de565b610477610472366004614cb5565b611022565b6040516102ea9493929190615cc3565b610306611044565b6104a261049d366004614ce5565b611051565b6040516102ea929190615c8d565b6102d36104be366004614d15565b6110bd565b6103396104d1366004614cb5565b6111f2565b6104de611364565b6040516102ea91906159a1565b6102d3611370565b6102d36114c2565b610306610509366004614e19565b61155e565b6102d361051c366004614ce5565b611572565b6102dd61052f366004614dbc565b61195d565b6102d3610542366004614e38565b611984565b6103a8610555366004614df8565b6119f7565b6104de611d7d565b610457612022565b6102d3610578366004614c68565b612031565b61030661058b366004614bf2565b61207f565b61030661059e366004614bf2565b612091565b6104a26105b1366004614bf2565b61209c565b6102d36105c4366004614ce5565b6120b2565b6103066120f6565b6103a86105df366004614bf2565b612100565b6103a86105f2366004614df8565b61210b565b6102d3610605366004614bf2565b6124d1565b610306610618366004614ce5565b612516565b6102d361062b366004614c68565b612548565b6103066125ee565b610306610646366004614bf2565b6125f4565b6102d3610659366004614c2e565b6125ff565b61066661264e565b6001600160a01b0316336001600160a01b03161461069f5760405162461bcd60e51b815260040161069690615b4f565b60405180910390fd5b600081116106bf5760405162461bcd60e51b815260040161069690615c1f565b6106cb82826000612665565b5050565b6002546001600160a01b031681565b6000806106ea8361278f565b509150505b919050565b6106fc6127e2565b600061070661280e565b604051636b42ba1d60e11b81529091506001600160a01b0382169063d685743a90610738908590600090600401615a23565b600060405180830381600087803b15801561075257600080fd5b505af1158015610766573d6000803e3d6000fd5b50506040516304bd11e560e01b81526001600160a01b03841692506304bd11e59150610797906001906004016159c3565b600060405180830381600087803b1580156107b157600080fd5b505af11580156107c5573d6000803e3d6000fd5b505050506106cb82612825565b60008060006107e084612cd3565b509196909550909350915050565b60008060008060006108276108227f6578743a41676772656761746f7249737375656453796e746873000000000000612d43565b612da0565b50935050925050600080610839612e2b565b915091508396508160001461085d57610858878363ffffffff612e6616565b610860565b60005b9550600061086c612e86565b905042811080156108895750838142031180610889575081814203115b95505050505050909192565b61089d6127e2565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906108e89083906158de565b60405180910390a150565b60066020526000908152604090205481565b61090d6127e2565b6002546040516321f8a72160e01b81526001600160a01b03909116906321f8a7219061093b90600401615b12565b60206040518083038186803b15801561095357600080fd5b505afa158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061098b9190810190614c10565b6001600160a01b0316826001600160a01b0316146109bb5760405162461bcd60e51b815260040161069690615af2565b600081116109db5760405162461bcd60e51b815260040161069690615c0f565b6109e3612f30565b6001600160a01b0316631b16802c83631cd554d160e21b6040518363ffffffff1660e01b8152600401610a17929190615922565b606060405180830381600087803b158015610a3157600080fd5b505af1158015610a45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a699190810190614f73565b5050631cd554d160e21b600052506005602052600080516020615e1483398151915254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90610abb9085908590600401615922565b600060405180830381600087803b158015610ad557600080fd5b505af1158015610ae9573d6000803e3d6000fd5b505050505050565b6000610afb612f47565b90505b90565b60006060610b0d611d7d565b905060005b8151811015610c0f576000828281518110610b2957fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a72190610b7a9085906004016159d1565b60206040518083038186803b158015610b9257600080fd5b505afa158015610ba6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610bca9190810190614c10565b6001600160a01b0316141580610bf557506000818152600360205260409020546001600160a01b0316155b15610c065760009350505050610afe565b50600101610b12565b50600191505090565b610c2061264e565b6001600160a01b0316336001600160a01b031614610c505760405162461bcd60e51b815260040161069690615b4f565b610c5a8282612fa2565b6106cb8260006001613043565b610c7a66119959541bdbdb60ca1b612d43565b6001600160a01b0316336001600160a01b031614610caa5760405162461bcd60e51b815260040161069690615b6f565b6000610cb46132b6565b9050816001600160801b0316816001600160a01b031663988e65956040518163ffffffff1660e01b815260040160206040518083038186803b158015610cf957600080fd5b505afa158015610d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d319190810190614e92565b6001600160801b031610156106cb5760405163abb6de9560e01b81526001600160a01b0382169063abb6de9590610abb908590600401615c7f565b6005602052600090815260409020546001600160a01b031681565b60408051828152602080840282010190915260609082908290828015610db7578160200160208202803883390190505b50905060005b82811015610e2a5760056000878784818110610dd557fe5b90506020020135815260200190815260200160002060009054906101000a90046001600160a01b0316828281518110610e0a57fe5b6001600160a01b0390921660209283029190910190910152600101610dbd565b509150505b92915050565b610e3d61264e565b6001600160a01b0316336001600160a01b031614610e6d5760405162461bcd60e51b815260040161069690615b4f565b610e7783836132d6565b610e8383826000612665565b505050565b610e906127e2565b8060005b81811015610ecd57610ec5848483818110610eab57fe5b9050602002016020610ec09190810190614e38565b61330b565b600101610e94565b50610ed661280e565b6001600160a01b03166304bd11e560016040518263ffffffff1660e01b8152600401610f0291906159c3565b600060405180830381600087803b158015610f1c57600080fd5b505af1158015610f30573d6000803e3d6000fd5b50505050505050565b610f4161264e565b6001600160a01b0316336001600160a01b031614610f715760405162461bcd60e51b815260040161069690615b4f565b610f7e8160006001613043565b50565b6000610f8b61349c565b6001600160a01b031663c8e5bbd5610fa360016134b7565b6040518263ffffffff1660e01b8152600401610fbf91906159a1565b60006040518083038186803b158015610fd757600080fd5b505afa158015610feb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e2f9190810190614d57565b6001546001600160a01b031681565b6000806000806110328686613593565b93509350935093505b92959194509250565b6524b9b9bab2b960d11b81565b600080600061106e61106286613941565b620a69cb60eb1b6139c6565b93509091506000905061108f611082613a37565b839063ffffffff613a8f16565b90508481106110a157600093506110b4565b6110b1858263ffffffff613aa416565b93505b50509250929050565b6110c56127e2565b8060006110d061280e565b90506060826040519080825280602002602001820160405280156110fe578160200160208202803883390190505b506040516305ece36d60e21b81529091506001600160a01b038316906317b38db4906111329088908890869060040161597b565b600060405180830381600087803b15801561114c57600080fd5b505af1158015611160573d6000803e3d6000fd5b50506040516304bd11e560e01b81526001600160a01b03851692506304bd11e59150611191906001906004016159c3565b600060405180830381600087803b1580156111ab57600080fd5b505af11580156111bf573d6000803e3d6000fd5b506000925050505b83811015610ae9576111ea8686838181106111de57fe5b90506020020135612825565b6001016111c7565b60008060006111ff61264e565b6001600160a01b0316336001600160a01b03161461122f5760405162461bcd60e51b815260040161069690615b4f565b611237613acc565b6001600160a01b031663952225f386866040518363ffffffff1660e01b8152600401611264929190615907565b60206040518083038186803b15801561127c57600080fd5b505afa158015611290573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112b49190810190614d9e565b6112d05760405162461bcd60e51b815260040161069690615baf565b60006112dc8686613593565b929650909450925090506112f1868483613ae4565b8461135c576112fe613acc565b6001600160a01b031663974e9e7f876040518263ffffffff1660e01b815260040161132991906158de565b600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b505050505b509250925092565b6060610afb60006134b7565b606061137a611d7d565b905060005b81518110156106cb57600082828151811061139657fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016113d891906158d3565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401611404929190615a3e565b60206040518083038186803b15801561141c57600080fd5b505afa158015611430573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114549190810190614c10565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68906114b090849084906159df565b60405180910390a1505060010161137f565b6001546001600160a01b031633146114ec5760405162461bcd60e51b815260040161069690615ac2565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9261152f926001600160a01b03918216929116906158ec565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b600061156a8383613c1b565b509392505050565b6002546040516321f8a72160e01b81526000916001600160a01b0316906321f8a721906115bc9075446562744d69677261746f724f6e457468657265756d60501b906004016159d1565b60206040518083038186803b1580156115d457600080fd5b505afa1580156115e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061160c9190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a7219061165b9075446562744d69677261746f724f6e4f7074696d69736d60501b906004016159d1565b60206040518083038186803b15801561167357600080fd5b505afa158015611687573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116ab9190810190614c10565b9050336001600160a01b03831614806116cc5750336001600160a01b038216145b6116e85760405162461bcd60e51b815260040161069690615c2f565b6001600160a01b038216158061170557506001600160a01b038116155b6117215760405162461bcd60e51b815260040161069690615ab2565b600061172b6132b6565b6002546040516321f8a72160e01b81529192506001600160a01b0316906321f8a721906117759075446562744d69677261746f724f6e457468657265756d60501b906004016159d1565b60206040518083038186803b15801561178d57600080fd5b505afa1580156117a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117c59190810190614c10565b6001600160a01b0316336001600160a01b0316141561184357604051631a378f0d60e01b81526001600160a01b03821690631a378f0d9061180c9088908890600401615922565b600060405180830381600087803b15801561182657600080fd5b505af115801561183a573d6000803e3d6000fd5b50505050611956565b6002546040516321f8a72160e01b81526001600160a01b03909116906321f8a7219061188c9075446562744d69677261746f724f6e4f7074696d69736d60501b906004016159d1565b60206040518083038186803b1580156118a457600080fd5b505afa1580156118b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118dc9190810190614c10565b6001600160a01b0316336001600160a01b0316141561195657604051636178258560e11b81526001600160a01b0382169063c2f04b0a906119239088908890600401615922565b600060405180830381600087803b15801561193d57600080fd5b505af1158015611951573d6000803e3d6000fd5b505050505b5050505050565b6004818154811061196a57fe5b6000918252602090912001546001600160a01b0316905081565b61198c6127e2565b6119958161330b565b61199d61280e565b6001600160a01b03166304bd11e560016040518263ffffffff1660e01b81526004016119c991906159c3565b600060405180830381600087803b1580156119e357600080fd5b505af1158015611956573d6000803e3d6000fd5b6002546040516321f8a72160e01b815260009182916001600160a01b03909116906321f8a72190611a48907853796e746865746978427269646765546f4f7074696d69736d60381b906004016159d1565b60206040518083038186803b158015611a6057600080fd5b505afa158015611a74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a989190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a72190611ae6907453796e746865746978427269646765546f4261736560581b906004016159d1565b60206040518083038186803b158015611afe57600080fd5b505afa158015611b12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b369190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a72190611b769066119959541bdbdb60ca1b906004016159d1565b60206040518083038186803b158015611b8e57600080fd5b505afa158015611ba2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611bc69190810190614c10565b9050336001600160a01b0384161480611be75750336001600160a01b038316145b80611bfa5750336001600160a01b038216145b611c165760405162461bcd60e51b815260040161069690615ad2565b6000878152600560205260409020546001600160a01b0316611c4a5760405162461bcd60e51b815260040161069690615b8f565b60008511611c6a5760405162461bcd60e51b815260040161069690615c1f565b611c7386613da6565b6000878152600560205260409081902054905163219e412d60e21b81526001600160a01b039091169063867904b490611cb29089908990600401615922565b600060405180830381600087803b158015611ccc57600080fd5b505af1158015611ce0573d6000803e3d6000fd5b50505050600080611cf089613e1f565b91509150611cfc61280e565b6001600160a01b03166342c7b819611d22611d1d8a8663ffffffff613ea416565b613ece565b6040518263ffffffff1660e01b8152600401611d3e91906159d1565b600060405180830381600087803b158015611d5857600080fd5b505af1158015611d6c573d6000803e3d6000fd5b50929b9a5050505050505050505050565b606080611d88613ef7565b60408051600e8082526101e0820190925291925060609190602082016101c080388339019050509050680a6f2dce8d0cae8d2f60bb1b81600081518110611dcb57fe5b6020026020010181815250506822bc31b430b733b2b960b91b81600181518110611df157fe5b6020026020010181815250506c45786368616e6765526174657360981b81600281518110611e1b57fe5b6020026020010181815250506d21b4b931bab4ba213932b0b5b2b960911b81600381518110611e4657fe5b6020026020010181815250507153796e74686574697844656274536861726560701b81600481518110611e7557fe5b60200260200101818152505066119959541bdbdb60ca1b81600581518110611e9957fe5b6020026020010181815250507044656c6567617465417070726f76616c7360781b81600681518110611ec757fe5b6020026020010181815250506d2932bbb0b93222b9b1b937bbab1960911b81600781518110611ef257fe5b602002602001018181525050692634b8bab4b230ba37b960b11b81600881518110611f1957fe5b602002602001018181525050704c697175696461746f725265776172647360781b81600981518110611f4757fe5b6020026020010181815250506844656274436163686560b81b81600a81518110611f6d57fe5b6020026020010181815250506c29bcb73a342932b232b2b6b2b960991b81600b81518110611f9757fe5b6020026020010181815250507f6578743a41676772656761746f7249737375656453796e74687300000000000081600c81518110611fd157fe5b602002602001018181525050766578743a41676772656761746f7244656274526174696f60481b81600d8151811061200557fe5b60200260200101818152505061201b8282613f48565b9250505090565b6000546001600160a01b031681565b61203961264e565b6001600160a01b0316336001600160a01b0316146120695760405162461bcd60e51b815260040161069690615b4f565b6120738383612fa2565b610e8383826000613043565b600061208a82613ffd565b5092915050565b6000610e2f82614053565b6000806120a883613ffd565b915091505b915091565b6120ba61264e565b6001600160a01b0316336001600160a01b0316146120ea5760405162461bcd60e51b815260040161069690615b4f565b6106cb82826000613043565b6000610afb613a37565b6000610e2f826140ef565b6002546040516321f8a72160e01b815260009182916001600160a01b03909116906321f8a7219061215c907853796e746865746978427269646765546f4f7074696d69736d60381b906004016159d1565b60206040518083038186803b15801561217457600080fd5b505afa158015612188573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506121ac9190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a721906121fa907453796e746865746978427269646765546f4261736560581b906004016159d1565b60206040518083038186803b15801561221257600080fd5b505afa158015612226573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061224a9190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a7219061228a9066119959541bdbdb60ca1b906004016159d1565b60206040518083038186803b1580156122a257600080fd5b505afa1580156122b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506122da9190810190614c10565b9050336001600160a01b03841614806122fb5750336001600160a01b038316145b8061230e5750336001600160a01b038216145b61232a5760405162461bcd60e51b815260040161069690615ad2565b6000878152600560205260409020546001600160a01b031661235e5760405162461bcd60e51b815260040161069690615b8f565b6000851161237e5760405162461bcd60e51b815260040161069690615c1f565b612386612f30565b6001600160a01b0316631b16802c87896040518363ffffffff1660e01b81526004016123b3929190615922565b606060405180830381600087803b1580156123cd57600080fd5b505af11580156123e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124059190810190614f73565b50505060008781526005602052604090819020549051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906124479089908990600401615922565b600060405180830381600087803b15801561246157600080fd5b505af1158015612475573d6000803e3d6000fd5b5050505060008061248589613e1f565b9150915061249161280e565b6001600160a01b03166342c7b8196124b2611d1d8a8663ffffffff613ea416565b6000036040518263ffffffff1660e01b8152600401611d3e91906159d1565b6124d961264e565b6001600160a01b0316336001600160a01b0316146125095760405162461bcd60e51b815260040161069690615b4f565b610f7e8160006001612665565b60008061252284613941565b905080612533576000915050610e2f565b61253d81846139c6565b509095945050505050565b61255061410e565b826001600160a01b031663d4b839926040518163ffffffff1660e01b815260040160206040518083038186803b15801561258957600080fd5b505afa15801561259d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506125c19190810190614c10565b6001600160a01b0316639dc29fac83836040518363ffffffff1660e01b8152600401610f02929190615922565b60045490565b6000610e2f82614146565b61260761264e565b6001600160a01b0316336001600160a01b0316146126375760405162461bcd60e51b815260040161069690615b4f565b61264182826132d6565b6106cb8260006001612665565b6000610afb680a6f2dce8d0cae8d2f60bb1b612d43565b61266d6141bf565b1561267757610e83565b60008061268385612cd3565b93505050915061269281614388565b826126bc57818411156126b75760405162461bcd60e51b815260040161069690615b2f565b6126c0565b8193505b6126ca85856143a6565b6126d385613da6565b631cd554d160e21b6000526005602052600080516020615e148339815191525460405163219e412d60e21b81526001600160a01b039091169063867904b4906127229088908890600401615922565b600060405180830381600087803b15801561273c57600080fd5b505af1158015612750573d6000803e3d6000fd5b5050505061275c61280e565b6001600160a01b03166342c7b81961277386613ece565b6040518263ffffffff1660e01b815260040161192391906159d1565b6000806000806127a4620a69cb60eb1b613e1f565b9150915060006127bc6127b687614053565b846144f0565b90506127d66127c9613a37565b829063ffffffff613ea416565b94509092505050915091565b6000546001600160a01b0316331461280c5760405162461bcd60e51b815260040161069690615bbf565b565b6000610afb6844656274436163686560b81b612d43565b6000818152600560205260409020546001600160a01b03168061285a5760405162461bcd60e51b815260040161069690615b9f565b631cd554d160e21b8214156128815760405162461bcd60e51b815260040161069690615bef565b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156128bc57600080fd5b505afa1580156128d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506128f49190810190614dda565b90508015612b765760008061290761349c565b6001600160a01b0316638295016a86856040518363ffffffff1660e01b8152600401612934929190615a5e565b60606040518083038186803b15801561294c57600080fd5b505afa158015612960573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506129849190810190614f73565b5091509150600081116129a95760405162461bcd60e51b815260040161069690615c6f565b60006129b3614502565b631cd554d160e21b6000526005602052600080516020615e148339815191525460405163219e412d60e21b81529192506001600160a01b03169063867904b490612a039084908790600401615922565b600060405180830381600087803b158015612a1d57600080fd5b505af1158015612a31573d6000803e3d6000fd5b50505050612a3d61280e565b6001600160a01b03166342c7b819612a5485613ece565b6040518263ffffffff1660e01b8152600401612a7091906159d1565b600060405180830381600087803b158015612a8a57600080fd5b505af1158015612a9e573d6000803e3d6000fd5b50505050806001600160a01b0316633a70599c866001600160a01b031663ec5568896040518163ffffffff1660e01b815260040160206040518083038186803b158015612aea57600080fd5b505afa158015612afe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612b229190810190614e56565b846040518363ffffffff1660e01b8152600401612b40929190615a93565b600060405180830381600087803b158015612b5a57600080fd5b505af1158015612b6e573d6000803e3d6000fd5b505050505050505b60005b600454811015612c5d57826001600160a01b031660048281548110612b9a57fe5b6000918252602090912001546001600160a01b03161415612c555760048181548110612bc257fe5b600091825260209091200180546001600160a01b0319169055600480546000198101908110612bed57fe5b600091825260209091200154600480546001600160a01b039092169183908110612c1357fe5b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790556004805490612c4f906000198301614a7f565b50612c5d565b600101612b79565b506001600160a01b038216600090815260066020908152604080832083905585835260059091529081902080546001600160a01b0319169055517f6166f5c475cc1cd535c6cdf14a6d5edb811e34117031fc2863392a136eb655d090612cc690859085906159df565b60405180910390a1505050565b600080600080612cf2612ce586613941565b631cd554d160e21b6139c6565b91945092509050600080612d058761278f565b915091508195508280612d155750805b9250858510612d275760009550612d3a565b612d37868663ffffffff613aa416565b95505b50509193509193565b60008181526003602090815260408083205490516001600160a01b039091169182151591612d73918691016158b3565b6040516020818303038152906040529061208a5760405162461bcd60e51b81526004016106969190615aa1565b6000806000806000856001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015612de157600080fd5b505afa158015612df5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612e199190810190614fb6565b939a9299509097509550909350915050565b600080600080612e57610822766578743a41676772656761746f7244656274526174696f60481b612d43565b50919650909450505050509091565b6000612e7f83836b033b2e3c9fd0803ce800000061451d565b9392505050565b6000612e90614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6e1c985d1954dd185b1954195c9a5bd9608a1b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b60206040518083038186803b158015612ef857600080fd5b505afa158015612f0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610afb9190810190614dda565b6000610afb6822bc31b430b733b2b960b91b612d43565b6000612f51614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f6d696e696d756d5374616b6554696d6560801b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b612faa61457e565b6001600160a01b0316637d3f0ba283836040518363ffffffff1660e01b8152600401612fd79291906158ec565b60206040518083038186803b158015612fef57600080fd5b505afa158015613003573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506130279190810190614d9e565b6106cb5760405162461bcd60e51b815260040161069690615ae2565b61304b6141bf565b1561305557610e83565b806131b257613063836140ef565b61307f5760405162461bcd60e51b815260040161069690615c4f565b60008061308a612f30565b6001600160a01b0316631b16802c86631cd554d160e21b6040518363ffffffff1660e01b81526004016130be929190615922565b606060405180830381600087803b1580156130d857600080fd5b505af11580156130ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506131109190810190614f73565b90935091505080156131af57613124612f30565b6001600160a01b0316634c268fc886631cd554d160e21b87866040518563ffffffff1660e01b815260040161315c949392919061593d565b60206040518083038186803b15801561317457600080fd5b505afa158015613188573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506131ac9190810190614dda565b93505b50505b6000806131c1612ce586613941565b92505091506000806131d28761278f565b915091506131e783806131e25750815b614388565b600084116132075760405162461bcd60e51b815260040161069690615b1f565b84156132205761321d848363ffffffff613aa416565b95505b600061322e8889898861459d565b905082613241868363ffffffff613aa416565b116132ac5761324e613acc565b6001600160a01b031663974e9e7f896040518263ffffffff1660e01b815260040161327991906158de565b600060405180830381600087803b15801561329357600080fd5b505af11580156132a7573d6000803e3d6000fd5b505050505b5050505050505050565b6000610afb7153796e74686574697844656274536861726560701b612d43565b6132de61457e565b6001600160a01b0316630487261783836040518363ffffffff1660e01b8152600401612fd79291906158ec565b6000816001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b15801561334657600080fd5b505afa15801561335a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061337e9190810190614dda565b6000818152600560205260409020549091506001600160a01b0316156133b65760405162461bcd60e51b815260040161069690615c3f565b6001600160a01b038216600090815260066020526040902054156133ec5760405162461bcd60e51b815260040161069690615bcf565b60048054600181019091557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b0384166001600160a01b03199182168117909255600083815260056020908152604080832080549094168517909355928152600690925290819020829055517f0a2b6ebf143b3e9fcd67e17748ad315174746100c27228468b2c98c302c628849061349090839085906159df565b60405180910390a15050565b6000610afb6c45786368616e6765526174657360981b612d43565b606080826134c65760006134c9565b60015b60ff16600480549050016040519080825280602002602001820160405280156134fc578160200160208202803883390190505b50905060005b60045481101561356357600660006004838154811061351d57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054825183908390811061355057fe5b6020908102919091010152600101613502565b508215610e2f576004548151620a69cb60eb1b918391811061358157fe5b60200260200101818152505092915050565b60008060008060006135a7612ce588613941565b91935090915060009050806135c1620a69cb60eb1b613e1f565b915091506135d583806131e2575081614388565b600088156137b3576135e56146ca565b90506135ef613acc565b6001600160a01b031663f557f73c8661361061360a8e614053565b876144f0565b846040518463ffffffff1660e01b815260040161362f939291906159fb565b60206040518083038186803b15801561364757600080fd5b505afa15801561365b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061367f9190810190614dda565b9650613737613729613713837384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156136cf57600080fd5b505af41580156136e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506137079190810190614dda565b9063ffffffff61472b16565b61371d8a87614750565b9063ffffffff613ea416565b6137328c614762565b61476c565b97506137a361379d613787837384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156136cf57600080fd5b6137918b876144f0565b9063ffffffff61478216565b8861476c565b96506000955061103b9350505050565b6137bb6147a0565b905060006137d26137ca614800565b613707614855565b905060006137f86137f2836137e68f614053565b9063ffffffff613aa416565b866144f0565b9050613802613acc565b6001600160a01b031663f557f73c8883866040518463ffffffff1660e01b8152600401613831939291906159fb565b60206040518083038186803b15801561384957600080fd5b505afa15801561385d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506138819190810190614dda565b985060006138da6138d0857384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156136cf57600080fd5b61371d8c89614750565b90506138e58d614053565b6138f5828563ffffffff61472b16565b106139245787995061390a836137e68f614053565b9a506139158d6148af565b985061103b9650505050505050565b61392f8d82856148b9565b909b50985061103b9650505050505050565b600061394b6132b6565b6001600160a01b03166370a08231836040518263ffffffff1660e01b815260040161397691906158de565b60206040518083038186803b15801561398e57600080fd5b505afa1580156139a2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e2f9190810190614dda565b60008060008060006139d66107ee565b925050915086600014156139f257600094509092509050613a30565b6000806139fe88613e1f565b91509150613a1b82613a0f8b614914565b9063ffffffff613a8f16565b96508395508080613a295750825b9450505050505b9250925092565b6000613a41614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6c69737375616e6365526174696f60981b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b6000612e7f8383670de0b6b3a764000061451d565b600082821115613ac65760405162461bcd60e51b815260040161069690615b3f565b50900390565b6000610afb692634b8bab4b230ba37b960b11b612d43565b613aec614932565b6001600160a01b031663270fb338846040518263ffffffff1660e01b8152600401613b1791906158de565b600060405180830381600087803b158015613b3157600080fd5b505af1158015613b45573d6000803e3d6000fd5b505050506000613b536132b6565b90506000613b6085613941565b905082841415613b9857604051631a378f0d60e01b81526001600160a01b03831690631a378f0d9061180c9088908590600401615922565b6000613ba385614951565b9050826001600160a01b0316631a378f0d87848410613bc25784613bc4565b835b6040518363ffffffff1660e01b8152600401613be1929190615922565b600060405180830381600087803b158015613bfb57600080fd5b505af1158015613c0f573d6000803e3d6000fd5b50505050505050505050565b6000806000806000613c2b61280e565b6001600160a01b0316633a900a2e6040518163ffffffff1660e01b815260040160806040518083038186803b158015613c6357600080fd5b505afa158015613c77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613c9b9190810190614f12565b935093505092508180613cab5750805b935085613d5157600080613cbd61280e565b6001600160a01b0316632992dba26040518163ffffffff1660e01b8152600401604080518083038186803b158015613cf457600080fd5b505afa158015613d08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613d2c9190810190614eb0565b9092509050613d41858363ffffffff61472b16565b94508580613d4c5750805b955050505b631cd554d160e21b871415613d6b5750909250613d9f9050565b600080613d7789613e1f565b9092509050613d8c858363ffffffff613a8f16565b8680613d955750815b9650965050505050505b9250929050565b613dae614561565b6001600160a01b0316631d5b277f6524b9b9bab2b960d11b6d1b185cdd125cdcdd59515d995b9d60921b84604051602001613dea92919061588d565b60405160208183030381529060405280519060200120426040518463ffffffff1660e01b81526004016119c9939291906159fb565b600080613e2a61349c565b6001600160a01b0316630c71cd23846040518263ffffffff1660e01b8152600401613e5591906159d1565b604080518083038186803b158015613e6c57600080fd5b505afa158015613e80573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506120a89190810190614eb0565b6000670de0b6b3a7640000613ebf848463ffffffff61498316565b81613ec657fe5b049392505050565b6000600160ff1b8210613ef35760405162461bcd60e51b815260040161069690615c5f565b5090565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110613f3957fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015613f78578160200160208202803883390190505b50905060005b8351811015613fba57838181518110613f9357fe5b6020026020010151828281518110613fa757fe5b6020908102919091010152600101613f7e565b5060005b825181101561208a57828181518110613fd357fe5b6020026020010151828286510181518110613fea57fe5b6020908102919091010152600101613fbe565b600080600061400b84614053565b905060008061401c61106287613941565b92505091508260001415614038576000945092506120ad915050565b614048828463ffffffff613a8f16565b945092505050915091565b6000610e2f614060614932565b6001600160a01b0316628cc262846040518263ffffffff1660e01b815260040161408a91906158de565b60206040518083038186803b1580156140a257600080fd5b505afa1580156140b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506140da9190810190614dda565b6137076140e6856148af565b61370786614762565b60006141056140fc612f47565b61370784614146565b42101592915050565b614116614502565b6001600160a01b0316336001600160a01b03161461280c5760405162461bcd60e51b815260040161069690615bff565b6000614150614561565b6001600160a01b03166323257c2b6524b9b9bab2b960d11b6d1b185cdd125cdcdd59515d995b9d60921b8560405160200161418c92919061588d565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b81526004016139769291906159ed565b6000806141e5766578743a41676772656761746f7244656274526174696f60481b612d43565b90506000816001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561422257600080fd5b505afa158015614236573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061425a9190810190614fb6565b505050915050600061426a61349c565b6001600160a01b031663045056f8620a69cb60eb1b6040518263ffffffff1660e01b815260040161429b91906159d1565b606060405180830381600087803b1580156142b557600080fd5b505af11580156142c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506142ed9190810190614ecf565b509150506142f96149bd565b6001600160a01b031663413caeb584846040518363ffffffff1660e01b8152600401614326929190615922565b602060405180830381600087803b15801561434057600080fd5b505af1158015614354573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506143789190810190614d9e565b806143805750805b935050505090565b8015610f7e5760405162461bcd60e51b815260040161069690615b7f565b6143ae614932565b6001600160a01b031663270fb338836040518263ffffffff1660e01b81526004016143d991906158de565b600060405180830381600087803b1580156143f357600080fd5b505af1158015614407573d6000803e3d6000fd5b5050505060006144156132b6565b9050600061442283614951565b90508061448e57604051636178258560e11b81526001600160a01b0383169063c2f04b0a906144579087908790600401615922565b600060405180830381600087803b15801561447157600080fd5b505af1158015614485573d6000803e3d6000fd5b505050506144ea565b604051636178258560e11b81526001600160a01b0383169063c2f04b0a906144bc9087908590600401615922565b600060405180830381600087803b1580156144d657600080fd5b505af11580156132ac573d6000803e3d6000fd5b50505050565b6000612e7f838363ffffffff6149d916565b6000610afb6c29bcb73a342932b232b2b6b2b960991b612d43565b6000806145438461453787600a870263ffffffff61498316565b9063ffffffff6149ee16565b90506005600a825b061061455557600a015b600a9004949350505050565b6000610afb6e466c657869626c6553746f7261676560881b612d43565b6000610afb7044656c6567617465417070726f76616c7360781b612d43565b60006145a76141bf565b156145b4575060006146c2565b8282106145c157826145c3565b815b90506145d0858284613ae4565b631cd554d160e21b6000526005602052600080516020615e1483398151915254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac9061461f9087908590600401615922565b600060405180830381600087803b15801561463957600080fd5b505af115801561464d573d6000803e3d6000fd5b5050505061465961280e565b6001600160a01b03166342c7b81961467083613ece565b6000036040518263ffffffff1660e01b815260040161468f91906159d1565b600060405180830381600087803b1580156146a957600080fd5b505af11580156146bd573d6000803e3d6000fd5b505050505b949350505050565b60006146d4614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7573656c664c69717569646174696f6e50656e616c747960501b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b600082820183811015612e7f5760405162461bcd60e51b815260040161069690615b02565b6000612e7f838363ffffffff613a8f16565b600061394b61264e565b600081831061477b5781612e7f565b5090919050565b6000612e7f8261453785670de0b6b3a764000063ffffffff61498316565b60006147aa614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b74736e784c69717569646174696f6e50656e616c747960581b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b600061480a614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b69199b1859d4995dd85c9960b21b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b600061485f614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6e1b1a5c5d5a59185d1954995dd85c99608a1b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b600061394b614a23565b60008060006148c786614762565b9050806148da868663ffffffff61472b16565b116148ec57508391506000905061490c565b614900816137e6878763ffffffff61472b16565b859350915061490c9050565b935093915050565b60008061491f612e2b565b509050612e7f838263ffffffff614a3f16565b6000610afb704c697175696461746f725265776172647360781b612d43565b60008061495c612e2b565b509050801561497a57614975838263ffffffff612e6616565b612e7f565b50600092915050565b60008261499257506000610e2f565b8282028284828161499f57fe5b0414612e7f5760405162461bcd60e51b815260040161069690615bdf565b6000610afb6d21b4b931bab4ba213932b0b5b2b960911b612d43565b6000612e7f8383670de0b6b3a7640000614a54565b6000808211614a0f5760405162461bcd60e51b815260040161069690615b5f565b6000828481614a1a57fe5b04949350505050565b6000610afb6d2932bbb0b93222b9b1b937bbab1960911b612d43565b6000612e7f83836b033b2e3c9fd0803ce80000005b600080600a8304614a6b868663ffffffff61498316565b81614a7257fe5b0490506005600a8261454b565b815481835581811115610e8357600083815260209020610e83918101908301610afe91905b80821115613ef35760008155600101614aa4565b8035610e2f81615dd2565b8051610e2f81615dd2565b60008083601f840112614ae057600080fd5b50813567ffffffffffffffff811115614af857600080fd5b602083019150836020820283011115613d9f57600080fd5b600082601f830112614b2157600080fd5b8151614b34614b2f82615cf8565b615cd1565b91508181835260208401935060208101905083856020840282011115614b5957600080fd5b60005b83811015614b855781614b6f8882614bb0565b8452506020928301929190910190600101614b5c565b5050505092915050565b8035610e2f81615de6565b8051610e2f81615de6565b8035610e2f81615def565b8051610e2f81615def565b8035610e2f81615df8565b8051610e2f81615df8565b8035610e2f81615e01565b8051610e2f81615e01565b8051610e2f81615e0a565b600060208284031215614c0457600080fd5b60006146c28484614ab8565b600060208284031215614c2257600080fd5b60006146c28484614ac3565b60008060408385031215614c4157600080fd5b6000614c4d8585614ab8565b9250506020614c5e85828601614ab8565b9150509250929050565b600080600060608486031215614c7d57600080fd5b6000614c898686614ab8565b9350506020614c9a86828701614ab8565b9250506040614cab86828701614ba5565b9150509250925092565b60008060408385031215614cc857600080fd5b6000614cd48585614ab8565b9250506020614c5e85828601614b8f565b60008060408385031215614cf857600080fd5b6000614d048585614ab8565b9250506020614c5e85828601614ba5565b60008060208385031215614d2857600080fd5b823567ffffffffffffffff811115614d3f57600080fd5b614d4b85828601614ace565b92509250509250929050565b60008060408385031215614d6a57600080fd5b825167ffffffffffffffff811115614d8157600080fd5b614d8d85828601614b10565b9250506020614c5e85828601614b9a565b600060208284031215614db057600080fd5b60006146c28484614b9a565b600060208284031215614dce57600080fd5b60006146c28484614ba5565b600060208284031215614dec57600080fd5b60006146c28484614bb0565b600080600060608486031215614e0d57600080fd5b6000614c898686614ba5565b60008060408385031215614e2c57600080fd5b6000614cd48585614ba5565b600060208284031215614e4a57600080fd5b60006146c28484614bbb565b600060208284031215614e6857600080fd5b60006146c28484614bc6565b600060208284031215614e8657600080fd5b60006146c28484614bd1565b600060208284031215614ea457600080fd5b60006146c28484614bdc565b60008060408385031215614ec357600080fd5b6000614d8d8585614bb0565b600080600060608486031215614ee457600080fd5b6000614ef08686614bb0565b9350506020614f0186828701614b9a565b9250506040614cab86828701614b9a565b60008060008060808587031215614f2857600080fd5b6000614f348787614bb0565b9450506020614f4587828801614bb0565b9350506040614f5687828801614b9a565b9250506060614f6787828801614b9a565b91505092959194509250565b600080600060608486031215614f8857600080fd5b6000614f948686614bb0565b9350506020614fa586828701614bb0565b9250506040614cab86828701614bb0565b600080600080600060a08688031215614fce57600080fd5b6000614fda8888614be7565b9550506020614feb88828901614bb0565b9450506040614ffc88828901614bb0565b935050606061500d88828901614bb0565b925050608061501e88828901614be7565b9150509295509295909350565b600061503783836151a2565b505060200190565b600061503783836151bc565b61505481615d2c565b82525050565b61505461506682615d2c565b615db1565b60006150778385615d23565b93506001600160fb1b0383111561508d57600080fd5b60208302925061509e838584615d79565b50500190565b60006150af82615d1f565b6150b98185615d23565b93506150c483615d19565b8060005b838110156150f25781516150dc888261502b565b97506150e783615d19565b9250506001016150c8565b509495945050505050565b600061510882615d1f565b6151128185615d23565b935061511d83615d19565b8060005b838110156150f2578151615135888261503f565b975061514083615d19565b925050600101615121565b600061515682615d1f565b6151608185615d23565b935061516b83615d19565b8060005b838110156150f2578151615183888261502b565b975061518e83615d19565b92505060010161516f565b61505481615d37565b61505481610afe565b6150546151b782610afe565b610afe565b61505481615d3c565b61505481615d6e565b60006151d982615d1f565b6151e38185615d23565b93506151f3818560208601615d85565b6151fc81615dc2565b9093019392505050565b6000615213601883615d23565b7f6f6e65206d69677261746f72206d757374206265203078300000000000000000815260200192915050565b600061524c603583615d23565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b60006152a3601483615d23565b736f6e6c792074727573746564206d696e7465727360601b815260200192915050565b60006152d3601d83615d23565b7f4e6f7420617070726f76656420746f20616374206f6e20626568616c66000000815260200192915050565b600061530c600d83615d23565b6c77726f6e67206164647265737360981b815260200192915050565b6000615335601b83615d23565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b74436f6c6c61746572616c53686f72744c656761637960581b9052565b600061538b601283615d23565b714e6f206465627420746f20666f726769766560701b815260200192915050565b60006153b9601083615d23565b6f416d6f756e7420746f6f206c6172676560801b815260200192915050565b60006153e5601e83615d23565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b600061541e600e83615d23565b6d09edcd8f240a6f2dce8d0cae8d2f60931b815260200192915050565b6000615448601a83615d23565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006154816011836106ef565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006154ae601083615d23565b6f135d5cdd08189948199959481c1bdbdb60821b815260200192915050565b60006154da601e83615d23565b7f412073796e7468206f7220534e58207261746520697320696e76616c69640000815260200192915050565b6000615513601383615d23565b721cde5b9d1a08191bd95cdb89dd08195e1a5cdd606a1b815260200192915050565b6000615542601483615d23565b7314de5b9d1a08191bd95cc81b9bdd08195e1a5cdd60621b815260200192915050565b6000615572601883615d23565b7f4e6f74206f70656e20666f72206c69717569646174696f6e0000000000000000815260200192915050565b60006155ab602f83615d23565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b631cd554d160e21b9052565b6000615608601c83615d23565b7f53796e7468206164647265737320616c72656164792065786973747300000000815260200192915050565b6000615641602183615d23565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000615684601383615d23565b72086c2dcdcdee840e4cadadeecca40e6f2dce8d606b1b815260200192915050565b60006156b3601283615d23565b7127b7363c9029bcb73a342932b232b2b6b2b960711b815260200192915050565b60006156e1601483615d23565b7363616e6e6f74206275726e20302073796e74687360601b815260200192915050565b6000615711601583615d23565b7463616e6e6f7420697373756520302073796e74687360581b815260200192915050565b60006157426019836106ef565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b600061577b601683615d23565b756f6e6c792074727573746564206d69677261746f727360501b815260200192915050565b60006157ad600c83615d23565b6b53796e74682065786973747360a01b815260200192915050565b60006157d5601e83615d23565b7f4d696e696d756d207374616b652074696d65206e6f7420726561636865640000815260200192915050565b600061580e602883615d23565b7f53616665436173743a2076616c756520646f65736e27742066697420696e2061815267371034b73a191a9b60c11b602082015260400192915050565b6000615858601a83615d23565b7f43616e6e6f742072656d6f766520776974686f75742072617465000000000000815260200192915050565b61505481615d47565b600061589982856151ab565b6020820191506158a9828461505a565b5060140192915050565b60006158be82615474565b91506158ca82846151ab565b50602001919050565b60006158be82615735565b60208101610e2f828461504b565b604081016158fa828561504b565b612e7f602083018461504b565b60408101615915828561504b565b612e7f6020830184615199565b60408101615930828561504b565b612e7f60208301846151a2565b6080810161594b828761504b565b61595860208301866151a2565b61596560408301856151a2565b61597260608301846151a2565b95945050505050565b6040808252810161598d81858761506b565b90508181036020830152615972818461514b565b60208082528101612e7f81846150a4565b60208082528101612e7f81846150fd565b60208101610e2f8284615199565b60208101610e2f82846151a2565b604081016158fa82856151a2565b6040810161593082856151a2565b60608101615a0982866151a2565b615a1660208301856151a2565b6146c260408301846151a2565b60408101615a3182856151a2565b612e7f60208301846151c5565b60408101615a4c82856151a2565b81810360208301526146c281846151ce565b60608101615a6c82856151a2565b615a7960208301846151a2565b612e7f604083016155ef565b60208101610e2f82846151bc565b6040810161593082856151bc565b60208082528101612e7f81846151ce565b60208082528101610e2f81615206565b60208082528101610e2f8161523f565b60208082528101610e2f81615296565b60208082528101610e2f816152c6565b60208082528101610e2f816152ff565b60208082528101610e2f81615328565b602081016106ef82615361565b60208082528101610e2f8161537e565b60208082528101610e2f816153ac565b60208082528101610e2f816153d8565b60208082528101610e2f81615411565b60208082528101610e2f8161543b565b60208082528101610e2f816154a1565b60208082528101610e2f816154cd565b60208082528101610e2f81615506565b60208082528101610e2f81615535565b60208082528101610e2f81615565565b60208082528101610e2f8161559e565b60208082528101610e2f816155fb565b60208082528101610e2f81615634565b60208082528101610e2f81615677565b60208082528101610e2f816156a6565b60208082528101610e2f816156d4565b60208082528101610e2f81615704565b60208082528101610e2f8161576e565b60208082528101610e2f816157a0565b60208082528101610e2f816157c8565b60208082528101610e2f81615801565b60208082528101610e2f8161584b565b60208101610e2f8284615884565b6040810161591582856151a2565b60608101615ca982866151a2565b615cb660208301856151a2565b6146c26040830184615199565b6080810161594b82876151a2565b60405181810167ffffffffffffffff81118282101715615cf057600080fd5b604052919050565b600067ffffffffffffffff821115615d0f57600080fd5b5060209081020190565b60200190565b5190565b90815260200190565b6000610e2f82615d53565b151590565b6000610e2f82615d2c565b6001600160801b031690565b6001600160a01b031690565b69ffffffffffffffffffff1690565b6000610e2f82610afe565b82818337506000910152565b60005b83811015615da0578181015183820152602001615d88565b838111156144ea5750506000910152565b6000610e2f826000610e2f82615dcc565b601f01601f191690565b60601b90565b615ddb81615d2c565b8114610f7e57600080fd5b615ddb81615d37565b615ddb81610afe565b615ddb81615d3c565b615ddb81615d47565b615ddb81615d5f56fe74c62d09fbc50aefae0794a9a068f786a692826fbdfe63828ec23a875865823fa365627a7a723158207d089a8f784c6219cab4a22411b0374ef35ef8ab0fec92242ba40a17c890a9e66c6578706572696d656e74616cf564736f6c63430005100040000000000000000000000000302d2451d9f47620374b54c521423bf0403916a20000000000000000000000004e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef2

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102bb5760003560e01c806372c6581611610182578063a311c7c2116100e9578063c81ff8fa116100a2578063d686c06c1161007c578063d686c06c1461061d578063dbf6334014610630578063dd3d2b2e14610638578063fd864ccf1461064b576102bb565b8063c81ff8fa146105e4578063c8977132146105f7578063d37c4d8b1461060a576102bb565b8063a311c7c21461057d578063a5fdc5de14610590578063ae3bbbbb146105a3578063b06e8c65146105b6578063b410a034146105c9578063bff4fdfc146105d1576102bb565b8063835e119c1161013b578063835e119c14610521578063849cf58814610534578063890235d414610547578063899ffef41461055a5780638da5cb5b146105625780639a5154b41461056a576102bb565b806372c65816146104c357806372cb051f146104d657806374185360146104eb57806379ba5097146104f35780637b1001b7146104fb57806380aa6a911461050e576102bb565b806331e6da5a116102265780634e99bda9116101df5780634e99bda91461044757806353a47bb71461044f5780635e887fe914610464578063614d08f8146104875780636bed04151461048f5780637168d2c2146104b0576102bb565b806331e6da5a146103c857806332608039146103db5780633b6afe40146103ee57806344ec6b621461040e57806347a9b6db14610421578063497d704a14610434576102bb565b80631627540c116102785780631627540c1461035f57806316b2213f146103725780631b3ba4d014610385578063242df9e1146103985780632af64bd3146103a05780632b3f41aa146103b5576102bb565b8063042e0688146102c057806304f3bcec146102d557806305b3c1c9146102f35780630b887dae146103135780631137aedf146103265780631313e6ca14610348575b600080fd5b6102d36102ce366004614ce5565b61065e565b005b6102dd6106cf565b6040516102ea9190615a85565b60405180910390f35b610306610301366004614bf2565b6106de565b6040516102ea91906159d1565b6102d3610321366004614dbc565b6106f4565b610339610334366004614bf2565b6107d2565b6040516102ea939291906159fb565b6103506107ee565b6040516102ea93929190615c9b565b6102d361036d366004614bf2565b610895565b610306610380366004614bf2565b6108f3565b6102d3610393366004614ce5565b610905565b610306610af1565b6103a8610b01565b6040516102ea91906159c3565b6102d36103c3366004614c2e565b610c18565b6102d36103d6366004614e74565b610c67565b6102dd6103e9366004614dbc565b610d6c565b6104016103fc366004614d15565b610d87565b6040516102ea91906159b2565b6102d361041c366004614c68565b610e35565b6102d361042f366004614d15565b610e88565b6102d3610442366004614bf2565b610f39565b6103a8610f81565b610457611013565b6040516102ea91906158de565b610477610472366004614cb5565b611022565b6040516102ea9493929190615cc3565b610306611044565b6104a261049d366004614ce5565b611051565b6040516102ea929190615c8d565b6102d36104be366004614d15565b6110bd565b6103396104d1366004614cb5565b6111f2565b6104de611364565b6040516102ea91906159a1565b6102d3611370565b6102d36114c2565b610306610509366004614e19565b61155e565b6102d361051c366004614ce5565b611572565b6102dd61052f366004614dbc565b61195d565b6102d3610542366004614e38565b611984565b6103a8610555366004614df8565b6119f7565b6104de611d7d565b610457612022565b6102d3610578366004614c68565b612031565b61030661058b366004614bf2565b61207f565b61030661059e366004614bf2565b612091565b6104a26105b1366004614bf2565b61209c565b6102d36105c4366004614ce5565b6120b2565b6103066120f6565b6103a86105df366004614bf2565b612100565b6103a86105f2366004614df8565b61210b565b6102d3610605366004614bf2565b6124d1565b610306610618366004614ce5565b612516565b6102d361062b366004614c68565b612548565b6103066125ee565b610306610646366004614bf2565b6125f4565b6102d3610659366004614c2e565b6125ff565b61066661264e565b6001600160a01b0316336001600160a01b03161461069f5760405162461bcd60e51b815260040161069690615b4f565b60405180910390fd5b600081116106bf5760405162461bcd60e51b815260040161069690615c1f565b6106cb82826000612665565b5050565b6002546001600160a01b031681565b6000806106ea8361278f565b509150505b919050565b6106fc6127e2565b600061070661280e565b604051636b42ba1d60e11b81529091506001600160a01b0382169063d685743a90610738908590600090600401615a23565b600060405180830381600087803b15801561075257600080fd5b505af1158015610766573d6000803e3d6000fd5b50506040516304bd11e560e01b81526001600160a01b03841692506304bd11e59150610797906001906004016159c3565b600060405180830381600087803b1580156107b157600080fd5b505af11580156107c5573d6000803e3d6000fd5b505050506106cb82612825565b60008060006107e084612cd3565b509196909550909350915050565b60008060008060006108276108227f6578743a41676772656761746f7249737375656453796e746873000000000000612d43565b612da0565b50935050925050600080610839612e2b565b915091508396508160001461085d57610858878363ffffffff612e6616565b610860565b60005b9550600061086c612e86565b905042811080156108895750838142031180610889575081814203115b95505050505050909192565b61089d6127e2565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906108e89083906158de565b60405180910390a150565b60066020526000908152604090205481565b61090d6127e2565b6002546040516321f8a72160e01b81526001600160a01b03909116906321f8a7219061093b90600401615b12565b60206040518083038186803b15801561095357600080fd5b505afa158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061098b9190810190614c10565b6001600160a01b0316826001600160a01b0316146109bb5760405162461bcd60e51b815260040161069690615af2565b600081116109db5760405162461bcd60e51b815260040161069690615c0f565b6109e3612f30565b6001600160a01b0316631b16802c83631cd554d160e21b6040518363ffffffff1660e01b8152600401610a17929190615922565b606060405180830381600087803b158015610a3157600080fd5b505af1158015610a45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a699190810190614f73565b5050631cd554d160e21b600052506005602052600080516020615e1483398151915254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90610abb9085908590600401615922565b600060405180830381600087803b158015610ad557600080fd5b505af1158015610ae9573d6000803e3d6000fd5b505050505050565b6000610afb612f47565b90505b90565b60006060610b0d611d7d565b905060005b8151811015610c0f576000828281518110610b2957fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a72190610b7a9085906004016159d1565b60206040518083038186803b158015610b9257600080fd5b505afa158015610ba6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610bca9190810190614c10565b6001600160a01b0316141580610bf557506000818152600360205260409020546001600160a01b0316155b15610c065760009350505050610afe565b50600101610b12565b50600191505090565b610c2061264e565b6001600160a01b0316336001600160a01b031614610c505760405162461bcd60e51b815260040161069690615b4f565b610c5a8282612fa2565b6106cb8260006001613043565b610c7a66119959541bdbdb60ca1b612d43565b6001600160a01b0316336001600160a01b031614610caa5760405162461bcd60e51b815260040161069690615b6f565b6000610cb46132b6565b9050816001600160801b0316816001600160a01b031663988e65956040518163ffffffff1660e01b815260040160206040518083038186803b158015610cf957600080fd5b505afa158015610d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d319190810190614e92565b6001600160801b031610156106cb5760405163abb6de9560e01b81526001600160a01b0382169063abb6de9590610abb908590600401615c7f565b6005602052600090815260409020546001600160a01b031681565b60408051828152602080840282010190915260609082908290828015610db7578160200160208202803883390190505b50905060005b82811015610e2a5760056000878784818110610dd557fe5b90506020020135815260200190815260200160002060009054906101000a90046001600160a01b0316828281518110610e0a57fe5b6001600160a01b0390921660209283029190910190910152600101610dbd565b509150505b92915050565b610e3d61264e565b6001600160a01b0316336001600160a01b031614610e6d5760405162461bcd60e51b815260040161069690615b4f565b610e7783836132d6565b610e8383826000612665565b505050565b610e906127e2565b8060005b81811015610ecd57610ec5848483818110610eab57fe5b9050602002016020610ec09190810190614e38565b61330b565b600101610e94565b50610ed661280e565b6001600160a01b03166304bd11e560016040518263ffffffff1660e01b8152600401610f0291906159c3565b600060405180830381600087803b158015610f1c57600080fd5b505af1158015610f30573d6000803e3d6000fd5b50505050505050565b610f4161264e565b6001600160a01b0316336001600160a01b031614610f715760405162461bcd60e51b815260040161069690615b4f565b610f7e8160006001613043565b50565b6000610f8b61349c565b6001600160a01b031663c8e5bbd5610fa360016134b7565b6040518263ffffffff1660e01b8152600401610fbf91906159a1565b60006040518083038186803b158015610fd757600080fd5b505afa158015610feb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e2f9190810190614d57565b6001546001600160a01b031681565b6000806000806110328686613593565b93509350935093505b92959194509250565b6524b9b9bab2b960d11b81565b600080600061106e61106286613941565b620a69cb60eb1b6139c6565b93509091506000905061108f611082613a37565b839063ffffffff613a8f16565b90508481106110a157600093506110b4565b6110b1858263ffffffff613aa416565b93505b50509250929050565b6110c56127e2565b8060006110d061280e565b90506060826040519080825280602002602001820160405280156110fe578160200160208202803883390190505b506040516305ece36d60e21b81529091506001600160a01b038316906317b38db4906111329088908890869060040161597b565b600060405180830381600087803b15801561114c57600080fd5b505af1158015611160573d6000803e3d6000fd5b50506040516304bd11e560e01b81526001600160a01b03851692506304bd11e59150611191906001906004016159c3565b600060405180830381600087803b1580156111ab57600080fd5b505af11580156111bf573d6000803e3d6000fd5b506000925050505b83811015610ae9576111ea8686838181106111de57fe5b90506020020135612825565b6001016111c7565b60008060006111ff61264e565b6001600160a01b0316336001600160a01b03161461122f5760405162461bcd60e51b815260040161069690615b4f565b611237613acc565b6001600160a01b031663952225f386866040518363ffffffff1660e01b8152600401611264929190615907565b60206040518083038186803b15801561127c57600080fd5b505afa158015611290573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112b49190810190614d9e565b6112d05760405162461bcd60e51b815260040161069690615baf565b60006112dc8686613593565b929650909450925090506112f1868483613ae4565b8461135c576112fe613acc565b6001600160a01b031663974e9e7f876040518263ffffffff1660e01b815260040161132991906158de565b600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b505050505b509250925092565b6060610afb60006134b7565b606061137a611d7d565b905060005b81518110156106cb57600082828151811061139657fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016113d891906158d3565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401611404929190615a3e565b60206040518083038186803b15801561141c57600080fd5b505afa158015611430573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114549190810190614c10565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68906114b090849084906159df565b60405180910390a1505060010161137f565b6001546001600160a01b031633146114ec5760405162461bcd60e51b815260040161069690615ac2565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9261152f926001600160a01b03918216929116906158ec565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b600061156a8383613c1b565b509392505050565b6002546040516321f8a72160e01b81526000916001600160a01b0316906321f8a721906115bc9075446562744d69677261746f724f6e457468657265756d60501b906004016159d1565b60206040518083038186803b1580156115d457600080fd5b505afa1580156115e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061160c9190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a7219061165b9075446562744d69677261746f724f6e4f7074696d69736d60501b906004016159d1565b60206040518083038186803b15801561167357600080fd5b505afa158015611687573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116ab9190810190614c10565b9050336001600160a01b03831614806116cc5750336001600160a01b038216145b6116e85760405162461bcd60e51b815260040161069690615c2f565b6001600160a01b038216158061170557506001600160a01b038116155b6117215760405162461bcd60e51b815260040161069690615ab2565b600061172b6132b6565b6002546040516321f8a72160e01b81529192506001600160a01b0316906321f8a721906117759075446562744d69677261746f724f6e457468657265756d60501b906004016159d1565b60206040518083038186803b15801561178d57600080fd5b505afa1580156117a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117c59190810190614c10565b6001600160a01b0316336001600160a01b0316141561184357604051631a378f0d60e01b81526001600160a01b03821690631a378f0d9061180c9088908890600401615922565b600060405180830381600087803b15801561182657600080fd5b505af115801561183a573d6000803e3d6000fd5b50505050611956565b6002546040516321f8a72160e01b81526001600160a01b03909116906321f8a7219061188c9075446562744d69677261746f724f6e4f7074696d69736d60501b906004016159d1565b60206040518083038186803b1580156118a457600080fd5b505afa1580156118b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118dc9190810190614c10565b6001600160a01b0316336001600160a01b0316141561195657604051636178258560e11b81526001600160a01b0382169063c2f04b0a906119239088908890600401615922565b600060405180830381600087803b15801561193d57600080fd5b505af1158015611951573d6000803e3d6000fd5b505050505b5050505050565b6004818154811061196a57fe5b6000918252602090912001546001600160a01b0316905081565b61198c6127e2565b6119958161330b565b61199d61280e565b6001600160a01b03166304bd11e560016040518263ffffffff1660e01b81526004016119c991906159c3565b600060405180830381600087803b1580156119e357600080fd5b505af1158015611956573d6000803e3d6000fd5b6002546040516321f8a72160e01b815260009182916001600160a01b03909116906321f8a72190611a48907853796e746865746978427269646765546f4f7074696d69736d60381b906004016159d1565b60206040518083038186803b158015611a6057600080fd5b505afa158015611a74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a989190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a72190611ae6907453796e746865746978427269646765546f4261736560581b906004016159d1565b60206040518083038186803b158015611afe57600080fd5b505afa158015611b12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b369190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a72190611b769066119959541bdbdb60ca1b906004016159d1565b60206040518083038186803b158015611b8e57600080fd5b505afa158015611ba2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611bc69190810190614c10565b9050336001600160a01b0384161480611be75750336001600160a01b038316145b80611bfa5750336001600160a01b038216145b611c165760405162461bcd60e51b815260040161069690615ad2565b6000878152600560205260409020546001600160a01b0316611c4a5760405162461bcd60e51b815260040161069690615b8f565b60008511611c6a5760405162461bcd60e51b815260040161069690615c1f565b611c7386613da6565b6000878152600560205260409081902054905163219e412d60e21b81526001600160a01b039091169063867904b490611cb29089908990600401615922565b600060405180830381600087803b158015611ccc57600080fd5b505af1158015611ce0573d6000803e3d6000fd5b50505050600080611cf089613e1f565b91509150611cfc61280e565b6001600160a01b03166342c7b819611d22611d1d8a8663ffffffff613ea416565b613ece565b6040518263ffffffff1660e01b8152600401611d3e91906159d1565b600060405180830381600087803b158015611d5857600080fd5b505af1158015611d6c573d6000803e3d6000fd5b50929b9a5050505050505050505050565b606080611d88613ef7565b60408051600e8082526101e0820190925291925060609190602082016101c080388339019050509050680a6f2dce8d0cae8d2f60bb1b81600081518110611dcb57fe5b6020026020010181815250506822bc31b430b733b2b960b91b81600181518110611df157fe5b6020026020010181815250506c45786368616e6765526174657360981b81600281518110611e1b57fe5b6020026020010181815250506d21b4b931bab4ba213932b0b5b2b960911b81600381518110611e4657fe5b6020026020010181815250507153796e74686574697844656274536861726560701b81600481518110611e7557fe5b60200260200101818152505066119959541bdbdb60ca1b81600581518110611e9957fe5b6020026020010181815250507044656c6567617465417070726f76616c7360781b81600681518110611ec757fe5b6020026020010181815250506d2932bbb0b93222b9b1b937bbab1960911b81600781518110611ef257fe5b602002602001018181525050692634b8bab4b230ba37b960b11b81600881518110611f1957fe5b602002602001018181525050704c697175696461746f725265776172647360781b81600981518110611f4757fe5b6020026020010181815250506844656274436163686560b81b81600a81518110611f6d57fe5b6020026020010181815250506c29bcb73a342932b232b2b6b2b960991b81600b81518110611f9757fe5b6020026020010181815250507f6578743a41676772656761746f7249737375656453796e74687300000000000081600c81518110611fd157fe5b602002602001018181525050766578743a41676772656761746f7244656274526174696f60481b81600d8151811061200557fe5b60200260200101818152505061201b8282613f48565b9250505090565b6000546001600160a01b031681565b61203961264e565b6001600160a01b0316336001600160a01b0316146120695760405162461bcd60e51b815260040161069690615b4f565b6120738383612fa2565b610e8383826000613043565b600061208a82613ffd565b5092915050565b6000610e2f82614053565b6000806120a883613ffd565b915091505b915091565b6120ba61264e565b6001600160a01b0316336001600160a01b0316146120ea5760405162461bcd60e51b815260040161069690615b4f565b6106cb82826000613043565b6000610afb613a37565b6000610e2f826140ef565b6002546040516321f8a72160e01b815260009182916001600160a01b03909116906321f8a7219061215c907853796e746865746978427269646765546f4f7074696d69736d60381b906004016159d1565b60206040518083038186803b15801561217457600080fd5b505afa158015612188573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506121ac9190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a721906121fa907453796e746865746978427269646765546f4261736560581b906004016159d1565b60206040518083038186803b15801561221257600080fd5b505afa158015612226573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061224a9190810190614c10565b6002546040516321f8a72160e01b81529192506000916001600160a01b03909116906321f8a7219061228a9066119959541bdbdb60ca1b906004016159d1565b60206040518083038186803b1580156122a257600080fd5b505afa1580156122b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506122da9190810190614c10565b9050336001600160a01b03841614806122fb5750336001600160a01b038316145b8061230e5750336001600160a01b038216145b61232a5760405162461bcd60e51b815260040161069690615ad2565b6000878152600560205260409020546001600160a01b031661235e5760405162461bcd60e51b815260040161069690615b8f565b6000851161237e5760405162461bcd60e51b815260040161069690615c1f565b612386612f30565b6001600160a01b0316631b16802c87896040518363ffffffff1660e01b81526004016123b3929190615922565b606060405180830381600087803b1580156123cd57600080fd5b505af11580156123e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124059190810190614f73565b50505060008781526005602052604090819020549051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906124479089908990600401615922565b600060405180830381600087803b15801561246157600080fd5b505af1158015612475573d6000803e3d6000fd5b5050505060008061248589613e1f565b9150915061249161280e565b6001600160a01b03166342c7b8196124b2611d1d8a8663ffffffff613ea416565b6000036040518263ffffffff1660e01b8152600401611d3e91906159d1565b6124d961264e565b6001600160a01b0316336001600160a01b0316146125095760405162461bcd60e51b815260040161069690615b4f565b610f7e8160006001612665565b60008061252284613941565b905080612533576000915050610e2f565b61253d81846139c6565b509095945050505050565b61255061410e565b826001600160a01b031663d4b839926040518163ffffffff1660e01b815260040160206040518083038186803b15801561258957600080fd5b505afa15801561259d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506125c19190810190614c10565b6001600160a01b0316639dc29fac83836040518363ffffffff1660e01b8152600401610f02929190615922565b60045490565b6000610e2f82614146565b61260761264e565b6001600160a01b0316336001600160a01b0316146126375760405162461bcd60e51b815260040161069690615b4f565b61264182826132d6565b6106cb8260006001612665565b6000610afb680a6f2dce8d0cae8d2f60bb1b612d43565b61266d6141bf565b1561267757610e83565b60008061268385612cd3565b93505050915061269281614388565b826126bc57818411156126b75760405162461bcd60e51b815260040161069690615b2f565b6126c0565b8193505b6126ca85856143a6565b6126d385613da6565b631cd554d160e21b6000526005602052600080516020615e148339815191525460405163219e412d60e21b81526001600160a01b039091169063867904b4906127229088908890600401615922565b600060405180830381600087803b15801561273c57600080fd5b505af1158015612750573d6000803e3d6000fd5b5050505061275c61280e565b6001600160a01b03166342c7b81961277386613ece565b6040518263ffffffff1660e01b815260040161192391906159d1565b6000806000806127a4620a69cb60eb1b613e1f565b9150915060006127bc6127b687614053565b846144f0565b90506127d66127c9613a37565b829063ffffffff613ea416565b94509092505050915091565b6000546001600160a01b0316331461280c5760405162461bcd60e51b815260040161069690615bbf565b565b6000610afb6844656274436163686560b81b612d43565b6000818152600560205260409020546001600160a01b03168061285a5760405162461bcd60e51b815260040161069690615b9f565b631cd554d160e21b8214156128815760405162461bcd60e51b815260040161069690615bef565b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156128bc57600080fd5b505afa1580156128d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506128f49190810190614dda565b90508015612b765760008061290761349c565b6001600160a01b0316638295016a86856040518363ffffffff1660e01b8152600401612934929190615a5e565b60606040518083038186803b15801561294c57600080fd5b505afa158015612960573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506129849190810190614f73565b5091509150600081116129a95760405162461bcd60e51b815260040161069690615c6f565b60006129b3614502565b631cd554d160e21b6000526005602052600080516020615e148339815191525460405163219e412d60e21b81529192506001600160a01b03169063867904b490612a039084908790600401615922565b600060405180830381600087803b158015612a1d57600080fd5b505af1158015612a31573d6000803e3d6000fd5b50505050612a3d61280e565b6001600160a01b03166342c7b819612a5485613ece565b6040518263ffffffff1660e01b8152600401612a7091906159d1565b600060405180830381600087803b158015612a8a57600080fd5b505af1158015612a9e573d6000803e3d6000fd5b50505050806001600160a01b0316633a70599c866001600160a01b031663ec5568896040518163ffffffff1660e01b815260040160206040518083038186803b158015612aea57600080fd5b505afa158015612afe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612b229190810190614e56565b846040518363ffffffff1660e01b8152600401612b40929190615a93565b600060405180830381600087803b158015612b5a57600080fd5b505af1158015612b6e573d6000803e3d6000fd5b505050505050505b60005b600454811015612c5d57826001600160a01b031660048281548110612b9a57fe5b6000918252602090912001546001600160a01b03161415612c555760048181548110612bc257fe5b600091825260209091200180546001600160a01b0319169055600480546000198101908110612bed57fe5b600091825260209091200154600480546001600160a01b039092169183908110612c1357fe5b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790556004805490612c4f906000198301614a7f565b50612c5d565b600101612b79565b506001600160a01b038216600090815260066020908152604080832083905585835260059091529081902080546001600160a01b0319169055517f6166f5c475cc1cd535c6cdf14a6d5edb811e34117031fc2863392a136eb655d090612cc690859085906159df565b60405180910390a1505050565b600080600080612cf2612ce586613941565b631cd554d160e21b6139c6565b91945092509050600080612d058761278f565b915091508195508280612d155750805b9250858510612d275760009550612d3a565b612d37868663ffffffff613aa416565b95505b50509193509193565b60008181526003602090815260408083205490516001600160a01b039091169182151591612d73918691016158b3565b6040516020818303038152906040529061208a5760405162461bcd60e51b81526004016106969190615aa1565b6000806000806000856001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015612de157600080fd5b505afa158015612df5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612e199190810190614fb6565b939a9299509097509550909350915050565b600080600080612e57610822766578743a41676772656761746f7244656274526174696f60481b612d43565b50919650909450505050509091565b6000612e7f83836b033b2e3c9fd0803ce800000061451d565b9392505050565b6000612e90614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6e1c985d1954dd185b1954195c9a5bd9608a1b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b60206040518083038186803b158015612ef857600080fd5b505afa158015612f0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610afb9190810190614dda565b6000610afb6822bc31b430b733b2b960b91b612d43565b6000612f51614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f6d696e696d756d5374616b6554696d6560801b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b612faa61457e565b6001600160a01b0316637d3f0ba283836040518363ffffffff1660e01b8152600401612fd79291906158ec565b60206040518083038186803b158015612fef57600080fd5b505afa158015613003573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506130279190810190614d9e565b6106cb5760405162461bcd60e51b815260040161069690615ae2565b61304b6141bf565b1561305557610e83565b806131b257613063836140ef565b61307f5760405162461bcd60e51b815260040161069690615c4f565b60008061308a612f30565b6001600160a01b0316631b16802c86631cd554d160e21b6040518363ffffffff1660e01b81526004016130be929190615922565b606060405180830381600087803b1580156130d857600080fd5b505af11580156130ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506131109190810190614f73565b90935091505080156131af57613124612f30565b6001600160a01b0316634c268fc886631cd554d160e21b87866040518563ffffffff1660e01b815260040161315c949392919061593d565b60206040518083038186803b15801561317457600080fd5b505afa158015613188573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506131ac9190810190614dda565b93505b50505b6000806131c1612ce586613941565b92505091506000806131d28761278f565b915091506131e783806131e25750815b614388565b600084116132075760405162461bcd60e51b815260040161069690615b1f565b84156132205761321d848363ffffffff613aa416565b95505b600061322e8889898861459d565b905082613241868363ffffffff613aa416565b116132ac5761324e613acc565b6001600160a01b031663974e9e7f896040518263ffffffff1660e01b815260040161327991906158de565b600060405180830381600087803b15801561329357600080fd5b505af11580156132a7573d6000803e3d6000fd5b505050505b5050505050505050565b6000610afb7153796e74686574697844656274536861726560701b612d43565b6132de61457e565b6001600160a01b0316630487261783836040518363ffffffff1660e01b8152600401612fd79291906158ec565b6000816001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b15801561334657600080fd5b505afa15801561335a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061337e9190810190614dda565b6000818152600560205260409020549091506001600160a01b0316156133b65760405162461bcd60e51b815260040161069690615c3f565b6001600160a01b038216600090815260066020526040902054156133ec5760405162461bcd60e51b815260040161069690615bcf565b60048054600181019091557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b0384166001600160a01b03199182168117909255600083815260056020908152604080832080549094168517909355928152600690925290819020829055517f0a2b6ebf143b3e9fcd67e17748ad315174746100c27228468b2c98c302c628849061349090839085906159df565b60405180910390a15050565b6000610afb6c45786368616e6765526174657360981b612d43565b606080826134c65760006134c9565b60015b60ff16600480549050016040519080825280602002602001820160405280156134fc578160200160208202803883390190505b50905060005b60045481101561356357600660006004838154811061351d57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054825183908390811061355057fe5b6020908102919091010152600101613502565b508215610e2f576004548151620a69cb60eb1b918391811061358157fe5b60200260200101818152505092915050565b60008060008060006135a7612ce588613941565b91935090915060009050806135c1620a69cb60eb1b613e1f565b915091506135d583806131e2575081614388565b600088156137b3576135e56146ca565b90506135ef613acc565b6001600160a01b031663f557f73c8661361061360a8e614053565b876144f0565b846040518463ffffffff1660e01b815260040161362f939291906159fb565b60206040518083038186803b15801561364757600080fd5b505afa15801561365b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061367f9190810190614dda565b9650613737613729613713837384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156136cf57600080fd5b505af41580156136e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506137079190810190614dda565b9063ffffffff61472b16565b61371d8a87614750565b9063ffffffff613ea416565b6137328c614762565b61476c565b97506137a361379d613787837384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156136cf57600080fd5b6137918b876144f0565b9063ffffffff61478216565b8861476c565b96506000955061103b9350505050565b6137bb6147a0565b905060006137d26137ca614800565b613707614855565b905060006137f86137f2836137e68f614053565b9063ffffffff613aa416565b866144f0565b9050613802613acc565b6001600160a01b031663f557f73c8883866040518463ffffffff1660e01b8152600401613831939291906159fb565b60206040518083038186803b15801561384957600080fd5b505afa15801561385d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506138819190810190614dda565b985060006138da6138d0857384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156136cf57600080fd5b61371d8c89614750565b90506138e58d614053565b6138f5828563ffffffff61472b16565b106139245787995061390a836137e68f614053565b9a506139158d6148af565b985061103b9650505050505050565b61392f8d82856148b9565b909b50985061103b9650505050505050565b600061394b6132b6565b6001600160a01b03166370a08231836040518263ffffffff1660e01b815260040161397691906158de565b60206040518083038186803b15801561398e57600080fd5b505afa1580156139a2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e2f9190810190614dda565b60008060008060006139d66107ee565b925050915086600014156139f257600094509092509050613a30565b6000806139fe88613e1f565b91509150613a1b82613a0f8b614914565b9063ffffffff613a8f16565b96508395508080613a295750825b9450505050505b9250925092565b6000613a41614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6c69737375616e6365526174696f60981b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b6000612e7f8383670de0b6b3a764000061451d565b600082821115613ac65760405162461bcd60e51b815260040161069690615b3f565b50900390565b6000610afb692634b8bab4b230ba37b960b11b612d43565b613aec614932565b6001600160a01b031663270fb338846040518263ffffffff1660e01b8152600401613b1791906158de565b600060405180830381600087803b158015613b3157600080fd5b505af1158015613b45573d6000803e3d6000fd5b505050506000613b536132b6565b90506000613b6085613941565b905082841415613b9857604051631a378f0d60e01b81526001600160a01b03831690631a378f0d9061180c9088908590600401615922565b6000613ba385614951565b9050826001600160a01b0316631a378f0d87848410613bc25784613bc4565b835b6040518363ffffffff1660e01b8152600401613be1929190615922565b600060405180830381600087803b158015613bfb57600080fd5b505af1158015613c0f573d6000803e3d6000fd5b50505050505050505050565b6000806000806000613c2b61280e565b6001600160a01b0316633a900a2e6040518163ffffffff1660e01b815260040160806040518083038186803b158015613c6357600080fd5b505afa158015613c77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613c9b9190810190614f12565b935093505092508180613cab5750805b935085613d5157600080613cbd61280e565b6001600160a01b0316632992dba26040518163ffffffff1660e01b8152600401604080518083038186803b158015613cf457600080fd5b505afa158015613d08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613d2c9190810190614eb0565b9092509050613d41858363ffffffff61472b16565b94508580613d4c5750805b955050505b631cd554d160e21b871415613d6b5750909250613d9f9050565b600080613d7789613e1f565b9092509050613d8c858363ffffffff613a8f16565b8680613d955750815b9650965050505050505b9250929050565b613dae614561565b6001600160a01b0316631d5b277f6524b9b9bab2b960d11b6d1b185cdd125cdcdd59515d995b9d60921b84604051602001613dea92919061588d565b60405160208183030381529060405280519060200120426040518463ffffffff1660e01b81526004016119c9939291906159fb565b600080613e2a61349c565b6001600160a01b0316630c71cd23846040518263ffffffff1660e01b8152600401613e5591906159d1565b604080518083038186803b158015613e6c57600080fd5b505afa158015613e80573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506120a89190810190614eb0565b6000670de0b6b3a7640000613ebf848463ffffffff61498316565b81613ec657fe5b049392505050565b6000600160ff1b8210613ef35760405162461bcd60e51b815260040161069690615c5f565b5090565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110613f3957fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015613f78578160200160208202803883390190505b50905060005b8351811015613fba57838181518110613f9357fe5b6020026020010151828281518110613fa757fe5b6020908102919091010152600101613f7e565b5060005b825181101561208a57828181518110613fd357fe5b6020026020010151828286510181518110613fea57fe5b6020908102919091010152600101613fbe565b600080600061400b84614053565b905060008061401c61106287613941565b92505091508260001415614038576000945092506120ad915050565b614048828463ffffffff613a8f16565b945092505050915091565b6000610e2f614060614932565b6001600160a01b0316628cc262846040518263ffffffff1660e01b815260040161408a91906158de565b60206040518083038186803b1580156140a257600080fd5b505afa1580156140b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506140da9190810190614dda565b6137076140e6856148af565b61370786614762565b60006141056140fc612f47565b61370784614146565b42101592915050565b614116614502565b6001600160a01b0316336001600160a01b03161461280c5760405162461bcd60e51b815260040161069690615bff565b6000614150614561565b6001600160a01b03166323257c2b6524b9b9bab2b960d11b6d1b185cdd125cdcdd59515d995b9d60921b8560405160200161418c92919061588d565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b81526004016139769291906159ed565b6000806141e5766578743a41676772656761746f7244656274526174696f60481b612d43565b90506000816001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561422257600080fd5b505afa158015614236573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061425a9190810190614fb6565b505050915050600061426a61349c565b6001600160a01b031663045056f8620a69cb60eb1b6040518263ffffffff1660e01b815260040161429b91906159d1565b606060405180830381600087803b1580156142b557600080fd5b505af11580156142c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506142ed9190810190614ecf565b509150506142f96149bd565b6001600160a01b031663413caeb584846040518363ffffffff1660e01b8152600401614326929190615922565b602060405180830381600087803b15801561434057600080fd5b505af1158015614354573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506143789190810190614d9e565b806143805750805b935050505090565b8015610f7e5760405162461bcd60e51b815260040161069690615b7f565b6143ae614932565b6001600160a01b031663270fb338836040518263ffffffff1660e01b81526004016143d991906158de565b600060405180830381600087803b1580156143f357600080fd5b505af1158015614407573d6000803e3d6000fd5b5050505060006144156132b6565b9050600061442283614951565b90508061448e57604051636178258560e11b81526001600160a01b0383169063c2f04b0a906144579087908790600401615922565b600060405180830381600087803b15801561447157600080fd5b505af1158015614485573d6000803e3d6000fd5b505050506144ea565b604051636178258560e11b81526001600160a01b0383169063c2f04b0a906144bc9087908590600401615922565b600060405180830381600087803b1580156144d657600080fd5b505af11580156132ac573d6000803e3d6000fd5b50505050565b6000612e7f838363ffffffff6149d916565b6000610afb6c29bcb73a342932b232b2b6b2b960991b612d43565b6000806145438461453787600a870263ffffffff61498316565b9063ffffffff6149ee16565b90506005600a825b061061455557600a015b600a9004949350505050565b6000610afb6e466c657869626c6553746f7261676560881b612d43565b6000610afb7044656c6567617465417070726f76616c7360781b612d43565b60006145a76141bf565b156145b4575060006146c2565b8282106145c157826145c3565b815b90506145d0858284613ae4565b631cd554d160e21b6000526005602052600080516020615e1483398151915254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac9061461f9087908590600401615922565b600060405180830381600087803b15801561463957600080fd5b505af115801561464d573d6000803e3d6000fd5b5050505061465961280e565b6001600160a01b03166342c7b81961467083613ece565b6000036040518263ffffffff1660e01b815260040161468f91906159d1565b600060405180830381600087803b1580156146a957600080fd5b505af11580156146bd573d6000803e3d6000fd5b505050505b949350505050565b60006146d4614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7573656c664c69717569646174696f6e50656e616c747960501b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b600082820183811015612e7f5760405162461bcd60e51b815260040161069690615b02565b6000612e7f838363ffffffff613a8f16565b600061394b61264e565b600081831061477b5781612e7f565b5090919050565b6000612e7f8261453785670de0b6b3a764000063ffffffff61498316565b60006147aa614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b74736e784c69717569646174696f6e50656e616c747960581b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b600061480a614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b69199b1859d4995dd85c9960b21b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b600061485f614561565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6e1b1a5c5d5a59185d1954995dd85c99608a1b6040518363ffffffff1660e01b8152600401612ee09291906159ed565b600061394b614a23565b60008060006148c786614762565b9050806148da868663ffffffff61472b16565b116148ec57508391506000905061490c565b614900816137e6878763ffffffff61472b16565b859350915061490c9050565b935093915050565b60008061491f612e2b565b509050612e7f838263ffffffff614a3f16565b6000610afb704c697175696461746f725265776172647360781b612d43565b60008061495c612e2b565b509050801561497a57614975838263ffffffff612e6616565b612e7f565b50600092915050565b60008261499257506000610e2f565b8282028284828161499f57fe5b0414612e7f5760405162461bcd60e51b815260040161069690615bdf565b6000610afb6d21b4b931bab4ba213932b0b5b2b960911b612d43565b6000612e7f8383670de0b6b3a7640000614a54565b6000808211614a0f5760405162461bcd60e51b815260040161069690615b5f565b6000828481614a1a57fe5b04949350505050565b6000610afb6d2932bbb0b93222b9b1b937bbab1960911b612d43565b6000612e7f83836b033b2e3c9fd0803ce80000005b600080600a8304614a6b868663ffffffff61498316565b81614a7257fe5b0490506005600a8261454b565b815481835581811115610e8357600083815260209020610e83918101908301610afe91905b80821115613ef35760008155600101614aa4565b8035610e2f81615dd2565b8051610e2f81615dd2565b60008083601f840112614ae057600080fd5b50813567ffffffffffffffff811115614af857600080fd5b602083019150836020820283011115613d9f57600080fd5b600082601f830112614b2157600080fd5b8151614b34614b2f82615cf8565b615cd1565b91508181835260208401935060208101905083856020840282011115614b5957600080fd5b60005b83811015614b855781614b6f8882614bb0565b8452506020928301929190910190600101614b5c565b5050505092915050565b8035610e2f81615de6565b8051610e2f81615de6565b8035610e2f81615def565b8051610e2f81615def565b8035610e2f81615df8565b8051610e2f81615df8565b8035610e2f81615e01565b8051610e2f81615e01565b8051610e2f81615e0a565b600060208284031215614c0457600080fd5b60006146c28484614ab8565b600060208284031215614c2257600080fd5b60006146c28484614ac3565b60008060408385031215614c4157600080fd5b6000614c4d8585614ab8565b9250506020614c5e85828601614ab8565b9150509250929050565b600080600060608486031215614c7d57600080fd5b6000614c898686614ab8565b9350506020614c9a86828701614ab8565b9250506040614cab86828701614ba5565b9150509250925092565b60008060408385031215614cc857600080fd5b6000614cd48585614ab8565b9250506020614c5e85828601614b8f565b60008060408385031215614cf857600080fd5b6000614d048585614ab8565b9250506020614c5e85828601614ba5565b60008060208385031215614d2857600080fd5b823567ffffffffffffffff811115614d3f57600080fd5b614d4b85828601614ace565b92509250509250929050565b60008060408385031215614d6a57600080fd5b825167ffffffffffffffff811115614d8157600080fd5b614d8d85828601614b10565b9250506020614c5e85828601614b9a565b600060208284031215614db057600080fd5b60006146c28484614b9a565b600060208284031215614dce57600080fd5b60006146c28484614ba5565b600060208284031215614dec57600080fd5b60006146c28484614bb0565b600080600060608486031215614e0d57600080fd5b6000614c898686614ba5565b60008060408385031215614e2c57600080fd5b6000614cd48585614ba5565b600060208284031215614e4a57600080fd5b60006146c28484614bbb565b600060208284031215614e6857600080fd5b60006146c28484614bc6565b600060208284031215614e8657600080fd5b60006146c28484614bd1565b600060208284031215614ea457600080fd5b60006146c28484614bdc565b60008060408385031215614ec357600080fd5b6000614d8d8585614bb0565b600080600060608486031215614ee457600080fd5b6000614ef08686614bb0565b9350506020614f0186828701614b9a565b9250506040614cab86828701614b9a565b60008060008060808587031215614f2857600080fd5b6000614f348787614bb0565b9450506020614f4587828801614bb0565b9350506040614f5687828801614b9a565b9250506060614f6787828801614b9a565b91505092959194509250565b600080600060608486031215614f8857600080fd5b6000614f948686614bb0565b9350506020614fa586828701614bb0565b9250506040614cab86828701614bb0565b600080600080600060a08688031215614fce57600080fd5b6000614fda8888614be7565b9550506020614feb88828901614bb0565b9450506040614ffc88828901614bb0565b935050606061500d88828901614bb0565b925050608061501e88828901614be7565b9150509295509295909350565b600061503783836151a2565b505060200190565b600061503783836151bc565b61505481615d2c565b82525050565b61505461506682615d2c565b615db1565b60006150778385615d23565b93506001600160fb1b0383111561508d57600080fd5b60208302925061509e838584615d79565b50500190565b60006150af82615d1f565b6150b98185615d23565b93506150c483615d19565b8060005b838110156150f25781516150dc888261502b565b97506150e783615d19565b9250506001016150c8565b509495945050505050565b600061510882615d1f565b6151128185615d23565b935061511d83615d19565b8060005b838110156150f2578151615135888261503f565b975061514083615d19565b925050600101615121565b600061515682615d1f565b6151608185615d23565b935061516b83615d19565b8060005b838110156150f2578151615183888261502b565b975061518e83615d19565b92505060010161516f565b61505481615d37565b61505481610afe565b6150546151b782610afe565b610afe565b61505481615d3c565b61505481615d6e565b60006151d982615d1f565b6151e38185615d23565b93506151f3818560208601615d85565b6151fc81615dc2565b9093019392505050565b6000615213601883615d23565b7f6f6e65206d69677261746f72206d757374206265203078300000000000000000815260200192915050565b600061524c603583615d23565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b60006152a3601483615d23565b736f6e6c792074727573746564206d696e7465727360601b815260200192915050565b60006152d3601d83615d23565b7f4e6f7420617070726f76656420746f20616374206f6e20626568616c66000000815260200192915050565b600061530c600d83615d23565b6c77726f6e67206164647265737360981b815260200192915050565b6000615335601b83615d23565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b74436f6c6c61746572616c53686f72744c656761637960581b9052565b600061538b601283615d23565b714e6f206465627420746f20666f726769766560701b815260200192915050565b60006153b9601083615d23565b6f416d6f756e7420746f6f206c6172676560801b815260200192915050565b60006153e5601e83615d23565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b600061541e600e83615d23565b6d09edcd8f240a6f2dce8d0cae8d2f60931b815260200192915050565b6000615448601a83615d23565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006154816011836106ef565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006154ae601083615d23565b6f135d5cdd08189948199959481c1bdbdb60821b815260200192915050565b60006154da601e83615d23565b7f412073796e7468206f7220534e58207261746520697320696e76616c69640000815260200192915050565b6000615513601383615d23565b721cde5b9d1a08191bd95cdb89dd08195e1a5cdd606a1b815260200192915050565b6000615542601483615d23565b7314de5b9d1a08191bd95cc81b9bdd08195e1a5cdd60621b815260200192915050565b6000615572601883615d23565b7f4e6f74206f70656e20666f72206c69717569646174696f6e0000000000000000815260200192915050565b60006155ab602f83615d23565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b631cd554d160e21b9052565b6000615608601c83615d23565b7f53796e7468206164647265737320616c72656164792065786973747300000000815260200192915050565b6000615641602183615d23565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000615684601383615d23565b72086c2dcdcdee840e4cadadeecca40e6f2dce8d606b1b815260200192915050565b60006156b3601283615d23565b7127b7363c9029bcb73a342932b232b2b6b2b960711b815260200192915050565b60006156e1601483615d23565b7363616e6e6f74206275726e20302073796e74687360601b815260200192915050565b6000615711601583615d23565b7463616e6e6f7420697373756520302073796e74687360581b815260200192915050565b60006157426019836106ef565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b600061577b601683615d23565b756f6e6c792074727573746564206d69677261746f727360501b815260200192915050565b60006157ad600c83615d23565b6b53796e74682065786973747360a01b815260200192915050565b60006157d5601e83615d23565b7f4d696e696d756d207374616b652074696d65206e6f7420726561636865640000815260200192915050565b600061580e602883615d23565b7f53616665436173743a2076616c756520646f65736e27742066697420696e2061815267371034b73a191a9b60c11b602082015260400192915050565b6000615858601a83615d23565b7f43616e6e6f742072656d6f766520776974686f75742072617465000000000000815260200192915050565b61505481615d47565b600061589982856151ab565b6020820191506158a9828461505a565b5060140192915050565b60006158be82615474565b91506158ca82846151ab565b50602001919050565b60006158be82615735565b60208101610e2f828461504b565b604081016158fa828561504b565b612e7f602083018461504b565b60408101615915828561504b565b612e7f6020830184615199565b60408101615930828561504b565b612e7f60208301846151a2565b6080810161594b828761504b565b61595860208301866151a2565b61596560408301856151a2565b61597260608301846151a2565b95945050505050565b6040808252810161598d81858761506b565b90508181036020830152615972818461514b565b60208082528101612e7f81846150a4565b60208082528101612e7f81846150fd565b60208101610e2f8284615199565b60208101610e2f82846151a2565b604081016158fa82856151a2565b6040810161593082856151a2565b60608101615a0982866151a2565b615a1660208301856151a2565b6146c260408301846151a2565b60408101615a3182856151a2565b612e7f60208301846151c5565b60408101615a4c82856151a2565b81810360208301526146c281846151ce565b60608101615a6c82856151a2565b615a7960208301846151a2565b612e7f604083016155ef565b60208101610e2f82846151bc565b6040810161593082856151bc565b60208082528101612e7f81846151ce565b60208082528101610e2f81615206565b60208082528101610e2f8161523f565b60208082528101610e2f81615296565b60208082528101610e2f816152c6565b60208082528101610e2f816152ff565b60208082528101610e2f81615328565b602081016106ef82615361565b60208082528101610e2f8161537e565b60208082528101610e2f816153ac565b60208082528101610e2f816153d8565b60208082528101610e2f81615411565b60208082528101610e2f8161543b565b60208082528101610e2f816154a1565b60208082528101610e2f816154cd565b60208082528101610e2f81615506565b60208082528101610e2f81615535565b60208082528101610e2f81615565565b60208082528101610e2f8161559e565b60208082528101610e2f816155fb565b60208082528101610e2f81615634565b60208082528101610e2f81615677565b60208082528101610e2f816156a6565b60208082528101610e2f816156d4565b60208082528101610e2f81615704565b60208082528101610e2f8161576e565b60208082528101610e2f816157a0565b60208082528101610e2f816157c8565b60208082528101610e2f81615801565b60208082528101610e2f8161584b565b60208101610e2f8284615884565b6040810161591582856151a2565b60608101615ca982866151a2565b615cb660208301856151a2565b6146c26040830184615199565b6080810161594b82876151a2565b60405181810167ffffffffffffffff81118282101715615cf057600080fd5b604052919050565b600067ffffffffffffffff821115615d0f57600080fd5b5060209081020190565b60200190565b5190565b90815260200190565b6000610e2f82615d53565b151590565b6000610e2f82615d2c565b6001600160801b031690565b6001600160a01b031690565b69ffffffffffffffffffff1690565b6000610e2f82610afe565b82818337506000910152565b60005b83811015615da0578181015183820152602001615d88565b838111156144ea5750506000910152565b6000610e2f826000610e2f82615dcc565b601f01601f191690565b60601b90565b615ddb81615d2c565b8114610f7e57600080fd5b615ddb81615d37565b615ddb81610afe565b615ddb81615d3c565b615ddb81615d47565b615ddb81615d5f56fe74c62d09fbc50aefae0794a9a068f786a692826fbdfe63828ec23a875865823fa365627a7a723158207d089a8f784c6219cab4a22411b0374ef35ef8ab0fec92242ba40a17c890a9e66c6578706572696d656e74616cf564736f6c63430005100040

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

000000000000000000000000302d2451d9f47620374b54c521423bf0403916a20000000000000000000000004e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef2

-----Decoded View---------------
Arg [0] : _owner (address): 0x302d2451d9f47620374B54c521423Bf0403916A2
Arg [1] : _resolver (address): 0x4E3b31eB0E5CB73641EE1E65E7dCEFe520bA3ef2

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000302d2451d9f47620374b54c521423bf0403916a2
Arg [1] : 0000000000000000000000004e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef2


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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