contract TokenSwap is Ownable ,Pausable  {
    
    using SafeMath for uint256;
    ERC20 public oldToken;
    ERC20 public newToken;

    constructor (address _oldToken , address _newToken ) public {
        oldToken = ERC20(_oldToken);
        newToken = ERC20(_newToken);
    
    }
    

    
    function swapTokens() public whenNotPaused{
        uint tokenAllowance = oldToken.allowance(msg.sender, address(this));
        require(tokenAllowance>0 , "token allowence is");
        require(newToken.balanceOf(address(this)) > tokenAllowance , "not enough balance");
        oldToken.transferFrom(msg.sender, address(0), tokenAllowance);
        newToken.transfer(msg.sender, tokenAllowance);

    }
    

    function kill() public onlyOwner {
    selfdestruct(msg.sender);
  }
  
      /**
     * @dev Return all tokens back to owner, in case any were accidentally
     *   transferred to this contract.
     */
    function returnNewTokens() public onlyOwner whenNotPaused {
        newToken.transfer(owner, newToken.balanceOf(address(this)));
    }
    
       
    
      /**
     * @dev Return all tokens back to owner, in case any were accidentally
     *   transferred to this contract.
     */
    function returnOldTokens() public onlyOwner whenNotPaused {
        oldToken.transfer(owner, oldToken.balanceOf(address(this)));
    }
    
    
}
function returnOldTokens() public onlyOwner whenNotPaused {
    oldToken.transfer(owner, oldToken.balanceOf(address(this)));
}

/**
 * @dev Return all tokens back to owner, in case any were accidentally
 *   transferred to this contract.
 */