Contract 0xA8a3B1A1e09A0f84B2856533DB4eE0Cc88DD4E11

 
Txn Hash
Method
Block
From
To
Value
0x42297e8cd75cdab1ebf8cf30d5eeeb1db01dff26855cbf988473b3edc3df100bTransfer Ownersh...128579472021-07-19 15:47:22435 days 4 hrs ago0xa0863436913b1b439ccaa6fbf89408116c1dde29 IN  0xa8a3b1a1e09a0f84b2856533db4ee0cc88dd4e110 Ether0.0010057635
0x92c6bf4dd16f46cde339e7220f36a6fc1d278f1be1b1a983c416e160dd02f15fToggle Contract ...125740772021-06-05 10:59:40479 days 9 hrs ago0xa0863436913b1b439ccaa6fbf89408116c1dde29 IN  0xa8a3b1a1e09a0f84b2856533db4ee0cc88dd4e110 Ether0.0005032919
0x5974380179a02164fee15c22b8d9769633bf148659b53d639fada8659025a77d0x60806040125669102021-06-04 8:36:31480 days 11 hrs ago0xa0863436913b1b439ccaa6fbf89408116c1dde29 IN  Create: yVault_ZapOut_V30 Ether0.0431268618
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
yVault_ZapOut_V3

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, GNU GPLv2 license
File 1 of 8 : ZapBaseV2.sol
// SPDX-License-Identifier: GPL-2.0
pragma solidity ^0.8.0;

import "../oz/0.8.0/access/Ownable.sol";
import "../oz/0.8.0/token/ERC20/utils/SafeERC20.sol";

abstract contract ZapBaseV2 is Ownable {
    using SafeERC20 for IERC20;
    bool public stopped = false;

    // if true, goodwill is not deducted
    mapping(address => bool) public feeWhitelist;

    uint256 public goodwill;
    // % share of goodwill (0-100 %)
    uint256 affiliateSplit;
    // restrict affiliates
    mapping(address => bool) public affiliates;
    // affiliate => token => amount
    mapping(address => mapping(address => uint256)) public affiliateBalance;
    // token => amount
    mapping(address => uint256) public totalAffiliateBalance;
    // swapTarget => approval status
    mapping(address => bool) public approvedTargets;

    address internal constant ETHAddress =
        0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    constructor(uint256 _goodwill, uint256 _affiliateSplit) {
        goodwill = _goodwill;
        affiliateSplit = _affiliateSplit;
    }

    // circuit breaker modifiers
    modifier stopInEmergency {
        if (stopped) {
            revert("Temporarily Paused");
        } else {
            _;
        }
    }

    function _getBalance(address token)
        internal
        view
        returns (uint256 balance)
    {
        if (token == address(0)) {
            balance = address(this).balance;
        } else {
            balance = IERC20(token).balanceOf(address(this));
        }
    }

    function _approveToken(address token, address spender) internal {
        IERC20 _token = IERC20(token);
        if (_token.allowance(address(this), spender) > 0) return;
        else {
            _token.safeApprove(spender, type(uint256).max);
        }
    }

    function _approveToken(
        address token,
        address spender,
        uint256 amount
    ) internal {
        IERC20(token).safeApprove(spender, 0);
        IERC20(token).safeApprove(spender, amount);
    }

    // - to Pause the contract
    function toggleContractActive() public onlyOwner {
        stopped = !stopped;
    }

    function set_feeWhitelist(address zapAddress, bool status)
        external
        onlyOwner
    {
        feeWhitelist[zapAddress] = status;
    }

    function set_new_goodwill(uint256 _new_goodwill) public onlyOwner {
        require(
            _new_goodwill >= 0 && _new_goodwill <= 100,
            "GoodWill Value not allowed"
        );
        goodwill = _new_goodwill;
    }

    function set_new_affiliateSplit(uint256 _new_affiliateSplit)
        external
        onlyOwner
    {
        require(
            _new_affiliateSplit <= 100,
            "Affiliate Split Value not allowed"
        );
        affiliateSplit = _new_affiliateSplit;
    }

    function set_affiliate(address _affiliate, bool _status)
        external
        onlyOwner
    {
        affiliates[_affiliate] = _status;
    }

    ///@notice Withdraw goodwill share, retaining affilliate share
    function withdrawTokens(address[] calldata tokens) external onlyOwner {
        for (uint256 i = 0; i < tokens.length; i++) {
            uint256 qty;

            if (tokens[i] == ETHAddress) {
                qty = address(this).balance - totalAffiliateBalance[tokens[i]];

                Address.sendValue(payable(owner()), qty);
            } else {
                qty =
                    IERC20(tokens[i]).balanceOf(address(this)) -
                    totalAffiliateBalance[tokens[i]];
                IERC20(tokens[i]).safeTransfer(owner(), qty);
            }
        }
    }

    ///@notice Withdraw affilliate share, retaining goodwill share
    function affilliateWithdraw(address[] calldata tokens) external {
        uint256 tokenBal;
        for (uint256 i = 0; i < tokens.length; i++) {
            tokenBal = affiliateBalance[msg.sender][tokens[i]];
            affiliateBalance[msg.sender][tokens[i]] = 0;
            totalAffiliateBalance[tokens[i]] =
                totalAffiliateBalance[tokens[i]] -
                tokenBal;

            if (tokens[i] == ETHAddress) {
                Address.sendValue(payable(msg.sender), tokenBal);
            } else {
                IERC20(tokens[i]).safeTransfer(msg.sender, tokenBal);
            }
        }
    }

    function setApprovedTargets(
        address[] calldata targets,
        bool[] calldata isApproved
    ) external onlyOwner {
        require(targets.length == isApproved.length, "Invalid Input length");

        for (uint256 i = 0; i < targets.length; i++) {
            approvedTargets[targets[i]] = isApproved[i];
        }
    }

    receive() external payable {
        require(msg.sender != tx.origin, "Do not send ETH directly");
    }
}

File 2 of 8 : ZapOutBaseV3.sol
// SPDX-License-Identifier: GPL-2.0

pragma solidity ^0.8.0;
import "./ZapBaseV2.sol";

abstract contract ZapOutBaseV3 is ZapBaseV2 {
    using SafeERC20 for IERC20;

    /**
        @dev Transfer tokens from msg.sender to this contract
        @param token The ERC20 token to transfer to this contract
        @param shouldSellEntireBalance If True transfers entrire allowable amount from another contract
        @return Quantity of tokens transferred to this contract
     */
    function _pullTokens(
        address token,
        uint256 amount,
        bool shouldSellEntireBalance
    ) internal returns (uint256) {
        if (shouldSellEntireBalance) {
            require(
                Address.isContract(msg.sender),
                "ERR: shouldSellEntireBalance is true for EOA"
            );

            uint256 allowance =
                IERC20(token).allowance(msg.sender, address(this));
            IERC20(token).safeTransferFrom(
                msg.sender,
                address(this),
                allowance
            );

            return allowance;
        } else {
            IERC20(token).safeTransferFrom(msg.sender, address(this), amount);

            return amount;
        }
    }

    function _subtractGoodwill(
        address token,
        uint256 amount,
        address affiliate,
        bool enableGoodwill
    ) internal returns (uint256 totalGoodwillPortion) {
        bool whitelisted = feeWhitelist[msg.sender];
        if (enableGoodwill && !whitelisted && goodwill > 0) {
            totalGoodwillPortion = (amount * goodwill) / 10000;

            if (affiliates[affiliate]) {
                if (token == address(0)) {
                    token = ETHAddress;
                }

                uint256 affiliatePortion =
                    (totalGoodwillPortion * affiliateSplit) / 100;
                affiliateBalance[affiliate][token] += affiliatePortion;
                totalAffiliateBalance[token] += affiliatePortion;
            }
        }
    }
}

File 3 of 8 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(
            newOwner != address(0),
            "Ownable: new owner is the zero address"
        );
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 4 of 8 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
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.
     *
     * IMPORTANT: 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
    );
}

File 5 of 8 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.transfer.selector, to, value)
        );
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
        );
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.approve.selector, spender, value)
        );
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(
                token.approve.selector,
                spender,
                newAllowance
            )
        );
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(
                oldAllowance >= value,
                "SafeERC20: decreased allowance below zero"
            );
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(
                token,
                abi.encodeWithSelector(
                    token.approve.selector,
                    spender,
                    newAllowance
                )
            );
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata =
            address(token).functionCall(
                data,
                "SafeERC20: low-level call failed"
            );
        if (returndata.length > 0) {
            // Return data is optional
            // solhint-disable-next-line max-line-length
            require(
                abi.decode(returndata, (bool)),
                "SafeERC20: ERC20 operation did not succeed"
            );
        }
    }
}

File 6 of 8 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(
            address(this).balance >= amount,
            "Address: insufficient balance"
        );

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(
            success,
            "Address: unable to send value, recipient may have reverted"
        );
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data)
        internal
        returns (bytes memory)
    {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return
            functionCallWithValue(
                target,
                data,
                value,
                "Address: low-level call with value failed"
            );
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(
            address(this).balance >= value,
            "Address: insufficient balance for call"
        );
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) =
            target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data)
        internal
        view
        returns (bytes memory)
    {
        return
            functionStaticCall(
                target,
                data,
                "Address: low-level static call failed"
            );
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data)
        internal
        returns (bytes memory)
    {
        return
            functionDelegateCall(
                target,
                data,
                "Address: low-level delegate call failed"
            );
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 7 of 8 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 8 of 8 : yVault_ZapOut_V3.sol
// ███████╗░█████╗░██████╗░██████╗░███████╗██████╗░░░░███████╗██╗
// ╚════██║██╔══██╗██╔══██╗██╔══██╗██╔════╝██╔══██╗░░░██╔════╝██║
// ░░███╔═╝███████║██████╔╝██████╔╝█████╗░░██████╔╝░░░█████╗░░██║
// ██╔══╝░░██╔══██║██╔═══╝░██╔═══╝░██╔══╝░░██╔══██╗░░░██╔══╝░░██║
// ███████╗██║░░██║██║░░░░░██║░░░░░███████╗██║░░██║██╗██║░░░░░██║
// ╚══════╝╚═╝░░╚═╝╚═╝░░░░░╚═╝░░░░░╚══════╝╚═╝░░╚═╝╚═╝╚═╝░░░░░╚═╝
// Copyright (C) 2021 zapper

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//

///@author Zapper
///@notice This contract removes liquidity from yEarn Vaults to ETH or ERC20 Tokens.
// SPDX-License-Identifier: GPL-2.0

pragma solidity ^0.8.0;
import "../_base/ZapOutBaseV3.sol";

interface IWETH {
    function withdraw(uint256 wad) external;
}

interface IYVault {
    function deposit(uint256) external;

    function withdraw(uint256) external;

    function getPricePerFullShare() external view returns (uint256);

    function token() external view returns (address);

    function decimals() external view returns (uint256);

    // V2
    function pricePerShare() external view returns (uint256);

    function permit(
        address owner,
        address spender,
        uint256 amount,
        uint256 expiry,
        bytes calldata signature
    ) external returns (bool);

    function name() external pure returns (string memory);

    function nonces(address owner) external view returns (uint256);
}

interface IYVaultV1Registry {
    function getVaults() external view returns (address[] memory);

    function getVaultsLength() external view returns (uint256);
}

// -- Aave --
interface IAaveLendingPoolAddressesProvider {
    function getLendingPool() external view returns (address);

    function getLendingPoolCore() external view returns (address payable);
}

interface IAToken {
    function redeem(uint256 _amount) external;

    function underlyingAssetAddress() external returns (address);
}

contract yVault_ZapOut_V3 is ZapOutBaseV3 {
    using SafeERC20 for IERC20;

    IAaveLendingPoolAddressesProvider
        private constant lendingPoolAddressProvider =
        IAaveLendingPoolAddressesProvider(
            0x24a42fD28C976A61Df5D00D0599C34c4f90748c8
        );

    IYVaultV1Registry V1Registry =
        IYVaultV1Registry(0x3eE41C098f9666ed2eA246f4D2558010e59d63A0);

    address private constant wethTokenAddress =
        0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

    uint256 private constant deadline =
        0xf000000000000000000000000000000000000000000000000000000000000000;

    event Zapout(
        address _toWhomToIssue,
        address _fromYVaultAddress,
        address _toTokenAddress,
        uint256 _tokensRecieved
    );

    constructor(
        address _curveZapOut,
        uint256 _goodwill,
        uint256 _affiliateSplit
    ) ZapBaseV2(_goodwill, _affiliateSplit) {
        // Curve ZapOut
        approvedTargets[_curveZapOut] = true;
        // 0x exchange
        approvedTargets[0xDef1C0ded9bec7F1a1670819833240f027b25EfF] = true;
    }

    /**
        @notice Zap out in to a single token with permit
        @param fromVault Vault from which to remove liquidity
        @param amountIn Quantity of vault tokens to remove
        @param toToken Address of desired token
        @param isAaveUnderlying True if vault contains aave token
        @param minToTokens Minimum quantity of tokens to receive, reverts otherwise
        @param permitSig Encoded permit hash, which contains r,s,v values
        @param swapTarget Execution targets for swap or Zap
        @param swapData DEX or Zap data
        @param affiliate Affiliate address
        @param shouldSellEntireBalance If True transfers entrire allowable amount from another contract
        @return tokensReceived Quantity of tokens or ETH received
    */
    function ZapOutWithPermit(
        address fromVault,
        uint256 amountIn,
        address toToken,
        bool isAaveUnderlying,
        uint256 minToTokens,
        bytes calldata permitSig,
        address swapTarget,
        bytes calldata swapData,
        address affiliate,
        bool shouldSellEntireBalance
    ) external returns (uint256 tokensReceived) {
        // permit
        _permit(fromVault, amountIn, permitSig);

        return
            ZapOut(
                fromVault,
                amountIn,
                toToken,
                isAaveUnderlying,
                minToTokens,
                swapTarget,
                swapData,
                affiliate,
                shouldSellEntireBalance
            );
    }

    function _permit(
        address fromVault,
        uint256 amountIn,
        bytes memory permitSig
    ) internal {
        bool success =
            IYVault(fromVault).permit(
                msg.sender,
                address(this),
                amountIn,
                deadline,
                permitSig
            );
        require(success, "Could Not Permit");
    }

    /**
        @notice Zap out in to a single token with permit
        @param fromVault Vault from which to remove liquidity
        @param amountIn Quantity of vault tokens to remove
        @param toToken Address of desired token
        @param isAaveUnderlying True if vault contains aave token
        @param minToTokens Minimum quantity of tokens to receive, reverts otherwise
        @param swapTarget Execution targets for swap or Zap
        @param swapData DEX or Zap data
        @param affiliate Affiliate address
        @param shouldSellEntireBalance If True transfers entrire allowable amount from another contract
        @return tokensReceived Quantity of tokens or ETH received
    */
    function ZapOut(
        address fromVault,
        uint256 amountIn,
        address toToken,
        bool isAaveUnderlying,
        uint256 minToTokens,
        address swapTarget,
        bytes memory swapData,
        address affiliate,
        bool shouldSellEntireBalance
    ) public stopInEmergency returns (uint256 tokensReceived) {
        _pullTokens(fromVault, amountIn, shouldSellEntireBalance);

        // get underlying token from vault
        address underlyingToken = IYVault(fromVault).token();
        uint256 underlyingTokenReceived =
            _vaultWithdraw(fromVault, amountIn, underlyingToken);

        // swap to toToken
        uint256 toTokenAmt;

        if (isAaveUnderlying) {
            address underlyingAsset =
                IAToken(underlyingToken).underlyingAssetAddress();
            // unwrap atoken
            IAToken(underlyingToken).redeem(underlyingTokenReceived);

            // aTokens are 1:1
            if (underlyingAsset == toToken) {
                toTokenAmt = underlyingTokenReceived;
            } else {
                toTokenAmt = _fillQuote(
                    underlyingAsset,
                    toToken,
                    underlyingTokenReceived,
                    swapTarget,
                    swapData
                );
            }
        } else {
            toTokenAmt = _fillQuote(
                underlyingToken,
                toToken,
                underlyingTokenReceived,
                swapTarget,
                swapData
            );
        }
        require(toTokenAmt >= minToTokens, "Err: High Slippage");

        uint256 totalGoodwillPortion =
            _subtractGoodwill(toToken, toTokenAmt, affiliate, true);
        tokensReceived = toTokenAmt - totalGoodwillPortion;

        // send toTokens
        if (toToken == address(0)) {
            Address.sendValue(payable(msg.sender), tokensReceived);
        } else {
            IERC20(toToken).safeTransfer(msg.sender, tokensReceived);
        }
    }

    function _vaultWithdraw(
        address fromVault,
        uint256 amount,
        address underlyingVaultToken
    ) internal returns (uint256 underlyingReceived) {
        uint256 iniUnderlyingBal = _getBalance(underlyingVaultToken);

        IYVault(fromVault).withdraw(amount);

        underlyingReceived =
            _getBalance(underlyingVaultToken) -
            iniUnderlyingBal;
    }

    function _fillQuote(
        address _fromTokenAddress,
        address toToken,
        uint256 _amount,
        address _swapTarget,
        bytes memory swapData
    ) internal returns (uint256 amtBought) {
        if (_fromTokenAddress == toToken) {
            return _amount;
        }

        if (_fromTokenAddress == wethTokenAddress && toToken == address(0)) {
            IWETH(wethTokenAddress).withdraw(_amount);
            return _amount;
        }

        uint256 valueToSend;
        if (_fromTokenAddress == address(0)) {
            valueToSend = _amount;
        } else {
            _approveToken(_fromTokenAddress, _swapTarget, _amount);
        }

        uint256 iniBal = _getBalance(toToken);
        require(approvedTargets[_swapTarget], "Target not Authorized");
        (bool success, ) = _swapTarget.call{ value: valueToSend }(swapData);
        require(success, "Error Swapping Tokens 1");
        uint256 finalBal = _getBalance(toToken);

        require(finalBal > 0, "ERR: Swapped to wrong token");
        amtBought = finalBal - iniBal;
    }

    /**
        @notice Utility function to determine the quantity of underlying tokens removed from vault
        @param fromVault Yearn vault from which to remove liquidity
        @param liquidity Quantity of vault tokens to remove
        @return Quantity of underlying LP or token removed
    */
    function removeLiquidityReturn(address fromVault, uint256 liquidity)
        external
        view
        returns (uint256)
    {
        IYVault vault = IYVault(fromVault);

        address[] memory V1Vaults = V1Registry.getVaults();

        for (uint256 i = 0; i < V1Registry.getVaultsLength(); i++) {
            if (V1Vaults[i] == fromVault)
                return (liquidity * (vault.getPricePerFullShare())) / (10**18);
        }
        return (liquidity * (vault.pricePerShare())) / (10**vault.decimals());
    }
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_curveZapOut","type":"address"},{"internalType":"uint256","name":"_goodwill","type":"uint256"},{"internalType":"uint256","name":"_affiliateSplit","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_toWhomToIssue","type":"address"},{"indexed":false,"internalType":"address","name":"_fromYVaultAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_toTokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_tokensRecieved","type":"uint256"}],"name":"Zapout","type":"event"},{"inputs":[{"internalType":"address","name":"fromVault","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"bool","name":"isAaveUnderlying","type":"bool"},{"internalType":"uint256","name":"minToTokens","type":"uint256"},{"internalType":"address","name":"swapTarget","type":"address"},{"internalType":"bytes","name":"swapData","type":"bytes"},{"internalType":"address","name":"affiliate","type":"address"},{"internalType":"bool","name":"shouldSellEntireBalance","type":"bool"}],"name":"ZapOut","outputs":[{"internalType":"uint256","name":"tokensReceived","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"fromVault","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"bool","name":"isAaveUnderlying","type":"bool"},{"internalType":"uint256","name":"minToTokens","type":"uint256"},{"internalType":"bytes","name":"permitSig","type":"bytes"},{"internalType":"address","name":"swapTarget","type":"address"},{"internalType":"bytes","name":"swapData","type":"bytes"},{"internalType":"address","name":"affiliate","type":"address"},{"internalType":"bool","name":"shouldSellEntireBalance","type":"bool"}],"name":"ZapOutWithPermit","outputs":[{"internalType":"uint256","name":"tokensReceived","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"affiliateBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"affiliates","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"affilliateWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"approvedTargets","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"goodwill","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fromVault","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"name":"removeLiquidityReturn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"bool[]","name":"isApproved","type":"bool[]"}],"name":"setApprovedTargets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_affiliate","type":"address"},{"internalType":"bool","name":"_status","type":"bool"}],"name":"set_affiliate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"zapAddress","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"set_feeWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_new_affiliateSplit","type":"uint256"}],"name":"set_new_affiliateSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_new_goodwill","type":"uint256"}],"name":"set_new_goodwill","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stopped","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"toggleContractActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalAffiliateBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040526000805460ff60a01b19169055600880546001600160a01b031916733ee41c098f9666ed2ea246f4d2558010e59d63a01790553480156200004457600080fd5b5060405162002a0738038062002a07833981016040819052620000679162000124565b600080546001600160a01b03191633908117825560405184928492918291907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35060029190915560035550506001600160a01b031660009081526007602052604081208054600160ff19918216811790925573def1c0ded9bec7f1a1670819833240f027b25eff9092527ff6019cd1944dc466e824190b288e5a63528dd4c9a6d8cbd707956fd30d2f1e0d805490921617905562000167565b60008060006060848603121562000139578283fd5b83516001600160a01b038116811462000150578384fd5b602085015160409095015190969495509392505050565b61289080620001776000396000f3fe60806040526004361061012e5760003560e01c80635ecb16cd116100ab5780638da5cb5b1161006f5780638da5cb5b146103a85780639735a634146103d05780639779d1a6146103f0578063d408f65714610420578063f2fde38b14610450578063fbec27bf1461047057600080fd5b80635ecb16cd14610312578063715018a61461033257806375f12b21146103475780637ee992831461036857806389c6973b1461038857600080fd5b80632c6ca9ac116100f25780632c6ca9ac1461025c5780633ff428c71461027c5780634f51e2941461029c578063550bfa56146102dc5780635de0398e146102fc57600080fd5b806301e980d41461018f5780630dc9de85146101af5780631385d24c146101cf5780631781261f146101e457806318b135e31461022f57600080fd5b3661018a57333214156101885760405162461bcd60e51b815260206004820152601860248201527f446f206e6f742073656e6420455448206469726563746c79000000000000000060448201526064015b60405180910390fd5b005b600080fd5b34801561019b57600080fd5b506101886101aa36600461253d565b610490565b3480156101bb57600080fd5b506101886101ca3660046123a8565b61051a565b3480156101db57600080fd5b50610188610775565b3480156101f057600080fd5b5061021c6101ff36600461211e565b600560209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b34801561023b57600080fd5b5061021c61024a3660046120e6565b60066020526000908152604090205481565b34801561026857600080fd5b5061021c6102773660046122bb565b6107c0565b34801561028857600080fd5b50610188610297366004612156565b61085d565b3480156102a857600080fd5b506102cc6102b73660046120e6565b60046020526000908152604090205460ff1681565b6040519015158152602001610226565b3480156102e857600080fd5b506101886102f736600461253d565b6108b2565b34801561030857600080fd5b5061021c60025481565b34801561031e57600080fd5b5061018861032d3660046123a8565b610932565b34801561033e57600080fd5b50610188610ba3565b34801561035357600080fd5b506000546102cc90600160a01b900460ff1681565b34801561037457600080fd5b5061021c610383366004612183565b610c17565b34801561039457600080fd5b5061021c6103a33660046121ae565b610f33565b3480156103b457600080fd5b506000546040516001600160a01b039091168152602001610226565b3480156103dc57600080fd5b506101886103eb3660046123e8565b6111d9565b3480156103fc57600080fd5b506102cc61040b3660046120e6565b60076020526000908152604090205460ff1681565b34801561042c57600080fd5b506102cc61043b3660046120e6565b60016020526000908152604090205460ff1681565b34801561045c57600080fd5b5061018861046b3660046120e6565b611303565b34801561047c57600080fd5b5061018861048b366004612156565b6113ed565b6000546001600160a01b031633146104ba5760405162461bcd60e51b815260040161017f90612602565b60648111156105155760405162461bcd60e51b815260206004820152602160248201527f416666696c696174652053706c69742056616c7565206e6f7420616c6c6f77656044820152601960fa1b606482015260840161017f565b600355565b6000805b8281101561076f573360009081526005602052604081209085858481811061055657634e487b7160e01b600052603260045260246000fd5b905060200201602081019061056b91906120e6565b6001600160a01b031681526020808201929092526040908101600090812054338252600590935290812091935090818686858181106105ba57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906105cf91906120e6565b6001600160a01b03166001600160a01b0316815260200190815260200160002081905550816006600086868581811061061857634e487b7160e01b600052603260045260246000fd5b905060200201602081019061062d91906120e6565b6001600160a01b03166001600160a01b031681526020019081526020016000205461065891906127aa565b6006600086868581811061067c57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061069191906120e6565b6001600160a01b0316815260208101919091526040016000205573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8484838181106106e057634e487b7160e01b600052603260045260246000fd5b90506020020160208101906106f591906120e6565b6001600160a01b031614156107135761070e3383611442565b61075d565b61075d338386868581811061073857634e487b7160e01b600052603260045260246000fd5b905060200201602081019061074d91906120e6565b6001600160a01b0316919061155b565b80610767816127ed565b91505061051e565b50505050565b6000546001600160a01b0316331461079f5760405162461bcd60e51b815260040161017f90612602565b6000805460ff60a01b198116600160a01b9182900460ff1615909102179055565b60006108038d8d8a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506115be92505050565b61084c8d8d8d8d8d8b8b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508d92508c9150610f339050565b9d9c50505050505050505050505050565b6000546001600160a01b031633146108875760405162461bcd60e51b815260040161017f90612602565b6001600160a01b03919091166000908152600460205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146108dc5760405162461bcd60e51b815260040161017f90612602565b606481111561092d5760405162461bcd60e51b815260206004820152601a60248201527f476f6f6457696c6c2056616c7565206e6f7420616c6c6f776564000000000000604482015260640161017f565b600255565b6000546001600160a01b0316331461095c5760405162461bcd60e51b815260040161017f90612602565b60005b81811015610b9e57600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee84848481811061099e57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906109b391906120e6565b6001600160a01b03161415610a4157600660008585858181106109e657634e487b7160e01b600052603260045260246000fd5b90506020020160208101906109fb91906120e6565b6001600160a01b03168152602081019190915260400160002054610a1f90476127aa565b9050610a3c610a366000546001600160a01b031690565b82611442565b610b8b565b60066000858585818110610a6557634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a7a91906120e6565b6001600160a01b03166001600160a01b0316815260200190815260200160002054848484818110610abb57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610ad091906120e6565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b158015610b1157600080fd5b505afa158015610b25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b499190612555565b610b5391906127aa565b9050610b8b610b6a6000546001600160a01b031690565b8286868681811061073857634e487b7160e01b600052603260045260246000fd5b5080610b96816127ed565b91505061095f565b505050565b6000546001600160a01b03163314610bcd5760405162461bcd60e51b815260040161017f90612602565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000808390506000600860009054906101000a90046001600160a01b03166001600160a01b03166344d00f826040518163ffffffff1660e01b815260040160006040518083038186803b158015610c6d57600080fd5b505afa158015610c81573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ca99190810190612451565b905060005b600860009054906101000a90046001600160a01b03166001600160a01b03166344b19dfc6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cfc57600080fd5b505afa158015610d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d349190612555565b811015610e2657856001600160a01b0316828281518110610d6557634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03161415610e1457670de0b6b3a7640000836001600160a01b03166377c7b8fc6040518163ffffffff1660e01b815260040160206040518083038186803b158015610dbe57600080fd5b505afa158015610dd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df69190612555565b610e00908761278b565b610e0a9190612680565b9350505050610f2d565b80610e1e816127ed565b915050610cae565b50816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610e6057600080fd5b505afa158015610e74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e989190612555565b610ea390600a6126e3565b826001600160a01b03166399530b066040518163ffffffff1660e01b815260040160206040518083038186803b158015610edc57600080fd5b505afa158015610ef0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f149190612555565b610f1e908661278b565b610f289190612680565b925050505b92915050565b60008054600160a01b900460ff1615610f835760405162461bcd60e51b815260206004820152601260248201527115195b5c1bdc985c9a5b1e4814185d5cd95960721b604482015260640161017f565b610f8e8a8a8461168d565b5060008a6001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b158015610fca57600080fd5b505afa158015610fde573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110029190612102565b905060006110118c8c846117b5565b905060008915611125576000836001600160a01b03166389d1a0fc6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561105857600080fd5b505af115801561106c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110909190612102565b60405163db006a7560e01b8152600481018590529091506001600160a01b0385169063db006a7590602401600060405180830381600087803b1580156110d557600080fd5b505af11580156110e9573d6000803e3d6000fd5b505050508b6001600160a01b0316816001600160a01b0316141561110f5782915061111f565b61111c818d858c8c61183b565b91505b50611135565b611132838c848b8b61183b565b90505b8881101561117a5760405162461bcd60e51b81526020600482015260126024820152714572723a204869676820536c69707061676560701b604482015260640161017f565b60006111898c83896001611ab6565b905061119581836127aa565b94506001600160a01b038c166111b4576111af3386611442565b6111c8565b6111c86001600160a01b038d16338761155b565b505050509998505050505050505050565b6000546001600160a01b031633146112035760405162461bcd60e51b815260040161017f90612602565b8281146112495760405162461bcd60e51b8152602060048201526014602482015273092dcecc2d8d2c84092dce0eae840d8cadccee8d60631b604482015260640161017f565b60005b838110156112fc5782828281811061127457634e487b7160e01b600052603260045260246000fd5b90506020020160208101906112899190612505565b600760008787858181106112ad57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906112c291906120e6565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055806112f4816127ed565b91505061124c565b5050505050565b6000546001600160a01b0316331461132d5760405162461bcd60e51b815260040161017f90612602565b6001600160a01b0381166113925760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161017f565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146114175760405162461bcd60e51b815260040161017f90612602565b6001600160a01b03919091166000908152600160205260409020805460ff1916911515919091179055565b804710156114925760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161017f565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146114df576040519150601f19603f3d011682016040523d82523d6000602084013e6114e4565b606091505b5050905080610b9e5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161017f565b6040516001600160a01b038316602482015260448101829052610b9e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611be1565b604051639fd5a6cf60e01b81526000906001600160a01b03851690639fd5a6cf906115f990339030908890600f60fc1b9089906004016125b5565b602060405180830381600087803b15801561161357600080fd5b505af1158015611627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164b9190612521565b90508061076f5760405162461bcd60e51b815260206004820152601060248201526f10dbdd5b1908139bdd0814195c9b5a5d60821b604482015260640161017f565b6000811561179657333b6116f85760405162461bcd60e51b815260206004820152602c60248201527f4552523a2073686f756c6453656c6c456e7469726542616c616e63652069732060448201526b7472756520666f7220454f4160a01b606482015260840161017f565b604051636eb1769f60e11b81523360048201523060248201526000906001600160a01b0386169063dd62ed3e9060440160206040518083038186803b15801561174057600080fd5b505afa158015611754573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117789190612555565b905061178f6001600160a01b038616333084611cb3565b90506117ae565b6117ab6001600160a01b038516333086611cb3565b50815b9392505050565b6000806117c183611ceb565b604051632e1a7d4d60e01b8152600481018690529091506001600160a01b03861690632e1a7d4d90602401600060405180830381600087803b15801561180657600080fd5b505af115801561181a573d6000803e3d6000fd5b505050508061182884611ceb565b61183291906127aa565b95945050505050565b6000846001600160a01b0316866001600160a01b0316141561185e575082611832565b6001600160a01b03861673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214801561189157506001600160a01b038516155b1561190357604051632e1a7d4d60e01b81526004810185905273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90602401600060405180830381600087803b1580156118e357600080fd5b505af11580156118f7573d6000803e3d6000fd5b50505050839050611832565b60006001600160a01b03871661191a575083611925565b611925878587611d81565b600061193087611ceb565b6001600160a01b03861660009081526007602052604090205490915060ff166119935760405162461bcd60e51b815260206004820152601560248201527415185c99d95d081b9bdd08105d5d1a1bdc9a5e9959605a1b604482015260640161017f565b6000856001600160a01b031683866040516119ae9190612599565b60006040518083038185875af1925050503d80600081146119eb576040519150601f19603f3d011682016040523d82523d6000602084013e6119f0565b606091505b5050905080611a415760405162461bcd60e51b815260206004820152601760248201527f4572726f72205377617070696e6720546f6b656e732031000000000000000000604482015260640161017f565b6000611a4c89611ceb565b905060008111611a9e5760405162461bcd60e51b815260206004820152601b60248201527f4552523a205377617070656420746f2077726f6e6720746f6b656e0000000000604482015260640161017f565b611aa883826127aa565b9a9950505050505050505050565b3360009081526001602052604081205460ff16828015611ad4575080155b8015611ae257506000600254115b15611bd85761271060025486611af8919061278b565b611b029190612680565b6001600160a01b03851660009081526004602052604090205490925060ff1615611bd8576001600160a01b038616611b4c5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee95505b6000606460035484611b5e919061278b565b611b689190612680565b6001600160a01b038087166000908152600560209081526040808320938c16835292905290812080549293508392909190611ba4908490612668565b90915550506001600160a01b03871660009081526006602052604081208054839290611bd1908490612668565b9091555050505b50949350505050565b6000611c36826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611daa9092919063ffffffff16565b805190915015610b9e5780806020019051810190611c549190612521565b610b9e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161017f565b6040516001600160a01b038085166024830152831660448201526064810182905261076f9085906323b872dd60e01b90608401611587565b60006001600160a01b038216611d02575047919050565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a082319060240160206040518083038186803b158015611d4157600080fd5b505afa158015611d55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d799190612555565b90505b919050565b611d966001600160a01b038416836000611dc1565b610b9e6001600160a01b0384168383611dc1565b6060611db98484600085611ee5565b949350505050565b801580611e4a5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611e1057600080fd5b505afa158015611e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e489190612555565b155b611eb55760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161017f565b6040516001600160a01b038316602482015260448101829052610b9e90849063095ea7b360e01b90606401611587565b606082471015611f465760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161017f565b843b611f945760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161017f565b600080866001600160a01b03168587604051611fb09190612599565b60006040518083038185875af1925050503d8060008114611fed576040519150601f19603f3d011682016040523d82523d6000602084013e611ff2565b606091505b509150915061200282828661200d565b979650505050505050565b6060831561201c5750816117ae565b82511561202c5782518084602001fd5b8160405162461bcd60e51b815260040161017f91906125ef565b8035611d7c81612834565b60008083601f840112612062578182fd5b50813567ffffffffffffffff811115612079578182fd5b6020830191508360208260051b850101111561209457600080fd5b9250929050565b8035611d7c8161284c565b60008083601f8401126120b7578182fd5b50813567ffffffffffffffff8111156120ce578182fd5b60208301915083602082850101111561209457600080fd5b6000602082840312156120f7578081fd5b81356117ae81612834565b600060208284031215612113578081fd5b81516117ae81612834565b60008060408385031215612130578081fd5b823561213b81612834565b9150602083013561214b81612834565b809150509250929050565b60008060408385031215612168578182fd5b823561217381612834565b9150602083013561214b8161284c565b60008060408385031215612195578182fd5b82356121a081612834565b946020939093013593505050565b60008060008060008060008060006101208a8c0312156121cc578485fd5b89356121d781612834565b985060208a810135985060408b01356121ef81612834565b975060608b01356121ff8161284c565b965060808b0135955060a08b013561221681612834565b945060c08b013567ffffffffffffffff80821115612232578586fd5b818d0191508d601f830112612245578586fd5b8135818111156122575761225761281e565b612269601f8201601f19168501612637565b91508082528e8482850101111561227e578687fd5b8084840185840137810190920194909452925061229d60e08b01612046565b91506122ac6101008b0161209b565b90509295985092959850929598565b6000806000806000806000806000806000806101408d8f0312156122dd578283fd5b6122e68d612046565b9b5060208d01359a506122fb60408e01612046565b995061230960608e0161209b565b985060808d0135975067ffffffffffffffff60a08e0135111561232a578283fd5b61233a8e60a08f01358f016120a6565b909750955061234b60c08e01612046565b945067ffffffffffffffff60e08e01351115612365578283fd5b6123758e60e08f01358f016120a6565b90945092506123876101008e01612046565b91506123966101208e0161209b565b90509295989b509295989b509295989b565b600080602083850312156123ba578182fd5b823567ffffffffffffffff8111156123d0578283fd5b6123dc85828601612051565b90969095509350505050565b600080600080604085870312156123fd578182fd5b843567ffffffffffffffff80821115612414578384fd5b61242088838901612051565b90965094506020870135915080821115612438578384fd5b5061244587828801612051565b95989497509550505050565b60006020808385031215612463578182fd5b825167ffffffffffffffff8082111561247a578384fd5b818501915085601f83011261248d578384fd5b81518181111561249f5761249f61281e565b8060051b91506124b0848301612637565b8181528481019084860184860187018a10156124ca578788fd5b8795505b838610156124f857805194506124e385612834565b848352600195909501949186019186016124ce565b5098975050505050505050565b600060208284031215612516578081fd5b81356117ae8161284c565b600060208284031215612532578081fd5b81516117ae8161284c565b60006020828403121561254e578081fd5b5035919050565b600060208284031215612566578081fd5b5051919050565b600081518084526125858160208601602086016127c1565b601f01601f19169290920160200192915050565b600082516125ab8184602087016127c1565b9190910192915050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906120029083018461256d565b6020815260006117ae602083018461256d565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b604051601f8201601f1916810167ffffffffffffffff811182821017156126605761266061281e565b604052919050565b6000821982111561267b5761267b612808565b500190565b60008261269b57634e487b7160e01b81526012600452602481fd5b500490565b600181815b808511156126db5781600019048211156126c1576126c1612808565b808516156126ce57918102915b93841c93908002906126a5565b509250929050565b60006117ae83836000826126f957506001610f2d565b8161270657506000610f2d565b816001811461271c576002811461272657612742565b6001915050610f2d565b60ff84111561273757612737612808565b50506001821b610f2d565b5060208310610133831016604e8410600b8410161715612765575081810a610f2d565b61276f83836126a0565b806000190482111561278357612783612808565b029392505050565b60008160001904831182151516156127a5576127a5612808565b500290565b6000828210156127bc576127bc612808565b500390565b60005b838110156127dc5781810151838201526020016127c4565b8381111561076f5750506000910152565b600060001982141561280157612801612808565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461284957600080fd5b50565b801515811461284957600080fdfea2646970667358221220672b85db111c1493f998e92878a5e24bfe61a5c078b6bcc3b9a5ffc5829d385164736f6c63430008040033000000000000000000000000d754ffb697cd276ad6b0f0273521775c1a11b17500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

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

000000000000000000000000d754ffb697cd276ad6b0f0273521775c1a11b17500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _curveZapOut (address): 0xD754ffB697CD276ad6B0f0273521775C1A11b175
Arg [1] : _goodwill (uint256): 0
Arg [2] : _affiliateSplit (uint256): 0

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000d754ffb697cd276ad6b0f0273521775c1a11b175
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

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.