I've made a python web3 script that swaps ETH to Token using exactInputSingle
function on Uniswap v3 Abritrum chain.
Transactions are successful and the script is working, but the problem is, when I reverse the swap (selling tokens to get ETH), I receive wETH instead of ETH. On Uniswap v2, this can be easily be solved by using swapExactTokensForETH
, but Uniswap v3 is different.
Here's a sample portion of the txn in my code:
# Txn Params
fee = 3000
min_out = 0
deadline = int(time()) + 900
txn_params = (token_address, weth_address, fee, wallet_address, deadline, amount_to_sell, min_out, 0)
uniswapv3_txn = router.functions.exactInputSingle(txn_params).buildTransaction(
{
'from': wallet_address,
'gas': int(gas_limit),
'maxFeePerGas': web3.toWei(data_gas_max_fee, 'gwei'),
'maxPriorityFeePerGas': web3.toWei(gas_max_priority, 'gwei'),
'nonce': web3.eth.get_transaction_count(wallet_address),
})
signed_txn = web3.eth.account.sign_transaction(uniswapv3_txn, private_key=private_key)
tx_token = web3.eth.send_raw_transaction(signed_txn.rawTransaction)
receipt = web3.eth.wait_for_transaction_receipt(tx_token, timeout=900)
How would I be able to receive ETH instead of wETH?