contract StandardToken is StandardAuth {
    using SafeMath for uint;

    mapping(address => uint) balances;
    mapping(address => mapping (address => uint256)) allowed;
    mapping(address => bool) optionPoolMembers;
    mapping(address => uint) optionPoolMemberApproveTotal;
    string public name;
    string public symbol;
    uint8 public decimals = 9;
    uint256 public totalSupply;
    uint256 public optionPoolLockTotal = 500000000;
    uint [2][7] public optionPoolMembersUnlockPlans = [
        [1596211200,15],    //2020-08-01 00:00:00 unlock 15%
        [1612108800,30],    //2021-02-01 00:00:00 unlock 30%
        [1627747200,45],    //2021-08-01 00:00:00 unlock 45%
        [1643644800,60],    //2022-02-01 00:00:00 unlock 60%
        [1659283200,75],    //2022-08-01 00:00:00 unlock 75%
        [1675180800,90],    //2023-02-01 00:00:00 unlock 90%
        [1690819200,100]    //2023-08-01 00:00:00 unlock 100%
    ];
    
    constructor(uint256 _initialAmount, string _tokenName, string _tokenSymbol) public  {
        balances[msg.sender] = _initialAmount;               
        totalSupply = _initialAmount;                        
        name = _tokenName;                                   
        symbol = _tokenSymbol;
        optionPoolMembers[0x36b4F89608B5a5d5bd675b13a9d1075eCb64C2B5] = true;
        optionPoolMembers[0xDdcEb1A0c975Da8f0E0c457e06D6eBfb175570A7] = true;
        optionPoolMembers[0x46b6bA8ff5b91FF6B76964e143f3573767a20c1C] = true;
        optionPoolMembers[0xBF95141188dB8FDeFe85Ce2412407A9266d96dA3] = true;
    }

    modifier verifyTheLock(uint _value) {
        if(optionPoolMembers[msg.sender] == true) {
            if(balances[msg.sender] - optionPoolMemberApproveTotal[msg.sender] - _value < optionPoolMembersLockTotalOf(msg.sender)) {
                revert();
            } else {
                _;
            }
        } else {
            _;
        }
    }
    
    // Function to access name of token .
    function name() public view returns (string _name) {
        return name;
    }
    // Function to access symbol of token .
    function symbol() public view returns (string _symbol) {
        return symbol;
    }
    // Function to access decimals of token .
    function decimals() public view returns (uint8 _decimals) {
        return decimals;
    }
    // Function to access total supply of tokens .
    function totalSupply() public view returns (uint _totalSupply) {
        return totalSupply;
    }
    function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
        return allowed[_owner][_spender];
    }
    function balanceOf(address _owner) public view returns (uint balance) {
        return balances[_owner];
    }
    function verifyOptionPoolMembers(address _add) public view returns (bool _verifyResults) {
        return optionPoolMembers[_add];
    }
    
    function optionPoolMembersLockTotalOf(address _memAdd) public view returns (uint _optionPoolMembersLockTotal) {
        if(optionPoolMembers[_memAdd] != true){
            return 0;
        }
        
        uint unlockPercent = 0;
        
        for (uint8 i = 0; i < optionPoolMembersUnlockPlans.length; i++) {
            if(now >= optionPoolMembersUnlockPlans[i][0]) {
                unlockPercent = optionPoolMembersUnlockPlans[i][1];
            } else {
                break;
            }
        }
        
        return optionPoolLockTotal * (100 - unlockPercent) / 100;
    }
    
    function transfer(address _to, uint _value) public verifyTheLock(_value) returns (bool success) {
        assert(_value > 0);
        assert(balances[msg.sender] >= _value);
        assert(msg.sender != _to);
        
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        
        emit Transfer(msg.sender, _to, _value);

        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        assert(balances[_from] >= _value);
        assert(allowed[_from][msg.sender] >= _value);

        if(optionPoolMembers[_from] == true) {
            optionPoolMemberApproveTotal[_from] = optionPoolMemberApproveTotal[_from].sub(_value);
        }
        
        allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
        balances[_from] = balances[_from].sub(_value);
        balances[_to] = balances[_to].add(_value);
        emit Transfer(_from, _to, _value);

        return true;
        
    }

    function approve(address _spender, uint256 _value) public verifyTheLock(_value) returns (bool success) {
        assert(_value > 0);
        assert(msg.sender != _spender);
        
        if(optionPoolMembers[msg.sender] == true) {
            
            if(allowed[msg.sender][_spender] > 0){
                optionPoolMemberApproveTotal[msg.sender] = optionPoolMemberApproveTotal[msg.sender].sub(allowed[msg.sender][_spender]);
            }
            
            optionPoolMemberApproveTotal[msg.sender] = optionPoolMemberApproveTotal[msg.sender].add(_value);
        }
        
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        
        return true;
    }

}
function decimals() public view returns (uint8 _decimals) {
    return decimals;
}

// Function to access decimals of token .