Skip to content

Uniswap V3 math: complete dex/v3.zig (tick math, sqrtPriceX96 swaps) #69

Description

@koko1123

Motivation

dex/v3.zig and dex/router.zig are stubs while V2 math is complete and benchmarked (24ns getAmountOut). V3 concentrated-liquidity math is what searchers actually need in 2026, and a limb-native Zig implementation would extend the existing 'beats Rust on DEX math' story. Complements #15 (router ABI decoding).

Scope

  • Tick <-> sqrtPriceX96 conversions (getSqrtRatioAtTick / getTickAtSqrtRatio, Q64.96 fixed point)
  • swap-within-tick amount math (SwapMath.computeSwapStep equivalent)
  • liquidity math helpers (getAmount0/1Delta)
  • Bench entries comparing against the uniswap-v3 reference vectors

Pointers

u256 limb arithmetic in uint256.zig (mulDiv already exists and is benchmarked at 18ns); validate against the canonical TickMath test vectors from the Uniswap v3-core repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededmevMEV/searcher tooling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions