We study the optimal timing of liquidity withdrawal for a liquidity provider (LP) in an automated market maker (AMM). While liquidity provision generates fee income, it also exposes LPs to impermanent loss arising from price fluctuations and arbitrage activity. We formulate the LP's exit decision as an optimal stopping problem in which the exit time is chosen endogenously to balance these opposing effects. The model explicitly distinguishes between an external reference price and the AMM's internal price, with trades driven by stochastic order flows that include both arbitrageurs and noise traders. Using dynamic programming, we characterise the LP's value function as the unique viscosity solution to a Hamilton-Jacobi-Bellman quasi-variational inequality. We solve the problem numerically using both a finite-difference Euler scheme and a Longstaff-Schwartz regression approach. Our results show that the optimal exit strategy depends jointly on price volatility, fee levels, and trading activity. Liquidity providers tend to remain in the pool when expected fee income outweighs potential impermanent loss, but optimally exit when price misalignments become too large. In particular, LPs may withdraw liquidity before arbitrageurs fully realign prices, thereby limiting realised impermanent loss.

PDF version