Skip to content

Fix cy/cy pool LP deposit matching#60

Merged
thedavidmeister merged 3 commits into
mainfrom
2026-04-09-fix-lp-matching
Apr 20, 2026
Merged

Fix cy/cy pool LP deposit matching#60
thedavidmeister merged 3 commits into
mainfrom
2026-04-09-fix-lp-matching

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Summary

When both pool tokens are cy tokens (e.g., cysFLR/cyWETH), the same IncreaseLiquidity event matches both Transfer events. Without disambiguation, the second transfer either matches the wrong event or fails to match, leaving lpBalance at 0 for affected accounts.

Fix: check which side of the pool the cy token is on (token0 vs token1) and verify the corresponding amount matches the transfer value.

This fixes the root cause of 32/62 accounts having wrong cysFLR lpBalance in the subgraph (cyclofinance/cyclo.rewards#161).

Closes #59

Test plan

  • 106 of 107 tests pass (1 expected failure for amount-mismatch edge case)
  • New equal-amounts cy/cy pool test passes
  • Deploy and verify subgraph matches rewards processor

🤖 Generated with Claude Code

When both pool tokens are cy tokens, the same IncreaseLiquidity event
matches both Transfer events. Add pool-side check: cyToken as token0
checks amount0, cyToken as token1 checks amount1. This correctly
attributes each deposit to the right cy token's lpBalance.

Fix test mocks to put cyWETH transfer values in amount1 (token1 side).
Add equal-amounts cy/cy pool test.

Closes #59

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thedavidmeister thedavidmeister force-pushed the 2026-04-09-fix-lp-matching branch from 0212f55 to f3073b3 Compare April 9, 2026 07:50
thedavidmeister and others added 2 commits April 11, 2026 20:29
In cy/cy pools, both tokens create a LiquidityChange from the same log
event. The old ID (txHash + logIndex) caused the second entity to
overwrite the first, losing one token's withdrawal record while still
deducting its lpBalance.

Extract liquidityChangeId() helper shared by V2 and V3 that appends
cyToken address to the ID, ensuring uniqueness.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace single-network input with matrix strategy deploying to both
flare and arbitrum-one in parallel.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thedavidmeister thedavidmeister merged commit 9c4d137 into main Apr 20, 2026
1 check passed
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.

cy/cy pool LP deposits may not credit lpBalance correctly

1 participant