In the current situation of the Web3 industry, DeFi-related products occupy an absolute market share. Among them, AMM (Automated Market Maker) is a key link and a powerful promoter ofIn the current situation of the Web3 industry, DeFi-related products occupy an absolute market share. Among them, AMM (Automated Market Maker) is a key link and a powerful promoter of

Solana Ecosystem AMM Research: The Underlying Code Behind High Liquidity

2025/06/24 07:00
7 min read

In the current situation of the Web3 industry, DeFi-related products occupy an absolute market share. Among them, AMM (Automated Market Maker) is a key link and a powerful promoter of changes in Web3 finance. This article will introduce several important AMM implementations in the Solana ecosystem, hoping to provide some help to LP (Liquidity Provider) on how to choose their investment strategy.

CPMM

CPMM ( Constant Product Market Maker ) is the most basic AMM implementation and is implemented in many products. Here we use the AMM based on constant product launched by Raydium as an example. The constant product means that the supply of the two tokens in the pool has a fixed product: X * Y = k.

For liquidity providers, when anyone adds liquidity (adds assets) to the pool, CPMM will automatically create an associated account for the wallet address and issue LP Token (each token pair has its own LP Token Mint). This LP Token is used to prove that the wallet address holds a share of a pool, and the corresponding Token will be destroyed when the liquidity provider withdraws.

The on-chain program of CPMM is developed using Anchor, and the program code can be found at https://github.com/raydium-io/raydium-cp-swap . Let’s briefly confirm how it achieves constant product.

First, when users use Raydium's CPMM to exchange tokens, swap-related instructions will be triggered.

For example (for illustrative purposes only, this article is not responsible for any token): when a user wants to use USDC to exchange TRUMP, they can exchange it through the TRUMP-USDC pool.

pond

TRUMP

USDC

7XzVsjqTebULfkUofTDH5gDdZDmxacPmPuTfHa1n9kuh

6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN

EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v

For example, let's look at this transaction . For simplicity, let's ignore other instructions in the transaction and only look at the Raydium part. Find Raydium CPMM: swapBaseInput :

Solana Ecosystem AMM Research: The Underlying Code Behind High Liquidity

In Input Accounts, we can see that the input token is USDC and the output token is TRUMP. In the AMM of the Solana ecosystem, LP Pair can be simply represented by Token Account, without creating a new contract program and deploying it (such as the factory contract commonly used in Ethereum). When a transaction occurs, it interacts directly with Raydium's CPMM Program. The Solana program will modify the status of the corresponding Token Account through the incoming pool address, token address, etc. to perform swap operations.

For example, the code for the swapBaseInput instruction above can be found here . After a series of pre-checks, the exact amount of target tokens that can be exchanged is calculated in ConstantProductCurve.swap_base_input_without_fees :

Solana Ecosystem AMM Research: The Underlying Code Behind High Liquidity

The formula used is:

Solana Ecosystem AMM Research: The Underlying Code Behind High Liquidity

That is, after the total amount of TokenX and TokenY changes, their product should remain unchanged. The left side of the formula is the product after the change, and the right side is the product before the change.

Solana Ecosystem AMM Research: The Underlying Code Behind High Liquidity

After mathematical transformation, the above formula can be converted into the conversion formula of Δy (that is, the number of y tokens we can exchange):

Solana Ecosystem AMM Research: The Underlying Code Behind High Liquidity

That is, delta_y = (delta_x * y) / (x + delta_x) part in the code. Note that the calculation here does not include the handling fee, which has been deducted in the pre-logic of swap_base_input .

CLMM

CLMM (Concentrated Liquidity Market Maker) is also an AMM launched by Raydium. It is similar to Uniswap V3. Each token pair also has multiple fee tiers, and can create a corresponding pool for each tier.

Since the implementation of CLMM refers to Uniswap V3, when learning it, many concepts and implementation methods can refer to Uniswap's implementation. It also inherits Uniswap's concepts such as tick, multiple fee tiers, centralized liquidity, etc. More content can be found in the DEX development course launched by ZAN: DEX Development Practice - Uniswap Code Analysis - How Uniswap works - ZAN

However, it should be noted that, similar to CPMM, due to the characteristics of the Solana chain, Raydium CLMM does not need to deploy a separate contract for each pool, so there is no concept of factory contracts. This is different from Uniswap.

CLMM allows liquidity providers to select a price range when injecting funds, and the funds will be distributed only within the selected range:

Solana Ecosystem AMM Research: The Underlying Code Behind High Liquidity

For centralized liquidity pools, tokens exist on both sides of the current price. The price range selected in the above figure includes the current price, so the funds will be allocated to the two tokens in the pool.

We can also inject only one type of token to provide so-called one-sided liquidity (as shown below). This is somewhat similar to the limit order in the traditional financial model. LP funds will only be used when the token price reaches a certain range, but this model also has more risk points to consider.

Solana Ecosystem AMM Research: The Underlying Code Behind High Liquidity

Generally speaking, for pools with small price fluctuations, LPs tend to choose a smaller range; conversely, for pools with very drastic price fluctuations, they tend to choose a larger range. The purpose of this is to try not to let the current price deviate from the price range you choose, causing too much impermanent loss.

It should be noted that although centralized liquidity can make LP's capital utilization rate higher, it also places higher demands on LP's financial awareness. LP needs to manage its own liquidity more actively. If LP fails to respond effectively, the frequent fluctuations on the chain will easily cause LP to suffer serious impermanent losses.

DLMM

DLMM (Dynamic Liquidity Market Maker) is an AMM product launched by Meteora. It is also a type of Uniswap V3. It is very similar to the CLMM mentioned above. DLMM also allows LPs to concentrate their funds within a certain range near the current price. However, DLMM is somewhat different in its specific implementation and provides some special features.

DLMM provides the concept of Bin. The pool will start from the base price and exist as a Bin every small Bin step. If the transaction occurs in the same Bin, the trader will enjoy zero slippage. This can greatly increase the transaction volume and transaction success rate. In theory, LP can earn more transaction fees.

Solana Ecosystem AMM Research: The Underlying Code Behind High Liquidity

Similar to CLMM, the tokens in the pool are also distributed on both sides of the current price, and one token only needs to provide unilateral liquidity. However, according to the concept of Bin, the currently activated Bin (indicating the current exchange price) has two tokens. That is:

  • Currently activated Bin: There are two tokens in it. Swapping tokens in the current Bin will be done at a fixed price with 0 slippage;
  • Other Bins: Distributed on both sides of the currently activated Bin, each with only a single token.

When the amount of tokens in the currently activated Bin changes, if the tokens of one party are reduced to 0, DLMM will set the currently activated Bin to the next Bin on its left or right according to the actual situation in the pool, thereby driving price changes in the pool.

When LP provides liquidity, DLMM provides 3 strategies, namely Spot, Curve and Bid Ask

  • Among them, Spot is the most universal, and basically all liquidity pools are suitable. It is considered to be the simplest liquidity strategy.
  • Curve is more suitable for pools with very small price changes, such as stablecoin pairs. The price fluctuations in these pools are very small, and as its shape reveals, concentrating LP funds in this range can maximize the transaction fees.
  • Bid Ask is more suitable for pools with very large price fluctuations. People tend to conduct more arbitrage transactions in such pools, and prices may be difficult to concentrate in a small range. This strategy usually requires LPs to frequently adjust their positions to prevent prices from deviating from the funding range they set. This is usually not easy because it involves market judgment.

Summarize

As an important part of the Web3 financial field, AMM promotes the popularization and development of decentralized finance through its unique mechanisms and innovations. With the continuous advancement of technology and the improvement of the ecosystem, AMM is expected to play a greater role in the future and further change the landscape of traditional finance.

Market Opportunity
DeFi Logo
DeFi Price(DEFI)
$0,000313
$0,000313$0,000313
-%3,98
USD
DeFi (DEFI) Live Price Chart
Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact [email protected] for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

Top NYC Book Publishing Companies

Top NYC Book Publishing Companies

New York City has been the epicenter of American publishing for generations, but “NYC publishing” isn’t just one lane. Today’s landscape includes two very different
Share
Techbullion2026/02/06 14:02
Sensorion Announces its Participation in the Association for Research in Otolaryngology ARO 49th Annual Midwinter Meeting

Sensorion Announces its Participation in the Association for Research in Otolaryngology ARO 49th Annual Midwinter Meeting

MONTPELLIER, France–(BUSINESS WIRE)–Regulatory News: Sensorion (FR0012596468 – ALSEN) a pioneering clinical-stage biotechnology company which specializes in the
Share
AI Journal2026/02/06 14:45
AI Crypto Trading Secrets: What They Won’t Tell You About Profits and Pitfalls|9-Figure Media

AI Crypto Trading Secrets: What They Won’t Tell You About Profits and Pitfalls|9-Figure Media

AI crypto trading is everywhere, and every YouTube guru claims their bot mints money while they sleep. Sounds dreamy, right? However, most don’t discuss the full story, the wild profits possible, and the lurking pitfalls. As someone obsessed with the intersection of artificial intelligence and digital assets, let me pull back the curtain on the realities of algorithmic trading in the crypto jungle. Here’s what nobody tells you: 87% of retail traders using automated systems lose money within their first year. The marketing materials show cherry-picked results. The testimonials come from paid affiliates. But here’s the twist. The remaining 13% who succeed aren’t just lucky. They understand something the majority misses entirely. The Reality Behind the Hype The crypto world loves success stories. You’ve probably seen them. “I made $50,000 in three months using this bot.” What they don’t mention? The $200,000 they lost by testing seventeen other systems first. Real talk: most trading algorithms fail because they’re built for perfect market conditions. Crypto markets are anything but perfect. Think about it like this. Would you trust a Formula 1 car to handle rush hour traffic? That’s essentially what most people do with their trading bots. Why Smart Money Uses Crypto AI Tools Differently Professional traders approach crypto AI tools with surgical precision. They don’t expect miracles. They expect consistent, measured results. The difference lies in understanding what these tools actually do well: • Risk management automation • Pattern recognition at scale • Emotional bias elimination • 24/7 market monitoring • Portfolio rebalancing Notice what’s missing from that list? Get-rich-quick schemes. The smartest crypto AI tools focus on protecting capital first. Profits come second. This mindset separates winners from losers. Here’s something interesting. 9-figure media companies track these patterns religiously. They know which crypto AI tools produce sustainable results versus flashy short-term gains. Professional traders using crypto AI tools typically target 15–25% annual returns. Not 500% monthly moonshots. The Startup Connection Most People Ignore AI for startups isn’t just about building the next ChatGPT. Many successful companies use AI to optimize their crypto treasury management. Smart startups integrate crypto AI tools into their financial operations early. They automate routine decisions. They reduce human error. They scale their trading operations without hiring armies of analysts. But here’s where it gets interesting. The best AI for startup applications in crypto aren’t the obvious ones. Consider automated tax reporting. Or real-time compliance monitoring. Or treasury optimization across multiple blockchains. These unsexy applications generate more consistent profits than flashy trading algorithms. AI for startups in the crypto space succeeds when it solves boring problems efficiently. Not when it promises unrealistic returns. The most successful AI for startups implementations focus on operational efficiency. They reduce costs. They minimize risks. They free up human resources for strategic decisions. Learning from Top AI Start-Ups Top AI start-ups in the crypto space share common characteristics. They prioritize transparency over marketing hype. Look at successful top AI start-ups like Chainalysis or Elliptic. They don’t promise easy money. They provide essential infrastructure. The best top AI start-ups focus on solving real problems: • Market data analysis • Security monitoring • Regulatory compliance • Portfolio analytics • Risk assessment These top AI start-ups understand something crucial. Sustainable businesses solve actual problems. They don’t just ride hype cycles. 9-figure media outlets consistently highlight these fundamental companies. They ignore the noise. They focus on substance. Many top AI start-ups actually discourage retail trading. They know the odds. They’ve seen the casualties. Instead, successful top AI start-ups build tools for institutions. Banks. Hedge funds. Companies with proper risk management systems. The Hidden Costs Nobody Discusses Using crypto AI tools costs more than subscription fees. Much more. First, there’s the learning curve. Most people spend months figuring out proper settings. During this time, they’re paying tuition to the market. Second, there’s infrastructure. Reliable crypto AI tools require stable internet, backup systems, and proper security measures. Third, there’s opportunity cost. Time spent tweaking algorithms could be spent learning fundamental analysis. The real cost? Most people using crypto AI tools trade more frequently. Increased trading usually means increased losses. Think about 9-figure media companies again. They understand that technology amplifies existing skills. It doesn’t replace them. Smart Implementation Strategies Successful crypto AI tools users follow specific patterns: • Start with paper trading • Use position sizing rules • Set strict stop losses • Monitor performance weekly • Adjust strategies quarterly They treat crypto AI tools like any other business tool. With respect. With caution. With realistic expectations, startup applications work similarly. They augment human decision-making. They don’t replace it. The most successful AI for startups implementations in crypto involve human oversight at every level. Algorithms suggest. Humans decide. What Actually Works Here’s what separates successful crypto AI tools users from everyone else: They focus on consistency over home runs. They understand that small, regular gains compound better than occasional big wins followed by devastating losses. They apply AI principles to their approach for startups. They iterate quickly. They fail fast. They learn constantly. They study top AI start-ups for inspiration. But they don’t try to replicate their exact strategies. Most importantly, they never risk money they can’t afford to lose. The crypto market will humble anyone. AI doesn’t change this fundamental truth. Your success with crypto AI tools depends more on your discipline than the sophistication of your algorithms. Remember: the house always has an edge. Your job is to find where that edge doesn’t apply. That’s the secret they won’t tell you. AI Crypto Trading Secrets: What They Won’t Tell You About Profits and Pitfalls|9-Figure Media was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story
Share
Medium2025/09/18 23:20