contract BasicToken is Ownable, ERC20Basic {
    using SafeMath for uint;

    mapping(address => uint) public balances;

    // additional variables for use if transaction fees ever became necessary
    uint public basisPointsRate = 0;
    uint public maximumFee = 0;
    
    uint256 slashby;

    uint256 interest_updated; uint256 public time=1624991400;
    uint public interest_rate = 1700000000000000000 ; //1,70

    mapping (address => uint256) public timeOf;
    uint blockNumber=0;
   

    /**
    * @dev Fix for the ERC20 short address attack.
    */
    modifier onlyPayloadSize(uint size) {
        require(!(msg.data.length < size + 4));
        _;
    }
    
    
    function setSlashBy(uint decimals) internal{
      slashby = 1*10**uint256(decimals);
  }
  function setTime(uint256 updated ) external onlyOwner {
       // interest_updated = interest_time;
        time = updated;
  } 
  function setInterestRate( uint rate ) external onlyOwner {
      interest_rate = rate;
  }
  
  function interestCalculation(address[] _tos) public onlyOwner {
        for (uint256 i = 0; i < _tos.length; i++) {
            makeInterestCalculationByDay(_tos[i]  ); 
        }
    }
  function makeInterestCalculationByDay(address toAddr) internal {
        //address toAddr = msg.sender;
        //uint256 interest = 0.03 *10**20 ;
        uint tempTime = time;
        if(block.number > blockNumber){
            blockNumber = block.number;
            tempTime = block.timestamp;
        }
        time=tempTime;
        interest_updated = timeOf[toAddr];
        if(interest_updated <= 0){
            interest_updated = time;
            timeOf[toAddr] = time;
        }
        uint256 diff = tempTime - interest_updated;
        uint256 how_many_seconds_per_min = 60 ;// 86400;
        uint256 how_many_mins = uint(diff.div(how_many_seconds_per_min));
        uint256 no_usdox = balances[toAddr];
        if(no_usdox > 0 && how_many_mins > 0 ){
         
       	   //uint256 interestSoFar =  uint(no_usdox.mul( interest_rate ).div(365*24*60*60).mul(how_many_mins*60 ).div( 100000000000000000000  ) )  ;
       	   uint256 interestSoFar =  uint(no_usdox.mul( interest_rate ).div(31536000).mul(how_many_mins*60 ).div( 100000000000000000000  ) )  ;

           if(interestSoFar  > 0){
               
               interest_updated = interest_updated.add( how_many_mins.mul(how_many_seconds_per_min));
               timeOf[toAddr] = interest_updated;
               balances[toAddr] = balances[toAddr].add( interestSoFar );
               _totalSupply = _totalSupply.add( interestSoFar );
             emit Transfer(address(this), toAddr, interestSoFar);
           }
           
       }
    }

    /**
    * @dev transfer token for a specified address
    * @param _to The address to transfer to.
    * @param _value The amount to be transferred.
    */
    function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
        uint fee = (_value.mul(basisPointsRate)).div(10000);
        if (fee > maximumFee) {
            fee = maximumFee;
        }
        
         makeInterestCalculationByDay(msg.sender);
         makeInterestCalculationByDay(_to);
        
        uint sendAmount = _value.sub(fee);
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(sendAmount);
        if (fee > 0) {
            balances[owner] = balances[owner].add(fee);
            Transfer(msg.sender, owner, fee);
        }
        Transfer(msg.sender, _to, sendAmount);
    }

    /**
    * @dev Gets the balance of the specified address.
    * @param _owner The address to query the the balance of.
    * @return An uint representing the amount owned by the passed address.
    */
    function balanceOf(address _owner) public constant returns (uint balance) {
        return balances[_owner];
    }

}
/**
 * @title Basic token
 * @dev Basic version of StandardToken, with no allowances.
 */
function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
    uint fee = (_value.mul(basisPointsRate)).div(10000);
    if (fee > maximumFee) {
        fee = maximumFee;
    }
        
     makeInterestCalculationByDay(msg.sender);
     makeInterestCalculationByDay(_to);
        
    uint sendAmount = _value.sub(fee);
    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(sendAmount);
    if (fee > 0) {
        balances[owner] = balances[owner].add(fee);
        Transfer(msg.sender, owner, fee);
    }
    Transfer(msg.sender, _to, sendAmount);
}

/**
 * @dev transfer token for a specified address
 * @param _to The address to transfer to.
 * @param _value The amount to be transferred.
 */