Contract 0x793EbBe21607e4F04788F89c7a9b97320773Ec59

 

TxHash Block Age From To Value [TxFee]
0x779f86384da19ce7707d88e57b6f8b86c3c4278bc0c9fa9cd36022ae03994c93723871731 days 17 hrs ago0x1bdb1783505f626a55a5e3dd3e366df1cd69c055 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec5917 Ether0.0085290336
0x449477ce3ef8286c2ecd8205dd7575a066a17f7370dbe8f7ced126ef1c463be5717523045 days 23 hrs ago0xc6df64667154423740b3095d5ec88ac5298468ac IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.3 Ether0.002940397
0x6ff1e928699477e0e9c33f0573ee87944b148661a13143d40f91b8ca1bce30ae715446350 days 5 hrs ago0x36969179eca29e4c9d43e7a0cd9eebd10a3c6df9 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.48 Ether0.005809077
0x647c01081164e1d5d85f3e148511038e89319ff83d688fafa500c7f7d23c0e4e715373750 days 9 hrs ago0xbcf755f75aad75a7444704668a79e05c2a4417a3 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec5925 Ether0.0057983904
0xd3649f3c0ae0a7c2f87dad363e94214a9f5a319530a0bc81e9a8a3fb3054a299715276450 days 13 hrs ago0x74e2f04def059397d4a3382fd4a85df062d75bf4 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec591 Ether0.007890278
0x5fcd467c32e960af551e5ab7e3226c714e40a31f62cff4d39b88faed9c0d6862715229650 days 15 hrs ago0xcf82fdd676ffebf4f5ebe344b06f76110be6942b IN  0x793ebbe21607e4f04788f89c7a9b97320773ec593.65710698 Ether0.0033510645
0x00084b1cab4bbc3b697a0eac38c300f7fc5df210b3b284016dcf35228477b416715156950 days 19 hrs ago0xa7b7b2b38b74ed1941b627b0f68a36c5b52956ed IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.10591425 Ether0.0032763148
0x8bea501d57275f873d7c7b8495d0026d597e1c550e4a24cb62d77059c653e03b714963651 days 4 hrs ago0x7cc6043881ba81bec5f9d10311bfc598e5a73d8c IN  0x793ebbe21607e4f04788f89c7a9b97320773ec591 Ether0.001434468
0x6f40329b1420cf8bd3571032458040e88a7015a326f061523406bd77d0a61612714910951 days 7 hrs ago0x160f713d638f7c849f807b97c6b71a3581b01dc3 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.16 Ether0.003801001
0x3d45f1ef94dc21859104300a2bd8619737baba72acbc72d76becd7f251c51afe714813651 days 12 hrs ago0x935fdf040b2cd9741e2d8a9a13a24da82a26eadb IN  0x793ebbe21607e4f04788f89c7a9b97320773ec591.2 Ether0.007889574
0x9ec3822c63e46d15ca9f302533585d818474abd0524aa558dabd1ce9c5bec0c1714667851 days 19 hrs ago0xfa5986ccb015661e55c79ed391f8430d86af385f IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590 Ether0.00059013
0xef84a2be890036fca5564e7c30bd8e4911155ea58a1a6f34935975e211f9204d714666851 days 19 hrs ago0xfa5986ccb015661e55c79ed391f8430d86af385f IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590 Ether0.0006074952
0x096977714a3c60430567d59ef7bcc88d97528fc57a29cabfc8fb47d3b57a786e714666251 days 19 hrs ago0xfa5986ccb015661e55c79ed391f8430d86af385f IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590 Ether0.0005396235
0xd97d7fc52eb50136e3533a74f41d677fa8c9ff9b132815f13b14d4a5f33fdd66714665151 days 19 hrs ago0xfa5986ccb015661e55c79ed391f8430d86af385f IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590 Ether0.000606996
0xc50d4638be72abe63e60229bb23f3241af7dbc18fb4d2f420710b684843d27dd714638951 days 20 hrs ago0xfa5986ccb015661e55c79ed391f8430d86af385f IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.2 Ether0.0005682105
0x20e8fb415bcc26225073cb429fed4e5540520062fea8d03cb74c6e8e2ae07bae714549452 days 1 hr ago0x866f334aaef32c022a73262b4f854afe1269dfd5 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.5 Ether0.0032305708
0x94f65bdb5f4465bbb9ea19686ec6ad49908c6415a6f2469a3bfa6bba9af086cb714523552 days 2 hrs ago0x2b352b5531c626c6e0ff31a3bb8c71e508849705 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec593.822669668761982 Ether0.0037474785
0x52f19fbf467c7e8c8a5fd4545a96a2f5fe6c8621e7e32f7ef3432dc70b37ec80714435552 days 6 hrs ago0x35a7a53a29c6d06e9d3c070d388c20676846b795 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.111384 Ether0.0034252382
0x6f9aba44d883d2b2579322acf13fe3f0c54e706eeefc953e3360976059b42dbd714417152 days 7 hrs ago0xa84944735b66e957fe385567dcc85975022fe68a IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.986076184263918 Ether0.0145949
0xcefab592b2778ff9f7113493591a23f2c96effdada46b4d7924a21b9baf2214a714395852 days 8 hrs ago0x5cfc6125672a7d1af61da570e09b9047d586bb7a IN  0x793ebbe21607e4f04788f89c7a9b97320773ec5911.201492472376549 Ether0.003723725
0x427ca51df6ba5c82222b0cb6537fd23f26b70ef729b25065a6eca6b3c2f1d08b714376552 days 9 hrs ago0x50ffee8f3e9696b685190c293f7a0db68b54ddca IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.423 Ether0.006455106
0x6cef15ea74cba33e09575ac7a42460f465b465ad2a4628feb712cb9e53c2cde6714349252 days 10 hrs ago0x06a465bca91bed9b65f519866314814fbd10ba0b IN  0x793ebbe21607e4f04788f89c7a9b97320773ec591 Ether0.008607576
0x281fad12c7b21fb64cbf1a84ca9f3271fe070f49973e8fa07c558bf879e365c9714262952 days 15 hrs ago0x6f21af74fac7d7f80e3ae89070f6d38e18de9ea9 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec590.1180548 Ether0.0011673872
0x2ed962752909f9f7783f602ca67e58a89a7835af7218b4e2a5ef9b67fc233b3a714193352 days 18 hrs ago0x498c1bdb47735640c524c9511d14be9a3c315837 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec595.51 Ether0.0036544656
0x19f757955de7b0caa4075329da10c9010352c057d4a49e3c2b74f85f3ba3edfb714155452 days 20 hrs ago0x90a286841a7e928509c4016186ee4ced3e2ec079 IN  0x793ebbe21607e4f04788f89c7a9b97320773ec59500 Ether0.0046896538
[ Download CSV Export 

Latest 25 internal transaction, Click here to view more Internal Transactions as a result of Contract Execution

Parent TxHash Block Age From To Value
0x779f86384da19ce7707d88e57b6f8b86c3c4278bc0c9fa9cd36022ae03994c93723871731 days 17 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc217 Ether
0x449477ce3ef8286c2ecd8205dd7575a066a17f7370dbe8f7ced126ef1c463be5717523045 days 23 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20.3 Ether
0x6ff1e928699477e0e9c33f0573ee87944b148661a13143d40f91b8ca1bce30ae715446350 days 5 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20.48 Ether
0x647c01081164e1d5d85f3e148511038e89319ff83d688fafa500c7f7d23c0e4e715373750 days 9 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc225 Ether
0xd3649f3c0ae0a7c2f87dad363e94214a9f5a319530a0bc81e9a8a3fb3054a299715276450 days 13 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc21 Ether
0x5fcd467c32e960af551e5ab7e3226c714e40a31f62cff4d39b88faed9c0d6862715229650 days 15 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xcf82fdd676ffebf4f5ebe344b06f76110be6942b0.07170798 Ether
0x5fcd467c32e960af551e5ab7e3226c714e40a31f62cff4d39b88faed9c0d6862715229650 days 15 hrs ago0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20x793ebbe21607e4f04788f89c7a9b97320773ec590.07170798 Ether
0x5fcd467c32e960af551e5ab7e3226c714e40a31f62cff4d39b88faed9c0d6862715229650 days 15 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc23.65710698 Ether
0x00084b1cab4bbc3b697a0eac38c300f7fc5df210b3b284016dcf35228477b416715156950 days 19 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xa7b7b2b38b74ed1941b627b0f68a36c5b52956ed0.00125025 Ether
0x00084b1cab4bbc3b697a0eac38c300f7fc5df210b3b284016dcf35228477b416715156950 days 19 hrs ago0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20x793ebbe21607e4f04788f89c7a9b97320773ec590.00125025 Ether
0x00084b1cab4bbc3b697a0eac38c300f7fc5df210b3b284016dcf35228477b416715156950 days 19 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20.10591425 Ether
0x8bea501d57275f873d7c7b8495d0026d597e1c550e4a24cb62d77059c653e03b714963651 days 4 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc21 Ether
0x6f40329b1420cf8bd3571032458040e88a7015a326f061523406bd77d0a61612714910951 days 7 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20.16 Ether
0x3d45f1ef94dc21859104300a2bd8619737baba72acbc72d76becd7f251c51afe714813651 days 12 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc21.2 Ether
0x9ec3822c63e46d15ca9f302533585d818474abd0524aa558dabd1ce9c5bec0c1714667851 days 19 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xfa5986ccb015661e55c79ed391f8430d86af385f0.047674751999999999 Ether
0x9ec3822c63e46d15ca9f302533585d818474abd0524aa558dabd1ce9c5bec0c1714667851 days 19 hrs ago0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20x793ebbe21607e4f04788f89c7a9b97320773ec590.047674751999999999 Ether
0xef84a2be890036fca5564e7c30bd8e4911155ea58a1a6f34935975e211f9204d714666851 days 19 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xfa5986ccb015661e55c79ed391f8430d86af385f0.111572783462282398 Ether
0xef84a2be890036fca5564e7c30bd8e4911155ea58a1a6f34935975e211f9204d714666851 days 19 hrs ago0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20x793ebbe21607e4f04788f89c7a9b97320773ec590.111572783462282398 Ether
0xd97d7fc52eb50136e3533a74f41d677fa8c9ff9b132815f13b14d4a5f33fdd66714665151 days 19 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xfa5986ccb015661e55c79ed391f8430d86af385f0.037245899999999999 Ether
0xd97d7fc52eb50136e3533a74f41d677fa8c9ff9b132815f13b14d4a5f33fdd66714665151 days 19 hrs ago0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20x793ebbe21607e4f04788f89c7a9b97320773ec590.037245899999999999 Ether
0xc50d4638be72abe63e60229bb23f3241af7dbc18fb4d2f420710b684843d27dd714638951 days 20 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20.2 Ether
0x20e8fb415bcc26225073cb429fed4e5540520062fea8d03cb74c6e8e2ae07bae714549452 days 1 hr ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20.5 Ether
0x94f65bdb5f4465bbb9ea19686ec6ad49908c6415a6f2469a3bfa6bba9af086cb714523552 days 2 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590x2b352b5531c626c6e0ff31a3bb8c71e5088497050.074954307230627108 Ether
0x94f65bdb5f4465bbb9ea19686ec6ad49908c6415a6f2469a3bfa6bba9af086cb714523552 days 2 hrs ago0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20x793ebbe21607e4f04788f89c7a9b97320773ec590.074954307230627108 Ether
0x94f65bdb5f4465bbb9ea19686ec6ad49908c6415a6f2469a3bfa6bba9af086cb714523552 days 2 hrs ago0x793ebbe21607e4f04788f89c7a9b97320773ec590xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc23.822669668761982513 Ether
[ Download CSV Export 

Contract Source Code Verified (Exact Match)

Contract Name:
ProxyCreationAndExecute

Compiler Version
v0.4.21+commit.dfe3193c

Optimization Enabled:
Yes

Runs (Optimizer):
200

Contract Source Code

pragma solidity ^0.4.16;

contract DSMath {
    function add(uint x, uint y) internal pure returns (uint z) {
        require((z = x + y) >= x);
    }
    function sub(uint x, uint y) internal pure returns (uint z) {
        require((z = x - y) <= x);
    }
    function mul(uint x, uint y) internal pure returns (uint z) {
        require(y == 0 || (z = x * y) / y == x);
    }

    function min(uint x, uint y) internal pure returns (uint z) {
        return x <= y ? x : y;
    }
    function max(uint x, uint y) internal pure returns (uint z) {
        return x >= y ? x : y;
    }
    function imin(int x, int y) internal pure returns (int z) {
        return x <= y ? x : y;
    }
    function imax(int x, int y) internal pure returns (int z) {
        return x >= y ? x : y;
    }

    uint constant WAD = 10 ** 18;
    uint constant RAY = 10 ** 27;

    function wmul(uint x, uint y) internal pure returns (uint z) {
        z = add(mul(x, y), WAD / 2) / WAD;
    }
    function rmul(uint x, uint y) internal pure returns (uint z) {
        z = add(mul(x, y), RAY / 2) / RAY;
    }
    function wdiv(uint x, uint y) internal pure returns (uint z) {
        z = add(mul(x, WAD), y / 2) / y;
    }
    function rdiv(uint x, uint y) internal pure returns (uint z) {
        z = add(mul(x, RAY), y / 2) / y;
    }

    // This famous algorithm is called "exponentiation by squaring"
    // and calculates x^n with x as fixed-point and n as regular unsigned.
    //
    // It's O(log n), instead of O(n) for naive repeated multiplication.
    //
    // These facts are why it works:
    //
    //  If n is even, then x^n = (x^2)^(n/2).
    //  If n is odd,  then x^n = x * x^(n-1),
    //   and applying the equation for even x gives
    //    x^n = x * (x^2)^((n-1) / 2).
    //
    //  Also, EVM division is flooring and
    //    floor[(n-1) / 2] = floor[n / 2].
    //
    function rpow(uint x, uint n) internal pure returns (uint z) {
        z = n % 2 != 0 ? x : RAY;

        for (n /= 2; n != 0; n /= 2) {
            x = rmul(x, x);

            if (n % 2 != 0) {
                z = rmul(z, x);
            }
        }
    }
}

contract OtcInterface {
    function sellAllAmount(address, uint, address, uint) public returns (uint);
    function buyAllAmount(address, uint, address, uint) public returns (uint);
    function getPayAmount(address, address, uint) public constant returns (uint);
}

contract TokenInterface {
    function balanceOf(address) public returns (uint);
    function allowance(address, address) public returns (uint);
    function approve(address, uint) public;
    function transfer(address,uint) public returns (bool);
    function transferFrom(address, address, uint) public returns (bool);
    function deposit() public payable;
    function withdraw(uint) public;
}

contract OasisDirectProxy is DSMath {
    function withdrawAndSend(TokenInterface wethToken, uint wethAmt) internal {
        wethToken.withdraw(wethAmt);
        require(msg.sender.call.value(wethAmt)());
    }

    function sellAllAmount(OtcInterface otc, TokenInterface payToken, uint payAmt, TokenInterface buyToken, uint minBuyAmt) public returns (uint buyAmt) {
        require(payToken.transferFrom(msg.sender, this, payAmt));
        if (payToken.allowance(this, otc) < payAmt) {
            payToken.approve(otc, uint(-1));
        }
        buyAmt = otc.sellAllAmount(payToken, payAmt, buyToken, minBuyAmt);
        require(buyToken.transfer(msg.sender, buyAmt));
    }

    function sellAllAmountPayEth(OtcInterface otc, TokenInterface wethToken, TokenInterface buyToken, uint minBuyAmt) public payable returns (uint buyAmt) {
        wethToken.deposit.value(msg.value)();
        if (wethToken.allowance(this, otc) < msg.value) {
            wethToken.approve(otc, uint(-1));
        }
        buyAmt = otc.sellAllAmount(wethToken, msg.value, buyToken, minBuyAmt);
        require(buyToken.transfer(msg.sender, buyAmt));
    }

    function sellAllAmountBuyEth(OtcInterface otc, TokenInterface payToken, uint payAmt, TokenInterface wethToken, uint minBuyAmt) public returns (uint wethAmt) {
        require(payToken.transferFrom(msg.sender, this, payAmt));
        if (payToken.allowance(this, otc) < payAmt) {
            payToken.approve(otc, uint(-1));
        }
        wethAmt = otc.sellAllAmount(payToken, payAmt, wethToken, minBuyAmt);
        withdrawAndSend(wethToken, wethAmt);
    }

    function buyAllAmount(OtcInterface otc, TokenInterface buyToken, uint buyAmt, TokenInterface payToken, uint maxPayAmt) public returns (uint payAmt) {
        uint payAmtNow = otc.getPayAmount(payToken, buyToken, buyAmt);
        require(payAmtNow <= maxPayAmt);
        require(payToken.transferFrom(msg.sender, this, payAmtNow));
        if (payToken.allowance(this, otc) < payAmtNow) {
            payToken.approve(otc, uint(-1));
        }
        payAmt = otc.buyAllAmount(buyToken, buyAmt, payToken, payAmtNow);
        require(buyToken.transfer(msg.sender, min(buyAmt, buyToken.balanceOf(this)))); // To avoid rounding issues we check the minimum value
    }

    function buyAllAmountPayEth(OtcInterface otc, TokenInterface buyToken, uint buyAmt, TokenInterface wethToken) public payable returns (uint wethAmt) {
        // In this case user needs to send more ETH than a estimated value, then contract will send back the rest
        wethToken.deposit.value(msg.value)();
        if (wethToken.allowance(this, otc) < msg.value) {
            wethToken.approve(otc, uint(-1));
        }
        wethAmt = otc.buyAllAmount(buyToken, buyAmt, wethToken, msg.value);
        require(buyToken.transfer(msg.sender, min(buyAmt, buyToken.balanceOf(this)))); // To avoid rounding issues we check the minimum value
        withdrawAndSend(wethToken, sub(msg.value, wethAmt));
    }

    function buyAllAmountBuyEth(OtcInterface otc, TokenInterface wethToken, uint wethAmt, TokenInterface payToken, uint maxPayAmt) public returns (uint payAmt) {
        uint payAmtNow = otc.getPayAmount(payToken, wethToken, wethAmt);
        require(payAmtNow <= maxPayAmt);
        require(payToken.transferFrom(msg.sender, this, payAmtNow));
        if (payToken.allowance(this, otc) < payAmtNow) {
            payToken.approve(otc, uint(-1));
        }
        payAmt = otc.buyAllAmount(wethToken, wethAmt, payToken, payAmtNow);
        withdrawAndSend(wethToken, wethAmt);
    }

    function() public payable {}
}

contract DSAuthority {
    function canCall(
        address src, address dst, bytes4 sig
    ) public view returns (bool);
}

contract DSAuthEvents {
    event LogSetAuthority (address indexed authority);
    event LogSetOwner     (address indexed owner);
}

contract DSAuth is DSAuthEvents {
    DSAuthority  public  authority;
    address      public  owner;

    function DSAuth() public {
        owner = msg.sender;
        LogSetOwner(msg.sender);
    }

    function setOwner(address owner_)
        public
        auth
    {
        owner = owner_;
        LogSetOwner(owner);
    }

    function setAuthority(DSAuthority authority_)
        public
        auth
    {
        authority = authority_;
        LogSetAuthority(authority);
    }

    modifier auth {
        require(isAuthorized(msg.sender, msg.sig));
        _;
    }

    function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
        if (src == address(this)) {
            return true;
        } else if (src == owner) {
            return true;
        } else if (authority == DSAuthority(0)) {
            return false;
        } else {
            return authority.canCall(src, this, sig);
        }
    }
}

contract DSNote {
    event LogNote(
        bytes4   indexed  sig,
        address  indexed  guy,
        bytes32  indexed  foo,
        bytes32  indexed  bar,
        uint              wad,
        bytes             fax
    ) anonymous;

    modifier note {
        bytes32 foo;
        bytes32 bar;

        assembly {
            foo := calldataload(4)
            bar := calldataload(36)
        }

        LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);

        _;
    }
}

// DSProxy
// Allows code execution using a persistant identity This can be very
// useful to execute a sequence of atomic actions. Since the owner of
// the proxy can be changed, this allows for dynamic ownership models
// i.e. a multisig
contract DSProxy is DSAuth, DSNote {
    DSProxyCache public cache;  // global cache for contracts

    function DSProxy(address _cacheAddr) public {
        require(setCache(_cacheAddr));
    }

    function() public payable {
    }

    // use the proxy to execute calldata _data on contract _code
    function execute(bytes _code, bytes _data)
        public
        payable
        returns (address target, bytes32 response)
    {
        target = cache.read(_code);
        if (target == 0x0) {
            // deploy contract & store its address in cache
            target = cache.write(_code);
        }

        response = execute(target, _data);
    }

    function execute(address _target, bytes _data)
        public
        auth
        note
        payable
        returns (bytes32 response)
    {
        require(_target != 0x0);

        // call contract in current context
        assembly {
            let succeeded := delegatecall(sub(gas, 5000), _target, add(_data, 0x20), mload(_data), 0, 32)
            response := mload(0)      // load delegatecall output
            switch iszero(succeeded)
            case 1 {
                // throw if delegatecall failed
                revert(0, 0)
            }
        }
    }

    //set new cache
    function setCache(address _cacheAddr)
        public
        auth
        note
        returns (bool)
    {
        require(_cacheAddr != 0x0);        // invalid cache address
        cache = DSProxyCache(_cacheAddr);  // overwrite cache
        return true;
    }
}

// DSProxyFactory
// This factory deploys new proxy instances through build()
// Deployed proxy addresses are logged
contract DSProxyFactory {
    event Created(address indexed sender, address proxy, address cache);
    mapping(address=>bool) public isProxy;
    DSProxyCache public cache = new DSProxyCache();

    // deploys a new proxy instance
    // sets owner of proxy to caller
    function build() public returns (DSProxy proxy) {
        proxy = build(msg.sender);
    }

    // deploys a new proxy instance
    // sets custom owner of proxy
    function build(address owner) public returns (DSProxy proxy) {
        proxy = new DSProxy(cache);
        Created(owner, address(proxy), address(cache));
        proxy.setOwner(owner);
        isProxy[proxy] = true;
    }
}

// DSProxyCache
// This global cache stores addresses of contracts previously deployed
// by a proxy. This saves gas from repeat deployment of the same
// contracts and eliminates blockchain bloat.

// By default, all proxies deployed from the same factory store
// contracts in the same cache. The cache a proxy instance uses can be
// changed.  The cache uses the sha3 hash of a contract's bytecode to
// lookup the address
contract DSProxyCache {
    mapping(bytes32 => address) cache;

    function read(bytes _code) public view returns (address) {
        bytes32 hash = keccak256(_code);
        return cache[hash];
    }

    function write(bytes _code) public returns (address target) {
        assembly {
            target := create(0, add(_code, 0x20), mload(_code))
            switch iszero(extcodesize(target))
            case 1 {
                // throw if contract failed to deploy
                revert(0, 0)
            }
        }
        bytes32 hash = keccak256(_code);
        cache[hash] = target;
    }
}

contract ProxyCreationAndExecute is OasisDirectProxy {
    TokenInterface wethToken;

    function ProxyCreationAndExecute(address wethToken_) {
        wethToken = TokenInterface(wethToken_);
    }

    function createAndSellAllAmount(DSProxyFactory factory, OtcInterface otc, TokenInterface payToken, uint payAmt, TokenInterface buyToken, uint minBuyAmt) public returns (DSProxy proxy, uint buyAmt) {
        proxy = factory.build(msg.sender);
        buyAmt = sellAllAmount(otc, payToken, payAmt, buyToken, minBuyAmt);
    }

    function createAndSellAllAmountPayEth(DSProxyFactory factory, OtcInterface otc, TokenInterface buyToken, uint minBuyAmt) public payable returns (DSProxy proxy, uint buyAmt) {
        proxy = factory.build(msg.sender);
        buyAmt = sellAllAmountPayEth(otc, wethToken, buyToken, minBuyAmt);
    }

    function createAndSellAllAmountBuyEth(DSProxyFactory factory, OtcInterface otc, TokenInterface payToken, uint payAmt, uint minBuyAmt) public returns (DSProxy proxy, uint wethAmt) {
        proxy = factory.build(msg.sender);
        wethAmt = sellAllAmountBuyEth(otc, payToken, payAmt, wethToken, minBuyAmt);
    }

    function createAndBuyAllAmount(DSProxyFactory factory, OtcInterface otc, TokenInterface buyToken, uint buyAmt, TokenInterface payToken, uint maxPayAmt) public returns (DSProxy proxy, uint payAmt) {
        proxy = factory.build(msg.sender);
        payAmt = buyAllAmount(otc, buyToken, buyAmt, payToken, maxPayAmt);
    }

    function createAndBuyAllAmountPayEth(DSProxyFactory factory, OtcInterface otc, TokenInterface buyToken, uint buyAmt) public payable returns (DSProxy proxy, uint wethAmt) {
        proxy = factory.build(msg.sender);
        wethAmt = buyAllAmountPayEth(otc, buyToken, buyAmt, wethToken);
    }

    function createAndBuyAllAmountBuyEth(DSProxyFactory factory, OtcInterface otc, uint wethAmt, TokenInterface payToken, uint maxPayAmt) public returns (DSProxy proxy, uint payAmt) {
        proxy = factory.build(msg.sender);
        payAmt = buyAllAmountBuyEth(otc, wethToken, wethAmt, payToken, maxPayAmt);
    }

    function() public payable {
        require(msg.sender == address(wethToken));
    }
}

