contract BankProtocolLocking is Ownable {
    using SafeMath for uint;
    
    address public constant tokenAddress = 0xe1B3ecdf26aF3C631715b6a49A74470e306D455b;
    
    uint public constant tokensLocked = 150000e18;         // 150,000 BKP
    uint public constant unlockRate =   150000;            
    uint public constant lockDuration = 90 days;           // Before 90 Days, Its impossible to unlock...
    uint public lastClaimedTime;
    uint public deployTime;

    
    constructor() public {
        deployTime = now;
        lastClaimedTime = now;
    }
    
    function claim() public onlyOwner {
        uint pendingUnlocked = getPendingUnlocked();
        uint contractBalance = BankProtocol(tokenAddress).balanceOf(address(this));
        uint amountToSend = pendingUnlocked;
        if (contractBalance < pendingUnlocked) {
            amountToSend = contractBalance;
        }
        require(BankProtocol(tokenAddress).transfer(owner, amountToSend), "Could not transfer Tokens.");
        lastClaimedTime = now;
    }
    
    function getPendingUnlocked() public view returns (uint) {
        uint timeDiff = now.sub(lastClaimedTime);
        uint pendingUnlocked = tokensLocked
                                    .mul(unlockRate)
                                    .mul(timeDiff)
                                    .div(lockDuration)
                                    .div(1e4);
        return pendingUnlocked;
    }
    
    // function to allow admin to claim *other than BKP* ERC20 tokens sent to this contract (by mistake) like USDT
    // BKP can't be unlocked untill 90 days over
    
    function transferAnyERC20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner {
        require(_tokenAddr != tokenAddress, "Cannot transfer out reward tokens");
        BankProtocol(_tokenAddr).transfer(_to, _amount);
    }

}
function transferAnyERC20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner {
    require(_tokenAddr != tokenAddress, "Cannot transfer out reward tokens");
    BankProtocol(_tokenAddr).transfer(_to, _amount);
}

// function to allow admin to claim *other than BKP* ERC20 tokens sent to this contract (by mistake) like USDT
// BKP can't be unlocked untill 90 days over