Contract 0x5F0CCaBe97bF838c777F08702E17EC300FF78cD0

  Note: Our ETH balance display is temporarily unavailable. Please check back later.

Contract Overview

Balance:
Txn Hash Method
Block
From
To
Value
0xe9e58dc6c62d9018a55ddce5ab1368d2b123a5d1f09c85a74d4f02d0e48e3a9dAccept Ownership13514832022-09-22 20:33:29553 days 10 hrs ago0x48914229dedd5a9922f44441ffccfc2cb7856ee9 IN  0x5f0ccabe97bf838c777f08702e17ec300ff78cd00 ETH00.000000001
0x2168723e9ad6c32016d9ea11191765a7eeee88601856971e7b36c8ce1e93e3ccNominate New Own...13511262022-09-22 20:16:07553 days 10 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x5f0ccabe97bf838c777f08702e17ec300ff78cd00 ETH00.000000001
0x27ac7bd4133c07a2a8f7243c8d13e9db7cdd2f356a5b108e4f150ff662414c2dAccept Ownership7517322022-08-30 20:53:18576 days 9 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x5f0ccabe97bf838c777f08702e17ec300ff78cd00 ETH00.000000001
0x890dba7129bc9a860807de1b786dbe7dca2a251bc2944c96ca22b4596affbce8Nominate New Own...7516512022-08-30 20:50:18576 days 9 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x5f0ccabe97bf838c777f08702e17ec300ff78cd00 ETH00.000000001
0x40485eaeaa2e7a80e6e54cfaed4804e06565f43e8b6ab65cd76b8129b89d09e7Nominate New Own...7507772022-08-30 19:56:18576 days 10 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x5f0ccabe97bf838c777f08702e17ec300ff78cd00 ETH00.000000001
0x5dd1aa55ed79d9e9c3fc229abc3137fd6e4bb599661afdc8c4eea7c16bf2cda5Nominate New Own...7506612022-08-30 19:50:18576 days 10 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x5f0ccabe97bf838c777f08702e17ec300ff78cd00 ETH00.000000001
0x6844a4fa1b633f3a80b431ff0ccf1b1818c4c491dcca138f2b4fe33685e386440x608060407503052022-08-30 19:29:18576 days 11 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  Create: Issuer0 ETH0.0000000000120.000000001
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x216eaf79575563a5e13227ad075850cdeb0040830 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x7c0b9fba343fc80086ccc248a8431d5d8531d7820 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x88caf687f3e1cae053bf0cdbb52efb1c5dcabd870 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x3c710172e7f95acaaded243982a90f8f235ff9f10 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x216eaf79575563a5e13227ad075850cdeb0040830 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x88e566cf9e29e08affb23abe3e9065bd88acb152 0x5f0ccabe97bf838c777f08702e17ec300ff78cd00 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x88e566cf9e29e08affb23abe3e9065bd88acb1520 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x1c6c0a89064206e397e75b11bcd370e8a8a007b40 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x88caf687f3e1cae053bf0cdbb52efb1c5dcabd870 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0xd134db47ddf5a6feb245452af17ccaf92ee53d3c0 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0xfafd00d0caa6d5cd5161c5c1f18aab24942acafa0 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x32a0baa5acec418a85fd032f0292893b8e4f743b0 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x1c6c0a89064206e397e75b11bcd370e8a8a007b40 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x280e5dfaa78ce685a846830bae5f2fd21d6a3d890 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x88caf687f3e1cae053bf0cdbb52efb1c5dcabd870 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x216eaf79575563a5e13227ad075850cdeb0040830 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x88e566cf9e29e08affb23abe3e9065bd88acb152 0x5f0ccabe97bf838c777f08702e17ec300ff78cd00 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x88e566cf9e29e08affb23abe3e9065bd88acb1520 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x216eaf79575563a5e13227ad075850cdeb0040830 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x904c9424484ba6d5c47d979d8e9fc5261747d681 0x5f0ccabe97bf838c777f08702e17ec300ff78cd00 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x904c9424484ba6d5c47d979d8e9fc5261747d6810 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x3c710172e7f95acaaded243982a90f8f235ff9f10 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x5cb8210159f486dfe8dc779357ee5a15b8f233bc0 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x280e5dfaa78ce685a846830bae5f2fd21d6a3d890 ETH
0x622fde6c139d5bb4ee5e92e7fcb8dc2eb2fcc5a51ca2c050052b61f1e3da37b210697792022-09-13 13:17:14562 days 17 hrs ago 0x5f0ccabe97bf838c777f08702e17ec300ff78cd0 0x216eaf79575563a5e13227ad075850cdeb0040830 ETH
[ Download CSV Export 
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
Issuer

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at goerli-optimism.etherscan.io on 2022-08-30
*/

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

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


// SPDX-License-Identifier: MIT


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

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

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

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

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

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

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


/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

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

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
        if (a == 0) {
            return 0;
        }

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

        return c;
    }

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

        return c;
    }

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


// Libraries


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

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

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

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

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

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

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

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

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

        return quotientTimesTen / 10;
    }

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

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

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

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

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

        return resultTimesTen / 10;
    }

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

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

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

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

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

        return quotientTimesTen / 10;
    }

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

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

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


// https://docs.synthetix.io/contracts/source/interfaces/isynthetixdebtshare
interface ISynthetixDebtShare {
    // Views

    function currentPeriodId() external view returns (uint128);

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

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

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

    function totalSupply() external view returns (uint);

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

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

    // Mutative functions

    function takeSnapshot(uint128 id) external;

    function mintShare(address account, uint256 amount) external;

    function burnShare(address account, uint256 amount) external;

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

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

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

    function addAuthorizedBroker(address target) external;

    function removeAuthorizedBroker(address target) external;

    function addAuthorizedToSnapshot(address target) external;

    function removeAuthorizedToSnapshot(address target) external;
}


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

    function rate() external view returns (uint);

    function readyToSettle() external view returns (bool);

    function secsLeftInWaitingPeriod() external view returns (uint);

    function settled() external view returns (bool);

    function synth() external view returns (ISynth);

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


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

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

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

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

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

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

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

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

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

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

    function priceDeviationThresholdFactor() external view returns (uint);

    function waitingPeriodSecs() external view returns (uint);

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

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

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

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

    function suspendSynthWithInvalidRate(bytes32 currencyKey) external;
}


// https://docs.synthetix.io/contracts/source/interfaces/idelegateapprovals
interface IDelegateApprovals {
    // Views
    function canBurnFor(address authoriser, address delegate) external view returns (bool);

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

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

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

    // Mutative
    function approveAllDelegatePowers(address delegate) external;

    function removeAllDelegatePowers(address delegate) external;

    function approveBurnOnBehalf(address delegate) external;

    function removeBurnOnBehalf(address delegate) external;

    function approveIssueOnBehalf(address delegate) external;

    function removeIssueOnBehalf(address delegate) external;

    function approveClaimOnBehalf(address delegate) external;

    function removeClaimOnBehalf(address delegate) external;

    function approveExchangeOnBehalf(address delegate) external;

    function removeExchangeOnBehalf(address delegate) external;
}


// https://docs.synthetix.io/contracts/source/interfaces/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 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 rateWithSafetyChecks(bytes32 currencyKey)
        external
        returns (
            uint rate,
            bool broken,
            bool invalid
        );
}


// https://docs.synthetix.io/contracts/source/interfaces/ICircuitBreaker
interface ICircuitBreaker {
    // Views
    function isInvalid(address oracleAddress, uint value) external view returns (bool);

    function priceDeviationThresholdFactor() external view returns (uint);

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

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

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

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

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


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


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

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

    function decimals() external view returns (uint8);

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

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

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

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

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

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

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

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


interface ILiquidator {
    // Views
    function issuanceRatio() external view returns (uint);

    function liquidationDelay() external view returns (uint);

    function liquidationRatio() external view returns (uint);

    function liquidationEscrowDuration() external view returns (uint);

    function liquidationPenalty() external view returns (uint);

    function selfLiquidationPenalty() external view returns (uint);

    function liquidateReward() external view returns (uint);

    function flagReward() external view returns (uint);

    function liquidationCollateralRatio() external view returns (uint);

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

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

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

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

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

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

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

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

    function checkAndRemoveAccountInLiquidation(address account) external;
}


interface ILiquidatorRewards {
    // Views

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

    // Mutative

    function getReward(address account) external;

    function notifyRewardAmount(uint256 reward) external;

    function updateEntry(address account) external;
}


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

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

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

    function redeem(IERC20 synthProxy) external;

    function redeemAll(IERC20[] calldata synthProxies) external;

    function redeemPartial(IERC20 synthProxy, uint amountOfSynth) external;

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


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

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

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

    function requireSystemActive() external view;

    function systemSuspended() external view returns (bool);

    function requireIssuanceActive() external view;

    function requireExchangeActive() external view;

    function requireFuturesActive() external view;

    function requireFuturesMarketActive(bytes32 marketKey) external view;

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

    function requireSynthActive(bytes32 currencyKey) external view;

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

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

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

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

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

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

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

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

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

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

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

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

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

    function suspendSynth(bytes32 currencyKey, uint256 reason) external;

    function suspendFuturesMarket(bytes32 marketKey, uint256 reason) external;

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


// Inheritance


// Internal references


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

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

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

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

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

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

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

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

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

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

    event TargetUpdated(Proxyable newTarget);
}


// Inheritance


// Internal references


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

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

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

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

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

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

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

    modifier onlyProxy {
        _onlyProxy();
        _;
    }

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

    modifier optionalProxy {
        _optionalProxy();
        _;
    }

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

    modifier optionalProxy_onlyOwner {
        _optionalProxy_onlyOwner();
        _;
    }

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

    event ProxyUpdated(address proxyAddress);
}


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

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


interface AggregatorV3Interface {

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

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

}


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

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

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

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

}


// Inheritance


// Libraries


// Internal references


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

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

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

    function updateDebtCacheValidity(bool currentlyInvalid) external;

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

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

    function updateCachedsUSDDebt(int amount) external;
}

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

    bytes32 public constant CONTRACT_NAME = "Issuer";

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

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

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

    // Flexible storage names

    bytes32 internal constant LAST_ISSUE_EVENT = "lastIssueEvent";

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

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

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

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

    /* ========== VIEWS ========== */
    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
        bytes32[] memory existingAddresses = MixinSystemSettings.resolverAddressesRequired();
        bytes32[] memory newAddresses = new bytes32[](15);
        newAddresses[0] = CONTRACT_SYNTHETIX;
        newAddresses[1] = CONTRACT_EXCHANGER;
        newAddresses[2] = CONTRACT_EXRATES;
        newAddresses[3] = CONTRACT_CIRCUIT_BREAKER;
        newAddresses[4] = CONTRACT_SYNTHETIXDEBTSHARE;
        newAddresses[5] = CONTRACT_FEEPOOL;
        newAddresses[6] = CONTRACT_DELEGATEAPPROVALS;
        newAddresses[7] = CONTRACT_REWARDESCROW_V2;
        newAddresses[8] = CONTRACT_SYNTHETIXESCROW;
        newAddresses[9] = CONTRACT_LIQUIDATOR;
        newAddresses[10] = CONTRACT_LIQUIDATOR_REWARDS;
        newAddresses[11] = CONTRACT_DEBTCACHE;
        newAddresses[12] = CONTRACT_SYNTHREDEEMER;
        newAddresses[13] = CONTRACT_EXT_AGGREGATOR_ISSUED_SYNTHS;
        newAddresses[14] = CONTRACT_EXT_AGGREGATOR_DEBT_RATIO;
        return combineArrays(existingAddresses, newAddresses);
    }

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

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

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

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

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

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

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

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

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

    function synthetixEscrow() internal view returns (IHasBalance) {
        return IHasBalance(requireAndGetAddress(CONTRACT_SYNTHETIXESCROW));
    }

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

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

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

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

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

        uint stalePeriod = getRateStalePeriod();

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

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

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

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

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

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

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

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

        return currencyKeys;
    }

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

        IExchangeRates exRates = exchangeRates();

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

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

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

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

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

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

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

        anyRateIsInvalid = currencyRateInvalid || debtInfoStale;
    }

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

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

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

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

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

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

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

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

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

        (uint debtBalance, , bool anyRateIsInvalid) =
            _debtBalanceOfAndTotalDebt(synthetixDebtShare().balanceOf(_issuer), SNX);

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

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

    function _collateral(address account) internal view returns (uint) {
        return
            synthetixERC20()
                .balanceOf(account)
                .add(synthetixEscrow().balanceOf(account))
                .add(rewardEscrowV2().balanceOf(account))
                .add(liquidatorRewards().earned(account));
    }

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

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

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

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

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

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

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

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

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

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

    function debtBalanceOf(address _issuer, bytes32 currencyKey) external view returns (uint debtBalance) {
        ISynthetixDebtShare sds = synthetixDebtShare();

        // What was their initial debt ownership?
        uint debtShareBalance = sds.balanceOf(_issuer);

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

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

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

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

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

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

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

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

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

        return addresses;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                break;
            }
        }

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

        emit SynthRemoved(currencyKey, synthToRemove);
    }

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

        _removeSynth(currencyKey);
    }

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

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

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

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

        // record issue timestamp
        _setLastIssueEvent(to);

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

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

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

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

        exchanger().settle(from, currencyKey);

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

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

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

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

        exchanger().settle(short, sUSD);

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

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

        _issueSynths(from, amount, false);
    }

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

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

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

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

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

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

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

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

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

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

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

        // Remove liquidation flag
        liquidator().removeAccountInLiquidation(account);
    }

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

        // otherwise calculateAmountToFixCollateral reverts with unhelpful underflow error
        if (!liquidator().isLiquidationOpen(account, isSelfLiquidation)) {
            return (0, 0, 0, debtBalance);
        }

        // Get the penalty for the liquidation type
        uint penalty = isSelfLiquidation ? getSelfLiquidationPenalty() : getSnxLiquidationPenalty();

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

        // Get the total amount of SNX collateral (including escrows and rewards)
        uint collateralForAccount = _collateral(account);

        // Calculate the amount of debt to liquidate to fix c-ratio
        debtToRemove = liquidator().calculateAmountToFixCollateral(
            debtBalance,
            _snxToUSD(collateralForAccount, snxRate),
            penalty
        );

        // Get the equivalent amount of SNX for the amount to liquidate
        // Note: While calculateAmountToFixCollateral takes the penalty into account,
        // it only calculates the debt to be repaid (so that c-ratio is reached). The penalty still needs to be
        // applied on the collateral side (SNX) correctly. Which is why redeemTarget needs to be multiplied by 1 + penalty
        // to get the SNX amount calculateAmountToFixCollateral was using for its calculation.
        // This is a "target" because it may not be available, so will be adjusted
        uint redeemTarget = _usdToSnx(debtToRemove, snxRate).multiplyDecimal(SafeDecimalMath.unit().add(penalty));

        // calculate actually redeemable collateral for the conditions
        (totalRedeemed, escrowToLiquidate) = _redeemableCollateralForTarget(account, redeemTarget, isSelfLiquidation);

        // totalRedeemed == redeemTarget, all of the debtToRemove is removed, otherwise adjust it to redeemable collateral
        if (totalRedeemed < redeemTarget) {
            // Adjust debt amount to ratio of actual vs. target collateral amounts
            debtToRemove = debtToRemove.multiplyDecimal(totalRedeemed).divideDecimal(redeemTarget);

            // if all collateral is gone, erase the bad debt (some unliquidatable collateral can be in
            // legacy SynthetixEscrow or LiquidatorRewards (if Synthetix liquidation method didn't call getReward() before this)
            // Note that collateralForAccount cannot be < totalRedeemed, because totalRedeemed comes from an exact
            // calculation in _redeemableCollateralForTarget(). If the calculations change to create a possibility
            // for a rounding imprecision, this check may need to be changed to `<=`.
            if (collateralForAccount == totalRedeemed) {
                debtToRemove = debtBalance;
            }
        }

        return (totalRedeemed, debtToRemove, escrowToLiquidate, debtBalance);
    }

    // SIP-252
    // calculates the amount of SNX that can be liquidated (redeemed) for the various cases
    // of transferrable & escrowed collateral & self or forced liquidation
    function _redeemableCollateralForTarget(
        address account,
        uint redeemTarget,
        bool isSelfLiquidation
    ) internal view returns (uint totalRedeemed, uint escrowToLiquidate) {
        // The balanceOf here can be considered "transferable" since it's not escrowed,
        // and it is the only SNX that can potentially be transfered if unstaked.
        uint transferable = synthetixERC20().balanceOf(account);
        if (redeemTarget <= transferable) {
            // transferrable is enough
            return (redeemTarget, 0);
        } else {
            // if transferrable is not enough
            if (isSelfLiquidation) {
                // cannot use escrow because it's not available for self-liquidation
                return (transferable, 0);
            } else {
                // can use escrow if forced liquidation
                uint escrow = rewardEscrowV2().balanceOf(account);
                if (redeemTarget > transferable.add(escrow)) {
                    // all of escrow needs to be redeemed
                    return (transferable.add(escrow), escrow);
                } else {
                    // need only part of the escrow, add the needed part to redeemed
                    escrowToLiquidate = redeemTarget.sub(transferable);
                    return (transferable.add(escrowToLiquidate), escrowToLiquidate);
                }
            }
        }
    }

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

        ISynthetixDebtShare sds = synthetixDebtShare();

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

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

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

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

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

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

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

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

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

        // record issue timestamp
        _setLastIssueEvent(from);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        ISynthetixDebtShare sds = synthetixDebtShare();

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

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

        ISynthetixDebtShare sds = synthetixDebtShare();

        uint currentDebtShare = sds.balanceOf(from);

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

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

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

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

    modifier onlyTrustedMinters() {
        address bridgeL1 = resolver.getAddress(CONTRACT_SYNTHETIXBRIDGETOOPTIMISM);
        address bridgeL2 = resolver.getAddress(CONTRACT_SYNTHETIXBRIDGETOBASE);
        require(msg.sender == bridgeL1 || msg.sender == bridgeL2, "Issuer: only trusted minters");
        require(bridgeL1 == address(0) || bridgeL2 == address(0), "Issuer: one minter must be 0x0");
        _;
    }

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

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

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

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

Contract ABI

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

