Skip to content

Commit

Permalink
fix: remove unused sqrtPriceLimitX96 field from swap structs (#25)
Browse files Browse the repository at this point in the history
The `sqrtPriceLimitX96` field has been removed from swap-related structs and associated test cases. This cleanup eliminates redundant dependencies and simplifies the struct definitions.
  • Loading branch information
shuhuiluo authored Jan 22, 2025
1 parent f193180 commit 17c910c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ sol! {
bool zeroForOne;
uint128 amountIn;
uint128 amountOutMinimum;
uint160 sqrtPriceLimitX96;
bytes hookData;
}

Expand All @@ -81,7 +80,6 @@ sol! {
bool zeroForOne;
uint128 amountOut;
uint128 amountInMaximum;
uint160 sqrtPriceLimitX96;
bytes hookData;
}

Expand Down
4 changes: 1 addition & 3 deletions src/utils/v4_base_actions_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn parse_calldata(calldata: &Bytes) -> Result<V4RouterCall, Error> {
mod tests {
use super::*;
use crate::{prelude::*, tests::*};
use alloy_primitives::{address, uint, Address, U160, U256};
use alloy_primitives::{address, uint, Address, U256};
use once_cell::sync::Lazy;
use uniswap_v3_sdk::prelude::{encode_sqrt_ratio_x96, FeeAmount};

Expand Down Expand Up @@ -88,15 +88,13 @@ mod tests {
zeroForOne: true,
amountIn: AMOUNT.try_into().unwrap(),
amountOutMinimum: AMOUNT.try_into().unwrap(),
sqrtPriceLimitX96: U160::ZERO,
hookData: Bytes::default(),
}),
Actions::SWAP_EXACT_OUT_SINGLE(SwapExactOutSingleParams {
poolKey: USDC_WETH.pool_key.clone(),
zeroForOne: true,
amountOut: AMOUNT.try_into().unwrap(),
amountInMaximum: AMOUNT.try_into().unwrap(),
sqrtPriceLimitX96: U160::ZERO,
hookData: Bytes::default(),
}),
Actions::SWAP_EXACT_IN(SwapExactInParams {
Expand Down
5 changes: 2 additions & 3 deletions src/utils/v4_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ mod tests {
prelude::{Pool, Route},
tests::*,
};
use alloy_primitives::{hex, U160};
use alloy_primitives::hex;
use once_cell::sync::Lazy;

static USDC_WETH: Lazy<Pool<Vec<Tick>>> = Lazy::new(|| {
Expand Down Expand Up @@ -334,13 +334,12 @@ mod tests {
zeroForOne: true,
amountIn: ONE_ETHER,
amountOutMinimum: ONE_ETHER / 2,
sqrtPriceLimitX96: U160::ZERO,
hookData: Bytes::default(),
}));
assert_eq!(planner.actions, vec![0x06]);
assert_eq!(
planner.params[0],
hex!("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000").to_vec()
hex!("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000006f05b59d3b2000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000000").to_vec()
);
}

Expand Down

0 comments on commit 17c910c

Please sign in to comment.