Contract 0x0000000006ADBd7c01Bc0738cDBFc3932600Ad63 3

 
 
Txn Hash
Method
Block
From
To
Value
0x0a81ee772688df03c94555c7b58920f88b54be87fc40ae13c7102e764a29a150Aggregate85676742019-09-17 15:16:481170 days 5 hrs agoENS Name k06a.eth IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0034393230
0x9bfc0e7860965dbb9d637c131bbd5fdd643fbfcb5acd6fe3e3e3003ad8cc37cfTransfer80457672019-06-28 10:20:541251 days 10 hrs agoENS Name cryptomaniacs.eth IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0008264420
0x77a087b876dd0e9ff6a815cb60722e9e408a4a895e1a3cca6254db5ae08dee37Aggregate80037172019-06-21 21:02:321257 days 23 hrs ago0x14559df3fbe66cab6f893d8dd53f7bfe68de9c65 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.001335613
0x3aeba5979b888c20ec705c199df76cbe4f009f3c37f06daa252e7b0b18a5b047Aggregate80018082019-06-21 13:42:371258 days 7 hrs ago0x14559df3fbe66cab6f893d8dd53f7bfe68de9c65 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.002557356
0xd0ac2e3016c86dda786e5cf52e6f996af596bbad8d90e512b39263bb6d0b9d7dAggregate79848002019-06-18 21:52:231260 days 22 hrs ago0xc8557792446904fe0b7b5622b1ac2706c726a9ce IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.000716882
0x93f61b298711ba3260dfe10941a715d6f4839617ca1187abd8325737dba2091fAggregate79843072019-06-18 19:56:561261 days 47 mins agoENS Name k06a.eth IN  0x0000000006adbd7c01bc0738cdbfc3932600ad634.99523431 Ether0.0078457420
0xa63b59daf6e25b436f8bf87b63f769b461493564cd49131f575ab297f4e5ff99Aggregate79838052019-06-18 18:04:291261 days 2 hrs ago0x2a1e041d67e597d8e72bb3725c25d9fff97b8691 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0023971410
0xd5fadc0f6f1fa4c23cd578d774906fcc3e02af43a1ff52bf04d3ae37ce1d7e6dAggregate79822482019-06-18 12:19:461261 days 8 hrs agoENS Name cryptomaniacs.eth IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0010912810
0x5af4abe86a9c87b9e7c8d0f61b26e20ba6a6a7d58843d7b8480cb8ef185faea4Aggregate79807032019-06-18 6:32:241261 days 14 hrs ago0x4fe95c36bb9b3a81f278569525162f91615e77d7 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0019782810
0x0aab8268cbc8795132260e681a37ec5cc03dc6dc91d8ad30b1a6e4544213815dAggregate79806962019-06-18 6:31:031261 days 14 hrs ago0x4fe95c36bb9b3a81f278569525162f91615e77d7 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.000829063
0xce7f5886f8806200547b4f21c87ac99e975d501cc762eaf5341a74170220efd4Aggregate79790262019-06-18 0:01:141261 days 20 hrs ago0x8e5d30f161ba3ebb09dc3c1f06515656af34baa1 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.001114043
0xff9a59cd8dcb1f14ce5275ab73f2ef08af5a340ae0e65d4097be2c367a398977Aggregate79783922019-06-17 21:44:021261 days 23 hrs ago0x14559df3fbe66cab6f893d8dd53f7bfe68de9c65 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.002460185
0x172896f8fef3feaa69e803292784795fd2c058910b17dba620a8d42aaabb64a0Aggregate79783052019-06-17 21:23:061261 days 23 hrs ago0x0d4e989c7620c8749c9417d2bf218896c767b606 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0022377210
0x282b0f3109538912fe1845d283b86efb52779facb968f394b56d44e7518abfdcAggregate79775792019-06-17 18:39:421262 days 2 hrs ago0x4fc691a1cf6a03ee6f1aa626fe63da0a0663d750 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630.002 Ether0.0021657620
0x8565033f51bcf3e92cbc4ef83b8739fbee6dcf4b1a3415d681ba494c08380c86Aggregate79775672019-06-17 18:37:141262 days 2 hrs ago0x4fc691a1cf6a03ee6f1aa626fe63da0a0663d750 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0029464220
0xce0e169d109180ec1a372cebff3e42fd1bc469b90b23e2561ca2766e6a6dc6c3Aggregate79775262019-06-17 18:29:061262 days 2 hrs ago0x4fc691a1cf6a03ee6f1aa626fe63da0a0663d750 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630.011 Ether0.0021670420
0x7da066102341d2bf9e2c7e300754900b5751ba70216047a147eee574e77b82b8Aggregate79775072019-06-17 18:24:261262 days 2 hrs ago0x4fc691a1cf6a03ee6f1aa626fe63da0a0663d750 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.003450620
0x7e480d4aeaf92ae5d7e624a9141a0c26d69ffb48005b4bc438e176eaf793d885Aggregate79769852019-06-17 16:27:051262 days 4 hrs ago0xc8557792446904fe0b7b5622b1ac2706c726a9ce IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630.20432301 Ether0.000581142
0xcc589c7611102d53c25f2cbf80715815b9cdb40179289da7ac05eb85a4b5634aAggregate79766512019-06-17 15:14:591262 days 5 hrs ago0x4fe95c36bb9b3a81f278569525162f91615e77d7 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0065426813.2
0x8dfb152defdeb11c4bdf22d87f40f4fab031d35659f8dde6a6e3363effef5bebAggregate79763882019-06-17 14:15:441262 days 6 hrs ago0x0d4e989c7620c8749c9417d2bf218896c767b606 IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0386417240
0xfc51ea0c0ecb354422eee25c5eec4b9586d76e75da00b4eb3b6ce6a0fcdcc33aAggregate79760892019-06-17 13:09:201262 days 7 hrs agoENS Name cryptomaniacs.eth IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0031701620
0x4d5442cbe8cddf1d615b99a5845392012e4aa13ac529c12220f75ce051eab56aAggregate79759372019-06-17 12:38:541262 days 8 hrs agoENS Name cryptomaniacs.eth IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630.9 Ether0.005459520
0x058e4a0dbc7743e2b96a969e2997e32532aa5ed2647e854063afce19849bd156Aggregate79758732019-06-17 12:23:071262 days 8 hrs agoENS Name cryptomaniacs.eth IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.0063183620
0x83234dda8e51a6c3a4d689e53996476c777dcae2aa2bc91ccc3ef484663744ceAggregate79758362019-06-17 12:14:201262 days 8 hrs agoENS Name cryptomaniacs.eth IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630 Ether0.006687120
0x5735e5e2cedd450934e219fc3ac037be6c91cd421801ed607e510013b4d2c141Aggregate79758142019-06-17 12:07:161262 days 8 hrs agoENS Name cryptomaniacs.eth IN  0x0000000006adbd7c01bc0738cdbfc3932600ad630.2 Ether0.0022158620
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x93f61b298711ba3260dfe10941a715d6f4839617ca1187abd8325737dba2091f79843072019-06-18 19:56:561261 days 47 mins ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63 Wrapped Ether4.99523431 Ether
0xa63b59daf6e25b436f8bf87b63f769b461493564cd49131f575ab297f4e5ff9979838052019-06-18 18:04:291261 days 2 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad630x2a1e041d67e597d8e72bb3725c25d9fff97b86910.00083096 Ether
0xa63b59daf6e25b436f8bf87b63f769b461493564cd49131f575ab297f4e5ff9979838052019-06-18 18:04:291261 days 2 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63ENS Name cryptomaniacs.eth0.00000016 Ether
0xa63b59daf6e25b436f8bf87b63f769b461493564cd49131f575ab297f4e5ff9979838052019-06-18 18:04:291261 days 2 hrs ago Bancor: ETH Token 0x0000000006adbd7c01bc0738cdbfc3932600ad630.00083113 Ether
0xd5fadc0f6f1fa4c23cd578d774906fcc3e02af43a1ff52bf04d3ae37ce1d7e6d79822482019-06-18 12:19:461261 days 8 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63ENS Name cryptomaniacs.eth0.03140537 Ether
0xd5fadc0f6f1fa4c23cd578d774906fcc3e02af43a1ff52bf04d3ae37ce1d7e6d79822482019-06-18 12:19:461261 days 8 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63ENS Name cryptomaniacs.eth0.00000628 Ether
0xd5fadc0f6f1fa4c23cd578d774906fcc3e02af43a1ff52bf04d3ae37ce1d7e6d79822482019-06-18 12:19:461261 days 8 hrs ago Uniswap: KNC 0x0000000006adbd7c01bc0738cdbfc3932600ad630.03141165 Ether
0x5af4abe86a9c87b9e7c8d0f61b26e20ba6a6a7d58843d7b8480cb8ef185faea479807032019-06-18 6:32:241261 days 14 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad630x4fe95c36bb9b3a81f278569525162f91615e77d71.89743227 Ether
0x5af4abe86a9c87b9e7c8d0f61b26e20ba6a6a7d58843d7b8480cb8ef185faea479807032019-06-18 6:32:241261 days 14 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63ENS Name cryptomaniacs.eth0.00037956 Ether
0x5af4abe86a9c87b9e7c8d0f61b26e20ba6a6a7d58843d7b8480cb8ef185faea479807032019-06-18 6:32:241261 days 14 hrs ago Uniswap: SAI 0x0000000006adbd7c01bc0738cdbfc3932600ad630.09489412 Ether
0x5af4abe86a9c87b9e7c8d0f61b26e20ba6a6a7d58843d7b8480cb8ef185faea479807032019-06-18 6:32:241261 days 14 hrs ago Wrapped Ether 0x0000000006adbd7c01bc0738cdbfc3932600ad631.80291771 Ether
0x172896f8fef3feaa69e803292784795fd2c058910b17dba620a8d42aaabb64a079783052019-06-17 21:23:061261 days 23 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad630x0d4e989c7620c8749c9417d2bf218896c767b60610.83994979 Ether
0x172896f8fef3feaa69e803292784795fd2c058910b17dba620a8d42aaabb64a079783052019-06-17 21:23:061261 days 23 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63ENS Name cryptomaniacs.eth0.00216842 Ether
0x172896f8fef3feaa69e803292784795fd2c058910b17dba620a8d42aaabb64a079783052019-06-17 21:23:061261 days 23 hrs ago Wrapped Ether 0x0000000006adbd7c01bc0738cdbfc3932600ad6310.84211822 Ether
0x282b0f3109538912fe1845d283b86efb52779facb968f394b56d44e7518abfdc79775792019-06-17 18:39:421262 days 2 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63 Uniswap: SPANK0.002 Ether
0xce0e169d109180ec1a372cebff3e42fd1bc469b90b23e2561ca2766e6a6dc6c379775262019-06-17 18:29:061262 days 2 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63 Uniswap: SPANK0.011 Ether
0x7e480d4aeaf92ae5d7e624a9141a0c26d69ffb48005b4bc438e176eaf793d88579769852019-06-17 16:27:051262 days 4 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63 Uniswap: SAI0.16345841 Ether
0x7e480d4aeaf92ae5d7e624a9141a0c26d69ffb48005b4bc438e176eaf793d88579769852019-06-17 16:27:051262 days 4 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63 0x6690819cb98c1211a8e38790d6cd48316ed518db0.0408646 Ether
0xfc51ea0c0ecb354422eee25c5eec4b9586d76e75da00b4eb3b6ce6a0fcdcc33a79760892019-06-17 13:09:201262 days 7 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63ENS Name cryptomaniacs.eth0.89957881 Ether
0xfc51ea0c0ecb354422eee25c5eec4b9586d76e75da00b4eb3b6ce6a0fcdcc33a79760892019-06-17 13:09:201262 days 7 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63ENS Name cryptomaniacs.eth0.00017995 Ether
0xfc51ea0c0ecb354422eee25c5eec4b9586d76e75da00b4eb3b6ce6a0fcdcc33a79760892019-06-17 13:09:201262 days 7 hrs ago Wrapped Ether 0x0000000006adbd7c01bc0738cdbfc3932600ad630.89975876 Ether
0x4d5442cbe8cddf1d615b99a5845392012e4aa13ac529c12220f75ce051eab56a79759372019-06-17 12:38:541262 days 8 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63 Uniswap: SAI0.54 Ether
0x4d5442cbe8cddf1d615b99a5845392012e4aa13ac529c12220f75ce051eab56a79759372019-06-17 12:38:541262 days 8 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63 0x6690819cb98c1211a8e38790d6cd48316ed518db0.36 Ether
0x058e4a0dbc7743e2b96a969e2997e32532aa5ed2647e854063afce19849bd15679758732019-06-17 12:23:071262 days 8 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63ENS Name cryptomaniacs.eth0.14628521 Ether
0x058e4a0dbc7743e2b96a969e2997e32532aa5ed2647e854063afce19849bd15679758732019-06-17 12:23:071262 days 8 hrs ago 0x0000000006adbd7c01bc0738cdbfc3932600ad63ENS Name cryptomaniacs.eth0.00002926 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AggregatedTokenSwap

Compiler Version
v0.5.8+commit.23d335f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2019-06-10
*/

pragma solidity ^0.5.0;

interface IGST2 {

    function freeUpTo(uint256 value) external returns (uint256 freed);

    function freeFromUpTo(address from, uint256 value) external returns (uint256 freed);

    function balanceOf(address who) external view returns (uint256);
}



library ExternalCall {
    // Source: https://github.com/gnosis/MultiSigWallet/blob/master/contracts/MultiSigWallet.sol
    // call has been separated into its own function in order to take advantage
    // of the Solidity's code generator to produce a loop that copies tx.data into memory.
    function externalCall(address destination, uint value, bytes memory data, uint dataOffset, uint dataLength) internal returns(bool result) {
        // solium-disable-next-line security/no-inline-assembly
        assembly {
            let x := mload(0x40)   // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention)
            let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that
            result := call(
                sub(gas, 34710),   // 34710 is the value that solidity is currently emitting
                                   // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) +
                                   // callNewAccountGas (25000, in case the destination address does not exist and needs creating)
                destination,
                value,
                add(d, dataOffset),
                dataLength,        // Size of the input (in bytes) - this is what fixes the padding problem
                x,
                0                  // Output is ignored, therefore the output size is zero
            )
        }
    }
}


/**
 * @title ERC20 interface
 * @dev see https://eips.ethereum.org/EIPS/eip-20
 */
interface IERC20 {
    function transfer(address to, uint256 value) external returns (bool);

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

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

    function totalSupply() external view returns (uint256);

    function balanceOf(address who) external view returns (uint256);

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

    event Transfer(address indexed from, address indexed to, uint256 value);

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


/**
 * @title SafeMath
 * @dev Unsigned math operations with safety checks that revert on error
 */
library SafeMath {
    /**
     * @dev Multiplies two unsigned integers, reverts on 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);

        return c;
    }

    /**
     * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Adds two unsigned integers, reverts on overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a);

        return c;
    }

    /**
     * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
     * reverts when dividing by zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b != 0);
        return a % b;
    }
}


/**
 * Utility library of inline functions on addresses
 */
library Address {
    /**
     * Returns whether the target address is a contract
     * @dev This function will return false if invoked during the constructor of a contract,
     * as the code is not actually created until after the constructor finishes.
     * @param account address of the account to check
     * @return whether the target address is a contract
     */
    function isContract(address account) internal view returns (bool) {
        uint256 size;
        // XXX Currently there is no better way to check if there is a contract in an address
        // than to check the size of the code at that address.
        // See https://ethereum.stackexchange.com/a/14016/36603
        // for more details about how this works.
        // TODO Check this again before the Serenity release, because all addresses will be
        // contracts then.
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }
}


/**
 * @title Ownable
 * @dev The Ownable contract has an owner address, and provides basic authorization control
 * functions, this simplifies the implementation of "user permissions".
 */
contract Ownable {
    address private _owner;

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

    /**
     * @dev The Ownable constructor sets the original `owner` of the contract to the sender
     * account.
     */
    constructor () internal {
        _owner = msg.sender;
        emit OwnershipTransferred(address(0), _owner);
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner());
        _;
    }

    /**
     * @return true if `msg.sender` is the owner of the contract.
     */
    function isOwner() public view returns (bool) {
        return msg.sender == _owner;
    }

    /**
     * @dev Allows the current owner to relinquish control of the contract.
     * It will not be possible to call the functions with the `onlyOwner`
     * modifier anymore.
     * @notice Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Allows the current owner to transfer control of the contract to a newOwner.
     * @param newOwner The address to transfer ownership to.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers control of the contract to a newOwner.
     * @param newOwner The address to transfer ownership to.
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0));
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}




/**
 * @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 ERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    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));
    }

    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'
        require((value == 0) || (token.allowance(address(this), spender) == 0));
        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).add(value);
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(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 equal true).
     * @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.

        // A Solidity high level call has three parts:
        //  1. The target address is checked to verify it contains contract code
        //  2. The call itself is made, and success asserted
        //  3. The return value is decoded, which in turn checks the size of the returned data.

        require(address(token).isContract());

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = address(token).call(data);
        require(success);

        if (returndata.length > 0) { // Return data is optional
            require(abi.decode(returndata, (bool)));
        }
    }
}



contract IWETH is IERC20 {

    function deposit() external payable;

    function withdraw(uint256 amount) external;
}



contract TokenSpender is Ownable {

    using SafeERC20 for IERC20;

    function claimTokens(IERC20 token, address who, address dest, uint256 amount) external onlyOwner {
        token.safeTransferFrom(who, dest, amount);
    }

}






contract AggregatedTokenSwap {

    using SafeERC20 for IERC20;
    using SafeMath for uint;
    using ExternalCall for address;

    address constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    TokenSpender public spender;
    IGST2 gasToken;
    address payable owner;
    uint fee; // 10000 => 100%, 1 => 0.01%

    event OneInchFeePaid(
        IERC20 indexed toToken,
        address indexed referrer,
        uint256 fee
    );

    modifier onlyOwner {
        require(
            msg.sender == owner,
            "Only owner can call this function."
        );
        _;
    }

    constructor(
        address payable _owner,
        IGST2 _gasToken,
        uint _fee
    )
    public
    {
        spender = new TokenSpender();
        owner = _owner;
        gasToken = _gasToken;
        fee = _fee;
    }

    function setFee(uint _fee) public onlyOwner {

        fee = _fee;
    }

    function aggregate(
        IERC20 fromToken,
        IERC20 toToken,
        uint tokensAmount,
        address[] memory callAddresses,
        bytes memory callDataConcat,
        uint[] memory starts,
        uint[] memory values,
        uint mintGasPrice,
        uint minTokensAmount,
        address payable referrer
    )
    public
    payable
    returns (uint returnAmount)
    {
        returnAmount = gasleft();
        uint gasTokenBalance = gasToken.balanceOf(address(this));

        require(callAddresses.length + 1 == starts.length);

        if (address(fromToken) != ETH_ADDRESS) {

            spender.claimTokens(fromToken, msg.sender, address(this), tokensAmount);
        }

        for (uint i = 0; i < starts.length - 1; i++) {

            if (starts[i + 1] - starts[i] > 0) {

                require(
                    callDataConcat[starts[i] + 0] != spender.claimTokens.selector[0] ||
                    callDataConcat[starts[i] + 1] != spender.claimTokens.selector[1] ||
                    callDataConcat[starts[i] + 2] != spender.claimTokens.selector[2] ||
                    callDataConcat[starts[i] + 3] != spender.claimTokens.selector[3]
                );
                require(callAddresses[i].externalCall(values[i], callDataConcat, starts[i], starts[i + 1] - starts[i]));
            }
        }

        if (address(toToken) == ETH_ADDRESS) {
            require(address(this).balance >= minTokensAmount);
        } else {
            require(toToken.balanceOf(address(this)) >= minTokensAmount);
        }

        //

        require(gasTokenBalance == gasToken.balanceOf(address(this)));
        if (mintGasPrice > 0) {
            audoRefundGas(returnAmount, mintGasPrice);
        }

        //

        returnAmount = _balanceOf(toToken, address(this)) * fee / 10000;
        if (referrer != address(0)) {
            returnAmount /= 2;
            if (!_transfer(toToken, referrer, returnAmount, true)) {
                returnAmount *= 2;
                emit OneInchFeePaid(toToken, address(0), returnAmount);
            } else {
                emit OneInchFeePaid(toToken, referrer, returnAmount / 2);
            }
        }

        _transfer(toToken, owner, returnAmount, false);

        returnAmount = _balanceOf(toToken, address(this));
        _transfer(toToken, msg.sender, returnAmount, false);
    }

    function infiniteApproveIfNeeded(IERC20 token, address to) external {
        if (
            address(token) != ETH_ADDRESS &&
            token.allowance(address(this), to) == 0
        ) {
            token.safeApprove(to, uint256(-1));
        }
    }

    function withdrawAllToken(IWETH token) external {
        uint256 amount = token.balanceOf(address(this));
        token.withdraw(amount);
    }

    function _balanceOf(IERC20 token, address who) internal view returns(uint256) {
        if (address(token) == ETH_ADDRESS || token == IERC20(0)) {
            return who.balance;
        } else {
            return token.balanceOf(who);
        }
    }

    function _transfer(IERC20 token, address payable to, uint256 amount, bool allowFail) internal returns(bool) {
        if (address(token) == ETH_ADDRESS || token == IERC20(0)) {
            if (allowFail) {
                return to.send(amount);
            } else {
                to.transfer(amount);
                return true;
            }
        } else {
            token.safeTransfer(to, amount);
            return true;
        }
    }

    function audoRefundGas(
        uint startGas,
        uint mintGasPrice
    )
    private
    returns (uint freed)
    {
        uint MINT_BASE = 32254;
        uint MINT_TOKEN = 36543;
        uint FREE_BASE = 14154;
        uint FREE_TOKEN = 6870;
        uint REIMBURSE = 24000;

        uint tokensAmount = ((startGas - gasleft()) + FREE_BASE) / (2 * REIMBURSE - FREE_TOKEN);
        uint maxReimburse = tokensAmount * REIMBURSE;

        uint mintCost = MINT_BASE + (tokensAmount * MINT_TOKEN);
        uint freeCost = FREE_BASE + (tokensAmount * FREE_TOKEN);

        uint efficiency = (maxReimburse * 100 * tx.gasprice) / (mintCost * mintGasPrice + freeCost * tx.gasprice);

        if (efficiency > 100) {

            return refundGas(
                tokensAmount
            );
        } else {

            return 0;
        }
    }

    function refundGas(
        uint tokensAmount
    )
    private
    returns (uint freed)
    {

        if (tokensAmount > 0) {

            uint safeNumTokens = 0;
            uint gas = gasleft();

            if (gas >= 27710) {
                safeNumTokens = (gas - 27710) / (1148 + 5722 + 150);
            }

            if (tokensAmount > safeNumTokens) {
                tokensAmount = safeNumTokens;
            }

            uint gasTokenBalance = IERC20(address(gasToken)).balanceOf(address(this));

            if (tokensAmount > 0 && gasTokenBalance >= tokensAmount) {

                return gasToken.freeUpTo(tokensAmount);
            } else {

                return 0;
            }
        } else {

            return 0;
        }
    }

    function() external payable {

        if (msg.value == 0 && msg.sender == owner) {

            IERC20 _gasToken = IERC20(address(gasToken));

            owner.transfer(address(this).balance);
            _gasToken.safeTransfer(owner, _gasToken.balanceOf(address(this)));
        }
    }
}

Contract Security Audit

Contract ABI

[{"constant":false,"inputs":[{"name":"fromToken","type":"address"},{"name":"toToken","type":"address"},{"name":"tokensAmount","type":"uint256"},{"name":"callAddresses","type":"address[]"},{"name":"callDataConcat","type":"bytes"},{"name":"starts","type":"uint256[]"},{"name":"values","type":"uint256[]"},{"name":"mintGasPrice","type":"uint256"},{"name":"minTokensAmount","type":"uint256"},{"name":"referrer","type":"address"}],"name":"aggregate","outputs":[{"name":"returnAmount","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_fee","type":"uint256"}],"name":"setFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"token","type":"address"}],"name":"withdrawAllToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"token","type":"address"},{"name":"to","type":"address"}],"name":"infiniteApproveIfNeeded","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"spender","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_owner","type":"address"},{"name":"_gasToken","type":"address"},{"name":"_fee","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"toToken","type":"address"},{"indexed":true,"name":"referrer","type":"address"},{"indexed":false,"name":"fee","type":"uint256"}],"name":"OneInchFeePaid","type":"event"}]

608060405234801561001057600080fd5b506040516060806117c68339810180604052606081101561003057600080fd5b508051602082015160409283015192519192909161004d906100b1565b604051809103906000f080158015610069573d6000803e3d6000fd5b50600080546001600160a01b03199081166001600160a01b039384161790915560028054821695831695909517909455600180549094169216919091179091556003556100be565b61041c806113aa83390190565b6112dd806100cd6000396000f3fe60806040526004361061004a5760003560e01c8063261fc7ef1461014757806369fe0e2d146103b8578063ae4dd0fc146103e2578063c9b2735914610415578063e8edc81614610450575b3415801561006257506002546001600160a01b031633145b15610145576001546002546040516001600160a01b03928316929190911690303180156108fc02916000818181858888f193505050501580156100a9573d6000803e3d6000fd5b5060025460408051600160e01b6370a082310281523060048201529051610143926001600160a01b0390811692908516916370a0823191602480820192602092909190829003018186803b15801561010057600080fd5b505afa158015610114573d6000803e3d6000fd5b505050506040513d602081101561012a57600080fd5b50516001600160a01b038416919063ffffffff61048116565b505b005b6103a6600480360361014081101561015e57600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b81111561019857600080fd5b8201836020820111156101aa57600080fd5b803590602001918460208302840111600160201b831117156101cb57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561021a57600080fd5b82018360208201111561022c57600080fd5b803590602001918460018302840111600160201b8311171561024d57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561029f57600080fd5b8201836020820111156102b157600080fd5b803590602001918460208302840111600160201b831117156102d257600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561032157600080fd5b82018360208201111561033357600080fd5b803590602001918460208302840111600160201b8311171561035457600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050823593505050602081013590604001356001600160a01b03166104db565b60408051918252519081900360200190f35b3480156103c457600080fd5b50610145600480360360208110156103db57600080fd5b5035610ae8565b3480156103ee57600080fd5b506101456004803603602081101561040557600080fd5b50356001600160a01b0316610b39565b34801561042157600080fd5b506101456004803603604081101561043857600080fd5b506001600160a01b0381358116916020013516610c1d565b34801561045c57600080fd5b50610465610ceb565b604080516001600160a01b039092168252519081900360200190f35b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0316600160e01b63a9059cbb021790526104d6908490610cfa565b505050565b60005a60015460408051600160e01b6370a0823102815230600482015290519293506000926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561053257600080fd5b505afa158015610546573d6000803e3d6000fd5b505050506040513d602081101561055c57600080fd5b505187518a5191925060019091011461057457600080fd5b6001600160a01b038c1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14610659576000809054906101000a90046001600160a01b03166001600160a01b0316630a5ea4668d33308e6040518563ffffffff1660e01b815260040180856001600160a01b03166001600160a01b03168152602001846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b03168152602001828152602001945050505050600060405180830381600087803b15801561064057600080fd5b505af1158015610654573d6000803e3d6000fd5b505050505b60005b600188510381101561086557600088828151811061067657fe5b602002602001015189836001018151811061068d57fe5b602002602001015103111561085d578751600160f91b600502908a908a90849081106106b557fe5b6020026020010151600001815181106106ca57fe5b602001015160f81c60f81b6001600160f81b03191614158061072d57508751600160f91b602f02908a908a908490811061070057fe5b60200260200101516001018151811061071557fe5b602001015160f81c60f81b6001600160f81b03191614155b8061077957508751600160fa1b602902908a908a908490811061074c57fe5b60200260200101516002018151811061076157fe5b602001015160f81c60f81b6001600160f81b03191614155b806107c557508751600160f91b603302908a908a908490811061079857fe5b6020026020010151600301815181106107ad57fe5b602001015160f81c60f81b6001600160f81b03191614155b6107ce57600080fd5b6108548782815181106107dd57fe5b60200260200101518a8a84815181106107f257fe5b60200260200101518b858151811061080657fe5b60200260200101518c866001018151811061081d57fe5b6020026020010151038e868151811061083257fe5b60200260200101516001600160a01b0316610df690949392919063ffffffff16565b61085d57600080fd5b60010161065c565b506001600160a01b038b1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561089e57303184111561089957600080fd5b610921565b60408051600160e01b6370a08231028152306004820152905185916001600160a01b038e16916370a0823191602480820192602092909190829003018186803b1580156108ea57600080fd5b505afa1580156108fe573d6000803e3d6000fd5b505050506040513d602081101561091457600080fd5b5051101561092157600080fd5b60015460408051600160e01b6370a0823102815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561096f57600080fd5b505afa158015610983573d6000803e3d6000fd5b505050506040513d602081101561099957600080fd5b505181146109a657600080fd5b84156109b8576109b68286610e1a565b505b6127106003546109c88d30610e9e565b02816109d057fe5b0491506001600160a01b03831615610aa4576002820491506109f58b84846001610f71565b610a505760028202915060006001600160a01b03168b6001600160a01b03167f713f62c1c63c3bb59b28b58e8486c5992361993a21817d75472fe9f2abad24cf846040518082815260200191505060405180910390a3610aa4565b826001600160a01b03168b6001600160a01b03167f713f62c1c63c3bb59b28b58e8486c5992361993a21817d75472fe9f2abad24cf60028581610a8f57fe5b60408051929091048252519081900360200190a35b600254610abe908c906001600160a01b0316846000610f71565b50610ac98b30610e9e565b9150610ad88b33846000610f71565b50509a9950505050505050505050565b6002546001600160a01b03163314610b3457604051600160e51b62461bcd0281526004018080602001828103825260228152602001806112906022913960400191505060405180910390fd5b600355565b60408051600160e01b6370a0823102815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b158015610b8657600080fd5b505afa158015610b9a573d6000803e3d6000fd5b505050506040513d6020811015610bb057600080fd5b505160408051600160e01b632e1a7d4d0281526004810183905290519192506001600160a01b03841691632e1a7d4d9160248082019260009290919082900301818387803b158015610c0157600080fd5b505af1158015610c15573d6000803e3d6000fd5b505050505050565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14801590610cc6575060408051600160e11b636eb1769f0281523060048201526001600160a01b03838116602483015291519184169163dd62ed3e91604480820192602092909190829003018186803b158015610c9857600080fd5b505afa158015610cac573d6000803e3d6000fd5b505050506040513d6020811015610cc257600080fd5b5051155b15610ce757610ce76001600160a01b0383168260001963ffffffff61104216565b5050565b6000546001600160a01b031681565b610d0c826001600160a01b0316611129565b610d1557600080fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310610d535780518252601f199092019160209182019101610d34565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610db5576040519150601f19603f3d011682016040523d82523d6000602084013e610dba565b606091505b509150915081610dc957600080fd5b805115610df057808060200190516020811015610de557600080fd5b5051610df057600080fd5b50505050565b600060405160208501600082858784018a8c6187965a03f198975050505050505050565b6000617dfe618ebf61374a611ad6615dc08561a0aa845a8b030181610e3b57fe5b0490508181028582028701848302860160003a8083028d8502019060649086020281610e6357fe5b0490506064811115610e8957610e7885611133565b9a5050505050505050505050610e98565b60009a50505050505050505050505b92915050565b60006001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1480610ed257506001600160a01b038316155b15610ee857506001600160a01b03811631610e98565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610f3e57600080fd5b505afa158015610f52573d6000803e3d6000fd5b505050506040513d6020811015610f6857600080fd5b50519050610e98565b60006001600160a01b03851673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1480610fa557506001600160a01b038516155b1561101c578115610fdc576040516001600160a01b0385169084156108fc029085906000818181858888f19350505050905061103a565b6040516001600160a01b0385169084156108fc029085906000818181858888f19350505050158015611012573d6000803e3d6000fd5b506001905061103a565b6110366001600160a01b038616858563ffffffff61048116565b5060015b949350505050565b8015806110cb575060408051600160e11b636eb1769f0281523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561109d57600080fd5b505afa1580156110b1573d6000803e3d6000fd5b505050506040513d60208110156110c757600080fd5b5051155b6110d457600080fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0316600160e01b63095ea7b3021790526104d6908490610cfa565b803b15155b919050565b60008115611287576000805a9050616c3e811061115757611b6c616c3d1982010491505b81841115611163578193505b60015460408051600160e01b6370a0823102815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b5051905084158015906111ee5750848110155b1561127b5760015460408051600160e11b6331b35c9b0281526004810188905290516001600160a01b0390921691636366b936916024808201926020929091908290030181600087803b15801561124457600080fd5b505af1158015611258573d6000803e3d6000fd5b505050506040513d602081101561126e57600080fd5b5051935061112e92505050565b6000935050505061112e565b50600061112e56fe4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f6e2ea165627a7a7230582060fd220e78050a6caaf3cae7ebb42156f556a53157e2a9cdf6acf7d4f3563d44002960806040819052600080546001600160a01b03191633178082556001600160a01b0316917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a36103c5806100576000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80630a5ea4661461005c578063715018a61461009a5780638da5cb5b146100a25780638f32d59b146100c6578063f2fde38b146100e2575b600080fd5b6100986004803603608081101561007257600080fd5b506001600160a01b03813581169160208101358216916040820135169060600135610108565b005b61009861013a565b6100aa610195565b604080516001600160a01b039092168252519081900360200190f35b6100ce6101a4565b604080519115158252519081900360200190f35b610098600480360360208110156100f857600080fd5b50356001600160a01b03166101b5565b6101106101a4565b61011957600080fd5b6101346001600160a01b03851684848463ffffffff6101d216565b50505050565b6101426101a4565b61014b57600080fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b6000546001600160a01b0316331490565b6101bd6101a4565b6101c657600080fd5b6101cf8161022f565b50565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b0316600160e01b6323b872dd0217905261013490859061029d565b6001600160a01b03811661024257600080fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6102af826001600160a01b0316610393565b6102b857600080fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106102f65780518252601f1990920191602091820191016102d7565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610358576040519150601f19603f3d011682016040523d82523d6000602084013e61035d565b606091505b50915091508161036c57600080fd5b8051156101345780806020019051602081101561038857600080fd5b505161013457600080fd5b3b15159056fea165627a7a72305820527e51161d7752928ef3397f1ca34e4c247f84785325db9edb769475e7251f6a00290000000000000000000000004d37f28d2db99e8d35a6c725a5f1749a085850a30000000000000000000000000000000000b3f879cb30fe243b4dfee438691c040000000000000000000000000000000000000000000000000000000000000002

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

0000000000000000000000004d37f28d2db99e8d35a6c725a5f1749a085850a30000000000000000000000000000000000b3f879cb30fe243b4dfee438691c040000000000000000000000000000000000000000000000000000000000000002

-----Decoded View---------------
Arg [0] : _owner (address): 0x4D37f28D2db99e8d35A6C725a5f1749A085850a3
Arg [1] : _gasToken (address): 0x0000000000b3F879cb30FE243b4Dfee438691c04
Arg [2] : _fee (uint256): 2

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000004d37f28d2db99e8d35a6c725a5f1749a085850a3
Arg [1] : 0000000000000000000000000000000000b3f879cb30fe243b4dfee438691c04
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000002


Swarm Source

bzzr://527e51161d7752928ef3397f1ca34e4c247f84785325db9edb769475e7251f6a
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.