OddVern figure

OddVern

A first-of-its-kind experiment on PancakeSwap v4 · BNB Chain

Abstract

OddVern is an autonomous on-chain protocol deployed on BNB Chain, implemented entirely within PancakeSwap v4's hook callback layer. The program is simultaneously an BEP-20 contract and a PancakeSwap v4 hook, bound permanently to a single liquidity pool through CREATE2 mining. Every interaction with that pool passes through OddVern's logic before the PoolManager processes it. The mechanism is geometric, not economic: OddVern does not collect fees, redistribute supply, or modify the price curve. It records, observes, and quietly modifies the geometry of where liquidity is permitted to live.

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.

The Gate — beforeAddLiquidity

The beforeAddLiquidity callback intercepts every attempt to provide liquidity to the bound pool. Its job is to reject deposits whose tick range exceeds an allowable bound. The bound is computed dynamically from the current coefficient:

maxAllowableTickWidth = MAX_TICK_RANGE × (1 − coefficient)

At coefficient zero, any range is acceptable — wide bands, narrow bands, anywhere in tick space. At coefficient near one, only positions within ±tickSpacing of the active tick are accepted. Everything else reverts.

The gate is not advisory. When an LP attempts to deposit outside the allowable window, the callback reverts and the entire transaction including any token transfers fails.

The Withdrawal — beforeRemoveLiquidity

The beforeRemoveLiquidity callback fires before any LP withdrawal. Unlike the add-liquidity gate, it does not reject the operation. Instead, it computes a coefficient adjustment: how much the global coefficient decreases as a result of this withdrawal.

Withdrawals from concentrated bands — positions tightly clustered around the active price — produce smaller decreases than withdrawals from wide bands. This asymmetry preserves the work done by past swaps.

The geometry the pool has been steered into is sticky against random LP exits. Easy to concentrate. Hard to dilute.

The Hook Layer

OddVern enables six of the fourteen V4 hook flags. Each callback fires at a specific moment in the pool's interaction lifecycle:

afterInitialize
Binds the contract to its target pool permanently.
beforeSwap
Captures pre-swap state. Returns ZERO_DELTA.
afterSwap
Walks the tick bitmap. Computes the coefficient.
beforeAddLiquidity
Reads the coefficient. Rejects out-of-band deposits.
beforeRemoveLiquidity
Asymmetric withdrawal accounting.
beforeSwapReturnDelta
Flag enabled. Callback returns zero for V4 parity.
the contract is six callbacks and one value. nothing else.

The Permission Bitmap

V4 hooks declare their callback subscriptions through a permission bitmap encoded in the contract's address. The trailing 14 bits of a hook's address must match the bits set in getHookPermissions. OddVern enables six flags: afterInitialize, beforeSwap, afterSwap, beforeAddLiquidity, beforeRemoveLiquidity, and beforeSwapReturnDelta.

The program address is derived via CREATE2 at deployment time using HookMiner from v4-periphery. The salt is brute-forced until a candidate address has the correct bits in the correct positions.

This binding between bytecode behavior and address layout is enforced by the PoolManager itself — a hook with mismatched bits cannot be called by the protocol.

The Invariant

The standard V4 PoolManager preserves the AMM invariant — every swap respects the constant-product or concentrated-liquidity math the pool was initialized with. OddVern does not modify the invariant. It does not change the price curve. It does not modify the swap math.

It operates entirely on the geometry of where liquidity is allowed to live, not how that liquidity prices.

This distinction matters. Swappers experience OddVern's pool as a normal V4 pool with normal slippage and normal price impact. Liquidity providers experience it as a pool with progressively narrowing deposit windows. Both views are correct. The AMM is unchanged; the geography of the AMM is what OddVern shapes.

Philosophy: Stillness Over Noise

OddVern stands in opposition to the cacophony of activity-obsessed protocols. In a space dominated by volume tracking, hype cycles, and viral mechanics, OddVern prioritizes a different set of values:

Quiet Systems: OddVern records what does not happen as faithfully as what does. The coefficient is the protocol's most honest reading — a number derived from geometry, not noise.

Geometric Honesty: No incentive structures, no liquidity mining, no fee distributions. OddVern rewards no one. It simply observes, records, and gates. The pool's shape is its only output.

Minimal Mechanism: The entire protocol is six hook callbacks and a single uint256. Complexity is the enemy of integrity. What cannot be modified cannot be exploited.

This philosophy aligns with OddVern's character: patient, watchful, immutable, and intentionally distant from the noise of conventional crypto narratives. The contract is the experiment; the coefficient is the only reading.