Skip to content
All library documents

Building a Real-Time DEX Liquidity Strategy with Execution and Cost Checks

Article FMZ digest · Author: ianzeng123

Summary

This case study describes building an automated concentrated-liquidity strategy for V3 and V4 pools. After two of three newly discovered tokens could not be sold, the author distinguishes token-level sell restrictions from liquidity removal and concludes that simulated mark-to-market gains are not realized profits. The revised accounting separates forecasts, inventory value, fees, and cash flows, and preserves unfinished transaction state for recovery.

The system broadens pool discovery through a paginated directory API, then combines market statistics with on-chain checks. Before entry, it estimates the strategy’s share of pool liquidity and compares discounted fee expectations with quote loss, slippage reserves, and gas budgets. Small live workflow tests measure transaction costs from receipts and reveal substantial variation between runs. Exit checks use price, losses, liquidity, and realized fee accrual rather than a fixed holding timer. The tests demonstrate that the process can execute and account for trades, but they do not establish long-term profitability; the fee model, pool filters, and risk controls still need validation.

Key ideas

  • A pool’s displayed price does not guarantee that a position can be exited at that price.
  • Track forecast income, inventory valuation, realized fees, and cash flows separately.
  • Use a broad pool directory for discovery, then verify candidates with market data and on-chain checks.
  • Estimate fee income from the position’s liquidity share and compare it with full entry and exit costs.
  • Measure gas from transaction receipts because costs can vary across otherwise similar operations.
  • Short execution tests do not establish that the strategy is profitable over time.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.