contract OneWaySwap is Ownable, Pausable{

    using SafeERC20 for ERC20;


    ERC20 oldToken;
    ERC20 newToken;

    address public burnAddress;

    event Burned(address who, uint256 amount, string why);

    constructor(ERC20 oldToken_, ERC20 newToken_, address burnAddress_)
    {
        require(address(oldToken_) != address(0) && address(newToken_) != address(0) && address(burnAddress_) != address(0), "Zero address not allowed");
        oldToken = oldToken_;
        newToken = newToken_;        
        burnAddress = burnAddress_;
        _pause();
    }

    function swap(uint256 amount) 
        external
        whenNotPaused
    {
        //oldToken.transferFrom(msg.sender, burnAddress, amount);
        oldToken.safeTransferFrom( msg.sender, burnAddress, amount);
        //newToken.transfer(msg.sender, amount);
        newToken.safeTransfer( msg.sender, amount);
    }

    function burn(uint256 amount, string memory why)
        external
        whenNotPaused
    {
        //oldToken.transferFrom(msg.sender, burnAddress, amount);
        oldToken.safeTransferFrom( msg.sender, burnAddress, amount);
        emit Burned(msg.sender, amount, why);
    }
    
    function pause() 
        external 
        onlyOwner
    {
        _pause();
    }

    function unPause() 
        external 
        onlyOwner
    {
        _unpause();
    }

    /**
    @dev at some point may wish to end the swap, and reallocate the newToken
    allows an `amount` of `token` to be withdrawn to `destination`
    **/
    function walletWithdraw(ERC20 token, uint256 amount, address destination)
        external
        onlyOwner
    {
        token.transfer(destination, amount);
    }

}
/** 
 @dev Performs a one-way 1:1 token swap
 1) code of the tokens is known, 
 2) both tokens have the same number of decimal places,
 3) both tokens revert on failure
 some effort was taken to create clear, self documenting, code.
 **/
function walletWithdraw(ERC20 token, uint256 amount, address destination)
    external
    onlyOwner
{
    token.transfer(destination, amount);
}

/**
 @dev at some point may wish to end the swap, and reallocate the newToken
 allows an `amount` of `token` to be withdrawn to `destination`
 **/