Skip to content

WRAP / UNWRAP with v4 swap #98

Locked Answered by Elnaril
AlexField26 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello Alex

Yes, it's possible, though it's absolutely not elegant in the current version ...
Here is an example where I sell some WBTC for ETH, and then get them as WETH:

from uniswap_universal_router_decoder import (
    FunctionRecipient,
    RouterCodec,
    V4Constants,
)
from uniswap_universal_router_decoder._enums import _RouterConstant  # ugly and not necessary, but maybe clearer ...

trx_params = (
    codec.
    encode.
    chain().
    v4_swap().
        swap_exact_in_single(
            pool_key=eth_wbtc_pool_key,
            zero_for_one=False,
            amount_in=wbtc_amount,
            amount_out_min=Wei(0),
        ).
        settle_all(wbtc_address, wbtc_amount).
      …

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Elnaril
Comment options

You must be logged in to vote
1 reply
@Elnaril
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #97 on April 15, 2025 14:57.