Let's talk about how to integrate Dexs like Uniswap V3. In 2021, friends who were doing MEV made enough money from triangular arbitrage in V2 to buy houses in Beijing and have multi-digit balances, but they found V3 too complicated and didn't want to deal with it, mainly because the competition is too fierce. Versions V2 and V3 almost form the cornerstone of DeFi, and the calculation mechanism of version V4 is basically consistent with V3. V2 uses K values and inverse proportional functions, where the numerical solution of at most a quadratic equation can yield all results, but V3 is about aggregated liquidity, where each position overlaps to form interval liquidity. The specific method is to construct virtual liquidity to achieve a shift in the curve. Because p = y/x ∝ L/x^2, when L remains constant and x is replaced with larger virtual liquidity, the price stabilizes significantly. However, the overlapping positions lead to liquidity being a piecewise function, with ticks acting as breakpoints, forming a tiered pricing structure similar to an order book, so it is necessary to obtain all ticks. But if the price is continuous, then the LP increment brought by the positions is also continuous, with infinitely many breakpoints, making it impossible to calculate. Therefore, the relationship between price and LP follows an interval pattern. You can buy at different prices with different liquidity step by step. The update of ticks becomes crucial; a mature method is to use a dedicated tick provider, while a simpler method is to pass in an array. Thus, path optimization becomes complex, changing from the past two parameters of reserves r1, r2 to multi-parameter optimization of (t1, L1) -> (tn, Ln). However, if routing is not considered, it is still easy to calculate.