Contract 0x412c870daAb642aA87715e2EA860d20E48E73267 1

Contract Overview

Balance:
0 Ether
Txn Hash
Method
Block
From
To
Value
0x1706f4fba878e496bd6bf9b6d452243781d40da29e397f090f64c42d525039d9Add Aggregator321741942022-06-14 16:10:4420 days 9 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00009242 2.5
0x52061806578f7489c1c94551b480e9582541a6fed3a20e0fbf532ed94de83b29Add Aggregator315275412022-05-10 12:57:4455 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011638 1
0x4e76821574fa7c4c553c51d2402b0c603a29f971d8966a09fe0b7426ad747437Add Aggregator315275392022-05-10 12:57:3655 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011638 1
0xd065ed7f0bf66c39565f6cce0e32c230485c43a746e784b24783022c434014b5Add Aggregator315275372022-05-10 12:57:2855 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0x5cbdc980944ca2ae0d9a4f91a6269a124e99cc34b1a9e2fbf8e4128c92d29ab2Add Aggregator315275342022-05-10 12:57:1255 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0x6521d8beff9a55a395e3b624c874b12db53b847fe48752220663a5ffb23544a9Add Aggregator315275322022-05-10 12:57:0455 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0x8e0171de8e391e20d8e7b0b2b4cd5fd143b202aa0c008fc51024ec286f496cb2Add Aggregator315275312022-05-10 12:56:5655 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0xfaf778b8f7dd32e32a72bc9a45febdc7c00b80420f0e86f88efda47a62328a0cAdd Aggregator315275302022-05-10 12:56:4855 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0xbd909e5266b72b1fb474b203ca65407c20a350de248cea7589eac521282004f7Add Aggregator315275282022-05-10 12:56:3655 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0x62c5239a85c31a226eae5bf049dcd26f64ebc929031b4f1f466fa922060d1cb4Add Aggregator315275262022-05-10 12:56:2855 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0xed4618f7c3dff0d4a097d63608eb68c29a821b30f9479ec0aeda669d1097c56cAdd Aggregator315275242022-05-10 12:56:2055 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0x6292fd655cc5d9d1cecabb82b063a0f6f63cb219eb3e3ebcacca112cf45656b6Add Aggregator315275202022-05-10 12:56:0455 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011636 1
0x8133ea8ab7c65b6520b73bd6d3ebf417fd28ac9f53f1d1f5e4c4c45d7726aa81Add Aggregator315275182022-05-10 12:55:5655 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011636 1
0xbe0dc02149084000b3c98c11c99bdc9643fc0b3f9bfbddfb96369d2ff7fb33dfAdd Aggregator315275152022-05-10 12:55:4455 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011636 1
0xfb08a79381ca9c7005d54b4c0f705717e87dd04961416fb072ce2f0f81460c60Add Aggregator315275142022-05-10 12:55:3655 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011636 1
0x04f5b5499871655410a9c6a3ac4f4faec3998326639513d3e0fdb28edda614b9Add Aggregator315275132022-05-10 12:55:2855 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011636 1
0xe2c6b72a8bd4f9aad2b3170a6b4ac68b3b867ddc3f16641b4fcd56c3ab416b73Add Aggregator315275092022-05-10 12:55:1255 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011636 1
0x6e0f5a2b0223c4f9ee1bd9903be914969cf5238ec5a814f138379c4b959855a4Add Aggregator315275052022-05-10 12:54:5655 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0x0e7e9efc598b24347354f37dcdfbda234bbf23578ed308837b7570db92779f80Add Aggregator315275032022-05-10 12:54:4855 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011637 1
0x85d84623093b0ea77cc1610632bcdccafb7e35283a9a2008a005c6728e3864b1Add Aggregator315275022022-05-10 12:54:4055 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011636 1
0xbec30f5931842df8e06a82d34de4f7cfc0d942ebca080b57023d577540f5f732Add Aggregator315275012022-05-10 12:54:3255 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00011636 1
0xe8d8ac57300e913abcb90c37aab31d2dd8ef3402de2dffa05f6e70cbcbe418b0Add Aggregator315274992022-05-10 12:54:2455 days 12 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x412c870daab642aa87715e2ea860d20e48e732670 Ether0.00013346 1
0x162e0a6e6b027e8b6f1e5691d1f60628ef7f1b7227732b3c69844e96050d22a90x60806040315271162022-05-10 12:25:2455 days 13 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  Create: ExchangeRatesWithDexPricing0 Ether0.00315368 1
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x1a60e2e2a8be0bc2b6381dd31fd3fd5f9a28de4c0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x9326bfa02add2366b30bacb125260af6410313310 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x44af736495544a726ed15cb0ebe2d87a6bcc1832 0x412c870daab642aa87715e2ea860d20e48e732670 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x6292aa9a6650ae14fbf974e5029f36f95a1848fd0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0xb1751e5ede811288ce2fc4c65aaca17a955366be0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0xb1751e5ede811288ce2fc4c65aaca17a955366be0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x9326bfa02add2366b30bacb125260af6410313310 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x53bae964339e8a742b5b47f6c10bbfa8ff138f34 0x412c870daab642aa87715e2ea860d20e48e732670 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x6292aa9a6650ae14fbf974e5029f36f95a1848fd0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0xb1751e5ede811288ce2fc4c65aaca17a955366be0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0xb1751e5ede811288ce2fc4c65aaca17a955366be0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x6135b13325bfc4b00278b4abc5e20bbce2d6580e0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x53bae964339e8a742b5b47f6c10bbfa8ff138f34 0x412c870daab642aa87715e2ea860d20e48e732670 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x6292aa9a6650ae14fbf974e5029f36f95a1848fd0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0xb1751e5ede811288ce2fc4c65aaca17a955366be0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0xb1751e5ede811288ce2fc4c65aaca17a955366be0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x9326bfa02add2366b30bacb125260af6410313310 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x53bae964339e8a742b5b47f6c10bbfa8ff138f34 0x412c870daab642aa87715e2ea860d20e48e732670 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x6292aa9a6650ae14fbf974e5029f36f95a1848fd0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0xb1751e5ede811288ce2fc4c65aaca17a955366be0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0xb1751e5ede811288ce2fc4c65aaca17a955366be0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x6135b13325bfc4b00278b4abc5e20bbce2d6580e0 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x53bae964339e8a742b5b47f6c10bbfa8ff138f34 0x412c870daab642aa87715e2ea860d20e48e732670 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x396c5e36dd0a0f5a5d33dae44368d4193f69a1f00 Ether
0x5efd612407465a94f0643faf2314a850fb55b4876023e510cd24dcfadfe146a6325458722022-07-04 18:28:246 hrs 58 mins ago 0x412c870daab642aa87715e2ea860d20e48e73267 0x9326bfa02add2366b30bacb125260af6410313310 Ether
[ 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:
ExchangeRatesWithDexPricing

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2022-05-10
*/

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

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



pragma solidity ^0.5.16;

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

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

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

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

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

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

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


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

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

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


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

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

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

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

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

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


// https://docs.synthetix.io/contracts/source/interfaces/iissuer
interface IIssuer {
    // Views
    function 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);

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

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

    function issueMaxSynths(address from) external;

    function issueMaxSynthsOnBehalf(address issueFor, address from) external;

    function burnSynths(address from, uint amount) external;

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

    function burnSynthsToTarget(address from) external;

    function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external;

    function burnForRedemption(
        address deprecatedSynthProxy,
        address account,
        uint balance
    ) external;

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

    function setCurrentPeriodId(uint128 periodId) external;

    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_PENALTY = "liquidationPenalty";
    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 getLiquidationPenalty() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_PENALTY);
    }

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


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


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


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


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

}


interface FlagsInterface {
  function getFlag(address) external view returns (bool);
  function getFlags(address[] calldata) external view returns (bool[] memory);
  function raiseFlag(address) external;
  function raiseFlags(address[] calldata) external;
  function lowerFlags(address[] calldata) external;
  function setRaisingAccessController(address) external;
}


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

    function exchangeRates() external view returns (address);

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

    function priceDeviationThresholdFactor() external view returns (uint);

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

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

    // Mutative functions
    function resetLastExchangeRate(bytes32[] calldata currencyKeys) external;

    function rateWithBreakCircuit(bytes32 currencyKey) external returns (uint lastValidRate, bool circuitBroken);
}


// Inheritance


// Libraries


// Internal references
// AggregatorInterface from Chainlink represents a decentralized pricing network for a single currency key

// FlagsInterface from Chainlink addresses SIP-76


// https://docs.synthetix.io/contracts/source/contracts/exchangerates
contract ExchangeRates is Owned, MixinSystemSettings, IExchangeRates {
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    bytes32 public constant CONTRACT_NAME = "ExchangeRates";
    //slither-disable-next-line naming-convention
    bytes32 internal constant sUSD = "sUSD";

    // Decentralized oracle networks that feed into pricing aggregators
    mapping(bytes32 => AggregatorV2V3Interface) public aggregators;

    mapping(bytes32 => uint8) public currencyKeyDecimals;

    // List of aggregator keys for convenient iteration
    bytes32[] public aggregatorKeys;

    // ========== CONSTRUCTOR ==========

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

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

    function addAggregator(bytes32 currencyKey, address aggregatorAddress) external onlyOwner {
        AggregatorV2V3Interface aggregator = AggregatorV2V3Interface(aggregatorAddress);
        // This check tries to make sure that a valid aggregator is being added.
        // It checks if the aggregator is an existing smart contract that has implemented `latestTimestamp` function.

        require(aggregator.latestRound() >= 0, "Given Aggregator is invalid");
        uint8 decimals = aggregator.decimals();
        require(decimals <= 18, "Aggregator decimals should be lower or equal to 18");
        if (address(aggregators[currencyKey]) == address(0)) {
            aggregatorKeys.push(currencyKey);
        }
        aggregators[currencyKey] = aggregator;
        currencyKeyDecimals[currencyKey] = decimals;
        emit AggregatorAdded(currencyKey, address(aggregator));
    }

    function removeAggregator(bytes32 currencyKey) external onlyOwner {
        address aggregator = address(aggregators[currencyKey]);
        require(aggregator != address(0), "No aggregator exists for key");
        delete aggregators[currencyKey];
        delete currencyKeyDecimals[currencyKey];

        bool wasRemoved = removeFromArray(currencyKey, aggregatorKeys);

        if (wasRemoved) {
            emit AggregatorRemoved(currencyKey, aggregator);
        }
    }

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

    function currenciesUsingAggregator(address aggregator) external view returns (bytes32[] memory currencies) {
        uint count = 0;
        currencies = new bytes32[](aggregatorKeys.length);
        for (uint i = 0; i < aggregatorKeys.length; i++) {
            bytes32 currencyKey = aggregatorKeys[i];
            if (address(aggregators[currencyKey]) == aggregator) {
                currencies[count++] = currencyKey;
            }
        }
    }

    function rateStalePeriod() external view returns (uint) {
        return getRateStalePeriod();
    }

    function aggregatorWarningFlags() external view returns (address) {
        return getAggregatorWarningFlags();
    }

    function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time) {
        RateAndUpdatedTime memory rateAndTime = _getRateAndUpdatedTime(currencyKey);
        return (rateAndTime.rate, rateAndTime.time);
    }

    function getLastRoundIdBeforeElapsedSecs(
        bytes32 currencyKey,
        uint startingRoundId,
        uint startingTimestamp,
        uint timediff
    ) external view returns (uint) {
        uint roundId = startingRoundId;
        uint nextTimestamp = 0;
        while (true) {
            (, nextTimestamp) = _getRateAndTimestampAtRound(currencyKey, roundId + 1);
            // if there's no new round, then the previous roundId was the latest
            if (nextTimestamp == 0 || nextTimestamp > startingTimestamp + timediff) {
                return roundId;
            }
            roundId++;
        }
        return roundId;
    }

    function getCurrentRoundId(bytes32 currencyKey) external view returns (uint) {
        return _getCurrentRoundId(currencyKey);
    }

    function effectiveValueAndRatesAtRound(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        uint roundIdForSrc,
        uint roundIdForDest
    )
        external
        view
        returns (
            uint value,
            uint sourceRate,
            uint destinationRate
        )
    {
        (sourceRate, ) = _getRateAndTimestampAtRound(sourceCurrencyKey, roundIdForSrc);
        // If there's no change in the currency, then just return the amount they gave us
        if (sourceCurrencyKey == destinationCurrencyKey) {
            destinationRate = sourceRate;
            value = sourceAmount;
        } else {
            (destinationRate, ) = _getRateAndTimestampAtRound(destinationCurrencyKey, roundIdForDest);
            // prevent divide-by 0 error (this happens if the dest is not a valid rate)
            if (destinationRate > 0) {
                // Calculate the effective value by going from source -> USD -> destination
                value = sourceAmount.multiplyDecimalRound(sourceRate).divideDecimalRound(destinationRate);
            }
        }
    }

    function rateAndTimestampAtRound(bytes32 currencyKey, uint roundId) external view returns (uint rate, uint time) {
        return _getRateAndTimestampAtRound(currencyKey, roundId);
    }

    function lastRateUpdateTimes(bytes32 currencyKey) external view returns (uint256) {
        return _getUpdatedTime(currencyKey);
    }

    function lastRateUpdateTimesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory) {
        uint[] memory lastUpdateTimes = new uint[](currencyKeys.length);

        for (uint i = 0; i < currencyKeys.length; i++) {
            lastUpdateTimes[i] = _getUpdatedTime(currencyKeys[i]);
        }

        return lastUpdateTimes;
    }

    function effectiveValue(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external view returns (uint value) {
        (value, , ) = _effectiveValueAndRates(sourceCurrencyKey, sourceAmount, destinationCurrencyKey);
    }

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

    // SIP-120 Atomic exchanges
    function effectiveAtomicValueAndRates(
        bytes32,
        uint,
        bytes32
    )
        external
        view
        returns (
            uint,
            uint,
            uint,
            uint
        )
    {
        _notImplemented();
    }

    function rateForCurrency(bytes32 currencyKey) external view returns (uint) {
        return _getRateAndUpdatedTime(currencyKey).rate;
    }

    /// @notice getting N rounds of rates for a currency at a specific round
    /// @param currencyKey the currency key
    /// @param numRounds the number of rounds to get
    /// @param roundId the round id
    /// @return a list of rates and a list of times
    function ratesAndUpdatedTimeForCurrencyLastNRounds(
        bytes32 currencyKey,
        uint numRounds,
        uint roundId
    ) external view returns (uint[] memory rates, uint[] memory times) {
        rates = new uint[](numRounds);
        times = new uint[](numRounds);

        roundId = roundId > 0 ? roundId : _getCurrentRoundId(currencyKey);
        for (uint i = 0; i < numRounds; i++) {
            // fetch the rate and treat is as current, so inverse limits if frozen will always be applied
            // regardless of current rate
            (rates[i], times[i]) = _getRateAndTimestampAtRound(currencyKey, roundId);

            if (roundId == 0) {
                // if we hit the last round, then return what we have
                return (rates, times);
            } else {
                roundId--;
            }
        }
    }

    function ratesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory) {
        uint[] memory _localRates = new uint[](currencyKeys.length);

        for (uint i = 0; i < currencyKeys.length; i++) {
            _localRates[i] = _getRate(currencyKeys[i]);
        }

        return _localRates;
    }

    function rateAndInvalid(bytes32 currencyKey) external view returns (uint rate, bool isInvalid) {
        RateAndUpdatedTime memory rateAndTime = _getRateAndUpdatedTime(currencyKey);

        if (currencyKey == sUSD) {
            return (rateAndTime.rate, false);
        }
        return (
            rateAndTime.rate,
            _rateIsStaleWithTime(getRateStalePeriod(), rateAndTime.time) ||
                _rateIsFlagged(currencyKey, FlagsInterface(getAggregatorWarningFlags()))
        );
    }

    function ratesAndInvalidForCurrencies(bytes32[] calldata currencyKeys)
        external
        view
        returns (uint[] memory rates, bool anyRateInvalid)
    {
        rates = new uint[](currencyKeys.length);

        uint256 _rateStalePeriod = getRateStalePeriod();

        // fetch all flags at once
        bool[] memory flagList = getFlagsForRates(currencyKeys);

        for (uint i = 0; i < currencyKeys.length; i++) {
            // do one lookup of the rate & time to minimize gas
            RateAndUpdatedTime memory rateEntry = _getRateAndUpdatedTime(currencyKeys[i]);
            rates[i] = rateEntry.rate;
            if (!anyRateInvalid && currencyKeys[i] != sUSD) {
                anyRateInvalid = flagList[i] || _rateIsStaleWithTime(_rateStalePeriod, rateEntry.time);
            }
        }
    }

    function rateIsStale(bytes32 currencyKey) external view returns (bool) {
        return _rateIsStale(currencyKey, getRateStalePeriod());
    }

    function rateIsInvalid(bytes32 currencyKey) external view returns (bool) {
        return
            _rateIsStale(currencyKey, getRateStalePeriod()) ||
            _rateIsFlagged(currencyKey, FlagsInterface(getAggregatorWarningFlags()));
    }

    function rateIsFlagged(bytes32 currencyKey) external view returns (bool) {
        return _rateIsFlagged(currencyKey, FlagsInterface(getAggregatorWarningFlags()));
    }

    function anyRateIsInvalid(bytes32[] calldata currencyKeys) external view returns (bool) {
        // Loop through each key and check whether the data point is stale.

        uint256 _rateStalePeriod = getRateStalePeriod();
        bool[] memory flagList = getFlagsForRates(currencyKeys);

        for (uint i = 0; i < currencyKeys.length; i++) {
            if (flagList[i] || _rateIsStale(currencyKeys[i], _rateStalePeriod)) {
                return true;
            }
        }

        return false;
    }

    /// this method checks whether any rate is:
    /// 1. flagged
    /// 2. stale with respect to current time (now)
    function anyRateIsInvalidAtRound(bytes32[] calldata currencyKeys, uint[] calldata roundIds)
        external
        view
        returns (bool)
    {
        // Loop through each key and check whether the data point is stale.

        require(roundIds.length == currencyKeys.length, "roundIds must be the same length as currencyKeys");

        uint256 _rateStalePeriod = getRateStalePeriod();
        bool[] memory flagList = getFlagsForRates(currencyKeys);

        for (uint i = 0; i < currencyKeys.length; i++) {
            if (flagList[i] || _rateIsStaleAtRound(currencyKeys[i], roundIds[i], _rateStalePeriod)) {
                return true;
            }
        }

        return false;
    }

    function synthTooVolatileForAtomicExchange(bytes32) external view returns (bool) {
        _notImplemented();
    }

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

    function getFlagsForRates(bytes32[] memory currencyKeys) internal view returns (bool[] memory flagList) {
        FlagsInterface _flags = FlagsInterface(getAggregatorWarningFlags());

        // fetch all flags at once
        if (_flags != FlagsInterface(0)) {
            address[] memory _aggregators = new address[](currencyKeys.length);

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

            flagList = _flags.getFlags(_aggregators);
        } else {
            flagList = new bool[](currencyKeys.length);
        }
    }

    function removeFromArray(bytes32 entry, bytes32[] storage array) internal returns (bool) {
        for (uint i = 0; i < array.length; i++) {
            if (array[i] == entry) {
                delete array[i];

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

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

                return true;
            }
        }
        return false;
    }

    function _formatAggregatorAnswer(bytes32 currencyKey, int256 rate) internal view returns (uint) {
        require(rate >= 0, "Negative rate not supported");
        if (currencyKeyDecimals[currencyKey] > 0) {
            uint multiplier = 10**uint(SafeMath.sub(18, currencyKeyDecimals[currencyKey]));
            return uint(uint(rate).mul(multiplier));
        }
        return uint(rate);
    }

    function _getRateAndUpdatedTime(bytes32 currencyKey) internal view returns (RateAndUpdatedTime memory) {
        // sUSD rate is 1.0
        if (currencyKey == sUSD) {
            return RateAndUpdatedTime({rate: uint216(SafeDecimalMath.unit()), time: 0});
        } else {
            AggregatorV2V3Interface aggregator = aggregators[currencyKey];
            if (aggregator != AggregatorV2V3Interface(0)) {
                // this view from the aggregator is the most gas efficient but it can throw when there's no data,
                // so let's call it low-level to suppress any reverts
                bytes memory payload = abi.encodeWithSignature("latestRoundData()");
                // solhint-disable avoid-low-level-calls
                // slither-disable-next-line low-level-calls
                (bool success, bytes memory returnData) = address(aggregator).staticcall(payload);

                if (success) {
                    (, int256 answer, , uint256 updatedAt, ) =
                        abi.decode(returnData, (uint80, int256, uint256, uint256, uint80));
                    return
                        RateAndUpdatedTime({
                            rate: uint216(_formatAggregatorAnswer(currencyKey, answer)),
                            time: uint40(updatedAt)
                        });
                } // else return defaults, to avoid reverting in views
            } // else return defaults, to avoid reverting in views
        }
    }

    function _getCurrentRoundId(bytes32 currencyKey) internal view returns (uint) {
        if (currencyKey == sUSD) {
            return 0;
        }
        AggregatorV2V3Interface aggregator = aggregators[currencyKey];
        if (aggregator != AggregatorV2V3Interface(0)) {
            return aggregator.latestRound();
        } // else return defaults, to avoid reverting in views
    }

    function _getRateAndTimestampAtRound(bytes32 currencyKey, uint roundId) internal view returns (uint rate, uint time) {
        // short circuit sUSD
        if (currencyKey == sUSD) {
            // sUSD has no rounds, and 0 time is preferrable for "volatility" heuristics
            // which are used in atomic swaps and fee reclamation
            return (SafeDecimalMath.unit(), 0);
        } else {
            AggregatorV2V3Interface aggregator = aggregators[currencyKey];
            if (aggregator != AggregatorV2V3Interface(0)) {
                // this view from the aggregator is the most gas efficient but it can throw when there's no data,
                // so let's call it low-level to suppress any reverts
                bytes memory payload = abi.encodeWithSignature("getRoundData(uint80)", roundId);
                // solhint-disable avoid-low-level-calls
                (bool success, bytes memory returnData) = address(aggregator).staticcall(payload);

                if (success) {
                    (, int256 answer, , uint256 updatedAt, ) =
                        abi.decode(returnData, (uint80, int256, uint256, uint256, uint80));
                    return (_formatAggregatorAnswer(currencyKey, answer), updatedAt);
                } // else return defaults, to avoid reverting in views
            } // else return defaults, to avoid reverting in views
        }
    }

    function _getRate(bytes32 currencyKey) internal view returns (uint256) {
        return _getRateAndUpdatedTime(currencyKey).rate;
    }

    function _getUpdatedTime(bytes32 currencyKey) internal view returns (uint256) {
        return _getRateAndUpdatedTime(currencyKey).time;
    }

    function _effectiveValueAndRates(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    )
        internal
        view
        returns (
            uint value,
            uint sourceRate,
            uint destinationRate
        )
    {
        sourceRate = _getRate(sourceCurrencyKey);
        // If there's no change in the currency, then just return the amount they gave us
        if (sourceCurrencyKey == destinationCurrencyKey) {
            destinationRate = sourceRate;
            value = sourceAmount;
        } else {
            // Calculate the effective value by going from source -> USD -> destination
            destinationRate = _getRate(destinationCurrencyKey);
            // prevent divide-by 0 error (this happens if the dest is not a valid rate)
            if (destinationRate > 0) {
                value = sourceAmount.multiplyDecimalRound(sourceRate).divideDecimalRound(destinationRate);
            }
        }
    }

    function _rateIsStale(bytes32 currencyKey, uint _rateStalePeriod) internal view returns (bool) {
        // sUSD is a special case and is never stale (check before an SLOAD of getRateAndUpdatedTime)
        if (currencyKey == sUSD) {
            return false;
        }
        return _rateIsStaleWithTime(_rateStalePeriod, _getUpdatedTime(currencyKey));
    }

    function _rateIsStaleAtRound(
        bytes32 currencyKey,
        uint roundId,
        uint _rateStalePeriod
    ) internal view returns (bool) {
        // sUSD is a special case and is never stale (check before an SLOAD of getRateAndUpdatedTime)
        if (currencyKey == sUSD) {
            return false;
        }
        (, uint time) = _getRateAndTimestampAtRound(currencyKey, roundId);
        return _rateIsStaleWithTime(_rateStalePeriod, time);
    }

    function _rateIsStaleWithTime(uint _rateStalePeriod, uint _time) internal view returns (bool) {
        return _time.add(_rateStalePeriod) < now;
    }

    function _rateIsFlagged(bytes32 currencyKey, FlagsInterface flags) internal view returns (bool) {
        // sUSD is a special case and is never invalid
        if (currencyKey == sUSD) {
            return false;
        }
        address aggregator = address(aggregators[currencyKey]);
        // when no aggregator or when the flags haven't been setup
        if (aggregator == address(0) || flags == FlagsInterface(0)) {
            return false;
        }
        return flags.getFlag(aggregator);
    }

    function _notImplemented() internal pure {
        // slither-disable-next-line dead-code
        revert("Cannot be run on this layer");
    }

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

    event AggregatorAdded(bytes32 currencyKey, address aggregator);
    event AggregatorRemoved(bytes32 currencyKey, address aggregator);
}


// https://sips.synthetix.io/sips/sip-120/
// Uniswap V3 based DecPriceAggregator (unaudited) e.g. https://etherscan.io/address/0xf120f029ac143633d1942e48ae2dfa2036c5786c#code
// https://github.com/sohkai/uniswap-v3-spot-twap-oracle
//  inteface: https://github.com/sohkai/uniswap-v3-spot-twap-oracle/blob/8f9777a6160a089c99f39f2ee297119ee293bc4b/contracts/interfaces/IDexPriceAggregator.sol
//  implementation: https://github.com/sohkai/uniswap-v3-spot-twap-oracle/blob/8f9777a6160a089c99f39f2ee297119ee293bc4b/contracts/DexPriceAggregatorUniswapV3.sol
interface IDexPriceAggregator {
    function assetToAsset(
        address tokenIn,
        uint amountIn,
        address tokenOut,
        uint twapPeriod
    ) external view returns (uint amountOut);
}


// Inheritance


// https://docs.synthetix.io/contracts/source/contracts/exchangerateswithdexpricing
contract ExchangeRatesWithDexPricing is ExchangeRates {
    bytes32 public constant CONTRACT_NAME = "ExchangeRatesWithDexPricing";

    bytes32 internal constant SETTING_DEX_PRICE_AGGREGATOR = "dexPriceAggregator";

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

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

    function setDexPriceAggregator(IDexPriceAggregator _dexPriceAggregator) external onlyOwner {
        flexibleStorage().setAddressValue(
            ExchangeRates.CONTRACT_NAME,
            SETTING_DEX_PRICE_AGGREGATOR,
            address(_dexPriceAggregator)
        );
        emit DexPriceAggregatorUpdated(address(_dexPriceAggregator));
    }

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

    function dexPriceAggregator() public view returns (IDexPriceAggregator) {
        return
            IDexPriceAggregator(
                flexibleStorage().getAddressValue(ExchangeRates.CONTRACT_NAME, SETTING_DEX_PRICE_AGGREGATOR)
            );
    }

    function atomicTwapWindow() external view returns (uint) {
        return getAtomicTwapWindow();
    }

    function atomicEquivalentForDexPricing(bytes32 currencyKey) external view returns (address) {
        return getAtomicEquivalentForDexPricing(currencyKey);
    }

    function atomicVolatilityConsiderationWindow(bytes32 currencyKey) external view returns (uint) {
        return getAtomicVolatilityConsiderationWindow(currencyKey);
    }

    function atomicVolatilityUpdateThreshold(bytes32 currencyKey) external view returns (uint) {
        return getAtomicVolatilityUpdateThreshold(currencyKey);
    }

    // SIP-120 Atomic exchanges
    // Note that the returned systemValue, systemSourceRate, and systemDestinationRate are based on
    // the current system rate, which may not be the atomic rate derived from value / sourceAmount
    function effectiveAtomicValueAndRates(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    )
        external
        view
        returns (
            uint value,
            uint systemValue,
            uint systemSourceRate,
            uint systemDestinationRate
        )
    {
        (systemValue, systemSourceRate, systemDestinationRate) = _effectiveValueAndRates(
            sourceCurrencyKey,
            sourceAmount,
            destinationCurrencyKey
        );

        bool usePureChainlinkPriceForSource = getPureChainlinkPriceForAtomicSwapsEnabled(sourceCurrencyKey);
        bool usePureChainlinkPriceForDest = getPureChainlinkPriceForAtomicSwapsEnabled(destinationCurrencyKey);
        uint sourceRate;
        uint destRate;

        // Handle the different scenarios that may arise when trading currencies with or without the PureChainlinkPrice set.
        // outlined here: https://sips.synthetix.io/sips/sip-198/#computation-methodology-in-atomic-pricing
        if (usePureChainlinkPriceForSource && usePureChainlinkPriceForDest) {
            // SRC and DEST are both set to trade at the PureChainlinkPrice
            sourceRate = systemSourceRate;
            destRate = systemDestinationRate;
        } else if (!usePureChainlinkPriceForSource && usePureChainlinkPriceForDest) {
            // SRC is NOT set to PureChainlinkPrice and DEST is set to PureChainlinkPrice
            sourceRate = _getMinValue(systemSourceRate, _getPriceFromDexAggregator(sourceCurrencyKey, sourceAmount));
            destRate = systemDestinationRate;
        } else if (usePureChainlinkPriceForSource && !usePureChainlinkPriceForDest) {
            // SRC is set to PureChainlinkPrice and DEST is NOT set to PureChainlinkPrice
            sourceRate = systemSourceRate;
            destRate = _getMaxValue(systemDestinationRate, _getPriceFromDexAggregator(destinationCurrencyKey, sourceAmount));
        } else {
            // Otherwise, neither SRC nor DEST is set to PureChainlinkPrice.
            sourceRate = _getMinValue(systemSourceRate, _getPriceFromDexAggregator(sourceCurrencyKey, sourceAmount));
            destRate = _getMaxValue(systemDestinationRate, _getPriceFromDexAggregator(destinationCurrencyKey, sourceAmount));
        }
        value = sourceAmount.mul(sourceRate).div(destRate);
    }

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

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

    /// @notice Retrieve the TWAP (time-weighted average price) of an asset from its Uniswap V3-equivalent pool
    /// @dev By default, the TWAP oracle 'hops' through the wETH pool. This can be overridden. See DexPriceAggregator for more information.
    /// @dev The TWAP oracle doesn't take into account variable slippage due to trade amounts, as Uniswap's OracleLibary doesn't cross ticks based on their liquidity. See: https://docs.uniswap.org/protocol/concepts/V3-overview/oracle#deriving-price-from-a-tick
    /// @param currencyKey The currency key of the synth we're retrieving the price for
    /// @param amount The amount of the asset we're interested in
    /// @return The price of the asset
    function _getPriceFromDexAggregator(bytes32 currencyKey, uint amount) internal view returns (uint) {
        require(amount != 0, "Amount must be greater than 0");

        IERC20 inputEquivalent = IERC20(getAtomicEquivalentForDexPricing(currencyKey));
        require(address(inputEquivalent) != address(0), "No atomic equivalent for input");

        IERC20 susdEquivalent = IERC20(getAtomicEquivalentForDexPricing("sUSD"));
        require(address(susdEquivalent) != address(0), "No atomic equivalent for sUSD");

        uint result =
            _dexPriceDestinationValue(inputEquivalent, susdEquivalent, amount).mul(SafeDecimalMath.unit()).div(amount);
        require(result != 0, "Result must be greater than 0");

        return result;
    }

    function _dexPriceDestinationValue(
        IERC20 sourceEquivalent,
        IERC20 destEquivalent,
        uint sourceAmount
    ) internal view returns (uint) {
        // Normalize decimals in case equivalent asset uses different decimals from internal unit
        uint sourceAmountInEquivalent =
            (sourceAmount.mul(10**uint(sourceEquivalent.decimals()))).div(SafeDecimalMath.unit());

        uint twapWindow = getAtomicTwapWindow();
        require(twapWindow != 0, "Uninitialized atomic twap window");

        uint twapValueInEquivalent =
            dexPriceAggregator().assetToAsset(
                address(sourceEquivalent),
                sourceAmountInEquivalent,
                address(destEquivalent),
                twapWindow
            );
        require(twapValueInEquivalent > 0, "dex price returned 0");

        // Similar to source amount, normalize decimals back to internal unit for output amount
        return (twapValueInEquivalent.mul(SafeDecimalMath.unit())).div(10**uint(destEquivalent.decimals()));
    }

    function synthTooVolatileForAtomicExchange(bytes32 currencyKey) external view returns (bool) {
        // sUSD is a special case and is never volatile
        if (currencyKey == "sUSD") return false;

        uint considerationWindow = getAtomicVolatilityConsiderationWindow(currencyKey);
        uint updateThreshold = getAtomicVolatilityUpdateThreshold(currencyKey);

        if (considerationWindow == 0 || updateThreshold == 0) {
            // If either volatility setting is not set, never judge an asset to be volatile
            return false;
        }

        // Go back through the historical oracle update rounds to see if there have been more
        // updates in the consideration window than the allowed threshold.
        // If there have, consider the asset volatile--by assumption that many close-by oracle
        // updates is a good proxy for price volatility.
        uint considerationWindowStart = block.timestamp.sub(considerationWindow);
        uint roundId = _getCurrentRoundId(currencyKey);
        for (updateThreshold; updateThreshold > 0; updateThreshold--) {
            (uint rate, uint time) = _getRateAndTimestampAtRound(currencyKey, roundId);
            if (time != 0 && time < considerationWindowStart) {
                // Round was outside consideration window so we can stop querying further rounds
                return false;
            } else if (rate == 0 || time == 0) {
                // Either entire round or a rate inside consideration window was not available
                // Consider the asset volatile
                break;
            }

            if (roundId == 0) {
                // Not enough historical data to continue further
                // Consider the asset volatile
                break;
            }
            roundId--;
        }

        return true;
    }

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

    event DexPriceAggregatorUpdated(address newDexPriceAggregator);
}

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":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"address","name":"aggregator","type":"address"}],"name":"AggregatorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"address","name":"aggregator","type":"address"}],"name":"AggregatorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"CacheUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newDexPriceAggregator","type":"address"}],"name":"DexPriceAggregatorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"constant":true,"inputs":[],"name":"CONTRACT_NAME","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"address","name":"aggregatorAddress","type":"address"}],"name":"addAggregator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"aggregatorKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"aggregatorWarningFlags","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"aggregators","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"anyRateIsInvalid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"},{"internalType":"uint256[]","name":"roundIds","type":"uint256[]"}],"name":"anyRateIsInvalidAtRound","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"atomicEquivalentForDexPricing","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"atomicTwapWindow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"atomicVolatilityConsiderationWindow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"atomicVolatilityUpdateThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"aggregator","type":"address"}],"name":"currenciesUsingAggregator","outputs":[{"internalType":"bytes32[]","name":"currencies","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"currencyKeyDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dexPriceAggregator","outputs":[{"internalType":"contract IDexPriceAggregator","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"sourceCurrencyKey","type":"bytes32"},{"internalType":"uint256","name":"sourceAmount","type":"uint256"},{"internalType":"bytes32","name":"destinationCurrencyKey","type":"bytes32"}],"name":"effectiveAtomicValueAndRates","outputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"systemValue","type":"uint256"},{"internalType":"uint256","name":"systemSourceRate","type":"uint256"},{"internalType":"uint256","name":"systemDestinationRate","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"sourceCurrencyKey","type":"bytes32"},{"internalType":"uint256","name":"sourceAmount","type":"uint256"},{"internalType":"bytes32","name":"destinationCurrencyKey","type":"bytes32"}],"name":"effectiveValue","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"sourceCurrencyKey","type":"bytes32"},{"internalType":"uint256","name":"sourceAmount","type":"uint256"},{"internalType":"bytes32","name":"destinationCurrencyKey","type":"bytes32"}],"name":"effectiveValueAndRates","outputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"sourceRate","type":"uint256"},{"internalType":"uint256","name":"destinationRate","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"sourceCurrencyKey","type":"bytes32"},{"internalType":"uint256","name":"sourceAmount","type":"uint256"},{"internalType":"bytes32","name":"destinationCurrencyKey","type":"bytes32"},{"internalType":"uint256","name":"roundIdForSrc","type":"uint256"},{"internalType":"uint256","name":"roundIdForDest","type":"uint256"}],"name":"effectiveValueAndRatesAtRound","outputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"sourceRate","type":"uint256"},{"internalType":"uint256","name":"destinationRate","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"getCurrentRoundId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"uint256","name":"startingRoundId","type":"uint256"},{"internalType":"uint256","name":"startingTimestamp","type":"uint256"},{"internalType":"uint256","name":"timediff","type":"uint256"}],"name":"getLastRoundIdBeforeElapsedSecs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"lastRateUpdateTimes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"lastRateUpdateTimesForCurrencies","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"rateAndInvalid","outputs":[{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"bool","name":"isInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"rateAndTimestampAtRound","outputs":[{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint256","name":"time","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"rateAndUpdatedTime","outputs":[{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint256","name":"time","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"rateForCurrency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"rateIsFlagged","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"rateIsInvalid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"rateIsStale","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rateStalePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"ratesAndInvalidForCurrencies","outputs":[{"internalType":"uint256[]","name":"rates","type":"uint256[]"},{"internalType":"bool","name":"anyRateInvalid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"ratesAndUpdatedTimeForCurrencyLastNRounds","outputs":[{"internalType":"uint256[]","name":"rates","type":"uint256[]"},{"internalType":"uint256[]","name":"times","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"ratesForCurrencies","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"removeAggregator","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":"contract IDexPriceAggregator","name":"_dexPriceAggregator","type":"address"}],"name":"setDexPriceAggregator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"synthTooVolatileForAtomicExchange","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506040516200385b3803806200385b8339818101604052604081101561003557600080fd5b50805160209091015181818080836001600160a01b03811661009e576040805162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f74206265203000000000000000604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b038316908117825560408051928352602083019190915280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a150600280546001600160a01b039092166001600160a01b0319909216919091179055505050505061372e806200012d6000396000f3fe608060405234801561001057600080fd5b50600436106102735760003560e01c80636ce66c80116101515780639eab4a37116100c3578063c8e5bbd511610087578063c8e5bbd514610855578063ce8480ea14610922578063d89ee8611461093f578063ed762450146109fd578063f216310714610abf578063fdadbc7e14610adc57610273565b80639eab4a3714610772578063a77715561461077a578063ac82f60814610797578063b295ad34146107b4578063c2c8a676146107e757610273565b80637a018a1e116101155780637a018a1e146106e25780638295016a146106ff5780638661cc7b14610728578063899ffef4146107455780638da5cb5b1461074d57806397a4aca01461075557610273565b80636ce66c801461063c5780637103353e1461068f57806374185360146106ac57806374eded39146106b457806379ba5097146106da57610273565b80632af64bd3116101ea5780634c36b837116101ae5780634c36b837146105d65780634f72def6146105de57806353a47bb7146105fb578063614d08f814610603578063654a60ac1461060b5780636a2b91511461063457610273565b80632af64bd3146105325780632bed9e0c1461053a57806338aa1b99146105575780633f0e084f146105745780634308a94f146105a057610273565b80630c71cd231161023c5780630c71cd23146104485780630ee4951b1461047e578063109e46a2146104985780631627540c146104c75780632528f0fe146104ef5780632678df961461050c57610273565b80629919c01461027857806304f3bcec146102a9578063055286e0146102cd57806305a046e51461031c5780630a7d36d1146103da575b600080fd5b6102956004803603602081101561028e57600080fd5b5035610aff565b604080519115158252519081900360200190f35b6102b1610b1a565b604080516001600160a01b039092168252519081900360200190f35b6102f6600480360360608110156102e357600080fd5b5080359060208101359060400135610b29565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61038a6004803603602081101561033257600080fd5b810190602081018135600160201b81111561034c57600080fd5b82018360208201111561035e57600080fd5b803590602001918460208302840111600160201b8311171561037f57600080fd5b509092509050610c21565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103c65781810151838201526020016103ae565b505050509050019250505060405180910390f35b610295600480360360208110156103f057600080fd5b810190602081018135600160201b81111561040a57600080fd5b82018360208201111561041c57600080fd5b803590602001918460208302840111600160201b8311171561043d57600080fd5b509092509050610ca3565b6104656004803603602081101561045e57600080fd5b5035610d56565b6040805192835290151560208301528051918290030190f35b610486610ddb565b60408051918252519081900360200190f35b610486600480360360808110156104ae57600080fd5b5080359060208101359060408101359060600135610deb565b6104ed600480360360208110156104dd57600080fd5b50356001600160a01b0316610e2e565b005b6102956004803603602081101561050557600080fd5b5035610e8a565b61038a6004803603602081101561052257600080fd5b50356001600160a01b0316610eaa565b610295610f5e565b6104ed6004803603602081101561055057600080fd5b5035611068565b6102956004803603602081101561056d57600080fd5b5035611164565b6104ed6004803603604081101561058a57600080fd5b50803590602001356001600160a01b0316611172565b6105bd600480360360208110156105b657600080fd5b50356113b8565b6040805192835260208301919091528051918290030190f35b6102b16113f0565b610486600480360360208110156105f457600080fd5b50356113fa565b6102b1611418565b610486611427565b6104866004803603606081101561062157600080fd5b508035906020810135906040013561144b565b610486611463565b610671600480360360a081101561065257600080fd5b508035906020810135906040810135906060810135906080013561146d565b60408051938452602084019290925282820152519081900360600190f35b6102b1600480360360208110156106a557600080fd5b50356114d2565b6104ed6114ed565b6104ed600480360360208110156106ca57600080fd5b50356001600160a01b03166116b5565b6104ed61179a565b610486600480360360208110156106f857600080fd5b5035611856565b6106716004803603606081101561071557600080fd5b5080359060208101359060400135611861565b6102956004803603602081101561073e57600080fd5b5035611881565b61038a61196a565b6102b16119bb565b6104866004803603602081101561076b57600080fd5b50356119ca565b6102b16119d5565b6104866004803603602081101561079057600080fd5b5035611a80565b610486600480360360208110156107ad57600080fd5b5035611a8b565b6107d1600480360360208110156107ca57600080fd5b5035611aa6565b6040805160ff9092168252519081900360200190f35b61038a600480360360208110156107fd57600080fd5b810190602081018135600160201b81111561081757600080fd5b82018360208201111561082957600080fd5b803590602001918460208302840111600160201b8311171561084a57600080fd5b509092509050611abb565b6108c36004803603602081101561086b57600080fd5b810190602081018135600160201b81111561088557600080fd5b82018360208201111561089757600080fd5b803590602001918460208302840111600160201b831117156108b857600080fd5b509092509050611b33565b604051808060200183151515158152602001828103825284818151815260200191508051906020019060200280838360005b8381101561090d5781810151838201526020016108f5565b50505050905001935050505060405180910390f35b6104866004803603602081101561093857600080fd5b5035611c7a565b6102956004803603604081101561095557600080fd5b810190602081018135600160201b81111561096f57600080fd5b82018360208201111561098157600080fd5b803590602001918460208302840111600160201b831117156109a257600080fd5b919390929091602081019035600160201b8111156109bf57600080fd5b8201836020820111156109d157600080fd5b803590602001918460208302840111600160201b831117156109f257600080fd5b509092509050611c85565b610a2660048036036060811015610a1357600080fd5b5080359060208101359060400135611d8c565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b83811015610a6a578181015183820152602001610a52565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015610aa9578181015183820152602001610a91565b5050505090500194505050505060405180910390f35b6102b160048036036020811015610ad557600080fd5b5035611e6a565b6105bd60048036036040811015610af257600080fd5b5080359060200135611e75565b6000610b1282610b0d611e8e565b611f06565b90505b919050565b6002546001600160a01b031681565b600080600080610b3a878787611f38565b919450925090506000610b4c88611f8a565b90506000610b5987611f8a565b9050600080838015610b685750825b15610b77575084905083610bf2565b83158015610b825750825b15610ba457610b9a86610b958d8d612070565b612288565b9150849050610bf2565b838015610baf575082155b15610bd157859150610bca85610bc58b8d612070565b61229e565b9050610bf2565b610bdf86610b958d8d612070565b9150610bef85610bc58b8d612070565b90505b610c1281610c068c8563ffffffff6122ad16565b9063ffffffff61230616565b97505050505093509350935093565b60608083839050604051908082528060200260200182016040528015610c51578160200160208202803883390190505b50905060005b83811015610c9957610c7a858583818110610c6e57fe5b90506020020135612370565b828281518110610c8657fe5b6020908102919091010152600101610c57565b5090505b92915050565b600080610cae611e8e565b90506060610cee85858080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061238c92505050565b905060005b84811015610d4a57818181518110610d0757fe5b602002602001015180610d315750610d31868683818110610d2457fe5b9050602002013584611f06565b15610d425760019350505050610c9d565b600101610cf3565b50600095945050505050565b600080610d616135be565b610d6a846125cf565b9050631cd554d160e21b841415610d9057516001600160d81b0316915060009050610dd6565b8051610dae610d9d611e8e565b836020015164ffffffffff166127dd565b80610dc55750610dc585610dc06127f8565b612877565b6001600160d81b0390911693509150505b915091565b6000610de5611e8e565b90505b90565b600083815b610dfd8783600101612955565b915050801580610e0e575083850181115b15610e1b57509050610e26565b600190910190610df0565b949350505050565b610e36612b34565b600180546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229181900360200190a150565b6000610e9882610b0d611e8e565b80610b125750610b1282610dc06127f8565b600654604080518281526020808402820101909152606091600091908015610edc578160200160208202803883390190505b50915060005b600654811015610f5757600060068281548110610efb57fe5b600091825260208083209091015480835260049091526040909120549091506001600160a01b039081169086161415610f4e5780848480600101955081518110610f4157fe5b6020026020010181815250505b50600101610ee2565b5050919050565b60006060610f6a61196a565b905060005b815181101561105f576000828281518110610f8657fe5b6020908102919091018101516000818152600383526040908190205460025482516321f8a72160e01b81526004810185905292519395506001600160a01b03918216949116926321f8a721926024808201939291829003018186803b158015610fee57600080fd5b505afa158015611002573d6000803e3d6000fd5b505050506040513d602081101561101857600080fd5b50516001600160a01b031614158061104557506000818152600360205260409020546001600160a01b0316155b156110565760009350505050610de8565b50600101610f6f565b50600191505090565b611070612b34565b6000818152600460205260409020546001600160a01b0316806110da576040805162461bcd60e51b815260206004820152601c60248201527f4e6f2061676772656761746f722065786973747320666f72206b657900000000604482015290519081900360640190fd5b600082815260046020908152604080832080546001600160a01b031916905560059091528120805460ff19169055611113836006612b7f565b9050801561115f57604080518481526001600160a01b038416602082015281517fec70e890fc7db7de4059b114c9093a1f41283d18ffcfbcac45566feea4d4f777929181900390910190a15b505050565b6000610b1282610dc06127f8565b61117a612b34565b60008190506000816001600160a01b031663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b1580156111ba57600080fd5b505afa1580156111ce573d6000803e3d6000fd5b505050506040513d60208110156111e457600080fd5b50511015611239576040805162461bcd60e51b815260206004820152601b60248201527f476976656e2041676772656761746f7220697320696e76616c69640000000000604482015290519081900360640190fd5b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561127457600080fd5b505afa158015611288573d6000803e3d6000fd5b505050506040513d602081101561129e57600080fd5b50519050601260ff821611156112e55760405162461bcd60e51b81526004018080602001828103825260328152602001806136c86032913960400191505060405180910390fd5b6000848152600460205260409020546001600160a01b031661133757600680546001810182556000919091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f018490555b600084815260046020908152604080832080546001600160a01b0319166001600160a01b0387169081179091556005835292819020805460ff191660ff861617905580518781529182019290925281517f0bcae573430f69c5361e5d76534d3f61d2d803958778680cd74be9dc6299bc63929181900390910190a150505050565b6000806113c36135be565b6113cc846125cf565b80516020909101516001600160d81b03909116935064ffffffffff16915050915091565b6000610de56127f8565b6006818154811061140757fe5b600091825260209091200154905081565b6001546001600160a01b031681565b7f45786368616e676552617465735769746844657850726963696e67000000000081565b6000611458848484611f38565b509095945050505050565b6000610de5612c23565b600080600061147c8886612955565b509150878614156114915750859150806114c7565b61149b8685612955565b50905080156114c7576114c4816114b8898563ffffffff612c9c16565b9063ffffffff612cb116565b92505b955095509592505050565b6004602052600090815260409020546001600160a01b031681565b60606114f761196a565b905060005b81518110156116b157600082828151811061151357fe5b602090810291909101810151600254604080517f5265736f6c766572206d697373696e67207461726765743a2000000000000000818601526039808201859052825180830390910181526059820180845263dacb2d0160e01b9052605d8201858152607d83019384528151609d84015281519597506000966001600160a01b039095169563dacb2d01958995939492939260bd0191908501908083838c5b838110156115c95781810151838201526020016115b1565b50505050905090810190601f1680156115f65780820380516001836020036101000a031916815260200191505b50935050505060206040518083038186803b15801561161457600080fd5b505afa158015611628573d6000803e3d6000fd5b505050506040513d602081101561163e57600080fd5b505160008381526003602090815260409182902080546001600160a01b0319166001600160a01b03851690811790915582518681529182015281519293507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68929081900390910190a150506001016114fc565b5050565b6116bd612b34565b6116c5612cc6565b604080516309b9412f60e31b81526c45786368616e6765526174657360981b6004820152713232bc283934b1b2a0b3b3b932b3b0ba37b960711b60248201526001600160a01b03848116604483015291519290911691634dca09789160648082019260009290919082900301818387803b15801561174257600080fd5b505af1158015611756573d6000803e3d6000fd5b5050604080516001600160a01b038516815290517f8a51d16f378c74938a4b9290afe425bbfba62f05aa9d27bff5e892f62696f7609350908190036020019150a150565b6001546001600160a01b031633146117e35760405162461bcd60e51b81526004018080602001828103825260358152602001806136136035913960400191505060405180910390fd5b600054600154604080516001600160a01b03938416815292909116602083015280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000610b1282612ce3565b6000806000611871868686611f38565b9250925092505b93509350939050565b600081631cd554d160e21b141561189a57506000610b15565b60006118a583612d88565b905060006118b284612e3c565b90508115806118bf575080155b156118cf57600092505050610b15565b60006118e1428463ffffffff612ef016565b905060006118ee86612ce3565b90505b821561195e576000806119048884612955565b915091508060001415801561191857508381105b1561192c5760009650505050505050610b15565b811580611937575080155b1561194357505061195e565b8261194f57505061195e565b505060001992830192016118f1565b50600195945050505050565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b816000815181106119ac57fe5b60200260200101818152505090565b6000546001600160a01b031681565b6000610b1282612e3c565b60006119df612cc6565b6001600160a01b0316639ee5955a6c45786368616e6765526174657360981b713232bc283934b1b2a0b3b3b932b3b0ba37b960711b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015611a4f57600080fd5b505afa158015611a63573d6000803e3d6000fd5b505050506040513d6020811015611a7957600080fd5b5051905090565b6000610b1282612d88565b6000611a96826125cf565b516001600160d81b031692915050565b60056020526000908152604090205460ff1681565b60608083839050604051908082528060200260200182016040528015611aeb578160200160208202803883390190505b50905060005b83811015610c9957611b14858583818110611b0857fe5b90506020020135611a8b565b828281518110611b2057fe5b6020908102919091010152600101611af1565b6060600083839050604051908082528060200260200182016040528015611b64578160200160208202803883390190505b5091506000611b71611e8e565b90506060611bb186868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061238c92505050565b905060005b85811015611c7057611bc66135be565b611be1888884818110611bd557fe5b905060200201356125cf565b905080600001516001600160d81b0316868381518110611bfd57fe5b60200260200101818152505084158015611c305750631cd554d160e21b888884818110611c2657fe5b9050602002013514155b15611c6757828281518110611c4157fe5b602002602001015180611c645750611c6484826020015164ffffffffff166127dd565b94505b50600101611bb6565b5050509250929050565b6000610b1282612370565b6000818414611cc55760405162461bcd60e51b81526004018080602001828103825260308152602001806136986030913960400191505060405180910390fd5b6000611ccf611e8e565b90506060611d0f87878080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061238c92505050565b905060005b86811015611d7e57818181518110611d2857fe5b602002602001015180611d655750611d65888883818110611d4557fe5b90506020020135878784818110611d5857fe5b9050602002013585612f4d565b15611d765760019350505050610e26565b600101611d14565b506000979650505050505050565b60608083604051908082528060200260200182016040528015611db9578160200160208202803883390190505b50915083604051908082528060200260200182016040528015611de6578160200160208202803883390190505b50905060008311611dff57611dfa85612ce3565b611e01565b825b925060005b84811015611e6057611e188685612955565b848381518110611e2457fe5b60200260200101848481518110611e3757fe5b60209081029190910101919091525283611e515750611e62565b60001990930192600101611e06565b505b935093915050565b6000610b1282612f7f565b600080611e828484612955565b915091505b9250929050565b6000611e98612cc6565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6e1c985d1954dd185b1954195c9a5bd9608a1b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015611a4f57600080fd5b6000631cd554d160e21b831415611f1f57506000610c9d565b611f3182611f2c85612370565b6127dd565b9392505050565b6000806000611f4686611a8b565b915083861415611f5a575083915080611878565b611f6384611a8b565b9050801561187857611f7f816114b8878563ffffffff612c9c16565b925093509350939050565b6000611f94612cc6565b6001600160a01b031663d994502d6d53797374656d53657474696e677360901b7f70757265436861696e6c696e6b466f7241746f6d696373456e61626c65640000856040516020018083815260200182815260200192505050604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561203e57600080fd5b505afa158015612052573d6000803e3d6000fd5b505050506040513d602081101561206857600080fd5b505192915050565b6000816120c4576040805162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b60006120cf84612f7f565b90506001600160a01b03811661212c576040805162461bcd60e51b815260206004820152601e60248201527f4e6f2061746f6d6963206571756976616c656e7420666f7220696e7075740000604482015290519081900360640190fd5b600061213e631cd554d160e21b612f7f565b90506001600160a01b03811661219b576040805162461bcd60e51b815260206004820152601d60248201527f4e6f2061746f6d6963206571756976616c656e7420666f722073555344000000604482015290519081900360640190fd5b600061222b85610c06731a60e2e2a8be0bc2b6381dd31fd3fd5f9a28de4c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156121e857600080fd5b505af41580156121fc573d6000803e3d6000fd5b505050506040513d602081101561221257600080fd5b505161221f87878b613033565b9063ffffffff6122ad16565b90508061227f576040805162461bcd60e51b815260206004820152601d60248201527f526573756c74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b95945050505050565b60008183106122975781611f31565b5090919050565b60008183116122975781611f31565b6000826122bc57506000610c9d565b828202828482816122c957fe5b0414611f315760405162461bcd60e51b81526004018080602001828103825260218152602001806136776021913960400191505060405180910390fd5b600080821161235c576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b600082848161236757fe5b04949350505050565b600061237b826125cf565b6020015164ffffffffff1692915050565b606060006123986127f8565b90506001600160a01b0381161561259a57606083516040519080825280602002602001820160405280156123d6578160200160208202803883390190505b50905060005b845181101561244b57600460008683815181106123f557fe5b6020026020010151815260200190815260200160002060009054906101000a90046001600160a01b031682828151811061242b57fe5b6001600160a01b03909216602092830291909101909101526001016123dc565b50604051631f5c8f2b60e21b81526020600482018181528351602484015283516001600160a01b03861693637d723cac93869392839260440191808601910280838360005b838110156124a8578181015183820152602001612490565b505050509050019250505060006040518083038186803b1580156124cb57600080fd5b505afa1580156124df573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561250857600080fd5b8101908080516040519392919084600160201b82111561252757600080fd5b90830190602082018581111561253c57600080fd5b82518660208202830111600160201b8211171561255857600080fd5b82525081516020918201928201910280838360005b8381101561258557818101518382015260200161256d565b505050509050016040525050509250506125c9565b82516040519080825280602002602001820160405280156125c5578160200160208202803883390190505b5091505b50919050565b6125d76135be565b631cd554d160e21b82141561267b576040518060400160405280731a60e2e2a8be0bc2b6381dd31fd3fd5f9a28de4c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561263557600080fd5b505af4158015612649573d6000803e3d6000fd5b505050506040513d602081101561265f57600080fd5b50516001600160d81b0316815260006020909101529050610b15565b6000828152600460205260409020546001600160a01b031680156125c95760408051600481526024810182526020810180516001600160e01b0316633fabe5a360e21b1781529151815191926000926060926001600160a01b0387169286928291908083835b602083106127005780518252601f1990920191602091820191016126e1565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612760576040519150601f19603f3d011682016040523d82523d6000602084013e612765565b606091505b509150915081156127d4576000808280602001905160a081101561278857600080fd5b506020810151606090910151604080518082019091529193509150806127ae8a85613374565b6001600160d81b031681526020018264ffffffffff168152509650505050505050610b15565b50505050919050565b6000426127f0838563ffffffff61341d16565b109392505050565b6000612802612cc6565b6001600160a01b0316639ee5955a6d53797374656d53657474696e677360901b7561676772656761746f725761726e696e67466c61677360501b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015611a4f57600080fd5b6000631cd554d160e21b83141561289057506000610c9d565b6000838152600460205260409020546001600160a01b03168015806128bc57506001600160a01b038316155b156128cb576000915050610c9d565b826001600160a01b031663357e47fe826040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561292157600080fd5b505afa158015612935573d6000803e3d6000fd5b505050506040513d602081101561294b57600080fd5b5051949350505050565b600080631cd554d160e21b8414156129e257731a60e2e2a8be0bc2b6381dd31fd3fd5f9a28de4c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156129ab57600080fd5b505af41580156129bf573d6000803e3d6000fd5b505050506040513d60208110156129d557600080fd5b5051915060009050611e87565b6000848152600460205260409020546001600160a01b03168015612b2c5760408051602480820187905282518083039091018152604490910182526020810180516001600160e01b0316639a6fc8f560e01b1781529151815191926000926060926001600160a01b0387169286928291908083835b60208310612a765780518252601f199092019160209182019101612a57565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612ad6576040519150601f19603f3d011682016040523d82523d6000602084013e612adb565b606091505b50915091508115612b28576000808280602001905160a0811015612afe57600080fd5b5060208101516060909101519092509050612b198a83613374565b97509550611e87945050505050565b5050505b509250929050565b6000546001600160a01b03163314612b7d5760405162461bcd60e51b815260040180806020018281038252602f815260200180613648602f913960400191505060405180910390fd5b565b6000805b8254811015612c195783838281548110612b9957fe5b90600052602060002001541415612c1157828181548110612bb657fe5b6000918252602082200155825483906000198101908110612bd357fe5b9060005260206000200154838281548110612bea57fe5b6000918252602090912001558254612c068460001983016135d5565b506001915050610c9d565b600101612b83565b5060009392505050565b6000612c2d612cc6565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f61746f6d69635477617057696e646f7760801b6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015611a4f57600080fd5b6000611f318383670de0b6b3a7640000613477565b6000611f318383670de0b6b3a76400006134b4565b6000610de56e466c657869626c6553746f7261676560881b6134da565b6000631cd554d160e21b821415612cfc57506000610b15565b6000828152600460205260409020546001600160a01b031680156125c957806001600160a01b031663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b158015612d5357600080fd5b505afa158015612d67573d6000803e3d6000fd5b505050506040513d6020811015612d7d57600080fd5b50519150610b159050565b6000612d92612cc6565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7f61746f6d6963566f6c436f6e73696465726174696f6e57696e646f7700000000856040516020018083815260200182815260200192505050604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561203e57600080fd5b6000612e46612cc6565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7f61746f6d6963566f6c5570646174655468726573686f6c640000000000000000856040516020018083815260200182815260200192505050604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561203e57600080fd5b600082821115612f47576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000631cd554d160e21b841415612f6657506000611f31565b6000612f728585612955565b91505061227f83826127dd565b6000612f89612cc6565b6001600160a01b0316639ee5955a6d53797374656d53657474696e677360901b7f61746f6d69634571756976616c656e74466f7244657850726963696e67000000856040516020018083815260200182815260200192505050604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561203e57600080fd5b60008061312d731a60e2e2a8be0bc2b6381dd31fd3fd5f9a28de4c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561307d57600080fd5b505af4158015613091573d6000803e3d6000fd5b505050506040513d60208110156130a757600080fd5b50516040805163313ce56760e01b81529051610c06916001600160a01b038a169163313ce56791600480820192602092909190829003018186803b1580156130ee57600080fd5b505afa158015613102573d6000803e3d6000fd5b505050506040513d602081101561311857600080fd5b5051869060ff16600a0a63ffffffff6122ad16565b90506000613139612c23565b90508061318d576040805162461bcd60e51b815260206004820181905260248201527f556e696e697469616c697a65642061746f6d696320747761702077696e646f77604482015290519081900360640190fd5b60006131976119d5565b60408051637c66194960e01b81526001600160a01b038a811660048301526024820187905289811660448301526064820186905291519290911691637c66194991608480820192602092909190829003018186803b1580156131f857600080fd5b505afa15801561320c573d6000803e3d6000fd5b505050506040513d602081101561322257600080fd5b505190508061326f576040805162461bcd60e51b815260206004820152601460248201527306465782070726963652072657475726e656420360641b604482015290519081900360640190fd5b613369866001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156132ab57600080fd5b505afa1580156132bf573d6000803e3d6000fd5b505050506040513d60208110156132d557600080fd5b505160408051630241ebdb60e61b8152905160ff909216600a0a91610c0691731a60e2e2a8be0bc2b6381dd31fd3fd5f9a28de4c9163907af6c091600480820192602092909190829003018186803b15801561333057600080fd5b505af4158015613344573d6000803e3d6000fd5b505050506040513d602081101561335a57600080fd5b5051849063ffffffff6122ad16565b979650505050505050565b6000808212156133cb576040805162461bcd60e51b815260206004820152601b60248201527f4e656761746976652072617465206e6f7420737570706f727465640000000000604482015290519081900360640190fd5b60008381526005602052604090205460ff16156125c9576000838152600560205260408120546134009060129060ff16612ef0565b600a0a9050613415838263ffffffff6122ad16565b915050610c9d565b600082820183811015611f31576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600080600a830461348e868663ffffffff6122ad16565b8161349557fe5b0490506005600a825b06106134a857600a015b600a9004949350505050565b6000806134ce84610c0687600a870263ffffffff6122ad16565b90506005600a8261349e565b600081815260036020908152604080832054815170026b4b9b9b4b7339030b2323932b9b99d1607d1b9381019390935260318084018690528251808503909101815260519093019091526001600160a01b031690816135b75760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561357c578181015183820152602001613564565b50505050905090810190601f1680156135a95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5092915050565b604080518082019091526000808252602082015290565b81548183558181111561115f5760008381526020902061115f918101908301610de891905b8082111561360e57600081556001016135fa565b509056fe596f75206d757374206265206e6f6d696e61746564206265666f726520796f752063616e20616363657074206f776e6572736869704f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77726f756e64496473206d757374206265207468652073616d65206c656e6774682061732063757272656e63794b65797341676772656761746f7220646563696d616c732073686f756c64206265206c6f776572206f7220657175616c20746f203138a265627a7a72315820aee681d97d2915943716e3ade233580f5f3d52c1a0449f76b279be9dedbe39e164736f6c6343000510003200000000000000000000000073570075092502472e4b61a7058df1a4a1db12f2000000000000000000000000242a3df52c375bee81b1c668741d7c63af68fdd2

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

00000000000000000000000073570075092502472e4b61a7058df1a4a1db12f2000000000000000000000000242a3df52c375bee81b1c668741d7c63af68fdd2

-----Decoded View---------------
Arg [0] : _owner (address): 0x73570075092502472e4b61a7058df1a4a1db12f2
Arg [1] : _resolver (address): 0x242a3df52c375bee81b1c668741d7c63af68fdd2

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000073570075092502472e4b61a7058df1a4a1db12f2
Arg [1] : 000000000000000000000000242a3df52c375bee81b1c668741d7c63af68fdd2


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

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