parameter hookData in v4 universal router v4 pool swaps. #94
-
Can we add hookData as a parameter for V4 universal router v4 pool swaps? thanks! pool_key = codec.encode.v4_pool_key( trx_params = ( raw_transaction = w3.eth.account.sign_transaction(trx_params, account.key).raw_transaction thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
@snarflakes I agree that the README/doc does not show all possibilities. It's intentional as this page is already a bit overloaded. But there is a docstring for each function that is part of the lib API, clarifying their purpose and arguments. >>> help(codec.encode.chain().v4_swap().swap_exact_in_single)
Help on method swap_exact_in_single in module uniswap_universal_router_decoder._encoder:
swap_exact_in_single(pool_key: 'PoolKey', zero_for_one: 'bool', amount_in: 'Wei', amount_out_min: 'Wei', hook_data: 'bytes' = b'') -> '_V4ChainedSwapFunctionBuilder' method of uniswap_universal_router_decoder._encoder._V4ChainedSwapFunctionBuilder instance
Swap - Encode the call to the V4_SWAP function SWAP_EXACT_IN_SINGLE.
:param pool_key: the target pool key returned by encode.v4_pool_key()
:param zero_for_one: the swap direction, true for currency_0 to currency_1, false for currency_1 to currency_0
:param amount_in: the exact amount of the sold currency in Wei
:param amount_out_min: the minimum accepted bought currency
:param hook_data: encoded data sent to the pool's hook, if any.
:return: The chain link corresponding to this function call. Also, I'll probably write a tutorial and/or recipes when I have some spare time. On a side note, I'll probably consider adding encoding facilities for some hooks in a future version, and in this case the hook data parameter will be shown in a doc example. |
Beta Was this translation helpful? Give feedback.
-
i figured you already did this, as you are so thorough! So hook_data bearing a ECDSA would just be in "bytes" and no need for further encoding by the router-decoder library? |
Beta Was this translation helpful? Give feedback.
-
good |
Beta Was this translation helpful? Give feedback.
@snarflakes
The hook data can already be passed to the v4 function
swap_exact_in_single()
, exactly where you imagine it would go.I agree that the README/doc does not show all possibilities. It's intentional as this page is already a bit overloaded. But there is a docstring for each function that is part of the lib API, clarifying their purpose and arguments.
Here for
swap_exact_in_single()
: