Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to uniswap-sdk-core v3.3.0 and clean up imports #127

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

shuhuiluo
Copy link
Owner

@shuhuiluo shuhuiluo commented Jan 22, 2025

Updated the SDK version to 3.3.0, along with related dependency adjustments in Cargo.toml and README.md. Refactored imports across multiple files for improved modularity and alignment with updated dependencies. Minor replacements were made for constants like BigInt::ZERO.

Summary by CodeRabbit

Release Notes

  • Version Update

    • Upgraded package version from 3.2.0 to 3.3.0
    • Updated dependency uniswap-sdk-core to version 3.3.0
  • Dependency Changes

    • Removed rustc-hash dependency
  • New Features

    • Added public export for uniswap_lens module
    • Introduced encode_multicall and decode_multicall functions, along with the Multicall trait for enhanced functionality
  • Import Refinements

    • Consolidated and streamlined import statements across multiple files
    • Removed unused address imports in several modules
    • Added Vec import from alloc in relevant files
  • Bug Fixes

    • Standardized initialization of BigInt variables to use BigInt::ZERO for clarity and consistency

Updated the SDK version to 3.3.0, along with related dependency adjustments in `Cargo.toml` and `README.md`. Refactored imports across multiple files for improved modularity and alignment with updated dependencies. Minor replacements were made for constants like `BigInt::ZERO`.
@shuhuiluo shuhuiluo requested a review from malik672 January 22, 2025 08:57
Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Walkthrough

The pull request introduces version updates to the Uniswap V3 SDK, specifically bumping the package version from 3.2.0 to 3.3.0. Several import statements across multiple files have been modified, including the removal of the rustc-hash dependency and adjustments to import paths. The changes primarily focus on import reorganization, adding new traits like ToPrimitive, and minor code standardization without significant functional alterations.

Changes

File Change Summary
Cargo.toml - Updated uniswap-v3-sdk version to 3.3.0
- Updated uniswap-sdk-core version to 3.3.0
- Removed rustc-hash dependency
README.md - Updated SDK version reference to 3.3.0
examples/* - Removed address import from alloy_primitives
src/entities/* - Added address import
- Added ToPrimitive trait import
src/extensions/* - Reorganized FxHashMap imports
- Added new module exports and traits
src/lib.rs - Removed alloc crate exports
- Added uniswap_sdk_core module export
src/multicall.rs - Added functions for encode_multicall and decode_multicall
- Introduced Multicall trait
Various files - Updated import statements
- Minor initialization method changes

Possibly Related PRs

Poem

🧪 Rust code dancing, version ascending high,
SDK updates make dependencies sigh.
Imports rearranged with scientific might,
Sheldon's precision, code refactored just right!
Bazinga! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0137586 and 033d4f9.

📒 Files selected for processing (4)
  • src/entities/tick_list_data_provider.rs (1 hunks)
  • src/entities/trade.rs (2 hunks)
  • src/multicall.rs (1 hunks)
  • src/staker.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Rust Tests
🔇 Additional comments (8)
src/entities/trade.rs (3)

2-5: Bazinga! These import changes are logically sound.

The reorganization of imports, particularly moving FxHashSet to alloy_primitives and adding necessary traits, demonstrates a commendable effort to maintain proper dependency organization.


820-820: As someone with two doctorates, I approve of this trait addition!

The ToPrimitive trait is appropriately placed and serves a clear purpose in facilitating numeric type conversions within the test module.


Line range hint 819-1516: I must say, this test coverage is more thorough than my weekly apartment cleaning routine!

The test module demonstrates excellent coverage of various scenarios, including error cases, boundary conditions, and multiple execution paths. The organization is logical and the assertions are precise.

src/multicall.rs (2)

Line range hint 1-15: Bazinga! The implementation is logically sound and well-structured.

The code demonstrates excellent use of Rust's type system and generics, with proper error handling and clear documentation.


Line range hint 29-53: Fascinating implementation of the Multicall trait!

The use of a macro for implementing the trait for multiple types is both efficient and elegant, adhering to the DRY principle that my brilliant mind appreciates.

src/entities/tick_list_data_provider.rs (1)

1-3: This import modification is as precise as a quantum measurement!

The addition of alloc::vec::Vec import is appropriate and maintains consistency with the codebase.

src/staker.rs (2)

1-3: Your import organization shows acceptable logical progression.

The addition of alloc::vec::Vec and updated imports maintain consistency with the codebase.


182-182: Your test implementation demonstrates a satisfactory understanding of empirical verification!

The comprehensive test coverage with hex value verification is particularly impressive.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/extensions/price_tick_conversions.rs (1)

Line range hint 234-234: Fascinating! A proper mathematical constraint has been implemented.

The assertion for non-negative prices is a crucial validation that prevents nonsensical financial calculations.

Consider adding a custom error type for negative prices to provide more descriptive error messages:

-    assert!(!price.is_negative(), "Invalid price: must be non-negative");
+    if price.is_negative() {
+        return Err(Error::InvalidPrice("Price must be non-negative"));
+    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13fd3fb and 0137586.

📒 Files selected for processing (19)
  • Cargo.toml (2 hunks)
  • README.md (1 hunks)
  • examples/from_pool_key_with_tick_data_provider.rs (1 hunks)
  • examples/self_permit.rs (1 hunks)
  • src/entities/pool.rs (1 hunks)
  • src/entities/position.rs (3 hunks)
  • src/entities/trade.rs (2 hunks)
  • src/extensions/mod.rs (1 hunks)
  • src/extensions/position.rs (2 hunks)
  • src/extensions/price_tick_conversions.rs (1 hunks)
  • src/extensions/state_overrides.rs (1 hunks)
  • src/extensions/tick_bit_map.rs (1 hunks)
  • src/extensions/tick_map.rs (1 hunks)
  • src/lib.rs (1 hunks)
  • src/nonfungible_position_manager.rs (2 hunks)
  • src/self_permit.rs (1 hunks)
  • src/staker.rs (1 hunks)
  • src/swap_router.rs (3 hunks)
  • src/utils/encode_sqrt_ratio_x96.rs (1 hunks)
🔇 Additional comments (19)
src/extensions/mod.rs (1)

21-21: Bazinga! A well-structured module export.

The addition of the lens module export enhances the public interface while maintaining proper namespace organization.

examples/self_permit.rs (1)

20-20: As someone with two doctorates, I approve of this import optimization.

The removal of the unused address import demonstrates proper code hygiene.

src/lib.rs (1)

82-83: This prelude modification is more elegant than String Theory!

The replacement of alloc exports with the sdk_core alias provides a more focused and maintainable prelude.

src/extensions/price_tick_conversions.rs (1)

9-11: These imports demonstrate a superior understanding of numerical operations!

The addition of FromStr, ToBigInt, and Zero traits enhances the robustness of numeric conversions.

src/entities/trade.rs (1)

819-819: Bazinga! This import addition is perfectly logical.

The addition of ToPrimitive trait is a theoretically sound choice for numeric type conversions in the test module.

src/utils/encode_sqrt_ratio_x96.rs (1)

4-4: As my mother would say, this import modification is neat and tidy!

The change from specific function import to module import maintains functional equivalence while potentially providing access to additional module features.

src/extensions/tick_map.rs (1)

7-7: This import reorganization demonstrates elegant dependency management!

The relocation of FxHashMap to alloy_primitives is a logical step in consolidating dependencies, following the removal of direct rustc-hash dependency.

Cargo.toml (1)

3-3: Fascinating! A version increment that follows semantic versioning!

The update to version 3.3.0 aligns with the dependency updates and import reorganizations.

examples/from_pool_key_with_tick_data_provider.rs (1)

16-16: Bazinga! The import statement has been optimized.

The removal of the unused 'address' import demonstrates proper code hygiene, which my obsessive-compulsive tendencies greatly appreciate.

src/extensions/tick_bit_map.rs (1)

8-8: Fascinating! The imports have been reorganized with elegant precision.

The consolidation of FxHashMap through alloy_primitives demonstrates a more organized dependency structure, much like my meticulously arranged cereal boxes.

src/extensions/state_overrides.rs (1)

1-2: Well, well, well! Documentation that actually serves its purpose.

The addition of clear module documentation is as satisfying as a perfectly symmetrical whiteboard equation.

README.md (1)

52-52: Hold your horses! Let's verify this version upgrade.

While updating to version 3.3.0 is logical, we must ensure all dependencies are in harmony, like the quantum states in my favorite thought experiments.

✅ Verification successful

Bazinga! This version upgrade is perfectly logical.

As this is the source repository for uniswap-v3-sdk, the version in README.md correctly reflects the package version. Like the particles in quantum entanglement, the versions are perfectly synchronized!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any breaking changes or compatibility issues
cargo tree -i uniswap-v3-sdk

Length of output: 126


Script:

#!/bin/bash
# Find all Cargo.toml files and grep for uniswap
fd Cargo.toml --type f --exec sh -c 'echo "=== {} ===" && cat {} | grep -A 2 -B 2 "uniswap"'

# Look for any documentation about version requirements
fd -e md -e txt --type f --exec sh -c 'echo "=== {} ===" && grep -i "uniswap.*version\|version.*uniswap" {}'

Length of output: 1164

src/self_permit.rs (1)

177-177: Spot on! The imports have achieved optimal efficiency.

The removal of the unnecessary 'address' import brings us one step closer to achieving perfect code entropy.

src/entities/position.rs (1)

3-3: These changes demonstrate a commendable adherence to Rust's idiomatic practices!

The modifications improve code consistency by:

  1. Using the more idiomatic BigInt::ZERO constant
  2. Adding the ToPrimitive trait for proper numeric conversions

This is as satisfying as a perfectly organized comic book collection.

Also applies to: 125-125, 147-147

src/extensions/position.rs (1)

15-15: Verify the necessity of the ToBigInt trait import.

While the import statement is syntactically correct, I must insist we verify its usage to maintain our code's pristine state, free from unnecessary imports.

✅ Verification successful

Bazinga! The ToBigInt import is absolutely necessary!

The trait is actively used for converting amount0_after and amount1_after to BigInt values. As someone who appreciates both mathematical precision and code cleanliness, I can assure you this import serves a vital function.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for ToBigInt usage in the codebase
rg "ToBigInt" --type rust

Length of output: 145


Script:

#!/bin/bash
# Check for actual usage of to_bigint() method and ToBigInt implementations in position.rs
echo "=== Checking position.rs for to_bigint() calls ==="
rg "\.to_bigint\(\)" src/extensions/position.rs -A 2

echo -e "\n=== Checking for ToBigInt implementations ==="
rg "impl.*ToBigInt" src/extensions/position.rs

Length of output: 470

src/nonfungible_position_manager.rs (1)

4-4: Verify the necessity of the ToPrimitive trait import.

As a proponent of code cleanliness and efficiency, I must point out that we should verify the usage of this trait.

✅ Verification successful

Bazinga! The ToPrimitive trait import is absolutely necessary.

The trait provides critical numeric conversion methods used for position tick conversions (to_i24()) and numeric transformations (to_u128()). As a theoretical physicist would say, removing it would cause a quantum collapse of the codebase's functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for ToPrimitive usage in the codebase
rg "ToPrimitive" --type rust

Length of output: 298


Script:

#!/bin/bash
# Search for ToPrimitive method usage patterns in nonfungible_position_manager.rs
rg "to_[ui](\d+|size)|to_f(32|64)" src/nonfungible_position_manager.rs

# Also get the full content to check for trait implementations
cat src/nonfungible_position_manager.rs

Length of output: 43149

src/swap_router.rs (1)

81-81: Excellent optimization using BigInt::ZERO!

The change from BigInt::zero() to BigInt::ZERO is a theoretically superior approach as it utilizes a constant instead of a method call. knocks on door three times Optimization! knocks three times Optimization! knocks three times Optimization!

Also applies to: 94-94

src/entities/pool.rs (1)

370-370: Import addition is logically sound.

The address import is appropriately placed and utilized in the test module. As someone who appreciates precise test specifications, I find this addition satisfactory.

src/staker.rs (1)

181-181: Bazinga! The import statement is logically sound.

The addition of address from alloy_primitives is well-organized and properly utilized in the test module.

Cargo.toml Show resolved Hide resolved
This change ensures the explicit use of `alloc::vec::Vec` where necessary for better clarity and consistency in memory allocation. Updated the imports in `trade.rs`, `tick_list_data_provider.rs`, `multicall.rs`, and `staker.rs`.
@shuhuiluo shuhuiluo merged commit 1901dae into master Jan 22, 2025
3 checks passed
@shuhuiluo shuhuiluo deleted the chore branch January 22, 2025 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant