Skip to main content
Shield Swap assigns each LP position a lower tick and an upper tick. The position contributes active liquidity only while the pool’s current tick is inside the half-open interval:
An LP can concentrate capital near the current market price. Inventory composition and fee production change as price crosses the position boundaries.

Position state

The public Position struct stores:
  • Pool identifier
  • Lower and upper ticks
  • Liquidity amount
  • Last fee-growth checkpoint for token0 and token1
  • Token0 and token1 amounts owed
The PositionNFT ownership record proves who may operate that position. Public market state can show the range and liquidity for a token_id without storing the owner’s address in the positions mapping.

Boundary accounting

Each initialized boundary stores both liquidity_gross and signed liquidity_net.
  • liquidity_gross is the total position liquidity that references the boundary.
  • liquidity_net describes the change to active liquidity when price crosses the boundary upward.
A lower boundary adds liquidity on an upward crossing. An upper boundary removes it. For a downward crossing, the contract applies the opposite sign. When liquidity_gross falls to zero, the contract removes the boundary from the initialized-tick list. This keeps the tick walk from stopping at an empty boundary.

In-range and out-of-range inventory

The liquidity formulas produce different token requirements depending on the current square-root price:
  • Below the range, the position is funded with token0.
  • Inside the range, the position uses both tokens.
  • Above the range, the position is funded with token1.
Mint and increase transfer the full native base-unit desired amounts into AMM custody, calculate the maximum supported liquidity, and then calculate the amounts actually used. The position receives desired - used as public tokens_owed; token change records contain only input-record value above the desired transfer.

Fee eligibility

Only active liquidity receives fees for a swap step. The position’s fee entitlement is derived from cumulative global fee growth and the fee-growth values stored outside its lower and upper ticks. Each step’s fractional fee growth is recorded immediately using the liquidity active during that step.

Contract-specific limits

Shield Swap combines tick ranges and Q128.128 per-liquidity fee growth with fixed unrolled tick walks, wide arithmetic, PositionNFT ownership records, public finalizer mappings, freezelist proofs, and a separate claim transaction. Quotes and range-management tools must reproduce these rules.