Skip to content

feat: Add PancakeSwap V4 support and test cases#5

Open
jetbldr wants to merge 1 commit into48Club:mainfrom
jetbldr:main
Open

feat: Add PancakeSwap V4 support and test cases#5
jetbldr wants to merge 1 commit into48Club:mainfrom
jetbldr:main

Conversation

@jetbldr
Copy link

@jetbldr jetbldr commented Jan 10, 2026

Summary

Add support for detecting sandwich attacks on PancakeSwap V4 pools.

Changes

  • New protocol parser: Added protocols/pancakev4/pancakev4.go to parse PancakeSwap V4 Swap events
  • Updated swap detection: Added PancakeSwap V4 event signature (0x04206ad2b7c0f463bff3dd4f33c5735b0f2957a351e4f79763a4fa9e775dd237) to protocols/swap.go
  • Test coverage: Added testCase7PancakeV4 test case using real on-chain sandwich attack data
  • Documentation: Updated README.md to reflect PancakeSwap V4 as a separately supported protocol

Background

PancakeSwap V4 uses a different Swap event signature than Uniswap V4:

  • Uniswap V4: 0x40e9cecb9f5f1f1c5b9c97dec2917b7ee92e57ba5563708daca94dd84ad7112f
  • PancakeSwap V4: 0x04206ad2b7c0f463bff3dd4f33c5735b0f2957a351e4f79763a4fa9e775dd237

Event structure:

Swap(bytes32 indexed id, address indexed sender, int128 amount0, int128 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick, uint24 fee, uint16 protocolFee)

Testing

go test -v -run TestDetectSandwichForBundle/testCase7PancakeV4

All tests pass ✅

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