The Binding — afterInitialize
OddVern is an BEP-20 contract on BNB Chain that simultaneously implements PancakeSwap v4's BaseHook interface. When its target pool is created on the PancakeSwap v4 PoolManager, the afterInitialize callback fires. OddVern uses this callback to permanently bind itself to the pool's PoolKey — a five-field struct containing currency0, currency1, fee, tickSpacing, and the hooks contract reference.
The binding is one-way and one-time. Once afterInitialize completes, all subsequent hook callbacks verify their incoming PoolKey against the stored binding. Swaps on any other pool are rejected at the first callback. The contract refuses to operate on any pool other than the one it was originally bound to.
This binding is cryptographic, not configurable. There is no admin function that can change it, no migration path that can move it, no upgrade pattern that could replace it. The contract is married to its pool at the moment of pool creation, and the marriage cannot be dissolved.
The Coefficient — afterSwap
The afterSwap callback is where OddVern does its primary computation. When a swap settles, the PoolManager updates the pool's slot0 — its sqrtPriceX96 and active tick — and updates the liquidity at each touched tick. OddVern's afterSwap reads this updated state and walks the tick bitmap.
For each populated tick within ±256 of the active tick, the hook reads the tick's net liquidity. Each tick's contribution to the coefficient is weighted by its inverse distance from the active tick — closer ticks count more, farther ticks count less. The weighted sum is normalized by the pool's total liquidity to produce a unitless value between zero and one.
This value is the concentration coefficient. It is stored as 18-decimal fixed-point and emitted as a CoefficientUpdated event. It is the only number the protocol exposes as live state, and it changes with every swap. As the coefficient rises, the geometry tightens; as it falls, the geometry loosens.
