• Decentralized exchange which is used to swap cryptos, remember we cannot swap from one blockchain to another. Like we cannot swap from Solana to Eth but we can swap Solana to tether as it is built on solana
  • The wallets tie up with exchanges which act like DEX. For Example, phantom uses Radium (and many other) as DEX. If we directly swap from DEX then it won’t charge us anything. If we swap from wallet it cuts some amount as fee.
  • These wallets use Some called as DEX aggregators which picks the right DEX for the swap for example, Jupiter which select which DEX gives best price for the corresponding transaction Note: The wallets like phantom automatically change the Exchanges depending on the best price possible

DEX vs CEX

DEX

  1. You have the private key of your wallet
  2. No one can censor you/take your assets (not true for centralized tokens like USDC)
  3. You have to do private key management yourself

DEX Jargons

  1. Markets: There are the trading pair markets. for example, SOL-USDC here in this market we can swap SOL and USDC, this will be created by individual or a company having big amounts of SOL and USDC, and this time it undergoes Constant Product Algorithm and this is the place we can even make money as the pool amount is different from actual amount, Now the person created the pool also get paid some amount as fees
  2. Swap: swapping tokens in market that’s it
  3. Quote: Estimated amount you’ll receive in a swap (not exactly just estimated as slippage is present)
  4. Slippage: Difference between quoted and actual price (price will change due to market speculations)
  5. Slippage Tolerance: Maximum acceptable price difference
    Example: Setting 1.5% tolerance means:
    • Won’t execute if price moves more than 1.5%
    • Protects from unexpected price changes
    • Transaction reverts if exceeded

CEX

  1. You delegate your assets to a central entity
  2. You don’t have to do private key management
  3. Govt can censor you, you have to KYC
  4. Exchange can get hacked

CEX Jargons

  1. Orderbooks: A real-time list showing all pending buy and sell orders for AAPL stock at different prices
  2. Bids: The price buyers are willing to pay (e.g., someone bids $175.50 to buy AAPL shares)
  3. Asks: The price sellers are willing to accept (e.g., someone asks $175.55 to sell AAPL shares)
  4. Spread: The difference between the highest bid and lowest ask (in this case, 175.50 = $0.05)
  5. Liquidity: How easily AAPL shares can be bought or sold without causing a significant price change
  6. Market Makers: Professional traders who provide liquidity by always being ready to buy or sell AAPL shares

Q How do market makers make money ?
A These market makers are big cooperation’s having brightest minds (codes and traders) making traders for the company. The Bid-Ask Spread This is their main source of profit. Using our previous AAPL example:

  • They buy at $175.50 (bid price)
  • They sell at $175.55 (ask price)
  • They pocket the 0.05 seems small, when trading millions of shares daily, it adds up significantly.
    Besides Exchanges also pay some amount for market makers
    The market makers place Bids and also make asks, as their primary goal is to make the market liquid

Constant Product Algorithm

when people give the DEX their funds via smart contract then the prices that will be shown in the order book are determined by Constant Product Algorithm
The formula is: x × y= k
Where: x is the reserve of Token A.
y is the reserve of Token B.
k is a constant, meaning it does not change as trades are executed

Example:

Let’s start with a pool containing:

  • x = 10 ETH
  • y = 20,000 USDC
  • k = 10 × 20,000 = 200,000

Example 1: Small Trade (1 ETH)

  • Someone wants to buy 1 ETH with USDC
  • New ETH amount (x): 9 ETH
  • New USDC amount (y): 200,000/9 = 22,222 USDC
  • USDC needed: 22,222 - 20,000 = 2,222 USDC
  • Price per ETH: 2,222 USDC

Example 2: Tiny Trade (0.5 ETH)

  • Someone wants to buy 0.5 ETH
  • New ETH amount: 9.5 ETH
  • New USDC amount: 200,000/9.5 = 21,053 USDC
  • USDC needed: 21,053 - 20,000 = 1,053 USDC
  • Price per ETH: 2,106 USDC

This shows:

  1. Smaller trades = less price impact
  2. Pool stays balanced automatically
  3. Each trade moves the price
  4. The product (k) always stays at 200,000

This is why DeFi traders often split large trades into smaller ones to minimize slippage.

Q how the constant k is decided ?
A The constant k is determined by the initial deposit of tokens when creating or adding to a liquidity pool

  1. Initial Deposit Example:
  • A user deposits 10 ETH and 20,000 USDC
  • k = 10 × 20,000 = 200,000
  • This k becomes the constant
  1. Price Check:
  • If current market price of ETH is 2,000 USDC
  • Initial deposit must match this ratio
  • Otherwise, arbitrageurs will quickly exploit the difference
  1. Adding Liquidity:
  • Must add both tokens in the correct ratio
  • Example: To add 20% more liquidity
    • Add 2 ETH and 4,000 USDC
    • New k = 12 × 24,000 = 288,000

The key is: k only changes when liquidity is added or removed, not during trades.
Most AMMs like Uniswap also require initial deposits to be made at the current market price to ensure the pool starts at a fair price.

Automated Market Makers

Automated Market Making (AMM) is exactly what we saw in the ETH/USDC example.
Automated Market Making (AMM) simply means:

  1. No human needed to set prices
  2. Math formula (x × y = k) automatically:
    • Determines prices
    • Adjusts after each trade
    • Ensures liquidity

Example: ETH/USDC pool

  • Start: 10 ETH, 20,000 USDC
  • Buy 1 ETH → Pool auto-adjusts to 9 ETH, 22,222 USDC
  • Price changes from 2,000 to 2,469 USDC/ETH automatically

That’s it - just pools of tokens and math, no traditional order books or market makers needed.
The automated marked makers are only present in DEX, btw in CEX there will be market makers but they are not automated, as same as in share market they run algorithms deciding the asks and bids

Impermanent Loss

Impermanent loss is a decentralized finance (DeFi) phenomenon that occurs when an automated market maker’s (AMMs) algorithmically driven token rebalancing formula creates a divergence between the price of an asset within a liquidity pool and the price of that asset outside of the liquidity pool.
For Context AMM will create liquidity pool (let us say SOL - USDT) in some DEX or CEX and fix a price, if that price is large with respect to the actual market price outside the liquidity pool then the person created the pool will lose some money in some initial time this is called Impermanent loss
Basically Liquidity pools are equivalent to FD’s in web2 world, like you pledge some money and it will increase if the currency value(INR for say) is stable and will go in loss if the inflation increased or if the currency value falls.
Liquidity pool is only profitable only if the crypto value is not fluctuating too much, both more and less, Thus most profitable (ideally) and secure liquidity pool will be of USDC - USDT
We can see the prices of an Crypto across all liquidity pools in coin market cap
know more: Blog by Gemini on DeFi Impermanent Loss

Liquidity Staked Tokens
  • Rather than directly staking SOL or ETH in an liquidity pool, there are some equivalent specially made Liquidity staked tokens, for example the Liquidity staked token for SOL is mSOL and same for ETH is LidoSETH
  • And why we need to stake these, rather staking SOL or ETH directly ??.
    • They are made for staking
    • When you directly stake SOL or ETH, your assets are locked and illiquid during the staking period. LSTs represent your staked position while remaining transferable and usable in DeFi.
    • Means assume SOL as a Home which is non-liquid asset means if you want to trade your home you need to sell it get money and then you can get some outcome out of it or even if you rent it you will get money at the end of the month to use, but but if you give it to a bank as a collateral and get Money(mSOL - Liquidity staked tokens) now you can use that money without selling the house
    • And the value of Liquid staking token will increase in the rate of consistent yield overtime
    • And for suppose i bought a car with mSOL then the car company can redeem the money by removing equivalent SOL with respect to that mSOL

DLLM’s and CLLM’s

Dynamic Liquidity Market Makers (DLLMs) are an evolution of traditional Automated Market Makers (AMMs) in DeFi

  • Traditional AMMs like Uniswap v2 use a constant product formula (x * y=k) and maintain liquidity across the entire price range
  • DLLMs dynamically adjust liquidity concentrations based on market conditions and trading activity

Key features of DLLMs:

  • Adaptive liquidity provision that shifts based on trading patterns
  • More efficient capital utilization compared to traditional AMMs
  • Active management of liquidity ranges to optimize trading fees
  • Reduced impermanent loss risk through dynamic position adjustment

Concentrated Liquidity Market Makers (CLLMs) are a related concept:

  • Allow liquidity providers to focus their capital within specific price ranges
  • Most notably implemented in Uniswap v3
  • Higher capital efficiency since liquidity isn’t spread across unused price ranges
  • More complex for liquidity providers but potentially more profitable

The main difference between DLLMs and CLLMs:

  • CLLMs require manual setting of price ranges by liquidity providers
  • DLLMs automatically adjust liquidity positions based on algorithms and market conditions
    Know more: Blog by innocentnweke on How to use DLLM