Contract Overview
Balance: 0 Ether
Transactions: 3 txns
 Latest 3 txns

TxHash Age From To Value [TxFee]
0x13c29cf83ce2ca36f896cf530f2631ddef8b410304feb35aba6ab7dd190ab26712 days 16 hrs ago0x2bc0d4efef61e6f98c1bf03fcf3276197dd9b2dc  IN   0x9226696583cee72090c2333c2c5c7f4c119193940 Ether0.000126078
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e12 days 16 hrs ago0x2bc0d4efef61e6f98c1bf03fcf3276197dd9b2dc  IN   0x9226696583cee72090c2333c2c5c7f4c119193940.01 Ether0.0002097
0xec6196cad55528a96202ff2f4aebb4cd8959c7eaaa5f3dcf83a07297b2893ef512 days 16 hrs ago0x2bc0d4efef61e6f98c1bf03fcf3276197dd9b2dc  IN    Contract Creation0 Ether0.00092167
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 12 Internal Transactions

ParentTxHash Block Age From To Value
0x13c29cf83ce2ca36f896cf530f2631ddef8b410304feb35aba6ab7dd190ab2671003147112 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0x13c29cf83ce2ca36f896cf530f2631ddef8b410304feb35aba6ab7dd190ab2671003147112 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xc4375b7de8af5a38a93548eb8453a498222c4ff20 Ether
0x13c29cf83ce2ca36f896cf530f2631ddef8b410304feb35aba6ab7dd190ab2671003147112 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xc4375b7de8af5a38a93548eb8453a498222c4ff20 Ether
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e1003146212 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xc4375b7de8af5a38a93548eb8453a498222c4ff20 Ether
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e1003146212 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e1003146212 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e1003146212 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e1003146212 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xd0a1e359811322d97991e03f863a0c30c2cf029c0.01 Ether
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e1003146212 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e1003146212 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e1003146212 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0x3542f41a6743bde3195f719ac9a562f7922da09906666b758daefbae99ef8f1e1003146212 days 16 hrs ago0x9226696583cee72090c2333c2c5c7f4c119193940xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
[ Download CSV Export  ] 
Contract Source Code Verified (Exact Match)
Contract Name: rebalance
Compiler Text: v0.5.2+commit.1df8f40c
Optimization Enabled: Yes
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity >0.4.99 <0.6.0;

/*
* http://ethedge.tech
* http://epictoken.dnsup.net/ (backup)
*
* Decentralized token exchange concept
* rebalancing eth contract value trade module with DAI (marketdao)
*
* ---How to use:
*  1. Send from ETH wallet to the smart contract address any amount ETH.
*  2.   1) Reinvest your profit by sending 0.00000001 ETH transaction to contract address
*       2) Claim your profit by sending 0.00000002 ETH transaction to contract address
*       3) Full exit (sell all and withdraw) by sending 0.00000003 ETH transaction to contract address
*  3. If you have innactive period more than 1 year - your account can be burned. Funds divided for token holders.
*  4. We use trade capital to invest to different crypto assets
*  5. Top big token holders can request audit.
*/


    interface DevsInterface {
        function payDividends(string calldata _sourceDesc) external payable;
//        function payDividends(string  _sourceDesc) public payable;
    }

    interface OasisInterface {
        function getBestOffer(address sell_gem, address buy_gem) external view returns(uint256);
        function getOffer(uint256 id) external view returns(uint256,address,uint256,address);
        function sellAllAmount(address pay_gem, uint pay_amt, address buy_gem, uint min_fill_amount) external returns (uint fill_amt);
    }

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

