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

TxHash Age From To Value [TxFee]
0xfc93e615c5f79140ba89f3519ab2d5513a09e29153f38ad7b598575ec7794f5712 days 15 hrs ago0x2bc0d4efef61e6f98c1bf03fcf3276197dd9b2dc  IN   0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0 Ether0.000146082
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f87812 days 15 hrs ago0x2bc0d4efef61e6f98c1bf03fcf3276197dd9b2dc  IN   0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0.01 Ether0.0002097
0x2449282b09eead50faab3522448dd798f0c5f5f131da29bf1eafa2947666ca3612 days 15 hrs ago0x2bc0d4efef61e6f98c1bf03fcf3276197dd9b2dc  IN    Contract Creation0 Ether0.000933213
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 12 Internal Transactions

ParentTxHash Block Age From To Value
0xfc93e615c5f79140ba89f3519ab2d5513a09e29153f38ad7b598575ec7794f571003172112 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0xfc93e615c5f79140ba89f3519ab2d5513a09e29153f38ad7b598575ec7794f571003172112 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xc4375b7de8af5a38a93548eb8453a498222c4ff20 Ether
0xfc93e615c5f79140ba89f3519ab2d5513a09e29153f38ad7b598575ec7794f571003172112 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xc4375b7de8af5a38a93548eb8453a498222c4ff20 Ether
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f8781003171312 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xc4375b7de8af5a38a93548eb8453a498222c4ff20 Ether
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f8781003171312 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f8781003171312 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f8781003171312 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f8781003171312 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xd0a1e359811322d97991e03f863a0c30c2cf029c0.01 Ether
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f8781003171312 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f8781003171312 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f8781003171312 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0xb9f47b01ab10e8bff494bbee78a9cee9f7ca7b5ec30466eb7a8100912f35f8781003171312 days 15 hrs ago0xbd0f9b5b405a4b1f66936e2d6df3b44362bdcf4e0xdb3b642ebc6ff85a3ab335cff9af2954f92159940 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;
    uint256 public lastWETHamount_=0; //only for debug

    
    //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);
//        wethAmt=lastDAIamount_=daiToken.balanceOf(address(this));
        lastWETHamount_=wethAmt;
