From 37e495d52dccad37e2946e3361b86a2ebce1178f Mon Sep 17 00:00:00 2001 From: Shuhui Luo <107524008+shuhuiluo@users.noreply.github.com> Date: Mon, 30 Dec 2024 01:59:14 -0500 Subject: [PATCH] chore: simplify fee collection logic and update dependencies Removed unnecessary vector allocation in the fee collection logic to streamline method parameters. Updated the `uniswap-v3-sdk` dependency to version 3.1.1 for improved compatibility. Also fixed a minor formatting issue in the `has_permission` utility function. --- Cargo.toml | 4 ++-- src/position_manager.rs | 8 +------- src/utils/hook.rs | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index acbedd4..faf2d69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uniswap-v4-sdk" -version = "0.1.0" +version = "0.1.1" edition = "2021" authors = ["Shuhui Luo "] description = "Uniswap V4 SDK for Rust" @@ -18,7 +18,7 @@ derive_more = "1.0.0" rustc-hash = "2.1.0" thiserror = { version = "2", default-features = false } uniswap-sdk-core = "3.2.0" -uniswap-v3-sdk = "3.0.0" +uniswap-v3-sdk = "3.1.1" [dev-dependencies] alloy-signer = "0.8" diff --git a/src/position_manager.rs b/src/position_manager.rs index ada9d87..724e545 100644 --- a/src/position_manager.rs +++ b/src/position_manager.rs @@ -358,7 +358,6 @@ pub fn collect_call_parameters( position: &Position, options: CollectOptions, ) -> MethodParameters { - let mut calldatas: Vec = Vec::with_capacity(1); let mut planner = V4PositionPlanner::default(); // To collect fees in V4, we need to: @@ -378,13 +377,8 @@ pub fn collect_call_parameters( options.recipient, ); - calldatas.push(encode_modify_liquidities( - planner.0.finalize(), - options.common_opts.deadline, - )); - MethodParameters { - calldata: encode_multicall(calldatas), + calldata: encode_modify_liquidities(planner.0.finalize(), options.common_opts.deadline), value: U256::ZERO, } } diff --git a/src/utils/hook.rs b/src/utils/hook.rs index 586e4a9..1ac8291 100644 --- a/src/utils/hook.rs +++ b/src/utils/hook.rs @@ -67,7 +67,7 @@ pub const fn permissions(address: Address) -> HookPermissions { #[inline] #[must_use] pub const fn has_permission(address: Address, hook_option: HookOptions) -> bool { - let mask = (address.0 .0[18] as u64) << 8 | (address.0 .0[19] as u64); + let mask = ((address.0 .0[18] as u64) << 8) | (address.0 .0[19] as u64); let hook_flag_index = hook_option as u64; mask & (1 << hook_flag_index) != 0 }