This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build core library (no_std by default)
cargo build
# Build with std feature
cargo build --features std
# Build with extensions (includes alloy for RPC interactions)
cargo build --features extensions
# Build with all features
cargo build --all-features# Run core tests
cargo test
# Run tests with std feature
cargo test --features std
# Run extension tests (must be single-threaded due to RPC state)
cargo test --features extensions --lib extensions -- --test-threads=1
# Run doc tests
cargo test --doc --all-features
# Run a specific test
cargo test test_name
# Run tests in a specific module
cargo test module_name::# Run clippy (must pass with no warnings)
cargo clippy --all-targets --all-features -- -D warnings
# Check formatting
cargo fmt --all -- --check
# Apply formatting
cargo fmt --allThis is a Rust implementation of the Uniswap V4 SDK, maintaining API compatibility with the TypeScript SDK while leveraging Rust's performance and safety features.
- no_std by default: Library works without the standard library for embedded/WASM environments
- Feature-gated extensions: Optional functionality behind the
extensionsfeature flag - Type safety: Strong typing using Rust's type system and alloy-rs types
- Integration with V3 SDK: Builds upon and re-exports uniswap-v3-sdk functionality
abi: Solidity type definitions using alloy-sol-types for V4 contractsentities: Core domain models (Pool, Position, Route, Trade) that represent V4 conceptsposition_manager: NFT position management with V4-specific actions (mint, increase/decrease liquidity)utils: V4-specific utilities including:v4_planner: Transaction planning for complex V4 operationsv4_position_planner: Position-specific transaction planningv4_base_actions_parser: Parse and encode V4 actions- Price/tick conversions, currency handling, hook utilities
extensions(feature-gated): Optional functionality requiring RPC access:pool_manager_lens: Query pool state directly from contracts (like StateView)simple_tick_data_provider: Fetch tick data via RPC calls
alloy: Ethereum types and contract interactions (optional, for extensions)uniswap-sdk-core: Core SDK functionality (currencies, tokens, etc.)uniswap-v3-sdk: V3 SDK for shared functionality and re-exportsthiserror: Error handling with proper error types
- Unit tests are inline with modules using
#[cfg(test)] - Shared test utilities and tokens are in
src/tests.rs - Extension tests require RPC access and must run single-threaded
- Tests match the TypeScript SDK for compatibility verification
- MSRV (Minimum Supported Rust Version) is 1.91
- When adding new features, maintain compatibility with the TypeScript SDK API
- Use snake_case naming convention (not camelCase like TypeScript)
- Import via prelude for convenience:
use uniswap_v4_sdk::prelude::* - Extension tests require
MAINNET_RPC_URLenvironment variable for RPC access