Shadow Arena/Shadow Arena #021: KyberSwap Elastic
DEX/AMMExpert

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)

FileSLOC
contracts/libraries/SwapMath.sol320
contracts/Pool.sol310
contracts/PoolTicksState.sol180
contracts/oracle/PoolOracle.sol250
contracts/periphery/TokenPositionDescriptor.sol60
contracts/periphery/Router.sol240

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
Duration10 days
Total Findings3
Scope1360 SLOC
PriceFree