contract rebalance {
    
    using SafeMath for uint256;

    event onCheckRebalance(
        uint256 bestBid,
        uint256 bestAsk,
        address indexed customerAddress,
        uint timestamp
);

    //Modifier that only allows owner of the bag to Smart Contract AKA Good to use the function
    modifier onlyOwner{
        require(msg.sender == owner_, "Only owner can do this!");
        _;
    }
    

    address public dai_=0xC4375B7De8af5a38a93548eb8453a498222C4fF2; //kovan
    //address public dai_=0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359; //mainnet
    //address public pricefeed_=0x9FfFE440258B79c5d6604001674A4722FfC0f7Bc; //kovan NOT NEEDED!
    //address public pricefeed_=0x729D19f657BD0614b4985Cf1D82531c67569197B; //mainnet NOT NEEDED!
    address public oasis_=0xdB3b642eBc6Ff85A3AB335CFf9af2954F9215994; //kovan
    //address public oasis_=0xB7ac09C2c0217B07d7c103029B4918a2C401eeCB; //mainnet
    address public weth_=0xd0A1E359811322d97991E03f863a0C30C2cF029C; //kovan
    //address public weth_=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; //mainnet
    
    address public devsReward_=0xfc81655585F2F3935895C1409b332AB797D90B33; //this is contract!
    address private owner_=msg.sender;
    uint256 public lastSellPrice_=0;
    uint256 public lastBuyPrice_=0;
    uint256 public lastETHamount_=0;
    uint256 public lastDAIamount_=0;

    
    //This function transfer ownership of contract from one entity to another
    function transferOwnership(address _newOwner) public onlyOwner{
        require(_newOwner != address(0));
        owner_ = _newOwner;
    }
    
    //Check if rebalance needed and do swap
    function checkRebalance() public payable{
        OasisInterface oasis=OasisInterface(oasis_);
        uint bestBid=oasis.getBestOffer(weth_,dai_);
        uint bestAsk=oasis.getBestOffer(dai_,weth_);
        (uint amountWEth,,uint amountDai,)=oasis.getOffer(bestBid);
        lastBuyPrice_=amountDai.mul(1e18).div(amountWEth);
        (amountDai,,amountWEth,)=oasis.getOffer(bestAsk);
        lastSellPrice_=amountDai.mul(1e18).div(amountWEth);
        
        TokenInterface wethToken=TokenInterface(weth_);
        TokenInterface daiToken=TokenInterface(dai_);

//buy DAI for ETH        
        wethToken.deposit.value(msg.value)();
        if (wethToken.allowance(address(this), oasis_) < msg.value) {
            wethToken.approve(oasis_, uint(-1));
        }
        uint buyAmt = oasis.sellAllAmount(weth_, msg.value, dai_, 1e15);
        //require(daiToken.transfer(msg.sender,buyAmt));
        
        lastETHamount_=address(this).balance;
        lastDAIamount_=daiToken.balanceOf(address(this));
        
        emit onCheckRebalance(lastBuyPrice_,lastSellPrice_,msg.sender,now);
    }
    
        //try sell
    function sell() public {
        OasisInterface oasis=OasisInterface(oasis_);
        TokenInterface wethToken=TokenInterface(weth_);
        TokenInterface daiToken=TokenInterface(dai_);

        //uint payAmt=1e16;
        uint payAmt=lastDAIamount_;
        //sell DAI for ETH
        //require(payToken.transferFrom(msg.sender, this, payAmt));
        if (daiToken.allowance(address(this), oasis_) < payAmt) {
            daiToken.approve(oasis_, uint(-1));
        }
        uint wethAmt = oasis.sellAllAmount(dai_, payAmt, weth_, 1e12);
//        wethToken.withdraw(wethAmt);
//        require(msg.sender.call.value(wethAmt)());

    }
}    
    

library SafeMath {
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        assert(c / a == b);
        return c;
    }

    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a / b;
        return c;
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        assert(b <= a);
        return a - b;
    }

    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        assert(c >= a);
        return c;
    }
}

    Contract ABI  
[{"constant":true,"inputs":[],"name":"weth_","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"devsReward_","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"sell","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"oasis_","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"checkRebalance","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"dai_","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastETHamount_","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastBuyPrice_","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastDAIamount_","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"lastSellPrice_","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"bestBid","type":"uint256"},{"indexed":false,"name":"bestAsk","type":"uint256"},{"indexed":true,"name":"customerAddress","type":"address"},{"indexed":false,"name":"timestamp","type":"uint256"}],"name":"onCheckRebalance","type":"event"}]

  Contract Creation Code Switch To Opcodes View
608060405260008054600160a060020a031990811673c4375b7de8af5a38a93548eb8453a498222c4ff217825560018054821673db3b642ebc6ff85a3ab335cff9af2954f921599417905560028054821673d0a1e359811322d97991e03f863a0c30c2cf029c17905560038054821673fc81655585f2f3935895c1409b332ab797d90b3317905560048054909116331790556005819055600681905560078190556008553480156100af57600080fd5b50610b72806100bf6000396000f3fe6080604052600436106100b9576000357c010000000000000000000000000000000000000000000000000000000090048063a6a72eb111610081578063a6a72eb114610138578063c73299c91461014d578063d459671014610174578063efe93ac614610189578063f2fde38b1461019e578063fbe0c9b2146101d1576100b9565b80633faa9033146100be57806343843cec146100ef57806345710074146101045780634a0ebe2f1461011b578063a56c077f14610130575b600080fd5b3480156100ca57600080fd5b506100d36101e6565b60408051600160a060020a039092168252519081900360200190f35b3480156100fb57600080fd5b506100d36101f5565b34801561011057600080fd5b50610119610204565b005b34801561012757600080fd5b506100d36103fb565b61011961040a565b34801561014457600080fd5b506100d3610a1a565b34801561015957600080fd5b50610162610a29565b60408051918252519081900360200190f35b34801561018057600080fd5b50610162610a2f565b34801561019557600080fd5b50610162610a35565b3480156101aa57600080fd5b50610119600480360360208110156101c157600080fd5b5035600160a060020a0316610a3b565b3480156101dd57600080fd5b50610162610af8565b600254600160a060020a031681565b600354600160a060020a031681565b60015460025460008054600854604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152306004820152600160a060020a039687166024820181905291519196958616959093169391928392859263dd62ed3e926044808201936020939283900390910190829087803b15801561028a57600080fd5b505af115801561029e573d6000803e3d6000fd5b505050506040513d60208110156102b457600080fd5b5051101561034457600154604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152600019602482015290519184169163095ea7b39160448082019260009290919082900301818387803b15801561032b57600080fd5b505af115801561033f573d6000803e3d6000fd5b505050505b60008054600254604080517f0621b4f6000000000000000000000000000000000000000000000000000000008152600160a060020a03938416600482015260248101869052918316604483015264e8d4a5100060648301525191871691630621b4f69160848082019260209290919082900301818787803b1580156103c857600080fd5b505af11580156103dc573d6000803e3d6000fd5b505050506040513d60208110156103f257600080fd5b50505050505050565b600154600160a060020a031681565b60015460025460008054604080517f0374fc6f000000000000000000000000000000000000000000000000000000008152600160a060020a039485166004820152918416602483015251929093169290918391630374fc6f916044808301926020929190829003018186803b15801561048257600080fd5b505afa158015610496573d6000803e3d6000fd5b505050506040513d60208110156104ac57600080fd5b505160008054600254604080517f0374fc6f000000000000000000000000000000000000000000000000000000008152600160a060020a039384166004820152918316602483015251939450919290851691630374fc6f916044808301926020929190829003018186803b15801561052357600080fd5b505afa158015610537573d6000803e3d6000fd5b505050506040513d602081101561054d57600080fd5b5051604080517f4579268a0000000000000000000000000000000000000000000000000000000081526004810185905290519192506000918291600160a060020a03871691634579268a91602480820192608092909190829003018186803b1580156105b857600080fd5b505afa1580156105cc573d6000803e3d6000fd5b505050506040513d60808110156105e257600080fd5b50805160409091015190925090506106188261060c83670de0b6b3a764000063ffffffff610afe16565b9063ffffffff610b2f16565b600655604080517f4579268a000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a03871691634579268a916024808301926080929190829003018186803b15801561067b57600080fd5b505afa15801561068f573d6000803e3d6000fd5b505050506040513d60808110156106a557600080fd5b508051604090910151925090506106ce8261060c83670de0b6b3a764000063ffffffff610afe16565b60055560025460008054604080517fd0e30db00000000000000000000000000000000000000000000000000000000081529051600160a060020a039485169490921692849263d0e30db0923492600480830193919282900301818588803b15801561073857600080fd5b505af115801561074c573d6000803e3d6000fd5b5050600154604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152306004820152600160a060020a0392831660248201529051349550918716935063dd62ed3e92506044808201926020929091908290030181600087803b1580156107c157600080fd5b505af11580156107d5573d6000803e3d6000fd5b505050506040513d60208110156107eb57600080fd5b5051101561087b57600154604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152600019602482015290519184169163095ea7b39160448082019260009290919082900301818387803b15801561086257600080fd5b505af1158015610876573d6000803e3d6000fd5b505050505b60025460008054604080517f0621b4f6000000000000000000000000000000000000000000000000000000008152600160a060020a039485166004820152346024820152918416604483015266038d7ea4c6800060648301525191928a1691630621b4f69160848082019260209290919082900301818787803b15801561090157600080fd5b505af1158015610915573d6000803e3d6000fd5b505050506040513d602081101561092b57600080fd5b5051308031600755604080517f70a08231000000000000000000000000000000000000000000000000000000008152600481019290925251919250600160a060020a038416916370a08231916024808201926020929091908290030181600087803b15801561099957600080fd5b505af11580156109ad573d6000803e3d6000fd5b505050506040513d60208110156109c357600080fd5b505160085560065460055460408051928352602083019190915242828201525133917f619ebd103f3b5ca30aae844383c864dbf44c0c65bba02d2203e82783649def39919081900360600190a25050505050505050565b600054600160a060020a031681565b60075481565b60065481565b60085481565b600454600160a060020a03163314610ab457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4f6e6c79206f776e65722063616e20646f207468697321000000000000000000604482015290519081900360640190fd5b600160a060020a0381161515610ac957600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60055481565b6000821515610b0f57506000610b29565b828202828482811515610b1e57fe5b0414610b2657fe5b90505b92915050565b6000808284811515610b3d57fe5b0494935050505056fea165627a7a7230582037db6f78876bb02fde06f32dc9f1444316a04bac5d9b71cc45a198ac54d0d3b90029

   Swarm Source:
bzzr://37db6f78876bb02fde06f32dc9f1444316a04bac5d9b71cc45a198ac54d0d3b9

 

View All
Block Age transaction Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward