-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
For v4 pools don't we want something like this in make_trade()? We have to ensure first token in pool_id is the smaller address which will then allow us to correctly set zero_for_one
elif pool_version.lower() == "v4":
# Encode V4 swap
tick_spacing = 60 # Default tick spacing, adjust if needed
if from_token > to_token:
pool_key = codec.encode.v4_pool_key(
to_token,
from_token,
fee,
tick_spacing,
)
zero_4_1 = False
else:
pool_key = codec.encode.v4_pool_key(
from_token,
to_token,
fee,
tick_spacing,
)
zero_4_1 = True
# Determine if input is native token (ETH/MATIC)
is_native_input = from_token.lower() == "0x0000000000000000000000000000000000000000"
encoded_data = (
codec.encode.chain()
.v4_swap()
.swap_exact_in_single(
pool_key=pool_key,
zero_for_one= zero_4_1,
amount_in=amount_in_wei,
amount_out_min=min_amount_out,
)
.take_all(to_token, 0)
.settle_all(from_token, amount_in_wei)
.build_v4_swap()
.build_transaction(self.account.address, amount_in_wei if is_native_input else 0, ur_address=self.router_address)
)
Metadata
Metadata
Assignees
Labels
No labels