Sepolia Testnet

Contract

0x2e11a3638F12A37263b1B4226b61412f6BBB277c

Overview

ETH Balance

0 ETH

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value
0x6080604056764902024-04-11 18:01:0068 days ago1712858460IN
 Create: DynamicSynthRedeemer
0 ETH0.001326950.94122827

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

Contract Source Code Verified (Exact Match)

Contract Name:
DynamicSynthRedeemer

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 2024-04-11
*/

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

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



pragma solidity ^0.5.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);
}


// Inheritance


// Internal references


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

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

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

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

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

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

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

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

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

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

    event TargetUpdated(Proxyable newTarget);
}


// Inheritance


// Internal references


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

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

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

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

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

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

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

    modifier onlyProxy {
        _onlyProxy();
        _;
    }

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

    modifier optionalProxy {
        _optionalProxy();
        _;
    }

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

    modifier optionalProxy_onlyOwner {
        _optionalProxy_onlyOwner();
        _;
    }

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

    event ProxyUpdated(address proxyAddress);
}


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

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

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


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

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

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

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

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

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


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

    function allNetworksDebtInfo()
        external
        view
        returns (
            uint256 debt,
            uint256 sharesSupply,
            bool isStale
        );

    function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid);

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

    function availableSynthCount() external view returns (uint);

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

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

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

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

    function collateralisationRatioAndAnyRatesInvalid(address _issuer)
        external
        view
        returns (uint cratio, bool anyRateIsInvalid);

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

    function issuanceRatio() external view returns (uint);

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

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

    function minimumStakeTime() external view returns (uint);

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

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

    function getSynths(bytes32[] calldata currencyKeys) external view returns (ISynth[] memory);

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

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

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

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

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

    function issueSynths(address from, uint amount) external;

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

    function issueMaxSynths(address from) external;

    function issueMaxSynthsOnBehalf(address issueFor, address from) external;

    function burnSynths(address from, uint amount) external;

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

    function burnSynthsToTarget(address from) external;

    function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external;

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

    function setCurrentPeriodId(uint128 periodId) external;

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

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

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

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

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


// Inheritance


// Internal references


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

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

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

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

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

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

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

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

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

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

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

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

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

    event AddressImported(bytes32 name, address destination);
}


// Internal references


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

    mapping(bytes32 => address) private addressCache;

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

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

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

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

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

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

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

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

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

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

        return true;
    }

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

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

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

    event CacheUpdated(bytes32 name, address destination);
}


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

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

    function decimals() external view returns (uint8);

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

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

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

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

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

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

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

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


interface IDynamicSynthRedeemer {
    function suspendRedemption() external;

    function resumeRedemption() external;

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

    function redeem(bytes32 currencyKey) external;

    function redeemAll(bytes32[] calldata currencyKeys) external;

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


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


pragma experimental ABIEncoderV2;

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

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

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


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

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

    function aggregatorWarningFlags() external view returns (address);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    function rateStalePeriod() external view returns (uint);

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

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

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

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

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

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


// Inheritence


// Libraries


// Internal references


contract DynamicSynthRedeemer is Owned, IDynamicSynthRedeemer, MixinResolver {
    using SafeDecimalMath for uint;

    bytes32 public constant CONTRACT_NAME = "DynamicSynthRedeemer";

    uint public discountRate;
    bool public redemptionActive;

    bytes32 internal constant sUSD = "sUSD";

    bytes32 private constant CONTRACT_ISSUER = "Issuer";
    bytes32 private constant CONTRACT_EXRATES = "ExchangeRates";

    constructor(address _owner, address _resolver) public Owned(_owner) MixinResolver(_resolver) {
        discountRate = SafeDecimalMath.unit();
    }

    /* ========== RESOLVER CONFIG ========== */

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

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

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

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

    function _redeemingActive() internal view {
        require(redemptionActive, "Redemption deactivated");
    }

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

    function getDiscountRate() external view returns (uint) {
        return discountRate;
    }

    /* ========== INTERNAL HELPERS ========== */

    function _proxyAddressForKey(bytes32 currencyKey) internal returns (address) {
        address synth = address(_issuer().synths(currencyKey));
        require(synth != address(0), "Invalid synth");
        return address(Proxyable(synth).proxy());
    }

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

    function redeemAll(bytes32[] calldata currencyKeys) external requireRedemptionActive {
        for (uint i = 0; i < currencyKeys.length; i++) {
            address synthProxy = _proxyAddressForKey(currencyKeys[i]);
            _redeem(synthProxy, currencyKeys[i], IERC20(synthProxy).balanceOf(msg.sender));
        }
    }

    function redeem(bytes32 currencyKey) external requireRedemptionActive {
        address synthProxy = _proxyAddressForKey(currencyKey);
        _redeem(synthProxy, currencyKey, IERC20(synthProxy).balanceOf(msg.sender));
    }

    function redeemPartial(bytes32 currencyKey, uint amountOfSynth) external requireRedemptionActive {
        address synthProxy = _proxyAddressForKey(currencyKey);
        // technically this check isn't necessary - Synth.burn would fail due to safe sub,
        // but this is a useful error message to the user
        require(IERC20(synthProxy).balanceOf(msg.sender) >= amountOfSynth, "Insufficient balance");
        _redeem(synthProxy, currencyKey, amountOfSynth);
    }

    function _redeem(
        address synthProxy,
        bytes32 currencyKey,
        uint amountOfSynth
    ) internal {
        require(amountOfSynth > 0, "No balance of synth to redeem");
        require(currencyKey != sUSD, "Cannot redeem sUSD");

        // Discount rate applied to chainlink price for dynamic redemptions
        (uint rate, bool invalid) = _exchangeRates().rateAndInvalid(currencyKey);
        uint rateToRedeem = rate.multiplyDecimalRound(discountRate);
        require(rateToRedeem > 0 && !invalid, "Synth not redeemable");

        uint amountInsUSD = amountOfSynth.multiplyDecimalRound(rateToRedeem);
        _issuer().burnAndIssueSynthsWithoutDebtCache(msg.sender, currencyKey, amountOfSynth, amountInsUSD);

        emit SynthRedeemed(synthProxy, msg.sender, amountOfSynth, amountInsUSD);
    }

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

    modifier requireRedemptionActive() {
        _redeemingActive();
        _;
    }

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

    function setDiscountRate(uint _newRate) external onlyOwner {
        require(_newRate >= 0 && _newRate <= SafeDecimalMath.unit(), "Invalid rate");
        discountRate = _newRate;
        emit DiscountRateUpdated(_newRate);
    }

    function suspendRedemption() external onlyOwner {
        require(redemptionActive, "Redemption suspended");
        redemptionActive = false;
        emit RedemptionSuspended();
    }

    function resumeRedemption() external onlyOwner {
        require(!redemptionActive, "Redemption not suspended");
        redemptionActive = true;
        emit RedemptionResumed();
    }

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

    event RedemptionSuspended();
    event RedemptionResumed();
    event DiscountRateUpdated(uint discountRate);
    event SynthRedeemed(address synth, address account, uint amountOfSynth, uint amountInsUSD);
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"CacheUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"discountRate","type":"uint256"}],"name":"DiscountRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[],"name":"RedemptionResumed","type":"event"},{"anonymous":false,"inputs":[],"name":"RedemptionSuspended","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"synth","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountOfSynth","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountInsUSD","type":"uint256"}],"name":"SynthRedeemed","type":"event"},{"constant":true,"inputs":[],"name":"CONTRACT_NAME","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"discountRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getDiscountRate","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":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"redeem","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[]","name":"currencyKeys","type":"bytes32[]"}],"name":"redeemAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"uint256","name":"amountOfSynth","type":"uint256"}],"name":"redeemPartial","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"redemptionActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"resolver","outputs":[{"internalType":"contract AddressResolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"resolverAddressesRequired","outputs":[{"internalType":"bytes32[]","name":"addresses","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"resumeRedemption","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_newRate","type":"uint256"}],"name":"setDiscountRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"suspendRedemption","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b50604051620019f7380380620019f7833981016040819052620000349162000192565b80826001600160a01b038116620000685760405162461bcd60e51b81526004016200005f9062000277565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000b591849062000251565b60405180910390a15080600260006101000a8154816001600160a01b0302191690836001600160a01b0316021790555050739d6d846d4546614a7e668e66886624c0ae21d78663907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156200012b57600080fd5b505af415801562000140573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250620001669190810190620001d1565b60045550620002e09050565b80516200017f81620002bb565b92915050565b80516200017f81620002d5565b60008060408385031215620001a657600080fd5b6000620001b4858562000172565b9250506020620001c78582860162000172565b9150509250929050565b600060208284031215620001e457600080fd5b6000620001f2848462000185565b949350505050565b6200020581620002a7565b82525050565b620002058162000292565b60006200022560198362000289565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b60408101620002618285620001fa565b6200027060208301846200020b565b9392505050565b602080825281016200017f8162000216565b90815260200190565b60006001600160a01b0382166200017f565b90565b60006200017f8260006200017f8262000292565b620002c68162000292565b8114620002d257600080fd5b50565b620002c681620002a4565b61170780620002f06000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063614d08f8116100a2578063899ffef411610071578063899ffef4146101e35780638da5cb5b146101f857806399845dac14610200578063e6c0e6d514610213578063eda1122c1461021b57610116565b8063614d08f8146101b857806374185360146101c057806379ba5097146101c85780637c69febd146101d057610116565b80632dee8b7e116100e95780632dee8b7e1461016b578063322cd02e146101735780634c74183c146101865780634ecc1f771461019b57806353a47bb7146101a357610116565b806304f3bcec1461011b5780630cd0675c146101395780631627540c146101435780632af64bd314610156575b600080fd5b61012361022e565b604051610130919061152f565b60405180910390f35b61014161023d565b005b610141610151366004610ee2565b6102a9565b61015e610307565b60405161013091906114e5565b61014161041f565b610141610181366004610f86565b61047e565b61018e61053e565b60405161013091906114f3565b61015e610544565b6101ab61054d565b6040516101309190611444565b61018e61055c565b610141610577565b6101416106cd565b6101416101de366004610f68565b610769565b6101eb610841565b60405161013091906114d4565b6101ab6108b1565b61014161020e366004610f26565b6108c0565b61018e610993565b610141610229366004610f68565b610999565b6002546001600160a01b031681565b6102456109df565b60055460ff16156102715760405162461bcd60e51b8152600401610268906115fe565b60405180910390fd5b6005805460ff191660011790556040517f7a2913cddb07686623e9d442b08e598f63153b82d934cb6c5e09e6b0652c221f90600090a1565b6102b16109df565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906102fc908390611444565b60405180910390a150565b60006060610313610841565b905060005b815181101561041557600082828151811061032f57fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a721906103809085906004016114f3565b60206040518083038186803b15801561039857600080fd5b505afa1580156103ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103d09190810190610f08565b6001600160a01b03161415806103fb57506000818152600360205260409020546001600160a01b0316155b1561040c576000935050505061041c565b50600101610318565b5060019150505b90565b6104276109df565b60055460ff166104495760405162461bcd60e51b81526004016102689061158e565b6005805460ff191690556040517f66993c4cde3b0d56d441001d7731b583158402f0b0531304dfa4d4772c18e50b90600090a1565b610486610a0b565b600061049183610a2d565b905081816001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016104c09190611452565b60206040518083038186803b1580156104d857600080fd5b505afa1580156104ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105109190810190610fde565b101561052e5760405162461bcd60e51b81526004016102689061159e565b610539818484610b53565b505050565b60045490565b60055460ff1681565b6001546001600160a01b031681565b73223cb730b6b4b1a9bcb73a342932b232b2b6b2b960611b81565b6060610581610841565b905060005b81518110156106c957600082828151811061059d57fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016105df9190611439565b6040516020818303038152906040526040518363ffffffff1660e01b815260040161060b92919061150f565b60206040518083038186803b15801561062357600080fd5b505afa158015610637573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061065b9190810190610f08565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68906106b79084908490611501565b60405180910390a15050600101610586565b5050565b6001546001600160a01b031633146106f75760405162461bcd60e51b81526004016102689061155e565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9261073a926001600160a01b039182169291169061149e565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6107716109df565b739d6d846d4546614a7e668e66886624c0ae21d78663907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156107b557600080fd5b505af41580156107c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107ed9190810190610fde565b81111561080c5760405162461bcd60e51b8152600401610268906115ee565b60048190556040517fc4f588c2b1b0db1ae244d5b46f69e0c5962875377386d78b2c9cd5b654f90637906102fc9083906114f3565b60408051600280825260608083018452926020830190803883390190505090506524b9b9bab2b960d11b8160008151811061087857fe5b6020026020010181815250506c45786368616e6765526174657360981b816001815181106108a257fe5b60200260200101818152505090565b6000546001600160a01b031681565b6108c8610a0b565b60005b818110156105395760006108f08484848181106108e457fe5b90506020020135610a2d565b905061098a8185858581811061090257fe5b90506020020135836001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016109359190611452565b60206040518083038186803b15801561094d57600080fd5b505afa158015610961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109859190810190610fde565b610b53565b506001016108cb565b60045481565b6109a1610a0b565b60006109ac82610a2d565b90506106c98183836001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016109359190611452565b6000546001600160a01b03163314610a095760405162461bcd60e51b8152600401610268906115be565b565b60055460ff16610a095760405162461bcd60e51b8152600401610268906115ce565b600080610a38610d2b565b6001600160a01b03166332608039846040518263ffffffff1660e01b8152600401610a6391906114f3565b60206040518083038186803b158015610a7b57600080fd5b505afa158015610a8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610ab39190810190610fc0565b90506001600160a01b038116610adb5760405162461bcd60e51b81526004016102689061156e565b806001600160a01b031663ec5568896040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1457600080fd5b505afa158015610b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b4c9190810190610fc0565b9392505050565b60008111610b735760405162461bcd60e51b81526004016102689061154e565b631cd554d160e21b821415610b9a5760405162461bcd60e51b81526004016102689061157e565b600080610ba5610d44565b6001600160a01b0316630c71cd23856040518263ffffffff1660e01b8152600401610bd091906114f3565b604080518083038186803b158015610be757600080fd5b505afa158015610bfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c1f9190810190610ffc565b915091506000610c3a60045484610d5f90919063ffffffff16565b9050600081118015610c4a575081155b610c665760405162461bcd60e51b8152600401610268906115ae565b6000610c78858363ffffffff610d5f16565b9050610c82610d2b565b6001600160a01b0316630d969cf5338888856040518563ffffffff1660e01b8152600401610cb39493929190611460565b600060405180830381600087803b158015610ccd57600080fd5b505af1158015610ce1573d6000803e3d6000fd5b505050507f8734fd5c7511ef698c61bce7dd8eefb212edea08cf7d9d4694e223c6f6121aef87338784604051610d1a94939291906114b9565b60405180910390a150505050505050565b6000610d3f6524b9b9bab2b960d11b610d7d565b905090565b6000610d3f6c45786368616e6765526174657360981b610d7d565b6000610d748383670de0b6b3a7640000610de1565b90505b92915050565b60008181526003602090815260408083205490516001600160a01b039091169182151591610dad91869101611419565b60405160208183030381529060405290610dda5760405162461bcd60e51b8152600401610268919061153d565b5092915050565b600080600a8304610df8868663ffffffff610e1d16565b81610dff57fe5b0490506005600a820610610e1157600a015b600a9004949350505050565b600082610e2c57506000610d77565b82820282848281610e3957fe5b0414610d745760405162461bcd60e51b8152600401610268906115de565b8035610d7781611692565b8051610d7781611692565b60008083601f840112610e7f57600080fd5b50813567ffffffffffffffff811115610e9757600080fd5b602083019150836020820283011115610eaf57600080fd5b9250929050565b8051610d77816116a9565b8035610d77816116b2565b8051610d77816116bb565b8051610d77816116b2565b600060208284031215610ef457600080fd5b6000610f008484610e57565b949350505050565b600060208284031215610f1a57600080fd5b6000610f008484610e62565b60008060208385031215610f3957600080fd5b823567ffffffffffffffff811115610f5057600080fd5b610f5c85828601610e6d565b92509250509250929050565b600060208284031215610f7a57600080fd5b6000610f008484610ec1565b60008060408385031215610f9957600080fd5b6000610fa58585610ec1565b9250506020610fb685828601610ec1565b9150509250929050565b600060208284031215610fd257600080fd5b6000610f008484610ecc565b600060208284031215610ff057600080fd5b6000610f008484610ed7565b6000806040838503121561100f57600080fd5b600061101b8585610ed7565b9250506020610fb685828601610eb6565b600061103883836110ba565b505060200190565b6110498161164d565b82525050565b61104981611626565b600061106382611614565b61106d8185611618565b93506110788361160e565b8060005b838110156110a6578151611090888261102c565b975061109b8361160e565b92505060010161107c565b509495945050505050565b61104981611631565b6110498161041c565b6110496110cf8261041c565b61041c565b61104981611636565b60006110e882611614565b6110f28185611618565b9350611102818560208601611658565b61110b81611688565b9093019392505050565b6000611122601d83611618565b7f4e6f2062616c616e6365206f662073796e746820746f2072656465656d000000815260200192915050565b600061115b603583611618565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b60006111b2600d83611618565b6c092dcecc2d8d2c840e6f2dce8d609b1b815260200192915050565b60006111db601283611618565b7110d85b9b9bdd081c995919595b481cd554d160721b815260200192915050565b6000611209601483611618565b73149959195b5c1d1a5bdb881cdd5cdc195b99195960621b815260200192915050565b6000611239601483611618565b73496e73756666696369656e742062616c616e636560601b815260200192915050565b6000611269601183611621565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b6000611296601483611618565b7353796e7468206e6f742072656465656d61626c6560601b815260200192915050565b60006112c6602f83611618565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b6000611317601683611618565b75149959195b5c1d1a5bdb8819195858dd1a5d985d195960521b815260200192915050565b6000611349602183611618565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b600061138c601983611621565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b60006113c5600c83611618565b6b496e76616c6964207261746560a01b815260200192915050565b60006113ed601883611618565b7f526564656d7074696f6e206e6f742073757370656e6465640000000000000000815260200192915050565b60006114248261125c565b915061143082846110c3565b50602001919050565b60006114248261137f565b60208101610d77828461104f565b60208101610d778284611040565b6080810161146e8287611040565b61147b60208301866110ba565b61148860408301856110ba565b61149560608301846110ba565b95945050505050565b604081016114ac828561104f565b610b4c602083018461104f565b608081016114c7828761104f565b61147b6020830186611040565b60208082528101610d748184611058565b60208101610d7782846110b1565b60208101610d7782846110ba565b604081016114ac82856110ba565b6040810161151d82856110ba565b8181036020830152610f0081846110dd565b60208101610d7782846110d4565b60208082528101610d7481846110dd565b60208082528101610d7781611115565b60208082528101610d778161114e565b60208082528101610d77816111a5565b60208082528101610d77816111ce565b60208082528101610d77816111fc565b60208082528101610d778161122c565b60208082528101610d7781611289565b60208082528101610d77816112b9565b60208082528101610d778161130a565b60208082528101610d778161133c565b60208082528101610d77816113b8565b60208082528101610d77816113e0565b60200190565b5190565b90815260200190565b919050565b6000610d7782611641565b151590565b6000610d7782611626565b6001600160a01b031690565b6000610d7782611636565b60005b8381101561167357818101518382015260200161165b565b83811115611682576000848401525b50505050565b601f01601f191690565b61169b81611626565b81146116a657600080fd5b50565b61169b81611631565b61169b8161041c565b61169b8161163656fea365627a7a7231582026f3e95beaba5deac1fb6901020b96c4651ae45eb83785f6e010894ffe27cbb66c6578706572696d656e74616cf564736f6c6343000510004000000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9000000000000000000000000b61a6af69e992e1bed69b0ae0cba5143ca25d4d1

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063614d08f8116100a2578063899ffef411610071578063899ffef4146101e35780638da5cb5b146101f857806399845dac14610200578063e6c0e6d514610213578063eda1122c1461021b57610116565b8063614d08f8146101b857806374185360146101c057806379ba5097146101c85780637c69febd146101d057610116565b80632dee8b7e116100e95780632dee8b7e1461016b578063322cd02e146101735780634c74183c146101865780634ecc1f771461019b57806353a47bb7146101a357610116565b806304f3bcec1461011b5780630cd0675c146101395780631627540c146101435780632af64bd314610156575b600080fd5b61012361022e565b604051610130919061152f565b60405180910390f35b61014161023d565b005b610141610151366004610ee2565b6102a9565b61015e610307565b60405161013091906114e5565b61014161041f565b610141610181366004610f86565b61047e565b61018e61053e565b60405161013091906114f3565b61015e610544565b6101ab61054d565b6040516101309190611444565b61018e61055c565b610141610577565b6101416106cd565b6101416101de366004610f68565b610769565b6101eb610841565b60405161013091906114d4565b6101ab6108b1565b61014161020e366004610f26565b6108c0565b61018e610993565b610141610229366004610f68565b610999565b6002546001600160a01b031681565b6102456109df565b60055460ff16156102715760405162461bcd60e51b8152600401610268906115fe565b60405180910390fd5b6005805460ff191660011790556040517f7a2913cddb07686623e9d442b08e598f63153b82d934cb6c5e09e6b0652c221f90600090a1565b6102b16109df565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906102fc908390611444565b60405180910390a150565b60006060610313610841565b905060005b815181101561041557600082828151811061032f57fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a721906103809085906004016114f3565b60206040518083038186803b15801561039857600080fd5b505afa1580156103ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103d09190810190610f08565b6001600160a01b03161415806103fb57506000818152600360205260409020546001600160a01b0316155b1561040c576000935050505061041c565b50600101610318565b5060019150505b90565b6104276109df565b60055460ff166104495760405162461bcd60e51b81526004016102689061158e565b6005805460ff191690556040517f66993c4cde3b0d56d441001d7731b583158402f0b0531304dfa4d4772c18e50b90600090a1565b610486610a0b565b600061049183610a2d565b905081816001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016104c09190611452565b60206040518083038186803b1580156104d857600080fd5b505afa1580156104ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105109190810190610fde565b101561052e5760405162461bcd60e51b81526004016102689061159e565b610539818484610b53565b505050565b60045490565b60055460ff1681565b6001546001600160a01b031681565b73223cb730b6b4b1a9bcb73a342932b232b2b6b2b960611b81565b6060610581610841565b905060005b81518110156106c957600082828151811061059d57fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016105df9190611439565b6040516020818303038152906040526040518363ffffffff1660e01b815260040161060b92919061150f565b60206040518083038186803b15801561062357600080fd5b505afa158015610637573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061065b9190810190610f08565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68906106b79084908490611501565b60405180910390a15050600101610586565b5050565b6001546001600160a01b031633146106f75760405162461bcd60e51b81526004016102689061155e565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9261073a926001600160a01b039182169291169061149e565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6107716109df565b739d6d846d4546614a7e668e66886624c0ae21d78663907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156107b557600080fd5b505af41580156107c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107ed9190810190610fde565b81111561080c5760405162461bcd60e51b8152600401610268906115ee565b60048190556040517fc4f588c2b1b0db1ae244d5b46f69e0c5962875377386d78b2c9cd5b654f90637906102fc9083906114f3565b60408051600280825260608083018452926020830190803883390190505090506524b9b9bab2b960d11b8160008151811061087857fe5b6020026020010181815250506c45786368616e6765526174657360981b816001815181106108a257fe5b60200260200101818152505090565b6000546001600160a01b031681565b6108c8610a0b565b60005b818110156105395760006108f08484848181106108e457fe5b90506020020135610a2d565b905061098a8185858581811061090257fe5b90506020020135836001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016109359190611452565b60206040518083038186803b15801561094d57600080fd5b505afa158015610961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109859190810190610fde565b610b53565b506001016108cb565b60045481565b6109a1610a0b565b60006109ac82610a2d565b90506106c98183836001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016109359190611452565b6000546001600160a01b03163314610a095760405162461bcd60e51b8152600401610268906115be565b565b60055460ff16610a095760405162461bcd60e51b8152600401610268906115ce565b600080610a38610d2b565b6001600160a01b03166332608039846040518263ffffffff1660e01b8152600401610a6391906114f3565b60206040518083038186803b158015610a7b57600080fd5b505afa158015610a8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610ab39190810190610fc0565b90506001600160a01b038116610adb5760405162461bcd60e51b81526004016102689061156e565b806001600160a01b031663ec5568896040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1457600080fd5b505afa158015610b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b4c9190810190610fc0565b9392505050565b60008111610b735760405162461bcd60e51b81526004016102689061154e565b631cd554d160e21b821415610b9a5760405162461bcd60e51b81526004016102689061157e565b600080610ba5610d44565b6001600160a01b0316630c71cd23856040518263ffffffff1660e01b8152600401610bd091906114f3565b604080518083038186803b158015610be757600080fd5b505afa158015610bfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c1f9190810190610ffc565b915091506000610c3a60045484610d5f90919063ffffffff16565b9050600081118015610c4a575081155b610c665760405162461bcd60e51b8152600401610268906115ae565b6000610c78858363ffffffff610d5f16565b9050610c82610d2b565b6001600160a01b0316630d969cf5338888856040518563ffffffff1660e01b8152600401610cb39493929190611460565b600060405180830381600087803b158015610ccd57600080fd5b505af1158015610ce1573d6000803e3d6000fd5b505050507f8734fd5c7511ef698c61bce7dd8eefb212edea08cf7d9d4694e223c6f6121aef87338784604051610d1a94939291906114b9565b60405180910390a150505050505050565b6000610d3f6524b9b9bab2b960d11b610d7d565b905090565b6000610d3f6c45786368616e6765526174657360981b610d7d565b6000610d748383670de0b6b3a7640000610de1565b90505b92915050565b60008181526003602090815260408083205490516001600160a01b039091169182151591610dad91869101611419565b60405160208183030381529060405290610dda5760405162461bcd60e51b8152600401610268919061153d565b5092915050565b600080600a8304610df8868663ffffffff610e1d16565b81610dff57fe5b0490506005600a820610610e1157600a015b600a9004949350505050565b600082610e2c57506000610d77565b82820282848281610e3957fe5b0414610d745760405162461bcd60e51b8152600401610268906115de565b8035610d7781611692565b8051610d7781611692565b60008083601f840112610e7f57600080fd5b50813567ffffffffffffffff811115610e9757600080fd5b602083019150836020820283011115610eaf57600080fd5b9250929050565b8051610d77816116a9565b8035610d77816116b2565b8051610d77816116bb565b8051610d77816116b2565b600060208284031215610ef457600080fd5b6000610f008484610e57565b949350505050565b600060208284031215610f1a57600080fd5b6000610f008484610e62565b60008060208385031215610f3957600080fd5b823567ffffffffffffffff811115610f5057600080fd5b610f5c85828601610e6d565b92509250509250929050565b600060208284031215610f7a57600080fd5b6000610f008484610ec1565b60008060408385031215610f9957600080fd5b6000610fa58585610ec1565b9250506020610fb685828601610ec1565b9150509250929050565b600060208284031215610fd257600080fd5b6000610f008484610ecc565b600060208284031215610ff057600080fd5b6000610f008484610ed7565b6000806040838503121561100f57600080fd5b600061101b8585610ed7565b9250506020610fb685828601610eb6565b600061103883836110ba565b505060200190565b6110498161164d565b82525050565b61104981611626565b600061106382611614565b61106d8185611618565b93506110788361160e565b8060005b838110156110a6578151611090888261102c565b975061109b8361160e565b92505060010161107c565b509495945050505050565b61104981611631565b6110498161041c565b6110496110cf8261041c565b61041c565b61104981611636565b60006110e882611614565b6110f28185611618565b9350611102818560208601611658565b61110b81611688565b9093019392505050565b6000611122601d83611618565b7f4e6f2062616c616e6365206f662073796e746820746f2072656465656d000000815260200192915050565b600061115b603583611618565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b60006111b2600d83611618565b6c092dcecc2d8d2c840e6f2dce8d609b1b815260200192915050565b60006111db601283611618565b7110d85b9b9bdd081c995919595b481cd554d160721b815260200192915050565b6000611209601483611618565b73149959195b5c1d1a5bdb881cdd5cdc195b99195960621b815260200192915050565b6000611239601483611618565b73496e73756666696369656e742062616c616e636560601b815260200192915050565b6000611269601183611621565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b6000611296601483611618565b7353796e7468206e6f742072656465656d61626c6560601b815260200192915050565b60006112c6602f83611618565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b6000611317601683611618565b75149959195b5c1d1a5bdb8819195858dd1a5d985d195960521b815260200192915050565b6000611349602183611618565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b600061138c601983611621565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b60006113c5600c83611618565b6b496e76616c6964207261746560a01b815260200192915050565b60006113ed601883611618565b7f526564656d7074696f6e206e6f742073757370656e6465640000000000000000815260200192915050565b60006114248261125c565b915061143082846110c3565b50602001919050565b60006114248261137f565b60208101610d77828461104f565b60208101610d778284611040565b6080810161146e8287611040565b61147b60208301866110ba565b61148860408301856110ba565b61149560608301846110ba565b95945050505050565b604081016114ac828561104f565b610b4c602083018461104f565b608081016114c7828761104f565b61147b6020830186611040565b60208082528101610d748184611058565b60208101610d7782846110b1565b60208101610d7782846110ba565b604081016114ac82856110ba565b6040810161151d82856110ba565b8181036020830152610f0081846110dd565b60208101610d7782846110d4565b60208082528101610d7481846110dd565b60208082528101610d7781611115565b60208082528101610d778161114e565b60208082528101610d77816111a5565b60208082528101610d77816111ce565b60208082528101610d77816111fc565b60208082528101610d778161122c565b60208082528101610d7781611289565b60208082528101610d77816112b9565b60208082528101610d778161130a565b60208082528101610d778161133c565b60208082528101610d77816113b8565b60208082528101610d77816113e0565b60200190565b5190565b90815260200190565b919050565b6000610d7782611641565b151590565b6000610d7782611626565b6001600160a01b031690565b6000610d7782611636565b60005b8381101561167357818101518382015260200161165b565b83811115611682576000848401525b50505050565b601f01601f191690565b61169b81611626565b81146116a657600080fd5b50565b61169b81611631565b61169b8161041c565b61169b8161163656fea365627a7a7231582026f3e95beaba5deac1fb6901020b96c4651ae45eb83785f6e010894ffe27cbb66c6578706572696d656e74616cf564736f6c63430005100040

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

00000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9000000000000000000000000b61a6af69e992e1bed69b0ae0cba5143ca25d4d1

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

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9
Arg [1] : 000000000000000000000000b61a6af69e992e1bed69b0ae0cba5143ca25d4d1


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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