not working
#69
-
the result:https://basescan.org/tx/0x88a14f4ae349a3b789c4e308ce4b97f04bce12bb3594319115edaf67b77c9a91 the code: def buy_usdc_from_v2_and_sell_to_v3():
global transient_eth_balance
# Wrap, Buy for 0.3 eth of usdc from v2, Sell to v3 and Unwrap
v2_path = [weth_address, usdc_address]
v2_in_amount = 5 * 10**14
print(v2_in_amount / (10**18))
v2_out_amount = 581526000 # with slippage
v3_path = [usdc_address, 500, weth_address]
v3_out_amount = int(2.98 * 10**17) # with slippage
encoded_input = (
codec
.encode
.chain()
.wrap_eth(FunctionRecipient.ROUTER, v2_in_amount)
.v2_swap_exact_in(FunctionRecipient.ROUTER, v2_in_amount, v2_out_amount, v2_path, payer_is_sender=True)
# .v3_swap_exact_in_from_balance(FunctionRecipient.ROUTER, v3_out_amount, v3_path)
# .unwrap_weth(FunctionRecipient.SENDER, 0)
.build(codec.get_default_deadline())
)
trx_hash = send_transaction(v2_in_amount, encoded_input)
receipt = w3.eth.wait_for_transaction_receipt(trx_hash)
assert receipt["status"] == 1, f'receipt["status"] is actually {receipt["status"]}' # trx success |
Beta Was this translation helpful? Give feedback.
Answered by
Elnaril
Aug 17, 2024
Replies: 1 comment 4 replies
-
Hello @ysrlin .v2_swap_exact_in(FunctionRecipient.ROUTER, v2_in_amount, v2_out_amount, v2_path, payer_is_sender=True) You should have |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The decoded input of the transaction 0x95852fea7300109dca92a4934c8f66be092dd081b8c7facdd563e1409f37d4f8 is: