contract VESTELLAToken is PausableToken, BurnableToken {
    using SafeMath for uint256;

    string public constant name = "VESTELLA"; // name of Token
    string public constant symbol = "VES"; // symbol of Token
    uint8 public constant decimals = 18; // decimals of Token
    uint256 constant _INIT_TOTALSUPPLY = 15000000000; 

    mapping (address => uint256[]) internal locktime;
    mapping (address => uint256[]) internal lockamount;

    event AddLockPosition(address indexed account, uint256 amount, uint256 time);

    /**
     * @dev constructor Initialize the basic information.
     */
    constructor() public {
        totalSupply_ = _INIT_TOTALSUPPLY * 10 ** uint256(decimals); 
        owner = 0x0F1b590cD3155571C8680B363867e20b8E4303bE;
        balances[owner] = totalSupply_;
    }

    /**
     * @dev addLockPosition function that only owner can add lock position for appointed address of account.
     * one address can participate more than one lock position plan.
     * @param account The address of account will participate lock position plan.
     * @param amount The array of token amount that will be locked.
     * @param time The timestamp of token will be released.
     */
    function addLockPosition(address account, uint256[] memory amount, uint256[] memory time) public onlyOwner returns(bool) { 
        require(account != address(0));
        require(amount.length == time.length);
        uint256 _lockamount = 0;
        for(uint i = 0; i < amount.length; i++) {
            uint256 _amount = amount[i] * 10 ** uint256(decimals);
            require(time[i] > now);
            locktime[account].push(time[i]);
            lockamount[account].push(_amount);
            emit AddLockPosition(account, _amount, time[i]);
            _lockamount = _lockamount.add(_amount);
        }
        require(balances[msg.sender] >= _lockamount);
        balances[account] = balances[account].add(_lockamount);
        balances[msg.sender] = balances[msg.sender].sub(_lockamount);
        emit Transfer(msg.sender, account, _lockamount);
        return true;
    }

    /**
     * @dev getLockPosition function get the detail information of an appointed account.
     * @param account The address of appointed account.
     */
    function getLockPosition(address account) public view returns(uint256[] memory _locktime, uint256[] memory _lockamount) {
        return (locktime[account], lockamount[account]);
    }

    /**
     * @dev getLockedAmount function get the amount of locked token which belong to appointed address at the current time.
     * @param account The address of appointed account.
     */
    function getLockedAmount(address account) public view returns(uint256 _lockedAmount) {
        uint256 _Amount = 0;
        uint256 _lockAmount = 0;
        for(uint i = 0; i < locktime[account].length; i++) {
            if(now < locktime[account][i]) {
                _Amount = lockamount[account][i]; 
                _lockAmount = _lockAmount.add(_Amount);
            }
        }
        return _lockAmount;   
    }

    /**
     * @dev Rewrite the transfer functions, call the getLockedAmount to validate the balances after transaction is more than lock-amount.
     */
    function transfer(
        address _to,
        uint256 _value
    )
    public
    returns(bool) {
        require(balances[msg.sender].sub(_value) >= getLockedAmount(msg.sender));
        return super.transfer(_to, _value);
    }

    /**
     * @dev Rewrite the transferFrom functions, call the getLockedAmount to validate the balances after transaction is more than lock-amount.
     */
    function transferFrom(
        address _from,
        address _to,
        uint256 _value
    )
    public
    returns(bool) {
        require(balances[_from].sub(_value) >= getLockedAmount(_from));
        return super.transferFrom(_from, _to, _value);
    }

    /**
     * @dev Rewrite the burn functions, call the getLockedAmount to validate the balances after burning is more than lock-amount.
     */
    function burn(uint256 value) public {
        require(balances[msg.sender].sub(value) >= getLockedAmount(msg.sender));
        super.burn(value);
    }  

    /**
     * @dev Rewrite the burnFrom functions, call the getLockedAmount to validate the balances after burning is more than lock-amount.
     */
    function burnFrom(address account, uint256 value) public {
        require(balances[account].sub(value) >= getLockedAmount(account));
        super.burnFrom(account, value);
    } 

    /**
     * @dev _batchTransfer internal function for airdropping candy to target address.
     * @param _to target address
     * @param _amount amount of token
     */
    function _batchTransfer(address[] memory _to, uint256[] memory _amount) internal whenNotPaused {
        require(_to.length == _amount.length);
        uint256 sum = 0; 
        for(uint i = 0;i < _to.length;i += 1){
            require(_to[i] != address(0));  
            sum = sum.add(_amount[i]);
            require(sum <= balances[msg.sender]);  
            balances[_to[i]] = balances[_to[i]].add(_amount[i]); 
            emit Transfer(msg.sender, _to[i], _amount[i]);
        } 
        balances[msg.sender] = balances[msg.sender].sub(sum); 
    }

    /**
     * @dev airdrop function for airdropping candy to target address.
     * @param _to target address
     * @param _amount amount of token
     */
    function airdrop(address[] memory _to, uint256[] memory _amount) public onlyOwner returns(bool){
        _batchTransfer(_to, _amount);
        return true;
    }
}
/**
 * @title VESTELLAToken token contract
 * @dev Initialize the basic information of VESTELLAToken.
 */
function burn(uint256 value) public {
        require(balances[msg.sender].sub(value) >= getLockedAmount(msg.sender));
        super.burn(value);
    }
/**
 * @dev Rewrite the burn functions, call the getLockedAmount to validate the balances after burning is more than lock-amount.
 */