Shadow Arena #021: KyberSwap Elastic
You built Uniswap V3's swap loop from scratch: one `liquidity` value, tick crossings that update it, rounding directions chosen so the invariant never breaks in the protocol's favor. KyberSwap Elastic re-authored that engine to fold swap fees straight back into active liquidity, so the swap step now tracks TWO components (baseL + reinvestL) instead of V3's single `liquidity`. That re-authoring is exactly where a ~$48M rounding-direction bug lived in the tick-crossing math. This is the capstone: a Sherlock competitive audit ran on this exact code in July 2023 and found a dependency bug and a router address collision, but the swap-loop rounding bug went unreported and was exploited in November 2023. 3 representative findings (1 C + 2 M) — the real exploit as C-01, plus the two Mediums the contest actually caught.
Scope (1360 SLOC)
| File | SLOC |
|---|---|
| contracts/libraries/SwapMath.sol | 320 |
| contracts/Pool.sol | 310 |
| contracts/PoolTicksState.sol | 180 |
| contracts/oracle/PoolOracle.sol | 250 |
| contracts/periphery/TokenPositionDescriptor.sol | 60 |
| contracts/periphery/Router.sol | 240 |
Documentation
Part of the Uniswap V3 Path
This shadow audit connects to the Uniswap V3 Build module. Students who built the concentrated-liquidity pool have an advantage because they understand tick accounting, the swap loop, fee growth, the observation oracle, and callback-based payment.
View Build Module