Skip to content

UserStatsPerPool: V2 remove-liquidity attributed to the pool address instead of the LP #911

Description

@FonsSicca

Source: data-quality audit of deployment 8fcf9a8 (2026-07-07). Full findings: Notion audit.

What to build

Attribute V2 remove-liquidity to the withdrawing liquidity provider instead of the pool's own address. Every V2 burn is currently credited to the pool address. All six on-chain burns checked land on real users whose totalLiquidityRemoved fields read zero, and each V2 pool carries exactly one row with a positive removed value, namely the pool itself. Across just the top 20 pools, $70.9B of lifetime removals are misattributed this way.

The burn flow is a transfer from the user to the pool followed by a transfer from the pool to the zero address. Only mint and burn transfers are stored for matching, so the matched transfer's sender is always the pool. lpBalance and all conservation sums are unaffected because they are driven by the regular user-to-pool transfer. Mint-side attribution is correct on all 10 checks, and CL removals through the position manager are correct. The defect is V2-only.

Root cause: src/EventHandlers/Pool/PoolTransferLogic.ts line 299 stores only mint and burn transfers, and src/EventHandlers/Pool/PoolBurnAndMintLogic.ts line 156 sets the recipient to the matched transfer's sender.

Acceptance criteria

  • V2 burns credit the withdrawing LP, not the pool address.
  • totalLiquidityRemovedUSD/Token0/Token1 populate on real user rows.
  • Mint-side attribution, lpBalance, and conservation sums unchanged.
  • Test covers a V2 burn resolving to the LP.

Blocked by

None — can start immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions