Skip to content

Commit

Permalink
chore: Rearrange derive attributes and simplify default implementation (
Browse files Browse the repository at this point in the history
#49)

* Rearrange derive attributes and simplify default implementation

The order of derive attributes has been rearranged to align with the standard convention across different structures in the code. Also, the default implementation in the get_fee_growth_inside.rs file has been simplified by applying the derive attribute for Default. These changes improve code consistency and readability.

* Update Uniswap V3 SDK version to 0.29.1

* Fix lint
  • Loading branch information
shuhuiluo authored May 1, 2024
1 parent 959b75c commit 00a6157
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "uniswap-v3-sdk"
version = "0.29.0"
version = "0.29.1"
edition = "2021"
authors = ["Shuhui Luo <twitter.com/aureliano_law>"]
description = "Uniswap V3 SDK for Rust"
license = "MIT"
readme = "README.md"
repository = "https://github.com/shuhuiluo/uniswap-v3-sdk-rs"
keywords = ["uniswap-v3", "ethereum", "rust", "sdk"]
keywords = ["uniswap-v3", "ethereum", "sdk"]
exclude = [".github", ".gitignore", "rustfmt.toml"]

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion src/entities/tick_list_data_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
use anyhow::Result;

/// A data provider for ticks that is backed by an in-memory array of ticks.
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct TickListDataProvider(Vec<Tick>);

impl TickListDataProvider {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/trade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn trade_comparator<TInput: CurrencyTrait, TOutput: CurrencyTrait, P: Clone>
}
}

#[derive(Clone, PartialEq, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct BestTradeOptions {
/// how many results to return
pub max_num_results: Option<usize>,
Expand Down
2 changes: 0 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(test)]

use crate::prelude::*;
use alloy_primitives::U256;
use once_cell::sync::Lazy;
Expand Down
10 changes: 1 addition & 9 deletions src/utils/get_fee_growth_inside.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
use alloy_primitives::U256;

#[derive(Clone, Debug, Default, PartialEq)]
pub struct FeeGrowthOutside {
pub fee_growth_outside0_x128: U256,
pub fee_growth_outside1_x128: U256,
}

impl Default for FeeGrowthOutside {
fn default() -> Self {
Self {
fee_growth_outside0_x128: U256::ZERO,
fee_growth_outside1_x128: U256::ZERO,
}
}
}

pub fn get_fee_growth_inside(
lower: FeeGrowthOutside,
upper: FeeGrowthOutside,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tick_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<T: TickTrait> TickList for [T] {
(next_initialized_tick, next_initialized_tick == index)
} else {
let word_pos = (compressed + 1) >> 8;
let maximum = (((word_pos + 1) << 8) - 1) * tick_spacing;
let maximum = ((word_pos << 8) + 255) * tick_spacing;
if Self::is_at_or_above_largest(self, tick) {
return (maximum, false);
}
Expand Down

0 comments on commit 00a6157

Please sign in to comment.