Sepolia Testnet

Contract

0x1f6Eba1Ac6a62df62edC54159A05711636b33D4C

Overview

ETH Balance

0 ETH

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value
0x6080604054872392024-03-14 23:30:2496 days ago1710459024IN
 Create: VirtualSynthMastercopy
0 ETH0.000168180.12412894

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

Contract Source Code Verified (Exact Match)

Contract Name:
VirtualSynthMastercopy

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-03-15
*/

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

* Synthetix: VirtualSynthMastercopy.sol
*
* Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/VirtualSynthMastercopy.sol
* Docs: https://docs.synthetix.io/contracts/VirtualSynthMastercopy
*
* Contract Dependencies: 
*	- ERC20
*	- IERC20
*	- IVirtualSynth
*	- VirtualSynth
* 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.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
 * the optional functions; to access them see `ERC20Detailed`.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a `Transfer` event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through `transferFrom`. This is
     * zero by default.
     *
     * This value changes when `approve` or `transferFrom` are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * > Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an `Approval` event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a `Transfer` event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to `approve`. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}


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

        return c;
    }

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

        return c;
    }

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

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

        return c;
    }

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

        return c;
    }

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


/**
 * @dev Implementation of the `IERC20` interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using `_mint`.
 * For a generic mechanism see `ERC20Mintable`.
 *
 * *For a detailed writeup see our guide [How to implement supply
 * mechanisms](https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226).*
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an `Approval` event is emitted on calls to `transferFrom`.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard `decreaseAllowance` and `increaseAllowance`
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See `IERC20.approve`.
 */
contract ERC20 is IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    /**
     * @dev See `IERC20.totalSupply`.
     */
    function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See `IERC20.balanceOf`.
     */
    function balanceOf(address account) public view returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See `IERC20.transfer`.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public returns (bool) {
        _transfer(msg.sender, recipient, amount);
        return true;
    }

    /**
     * @dev See `IERC20.allowance`.
     */
    function allowance(address owner, address spender) public view returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See `IERC20.approve`.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public returns (bool) {
        _approve(msg.sender, spender, value);
        return true;
    }

    /**
     * @dev See `IERC20.transferFrom`.
     *
     * Emits an `Approval` event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of `ERC20`;
     *
     * Requirements:
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `value`.
     * - the caller must have allowance for `sender`'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to `approve` that can be used as a mitigation for
     * problems described in `IERC20.approve`.
     *
     * Emits an `Approval` event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
        _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to `approve` that can be used as a mitigation for
     * problems described in `IERC20.approve`.
     *
     * Emits an `Approval` event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
        _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to `transfer`, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a `Transfer` event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _balances[sender] = _balances[sender].sub(amount);
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a `Transfer` event with `from` set to the zero address.
     *
     * Requirements
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal {
        require(account != address(0), "ERC20: mint to the zero address");

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

     /**
     * @dev Destoys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a `Transfer` event with `to` set to the zero address.
     *
     * Requirements
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 value) internal {
        require(account != address(0), "ERC20: burn from the zero address");

        _totalSupply = _totalSupply.sub(value);
        _balances[account] = _balances[account].sub(value);
        emit Transfer(account, address(0), value);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
     *
     * This is internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an `Approval` event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = value;
        emit Approval(owner, spender, value);
    }

    /**
     * @dev Destoys `amount` tokens from `account`.`amount` is then deducted
     * from the caller's allowance.
     *
     * See `_burn` and `_approve`.
     */
    function _burnFrom(address account, uint256 amount) internal {
        _burn(account, amount);
        _approve(account, msg.sender, _allowances[account][msg.sender].sub(amount));
    }
}


// Libraries


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

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

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

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

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

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

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

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

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

        return quotientTimesTen / 10;
    }

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

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

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

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

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

        return resultTimesTen / 10;
    }

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

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

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

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

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

        return quotientTimesTen / 10;
    }

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

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

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


// https://docs.synthetix.io/contracts/source/interfaces/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/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);
}


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

    function rate() external view returns (uint);

    function readyToSettle() external view returns (bool);

    function secsLeftInWaitingPeriod() external view returns (uint);

    function settled() external view returns (bool);

    function synth() external view returns (ISynth);

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


pragma experimental ABIEncoderV2;


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

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

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

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

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

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

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

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

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

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

    function priceDeviationThresholdFactor() external view returns (uint);

    function waitingPeriodSecs() external view returns (uint);

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

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

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

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

// Used to have strongly-typed access to internal mutative functions in Synthetix
interface ISynthetixInternal {
    function emitExchangeTracking(
        bytes32 trackingCode,
        bytes32 toCurrencyKey,
        uint256 toAmount,
        uint256 fee
    ) external;

    function emitSynthExchange(
        address account,
        bytes32 fromCurrencyKey,
        uint fromAmount,
        bytes32 toCurrencyKey,
        uint toAmount,
        address toAddress
    ) external;

    function emitAtomicSynthExchange(
        address account,
        bytes32 fromCurrencyKey,
        uint fromAmount,
        bytes32 toCurrencyKey,
        uint toAmount,
        address toAddress
    ) external;

    function emitExchangeReclaim(
        address account,
        bytes32 currencyKey,
        uint amount
    ) external;

    function emitExchangeRebate(
        address account,
        bytes32 currencyKey,
        uint amount
    ) external;
}

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

    function updateCachedSynthDebts(bytes32[] calldata currencyKeys) external;
}


// Inheritance


// Libraries


// Internal references


// https://docs.synthetix.io/contracts/source/contracts/virtualsynth
// Note: this contract should be treated as an abstract contract and should not be directly deployed.
//       On higher versions of solidity, it would be marked with the `abstract` keyword.
//       This contracts implements logic that is only intended to be accessed behind a proxy.
//       For the deployed "mastercopy" version, see VirtualSynthMastercopy.
contract VirtualSynth is ERC20, IVirtualSynth {
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    IERC20 public synth;
    IAddressResolver public resolver;

    bool public settled = false;

    uint8 public constant decimals = 18;

    // track initial supply so we can calculate the rate even after all supply is burned
    uint public initialSupply;

    // track final settled amount of the synth so we can calculate the rate after settlement
    uint public settledAmount;

    bytes32 public currencyKey;

    bool public initialized = false;

    function initialize(
        IERC20 _synth,
        IAddressResolver _resolver,
        address _recipient,
        uint _amount,
        bytes32 _currencyKey
    ) external {
        require(!initialized, "vSynth already initialized");
        initialized = true;

        synth = _synth;
        resolver = _resolver;
        currencyKey = _currencyKey;

        // Assumption: the synth will be issued to us within the same transaction,
        // and this supply matches that
        _mint(_recipient, _amount);

        initialSupply = _amount;

        // Note: the ERC20 base contract does not have a constructor, so we do not have to worry
        // about initializing its state separately
    }

    // INTERNALS

    function exchanger() internal view returns (IExchanger) {
        return IExchanger(resolver.requireAndGetAddress("Exchanger", "Exchanger contract not found"));
    }

    function secsLeft() internal view returns (uint) {
        return exchanger().maxSecsLeftInWaitingPeriod(address(this), currencyKey);
    }

    function calcRate() internal view returns (uint) {
        if (initialSupply == 0) {
            return 0;
        }

        uint synthBalance;

        if (!settled) {
            synthBalance = IERC20(address(synth)).balanceOf(address(this));
            (uint reclaim, uint rebate, ) = exchanger().settlementOwing(address(this), currencyKey);

            if (reclaim > 0) {
                synthBalance = synthBalance.sub(reclaim);
            } else if (rebate > 0) {
                synthBalance = synthBalance.add(rebate);
            }
        } else {
            synthBalance = settledAmount;
        }

        return synthBalance.divideDecimalRound(initialSupply);
    }

    function balanceUnderlying(address account) internal view returns (uint) {
        uint vBalanceOfAccount = balanceOf(account);

        return vBalanceOfAccount.multiplyDecimalRound(calcRate());
    }

    function settleSynth() internal {
        if (settled) {
            return;
        }
        settled = true;

        exchanger().settle(address(this), currencyKey);

        settledAmount = IERC20(address(synth)).balanceOf(address(this));

        emit Settled(totalSupply(), settledAmount);
    }

    // VIEWS

    function name() external view returns (string memory) {
        return string(abi.encodePacked("Virtual Synth ", currencyKey));
    }

    function symbol() external view returns (string memory) {
        return string(abi.encodePacked("v", currencyKey));
    }

    // get the rate of the vSynth to the synth.
    function rate() external view returns (uint) {
        return calcRate();
    }

    // show the balance of the underlying synth that the given address has, given
    // their proportion of totalSupply
    function balanceOfUnderlying(address account) external view returns (uint) {
        return balanceUnderlying(account);
    }

    function secsLeftInWaitingPeriod() external view returns (uint) {
        return secsLeft();
    }

    function readyToSettle() external view returns (bool) {
        return secsLeft() == 0;
    }

    // PUBLIC FUNCTIONS

    // Perform settlement of the underlying exchange if required,
    // then burn the accounts vSynths and transfer them their owed balanceOfUnderlying
    function settle(address account) external {
        settleSynth();

        IERC20(address(synth)).transfer(account, balanceUnderlying(account));

        _burn(account, balanceOf(account));
    }

    event Settled(uint totalSupply, uint amountAfterSettled);
}


// https://docs.synthetix.io/contracts/source/contracts/virtualsynthmastercopy
// Note: this is the "frozen" mastercopy of the VirtualSynth contract that should be linked to from
//       proxies.
contract VirtualSynthMastercopy is VirtualSynth {
    constructor() public ERC20() {
        // Freeze mastercopy on deployment so it can never be initialized with real arguments
        initialized = true;
    }
}

Contract ABI

[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalSupply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountAfterSettled","type":"uint256"}],"name":"Settled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOfUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currencyKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"initialSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract IERC20","name":"_synth","type":"address"},{"internalType":"contract IAddressResolver","name":"_resolver","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes32","name":"_currencyKey","type":"bytes32"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"readyToSettle","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"resolver","outputs":[{"internalType":"contract IAddressResolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"secsLeftInWaitingPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"settle","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"settled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"settledAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"synth","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]

60806040526004805460ff60a01b191690556008805460ff1916905534801561002757600080fd5b506008805460ff19166001179055611716806100446000396000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c80633db3dc9b116100c35780638f7758391161007c5780638f7758391461028657806395d89b411461028e578063a457c2d714610296578063a9059cbb146102a9578063dbd06c85146102bc578063dd62ed3e146102c457610158565b80633db3dc9b146102335780634be37cea1461023b5780636a256b291461024357806370a082311461025857806378f2ac261461026b5780638d7017d31461027357610158565b806323b872dd1161011557806323b872dd146101d55780632c4e722e146101e8578063313ce567146101f0578063378dc3dc14610205578063395093511461020d5780633af9e6691461022057610158565b806304f3bcec1461015d57806306fdde031461017b578063095ea7b314610190578063115f4fee146101b0578063158ef93e146101b857806318160ddd146101c0575b600080fd5b6101656102d7565b6040516101729190611522565b60405180910390f35b6101836102e6565b6040516101729190611530565b6101a361019e366004610fc8565b610310565b6040516101729190611506565b610165610327565b6101a3610336565b6101c861033f565b6040516101729190611514565b6101a36101e3366004610f7b565b610345565b6101c861039d565b6101f86103ac565b604051610172919061161d565b6101c86103b1565b6101a361021b366004610fc8565b6103b7565b6101c861022e366004610efd565b6103f3565b6101c86103fe565b6101c8610404565b610256610251366004610efd565b61040e565b005b6101c8610266366004610efd565b6104b6565b6101a36104d1565b610256610281366004611016565b6104e1565b6101a3610562565b610183610572565b6101a36102a4366004610fc8565b610587565b6101a36102b7366004610fc8565b6105c3565b6101c86105d0565b6101c86102d2366004610f41565b6105d6565b6004546001600160a01b031681565b60606007546040516020016102fb91906114b2565b60405160208183030381529060405290505b90565b600061031d338484610601565b5060015b92915050565b6003546001600160a01b031681565b60085460ff1681565b60025490565b60006103528484846106b5565b6001600160a01b03841660009081526001602090815260408083203380855292529091205461039291869161038d908663ffffffff6107b116565b610601565b5060015b9392505050565b60006103a76107d9565b905090565b601281565b60055481565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161031d91859061038d908663ffffffff61097016565b600061032182610995565b60065481565b60006103a76109bb565b610416610a44565b6003546001600160a01b031663a9059cbb8261043181610995565b6040518363ffffffff1660e01b815260040161044e9291906114eb565b602060405180830381600087803b15801561046857600080fd5b505af115801561047c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104a09190810190610ff8565b506104b3816104ae836104b6565b610bc2565b50565b6001600160a01b031660009081526020819052604090205490565b60006104db6109bb565b15905090565b60085460ff161561050d5760405162461bcd60e51b815260040161050490611591565b60405180910390fd5b6008805460ff19166001179055600380546001600160a01b038088166001600160a01b031992831617909255600480549287169290911691909117905560078190556105598383610c7f565b50600555505050565b600454600160a01b900460ff1681565b60606007546040516020016102fb91906114d2565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161031d91859061038d908663ffffffff6107b116565b600061031d3384846106b5565b60075481565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166106275760405162461bcd60e51b8152600401610504906115ef565b6001600160a01b03821661064d5760405162461bcd60e51b815260040161050490611551565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906106a8908590611514565b60405180910390a3505050565b6001600160a01b0383166106db5760405162461bcd60e51b8152600401610504906115df565b6001600160a01b0382166107015760405162461bcd60e51b815260040161050490611541565b6001600160a01b03831660009081526020819052604090205461072a908263ffffffff6107b116565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461075f908263ffffffff61097016565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906106a8908590611514565b6000828211156107d35760405162461bcd60e51b815260040161050490611571565b50900390565b6000600554600014156107ee5750600061030d565b600454600090600160a01b900460ff16610951576003546040516370a0823160e01b81526001600160a01b03909116906370a08231906108329030906004016114dd565b60206040518083038186803b15801561084a57600080fd5b505afa15801561085e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610882919081019061108b565b905060008061088f610d33565b6001600160a01b03166319d5c665306007546040518363ffffffff1660e01b81526004016108be9291906114eb565b60606040518083038186803b1580156108d657600080fd5b505afa1580156108ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061090e91908101906110a9565b50909250905081156109315761092a838363ffffffff6107b116565b925061094a565b801561094a57610947838263ffffffff61097016565b92505b5050610956565b506006545b60055461096a90829063ffffffff610db316565b91505090565b6000828201838110156103965760405162461bcd60e51b815260040161050490611561565b6000806109a1836104b6565b90506103966109ae6107d9565b829063ffffffff610dc816565b60006109c5610d33565b6001600160a01b031663059c29ec306007546040518363ffffffff1660e01b81526004016109f49291906114eb565b60206040518083038186803b158015610a0c57600080fd5b505afa158015610a20573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103a7919081019061108b565b600454600160a01b900460ff1615610a5b57610bc0565b6004805460ff60a01b1916600160a01b179055610a76610d33565b6001600160a01b0316631b16802c306007546040518363ffffffff1660e01b8152600401610aa59291906114eb565b606060405180830381600087803b158015610abf57600080fd5b505af1158015610ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610af791908101906110a9565b50506003546040516370a0823160e01b81526001600160a01b0390911691506370a0823190610b2a9030906004016114dd565b60206040518083038186803b158015610b4257600080fd5b505afa158015610b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b7a919081019061108b565b6006557ff5b268a3ff315cc44ccceeef86259c9e8eef81ceecb14001543809115380dd62610ba661033f565b600654604051610bb792919061160f565b60405180910390a15b565b6001600160a01b038216610be85760405162461bcd60e51b8152600401610504906115cf565b600254610bfb908263ffffffff6107b116565b6002556001600160a01b038216600090815260208190526040902054610c27908263ffffffff6107b116565b6001600160a01b0383166000818152602081905260408082209390935591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610c73908590611514565b60405180910390a35050565b6001600160a01b038216610ca55760405162461bcd60e51b8152600401610504906115ff565b600254610cb8908263ffffffff61097016565b6002556001600160a01b038216600090815260208190526040902054610ce4908263ffffffff61097016565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610c73908590611514565b6004805460405163dacb2d0160e01b81526000926001600160a01b039092169163dacb2d0191610d6391016115b1565b60206040518083038186803b158015610d7b57600080fd5b505afa158015610d8f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103a79190810190610f23565b60006103968383670de0b6b3a7640000610ddd565b60006103968383670de0b6b3a7640000610e21565b600080610e0384610df787600a870263ffffffff610e4c16565b9063ffffffff610e8616565b90506005600a825b0610610e1557600a015b600a9004949350505050565b600080600a8304610e38868663ffffffff610e4c16565b81610e3f57fe5b0490506005600a82610e0b565b600082610e5b57506000610321565b82820282848281610e6857fe5b04146103965760405162461bcd60e51b8152600401610504906115a1565b6000808211610ea75760405162461bcd60e51b815260040161050490611581565b6000828481610eb257fe5b04949350505050565b8035610321816116a4565b8051610321816116a4565b8051610321816116b8565b8035610321816116c1565b8035610321816116ca565b8051610321816116c1565b600060208284031215610f0f57600080fd5b6000610f1b8484610ebb565b949350505050565b600060208284031215610f3557600080fd5b6000610f1b8484610ec6565b60008060408385031215610f5457600080fd5b6000610f608585610ebb565b9250506020610f7185828601610ebb565b9150509250929050565b600080600060608486031215610f9057600080fd5b6000610f9c8686610ebb565b9350506020610fad86828701610ebb565b9250506040610fbe86828701610edc565b9150509250925092565b60008060408385031215610fdb57600080fd5b6000610fe78585610ebb565b9250506020610f7185828601610edc565b60006020828403121561100a57600080fd5b6000610f1b8484610ed1565b600080600080600060a0868803121561102e57600080fd5b600061103a8888610ee7565b955050602061104b88828901610ee7565b945050604061105c88828901610ebb565b935050606061106d88828901610edc565b925050608061107e88828901610edc565b9150509295509295909350565b60006020828403121561109d57600080fd5b6000610f1b8484610ef2565b6000806000606084860312156110be57600080fd5b60006110ca8686610ef2565b93505060206110db86828701610ef2565b9250506040610fbe86828701610ef2565b6110f58161163d565b82525050565b6110f581611648565b6110f58161030d565b6110f56111198261030d565b61030d565b6110f58161164d565b60006111328261162b565b61113c818561162f565b935061114c81856020860161166a565b6111558161169a565b9093019392505050565b600061116c60238361162f565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647281526265737360e81b602082015260400192915050565b60006111b160228361162f565b7f45524332303a20617070726f766520746f20746865207a65726f206164647265815261737360f01b602082015260400192915050565b60006111f5601b8361162f565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061122e601e8361162f565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b6000611267600e83611638565b6d02b34b93a3ab0b61029bcb73a34160951b8152600e0192915050565b6000611291601a8361162f565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006112ca601a8361162f565b7f7653796e746820616c726561647920696e697469616c697a6564000000000000815260200192915050565b600061130360218361162f565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6822bc31b430b733b2b960b91b9052565b6000611357600183611638565b603b60f91b815260010192915050565b600061137460218361162f565b7f45524332303a206275726e2066726f6d20746865207a65726f206164647265738152607360f81b602082015260400192915050565b60006113b760258361162f565b7f45524332303a207472616e736665722066726f6d20746865207a65726f206164815264647265737360d81b602082015260400192915050565b60006113fe60248361162f565b7f45524332303a20617070726f76652066726f6d20746865207a65726f206164648152637265737360e01b602082015260400192915050565b6000611444601c8361162f565b7f45786368616e67657220636f6e7472616374206e6f7420666f756e6400000000815260200192915050565b600061147d601f8361162f565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300815260200192915050565b6110f581611664565b60006114bd8261125a565b91506114c9828461110d565b50602001919050565b60006114bd8261134a565b6020810161032182846110ec565b604081016114f982856110ec565b6103966020830184611104565b6020810161032182846110fb565b602081016103218284611104565b60208101610321828461111e565b602080825281016103968184611127565b602080825281016103218161115f565b60208082528101610321816111a4565b60208082528101610321816111e8565b6020808252810161032181611221565b6020808252810161032181611284565b60208082528101610321816112bd565b60208082528101610321816112f6565b604081016115be82611339565b818103602083015261032181611437565b6020808252810161032181611367565b60208082528101610321816113aa565b60208082528101610321816113f1565b6020808252810161032181611470565b604081016114f98285611104565b6020810161032182846114a9565b5190565b90815260200190565b919050565b600061032182611658565b151590565b60006103218261163d565b6001600160a01b031690565b60ff1690565b60005b8381101561168557818101518382015260200161166d565b83811115611694576000848401525b50505050565b601f01601f191690565b6116ad8161163d565b81146104b357600080fd5b6116ad81611648565b6116ad8161030d565b6116ad8161164d56fea365627a7a72315820e6c2353be4ddd2d7ca4e27736eb0be03db9b522e022a1d4f80f98de3f3363e8f6c6578706572696d656e74616cf564736f6c63430005100040

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101585760003560e01c80633db3dc9b116100c35780638f7758391161007c5780638f7758391461028657806395d89b411461028e578063a457c2d714610296578063a9059cbb146102a9578063dbd06c85146102bc578063dd62ed3e146102c457610158565b80633db3dc9b146102335780634be37cea1461023b5780636a256b291461024357806370a082311461025857806378f2ac261461026b5780638d7017d31461027357610158565b806323b872dd1161011557806323b872dd146101d55780632c4e722e146101e8578063313ce567146101f0578063378dc3dc14610205578063395093511461020d5780633af9e6691461022057610158565b806304f3bcec1461015d57806306fdde031461017b578063095ea7b314610190578063115f4fee146101b0578063158ef93e146101b857806318160ddd146101c0575b600080fd5b6101656102d7565b6040516101729190611522565b60405180910390f35b6101836102e6565b6040516101729190611530565b6101a361019e366004610fc8565b610310565b6040516101729190611506565b610165610327565b6101a3610336565b6101c861033f565b6040516101729190611514565b6101a36101e3366004610f7b565b610345565b6101c861039d565b6101f86103ac565b604051610172919061161d565b6101c86103b1565b6101a361021b366004610fc8565b6103b7565b6101c861022e366004610efd565b6103f3565b6101c86103fe565b6101c8610404565b610256610251366004610efd565b61040e565b005b6101c8610266366004610efd565b6104b6565b6101a36104d1565b610256610281366004611016565b6104e1565b6101a3610562565b610183610572565b6101a36102a4366004610fc8565b610587565b6101a36102b7366004610fc8565b6105c3565b6101c86105d0565b6101c86102d2366004610f41565b6105d6565b6004546001600160a01b031681565b60606007546040516020016102fb91906114b2565b60405160208183030381529060405290505b90565b600061031d338484610601565b5060015b92915050565b6003546001600160a01b031681565b60085460ff1681565b60025490565b60006103528484846106b5565b6001600160a01b03841660009081526001602090815260408083203380855292529091205461039291869161038d908663ffffffff6107b116565b610601565b5060015b9392505050565b60006103a76107d9565b905090565b601281565b60055481565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161031d91859061038d908663ffffffff61097016565b600061032182610995565b60065481565b60006103a76109bb565b610416610a44565b6003546001600160a01b031663a9059cbb8261043181610995565b6040518363ffffffff1660e01b815260040161044e9291906114eb565b602060405180830381600087803b15801561046857600080fd5b505af115801561047c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104a09190810190610ff8565b506104b3816104ae836104b6565b610bc2565b50565b6001600160a01b031660009081526020819052604090205490565b60006104db6109bb565b15905090565b60085460ff161561050d5760405162461bcd60e51b815260040161050490611591565b60405180910390fd5b6008805460ff19166001179055600380546001600160a01b038088166001600160a01b031992831617909255600480549287169290911691909117905560078190556105598383610c7f565b50600555505050565b600454600160a01b900460ff1681565b60606007546040516020016102fb91906114d2565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161031d91859061038d908663ffffffff6107b116565b600061031d3384846106b5565b60075481565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166106275760405162461bcd60e51b8152600401610504906115ef565b6001600160a01b03821661064d5760405162461bcd60e51b815260040161050490611551565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906106a8908590611514565b60405180910390a3505050565b6001600160a01b0383166106db5760405162461bcd60e51b8152600401610504906115df565b6001600160a01b0382166107015760405162461bcd60e51b815260040161050490611541565b6001600160a01b03831660009081526020819052604090205461072a908263ffffffff6107b116565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461075f908263ffffffff61097016565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906106a8908590611514565b6000828211156107d35760405162461bcd60e51b815260040161050490611571565b50900390565b6000600554600014156107ee5750600061030d565b600454600090600160a01b900460ff16610951576003546040516370a0823160e01b81526001600160a01b03909116906370a08231906108329030906004016114dd565b60206040518083038186803b15801561084a57600080fd5b505afa15801561085e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610882919081019061108b565b905060008061088f610d33565b6001600160a01b03166319d5c665306007546040518363ffffffff1660e01b81526004016108be9291906114eb565b60606040518083038186803b1580156108d657600080fd5b505afa1580156108ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061090e91908101906110a9565b50909250905081156109315761092a838363ffffffff6107b116565b925061094a565b801561094a57610947838263ffffffff61097016565b92505b5050610956565b506006545b60055461096a90829063ffffffff610db316565b91505090565b6000828201838110156103965760405162461bcd60e51b815260040161050490611561565b6000806109a1836104b6565b90506103966109ae6107d9565b829063ffffffff610dc816565b60006109c5610d33565b6001600160a01b031663059c29ec306007546040518363ffffffff1660e01b81526004016109f49291906114eb565b60206040518083038186803b158015610a0c57600080fd5b505afa158015610a20573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103a7919081019061108b565b600454600160a01b900460ff1615610a5b57610bc0565b6004805460ff60a01b1916600160a01b179055610a76610d33565b6001600160a01b0316631b16802c306007546040518363ffffffff1660e01b8152600401610aa59291906114eb565b606060405180830381600087803b158015610abf57600080fd5b505af1158015610ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610af791908101906110a9565b50506003546040516370a0823160e01b81526001600160a01b0390911691506370a0823190610b2a9030906004016114dd565b60206040518083038186803b158015610b4257600080fd5b505afa158015610b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b7a919081019061108b565b6006557ff5b268a3ff315cc44ccceeef86259c9e8eef81ceecb14001543809115380dd62610ba661033f565b600654604051610bb792919061160f565b60405180910390a15b565b6001600160a01b038216610be85760405162461bcd60e51b8152600401610504906115cf565b600254610bfb908263ffffffff6107b116565b6002556001600160a01b038216600090815260208190526040902054610c27908263ffffffff6107b116565b6001600160a01b0383166000818152602081905260408082209390935591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610c73908590611514565b60405180910390a35050565b6001600160a01b038216610ca55760405162461bcd60e51b8152600401610504906115ff565b600254610cb8908263ffffffff61097016565b6002556001600160a01b038216600090815260208190526040902054610ce4908263ffffffff61097016565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610c73908590611514565b6004805460405163dacb2d0160e01b81526000926001600160a01b039092169163dacb2d0191610d6391016115b1565b60206040518083038186803b158015610d7b57600080fd5b505afa158015610d8f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103a79190810190610f23565b60006103968383670de0b6b3a7640000610ddd565b60006103968383670de0b6b3a7640000610e21565b600080610e0384610df787600a870263ffffffff610e4c16565b9063ffffffff610e8616565b90506005600a825b0610610e1557600a015b600a9004949350505050565b600080600a8304610e38868663ffffffff610e4c16565b81610e3f57fe5b0490506005600a82610e0b565b600082610e5b57506000610321565b82820282848281610e6857fe5b04146103965760405162461bcd60e51b8152600401610504906115a1565b6000808211610ea75760405162461bcd60e51b815260040161050490611581565b6000828481610eb257fe5b04949350505050565b8035610321816116a4565b8051610321816116a4565b8051610321816116b8565b8035610321816116c1565b8035610321816116ca565b8051610321816116c1565b600060208284031215610f0f57600080fd5b6000610f1b8484610ebb565b949350505050565b600060208284031215610f3557600080fd5b6000610f1b8484610ec6565b60008060408385031215610f5457600080fd5b6000610f608585610ebb565b9250506020610f7185828601610ebb565b9150509250929050565b600080600060608486031215610f9057600080fd5b6000610f9c8686610ebb565b9350506020610fad86828701610ebb565b9250506040610fbe86828701610edc565b9150509250925092565b60008060408385031215610fdb57600080fd5b6000610fe78585610ebb565b9250506020610f7185828601610edc565b60006020828403121561100a57600080fd5b6000610f1b8484610ed1565b600080600080600060a0868803121561102e57600080fd5b600061103a8888610ee7565b955050602061104b88828901610ee7565b945050604061105c88828901610ebb565b935050606061106d88828901610edc565b925050608061107e88828901610edc565b9150509295509295909350565b60006020828403121561109d57600080fd5b6000610f1b8484610ef2565b6000806000606084860312156110be57600080fd5b60006110ca8686610ef2565b93505060206110db86828701610ef2565b9250506040610fbe86828701610ef2565b6110f58161163d565b82525050565b6110f581611648565b6110f58161030d565b6110f56111198261030d565b61030d565b6110f58161164d565b60006111328261162b565b61113c818561162f565b935061114c81856020860161166a565b6111558161169a565b9093019392505050565b600061116c60238361162f565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647281526265737360e81b602082015260400192915050565b60006111b160228361162f565b7f45524332303a20617070726f766520746f20746865207a65726f206164647265815261737360f01b602082015260400192915050565b60006111f5601b8361162f565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061122e601e8361162f565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b6000611267600e83611638565b6d02b34b93a3ab0b61029bcb73a34160951b8152600e0192915050565b6000611291601a8361162f565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006112ca601a8361162f565b7f7653796e746820616c726561647920696e697469616c697a6564000000000000815260200192915050565b600061130360218361162f565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6822bc31b430b733b2b960b91b9052565b6000611357600183611638565b603b60f91b815260010192915050565b600061137460218361162f565b7f45524332303a206275726e2066726f6d20746865207a65726f206164647265738152607360f81b602082015260400192915050565b60006113b760258361162f565b7f45524332303a207472616e736665722066726f6d20746865207a65726f206164815264647265737360d81b602082015260400192915050565b60006113fe60248361162f565b7f45524332303a20617070726f76652066726f6d20746865207a65726f206164648152637265737360e01b602082015260400192915050565b6000611444601c8361162f565b7f45786368616e67657220636f6e7472616374206e6f7420666f756e6400000000815260200192915050565b600061147d601f8361162f565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300815260200192915050565b6110f581611664565b60006114bd8261125a565b91506114c9828461110d565b50602001919050565b60006114bd8261134a565b6020810161032182846110ec565b604081016114f982856110ec565b6103966020830184611104565b6020810161032182846110fb565b602081016103218284611104565b60208101610321828461111e565b602080825281016103968184611127565b602080825281016103218161115f565b60208082528101610321816111a4565b60208082528101610321816111e8565b6020808252810161032181611221565b6020808252810161032181611284565b60208082528101610321816112bd565b60208082528101610321816112f6565b604081016115be82611339565b818103602083015261032181611437565b6020808252810161032181611367565b60208082528101610321816113aa565b60208082528101610321816113f1565b6020808252810161032181611470565b604081016114f98285611104565b6020810161032182846114a9565b5190565b90815260200190565b919050565b600061032182611658565b151590565b60006103218261163d565b6001600160a01b031690565b60ff1690565b60005b8381101561168557818101518382015260200161166d565b83811115611694576000848401525b50505050565b601f01601f191690565b6116ad8161163d565b81146104b357600080fd5b6116ad81611648565b6116ad8161030d565b6116ad8161164d56fea365627a7a72315820e6c2353be4ddd2d7ca4e27736eb0be03db9b522e022a1d4f80f98de3f3363e8f6c6578706572696d656e74616cf564736f6c63430005100040

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.