//        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":"lastWETHamount_","outputs":[{"name":"","type":"uint256"}],"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
608060405260008054600160a060020a031990811673c4375b7de8af5a38a93548eb8453a498222c4ff217825560018054821673db3b642ebc6ff85a3ab335cff9af2954f921599417905560028054821673d0a1e359811322d97991e03f863a0c30c2cf029c17905560038054821673fc81655585f2f3935895c1409b332ab797d90b33179055600480549091163317905560058190556006819055600781905560088190556009553480156100b457600080fd5b50610b9b806100c46000396000f3fe6080604052600436106100c4576000357c010000000000000000000000000000000000000000000000000000000090048063bfb1da0211610081578063bfb1da0214610158578063c73299c91461017f578063d459671014610194578063efe93ac6146101a9578063f2fde38b146101be578063fbe0c9b2146101f1576100c4565b80633faa9033146100c957806343843cec146100fa578063457100741461010f5780634a0ebe2f14610126578063a56c077f1461013b578063a6a72eb114610143575b600080fd5b3480156100d557600080fd5b506100de610206565b60408051600160a060020a039092168252519081900360200190f35b34801561010657600080fd5b506100de610215565b34801561011b57600080fd5b50610124610224565b005b34801561013257600080fd5b506100de61041e565b61012461042d565b34801561014f57600080fd5b506100de610a3d565b34801561016457600080fd5b5061016d610a4c565b60408051918252519081900360200190f35b34801561018b57600080fd5b5061016d610a52565b3480156101a057600080fd5b5061016d610a58565b3480156101b557600080fd5b5061016d610a5e565b3480156101ca57600080fd5b50610124600480360360208110156101e157600080fd5b5035600160a060020a0316610a64565b3480156101fd57600080fd5b5061016d610b21565b600254600160a060020a031681565b600354600160a060020a031681565b60015460025460008054600854604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152306004820152600160a060020a039687166024820181905291519196958616959093169391928392859263dd62ed3e926044808201936020939283900390910190829087803b1580156102aa57600080fd5b505af11580156102be573d6000803e3d6000fd5b505050506040513d60208110156102d457600080fd5b5051101561036457600154604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152600019602482015290519184169163095ea7b39160448082019260009290919082900301818387803b15801561034b57600080fd5b505af115801561035f573d6000803e3d6000fd5b505050505b60008054600254604080517f0621b4f6000000000000000000000000000000000000000000000000000000008152600160a060020a03938416600482015260248101869052918316604483015264e8d4a5100060648301525191871691630621b4f69160848082019260209290919082900301818787803b1580156103e857600080fd5b505af11580156103fc573d6000803e3d6000fd5b505050506040513d602081101561041257600080fd5b50516009555050505050565b600154600160a060020a031681565b60015460025460008054604080517f0374fc6f000000000000000000000000000000000000000000000000000000008152600160a060020a039485166004820152918416602483015251929093169290918391630374fc6f916044808301926020929190829003018186803b1580156104a557600080fd5b505afa1580156104b9573d6000803e3d6000fd5b505050506040513d60208110156104cf57600080fd5b505160008054600254604080517f0374fc6f000000000000000000000000000000000000000000000000000000008152600160a060020a039384166004820152918316602483015251939450919290851691630374fc6f916044808301926020929190829003018186803b15801561054657600080fd5b505afa15801561055a573d6000803e3d6000fd5b505050506040513d602081101561057057600080fd5b5051604080517f4579268a0000000000000000000000000000000000000000000000000000000081526004810185905290519192506000918291600160a060020a03871691634579268a91602480820192608092909190829003018186803b1580156105db57600080fd5b505afa1580156105ef573d6000803e3d6000fd5b505050506040513d608081101561060557600080fd5b508051604090910151909250905061063b8261062f83670de0b6b3a764000063ffffffff610b2716565b9063ffffffff610b5816565b600655604080517f4579268a000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a03871691634579268a916024808301926080929190829003018186803b15801561069e57600080fd5b505afa1580156106b2573d6000803e3d6000fd5b505050506040513d60808110156106c857600080fd5b508051604090910151925090506106f18261062f83670de0b6b3a764000063ffffffff610b2716565b60055560025460008054604080517fd0e30db00000000000000000000000000000000000000000000000000000000081529051600160a060020a039485169490921692849263d0e30db0923492600480830193919282900301818588803b15801561075b57600080fd5b505af115801561076f573d6000803e3d6000fd5b5050600154604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152306004820152600160a060020a0392831660248201529051349550918716935063dd62ed3e92506044808201926020929091908290030181600087803b1580156107e457600080fd5b505af11580156107f8573d6000803e3d6000fd5b505050506040513d602081101561080e57600080fd5b5051101561089e57600154604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152600019602482015290519184169163095ea7b39160448082019260009290919082900301818387803b15801561088557600080fd5b505af1158015610899573d6000803e3d6000fd5b505050505b60025460008054604080517f0621b4f6000000000000000000000000000000000000000000000000000000008152600160a060020a039485166004820152346024820152918416604483015266038d7ea4c6800060648301525191928a1691630621b4f69160848082019260209290919082900301818787803b15801561092457600080fd5b505af1158015610938573d6000803e3d6000fd5b505050506040513d602081101561094e57600080fd5b5051308031600755604080517f70a08231000000000000000000000000000000000000000000000000000000008152600481019290925251919250600160a060020a038416916370a08231916024808201926020929091908290030181600087803b1580156109bc57600080fd5b505af11580156109d0573d6000803e3d6000fd5b505050506040513d60208110156109e657600080fd5b505160085560065460055460408051928352602083019190915242828201525133917f619ebd103f3b5ca30aae844383c864dbf44c0c65bba02d2203e82783649def39919081900360600190a25050505050505050565b600054600160a060020a031681565b60095481565b60075481565b60065481565b60085481565b600454600160a060020a03163314610add57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4f6e6c79206f776e65722063616e20646f207468697321000000000000000000604482015290519081900360640190fd5b600160a060020a0381161515610af257600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60055481565b6000821515610b3857506000610b52565b828202828482811515610b4757fe5b0414610b4f57fe5b90505b92915050565b6000808284811515610b6657fe5b0494935050505056fea165627a7a723058200a7e3ca434cb87e106ae279793815ad426c24e0142ed17b0e3950e37a42878a70029

   Swarm Source:
bzzr://0a7e3ca434cb87e106ae279793815ad426c24e0142ed17b0e3950e37a42878a7

 

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