Burning LP tokens

Last modified:

Liquidity providers may also remove liquidity from a CenturionDEX v2 pool. To do so, they return LP tokens to the protocol and, in exchange, receive the corresponding proportional share of the pool reserves.

We now describe this process more precisely. Consider a CenturionDEX v2 pool with reserves xx and yy of tokens XX and YY, respectively, and let SS denote the current total supply of LP tokens. Suppose that a liquidity provider redeems an amount ΔS\Delta S of LP tokens. Since LP tokens represent proportional ownership of the pool, redeeming ΔS\Delta S tokens corresponds to withdrawing the fraction

ΔSS\frac{\Delta S}{S}

of the pool.

Therefore, in exchange for burning ΔS\Delta S LP tokens, the liquidity provider receives

Δx=ΔSSx\Delta x=\frac{\Delta S}{S}x

units of token XX and

Δy=ΔSSy\Delta y=\frac{\Delta S}{S}y

units of token YY.

The redeemed LP tokens are then burned, so the total supply of LP tokens is updated to

S=SΔS.S' = S-\Delta S.

At the same time, the pool reserves are reduced proportionally. Hence, the post-burn reserves become

x=xΔx=xΔSSxx' = x-\Delta x = x-\frac{\Delta S}{S}x

and

y=yΔy=yΔSSy.y' = y-\Delta y = y-\frac{\Delta S}{S}y.

Thus, burning LP tokens simply returns to the liquidity provider the same fraction of each reserve as the fraction of LP supply being redeemed.

In the on-chain implementation, the returned token amounts are computed with integer division (for example, liquidity * balance / totalSupply), so each token amount is rounded down to the nearest wei.

The formula for the amounts returned upon liquidity removal is exactly the one implemented by the burn logic in CenturionDEX v2. In canonical notation, the mechanism is fully described by the relations above.