Example from token B:Token B Amount=2128LP Token×(currentSqrtPrice−minSqrtPrice)so you can reverse:LP Token=currentSqrtPrice−minSqrtPriceToken B Amount×2128
When a pool uses Compounding Fee Mode (collect_fee_mode = 2), it operates as a standard constant-product AMM with no concentrated price range. The pool reserves grow over time as a portion of trading fees are automatically reinvested.
The pool maintains the invariant:token_a_amount×token_b_amount=kwhere k is a constant. Unlike the standard DAMM v2 concentrated liquidity formula, there is no sqrt_min_price or sqrt_max_price bound — liquidity spans the full price range.
Pools with layout_version == 1 track token_a_amount and token_b_amount directly in the pool state, enabling accurate reserve accounting for the compounding mechanism.
The protocol fee is first subtracted from the total trading fee. The compounding/claiming split then applies to the LP fee (after protocol fee is removed):protocol_fee=fs×100protocol_fee_percentlp_fee=fs−protocol_feecompounding_fee=lp_fee×10000compounding_fee_bpsclaiming_fee=lp_fee−compounding_feeThe compounding fee is added directly to the pool reserves, increasing k over time and benefiting all LPs proportionally.