ETH Price: $3,567.32 (+2.76%)

Contract

0xB589Af3f2e3377A9a57da74bE1b6598926479505
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
Flag Account For...1053891492023-06-10 6:04:35375 days ago1686377075IN
Synthetix: Liquidator
0 ETH0.000036160.0975351
Flag Account For...576101722022-12-30 7:26:25537 days ago1672385185IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...576101002022-12-30 7:26:25537 days ago1672385185IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573776272022-12-29 20:42:49538 days ago1672346569IN
Synthetix: Liquidator
0 ETH0.000000350.001
Flag Account For...573764782022-12-29 20:37:34538 days ago1672346254IN
Synthetix: Liquidator
0 ETH0.000000190.0015
Flag Account For...573764552022-12-29 20:37:34538 days ago1672346254IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573764272022-12-29 20:37:19538 days ago1672346239IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573763932022-12-29 20:37:19538 days ago1672346239IN
Synthetix: Liquidator
0 ETH0.000000530.0015
Flag Account For...573763422022-12-29 20:37:04538 days ago1672346224IN
Synthetix: Liquidator
0 ETH0.000000530.0015
Flag Account For...573762472022-12-29 20:37:04538 days ago1672346224IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573756872022-12-29 20:36:19538 days ago1672346179IN
Synthetix: Liquidator
0 ETH0.000000190.0015
Flag Account For...573756402022-12-29 20:36:04538 days ago1672346164IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573756152022-12-29 20:36:04538 days ago1672346164IN
Synthetix: Liquidator
0 ETH0.000000530.0015
Flag Account For...573755862022-12-29 20:35:49538 days ago1672346149IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573755632022-12-29 20:35:49538 days ago1672346149IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573755052022-12-29 20:35:49538 days ago1672346149IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573754842022-12-29 20:35:33538 days ago1672346133IN
Synthetix: Liquidator
0 ETH0.000000530.0015
Flag Account For...573754632022-12-29 20:35:33538 days ago1672346133IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573753892022-12-29 20:35:18538 days ago1672346118IN
Synthetix: Liquidator
0 ETH0.000000190.0015
Flag Account For...573753622022-12-29 20:35:18538 days ago1672346118IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573753392022-12-29 20:35:03538 days ago1672346103IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573753062022-12-29 20:35:03538 days ago1672346103IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...573700852022-12-29 20:10:55538 days ago1672344655IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...571106262022-12-29 8:46:10538 days ago1672303570IN
Synthetix: Liquidator
0 ETH0.000000550.0015
Flag Account For...571105582022-12-29 8:46:10538 days ago1672303570IN
Synthetix: Liquidator
0 ETH0.000000550.0015
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To Value
1075582272023-07-30 11:07:11325 days ago1690715231
Synthetix: Liquidator
0 ETH
1075582272023-07-30 11:07:11325 days ago1690715231
Synthetix: Liquidator
0 ETH
1075582272023-07-30 11:07:11325 days ago1690715231
Synthetix: Liquidator
0 ETH
1075580812023-07-30 11:02:19325 days ago1690714939
Synthetix: Liquidator
0 ETH
1075580812023-07-30 11:02:19325 days ago1690714939
Synthetix: Liquidator
0 ETH
1075580812023-07-30 11:02:19325 days ago1690714939
Synthetix: Liquidator
0 ETH
1075579732023-07-30 10:58:43325 days ago1690714723
Synthetix: Liquidator
0 ETH
1075579732023-07-30 10:58:43325 days ago1690714723
Synthetix: Liquidator
0 ETH
1075579732023-07-30 10:58:43325 days ago1690714723
Synthetix: Liquidator
0 ETH
1075579512023-07-30 10:57:59325 days ago1690714679
Synthetix: Liquidator
0 ETH
1075579512023-07-30 10:57:59325 days ago1690714679
Synthetix: Liquidator
0 ETH
1075579512023-07-30 10:57:59325 days ago1690714679
Synthetix: Liquidator
0 ETH
1075579302023-07-30 10:57:17325 days ago1690714637
Synthetix: Liquidator
0 ETH
1075579302023-07-30 10:57:17325 days ago1690714637
Synthetix: Liquidator
0 ETH
1075579302023-07-30 10:57:17325 days ago1690714637
Synthetix: Liquidator
0 ETH
1075577942023-07-30 10:52:45325 days ago1690714365
Synthetix: Liquidator
0 ETH
1075577942023-07-30 10:52:45325 days ago1690714365
Synthetix: Liquidator
0 ETH
1075577942023-07-30 10:52:45325 days ago1690714365
Synthetix: Liquidator
0 ETH
1075573732023-07-30 10:38:43325 days ago1690713523
Synthetix: Liquidator
0 ETH
1075573732023-07-30 10:38:43325 days ago1690713523
Synthetix: Liquidator
0 ETH
1075573732023-07-30 10:38:43325 days ago1690713523
Synthetix: Liquidator
0 ETH
1075571032023-07-30 10:29:43325 days ago1690712983
Synthetix: Liquidator
0 ETH
1075571032023-07-30 10:29:43325 days ago1690712983
Synthetix: Liquidator
0 ETH
1075571032023-07-30 10:29:43325 days ago1690712983
Synthetix: Liquidator
0 ETH
1075570552023-07-30 10:28:07325 days ago1690712887
Synthetix: Liquidator
0 ETH
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Liquidator

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 optimistic.etherscan.io on 2022-11-30
*/

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

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


// Inheritance


// Internal references


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

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

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

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

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

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

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

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

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

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

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

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

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

    event AddressImported(bytes32 name, address destination);
}


// Internal references


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

    mapping(bytes32 => address) private addressCache;

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

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

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

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

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

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

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

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

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

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

        return true;
    }

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

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

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

    event CacheUpdated(bytes32 name, address destination);
}


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

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

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

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

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

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

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

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

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

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

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

    function deleteIntValue(bytes32 contractName, bytes32 record) external;

    function deleteAddressValue(bytes32 contractName, bytes32 record) external;

    function deleteBoolValue(bytes32 contractName, bytes32 record) external;

    function deleteBytes32Value(bytes32 contractName, bytes32 record) external;

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

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

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

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

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

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

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

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

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

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


// Internal references


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

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

    bytes32 internal constant CONTRACT_FLEXIBLESTORAGE = "FlexibleStorage";

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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


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


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

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

    function availableSynthCount() external view returns (uint);

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

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

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

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

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

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

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

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

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

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

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

    function transferableSynthetix(address account) external view returns (uint transferable);

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

    // Mutative Functions
    function burnSynths(uint amount) external;

    function burnSynthsOnBehalf(address burnForAddress, uint amount) external;

    function burnSynthsToTarget() external;

    function burnSynthsToTargetOnBehalf(address burnForAddress) external;

    function exchange(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external returns (uint amountReceived);

    function exchangeOnBehalf(
        address exchangeForAddress,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external returns (uint amountReceived);

    function exchangeWithTracking(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address rewardAddress,
        bytes32 trackingCode
    ) external returns (uint amountReceived);

    function exchangeWithTrackingForInitiator(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address rewardAddress,
        bytes32 trackingCode
    ) external returns (uint amountReceived);

    function exchangeOnBehalfWithTracking(
        address exchangeForAddress,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address rewardAddress,
        bytes32 trackingCode
    ) external returns (uint amountReceived);

    function exchangeWithVirtual(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        bytes32 trackingCode
    ) external returns (uint amountReceived, IVirtualSynth vSynth);

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

    function issueMaxSynths() external;

    function issueMaxSynthsOnBehalf(address issueForAddress) external;

    function issueSynths(uint amount) external;

    function issueSynthsOnBehalf(address issueForAddress, uint amount) external;

    function mint() external returns (bool);

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

    // Liquidations
    function liquidateDelinquentAccount(address account) external returns (bool);

    function liquidateDelinquentAccountEscrowIndex(address account, uint escrowStartIndex) external returns (bool);

    function liquidateSelf() external returns (bool);

    // Restricted Functions

    function mintSecondary(address account, uint amount) external;

    function mintSecondaryRewards(uint amount) external;

    function burnSecondary(address account, uint amount) external;

    function revokeAllEscrow(address account) external;
}


pragma experimental ABIEncoderV2;

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

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

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


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

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

    function aggregatorWarningFlags() external view returns (address);

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

    function anyRateIsInvalidAtRound(bytes32[] calldata currencyKeys, uint[] calldata roundIds) external view returns (bool);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    function rateStalePeriod() external view returns (uint);

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

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

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

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

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

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


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

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

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

    function requireSystemActive() external view;

    function systemSuspended() external view returns (bool);

    function requireIssuanceActive() external view;

    function requireExchangeActive() external view;

    function requireFuturesActive() external view;

    function requireFuturesMarketActive(bytes32 marketKey) external view;

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

    function requireSynthActive(bytes32 currencyKey) external view;

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

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

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

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

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

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

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

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

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

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

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

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

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

    function suspendSynth(bytes32 currencyKey, uint256 reason) external;

    function suspendFuturesMarket(bytes32 marketKey, uint256 reason) external;

    function updateAccessControl(
        bytes32 section,
        address account,
        bool canSuspend,
        bool canResume
    ) external;
}


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


// Inheritance


// Libraries


// Internal references


/// @title Upgrade Liquidation Mechanism V2 (SIP-148)
/// @notice This contract is a modification to the existing liquidation mechanism defined in SIP-15
contract Liquidator is Owned, MixinSystemSettings, ILiquidator {
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    struct LiquidationEntry {
        uint deadline;
        address caller;
    }

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

    bytes32 private constant CONTRACT_SYSTEMSTATUS = "SystemStatus";
    bytes32 private constant CONTRACT_SYNTHETIX = "Synthetix";
    bytes32 private constant CONTRACT_ISSUER = "Issuer";
    bytes32 private constant CONTRACT_EXRATES = "ExchangeRates";
    bytes32 private constant CONTRACT_SYNTHETIXESCROW = "SynthetixEscrow";
    bytes32 private constant CONTRACT_V3_LEGACYMARKET = "LegacyMarket";

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

    bytes32 public constant CONTRACT_NAME = "Liquidator";

    // Storage keys
    bytes32 public constant LIQUIDATION_DEADLINE = "LiquidationDeadline";
    bytes32 public constant LIQUIDATION_CALLER = "LiquidationCaller";

    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[](4);
        newAddresses[0] = CONTRACT_SYSTEMSTATUS;
        newAddresses[1] = CONTRACT_SYNTHETIX;
        newAddresses[2] = CONTRACT_ISSUER;
        newAddresses[3] = CONTRACT_EXRATES;
        addresses = combineArrays(existingAddresses, newAddresses);
    }

    function synthetix() internal view returns (ISynthetix) {
        return ISynthetix(requireAndGetAddress(CONTRACT_SYNTHETIX));
    }

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

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

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

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

    function liquidationDelay() external view returns (uint) {
        return getLiquidationDelay();
    }

    function liquidationRatio() external view returns (uint) {
        return getLiquidationRatio();
    }

    function liquidationEscrowDuration() external view returns (uint) {
        return getLiquidationEscrowDuration();
    }

    function liquidationPenalty() external view returns (uint) {
        // SIP-251: use getSnxLiquidationPenalty instead of getLiquidationPenalty
        // which is used for loans / shorts (collateral contracts).
        // Keeping the view name because it makes sense in the context of this contract.
        return getSnxLiquidationPenalty();
    }

    function selfLiquidationPenalty() external view returns (uint) {
        return getSelfLiquidationPenalty();
    }

    function liquidateReward() external view returns (uint) {
        return getLiquidateReward();
    }

    function flagReward() external view returns (uint) {
        return getFlagReward();
    }

    function liquidationCollateralRatio() external view returns (uint) {
        return SafeDecimalMath.unit().divideDecimalRound(getLiquidationRatio());
    }

    function getLiquidationDeadlineForAccount(address account) external view returns (uint) {
        LiquidationEntry memory liquidation = _getLiquidationEntryForAccount(account);
        return liquidation.deadline;
    }

    function getLiquidationCallerForAccount(address account) external view returns (address) {
        LiquidationEntry memory liquidation = _getLiquidationEntryForAccount(account);
        return liquidation.caller;
    }

    /// @notice Determines if an account is eligible for forced or self liquidation
    /// @dev An account is eligible to self liquidate if its c-ratio is below the target c-ratio
    /// @dev An account with no SNX collateral will not be open for liquidation since the ratio is 0
    function isLiquidationOpen(address account, bool isSelfLiquidation) external view returns (bool) {
        uint accountCollateralisationRatio = synthetix().collateralisationRatio(account);

        // Not open for liquidation if collateral ratio is less than or equal to target issuance ratio
        if (accountCollateralisationRatio <= getIssuanceRatio()) {
            return false;
        }

        if (!isSelfLiquidation) {
            LiquidationEntry memory liquidation = _getLiquidationEntryForAccount(account);

            // Open for liquidation if the deadline has passed and the user has enough SNX collateral.
            if (_deadlinePassed(liquidation.deadline) && _hasEnoughSNXForRewards(account)) {
                return true;
            }
            return false;
        } else {
            // Not open for self-liquidation when the account's collateral value is less than debt issued + forced penalty
            uint unit = SafeDecimalMath.unit();
            if (accountCollateralisationRatio > (unit.divideDecimal(unit.add(getSnxLiquidationPenalty())))) {
                return false;
            }
        }
        return true;
    }

    /// View for calculating the amounts of collateral (liquid and escrow that will be liquidated), and debt that will
    /// be removed.
    /// @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 zeroes otherwise calculateAmountToFixCollateral reverts with unhelpful underflow error
        if (!this.isLiquidationOpen(account, isSelfLiquidation)) {
            return (0, 0, 0, issuer().debtBalanceOf(account, "sUSD"));
        }

        return issuer().liquidationAmounts(account, isSelfLiquidation);
    }

    function isLiquidationDeadlinePassed(address account) external view returns (bool) {
        LiquidationEntry memory liquidation = _getLiquidationEntryForAccount(account);
        return _deadlinePassed(liquidation.deadline);
    }

    function _deadlinePassed(uint deadline) internal view returns (bool) {
        // check deadline is set > 0
        // check now > deadline
        return deadline > 0 && now > deadline;
    }

    /// @notice Checks if an account has enough SNX balance to be considered open for forced liquidation.
    function _hasEnoughSNXForRewards(address account) internal view returns (bool) {
        uint balance = issuer().collateral(account);
        return balance >= (getLiquidateReward().add(getFlagReward()));
    }

    /**
     * r = target issuance ratio
     * D = debt value
     * V = collateral value
     * P = liquidation penalty
     * S = debt amount to redeem
     * Calculates amount of synths = (D - V * r) / (1 - (1 + P) * r)
     *
     * Derivation of the formula:
     *   Collateral "sold" with penalty: collateral-sold = S * (1 + P)
     *   After liquidation: new-debt = D - S, new-collateral = V - collateral-sold = V - S * (1 + P)
     *   Because we fixed the c-ratio, new-debt / new-collateral = c-ratio: (D - S) / (V - S * (1 + P)) = r
     *   After solving for S we get: S = (D - V * r) / (1 - (1 + P) * r)
     * Note: this only returns the amount of debt to remove "assuming the penalty", the penalty still needs to be
     * correctly applied when removing collateral.
     */
    function calculateAmountToFixCollateral(
        uint debtBalance,
        uint collateral,
        uint penalty
    ) external view returns (uint) {
        uint ratio = getIssuanceRatio();
        uint unit = SafeDecimalMath.unit();

        uint dividend = debtBalance.sub(collateral.multiplyDecimal(ratio));
        uint divisor = unit.sub(unit.add(penalty).multiplyDecimal(ratio));

        return dividend.divideDecimal(divisor);
    }

    // get liquidationEntry for account
    // returns deadline = 0 when not set
    function _getLiquidationEntryForAccount(address account) internal view returns (LiquidationEntry memory _liquidation) {
        _liquidation.deadline = flexibleStorage().getUIntValue(CONTRACT_NAME, _getKey(LIQUIDATION_DEADLINE, account));

        // This is used to reward the caller for flagging an account for liquidation.
        _liquidation.caller = flexibleStorage().getAddressValue(CONTRACT_NAME, _getKey(LIQUIDATION_CALLER, account));
    }

    function _getKey(bytes32 _scope, address _account) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(_scope, _account));
    }

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

    // totalIssuedSynths checks synths for staleness
    // check snx rate is not stale
    function flagAccountForLiquidation(address account) external rateNotInvalid("SNX") {
        systemStatus().requireSystemActive();

        require(resolver.getAddress(CONTRACT_V3_LEGACYMARKET) == address(0), "Must liquidate using V3");

        require(getLiquidationRatio() > 0, "Liquidation ratio not set");
        require(getLiquidationDelay() > 0, "Liquidation delay not set");

        LiquidationEntry memory liquidation = _getLiquidationEntryForAccount(account);
        require(liquidation.deadline == 0, "Account already flagged for liquidation");

        uint accountsCollateralisationRatio = synthetix().collateralisationRatio(account);

        // if accounts issuance ratio is greater than or equal to liquidation ratio set liquidation entry
        require(
            accountsCollateralisationRatio >= getLiquidationRatio(),
            "Account issuance ratio is less than liquidation ratio"
        );

        // if account doesn't have enough liquidatable collateral for rewards the liquidation transaction
        // is not possible
        require(_hasEnoughSNXForRewards(account), "not enough SNX for rewards");

        uint deadline = now.add(getLiquidationDelay());

        _storeLiquidationEntry(account, deadline, msg.sender);

        emit AccountFlaggedForLiquidation(account, deadline);
    }

    /// @notice This function is called by the Issuer to remove an account's liquidation entry
    /// @dev The Issuer must check if the account's c-ratio is fixed before removing
    function removeAccountInLiquidation(address account) external onlyIssuer {
        LiquidationEntry memory liquidation = _getLiquidationEntryForAccount(account);
        if (liquidation.deadline > 0) {
            _removeLiquidationEntry(account);
        }
    }

    /// @notice External function to allow anyone to remove an account's liquidation entry
    /// @dev This function checks if the account's c-ratio is OK and that the rate of SNX is not stale
    function checkAndRemoveAccountInLiquidation(address account) external rateNotInvalid("SNX") {
        systemStatus().requireSystemActive();

        LiquidationEntry memory liquidation = _getLiquidationEntryForAccount(account);

        require(liquidation.deadline > 0, "Account has no liquidation set");

        uint accountsCollateralisationRatio = synthetix().collateralisationRatio(account);

        // Remove from liquidator if accountsCollateralisationRatio is fixed (less than equal target issuance ratio)
        if (accountsCollateralisationRatio <= getIssuanceRatio()) {
            _removeLiquidationEntry(account);
        }
    }

    function _storeLiquidationEntry(
        address _account,
        uint _deadline,
        address _caller
    ) internal {
        // record liquidation deadline and caller
        flexibleStorage().setUIntValue(CONTRACT_NAME, _getKey(LIQUIDATION_DEADLINE, _account), _deadline);

        flexibleStorage().setAddressValue(CONTRACT_NAME, _getKey(LIQUIDATION_CALLER, _account), _caller);
    }

    /// @notice Only delete the deadline value, keep caller for flag reward payout
    function _removeLiquidationEntry(address _account) internal {
        flexibleStorage().deleteUIntValue(CONTRACT_NAME, _getKey(LIQUIDATION_DEADLINE, _account));

        emit AccountRemovedFromLiquidation(_account, now);
    }

    /* ========== MODIFIERS ========== */
    modifier onlyIssuer() {
        require(msg.sender == address(issuer()), "Liquidator: Only the Issuer contract can perform this action");
        _;
    }

    modifier rateNotInvalid(bytes32 currencyKey) {
        require(!exchangeRates().rateIsInvalid(currencyKey), "Rate invalid or not a synth");
        _;
    }

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

    event AccountFlaggedForLiquidation(address indexed account, uint deadline);
    event AccountRemovedFromLiquidation(address indexed account, uint time);
}

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":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"AccountFlaggedForLiquidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"}],"name":"AccountRemovedFromLiquidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"CacheUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"constant":true,"inputs":[],"name":"CONTRACT_NAME","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"LIQUIDATION_CALLER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"LIQUIDATION_DEADLINE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"debtBalance","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"penalty","type":"uint256"}],"name":"calculateAmountToFixCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"checkAndRemoveAccountInLiquidation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"flagAccountForLiquidation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"flagReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getLiquidationCallerForAccount","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getLiquidationDeadlineForAccount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isLiquidationDeadlinePassed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"isSelfLiquidation","type":"bool"}],"name":"isLiquidationOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"issuanceRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"liquidateReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","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":[],"name":"liquidationCollateralRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"liquidationDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"liquidationEscrowDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"liquidationPenalty","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"liquidationRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeAccountInLiquidation","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":true,"inputs":[],"name":"selfLiquidationPenalty","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]

60806040523480156200001157600080fd5b5060405162002bb138038062002bb18339810160408190526200003491620000fc565b8080836001600160a01b038116620000695760405162461bcd60e51b81526004016200006090620001b8565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000b691849062000192565b60405180910390a150600280546001600160a01b0319166001600160a01b03929092169190911790555062000213915050565b8051620000f681620001f9565b92915050565b600080604083850312156200011057600080fd5b60006200011e8585620000e9565b92505060206200013185828601620000e9565b9150509250929050565b6200014681620001e5565b82525050565b6200014681620001d3565b600062000166601983620001ca565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b60408101620001a282856200013b565b620001b160208301846200014c565b9392505050565b60208082528101620000f68162000157565b90815260200190565b60006001600160a01b038216620000f6565b6000620000f6826000620000f682620001d3565b6200020481620001d3565b81146200021057600080fd5b50565b61298e80620002236000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c806374e889c911610104578063952225f3116100a2578063b410a03411610071578063b410a03414610350578063c855a8e114610358578063d45c0d7e14610360578063f557f73c14610373576101cf565b8063952225f31461030f578063974e9e7f14610322578063a0cf745114610335578063ad2bc2d51461033d576101cf565b8063828afc4b116100de578063828afc4b146102d7578063899ffef4146102ea5780638d1bd1be146102ff5780638da5cb5b14610307576101cf565b806374e889c9146102bf57806379ba5097146102c75780638074b372146102cf576101cf565b806339a9df1b116101715780635e887fe91161014b5780635e887fe914610284578063614d08f8146102a75780636a058966146102af57806374185360146102b7576101cf565b806339a9df1b1461024957806353a47bb71461025c5780635616c95714610271576101cf565b80631775765f116101ad5780631775765f1461021c57806323f5589a146102245780632af64bd31461022c57806331e4e03014610241576101cf565b806304f3bcec146101d45780631627540c146101f25780631710940c14610207575b600080fd5b6101dc610386565b6040516101e99190612749565b60405180910390f35b610205610200366004611f1e565b610395565b005b61020f6103f3565b6040516101e991906126a2565b61020f610403565b61020f61040d565b610234610417565b6040516101e99190612694565b61020f61052e565b610234610257366004611f1e565b610538565b610264610561565b6040516101e99190612625565b61026461027f366004611f1e565b610570565b610297610292366004611f62565b61058e565b6040516101e99493929190612858565b61020f610744565b61020f610755565b61020561076d565b61020f6108c3565b6102056108dd565b61020f610982565b61020f6102e5366004611f1e565b61098c565b6102f26109a7565b6040516101e99190612683565b61020f610a86565b610264610b1b565b61023461031d366004611f62565b610b2a565b610205610330366004611f1e565b610ce1565b61020f610d3d565b61020561034b366004611f1e565b610d47565b61020f610f1c565b61020f610f26565b61020561036e366004611f1e565b610f30565b61020f610381366004611fd8565b6112aa565b6002546001600160a01b031681565b61039d6113ab565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906103e8908390612625565b60405180910390a150565b60006103fd6113d7565b90505b90565b60006103fd611488565b60006103fd6114e3565b600060606104236109a7565b905060005b815181101561052557600082828151811061043f57fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a721906104909085906004016126a2565b60206040518083038186803b1580156104a857600080fd5b505afa1580156104bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104e09190810190611f44565b6001600160a01b031614158061050b57506000818152600360205260409020546001600160a01b0316155b1561051c5760009350505050610400565b50600101610428565b50600191505090565b60006103fd611543565b6000610542611ec5565b61054b8361159d565b905061055a816000015161171a565b9392505050565b6001546001600160a01b031681565b600061057a611ec5565b6105838361159d565b602001519392505050565b600080600080306001600160a01b031663952225f387876040518363ffffffff1660e01b81526004016105c292919061264e565b60206040518083038186803b1580156105da57600080fd5b505afa1580156105ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106129190810190611f9c565b6106ad57600080600061062361172c565b6001600160a01b031663d37c4d8b8a6040518263ffffffff1660e01b815260040161064e9190612669565b60206040518083038186803b15801561066657600080fd5b505afa15801561067a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061069e9190810190611fba565b9296509094509250905061073b565b6106b561172c565b6001600160a01b0316635e887fe987876040518363ffffffff1660e01b81526004016106e292919061264e565b60806040518083038186803b1580156106fa57600080fd5b505afa15801561070e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107329190810190612025565b93509350935093505b92959194509250565b692634b8bab4b230ba37b960b11b81565b702634b8bab4b230ba34b7b721b0b63632b960791b81565b60606107776109a7565b905060005b81518110156108bf57600082828151811061079357fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016107d5919061261a565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610801929190612729565b60206040518083038186803b15801561081957600080fd5b505afa15801561082d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108519190810190611f44565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68906108ad90849084906126b0565b60405180910390a1505060010161077c565b5050565b724c69717569646174696f6e446561646c696e6560681b81565b6001546001600160a01b031633146109105760405162461bcd60e51b815260040161090790612778565b60405180910390fd5b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92610953926001600160a01b0391821692911690612633565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b60006103fd611740565b6000610996611ec5565b61099f8361159d565b519392505050565b6060806109b2611795565b60408051600480825260a0820190925291925060609190602082016080803883390190505090506b53797374656d53746174757360a01b816000815181106109f657fe5b602002602001018181525050680a6f2dce8d0cae8d2f60bb1b81600181518110610a1c57fe5b6020026020010181815250506524b9b9bab2b960d11b81600281518110610a3f57fe5b6020026020010181815250506c45786368616e6765526174657360981b81600381518110610a6957fe5b602002602001018181525050610a7f82826117e6565b9250505090565b60006103fd610a93611488565b730142f40c25ce1f1177ed131101fa19217396cb8863907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b158015610ad757600080fd5b505af4158015610aeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b0f9190810190611fba565b9063ffffffff6118a216565b6000546001600160a01b031681565b600080610b356118b7565b6001600160a01b031663a311c7c2856040518263ffffffff1660e01b8152600401610b609190612625565b60206040518083038186803b158015610b7857600080fd5b505afa158015610b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610bb09190810190611fba565b9050610bba6118ce565b8111610bca576000915050610cdb565b82610c1a57610bd7611ec5565b610be08561159d565b9050610bef816000015161171a565b8015610bff5750610bff85611926565b15610c0f57600192505050610cdb565b600092505050610cdb565b6000730142f40c25ce1f1177ed131101fa19217396cb8863907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b158015610c6057600080fd5b505af4158015610c74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c989190810190611fba565b9050610cc2610cb5610ca86114e3565b839063ffffffff6119d516565b829063ffffffff6119fa16565b821115610cd457600092505050610cdb565b5060019150505b92915050565b610ce961172c565b6001600160a01b0316336001600160a01b031614610d195760405162461bcd60e51b815260040161090790612798565b610d21611ec5565b610d2a8261159d565b8051909150156108bf576108bf82611a24565b60006103fd611afb565b620a69cb60eb1b610d56611b56565b6001600160a01b0316632528f0fe826040518263ffffffff1660e01b8152600401610d8191906126a2565b60206040518083038186803b158015610d9957600080fd5b505afa158015610dad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610dd19190810190611f9c565b15610dee5760405162461bcd60e51b815260040161090790612808565b610df6611b71565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b158015610e2e57600080fd5b505afa158015610e42573d6000803e3d6000fd5b50505050610e4e611ec5565b610e578361159d565b8051909150610e785760405162461bcd60e51b815260040161090790612848565b6000610e826118b7565b6001600160a01b031663a311c7c2856040518263ffffffff1660e01b8152600401610ead9190612625565b60206040518083038186803b158015610ec557600080fd5b505afa158015610ed9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610efd9190810190611fba565b9050610f076118ce565b8111610f1657610f1684611a24565b50505050565b60006103fd6118ce565b60006103fd611b8b565b620a69cb60eb1b610f3f611b56565b6001600160a01b0316632528f0fe826040518263ffffffff1660e01b8152600401610f6a91906126a2565b60206040518083038186803b158015610f8257600080fd5b505afa158015610f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610fba9190810190611f9c565b15610fd75760405162461bcd60e51b815260040161090790612808565b610fdf611b71565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b15801561101757600080fd5b505afa15801561102b573d6000803e3d6000fd5b50506002546040516321f8a72160e01b8152600093506001600160a01b0390911691506321f8a72190611071906b131959d858de53585c9ad95d60a21b906004016126a2565b60206040518083038186803b15801561108957600080fd5b505afa15801561109d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110c19190810190611f44565b6001600160a01b0316146110e75760405162461bcd60e51b815260040161090790612818565b60006110f1611488565b1161110e5760405162461bcd60e51b8152600401610907906127d8565b6000611118611afb565b116111355760405162461bcd60e51b8152600401610907906127e8565b61113d611ec5565b6111468361159d565b8051909150156111685760405162461bcd60e51b815260040161090790612838565b60006111726118b7565b6001600160a01b031663a311c7c2856040518263ffffffff1660e01b815260040161119d9190612625565b60206040518083038186803b1580156111b557600080fd5b505afa1580156111c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111ed9190810190611fba565b90506111f7611488565b8110156112165760405162461bcd60e51b8152600401610907906127b8565b61121f84611926565b61123b5760405162461bcd60e51b815260040161090790612768565b6000611255611248611afb565b429063ffffffff6119d516565b9050611262858233611bf3565b846001600160a01b03167fc77e4625de0c70adaf3bd1aabb5f22f9eae8f565367c706fc209030c138579968260405161129b91906126a2565b60405180910390a25050505050565b6000806112b56118ce565b90506000730142f40c25ce1f1177ed131101fa19217396cb8863907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156112fd57600080fd5b505af4158015611311573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113359190810190611fba565b9050600061135961134c878563ffffffff611d2016565b889063ffffffff611d4a16565b9050600061138d61138085611374868a63ffffffff6119d516565b9063ffffffff611d2016565b849063ffffffff611d4a16565b905061139f828263ffffffff6119fa16565b98975050505050505050565b6000546001600160a01b031633146113d55760405162461bcd60e51b8152600401610907906127f8565b565b60006113e1611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7573656c664c69717569646174696f6e50656e616c747960501b6040518363ffffffff1660e01b81526004016114389291906126be565b60206040518083038186803b15801561145057600080fd5b505afa158015611464573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103fd9190810190611fba565b6000611492611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f6c69717569646174696f6e526174696f60801b6040518363ffffffff1660e01b81526004016114389291906126be565b60006114ed611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b74736e784c69717569646174696f6e50656e616c747960581b6040518363ffffffff1660e01b81526004016114389291906126be565b600061154d611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6e1b1a5c5d5a59185d1954995dd85c99608a1b6040518363ffffffff1660e01b81526004016114389291906126be565b6115a5611ec5565b6115ad611d72565b6001600160a01b03166323257c2b692634b8bab4b230ba37b960b11b6115e9724c69717569646174696f6e446561646c696e6560681b86611d8f565b6040518363ffffffff1660e01b81526004016116069291906126be565b60206040518083038186803b15801561161e57600080fd5b505afa158015611632573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116569190810190611fba565b8152611660611d72565b6001600160a01b0316639ee5955a692634b8bab4b230ba37b960b11b61169a702634b8bab4b230ba34b7b721b0b63632b960791b86611d8f565b6040518363ffffffff1660e01b81526004016116b79291906126be565b60206040518083038186803b1580156116cf57600080fd5b505afa1580156116e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117079190810190611f44565b6001600160a01b03166020820152919050565b60008082118015610cdb575050421190565b60006103fd6524b9b9bab2b960d11b611dc2565b600061174a611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b69199b1859d4995dd85c9960b21b6040518363ffffffff1660e01b81526004016114389291906126be565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b816000815181106117d757fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015611816578160200160208202803883390190505b50905060005b83518110156118585783818151811061183157fe5b602002602001015182828151811061184557fe5b602090810291909101015260010161181c565b5060005b825181101561189b5782818151811061187157fe5b602002602001015182828651018151811061188857fe5b602090810291909101015260010161185c565b5092915050565b600061055a8383670de0b6b3a7640000611e1f565b60006103fd680a6f2dce8d0cae8d2f60bb1b611dc2565b60006118d8611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6c69737375616e6365526174696f60981b6040518363ffffffff1660e01b81526004016114389291906126be565b60008061193161172c565b6001600160a01b031663a5fdc5de846040518263ffffffff1660e01b815260040161195c9190612625565b60206040518083038186803b15801561197457600080fd5b505afa158015611988573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506119ac9190810190611fba565b90506119cd6119b9611740565b6119c1611543565b9063ffffffff6119d516565b111592915050565b60008282018381101561055a5760405162461bcd60e51b815260040161090790612788565b600061055a82611a1885670de0b6b3a764000063ffffffff611e5616565b9063ffffffff611e9016565b611a2c611d72565b6001600160a01b03166318f662ed692634b8bab4b230ba37b960b11b611a68724c69717569646174696f6e446561646c696e6560681b85611d8f565b6040518363ffffffff1660e01b8152600401611a859291906126be565b600060405180830381600087803b158015611a9f57600080fd5b505af1158015611ab3573d6000803e3d6000fd5b50505050806001600160a01b03167f9b6ac8997b4f2edd0a27c1beb32f7c14d522e9c16f46e79daa5a144016bd6c8742604051611af091906126a2565b60405180910390a250565b6000611b05611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f6c69717569646174696f6e44656c617960801b6040518363ffffffff1660e01b81526004016114389291906126be565b60006103fd6c45786368616e6765526174657360981b611dc2565b60006103fd6b53797374656d53746174757360a01b611dc2565b6000611b95611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7f6c69717569646174696f6e457363726f774475726174696f6e000000000000006040518363ffffffff1660e01b81526004016114389291906126be565b611bfb611d72565b6001600160a01b0316631d5b277f692634b8bab4b230ba37b960b11b611c37724c69717569646174696f6e446561646c696e6560681b87611d8f565b856040518463ffffffff1660e01b8152600401611c5693929190612701565b600060405180830381600087803b158015611c7057600080fd5b505af1158015611c84573d6000803e3d6000fd5b50505050611c90611d72565b6001600160a01b0316634dca0978692634b8bab4b230ba37b960b11b611cca702634b8bab4b230ba34b7b721b0b63632b960791b87611d8f565b846040518463ffffffff1660e01b8152600401611ce9939291906126d9565b600060405180830381600087803b158015611d0357600080fd5b505af1158015611d17573d6000803e3d6000fd5b50505050505050565b6000670de0b6b3a7640000611d3b848463ffffffff611e5616565b81611d4257fe5b049392505050565b600082821115611d6c5760405162461bcd60e51b8152600401610907906127a8565b50900390565b60006103fd6e466c657869626c6553746f7261676560881b611dc2565b60008282604051602001611da49291906125d4565b60405160208183030381529060405280519060200120905092915050565b60008181526003602090815260408083205490516001600160a01b039091169182151591611df2918691016125fa565b6040516020818303038152906040529061189b5760405162461bcd60e51b81526004016109079190612757565b600080611e3984611a1887600a870263ffffffff611e5616565b90506005600a820610611e4a57600a015b600a9004949350505050565b600082611e6557506000610cdb565b82820282848281611e7257fe5b041461055a5760405162461bcd60e51b815260040161090790612828565b6000808211611eb15760405162461bcd60e51b8152600401610907906127c8565b6000828481611ebc57fe5b04949350505050565b604080518082019091526000808252602082015290565b8035610cdb81612922565b8051610cdb81612922565b8035610cdb81612939565b8051610cdb81612939565b8035610cdb81612942565b8051610cdb81612942565b600060208284031215611f3057600080fd5b6000611f3c8484611edc565b949350505050565b600060208284031215611f5657600080fd5b6000611f3c8484611ee7565b60008060408385031215611f7557600080fd5b6000611f818585611edc565b9250506020611f9285828601611ef2565b9150509250929050565b600060208284031215611fae57600080fd5b6000611f3c8484611efd565b600060208284031215611fcc57600080fd5b6000611f3c8484611f13565b600080600060608486031215611fed57600080fd5b6000611ff98686611f08565b935050602061200a86828701611f08565b925050604061201b86828701611f08565b9150509250925092565b6000806000806080858703121561203b57600080fd5b60006120478787611f13565b945050602061205887828801611f13565b935050604061206987828801611f13565b925050606061207a87828801611f13565b91505092959194509250565b6000612092838361211c565b505060200190565b6120a3816128ae565b82525050565b6120a36120b5826128ae565b612901565b60006120c58261289c565b6120cf81856128a0565b93506120da83612896565b8060005b838110156121085781516120f28882612086565b97506120fd83612896565b9250506001016120de565b509495945050505050565b6120a3816128b9565b6120a381610400565b6120a361213182610400565b610400565b6120a3816128ca565b600061214a8261289c565b61215481856128a0565b93506121648185602086016128d5565b61216d81612912565b9093019392505050565b6000612184601a836128a0565b7f6e6f7420656e6f75676820534e5820666f722072657761726473000000000000815260200192915050565b60006121bd6035836128a0565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000612214601b836128a0565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061224d603c836128a0565b7f4c697175696461746f723a204f6e6c79207468652049737375657220636f6e7481527f726163742063616e20706572666f726d207468697320616374696f6e00000000602082015260400192915050565b60006122ac601e836128a0565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b60006122e56035836128a0565b7f4163636f756e742069737375616e636520726174696f206973206c657373207481527468616e206c69717569646174696f6e20726174696f60581b602082015260400192915050565b600061233c601a836128a0565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006123756011836128a9565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006123a26019836128a0565b7f4c69717569646174696f6e20726174696f206e6f742073657400000000000000815260200192915050565b60006123db6019836128a0565b7f4c69717569646174696f6e2064656c6179206e6f742073657400000000000000815260200192915050565b6000612414602f836128a0565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b631cd554d160e21b9052565b6000612471601b836128a0565b7f5261746520696e76616c6964206f72206e6f7420612073796e74680000000000815260200192915050565b60006124aa6017836128a0565b7f4d757374206c6971756964617465207573696e67205633000000000000000000815260200192915050565b60006124e36021836128a0565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b60006125266027836128a0565b7f4163636f756e7420616c726561647920666c616767656420666f72206c69717581526634b230ba34b7b760c91b602082015260400192915050565b600061256f601e836128a0565b7f4163636f756e7420686173206e6f206c69717569646174696f6e207365740000815260200192915050565b60006125a86019836128a9565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b60006125e08285612125565b6020820191506125f082846120a9565b5060140192915050565b600061260582612368565b91506126118284612125565b50602001919050565b60006126058261259b565b60208101610cdb828461209a565b60408101612641828561209a565b61055a602083018461209a565b6040810161265c828561209a565b61055a6020830184612113565b60408101612677828461209a565b610cdb60208301612458565b6020808252810161055a81846120ba565b60208101610cdb8284612113565b60208101610cdb828461211c565b60408101612641828561211c565b604081016126cc828561211c565b61055a602083018461211c565b606081016126e7828661211c565b6126f4602083018561211c565b611f3c604083018461209a565b6060810161270f828661211c565b61271c602083018561211c565b611f3c604083018461211c565b60408101612737828561211c565b8181036020830152611f3c818461213f565b60208101610cdb8284612136565b6020808252810161055a818461213f565b60208082528101610cdb81612177565b60208082528101610cdb816121b0565b60208082528101610cdb81612207565b60208082528101610cdb81612240565b60208082528101610cdb8161229f565b60208082528101610cdb816122d8565b60208082528101610cdb8161232f565b60208082528101610cdb81612395565b60208082528101610cdb816123ce565b60208082528101610cdb81612407565b60208082528101610cdb81612464565b60208082528101610cdb8161249d565b60208082528101610cdb816124d6565b60208082528101610cdb81612519565b60208082528101610cdb81612562565b60808101612866828761211c565b612873602083018661211c565b612880604083018561211c565b61288d606083018461211c565b95945050505050565b60200190565b5190565b90815260200190565b919050565b6000610cdb826128be565b151590565b6001600160a01b031690565b6000610cdb826128ae565b60005b838110156128f05781810151838201526020016128d8565b83811115610f165750506000910152565b6000610cdb826000610cdb8261291c565b601f01601f191690565b60601b90565b61292b816128ae565b811461293657600080fd5b50565b61292b816128b9565b61292b8161040056fea365627a7a7231582024777914534a520d590d4cd50a223287b75058bcf967b23f4de5f238c7a6c0c56c6578706572696d656e74616cf564736f6c63430005100040000000000000000000000000302d2451d9f47620374b54c521423bf0403916a20000000000000000000000001cb059b7e74fd21665968c908806143e744d5f30

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c806374e889c911610104578063952225f3116100a2578063b410a03411610071578063b410a03414610350578063c855a8e114610358578063d45c0d7e14610360578063f557f73c14610373576101cf565b8063952225f31461030f578063974e9e7f14610322578063a0cf745114610335578063ad2bc2d51461033d576101cf565b8063828afc4b116100de578063828afc4b146102d7578063899ffef4146102ea5780638d1bd1be146102ff5780638da5cb5b14610307576101cf565b806374e889c9146102bf57806379ba5097146102c75780638074b372146102cf576101cf565b806339a9df1b116101715780635e887fe91161014b5780635e887fe914610284578063614d08f8146102a75780636a058966146102af57806374185360146102b7576101cf565b806339a9df1b1461024957806353a47bb71461025c5780635616c95714610271576101cf565b80631775765f116101ad5780631775765f1461021c57806323f5589a146102245780632af64bd31461022c57806331e4e03014610241576101cf565b806304f3bcec146101d45780631627540c146101f25780631710940c14610207575b600080fd5b6101dc610386565b6040516101e99190612749565b60405180910390f35b610205610200366004611f1e565b610395565b005b61020f6103f3565b6040516101e991906126a2565b61020f610403565b61020f61040d565b610234610417565b6040516101e99190612694565b61020f61052e565b610234610257366004611f1e565b610538565b610264610561565b6040516101e99190612625565b61026461027f366004611f1e565b610570565b610297610292366004611f62565b61058e565b6040516101e99493929190612858565b61020f610744565b61020f610755565b61020561076d565b61020f6108c3565b6102056108dd565b61020f610982565b61020f6102e5366004611f1e565b61098c565b6102f26109a7565b6040516101e99190612683565b61020f610a86565b610264610b1b565b61023461031d366004611f62565b610b2a565b610205610330366004611f1e565b610ce1565b61020f610d3d565b61020561034b366004611f1e565b610d47565b61020f610f1c565b61020f610f26565b61020561036e366004611f1e565b610f30565b61020f610381366004611fd8565b6112aa565b6002546001600160a01b031681565b61039d6113ab565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906103e8908390612625565b60405180910390a150565b60006103fd6113d7565b90505b90565b60006103fd611488565b60006103fd6114e3565b600060606104236109a7565b905060005b815181101561052557600082828151811061043f57fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a721906104909085906004016126a2565b60206040518083038186803b1580156104a857600080fd5b505afa1580156104bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104e09190810190611f44565b6001600160a01b031614158061050b57506000818152600360205260409020546001600160a01b0316155b1561051c5760009350505050610400565b50600101610428565b50600191505090565b60006103fd611543565b6000610542611ec5565b61054b8361159d565b905061055a816000015161171a565b9392505050565b6001546001600160a01b031681565b600061057a611ec5565b6105838361159d565b602001519392505050565b600080600080306001600160a01b031663952225f387876040518363ffffffff1660e01b81526004016105c292919061264e565b60206040518083038186803b1580156105da57600080fd5b505afa1580156105ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106129190810190611f9c565b6106ad57600080600061062361172c565b6001600160a01b031663d37c4d8b8a6040518263ffffffff1660e01b815260040161064e9190612669565b60206040518083038186803b15801561066657600080fd5b505afa15801561067a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061069e9190810190611fba565b9296509094509250905061073b565b6106b561172c565b6001600160a01b0316635e887fe987876040518363ffffffff1660e01b81526004016106e292919061264e565b60806040518083038186803b1580156106fa57600080fd5b505afa15801561070e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107329190810190612025565b93509350935093505b92959194509250565b692634b8bab4b230ba37b960b11b81565b702634b8bab4b230ba34b7b721b0b63632b960791b81565b60606107776109a7565b905060005b81518110156108bf57600082828151811061079357fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016107d5919061261a565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610801929190612729565b60206040518083038186803b15801561081957600080fd5b505afa15801561082d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108519190810190611f44565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68906108ad90849084906126b0565b60405180910390a1505060010161077c565b5050565b724c69717569646174696f6e446561646c696e6560681b81565b6001546001600160a01b031633146109105760405162461bcd60e51b815260040161090790612778565b60405180910390fd5b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92610953926001600160a01b0391821692911690612633565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b60006103fd611740565b6000610996611ec5565b61099f8361159d565b519392505050565b6060806109b2611795565b60408051600480825260a0820190925291925060609190602082016080803883390190505090506b53797374656d53746174757360a01b816000815181106109f657fe5b602002602001018181525050680a6f2dce8d0cae8d2f60bb1b81600181518110610a1c57fe5b6020026020010181815250506524b9b9bab2b960d11b81600281518110610a3f57fe5b6020026020010181815250506c45786368616e6765526174657360981b81600381518110610a6957fe5b602002602001018181525050610a7f82826117e6565b9250505090565b60006103fd610a93611488565b730142f40c25ce1f1177ed131101fa19217396cb8863907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b158015610ad757600080fd5b505af4158015610aeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b0f9190810190611fba565b9063ffffffff6118a216565b6000546001600160a01b031681565b600080610b356118b7565b6001600160a01b031663a311c7c2856040518263ffffffff1660e01b8152600401610b609190612625565b60206040518083038186803b158015610b7857600080fd5b505afa158015610b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610bb09190810190611fba565b9050610bba6118ce565b8111610bca576000915050610cdb565b82610c1a57610bd7611ec5565b610be08561159d565b9050610bef816000015161171a565b8015610bff5750610bff85611926565b15610c0f57600192505050610cdb565b600092505050610cdb565b6000730142f40c25ce1f1177ed131101fa19217396cb8863907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b158015610c6057600080fd5b505af4158015610c74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c989190810190611fba565b9050610cc2610cb5610ca86114e3565b839063ffffffff6119d516565b829063ffffffff6119fa16565b821115610cd457600092505050610cdb565b5060019150505b92915050565b610ce961172c565b6001600160a01b0316336001600160a01b031614610d195760405162461bcd60e51b815260040161090790612798565b610d21611ec5565b610d2a8261159d565b8051909150156108bf576108bf82611a24565b60006103fd611afb565b620a69cb60eb1b610d56611b56565b6001600160a01b0316632528f0fe826040518263ffffffff1660e01b8152600401610d8191906126a2565b60206040518083038186803b158015610d9957600080fd5b505afa158015610dad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610dd19190810190611f9c565b15610dee5760405162461bcd60e51b815260040161090790612808565b610df6611b71565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b158015610e2e57600080fd5b505afa158015610e42573d6000803e3d6000fd5b50505050610e4e611ec5565b610e578361159d565b8051909150610e785760405162461bcd60e51b815260040161090790612848565b6000610e826118b7565b6001600160a01b031663a311c7c2856040518263ffffffff1660e01b8152600401610ead9190612625565b60206040518083038186803b158015610ec557600080fd5b505afa158015610ed9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610efd9190810190611fba565b9050610f076118ce565b8111610f1657610f1684611a24565b50505050565b60006103fd6118ce565b60006103fd611b8b565b620a69cb60eb1b610f3f611b56565b6001600160a01b0316632528f0fe826040518263ffffffff1660e01b8152600401610f6a91906126a2565b60206040518083038186803b158015610f8257600080fd5b505afa158015610f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610fba9190810190611f9c565b15610fd75760405162461bcd60e51b815260040161090790612808565b610fdf611b71565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b15801561101757600080fd5b505afa15801561102b573d6000803e3d6000fd5b50506002546040516321f8a72160e01b8152600093506001600160a01b0390911691506321f8a72190611071906b131959d858de53585c9ad95d60a21b906004016126a2565b60206040518083038186803b15801561108957600080fd5b505afa15801561109d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110c19190810190611f44565b6001600160a01b0316146110e75760405162461bcd60e51b815260040161090790612818565b60006110f1611488565b1161110e5760405162461bcd60e51b8152600401610907906127d8565b6000611118611afb565b116111355760405162461bcd60e51b8152600401610907906127e8565b61113d611ec5565b6111468361159d565b8051909150156111685760405162461bcd60e51b815260040161090790612838565b60006111726118b7565b6001600160a01b031663a311c7c2856040518263ffffffff1660e01b815260040161119d9190612625565b60206040518083038186803b1580156111b557600080fd5b505afa1580156111c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111ed9190810190611fba565b90506111f7611488565b8110156112165760405162461bcd60e51b8152600401610907906127b8565b61121f84611926565b61123b5760405162461bcd60e51b815260040161090790612768565b6000611255611248611afb565b429063ffffffff6119d516565b9050611262858233611bf3565b846001600160a01b03167fc77e4625de0c70adaf3bd1aabb5f22f9eae8f565367c706fc209030c138579968260405161129b91906126a2565b60405180910390a25050505050565b6000806112b56118ce565b90506000730142f40c25ce1f1177ed131101fa19217396cb8863907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156112fd57600080fd5b505af4158015611311573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113359190810190611fba565b9050600061135961134c878563ffffffff611d2016565b889063ffffffff611d4a16565b9050600061138d61138085611374868a63ffffffff6119d516565b9063ffffffff611d2016565b849063ffffffff611d4a16565b905061139f828263ffffffff6119fa16565b98975050505050505050565b6000546001600160a01b031633146113d55760405162461bcd60e51b8152600401610907906127f8565b565b60006113e1611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7573656c664c69717569646174696f6e50656e616c747960501b6040518363ffffffff1660e01b81526004016114389291906126be565b60206040518083038186803b15801561145057600080fd5b505afa158015611464573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103fd9190810190611fba565b6000611492611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f6c69717569646174696f6e526174696f60801b6040518363ffffffff1660e01b81526004016114389291906126be565b60006114ed611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b74736e784c69717569646174696f6e50656e616c747960581b6040518363ffffffff1660e01b81526004016114389291906126be565b600061154d611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6e1b1a5c5d5a59185d1954995dd85c99608a1b6040518363ffffffff1660e01b81526004016114389291906126be565b6115a5611ec5565b6115ad611d72565b6001600160a01b03166323257c2b692634b8bab4b230ba37b960b11b6115e9724c69717569646174696f6e446561646c696e6560681b86611d8f565b6040518363ffffffff1660e01b81526004016116069291906126be565b60206040518083038186803b15801561161e57600080fd5b505afa158015611632573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116569190810190611fba565b8152611660611d72565b6001600160a01b0316639ee5955a692634b8bab4b230ba37b960b11b61169a702634b8bab4b230ba34b7b721b0b63632b960791b86611d8f565b6040518363ffffffff1660e01b81526004016116b79291906126be565b60206040518083038186803b1580156116cf57600080fd5b505afa1580156116e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117079190810190611f44565b6001600160a01b03166020820152919050565b60008082118015610cdb575050421190565b60006103fd6524b9b9bab2b960d11b611dc2565b600061174a611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b69199b1859d4995dd85c9960b21b6040518363ffffffff1660e01b81526004016114389291906126be565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b816000815181106117d757fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015611816578160200160208202803883390190505b50905060005b83518110156118585783818151811061183157fe5b602002602001015182828151811061184557fe5b602090810291909101015260010161181c565b5060005b825181101561189b5782818151811061187157fe5b602002602001015182828651018151811061188857fe5b602090810291909101015260010161185c565b5092915050565b600061055a8383670de0b6b3a7640000611e1f565b60006103fd680a6f2dce8d0cae8d2f60bb1b611dc2565b60006118d8611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6c69737375616e6365526174696f60981b6040518363ffffffff1660e01b81526004016114389291906126be565b60008061193161172c565b6001600160a01b031663a5fdc5de846040518263ffffffff1660e01b815260040161195c9190612625565b60206040518083038186803b15801561197457600080fd5b505afa158015611988573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506119ac9190810190611fba565b90506119cd6119b9611740565b6119c1611543565b9063ffffffff6119d516565b111592915050565b60008282018381101561055a5760405162461bcd60e51b815260040161090790612788565b600061055a82611a1885670de0b6b3a764000063ffffffff611e5616565b9063ffffffff611e9016565b611a2c611d72565b6001600160a01b03166318f662ed692634b8bab4b230ba37b960b11b611a68724c69717569646174696f6e446561646c696e6560681b85611d8f565b6040518363ffffffff1660e01b8152600401611a859291906126be565b600060405180830381600087803b158015611a9f57600080fd5b505af1158015611ab3573d6000803e3d6000fd5b50505050806001600160a01b03167f9b6ac8997b4f2edd0a27c1beb32f7c14d522e9c16f46e79daa5a144016bd6c8742604051611af091906126a2565b60405180910390a250565b6000611b05611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f6c69717569646174696f6e44656c617960801b6040518363ffffffff1660e01b81526004016114389291906126be565b60006103fd6c45786368616e6765526174657360981b611dc2565b60006103fd6b53797374656d53746174757360a01b611dc2565b6000611b95611d72565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7f6c69717569646174696f6e457363726f774475726174696f6e000000000000006040518363ffffffff1660e01b81526004016114389291906126be565b611bfb611d72565b6001600160a01b0316631d5b277f692634b8bab4b230ba37b960b11b611c37724c69717569646174696f6e446561646c696e6560681b87611d8f565b856040518463ffffffff1660e01b8152600401611c5693929190612701565b600060405180830381600087803b158015611c7057600080fd5b505af1158015611c84573d6000803e3d6000fd5b50505050611c90611d72565b6001600160a01b0316634dca0978692634b8bab4b230ba37b960b11b611cca702634b8bab4b230ba34b7b721b0b63632b960791b87611d8f565b846040518463ffffffff1660e01b8152600401611ce9939291906126d9565b600060405180830381600087803b158015611d0357600080fd5b505af1158015611d17573d6000803e3d6000fd5b50505050505050565b6000670de0b6b3a7640000611d3b848463ffffffff611e5616565b81611d4257fe5b049392505050565b600082821115611d6c5760405162461bcd60e51b8152600401610907906127a8565b50900390565b60006103fd6e466c657869626c6553746f7261676560881b611dc2565b60008282604051602001611da49291906125d4565b60405160208183030381529060405280519060200120905092915050565b60008181526003602090815260408083205490516001600160a01b039091169182151591611df2918691016125fa565b6040516020818303038152906040529061189b5760405162461bcd60e51b81526004016109079190612757565b600080611e3984611a1887600a870263ffffffff611e5616565b90506005600a820610611e4a57600a015b600a9004949350505050565b600082611e6557506000610cdb565b82820282848281611e7257fe5b041461055a5760405162461bcd60e51b815260040161090790612828565b6000808211611eb15760405162461bcd60e51b8152600401610907906127c8565b6000828481611ebc57fe5b04949350505050565b604080518082019091526000808252602082015290565b8035610cdb81612922565b8051610cdb81612922565b8035610cdb81612939565b8051610cdb81612939565b8035610cdb81612942565b8051610cdb81612942565b600060208284031215611f3057600080fd5b6000611f3c8484611edc565b949350505050565b600060208284031215611f5657600080fd5b6000611f3c8484611ee7565b60008060408385031215611f7557600080fd5b6000611f818585611edc565b9250506020611f9285828601611ef2565b9150509250929050565b600060208284031215611fae57600080fd5b6000611f3c8484611efd565b600060208284031215611fcc57600080fd5b6000611f3c8484611f13565b600080600060608486031215611fed57600080fd5b6000611ff98686611f08565b935050602061200a86828701611f08565b925050604061201b86828701611f08565b9150509250925092565b6000806000806080858703121561203b57600080fd5b60006120478787611f13565b945050602061205887828801611f13565b935050604061206987828801611f13565b925050606061207a87828801611f13565b91505092959194509250565b6000612092838361211c565b505060200190565b6120a3816128ae565b82525050565b6120a36120b5826128ae565b612901565b60006120c58261289c565b6120cf81856128a0565b93506120da83612896565b8060005b838110156121085781516120f28882612086565b97506120fd83612896565b9250506001016120de565b509495945050505050565b6120a3816128b9565b6120a381610400565b6120a361213182610400565b610400565b6120a3816128ca565b600061214a8261289c565b61215481856128a0565b93506121648185602086016128d5565b61216d81612912565b9093019392505050565b6000612184601a836128a0565b7f6e6f7420656e6f75676820534e5820666f722072657761726473000000000000815260200192915050565b60006121bd6035836128a0565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000612214601b836128a0565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061224d603c836128a0565b7f4c697175696461746f723a204f6e6c79207468652049737375657220636f6e7481527f726163742063616e20706572666f726d207468697320616374696f6e00000000602082015260400192915050565b60006122ac601e836128a0565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b60006122e56035836128a0565b7f4163636f756e742069737375616e636520726174696f206973206c657373207481527468616e206c69717569646174696f6e20726174696f60581b602082015260400192915050565b600061233c601a836128a0565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006123756011836128a9565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006123a26019836128a0565b7f4c69717569646174696f6e20726174696f206e6f742073657400000000000000815260200192915050565b60006123db6019836128a0565b7f4c69717569646174696f6e2064656c6179206e6f742073657400000000000000815260200192915050565b6000612414602f836128a0565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b631cd554d160e21b9052565b6000612471601b836128a0565b7f5261746520696e76616c6964206f72206e6f7420612073796e74680000000000815260200192915050565b60006124aa6017836128a0565b7f4d757374206c6971756964617465207573696e67205633000000000000000000815260200192915050565b60006124e36021836128a0565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b60006125266027836128a0565b7f4163636f756e7420616c726561647920666c616767656420666f72206c69717581526634b230ba34b7b760c91b602082015260400192915050565b600061256f601e836128a0565b7f4163636f756e7420686173206e6f206c69717569646174696f6e207365740000815260200192915050565b60006125a86019836128a9565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b60006125e08285612125565b6020820191506125f082846120a9565b5060140192915050565b600061260582612368565b91506126118284612125565b50602001919050565b60006126058261259b565b60208101610cdb828461209a565b60408101612641828561209a565b61055a602083018461209a565b6040810161265c828561209a565b61055a6020830184612113565b60408101612677828461209a565b610cdb60208301612458565b6020808252810161055a81846120ba565b60208101610cdb8284612113565b60208101610cdb828461211c565b60408101612641828561211c565b604081016126cc828561211c565b61055a602083018461211c565b606081016126e7828661211c565b6126f4602083018561211c565b611f3c604083018461209a565b6060810161270f828661211c565b61271c602083018561211c565b611f3c604083018461211c565b60408101612737828561211c565b8181036020830152611f3c818461213f565b60208101610cdb8284612136565b6020808252810161055a818461213f565b60208082528101610cdb81612177565b60208082528101610cdb816121b0565b60208082528101610cdb81612207565b60208082528101610cdb81612240565b60208082528101610cdb8161229f565b60208082528101610cdb816122d8565b60208082528101610cdb8161232f565b60208082528101610cdb81612395565b60208082528101610cdb816123ce565b60208082528101610cdb81612407565b60208082528101610cdb81612464565b60208082528101610cdb8161249d565b60208082528101610cdb816124d6565b60208082528101610cdb81612519565b60208082528101610cdb81612562565b60808101612866828761211c565b612873602083018661211c565b612880604083018561211c565b61288d606083018461211c565b95945050505050565b60200190565b5190565b90815260200190565b919050565b6000610cdb826128be565b151590565b6001600160a01b031690565b6000610cdb826128ae565b60005b838110156128f05781810151838201526020016128d8565b83811115610f165750506000910152565b6000610cdb826000610cdb8261291c565b601f01601f191690565b60601b90565b61292b816128ae565b811461293657600080fd5b50565b61292b816128b9565b61292b8161040056fea365627a7a7231582024777914534a520d590d4cd50a223287b75058bcf967b23f4de5f238c7a6c0c56c6578706572696d656e74616cf564736f6c63430005100040

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

000000000000000000000000302d2451d9f47620374b54c521423bf0403916a20000000000000000000000001cb059b7e74fd21665968c908806143e744d5f30

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

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000302d2451d9f47620374b54c521423bf0403916a2
Arg [1] : 0000000000000000000000001cb059b7e74fd21665968c908806143e744d5f30


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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ 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.