60806040523480156200001157600080fd5b5060405162005ef038038062005ef0833981810160405260408110156200003757600080fd5b5080516020909101518080836001600160a01b0381166200009f576040805162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f74206265203000000000000000604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b038316908117825560408051928352602083019190915280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a150600280546001600160a01b039092166001600160a01b0319909216919091179055505050615dc4806200012c6000396000f3fe608060405234801561001057600080fd5b50600436106102a05760003560e01c806372c6581611610167578063a5fdc5de116100ce578063c897713211610087578063c897713214610990578063d37c4d8b146109b6578063d686c06c146109e2578063dbf6334014610a18578063dd3d2b2e14610a20578063fd864ccf14610a46576102a0565b8063a5fdc5de146108b8578063ae3bbbbb146108de578063b06e8c6514610904578063b410a03414610930578063bff4fdfc14610938578063c81ff8fa1461095e576102a0565b8063849cf58811610120578063849cf588146107f4578063890235d41461081a578063899ffef41461084c5780638da5cb5b146108545780639a5154b41461085c578063a311c7c214610892576102a0565b806372c658161461076c57806372cb051f1461079a57806374185360146107a257806379ba5097146107aa5780637b1001b7146107b2578063835e119c146107d7576102a0565b806331e6da5a1161020b5780634e99bda9116101c45780634e99bda91461064d57806353a47bb7146106555780635e887fe91461065d578063614d08f8146106b15780636bed0415146106b95780637168d2c2146106fe576102a0565b806331e6da5a1461048257806332608039146104a85780633b6afe40146104c557806344ec6b621461058357806347a9b6db146105b9578063497d704a14610627576102a0565b80631627540c1161025d5780631627540c146103b857806316b2213f146103de5780631b3ba4d014610404578063242df9e1146104305780632af64bd3146104385780632b3f41aa14610454576102a0565b8063042e0688146102a557806304f3bcec146102d357806305b3c1c9146102f75780630b887dae1461032f5780631137aedf1461034c5780631313e6ca14610390575b600080fd5b6102d1600480360360408110156102bb57600080fd5b506001600160a01b038135169060200135610a74565b005b6102db610b34565b604080516001600160a01b039092168252519081900360200190f35b61031d6004803603602081101561030d57600080fd5b50356001600160a01b0316610b43565b60408051918252519081900360200190f35b6102d16004803603602081101561034557600080fd5b5035610b57565b6103726004803603602081101561036257600080fd5b50356001600160a01b0316610c3b565b60408051938452602084019290925282820152519081900360600190f35b610398610c57565b604080519384526020840192909252151582820152519081900360600190f35b6102d1600480360360208110156103ce57600080fd5b50356001600160a01b0316610d62565b61031d600480360360208110156103f457600080fd5b50356001600160a01b0316610dbe565b6102d16004803603604081101561041a57600080fd5b506001600160a01b038135169060200135610dd0565b61031d611116565b610440611126565b604080519115158252519081900360200190f35b6102d16004803603604081101561046a57600080fd5b506001600160a01b0381358116916020013516611230565b6102d16004803603602081101561049857600080fd5b50356001600160801b03166112a2565b6102db600480360360208110156104be57600080fd5b50356113e7565b610533600480360360208110156104db57600080fd5b810190602081018135600160201b8111156104f557600080fd5b82018360208201111561050757600080fd5b803590602001918460208302840111600160201b8311171561052857600080fd5b509092509050611402565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561056f578181015183820152602001610557565b505050509050019250505060405180910390f35b6102d16004803603606081101561059957600080fd5b506001600160a01b038135811691602081013590911690604001356114b0565b6102d1600480360360208110156105cf57600080fd5b810190602081018135600160201b8111156105e957600080fd5b8201836020820111156105fb57600080fd5b803590602001918460208302840111600160201b8311171561061c57600080fd5b509092509050611526565b6102d16004803603602081101561063d57600080fd5b50356001600160a01b03166115d6565b610440611641565b6102db6117a7565b61068b6004803603604081101561067357600080fd5b506001600160a01b03813516906020013515156117b6565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61031d6117d8565b6106e5600480360360408110156106cf57600080fd5b506001600160a01b0381351690602001356117e5565b6040805192835290151560208301528051918290030190f35b6102d16004803603602081101561071457600080fd5b810190602081018135600160201b81111561072e57600080fd5b82018360208201111561074057600080fd5b803590602001918460208302840111600160201b8311171561076157600080fd5b5090925090506118d1565b6103726004803603604081101561078257600080fd5b506001600160a01b0381351690602001351515611a74565b610533611c4c565b6102d1611c58565b6102d1611e1c565b61031d600480360360408110156107c857600080fd5b50803590602001351515611ed8565b6102db600480360360208110156107ed57600080fd5b5035611ee4565b6102d16004803603602081101561080a57600080fd5b50356001600160a01b0316611f0b565b6104406004803603606081101561083057600080fd5b508035906001600160a01b036020820135169060400135611f89565b6105336123dd565b6102db6126ae565b6102d16004803603606081101561087257600080fd5b506001600160a01b038135811691602081013590911690604001356126bd565b61031d600480360360208110156108a857600080fd5b50356001600160a01b031661272e565b61031d600480360360208110156108ce57600080fd5b50356001600160a01b0316612740565b6106e5600480360360208110156108f457600080fd5b50356001600160a01b031661274b565b6102d16004803603604081101561091a57600080fd5b506001600160a01b038135169060200135612761565b61031d6127c8565b6104406004803603602081101561094e57600080fd5b50356001600160a01b03166127d2565b6104406004803603606081101561097457600080fd5b508035906001600160a01b0360208201351690604001356127dd565b6102d1600480360360208110156109a657600080fd5b50356001600160a01b0316612c95565b61031d600480360360408110156109cc57600080fd5b506001600160a01b038135169060200135612cfd565b6102d1600480360360608110156109f857600080fd5b506001600160a01b03813581169160208101359091169060400135612db6565b61031d612e75565b61031d60048036036020811015610a3657600080fd5b50356001600160a01b0316612e7b565b6102d160048036036040811015610a5c57600080fd5b506001600160a01b0381358116916020013516612e86565b610a7c612ef8565b6001600160a01b0316336001600160a01b031614610acf576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b60008111610b24576040805162461bcd60e51b815260206004820152601d60248201527f4973737565723a2063616e6e6f7420697373756520302073796e746873000000604482015290519081900360640190fd5b610b3082826000612f0f565b5050565b6002546001600160a01b031681565b600080610b4f836130a1565b509392505050565b610b5f613169565b6000610b696131b4565b9050806001600160a01b031663d685743a8360006040518363ffffffff1660e01b81526004018083815260200182815260200192505050600060405180830381600087803b158015610bba57600080fd5b505af1158015610bce573d6000803e3d6000fd5b5050604080516304bd11e560e01b81526001600482015290516001600160a01b03851693506304bd11e59250602480830192600092919082900301818387803b158015610c1a57600080fd5b505af1158015610c2e573d6000803e3d6000fd5b50505050610b30826131cb565b6000806000610c4984613717565b509196909550909350915050565b6000806000806000610c887f6578743a41676772656761746f7249737375656453796e746873000000000000613807565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610cc057600080fd5b505afa158015610cd4573d6000803e3d6000fd5b505050506040513d60a0811015610cea57600080fd5b5060208101516060909101519092509050600080610d066138e4565b9150915083965081600014610d2a57610d25878363ffffffff61398616565b610d2d565b60005b95506000610d396139a6565b90504281108015610d565750838142031180610d56575081814203115b95505050505050909192565b610d6a613169565b600180546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229181900360200190a150565b60066020526000908152604090205481565b610dd8613169565b6001600160a01b038216610e33576040805162461bcd60e51b815260206004820152601760248201527f4973737565723a20696e76616c69642061646472657373000000000000000000604482015290519081900360640190fd5b600254604080516321f8a72160e01b815274436f6c6c61746572616c53686f72744c656761637960581b600482015290516001600160a01b03909216916321f8a72191602480820192602092909190829003018186803b158015610e9657600080fd5b505afa158015610eaa573d6000803e3d6000fd5b505050506040513d6020811015610ec057600080fd5b50516001600160a01b03838116911614610f21576040805162461bcd60e51b815260206004820152601b60248201527f4973737565723a2077726f6e672073686f727420616464726573730000000000604482015290519081900360640190fd5b631cd554d160e21b6000526005602052600080516020615d50833981519152546001600160a01b0316610f9b576040805162461bcd60e51b815260206004820152601b60248201527f4973737565723a2073796e746820646f65736e27742065786973740000000000604482015290519081900360640190fd5b60008111610ff0576040805162461bcd60e51b815260206004820152601c60248201527f4973737565723a2063616e6e6f74206275726e20302073796e74687300000000604482015290519081900360640190fd5b610ff8613a4f565b6001600160a01b0316631b16802c83631cd554d160e21b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050606060405180830381600087803b15801561105e57600080fd5b505af1158015611072573d6000803e3d6000fd5b505050506040513d606081101561108857600080fd5b5050631cd554d160e21b60009081526005602052600080516020615d508339815191525460408051632770a7eb60e21b81526001600160a01b0386811660048301526024820186905291519190921692639dc29fac926044808201939182900301818387803b1580156110fa57600080fd5b505af115801561110e573d6000803e3d6000fd5b505050505050565b6000611120613a66565b90505b90565b600060606111326123dd565b905060005b815181101561122757600082828151811061114e57fe5b6020908102919091018101516000818152600383526040908190205460025482516321f8a72160e01b81526004810185905292519395506001600160a01b03918216949116926321f8a721926024808201939291829003018186803b1580156111b657600080fd5b505afa1580156111ca573d6000803e3d6000fd5b505050506040513d60208110156111e057600080fd5b50516001600160a01b031614158061120d57506000818152600360205260409020546001600160a01b0316155b1561121e5760009350505050611123565b50600101611137565b50600191505090565b611238612ef8565b6001600160a01b0316336001600160a01b03161461128b576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b6112958282613adf565b610b308260006001613bb7565b6112b566119959541bdbdb60ca1b613807565b6001600160a01b0316336001600160a01b03161461130d576040805162461bcd60e51b815260206004820152601060248201526f135d5cdd08189948199959481c1bdbdb60821b604482015290519081900360640190fd5b6000611317613eb9565b9050816001600160801b0316816001600160a01b031663988e65956040518163ffffffff1660e01b815260040160206040518083038186803b15801561135c57600080fd5b505afa158015611370573d6000803e3d6000fd5b505050506040513d602081101561138657600080fd5b50516001600160801b03161015610b30576040805163abb6de9560e01b81526001600160801b038416600482015290516001600160a01b0383169163abb6de9591602480830192600092919082900301818387803b1580156110fa57600080fd5b6005602052600090815260409020546001600160a01b031681565b60408051828152602080840282010190915260609082908290828015611432578160200160208202803883390190505b50905060005b828110156114a5576005600087878481811061145057fe5b90506020020135815260200190815260200160002060009054906101000a90046001600160a01b031682828151811061148557fe5b6001600160a01b0390921660209283029190910190910152600101611438565b509150505b92915050565b6114b8612ef8565b6001600160a01b0316336001600160a01b03161461150b576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b6115158383613ed9565b61152183826000612f0f565b505050565b61152e613169565b8060005b818110156115665761155e84848381811061154957fe5b905060200201356001600160a01b0316613f34565b600101611532565b5061156f6131b4565b6001600160a01b03166304bd11e560016040518263ffffffff1660e01b81526004018082151515158152602001915050600060405180830381600087803b1580156115b957600080fd5b505af11580156115cd573d6000803e3d6000fd5b50505050505050565b6115de612ef8565b6001600160a01b0316336001600160a01b031614611631576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b61163e8160006001613bb7565b50565b600061164b614111565b6001600160a01b031663c8e5bbd5611663600161412c565b6040518263ffffffff1660e01b81526004018080602001828103825283818151815260200191508051906020019060200280838360005b838110156116b257818101518382015260200161169a565b505050509050019250505060006040518083038186803b1580156116d557600080fd5b505afa1580156116e9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561171257600080fd5b8101908080516040519392919084600160201b82111561173157600080fd5b90830190602082018581111561174657600080fd5b82518660208202830111600160201b8211171561176257600080fd5b82525081516020918201928201910280838360005b8381101561178f578181015183820152602001611777565b50505050919091016040525060200151949350505050565b6001546001600160a01b031681565b6000806000806117c68686614208565b93509350935093505b92959194509250565b6524b9b9bab2b960d11b81565b60008060006118826117f5613eb9565b6001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561184a57600080fd5b505afa15801561185e573d6000803e3d6000fd5b505050506040513d602081101561187457600080fd5b5051620a69cb60eb1b61456a565b9350909150600090506118a3611896614650565b839063ffffffff6146c616565b90508481106118b557600093506118c8565b6118c5858263ffffffff6146db16565b93505b50509250929050565b6118d9613169565b8060006118e46131b4565b9050606082604051908082528060200260200182016040528015611912578160200160208202803883390190505b509050816001600160a01b03166317b38db48686846040518463ffffffff1660e01b815260040180806020018060200183810383528686828181526020019250602002808284376000838201819052601f909101601f1916909201858103845286518152865160209182019382890193509102908190849084905b838110156119a557818101518382015260200161198d565b5050505090500195505050505050600060405180830381600087803b1580156119cd57600080fd5b505af11580156119e1573d6000803e3d6000fd5b5050604080516304bd11e560e01b81526001600482015290516001600160a01b03861693506304bd11e59250602480830192600092919082900301818387803b158015611a2d57600080fd5b505af1158015611a41573d6000803e3d6000fd5b506000925050505b8381101561110e57611a6c868683818110611a6057fe5b905060200201356131cb565b600101611a49565b6000806000611a81612ef8565b6001600160a01b0316336001600160a01b031614611ad4576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b611adc614738565b6040805163952225f360e01b81526001600160a01b03888116600483015287151560248301529151929091169163952225f391604480820192602092909190829003018186803b158015611b2f57600080fd5b505afa158015611b43573d6000803e3d6000fd5b505050506040513d6020811015611b5957600080fd5b5051611bac576040805162461bcd60e51b815260206004820152601860248201527f4e6f74206f70656e20666f72206c69717569646174696f6e0000000000000000604482015290519081900360640190fd5b6000611bb88686614208565b92965090945092509050611bcd868483614750565b611bd5614738565b6001600160a01b031663974e9e7f876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b158015611c2c57600080fd5b505af1158015611c40573d6000803e3d6000fd5b50505050509250925092565b6060611120600061412c565b6060611c626123dd565b905060005b8151811015610b30576000828281518110611c7e57fe5b602090810291909101810151600254604080517f5265736f6c766572206d697373696e67207461726765743a2000000000000000818601526039808201859052825180830390910181526059820180845263dacb2d0160e01b9052605d8201858152607d83019384528151609d84015281519597506000966001600160a01b039095169563dacb2d01958995939492939260bd0191908501908083838c5b83811015611d34578181015183820152602001611d1c565b50505050905090810190601f168015611d615780820380516001836020036101000a031916815260200191505b50935050505060206040518083038186803b158015611d7f57600080fd5b505afa158015611d93573d6000803e3d6000fd5b505050506040513d6020811015611da957600080fd5b505160008381526003602090815260409182902080546001600160a01b0319166001600160a01b03851690811790915582518681529182015281519293507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68929081900390910190a15050600101611c67565b6001546001600160a01b03163314611e655760405162461bcd60e51b8152600401808060200182810382526035815260200180615ca36035913960400191505060405180910390fd5b600054600154604080516001600160a01b03938416815292909116602083015280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000610b4f8383614979565b60048181548110611ef157fe5b6000918252602090912001546001600160a01b0316905081565b611f13613169565b611f1c81613f34565b611f246131b4565b6001600160a01b03166304bd11e560016040518263ffffffff1660e01b81526004018082151515158152602001915050600060405180830381600087803b158015611f6e57600080fd5b505af1158015611f82573d6000803e3d6000fd5b5050505050565b600254604080516321f8a72160e01b81527853796e746865746978427269646765546f4f7074696d69736d60381b6004820152905160009283926001600160a01b03909116916321f8a72191602480820192602092909190829003018186803b158015611ff557600080fd5b505afa158015612009573d6000803e3d6000fd5b505050506040513d602081101561201f57600080fd5b5051600254604080516321f8a72160e01b81527453796e746865746978427269646765546f4261736560581b600482015290519293506000926001600160a01b03909216916321f8a72191602480820192602092909190829003018186803b15801561208a57600080fd5b505afa15801561209e573d6000803e3d6000fd5b505050506040513d60208110156120b457600080fd5b50519050336001600160a01b03831614806120d75750336001600160a01b038216145b612128576040805162461bcd60e51b815260206004820152601c60248201527f4973737565723a206f6e6c792074727573746564206d696e7465727300000000604482015290519081900360640190fd5b6001600160a01b038216158061214557506001600160a01b038116155b612196576040805162461bcd60e51b815260206004820152601e60248201527f4973737565723a206f6e65206d696e746572206d757374206265203078300000604482015290519081900360640190fd5b6000868152600560205260409020546001600160a01b03166121ff576040805162461bcd60e51b815260206004820152601b60248201527f4973737565723a2073796e746820646f65736e27742065786973740000000000604482015290519081900360640190fd5b60008411612254576040805162461bcd60e51b815260206004820152601d60248201527f4973737565723a2063616e6e6f7420697373756520302073796e746873000000604482015290519081900360640190fd5b61225d85614b7b565b60008681526005602052604080822054815163219e412d60e21b81526001600160a01b038981166004830152602482018990529251929091169263867904b49260448084019382900301818387803b1580156122b857600080fd5b505af11580156122cc573d6000803e3d6000fd5b505050506000806122db614111565b6001600160a01b0316630c71cd23896040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b15801561231d57600080fd5b505afa158015612331573d6000803e3d6000fd5b505050506040513d604081101561234757600080fd5b508051602090910151909250905061235d6131b4565b6001600160a01b03166342c7b81961238361237e898663ffffffff614c2d16565b614c57565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156123b957600080fd5b505af11580156123cd573d6000803e3d6000fd5b50929a9950505050505050505050565b6060806123e8614c9f565b60408051600f808252610200820190925291925060609190602082016101e080388339019050509050680a6f2dce8d0cae8d2f60bb1b8160008151811061242b57fe5b6020026020010181815250506822bc31b430b733b2b960b91b8160018151811061245157fe5b6020026020010181815250506c45786368616e6765526174657360981b8160028151811061247b57fe5b6020026020010181815250506d21b4b931bab4ba213932b0b5b2b960911b816003815181106124a657fe5b6020026020010181815250507153796e74686574697844656274536861726560701b816004815181106124d557fe5b60200260200101818152505066119959541bdbdb60ca1b816005815181106124f957fe5b6020026020010181815250507044656c6567617465417070726f76616c7360781b8160068151811061252757fe5b6020026020010181815250506d2932bbb0b93222b9b1b937bbab1960911b8160078151811061255257fe5b6020026020010181815250506e53796e746865746978457363726f7760881b8160088151811061257e57fe5b602002602001018181525050692634b8bab4b230ba37b960b11b816009815181106125a557fe5b602002602001018181525050704c697175696461746f725265776172647360781b81600a815181106125d357fe5b6020026020010181815250506844656274436163686560b81b81600b815181106125f957fe5b6020026020010181815250506c29bcb73a342932b232b2b6b2b960991b81600c8151811061262357fe5b6020026020010181815250507f6578743a41676772656761746f7249737375656453796e74687300000000000081600d8151811061265d57fe5b602002602001018181525050766578743a41676772656761746f7244656274526174696f60481b81600e8151811061269157fe5b6020026020010181815250506126a78282614cf0565b9250505090565b6000546001600160a01b031681565b6126c5612ef8565b6001600160a01b0316336001600160a01b031614612718576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b6127228383613adf565b61152183826000613bb7565b600061273982614da5565b5092915050565b60006114aa82614e4f565b60008061275783614da5565b915091505b915091565b612769612ef8565b6001600160a01b0316336001600160a01b0316146127bc576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b610b3082826000613bb7565b6000611120614650565b60006114aa82615071565b600254604080516321f8a72160e01b81527853796e746865746978427269646765546f4f7074696d69736d60381b6004820152905160009283926001600160a01b03909116916321f8a72191602480820192602092909190829003018186803b15801561284957600080fd5b505afa15801561285d573d6000803e3d6000fd5b505050506040513d602081101561287357600080fd5b5051600254604080516321f8a72160e01b81527453796e746865746978427269646765546f4261736560581b600482015290519293506000926001600160a01b03909216916321f8a72191602480820192602092909190829003018186803b1580156128de57600080fd5b505afa1580156128f2573d6000803e3d6000fd5b505050506040513d602081101561290857600080fd5b50519050336001600160a01b038316148061292b5750336001600160a01b038216145b61297c576040805162461bcd60e51b815260206004820152601c60248201527f4973737565723a206f6e6c792074727573746564206d696e7465727300000000604482015290519081900360640190fd5b6001600160a01b038216158061299957506001600160a01b038116155b6129ea576040805162461bcd60e51b815260206004820152601e60248201527f4973737565723a206f6e65206d696e746572206d757374206265203078300000604482015290519081900360640190fd5b6000868152600560205260409020546001600160a01b0316612a53576040805162461bcd60e51b815260206004820152601b60248201527f4973737565723a2073796e746820646f65736e27742065786973740000000000604482015290519081900360640190fd5b60008411612aa8576040805162461bcd60e51b815260206004820152601d60248201527f4973737565723a2063616e6e6f7420697373756520302073796e746873000000604482015290519081900360640190fd5b612ab0613a4f565b6001600160a01b0316631b16802c86886040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050606060405180830381600087803b158015612b0f57600080fd5b505af1158015612b23573d6000803e3d6000fd5b505050506040513d6060811015612b3957600080fd5b5050600086815260056020526040808220548151632770a7eb60e21b81526001600160a01b0389811660048301526024820189905292519290911692639dc29fac9260448084019382900301818387803b158015612b9657600080fd5b505af1158015612baa573d6000803e3d6000fd5b50505050600080612bb9614111565b6001600160a01b0316630c71cd23896040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b158015612bfb57600080fd5b505afa158015612c0f573d6000803e3d6000fd5b505050506040513d6040811015612c2557600080fd5b5080516020909101519092509050612c3b6131b4565b6001600160a01b03166342c7b819612c5c61237e898663ffffffff614c2d16565b6000036040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156123b957600080fd5b612c9d612ef8565b6001600160a01b0316336001600160a01b031614612cf0576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b61163e8160006001612f0f565b600080612d08613eb9565b90506000816001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612d6257600080fd5b505afa158015612d76573d6000803e3d6000fd5b505050506040513d6020811015612d8c57600080fd5b5051905080612da0576000925050506114aa565b612daa818561456a565b50909695505050505050565b612dbe615090565b826001600160a01b031663d4b839926040518163ffffffff1660e01b815260040160206040518083038186803b158015612df757600080fd5b505afa158015612e0b573d6000803e3d6000fd5b505050506040513d6020811015612e2157600080fd5b505160408051632770a7eb60e21b81526001600160a01b0385811660048301526024820185905291519190921691639dc29fac91604480830192600092919082900301818387803b1580156115b957600080fd5b60045490565b60006114aa826150fd565b612e8e612ef8565b6001600160a01b0316336001600160a01b031614612ee1576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b612eeb8282613ed9565b610b308260006001612f0f565b6000611120680a6f2dce8d0cae8d2f60bb1b613807565b612f176151e1565b15612f2157611521565b600080612f2d85613717565b935050509150612f3c8161539e565b82612f8e5781841115612f89576040805162461bcd60e51b815260206004820152601060248201526f416d6f756e7420746f6f206c6172676560801b604482015290519081900360640190fd5b612f92565b8193505b612f9c85856153f1565b612fa585614b7b565b631cd554d160e21b60009081526005602052600080516020615d50833981519152546040805163219e412d60e21b81526001600160a01b038981166004830152602482018990529151919092169263867904b4926044808201939182900301818387803b15801561301557600080fd5b505af1158015613029573d6000803e3d6000fd5b505050506130356131b4565b6001600160a01b03166342c7b81961304c86614c57565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561308257600080fd5b505af1158015613096573d6000803e3d6000fd5b505050505050505050565b6000806000806130af614111565b6001600160a01b0316630c71cd23620a69cb60eb1b6040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b1580156130f757600080fd5b505afa15801561310b573d6000803e3d6000fd5b505050506040513d604081101561312157600080fd5b5080516020909101519092509050600061314361313d87614e4f565b8461557d565b905061315d613150614650565b829063ffffffff614c2d16565b94509092505050915091565b6000546001600160a01b031633146131b25760405162461bcd60e51b815260040180806020018281038252602f815260200180615cd8602f913960400191505060405180910390fd5b565b60006111206844656274436163686560b81b613807565b6000818152600560205260409020546001600160a01b03168061322c576040805162461bcd60e51b815260206004820152601460248201527314de5b9d1a08191bd95cc81b9bdd08195e1a5cdd60621b604482015290519081900360640190fd5b631cd554d160e21b82141561327e576040805162461bcd60e51b8152602060048201526013602482015272086c2dcdcdee840e4cadadeecca40e6f2dce8d606b1b604482015290519081900360640190fd5b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156132b957600080fd5b505afa1580156132cd573d6000803e3d6000fd5b505050506040513d60208110156132e357600080fd5b5051905080156135bb576000806132f8614111565b6001600160a01b0316638295016a86856040518363ffffffff1660e01b81526004018083815260200182815260200180631cd554d160e21b8152506020019250505060606040518083038186803b15801561335257600080fd5b505afa158015613366573d6000803e3d6000fd5b505050506040513d606081101561337c57600080fd5b5080516020909101519092509050806133dc576040805162461bcd60e51b815260206004820152601a60248201527f43616e6e6f742072656d6f766520776974686f75742072617465000000000000604482015290519081900360640190fd5b60006133e661558f565b631cd554d160e21b60009081526005602052600080516020615d50833981519152546040805163219e412d60e21b81526001600160a01b03808616600483015260248201899052915194955091169263867904b49260448084019391929182900301818387803b15801561345957600080fd5b505af115801561346d573d6000803e3d6000fd5b505050506134796131b4565b6001600160a01b03166342c7b81961349085614c57565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156134c657600080fd5b505af11580156134da573d6000803e3d6000fd5b50505050806001600160a01b0316633a70599c866001600160a01b031663ec5568896040518163ffffffff1660e01b815260040160206040518083038186803b15801561352657600080fd5b505afa15801561353a573d6000803e3d6000fd5b505050506040513d602081101561355057600080fd5b5051604080516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820186905251604480830192600092919082900301818387803b15801561359f57600080fd5b505af11580156135b3573d6000803e3d6000fd5b505050505050505b60005b6004548110156136a257826001600160a01b0316600482815481106135df57fe5b6000918252602090912001546001600160a01b0316141561369a576004818154811061360757fe5b600091825260209091200180546001600160a01b031916905560048054600019810190811061363257fe5b600091825260209091200154600480546001600160a01b03909216918390811061365857fe5b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790556004805490613694906000198301615c69565b506136a2565b6001016135be565b506001600160a01b0382166000818152600660209081526040808320839055868352600582529182902080546001600160a01b031916905581518681529081019290925280517f6166f5c475cc1cd535c6cdf14a6d5edb811e34117031fc2863392a136eb655d09281900390910190a1505050565b6000806000806137b6613728613eb9565b6001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561377d57600080fd5b505afa158015613791573d6000803e3d6000fd5b505050506040513d60208110156137a757600080fd5b5051631cd554d160e21b61456a565b919450925090506000806137c9876130a1565b9150915081955082806137d95750805b92508585106137eb57600095506137fe565b6137fb868663ffffffff6146db16565b95505b50509193509193565b600081815260036020908152604080832054815170026b4b9b9b4b7339030b2323932b9b99d1607d1b9381019390935260318084018690528251808503909101815260519093019091526001600160a01b031690816127395760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156138a9578181015183820152602001613891565b50505050905090810190601f1680156138d65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60008060008061390d766578743a41676772656761746f7244656274526174696f60481b613807565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561394557600080fd5b505afa158015613959573d6000803e3d6000fd5b505050506040513d60a081101561396f57600080fd5b506020810151606090910151909450925050509091565b600061399f83836b033b2e3c9fd0803ce80000006155aa565b9392505050565b60006139b06155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6e1c985d1954dd185b1954195c9a5bd9608a1b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b505afa158015613a32573d6000803e3d6000fd5b505050506040513d6020811015613a4857600080fd5b5051905090565b60006111206822bc31b430b733b2b960b91b613807565b6000613a706155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f6d696e696d756d5374616b6554696d6560801b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b613ae761560b565b60408051633e9f85d160e11b81526001600160a01b038581166004830152848116602483015291519290911691637d3f0ba291604480820192602092909190829003018186803b158015613b3a57600080fd5b505afa158015613b4e573d6000803e3d6000fd5b505050506040513d6020811015613b6457600080fd5b5051610b30576040805162461bcd60e51b815260206004820152601d60248201527f4e6f7420617070726f76656420746f20616374206f6e20626568616c66000000604482015290519081900360640190fd5b613bbf6151e1565b15613bc957611521565b80613d7a57613bd783615071565b613c28576040805162461bcd60e51b815260206004820152601e60248201527f4d696e696d756d207374616b652074696d65206e6f7420726561636865640000604482015290519081900360640190fd5b600080613c33613a4f565b6001600160a01b0316631b16802c86631cd554d160e21b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050606060405180830381600087803b158015613c9957600080fd5b505af1158015613cad573d6000803e3d6000fd5b505050506040513d6060811015613cc357600080fd5b50602081015160409091015190925090508015613d7757613ce2613a4f565b60408051630984d1f960e31b81526001600160a01b038881166004830152631cd554d160e21b6024830152604482018890526064820186905291519290911691634c268fc891608480820192602092909190829003018186803b158015613d4857600080fd5b505afa158015613d5c573d6000803e3d6000fd5b505050506040513d6020811015613d7257600080fd5b505193505b50505b600080613d88613728613eb9565b9250509150600080613d99876130a1565b91509150613dae8380613da95750815b61539e565b60008411613df8576040805162461bcd60e51b81526020600482015260126024820152714e6f206465627420746f20666f726769766560701b604482015290519081900360640190fd5b8415613e1157613e0e848363ffffffff6146db16565b95505b6000613e1f8889898861562a565b905082613e32868363ffffffff6146db16565b11613eaf57613e3f614738565b6001600160a01b031663974e9e7f896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b158015613e9657600080fd5b505af1158015613eaa573d6000803e3d6000fd5b505050505b5050505050505050565b60006111207153796e74686574697844656274536861726560701b613807565b613ee161560b565b60408051630487261760e01b81526001600160a01b038581166004830152848116602483015291519290911691630487261791604480820192602092909190829003018186803b158015613b3a57600080fd5b6000816001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b158015613f6f57600080fd5b505afa158015613f83573d6000803e3d6000fd5b505050506040513d6020811015613f9957600080fd5b50516000818152600560205260409020549091506001600160a01b031615613ff7576040805162461bcd60e51b815260206004820152600c60248201526b53796e74682065786973747360a01b604482015290519081900360640190fd5b6001600160a01b03821660009081526006602052604090205415614062576040805162461bcd60e51b815260206004820152601c60248201527f53796e7468206164647265737320616c72656164792065786973747300000000604482015290519081900360640190fd5b60048054600181019091557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b0384166001600160a01b03199182168117909255600083815260056020908152604080832080549094168517909355838252600681529082902084905581518481529081019290925280517f0a2b6ebf143b3e9fcd67e17748ad315174746100c27228468b2c98c302c628849281900390910190a15050565b60006111206c45786368616e6765526174657360981b613807565b6060808261413b57600061413e565b60015b60ff1660048054905001604051908082528060200260200182016040528015614171578160200160208202803883390190505b50905060005b6004548110156141d857600660006004838154811061419257fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205482518390839081106141c557fe5b6020908102919091010152600101614177565b5082156114aa576004548151620a69cb60eb1b91839181106141f657fe5b60200260200101818152505092915050565b600080600080600061427061421b613eb9565b6001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561377d57600080fd5b9193509091506142809050614738565b6040805163952225f360e01b81526001600160a01b038a8116600483015289151560248301529151929091169163952225f391604480820192602092909190829003018186803b1580156142d357600080fd5b505afa1580156142e7573d6000803e3d6000fd5b505050506040513d60208110156142fd57600080fd5b50516143135750600093508392508291506117cf565b6000866143275761432261575e565b61432f565b61432f6157dc565b905060008061433c614111565b6001600160a01b0316630c71cd23620a69cb60eb1b6040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b15801561438457600080fd5b505afa158015614398573d6000803e3d6000fd5b505050506040513d60408110156143ae57600080fd5b50805160209091015190925090506143cc8480613da957508161539e565b60006143d78b614e4f565b90506143e1614738565b6001600160a01b031663f557f73c876143fa848761557d565b876040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b15801561443d57600080fd5b505afa158015614451573d6000803e3d6000fd5b505050506040513d602081101561446757600080fd5b505160408051630241ebdb60e61b81529051919950600091614513916144fd918891736bb3b18694a6849654379f040dcb112e07da9dc79163907af6c091600480820192602092909190829003018186803b1580156144c557600080fd5b505af41580156144d9573d6000803e3d6000fd5b505050506040513d60208110156144ef57600080fd5b50519063ffffffff61585b16565b6145078b876158b5565b9063ffffffff614c2d16565b90506145208c828d6158c7565b909a509750808a101561455b5761454d816145418b8d63ffffffff614c2d16565b9063ffffffff615a6f16565b98508982141561455b578698505b50505050505092959194509250565b600080600080600061457a610c57565b9250509150866000141561459657600094509092509050614649565b6000806145a1614111565b6001600160a01b0316630c71cd23896040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b1580156145e357600080fd5b505afa1580156145f7573d6000803e3d6000fd5b505050506040513d604081101561460d57600080fd5b5080516020909101519092509050614634826146288b615a8d565b9063ffffffff6146c616565b965083955080806146425750825b9450505050505b9250925092565b600061465a6155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6c69737375616e6365526174696f60981b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b600061399f8383670de0b6b3a76400006155aa565b600082821115614732576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000611120692634b8bab4b230ba37b960b11b613807565b614758615aab565b6001600160a01b031663270fb338846040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b1580156147af57600080fd5b505af11580156147c3573d6000803e3d6000fd5b5050505060006147d1613eb9565b90506000816001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561482b57600080fd5b505afa15801561483f573d6000803e3d6000fd5b505050506040513d602081101561485557600080fd5b50519050838314156148de57816001600160a01b0316631a378f0d86836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156148c157600080fd5b505af11580156148d5573d6000803e3d6000fd5b50505050611f82565b60006148e985615aca565b9050826001600160a01b0316631a378f0d87848410614908578461490a565b835b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561495957600080fd5b505af115801561496d573d6000803e3d6000fd5b50505050505050505050565b60008060008060006149896131b4565b6001600160a01b0316633a900a2e6040518163ffffffff1660e01b815260040160806040518083038186803b1580156149c157600080fd5b505afa1580156149d5573d6000803e3d6000fd5b505050506040513d60808110156149eb57600080fd5b508051604082015160609092015190945090925090508180614a0a5750805b93506000614a16614111565b905086614ab757600080614a286131b4565b6001600160a01b0316632992dba26040518163ffffffff1660e01b8152600401604080518083038186803b158015614a5f57600080fd5b505afa158015614a73573d6000803e3d6000fd5b505050506040513d6040811015614a8957600080fd5b5080516020909101519092509050614aa7868363ffffffff61585b16565b95508680614ab25750805b965050505b631cd554d160e21b881415614ad25750919350614b74915050565b600080826001600160a01b0316630c71cd238b6040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b158015614b1857600080fd5b505afa158015614b2c573d6000803e3d6000fd5b505050506040513d6040811015614b4257600080fd5b5080516020909101519092509050614b60868363ffffffff6146c616565b8780614b695750815b975097505050505050505b9250929050565b614b836155ee565b604080516d1b185cdd125cdcdd59515d995b9d60921b6020808301919091526bffffffffffffffffffffffff19606086901b1682840152825160348184030181526054830180855281519190920120631d5b277f60e01b9091526524b9b9bab2b960d11b6058830152607882015242609882015290516001600160a01b039290921691631d5b277f9160b88082019260009290919082900301818387803b158015611f6e57600080fd5b6000670de0b6b3a7640000614c48848463ffffffff615afc16565b81614c4f57fe5b049392505050565b6000600160ff1b8210614c9b5760405162461bcd60e51b8152600401808060200182810382526028815260200180615d286028913960400191505060405180910390fd5b5090565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110614ce157fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015614d20578160200160208202803883390190505b50905060005b8351811015614d6257838181518110614d3b57fe5b6020026020010151828281518110614d4f57fe5b6020908102919091010152600101614d26565b5060005b825181101561273957828181518110614d7b57fe5b6020026020010151828286510181518110614d9257fe5b6020908102919091010152600101614d66565b6000806000614db384614e4f565b9050600080614e18614dc3613eb9565b6001600160a01b03166370a08231886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561184a57600080fd5b92505091508260001415614e345760009450925061275c915050565b614e44828463ffffffff6146c616565b945092505050915091565b60006114aa614e5c615aab565b6001600160a01b0316628cc262846040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015614eb057600080fd5b505afa158015614ec4573d6000803e3d6000fd5b505050506040513d6020811015614eda57600080fd5b5051615065614ee7615b55565b6001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015614f3c57600080fd5b505afa158015614f50573d6000803e3d6000fd5b505050506040513d6020811015614f6657600080fd5b5051615065614f73615b71565b6001600160a01b03166370a08231886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015614fc857600080fd5b505afa158015614fdc573d6000803e3d6000fd5b505050506040513d6020811015614ff257600080fd5b5051614ffc612ef8565b6001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561505157600080fd5b505afa1580156144d9573d6000803e3d6000fd5b9063ffffffff61585b16565b600061508761507e613a66565b615065846150fd565b42101592915050565b61509861558f565b6001600160a01b0316336001600160a01b0316146131b2576040805162461bcd60e51b815260206004820152601a60248201527f4973737565723a204f6e6c792053796e746852656465656d6572000000000000604482015290519081900360640190fd5b60006151076155ee565b6001600160a01b03166323257c2b6524b9b9bab2b960d11b6d1b185cdd125cdcdd59515d995b9d60921b8560405160200180838152602001826001600160a01b03166001600160a01b031660601b815260140192505050604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b1580156151af57600080fd5b505afa1580156151c3573d6000803e3d6000fd5b505050506040513d60208110156151d957600080fd5b505192915050565b600080615207766578743a41676772656761746f7244656274526174696f60481b613807565b90506000816001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561524457600080fd5b505afa158015615258573d6000803e3d6000fd5b505050506040513d60a081101561526e57600080fd5b50602001519050600061527f614111565b6001600160a01b031663045056f8620a69cb60eb1b6040518263ffffffff1660e01b815260040180828152602001915050606060405180830381600087803b1580156152ca57600080fd5b505af11580156152de573d6000803e3d6000fd5b505050506040513d60608110156152f457600080fd5b50602001519050615303615b8e565b6001600160a01b031663413caeb584846040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561536257600080fd5b505af1158015615376573d6000803e3d6000fd5b505050506040513d602081101561538c57600080fd5b5051806153965750805b935050505090565b801561163e576040805162461bcd60e51b815260206004820152601e60248201527f412073796e7468206f7220534e58207261746520697320696e76616c69640000604482015290519081900360640190fd5b6153f9615aab565b6001600160a01b031663270fb338836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b15801561545057600080fd5b505af1158015615464573d6000803e3d6000fd5b505050506000615472613eb9565b9050600061547f83615aca565b90508061550357816001600160a01b031663c2f04b0a85856040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156154e657600080fd5b505af11580156154fa573d6000803e3d6000fd5b50505050615577565b816001600160a01b031663c2f04b0a85836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561556357600080fd5b505af1158015613eaf573d6000803e3d6000fd5b50505050565b600061399f838363ffffffff615baa16565b60006111206c29bcb73a342932b232b2b6b2b960991b613807565b6000806155d0846155c487600a870263ffffffff615afc16565b9063ffffffff615bbf16565b90506005600a825b06106155e257600a015b600a9004949350505050565b60006111206e466c657869626c6553746f7261676560881b613807565b60006111207044656c6567617465417070726f76616c7360781b613807565b60006156346151e1565b1561564157506000615756565b82821061564e5782615650565b815b905061565d858284614750565b631cd554d160e21b60009081526005602052600080516020615d508339815191525460408051632770a7eb60e21b81526001600160a01b0388811660048301526024820186905291519190921692639dc29fac926044808201939182900301818387803b1580156156cd57600080fd5b505af11580156156e1573d6000803e3d6000fd5b505050506156ed6131b4565b6001600160a01b03166342c7b81961570483614c57565b6000036040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561573d57600080fd5b505af1158015615751573d6000803e3d6000fd5b505050505b949350505050565b60006157686155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b74736e784c69717569646174696f6e50656e616c747960581b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b60006157e66155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7573656c664c69717569646174696f6e50656e616c747960501b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b60008282018381101561399f576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600061399f838363ffffffff6146c616565b60008060006158d4612ef8565b6001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561592957600080fd5b505afa15801561593d573d6000803e3d6000fd5b505050506040513d602081101561595357600080fd5b5051905080851161596b575083915060009050615a67565b831561597c57915060009050615a67565b6000615986615b55565b6001600160a01b03166370a08231886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156159db57600080fd5b505afa1580156159ef573d6000803e3d6000fd5b505050506040513d6020811015615a0557600080fd5b50519050615a19828263ffffffff61585b16565b861115615a3b57615a30828263ffffffff61585b16565b93509150615a679050565b615a4b868363ffffffff6146db16565b9250615a5d828463ffffffff61585b16565b9350615a67915050565b935093915050565b600061399f826155c485670de0b6b3a764000063ffffffff615afc16565b600080615a986138e4565b50905061399f838263ffffffff615c2916565b6000611120704c697175696461746f725265776172647360781b613807565b600080615ad56138e4565b5090508015615af357615aee838263ffffffff61398616565b61399f565b50600092915050565b600082615b0b575060006114aa565b82820282848281615b1857fe5b041461399f5760405162461bcd60e51b8152600401808060200182810382526021815260200180615d076021913960400191505060405180910390fd5b60006111206d2932bbb0b93222b9b1b937bbab1960911b613807565b60006111206e53796e746865746978457363726f7760881b613807565b60006111206d21b4b931bab4ba213932b0b5b2b960911b613807565b600061399f8383670de0b6b3a7640000615c3e565b6000808211615c15576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481615c2057fe5b04949350505050565b600061399f83836b033b2e3c9fd0803ce80000005b600080600a8304615c55868663ffffffff615afc16565b81615c5c57fe5b0490506005600a826155d8565b8154818355818111156115215760008381526020902061152191810190830161112391905b80821115614c9b5760008155600101615c8e56fe596f75206d757374206265206e6f6d696e61746564206265666f726520796f752063616e20616363657074206f776e6572736869704f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7753616665436173743a2076616c756520646f65736e27742066697420696e20616e20696e7432353674c62d09fbc50aefae0794a9a068f786a692826fbdfe63828ec23a875865823f4973737565723a204f6e6c792053796e74686574697800000000000000000000a265627a7a72315820948feade1e9d3c49a8f5cc527c49505fcbfb481db0fd8f56536c54fa22a0f3f864736f6c6343000510003200000000000000000000000073570075092502472e4b61a7058df1a4a1db12f20000000000000000000000009fc84992df5496797784374b810e04238728743d

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102a05760003560e01c806372c6581611610167578063a5fdc5de116100ce578063c897713211610087578063c897713214610990578063d37c4d8b146109b6578063d686c06c146109e2578063dbf6334014610a18578063dd3d2b2e14610a20578063fd864ccf14610a46576102a0565b8063a5fdc5de146108b8578063ae3bbbbb146108de578063b06e8c6514610904578063b410a03414610930578063bff4fdfc14610938578063c81ff8fa1461095e576102a0565b8063849cf58811610120578063849cf588146107f4578063890235d41461081a578063899ffef41461084c5780638da5cb5b146108545780639a5154b41461085c578063a311c7c214610892576102a0565b806372c658161461076c57806372cb051f1461079a57806374185360146107a257806379ba5097146107aa5780637b1001b7146107b2578063835e119c146107d7576102a0565b806331e6da5a1161020b5780634e99bda9116101c45780634e99bda91461064d57806353a47bb7146106555780635e887fe91461065d578063614d08f8146106b15780636bed0415146106b95780637168d2c2146106fe576102a0565b806331e6da5a1461048257806332608039146104a85780633b6afe40146104c557806344ec6b621461058357806347a9b6db146105b9578063497d704a14610627576102a0565b80631627540c1161025d5780631627540c146103b857806316b2213f146103de5780631b3ba4d014610404578063242df9e1146104305780632af64bd3146104385780632b3f41aa14610454576102a0565b8063042e0688146102a557806304f3bcec146102d357806305b3c1c9146102f75780630b887dae1461032f5780631137aedf1461034c5780631313e6ca14610390575b600080fd5b6102d1600480360360408110156102bb57600080fd5b506001600160a01b038135169060200135610a74565b005b6102db610b34565b604080516001600160a01b039092168252519081900360200190f35b61031d6004803603602081101561030d57600080fd5b50356001600160a01b0316610b43565b60408051918252519081900360200190f35b6102d16004803603602081101561034557600080fd5b5035610b57565b6103726004803603602081101561036257600080fd5b50356001600160a01b0316610c3b565b60408051938452602084019290925282820152519081900360600190f35b610398610c57565b604080519384526020840192909252151582820152519081900360600190f35b6102d1600480360360208110156103ce57600080fd5b50356001600160a01b0316610d62565b61031d600480360360208110156103f457600080fd5b50356001600160a01b0316610dbe565b6102d16004803603604081101561041a57600080fd5b506001600160a01b038135169060200135610dd0565b61031d611116565b610440611126565b604080519115158252519081900360200190f35b6102d16004803603604081101561046a57600080fd5b506001600160a01b0381358116916020013516611230565b6102d16004803603602081101561049857600080fd5b50356001600160801b03166112a2565b6102db600480360360208110156104be57600080fd5b50356113e7565b610533600480360360208110156104db57600080fd5b810190602081018135600160201b8111156104f557600080fd5b82018360208201111561050757600080fd5b803590602001918460208302840111600160201b8311171561052857600080fd5b509092509050611402565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561056f578181015183820152602001610557565b505050509050019250505060405180910390f35b6102d16004803603606081101561059957600080fd5b506001600160a01b038135811691602081013590911690604001356114b0565b6102d1600480360360208110156105cf57600080fd5b810190602081018135600160201b8111156105e957600080fd5b8201836020820111156105fb57600080fd5b803590602001918460208302840111600160201b8311171561061c57600080fd5b509092509050611526565b6102d16004803603602081101561063d57600080fd5b50356001600160a01b03166115d6565b610440611641565b6102db6117a7565b61068b6004803603604081101561067357600080fd5b506001600160a01b03813516906020013515156117b6565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61031d6117d8565b6106e5600480360360408110156106cf57600080fd5b506001600160a01b0381351690602001356117e5565b6040805192835290151560208301528051918290030190f35b6102d16004803603602081101561071457600080fd5b810190602081018135600160201b81111561072e57600080fd5b82018360208201111561074057600080fd5b803590602001918460208302840111600160201b8311171561076157600080fd5b5090925090506118d1565b6103726004803603604081101561078257600080fd5b506001600160a01b0381351690602001351515611a74565b610533611c4c565b6102d1611c58565b6102d1611e1c565b61031d600480360360408110156107c857600080fd5b50803590602001351515611ed8565b6102db600480360360208110156107ed57600080fd5b5035611ee4565b6102d16004803603602081101561080a57600080fd5b50356001600160a01b0316611f0b565b6104406004803603606081101561083057600080fd5b508035906001600160a01b036020820135169060400135611f89565b6105336123dd565b6102db6126ae565b6102d16004803603606081101561087257600080fd5b506001600160a01b038135811691602081013590911690604001356126bd565b61031d600480360360208110156108a857600080fd5b50356001600160a01b031661272e565b61031d600480360360208110156108ce57600080fd5b50356001600160a01b0316612740565b6106e5600480360360208110156108f457600080fd5b50356001600160a01b031661274b565b6102d16004803603604081101561091a57600080fd5b506001600160a01b038135169060200135612761565b61031d6127c8565b6104406004803603602081101561094e57600080fd5b50356001600160a01b03166127d2565b6104406004803603606081101561097457600080fd5b508035906001600160a01b0360208201351690604001356127dd565b6102d1600480360360208110156109a657600080fd5b50356001600160a01b0316612c95565b61031d600480360360408110156109cc57600080fd5b506001600160a01b038135169060200135612cfd565b6102d1600480360360608110156109f857600080fd5b506001600160a01b03813581169160208101359091169060400135612db6565b61031d612e75565b61031d60048036036020811015610a3657600080fd5b50356001600160a01b0316612e7b565b6102d160048036036040811015610a5c57600080fd5b506001600160a01b0381358116916020013516612e86565b610a7c612ef8565b6001600160a01b0316336001600160a01b031614610acf576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b60008111610b24576040805162461bcd60e51b815260206004820152601d60248201527f4973737565723a2063616e6e6f7420697373756520302073796e746873000000604482015290519081900360640190fd5b610b3082826000612f0f565b5050565b6002546001600160a01b031681565b600080610b4f836130a1565b509392505050565b610b5f613169565b6000610b696131b4565b9050806001600160a01b031663d685743a8360006040518363ffffffff1660e01b81526004018083815260200182815260200192505050600060405180830381600087803b158015610bba57600080fd5b505af1158015610bce573d6000803e3d6000fd5b5050604080516304bd11e560e01b81526001600482015290516001600160a01b03851693506304bd11e59250602480830192600092919082900301818387803b158015610c1a57600080fd5b505af1158015610c2e573d6000803e3d6000fd5b50505050610b30826131cb565b6000806000610c4984613717565b509196909550909350915050565b6000806000806000610c887f6578743a41676772656761746f7249737375656453796e746873000000000000613807565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610cc057600080fd5b505afa158015610cd4573d6000803e3d6000fd5b505050506040513d60a0811015610cea57600080fd5b5060208101516060909101519092509050600080610d066138e4565b9150915083965081600014610d2a57610d25878363ffffffff61398616565b610d2d565b60005b95506000610d396139a6565b90504281108015610d565750838142031180610d56575081814203115b95505050505050909192565b610d6a613169565b600180546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229181900360200190a150565b60066020526000908152604090205481565b610dd8613169565b6001600160a01b038216610e33576040805162461bcd60e51b815260206004820152601760248201527f4973737565723a20696e76616c69642061646472657373000000000000000000604482015290519081900360640190fd5b600254604080516321f8a72160e01b815274436f6c6c61746572616c53686f72744c656761637960581b600482015290516001600160a01b03909216916321f8a72191602480820192602092909190829003018186803b158015610e9657600080fd5b505afa158015610eaa573d6000803e3d6000fd5b505050506040513d6020811015610ec057600080fd5b50516001600160a01b03838116911614610f21576040805162461bcd60e51b815260206004820152601b60248201527f4973737565723a2077726f6e672073686f727420616464726573730000000000604482015290519081900360640190fd5b631cd554d160e21b6000526005602052600080516020615d50833981519152546001600160a01b0316610f9b576040805162461bcd60e51b815260206004820152601b60248201527f4973737565723a2073796e746820646f65736e27742065786973740000000000604482015290519081900360640190fd5b60008111610ff0576040805162461bcd60e51b815260206004820152601c60248201527f4973737565723a2063616e6e6f74206275726e20302073796e74687300000000604482015290519081900360640190fd5b610ff8613a4f565b6001600160a01b0316631b16802c83631cd554d160e21b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050606060405180830381600087803b15801561105e57600080fd5b505af1158015611072573d6000803e3d6000fd5b505050506040513d606081101561108857600080fd5b5050631cd554d160e21b60009081526005602052600080516020615d508339815191525460408051632770a7eb60e21b81526001600160a01b0386811660048301526024820186905291519190921692639dc29fac926044808201939182900301818387803b1580156110fa57600080fd5b505af115801561110e573d6000803e3d6000fd5b505050505050565b6000611120613a66565b90505b90565b600060606111326123dd565b905060005b815181101561122757600082828151811061114e57fe5b6020908102919091018101516000818152600383526040908190205460025482516321f8a72160e01b81526004810185905292519395506001600160a01b03918216949116926321f8a721926024808201939291829003018186803b1580156111b657600080fd5b505afa1580156111ca573d6000803e3d6000fd5b505050506040513d60208110156111e057600080fd5b50516001600160a01b031614158061120d57506000818152600360205260409020546001600160a01b0316155b1561121e5760009350505050611123565b50600101611137565b50600191505090565b611238612ef8565b6001600160a01b0316336001600160a01b03161461128b576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b6112958282613adf565b610b308260006001613bb7565b6112b566119959541bdbdb60ca1b613807565b6001600160a01b0316336001600160a01b03161461130d576040805162461bcd60e51b815260206004820152601060248201526f135d5cdd08189948199959481c1bdbdb60821b604482015290519081900360640190fd5b6000611317613eb9565b9050816001600160801b0316816001600160a01b031663988e65956040518163ffffffff1660e01b815260040160206040518083038186803b15801561135c57600080fd5b505afa158015611370573d6000803e3d6000fd5b505050506040513d602081101561138657600080fd5b50516001600160801b03161015610b30576040805163abb6de9560e01b81526001600160801b038416600482015290516001600160a01b0383169163abb6de9591602480830192600092919082900301818387803b1580156110fa57600080fd5b6005602052600090815260409020546001600160a01b031681565b60408051828152602080840282010190915260609082908290828015611432578160200160208202803883390190505b50905060005b828110156114a5576005600087878481811061145057fe5b90506020020135815260200190815260200160002060009054906101000a90046001600160a01b031682828151811061148557fe5b6001600160a01b0390921660209283029190910190910152600101611438565b509150505b92915050565b6114b8612ef8565b6001600160a01b0316336001600160a01b03161461150b576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b6115158383613ed9565b61152183826000612f0f565b505050565b61152e613169565b8060005b818110156115665761155e84848381811061154957fe5b905060200201356001600160a01b0316613f34565b600101611532565b5061156f6131b4565b6001600160a01b03166304bd11e560016040518263ffffffff1660e01b81526004018082151515158152602001915050600060405180830381600087803b1580156115b957600080fd5b505af11580156115cd573d6000803e3d6000fd5b50505050505050565b6115de612ef8565b6001600160a01b0316336001600160a01b031614611631576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b61163e8160006001613bb7565b50565b600061164b614111565b6001600160a01b031663c8e5bbd5611663600161412c565b6040518263ffffffff1660e01b81526004018080602001828103825283818151815260200191508051906020019060200280838360005b838110156116b257818101518382015260200161169a565b505050509050019250505060006040518083038186803b1580156116d557600080fd5b505afa1580156116e9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561171257600080fd5b8101908080516040519392919084600160201b82111561173157600080fd5b90830190602082018581111561174657600080fd5b82518660208202830111600160201b8211171561176257600080fd5b82525081516020918201928201910280838360005b8381101561178f578181015183820152602001611777565b50505050919091016040525060200151949350505050565b6001546001600160a01b031681565b6000806000806117c68686614208565b93509350935093505b92959194509250565b6524b9b9bab2b960d11b81565b60008060006118826117f5613eb9565b6001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561184a57600080fd5b505afa15801561185e573d6000803e3d6000fd5b505050506040513d602081101561187457600080fd5b5051620a69cb60eb1b61456a565b9350909150600090506118a3611896614650565b839063ffffffff6146c616565b90508481106118b557600093506118c8565b6118c5858263ffffffff6146db16565b93505b50509250929050565b6118d9613169565b8060006118e46131b4565b9050606082604051908082528060200260200182016040528015611912578160200160208202803883390190505b509050816001600160a01b03166317b38db48686846040518463ffffffff1660e01b815260040180806020018060200183810383528686828181526020019250602002808284376000838201819052601f909101601f1916909201858103845286518152865160209182019382890193509102908190849084905b838110156119a557818101518382015260200161198d565b5050505090500195505050505050600060405180830381600087803b1580156119cd57600080fd5b505af11580156119e1573d6000803e3d6000fd5b5050604080516304bd11e560e01b81526001600482015290516001600160a01b03861693506304bd11e59250602480830192600092919082900301818387803b158015611a2d57600080fd5b505af1158015611a41573d6000803e3d6000fd5b506000925050505b8381101561110e57611a6c868683818110611a6057fe5b905060200201356131cb565b600101611a49565b6000806000611a81612ef8565b6001600160a01b0316336001600160a01b031614611ad4576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b611adc614738565b6040805163952225f360e01b81526001600160a01b03888116600483015287151560248301529151929091169163952225f391604480820192602092909190829003018186803b158015611b2f57600080fd5b505afa158015611b43573d6000803e3d6000fd5b505050506040513d6020811015611b5957600080fd5b5051611bac576040805162461bcd60e51b815260206004820152601860248201527f4e6f74206f70656e20666f72206c69717569646174696f6e0000000000000000604482015290519081900360640190fd5b6000611bb88686614208565b92965090945092509050611bcd868483614750565b611bd5614738565b6001600160a01b031663974e9e7f876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b158015611c2c57600080fd5b505af1158015611c40573d6000803e3d6000fd5b50505050509250925092565b6060611120600061412c565b6060611c626123dd565b905060005b8151811015610b30576000828281518110611c7e57fe5b602090810291909101810151600254604080517f5265736f6c766572206d697373696e67207461726765743a2000000000000000818601526039808201859052825180830390910181526059820180845263dacb2d0160e01b9052605d8201858152607d83019384528151609d84015281519597506000966001600160a01b039095169563dacb2d01958995939492939260bd0191908501908083838c5b83811015611d34578181015183820152602001611d1c565b50505050905090810190601f168015611d615780820380516001836020036101000a031916815260200191505b50935050505060206040518083038186803b158015611d7f57600080fd5b505afa158015611d93573d6000803e3d6000fd5b505050506040513d6020811015611da957600080fd5b505160008381526003602090815260409182902080546001600160a01b0319166001600160a01b03851690811790915582518681529182015281519293507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68929081900390910190a15050600101611c67565b6001546001600160a01b03163314611e655760405162461bcd60e51b8152600401808060200182810382526035815260200180615ca36035913960400191505060405180910390fd5b600054600154604080516001600160a01b03938416815292909116602083015280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000610b4f8383614979565b60048181548110611ef157fe5b6000918252602090912001546001600160a01b0316905081565b611f13613169565b611f1c81613f34565b611f246131b4565b6001600160a01b03166304bd11e560016040518263ffffffff1660e01b81526004018082151515158152602001915050600060405180830381600087803b158015611f6e57600080fd5b505af1158015611f82573d6000803e3d6000fd5b5050505050565b600254604080516321f8a72160e01b81527853796e746865746978427269646765546f4f7074696d69736d60381b6004820152905160009283926001600160a01b03909116916321f8a72191602480820192602092909190829003018186803b158015611ff557600080fd5b505afa158015612009573d6000803e3d6000fd5b505050506040513d602081101561201f57600080fd5b5051600254604080516321f8a72160e01b81527453796e746865746978427269646765546f4261736560581b600482015290519293506000926001600160a01b03909216916321f8a72191602480820192602092909190829003018186803b15801561208a57600080fd5b505afa15801561209e573d6000803e3d6000fd5b505050506040513d60208110156120b457600080fd5b50519050336001600160a01b03831614806120d75750336001600160a01b038216145b612128576040805162461bcd60e51b815260206004820152601c60248201527f4973737565723a206f6e6c792074727573746564206d696e7465727300000000604482015290519081900360640190fd5b6001600160a01b038216158061214557506001600160a01b038116155b612196576040805162461bcd60e51b815260206004820152601e60248201527f4973737565723a206f6e65206d696e746572206d757374206265203078300000604482015290519081900360640190fd5b6000868152600560205260409020546001600160a01b03166121ff576040805162461bcd60e51b815260206004820152601b60248201527f4973737565723a2073796e746820646f65736e27742065786973740000000000604482015290519081900360640190fd5b60008411612254576040805162461bcd60e51b815260206004820152601d60248201527f4973737565723a2063616e6e6f7420697373756520302073796e746873000000604482015290519081900360640190fd5b61225d85614b7b565b60008681526005602052604080822054815163219e412d60e21b81526001600160a01b038981166004830152602482018990529251929091169263867904b49260448084019382900301818387803b1580156122b857600080fd5b505af11580156122cc573d6000803e3d6000fd5b505050506000806122db614111565b6001600160a01b0316630c71cd23896040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b15801561231d57600080fd5b505afa158015612331573d6000803e3d6000fd5b505050506040513d604081101561234757600080fd5b508051602090910151909250905061235d6131b4565b6001600160a01b03166342c7b81961238361237e898663ffffffff614c2d16565b614c57565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156123b957600080fd5b505af11580156123cd573d6000803e3d6000fd5b50929a9950505050505050505050565b6060806123e8614c9f565b60408051600f808252610200820190925291925060609190602082016101e080388339019050509050680a6f2dce8d0cae8d2f60bb1b8160008151811061242b57fe5b6020026020010181815250506822bc31b430b733b2b960b91b8160018151811061245157fe5b6020026020010181815250506c45786368616e6765526174657360981b8160028151811061247b57fe5b6020026020010181815250506d21b4b931bab4ba213932b0b5b2b960911b816003815181106124a657fe5b6020026020010181815250507153796e74686574697844656274536861726560701b816004815181106124d557fe5b60200260200101818152505066119959541bdbdb60ca1b816005815181106124f957fe5b6020026020010181815250507044656c6567617465417070726f76616c7360781b8160068151811061252757fe5b6020026020010181815250506d2932bbb0b93222b9b1b937bbab1960911b8160078151811061255257fe5b6020026020010181815250506e53796e746865746978457363726f7760881b8160088151811061257e57fe5b602002602001018181525050692634b8bab4b230ba37b960b11b816009815181106125a557fe5b602002602001018181525050704c697175696461746f725265776172647360781b81600a815181106125d357fe5b6020026020010181815250506844656274436163686560b81b81600b815181106125f957fe5b6020026020010181815250506c29bcb73a342932b232b2b6b2b960991b81600c8151811061262357fe5b6020026020010181815250507f6578743a41676772656761746f7249737375656453796e74687300000000000081600d8151811061265d57fe5b602002602001018181525050766578743a41676772656761746f7244656274526174696f60481b81600e8151811061269157fe5b6020026020010181815250506126a78282614cf0565b9250505090565b6000546001600160a01b031681565b6126c5612ef8565b6001600160a01b0316336001600160a01b031614612718576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b6127228383613adf565b61152183826000613bb7565b600061273982614da5565b5092915050565b60006114aa82614e4f565b60008061275783614da5565b915091505b915091565b612769612ef8565b6001600160a01b0316336001600160a01b0316146127bc576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b610b3082826000613bb7565b6000611120614650565b60006114aa82615071565b600254604080516321f8a72160e01b81527853796e746865746978427269646765546f4f7074696d69736d60381b6004820152905160009283926001600160a01b03909116916321f8a72191602480820192602092909190829003018186803b15801561284957600080fd5b505afa15801561285d573d6000803e3d6000fd5b505050506040513d602081101561287357600080fd5b5051600254604080516321f8a72160e01b81527453796e746865746978427269646765546f4261736560581b600482015290519293506000926001600160a01b03909216916321f8a72191602480820192602092909190829003018186803b1580156128de57600080fd5b505afa1580156128f2573d6000803e3d6000fd5b505050506040513d602081101561290857600080fd5b50519050336001600160a01b038316148061292b5750336001600160a01b038216145b61297c576040805162461bcd60e51b815260206004820152601c60248201527f4973737565723a206f6e6c792074727573746564206d696e7465727300000000604482015290519081900360640190fd5b6001600160a01b038216158061299957506001600160a01b038116155b6129ea576040805162461bcd60e51b815260206004820152601e60248201527f4973737565723a206f6e65206d696e746572206d757374206265203078300000604482015290519081900360640190fd5b6000868152600560205260409020546001600160a01b0316612a53576040805162461bcd60e51b815260206004820152601b60248201527f4973737565723a2073796e746820646f65736e27742065786973740000000000604482015290519081900360640190fd5b60008411612aa8576040805162461bcd60e51b815260206004820152601d60248201527f4973737565723a2063616e6e6f7420697373756520302073796e746873000000604482015290519081900360640190fd5b612ab0613a4f565b6001600160a01b0316631b16802c86886040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050606060405180830381600087803b158015612b0f57600080fd5b505af1158015612b23573d6000803e3d6000fd5b505050506040513d6060811015612b3957600080fd5b5050600086815260056020526040808220548151632770a7eb60e21b81526001600160a01b0389811660048301526024820189905292519290911692639dc29fac9260448084019382900301818387803b158015612b9657600080fd5b505af1158015612baa573d6000803e3d6000fd5b50505050600080612bb9614111565b6001600160a01b0316630c71cd23896040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b158015612bfb57600080fd5b505afa158015612c0f573d6000803e3d6000fd5b505050506040513d6040811015612c2557600080fd5b5080516020909101519092509050612c3b6131b4565b6001600160a01b03166342c7b819612c5c61237e898663ffffffff614c2d16565b6000036040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156123b957600080fd5b612c9d612ef8565b6001600160a01b0316336001600160a01b031614612cf0576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b61163e8160006001612f0f565b600080612d08613eb9565b90506000816001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612d6257600080fd5b505afa158015612d76573d6000803e3d6000fd5b505050506040513d6020811015612d8c57600080fd5b5051905080612da0576000925050506114aa565b612daa818561456a565b50909695505050505050565b612dbe615090565b826001600160a01b031663d4b839926040518163ffffffff1660e01b815260040160206040518083038186803b158015612df757600080fd5b505afa158015612e0b573d6000803e3d6000fd5b505050506040513d6020811015612e2157600080fd5b505160408051632770a7eb60e21b81526001600160a01b0385811660048301526024820185905291519190921691639dc29fac91604480830192600092919082900301818387803b1580156115b957600080fd5b60045490565b60006114aa826150fd565b612e8e612ef8565b6001600160a01b0316336001600160a01b031614612ee1576040805162461bcd60e51b81526020600482015260166024820152600080516020615d70833981519152604482015290519081900360640190fd5b612eeb8282613ed9565b610b308260006001612f0f565b6000611120680a6f2dce8d0cae8d2f60bb1b613807565b612f176151e1565b15612f2157611521565b600080612f2d85613717565b935050509150612f3c8161539e565b82612f8e5781841115612f89576040805162461bcd60e51b815260206004820152601060248201526f416d6f756e7420746f6f206c6172676560801b604482015290519081900360640190fd5b612f92565b8193505b612f9c85856153f1565b612fa585614b7b565b631cd554d160e21b60009081526005602052600080516020615d50833981519152546040805163219e412d60e21b81526001600160a01b038981166004830152602482018990529151919092169263867904b4926044808201939182900301818387803b15801561301557600080fd5b505af1158015613029573d6000803e3d6000fd5b505050506130356131b4565b6001600160a01b03166342c7b81961304c86614c57565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561308257600080fd5b505af1158015613096573d6000803e3d6000fd5b505050505050505050565b6000806000806130af614111565b6001600160a01b0316630c71cd23620a69cb60eb1b6040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b1580156130f757600080fd5b505afa15801561310b573d6000803e3d6000fd5b505050506040513d604081101561312157600080fd5b5080516020909101519092509050600061314361313d87614e4f565b8461557d565b905061315d613150614650565b829063ffffffff614c2d16565b94509092505050915091565b6000546001600160a01b031633146131b25760405162461bcd60e51b815260040180806020018281038252602f815260200180615cd8602f913960400191505060405180910390fd5b565b60006111206844656274436163686560b81b613807565b6000818152600560205260409020546001600160a01b03168061322c576040805162461bcd60e51b815260206004820152601460248201527314de5b9d1a08191bd95cc81b9bdd08195e1a5cdd60621b604482015290519081900360640190fd5b631cd554d160e21b82141561327e576040805162461bcd60e51b8152602060048201526013602482015272086c2dcdcdee840e4cadadeecca40e6f2dce8d606b1b604482015290519081900360640190fd5b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156132b957600080fd5b505afa1580156132cd573d6000803e3d6000fd5b505050506040513d60208110156132e357600080fd5b5051905080156135bb576000806132f8614111565b6001600160a01b0316638295016a86856040518363ffffffff1660e01b81526004018083815260200182815260200180631cd554d160e21b8152506020019250505060606040518083038186803b15801561335257600080fd5b505afa158015613366573d6000803e3d6000fd5b505050506040513d606081101561337c57600080fd5b5080516020909101519092509050806133dc576040805162461bcd60e51b815260206004820152601a60248201527f43616e6e6f742072656d6f766520776974686f75742072617465000000000000604482015290519081900360640190fd5b60006133e661558f565b631cd554d160e21b60009081526005602052600080516020615d50833981519152546040805163219e412d60e21b81526001600160a01b03808616600483015260248201899052915194955091169263867904b49260448084019391929182900301818387803b15801561345957600080fd5b505af115801561346d573d6000803e3d6000fd5b505050506134796131b4565b6001600160a01b03166342c7b81961349085614c57565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156134c657600080fd5b505af11580156134da573d6000803e3d6000fd5b50505050806001600160a01b0316633a70599c866001600160a01b031663ec5568896040518163ffffffff1660e01b815260040160206040518083038186803b15801561352657600080fd5b505afa15801561353a573d6000803e3d6000fd5b505050506040513d602081101561355057600080fd5b5051604080516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820186905251604480830192600092919082900301818387803b15801561359f57600080fd5b505af11580156135b3573d6000803e3d6000fd5b505050505050505b60005b6004548110156136a257826001600160a01b0316600482815481106135df57fe5b6000918252602090912001546001600160a01b0316141561369a576004818154811061360757fe5b600091825260209091200180546001600160a01b031916905560048054600019810190811061363257fe5b600091825260209091200154600480546001600160a01b03909216918390811061365857fe5b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790556004805490613694906000198301615c69565b506136a2565b6001016135be565b506001600160a01b0382166000818152600660209081526040808320839055868352600582529182902080546001600160a01b031916905581518681529081019290925280517f6166f5c475cc1cd535c6cdf14a6d5edb811e34117031fc2863392a136eb655d09281900390910190a1505050565b6000806000806137b6613728613eb9565b6001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561377d57600080fd5b505afa158015613791573d6000803e3d6000fd5b505050506040513d60208110156137a757600080fd5b5051631cd554d160e21b61456a565b919450925090506000806137c9876130a1565b9150915081955082806137d95750805b92508585106137eb57600095506137fe565b6137fb868663ffffffff6146db16565b95505b50509193509193565b600081815260036020908152604080832054815170026b4b9b9b4b7339030b2323932b9b99d1607d1b9381019390935260318084018690528251808503909101815260519093019091526001600160a01b031690816127395760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156138a9578181015183820152602001613891565b50505050905090810190601f1680156138d65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60008060008061390d766578743a41676772656761746f7244656274526174696f60481b613807565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561394557600080fd5b505afa158015613959573d6000803e3d6000fd5b505050506040513d60a081101561396f57600080fd5b506020810151606090910151909450925050509091565b600061399f83836b033b2e3c9fd0803ce80000006155aa565b9392505050565b60006139b06155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6e1c985d1954dd185b1954195c9a5bd9608a1b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b505afa158015613a32573d6000803e3d6000fd5b505050506040513d6020811015613a4857600080fd5b5051905090565b60006111206822bc31b430b733b2b960b91b613807565b6000613a706155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f6d696e696d756d5374616b6554696d6560801b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b613ae761560b565b60408051633e9f85d160e11b81526001600160a01b038581166004830152848116602483015291519290911691637d3f0ba291604480820192602092909190829003018186803b158015613b3a57600080fd5b505afa158015613b4e573d6000803e3d6000fd5b505050506040513d6020811015613b6457600080fd5b5051610b30576040805162461bcd60e51b815260206004820152601d60248201527f4e6f7420617070726f76656420746f20616374206f6e20626568616c66000000604482015290519081900360640190fd5b613bbf6151e1565b15613bc957611521565b80613d7a57613bd783615071565b613c28576040805162461bcd60e51b815260206004820152601e60248201527f4d696e696d756d207374616b652074696d65206e6f7420726561636865640000604482015290519081900360640190fd5b600080613c33613a4f565b6001600160a01b0316631b16802c86631cd554d160e21b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050606060405180830381600087803b158015613c9957600080fd5b505af1158015613cad573d6000803e3d6000fd5b505050506040513d6060811015613cc357600080fd5b50602081015160409091015190925090508015613d7757613ce2613a4f565b60408051630984d1f960e31b81526001600160a01b038881166004830152631cd554d160e21b6024830152604482018890526064820186905291519290911691634c268fc891608480820192602092909190829003018186803b158015613d4857600080fd5b505afa158015613d5c573d6000803e3d6000fd5b505050506040513d6020811015613d7257600080fd5b505193505b50505b600080613d88613728613eb9565b9250509150600080613d99876130a1565b91509150613dae8380613da95750815b61539e565b60008411613df8576040805162461bcd60e51b81526020600482015260126024820152714e6f206465627420746f20666f726769766560701b604482015290519081900360640190fd5b8415613e1157613e0e848363ffffffff6146db16565b95505b6000613e1f8889898861562a565b905082613e32868363ffffffff6146db16565b11613eaf57613e3f614738565b6001600160a01b031663974e9e7f896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b158015613e9657600080fd5b505af1158015613eaa573d6000803e3d6000fd5b505050505b5050505050505050565b60006111207153796e74686574697844656274536861726560701b613807565b613ee161560b565b60408051630487261760e01b81526001600160a01b038581166004830152848116602483015291519290911691630487261791604480820192602092909190829003018186803b158015613b3a57600080fd5b6000816001600160a01b031663dbd06c856040518163ffffffff1660e01b815260040160206040518083038186803b158015613f6f57600080fd5b505afa158015613f83573d6000803e3d6000fd5b505050506040513d6020811015613f9957600080fd5b50516000818152600560205260409020549091506001600160a01b031615613ff7576040805162461bcd60e51b815260206004820152600c60248201526b53796e74682065786973747360a01b604482015290519081900360640190fd5b6001600160a01b03821660009081526006602052604090205415614062576040805162461bcd60e51b815260206004820152601c60248201527f53796e7468206164647265737320616c72656164792065786973747300000000604482015290519081900360640190fd5b60048054600181019091557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b0384166001600160a01b03199182168117909255600083815260056020908152604080832080549094168517909355838252600681529082902084905581518481529081019290925280517f0a2b6ebf143b3e9fcd67e17748ad315174746100c27228468b2c98c302c628849281900390910190a15050565b60006111206c45786368616e6765526174657360981b613807565b6060808261413b57600061413e565b60015b60ff1660048054905001604051908082528060200260200182016040528015614171578160200160208202803883390190505b50905060005b6004548110156141d857600660006004838154811061419257fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205482518390839081106141c557fe5b6020908102919091010152600101614177565b5082156114aa576004548151620a69cb60eb1b91839181106141f657fe5b60200260200101818152505092915050565b600080600080600061427061421b613eb9565b6001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561377d57600080fd5b9193509091506142809050614738565b6040805163952225f360e01b81526001600160a01b038a8116600483015289151560248301529151929091169163952225f391604480820192602092909190829003018186803b1580156142d357600080fd5b505afa1580156142e7573d6000803e3d6000fd5b505050506040513d60208110156142fd57600080fd5b50516143135750600093508392508291506117cf565b6000866143275761432261575e565b61432f565b61432f6157dc565b905060008061433c614111565b6001600160a01b0316630c71cd23620a69cb60eb1b6040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b15801561438457600080fd5b505afa158015614398573d6000803e3d6000fd5b505050506040513d60408110156143ae57600080fd5b50805160209091015190925090506143cc8480613da957508161539e565b60006143d78b614e4f565b90506143e1614738565b6001600160a01b031663f557f73c876143fa848761557d565b876040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b15801561443d57600080fd5b505afa158015614451573d6000803e3d6000fd5b505050506040513d602081101561446757600080fd5b505160408051630241ebdb60e61b81529051919950600091614513916144fd918891736bb3b18694a6849654379f040dcb112e07da9dc79163907af6c091600480820192602092909190829003018186803b1580156144c557600080fd5b505af41580156144d9573d6000803e3d6000fd5b505050506040513d60208110156144ef57600080fd5b50519063ffffffff61585b16565b6145078b876158b5565b9063ffffffff614c2d16565b90506145208c828d6158c7565b909a509750808a101561455b5761454d816145418b8d63ffffffff614c2d16565b9063ffffffff615a6f16565b98508982141561455b578698505b50505050505092959194509250565b600080600080600061457a610c57565b9250509150866000141561459657600094509092509050614649565b6000806145a1614111565b6001600160a01b0316630c71cd23896040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b1580156145e357600080fd5b505afa1580156145f7573d6000803e3d6000fd5b505050506040513d604081101561460d57600080fd5b5080516020909101519092509050614634826146288b615a8d565b9063ffffffff6146c616565b965083955080806146425750825b9450505050505b9250925092565b600061465a6155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6c69737375616e6365526174696f60981b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b600061399f8383670de0b6b3a76400006155aa565b600082821115614732576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000611120692634b8bab4b230ba37b960b11b613807565b614758615aab565b6001600160a01b031663270fb338846040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b1580156147af57600080fd5b505af11580156147c3573d6000803e3d6000fd5b5050505060006147d1613eb9565b90506000816001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561482b57600080fd5b505afa15801561483f573d6000803e3d6000fd5b505050506040513d602081101561485557600080fd5b50519050838314156148de57816001600160a01b0316631a378f0d86836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156148c157600080fd5b505af11580156148d5573d6000803e3d6000fd5b50505050611f82565b60006148e985615aca565b9050826001600160a01b0316631a378f0d87848410614908578461490a565b835b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561495957600080fd5b505af115801561496d573d6000803e3d6000fd5b50505050505050505050565b60008060008060006149896131b4565b6001600160a01b0316633a900a2e6040518163ffffffff1660e01b815260040160806040518083038186803b1580156149c157600080fd5b505afa1580156149d5573d6000803e3d6000fd5b505050506040513d60808110156149eb57600080fd5b508051604082015160609092015190945090925090508180614a0a5750805b93506000614a16614111565b905086614ab757600080614a286131b4565b6001600160a01b0316632992dba26040518163ffffffff1660e01b8152600401604080518083038186803b158015614a5f57600080fd5b505afa158015614a73573d6000803e3d6000fd5b505050506040513d6040811015614a8957600080fd5b5080516020909101519092509050614aa7868363ffffffff61585b16565b95508680614ab25750805b965050505b631cd554d160e21b881415614ad25750919350614b74915050565b600080826001600160a01b0316630c71cd238b6040518263ffffffff1660e01b815260040180828152602001915050604080518083038186803b158015614b1857600080fd5b505afa158015614b2c573d6000803e3d6000fd5b505050506040513d6040811015614b4257600080fd5b5080516020909101519092509050614b60868363ffffffff6146c616565b8780614b695750815b975097505050505050505b9250929050565b614b836155ee565b604080516d1b185cdd125cdcdd59515d995b9d60921b6020808301919091526bffffffffffffffffffffffff19606086901b1682840152825160348184030181526054830180855281519190920120631d5b277f60e01b9091526524b9b9bab2b960d11b6058830152607882015242609882015290516001600160a01b039290921691631d5b277f9160b88082019260009290919082900301818387803b158015611f6e57600080fd5b6000670de0b6b3a7640000614c48848463ffffffff615afc16565b81614c4f57fe5b049392505050565b6000600160ff1b8210614c9b5760405162461bcd60e51b8152600401808060200182810382526028815260200180615d286028913960400191505060405180910390fd5b5090565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110614ce157fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015614d20578160200160208202803883390190505b50905060005b8351811015614d6257838181518110614d3b57fe5b6020026020010151828281518110614d4f57fe5b6020908102919091010152600101614d26565b5060005b825181101561273957828181518110614d7b57fe5b6020026020010151828286510181518110614d9257fe5b6020908102919091010152600101614d66565b6000806000614db384614e4f565b9050600080614e18614dc3613eb9565b6001600160a01b03166370a08231886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561184a57600080fd5b92505091508260001415614e345760009450925061275c915050565b614e44828463ffffffff6146c616565b945092505050915091565b60006114aa614e5c615aab565b6001600160a01b0316628cc262846040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015614eb057600080fd5b505afa158015614ec4573d6000803e3d6000fd5b505050506040513d6020811015614eda57600080fd5b5051615065614ee7615b55565b6001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015614f3c57600080fd5b505afa158015614f50573d6000803e3d6000fd5b505050506040513d6020811015614f6657600080fd5b5051615065614f73615b71565b6001600160a01b03166370a08231886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015614fc857600080fd5b505afa158015614fdc573d6000803e3d6000fd5b505050506040513d6020811015614ff257600080fd5b5051614ffc612ef8565b6001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561505157600080fd5b505afa1580156144d9573d6000803e3d6000fd5b9063ffffffff61585b16565b600061508761507e613a66565b615065846150fd565b42101592915050565b61509861558f565b6001600160a01b0316336001600160a01b0316146131b2576040805162461bcd60e51b815260206004820152601a60248201527f4973737565723a204f6e6c792053796e746852656465656d6572000000000000604482015290519081900360640190fd5b60006151076155ee565b6001600160a01b03166323257c2b6524b9b9bab2b960d11b6d1b185cdd125cdcdd59515d995b9d60921b8560405160200180838152602001826001600160a01b03166001600160a01b031660601b815260140192505050604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b1580156151af57600080fd5b505afa1580156151c3573d6000803e3d6000fd5b505050506040513d60208110156151d957600080fd5b505192915050565b600080615207766578743a41676772656761746f7244656274526174696f60481b613807565b90506000816001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561524457600080fd5b505afa158015615258573d6000803e3d6000fd5b505050506040513d60a081101561526e57600080fd5b50602001519050600061527f614111565b6001600160a01b031663045056f8620a69cb60eb1b6040518263ffffffff1660e01b815260040180828152602001915050606060405180830381600087803b1580156152ca57600080fd5b505af11580156152de573d6000803e3d6000fd5b505050506040513d60608110156152f457600080fd5b50602001519050615303615b8e565b6001600160a01b031663413caeb584846040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561536257600080fd5b505af1158015615376573d6000803e3d6000fd5b505050506040513d602081101561538c57600080fd5b5051806153965750805b935050505090565b801561163e576040805162461bcd60e51b815260206004820152601e60248201527f412073796e7468206f7220534e58207261746520697320696e76616c69640000604482015290519081900360640190fd5b6153f9615aab565b6001600160a01b031663270fb338836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b15801561545057600080fd5b505af1158015615464573d6000803e3d6000fd5b505050506000615472613eb9565b9050600061547f83615aca565b90508061550357816001600160a01b031663c2f04b0a85856040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156154e657600080fd5b505af11580156154fa573d6000803e3d6000fd5b50505050615577565b816001600160a01b031663c2f04b0a85836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561556357600080fd5b505af1158015613eaf573d6000803e3d6000fd5b50505050565b600061399f838363ffffffff615baa16565b60006111206c29bcb73a342932b232b2b6b2b960991b613807565b6000806155d0846155c487600a870263ffffffff615afc16565b9063ffffffff615bbf16565b90506005600a825b06106155e257600a015b600a9004949350505050565b60006111206e466c657869626c6553746f7261676560881b613807565b60006111207044656c6567617465417070726f76616c7360781b613807565b60006156346151e1565b1561564157506000615756565b82821061564e5782615650565b815b905061565d858284614750565b631cd554d160e21b60009081526005602052600080516020615d508339815191525460408051632770a7eb60e21b81526001600160a01b0388811660048301526024820186905291519190921692639dc29fac926044808201939182900301818387803b1580156156cd57600080fd5b505af11580156156e1573d6000803e3d6000fd5b505050506156ed6131b4565b6001600160a01b03166342c7b81961570483614c57565b6000036040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561573d57600080fd5b505af1158015615751573d6000803e3d6000fd5b505050505b949350505050565b60006157686155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b74736e784c69717569646174696f6e50656e616c747960581b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b60006157e66155ee565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7573656c664c69717569646174696f6e50656e616c747960501b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015613a1e57600080fd5b60008282018381101561399f576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600061399f838363ffffffff6146c616565b60008060006158d4612ef8565b6001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561592957600080fd5b505afa15801561593d573d6000803e3d6000fd5b505050506040513d602081101561595357600080fd5b5051905080851161596b575083915060009050615a67565b831561597c57915060009050615a67565b6000615986615b55565b6001600160a01b03166370a08231886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156159db57600080fd5b505afa1580156159ef573d6000803e3d6000fd5b505050506040513d6020811015615a0557600080fd5b50519050615a19828263ffffffff61585b16565b861115615a3b57615a30828263ffffffff61585b16565b93509150615a679050565b615a4b868363ffffffff6146db16565b9250615a5d828463ffffffff61585b16565b9350615a67915050565b935093915050565b600061399f826155c485670de0b6b3a764000063ffffffff615afc16565b600080615a986138e4565b50905061399f838263ffffffff615c2916565b6000611120704c697175696461746f725265776172647360781b613807565b600080615ad56138e4565b5090508015615af357615aee838263ffffffff61398616565b61399f565b50600092915050565b600082615b0b575060006114aa565b82820282848281615b1857fe5b041461399f5760405162461bcd60e51b8152600401808060200182810382526021815260200180615d076021913960400191505060405180910390fd5b60006111206d2932bbb0b93222b9b1b937bbab1960911b613807565b60006111206e53796e746865746978457363726f7760881b613807565b60006111206d21b4b931bab4ba213932b0b5b2b960911b613807565b600061399f8383670de0b6b3a7640000615c3e565b6000808211615c15576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481615c2057fe5b04949350505050565b600061399f83836b033b2e3c9fd0803ce80000005b600080600a8304615c55868663ffffffff615afc16565b81615c5c57fe5b0490506005600a826155d8565b8154818355818111156115215760008381526020902061152191810190830161112391905b80821115614c9b5760008155600101615c8e56fe596f75206d757374206265206e6f6d696e61746564206265666f726520796f752063616e20616363657074206f776e6572736869704f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7753616665436173743a2076616c756520646f65736e27742066697420696e20616e20696e7432353674c62d09fbc50aefae0794a9a068f786a692826fbdfe63828ec23a875865823f4973737565723a204f6e6c792053796e74686574697800000000000000000000a265627a7a72315820948feade1e9d3c49a8f5cc527c49505fcbfb481db0fd8f56536c54fa22a0f3f864736f6c63430005100032

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

00000000000000000000000073570075092502472e4b61a7058df1a4a1db12f20000000000000000000000009fc84992df5496797784374b810e04238728743d

-----Decoded View---------------
Arg [0] : _owner (address): 0x73570075092502472E4b61A7058Df1A4a1DB12f2
Arg [1] : _resolver (address): 0x9Fc84992dF5496797784374B810E04238728743d

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000073570075092502472e4b61a7058df1a4a1db12f2
Arg [1] : 0000000000000000000000009fc84992df5496797784374b810e04238728743d


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading