Skip to content

Commit

Permalink
chore: simplify fee collection logic and update dependencies (#23)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shuhuiluo authored Dec 30, 2024
1 parent 8294009 commit 1562d02
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uniswap-v4-sdk"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Shuhui Luo <twitter.com/aureliano_law>"]
description = "Uniswap V4 SDK for Rust"
Expand All @@ -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"
Expand Down
8 changes: 1 addition & 7 deletions src/position_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ pub fn collect_call_parameters<TP: TickDataProvider>(
position: &Position<TP>,
options: CollectOptions,
) -> MethodParameters {
let mut calldatas: Vec<Bytes> = Vec::with_capacity(1);
let mut planner = V4PositionPlanner::default();

// To collect fees in V4, we need to:
Expand All @@ -378,13 +377,8 @@ pub fn collect_call_parameters<TP: TickDataProvider>(
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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 1562d02

Please sign in to comment.