Contract ABI

[{"constant":false,"inputs":[{"name":"otc","type":"address"},{"name":"payToken","type":"address"},{"name":"payAmt","type":"uint256"},{"name":"wethToken","type":"address"},{"name":"minBuyAmt","type":"uint256"}],"name":"sellAllAmountBuyEth","outputs":[{"name":"wethAmt","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"otc","type":"address"},{"name":"payToken","type":"address"},{"name":"payAmt","type":"uint256"},{"name":"buyToken","type":"address"},{"name":"minBuyAmt","type":"uint256"}],"name":"sellAllAmount","outputs":[{"name":"buyAmt","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"otc","type":"address"},{"name":"buyToken","type":"address"},{"name":"buyAmt","type":"uint256"},{"name":"payToken","type":"address"},{"name":"maxPayAmt","type":"uint256"}],"name":"buyAllAmount","outputs":[{"name":"payAmt","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"factory","type":"address"},{"name":"otc","type":"address"},{"name":"wethAmt","type":"uint256"},{"name":"payToken","type":"address"},{"name":"maxPayAmt","type":"uint256"}],"name":"createAndBuyAllAmountBuyEth","outputs":[{"name":"proxy","type":"address"},{"name":"payAmt","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"factory","type":"address"},{"name":"otc","type":"address"},{"name":"payToken","type":"address"},{"name":"payAmt","type":"uint256"},{"name":"minBuyAmt","type":"uint256"}],"name":"createAndSellAllAmountBuyEth","outputs":[{"name":"proxy","type":"address"},{"name":"wethAmt","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"factory","type":"address"},{"name":"otc","type":"address"},{"name":"buyToken","type":"address"},{"name":"buyAmt","type":"uint256"}],"name":"createAndBuyAllAmountPayEth","outputs":[{"name":"proxy","type":"address"},{"name":"wethAmt","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"factory","type":"address"},{"name":"otc","type":"address"},{"name":"buyToken","type":"address"},{"name":"minBuyAmt","type":"uint256"}],"name":"createAndSellAllAmountPayEth","outputs":[{"name":"proxy","type":"address"},{"name":"buyAmt","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"factory","type":"address"},{"name":"otc","type":"address"},{"name":"buyToken","type":"address"},{"name":"buyAmt","type":"uint256"},{"name":"payToken","type":"address"},{"name":"maxPayAmt","type":"uint256"}],"name":"createAndBuyAllAmount","outputs":[{"name":"proxy","type":"address"},{"name":"payAmt","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"otc","type":"address"},{"name":"buyToken","type":"address"},{"name":"buyAmt","type":"uint256"},{"name":"wethToken","type":"address"}],"name":"buyAllAmountPayEth","outputs":[{"name":"wethAmt","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"factory","type":"address"},{"name":"otc","type":"address"},{"name":"payToken","type":"address"},{"name":"payAmt","type":"uint256"},{"name":"buyToken","type":"address"},{"name":"minBuyAmt","type":"uint256"}],"name":"createAndSellAllAmount","outputs":[{"name":"proxy","type":"address"},{"name":"buyAmt","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"otc","type":"address"},{"name":"wethToken","type":"address"},{"name":"buyToken","type":"address"},{"name":"minBuyAmt","type":"uint256"}],"name":"sellAllAmountPayEth","outputs":[{"name":"buyAmt","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"otc","type":"address"},{"name":"wethToken","type":"address"},{"name":"wethAmt","type":"uint256"},{"name":"payToken","type":"address"},{"name":"maxPayAmt","type":"uint256"}],"name":"buyAllAmountBuyEth","outputs":[{"name":"payAmt","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"wethToken_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"}]

Contract Creation Code

6060604052341561000f57600080fd5b6040516020806116148339810160405280805160008054600160a060020a03909216600160a060020a031990921691909117905550506115c0806100546000396000f3006060604052600436106100a05763ffffffff60e060020a60003504166303e1b3c681146100bd5780631ebf0d11146101015780633c0ab650146101335780633fa9baf1146101655780636c1210e8146101b95780636fc4a4a2146101ea578063793e39cd1461020d57806392eeee63146102305780639a22dec514610268578063b126d0e51461028c578063e50278a6146102c4578063f9a87d4f146102e7575b60005433600160a060020a039081169116146100bb57600080fd5b005b34156100c857600080fd5b6100ef600160a060020a036004358116906024358116906044359060643516608435610319565b60405190815260200160405180910390f35b341561010c57600080fd5b6100ef600160a060020a03600435811690602435811690604435906064351660843561050d565b341561013e57600080fd5b6100ef600160a060020a036004358116906024358116906044359060643516608435610763565b341561017057600080fd5b610197600160a060020a036004358116906024358116906044359060643516608435610aae565b604051600160a060020a03909216825260208201526040908101905180910390f35b34156101c457600080fd5b610197600160a060020a0360043581169060243581169060443516606435608435610b3e565b610197600160a060020a0360043581169060243581169060443516606435610bc4565b610197600160a060020a0360043581169060243581169060443516606435610c54565b341561023b57600080fd5b610197600160a060020a03600435811690602435811690604435811690606435906084351660a435610cd7565b6100ef600160a060020a036004358116906024358116906044359060643516610d5b565b341561029757600080fd5b610197600160a060020a03600435811690602435811690604435811690606435906084351660a435610fdf565b6100ef600160a060020a0360043581169060243581169060443516606435611056565b34156102f257600080fd5b6100ef600160a060020a036004358116906024358116906044359060643516608435611277565b600084600160a060020a03166323b872dd33308760405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561037c57600080fd5b5af1151561038957600080fd5b50505060405180519050151561039e57600080fd5b8385600160a060020a031663dd62ed3e308960405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b15156103f557600080fd5b5af1151561040257600080fd5b5050506040518051905010156104795784600160a060020a031663095ea7b38760001960405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b151561046857600080fd5b5af1151561047557600080fd5b5050505b85600160a060020a0316630621b4f68686868660405160e060020a63ffffffff8716028152600160a060020a0394851660048201526024810193909352921660448201526064810191909152608401602060405180830381600087803b15156104e157600080fd5b5af115156104ee57600080fd5b50505060405180519050905061050483826114e5565b95945050505050565b600084600160a060020a03166323b872dd33308760405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561057057600080fd5b5af1151561057d57600080fd5b50505060405180519050151561059257600080fd5b8385600160a060020a031663dd62ed3e308960405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b15156105e957600080fd5b5af115156105f657600080fd5b50505060405180519050101561066d5784600160a060020a031663095ea7b38760001960405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b151561065c57600080fd5b5af1151561066957600080fd5b5050505b85600160a060020a0316630621b4f68686868660405160e060020a63ffffffff8716028152600160a060020a0394851660048201526024810193909352921660448201526064810191909152608401602060405180830381600087803b15156106d557600080fd5b5af115156106e257600080fd5b5050506040518051915050600160a060020a03831663a9059cbb338360405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561074157600080fd5b5af1151561074e57600080fd5b50505060405180519050151561050457600080fd5b60008086600160a060020a031663ff1fd97485888860405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156107c757600080fd5b5af115156107d457600080fd5b5050506040518051915050828111156107ec57600080fd5b83600160a060020a03166323b872dd33308460405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561084d57600080fd5b5af1151561085a57600080fd5b50505060405180519050151561086f57600080fd5b8084600160a060020a031663dd62ed3e308a60405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b15156108c657600080fd5b5af115156108d357600080fd5b50505060405180519050101561094a5783600160a060020a031663095ea7b38860001960405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b151561093957600080fd5b5af1151561094657600080fd5b5050505b86600160a060020a0316638185402b8787878560405160e060020a63ffffffff8716028152600160a060020a0394851660048201526024810193909352921660448201526064810191909152608401602060405180830381600087803b15156109b257600080fd5b5af115156109bf57600080fd5b5050506040518051925050600160a060020a03861663a9059cbb33610a3f88846370a082313060405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610a2357600080fd5b5af11515610a3057600080fd5b50505060405180519050611569565b60405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610a8257600080fd5b5af11515610a8f57600080fd5b505050604051805190501515610aa457600080fd5b5095945050505050565b60008086600160a060020a031663f3701da23360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610aff57600080fd5b5af11515610b0c57600080fd5b5050506040518051600054909350610b3291508790600160a060020a0316878787611277565b90509550959350505050565b60008086600160a060020a031663f3701da23360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610b8f57600080fd5b5af11515610b9c57600080fd5b5050506040518051600054909350610b329150879087908790600160a060020a031687610319565b60008085600160a060020a031663f3701da23360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610c1557600080fd5b5af11515610c2257600080fd5b5050506040518051600054909350610c499150869086908690600160a060020a0316610d5b565b905094509492505050565b60008085600160a060020a031663f3701da23360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610ca557600080fd5b5af11515610cb257600080fd5b5050506040518051600054909350610c4991508690600160a060020a03168686611056565b60008087600160a060020a031663f3701da23360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610d2857600080fd5b5af11515610d3557600080fd5b505050604051805190509150610d4e8787878787610763565b9050965096945050505050565b600081600160a060020a031663d0e30db0346040518263ffffffff1660e060020a0281526004016000604051808303818588803b1515610d9a57600080fd5b5af11515610da757600080fd5b505050503482600160a060020a031663dd62ed3e308860405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b1515610e0257600080fd5b5af11515610e0f57600080fd5b505050604051805190501015610e865781600160a060020a031663095ea7b38660001960405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b1515610e7557600080fd5b5af11515610e8257600080fd5b5050505b84600160a060020a0316638185402b8585853460405160e060020a63ffffffff8716028152600160a060020a0394851660048201526024810193909352921660448201526064810191909152608401602060405180830381600087803b1515610eee57600080fd5b5af11515610efb57600080fd5b5050506040518051915050600160a060020a03841663a9059cbb33610f5f86846370a082313060405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610a2357600080fd5b60405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610fa257600080fd5b5af11515610faf57600080fd5b505050604051805190501515610fc457600080fd5b610fd782610fd23484611584565b6114e5565b949350505050565b60008087600160a060020a031663f3701da23360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561103057600080fd5b5af1151561103d57600080fd5b505050604051805190509150610d4e878787878761050d565b600083600160a060020a031663d0e30db0346040518263ffffffff1660e060020a0281526004016000604051808303818588803b151561109557600080fd5b5af115156110a257600080fd5b505050503484600160a060020a031663dd62ed3e308860405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b15156110fd57600080fd5b5af1151561110a57600080fd5b5050506040518051905010156111815783600160a060020a031663095ea7b38660001960405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b151561117057600080fd5b5af1151561117d57600080fd5b5050505b84600160a060020a0316630621b4f68534868660405160e060020a63ffffffff8716028152600160a060020a0394851660048201526024810193909352921660448201526064810191909152608401602060405180830381600087803b15156111e957600080fd5b5af115156111f657600080fd5b5050506040518051915050600160a060020a03831663a9059cbb338360405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561125557600080fd5b5af1151561126257600080fd5b505050604051805190501515610fd757600080fd5b60008086600160a060020a031663ff1fd97485888860405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156112db57600080fd5b5af115156112e857600080fd5b50505060405180519150508281111561130057600080fd5b83600160a060020a03166323b872dd33308460405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561136157600080fd5b5af1151561136e57600080fd5b50505060405180519050151561138357600080fd5b8084600160a060020a031663dd62ed3e308a60405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b15156113da57600080fd5b5af115156113e757600080fd5b50505060405180519050101561145e5783600160a060020a031663095ea7b38860001960405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b151561144d57600080fd5b5af1151561145a57600080fd5b5050505b86600160a060020a0316638185402b8787878560405160e060020a63ffffffff8716028152600160a060020a0394851660048201526024810193909352921660448201526064810191909152608401602060405180830381600087803b15156114c657600080fd5b5af115156114d357600080fd5b505050604051805190509150610aa486865b81600160a060020a0316632e1a7d4d8260405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b151561152b57600080fd5b5af1151561153857600080fd5b50505033600160a060020a03168160405160006040518083038185875af192505050151561156557600080fd5b5050565b600081831115611579578161157b565b825b90505b92915050565b8082038281111561157e57600080fd00a165627a7a723058205e0896a71f48b6c42df9d3843ca60c3e5fad0463472b43c0236bfc26b30336990029000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

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

000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

Swarm Source

bzzr://5e0896a71f48b6c42df9d3843ca60c3e5fad0463472b43c0236bfc26b3033699
Block Age Transaction Difficulty GasUsed Reward
Block Age Uncle Number Difficulty GasUsed Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.