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

TxHash Age From To Value [TxFee]
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b12 days 16 hrs ago0x2bc0d4efef61e6f98c1bf03fcf3276197dd9b2dc  IN   0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800.01 Ether0.000209709
0x2e3e464e2c2f15f491f365ea16436be3d915d97fc19399c2147bdcddab69d64c12 days 16 hrs ago0x2bc0d4efef61e6f98c1bf03fcf3276197dd9b2dc  IN    Contract Creation0 Ether0.000955764


[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 9 Internal Transactions

ParentTxHash Block Age From To Value
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b1003128412 days 16 hrs ago0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b1003128412 days 16 hrs ago0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b1003128412 days 16 hrs ago0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800xd0a1e359811322d97991e03f863a0c30c2cf029c0 Ether
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b1003128412 days 16 hrs ago0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800xd0a1e359811322d97991e03f863a0c30c2cf029c0.01 Ether
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b1003128412 days 16 hrs ago0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800xc4375b7de8af5a38a93548eb8453a498222c4ff20 Ether
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b1003128412 days 16 hrs ago0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b1003128412 days 16 hrs ago0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b1003128412 days 16 hrs ago0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800xdb3b642ebc6ff85a3ab335cff9af2954f92159940 Ether
0xed40c80c9f09e90b0f0af74069c62d55a89736fbca9ac1ecfe28606e8aa32c9b1003128412 days 16 hrs ago0xc6b84a36ab1794b80c9e1399cde8c1b51fd570800xdb3b642ebc6ff85a3ab335cff9af2954f92159940 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_);

        lastETHamount_=address(this).balance;
        lastDAIamount_=daiToken.balanceOf(address(this));

//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));
        
        
        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=1e15;
        //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_, 1e15);
        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
608060405260008054600160a060020a031990811673c4375b7de8af5a38a93548eb8453a498222c4ff217825560018054821673db3b642ebc6ff85a3ab335cff9af2954f921599417905560028054821673d0a1e359811322d97991e03f863a0c30c2cf029c17905560038054821673fc81655585f2f3935895c1409b332ab797d90b3317905560048054909116331790556005819055600681905560078190556008553480156100af57600080fd5b50610bf9806100bf6000396000f3fe6080604052600436106100b9576000357c010000000000000000000000000000000000000000000000000000000090048063a6a72eb111610081578063a6a72eb114610138578063c73299c91461014d578063d459671014610174578063efe93ac614610189578063f2fde38b1461019e578063fbe0c9b2146101d1576100b9565b80633faa9033146100be57806343843cec146100ef57806345710074146101045780634a0ebe2f1461011b578063a56c077f14610130575b600080fd5b3480156100ca57600080fd5b506100d36101e6565b60408051600160a060020a039092168252519081900360200190f35b3480156100fb57600080fd5b506100d36101f5565b34801561011057600080fd5b50610119610204565b005b34801561012757600080fd5b506100d361047f565b61011961048e565b34801561014457600080fd5b506100d3610aa1565b34801561015957600080fd5b50610162610ab0565b60408051918252519081900360200190f35b34801561018057600080fd5b50610162610ab6565b34801561019557600080fd5b50610162610abc565b3480156101aa57600080fd5b50610119600480360360208110156101c157600080fd5b5035600160a060020a0316610ac2565b3480156101dd57600080fd5b50610162610b7f565b600254600160a060020a031681565b600354600160a060020a031681565b60015460025460008054604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152306004820152600160a060020a039586166024820181905291519195948516949092169266038d7ea4c68000928392859263dd62ed3e92604480820193602093909283900390910190829087803b15801561028f57600080fd5b505af11580156102a3573d6000803e3d6000fd5b505050506040513d60208110156102b957600080fd5b5051101561034957600154604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152600019602482015290519184169163095ea7b39160448082019260009290919082900301818387803b15801561033057600080fd5b505af1158015610344573d6000803e3d6000fd5b505050505b60008054600254604080517f0621b4f6000000000000000000000000000000000000000000000000000000008152600160a060020a03938416600482015260248101869052918316604483015266038d7ea4c6800060648301525191871691630621b4f69160848082019260209290919082900301818787803b1580156103cf57600080fd5b505af11580156103e3573d6000803e3d6000fd5b505050506040513d60208110156103f957600080fd5b5051604080517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018390529051919250600160a060020a03861691632e1a7d4d9160248082019260009290919082900301818387803b15801561046057600080fd5b505af1158015610474573d6000803e3d6000fd5b505050505050505050565b600154600160a060020a031681565b60015460025460008054604080517f0374fc6f000000000000000000000000000000000000000000000000000000008152600160a060020a039485166004820152918416602483015251929093169290918391630374fc6f916044808301926020929190829003018186803b15801561050657600080fd5b505afa15801561051a573d6000803e3d6000fd5b505050506040513d602081101561053057600080fd5b505160008054600254604080517f0374fc6f000000000000000000000000000000000000000000000000000000008152600160a060020a039384166004820152918316602483015251939450919290851691630374fc6f916044808301926020929190829003018186803b1580156105a757600080fd5b505afa1580156105bb573d6000803e3d6000fd5b505050506040513d60208110156105d157600080fd5b5051604080517f4579268a0000000000000000000000000000000000000000000000000000000081526004810185905290519192506000918291600160a060020a03871691634579268a91602480820192608092909190829003018186803b15801561063c57600080fd5b505afa158015610650573d6000803e3d6000fd5b505050506040513d608081101561066657600080fd5b508051604090910151909250905061069c8261069083670de0b6b3a764000063ffffffff610b8516565b9063ffffffff610bb616565b600655604080517f4579268a000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a03871691634579268a916024808301926080929190829003018186803b1580156106ff57600080fd5b505afa158015610713573d6000803e3d6000fd5b505050506040513d608081101561072957600080fd5b508051604090910151925090506107528261069083670de0b6b3a764000063ffffffff610b8516565b60055560025460008054308031600755604080517f70a08231000000000000000000000000000000000000000000000000000000008152600481019290925251600160a060020a03948516949092169283926370a08231926024808201936020939283900390910190829087803b1580156107cc57600080fd5b505af11580156107e0573d6000803e3d6000fd5b505050506040513d60208110156107f657600080fd5b5051600855604080517fd0e30db00000000000000000000000000000000000000000000000000000000081529051600160a060020a0384169163d0e30db091349160048082019260009290919082900301818588803b15801561085857600080fd5b505af115801561086c573d6000803e3d6000fd5b5050600154604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152306004820152600160a060020a0392831660248201529051349550918716935063dd62ed3e92506044808201926020929091908290030181600087803b1580156108e157600080fd5b505af11580156108f5573d6000803e3d6000fd5b505050506040513d602081101561090b57600080fd5b5051101561099b57600154604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152600019602482015290519184169163095ea7b39160448082019260009290919082900301818387803b15801561098257600080fd5b505af1158015610996573d6000803e3d6000fd5b505050505b60025460008054604080517f0621b4f6000000000000000000000000000000000000000000000000000000008152600160a060020a039485166004820152346024820152918416604483015266038d7ea4c6800060648301525191928a1691630621b4f69160848082019260209290919082900301818787803b158015610a2157600080fd5b505af1158015610a35573d6000803e3d6000fd5b505050506040513d6020811015610a4b57600080fd5b505160065460055460408051928352602083019190915242828201525191925033917f619ebd103f3b5ca30aae844383c864dbf44c0c65bba02d2203e82783649def399181900360600190a25050505050505050565b600054600160a060020a031681565b60075481565b60065481565b60085481565b600454600160a060020a03163314610b3b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4f6e6c79206f776e65722063616e20646f207468697321000000000000000000604482015290519081900360640190fd5b600160a060020a0381161515610b5057600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60055481565b6000821515610b9657506000610bb0565b828202828482811515610ba557fe5b0414610bad57fe5b90505b92915050565b6000808284811515610bc457fe5b0494935050505056fea165627a7a723058202fe516a2ebb646a434dabdb08318fa36dcc7806feb09a736afa9553e35c850e30029

   Swarm Source:
bzzr://2fe516a2ebb646a434dabdb08318fa36dcc7806feb09a736afa9553e35c850e3

 

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