contract VolatilePool is Ownable, ReentrancyGuard, ERC20 {
	using SafeMath for uint256;
    using SafeERC20 for IERC20;

    // Contract address where contract will send inTokens
    address public workerAddress;
    // Contract address of the Token contract accepts
    IERC20 public inToken;
    // Coefficient in ppm (parts per million)
    uint256 public coefficient;

    /** 
    * @dev Lender constructor
    * @param _inToken In Token contract address
    * @param _coefficient Coefficient ratio
    */
    constructor (
        uint8 _decimals,
    	address _inToken,
    	uint256 _coefficient
    )
    	public
        ERC20('volatilePoolToken', 'VPT')
    {
        _setupDecimals(_decimals);
        inToken = IERC20(_inToken);
    	setCoefficient(_coefficient);
    } 

    /***************************************
                    ADMIN
    ****************************************/

    /** 
    * @dev Sets Worker contract address, can be called only once
	* @param _workerAddress - New worker contract address
	*/
    function setWorker (
    	address _workerAddress
    )
    	external
    	onlyOwner
    {
        require (workerAddress == address(0), "worker address is already set");
    	workerAddress = _workerAddress;
    }

    /** 
    * @dev Sets Coefficient
	* @param _coefficient - New coefficient
	*/
    function setCoefficient (
    	uint256 _coefficient
    )
    	public
    	onlyOwner
    {
    	coefficient = _coefficient;
    }

    /***************************************
                    ACTIONS
    ****************************************/

    /**
     * @dev Destroys tokens from msg.sender account
     * @param _amount amount of tokens
     */
    function burn(uint256 _amount)  
        external 
    {
        _burn(msg.sender, _amount);
    }
    
    /**
     * @dev Transfers In Tokens preapproved by sender to worker contract, 
     * mints VPT Tokens amount*coefficient and transfers them to sender
     * @param _inAmount of In Tokens
     */
    function receiveInToken (uint256 _inAmount)
        external
        nonReentrant
    {
    	require(_inAmount != 0, "in amount is 0");
    	address _address = msg.sender;
    	inToken.safeTransferFrom(_address, workerAddress, _inAmount);
    	uint256 _outAmount = _inAmount.mul(coefficient).div(1e6);
    	_mint(_address, _outAmount);
    }
}
// 
function setCoefficient (
	uint256 _coefficient
)
	public
	onlyOwner
{
	coefficient = _coefficient;
}

/** 
 * @dev Sets Coefficient
 	* @param _coefficient - New coefficient
 	*/