You have 3 free guides left 😟
Unlock your guides
You have 3 free guides left 😟
Unlock your guides

Decentralized exchanges and automated market makers revolutionize token trading by eliminating intermediaries. These platforms use to execute trades directly on-chain, giving users full control of their funds and permissionless access to trading.

AMMs replace traditional order books with liquidity pools, allowing instant trades at any time. Users can tokens by interacting with these pools, while liquidity providers earn fees by supplying tokens. However, LPs face risks like when token prices diverge.

Decentralized Exchanges (DEXs) and Automated Market Makers (AMMs)

How DEXs and AMMs Enable Decentralized Token Trading

Top images from around the web for How DEXs and AMMs Enable Decentralized Token Trading
Top images from around the web for How DEXs and AMMs Enable Decentralized Token Trading
  • DEXs are non-custodial peer-to-peer token trading platforms that execute trades on-chain using smart contracts without a centralized intermediary
  • Users retain full control of their private keys and funds when trading on DEXs
  • DEXs offer permissionless access, allowing anyone to trade without needing to create an account or undergo KYC/AML checks
  • AMMs are a type of protocol that relies on liquidity pools rather than traditional order books to facilitate token swaps
  • AMM smart contracts automatically price assets and execute trades based on the ratio of tokens in liquidity pools

Comparing Traditional Order Books to Liquidity Pools

  • Centralized exchanges and some DEXs (IDEX, Loopring) use order books where buyers and sellers submit orders at their desired prices which are matched by the exchange
  • Order books require active market makers and sufficient trading volume to ensure liquidity
  • AMMs replace order books with liquidity pools that are pre-funded with two or more tokens, allowing trading at any time
  • Liquidity pools use a constant product market maker formula (x*y=k) to maintain the total value of assets in the pool and determine prices
  • As token ratios in the pool change after swaps, the relative prices adjust creating arbitrage opportunities that help rebalance the pool

Executing Token Swaps Using AMMs

  • Users can swap tokens by depositing one token into the AMM and withdrawing the equivalent value of the other
  • The AMM smart contract calculates the exchange rate based on the constant product formula and size of the trade relative to the pool
  • Larger trades relative to the pool size will result in more and a less favorable exchange rate for the user
  • Some AMM interfaces (, ) show the expected slippage and allow users to set a maximum slippage tolerance for their swap
  • Token swaps on AMMs are executed fully on-chain in a single transaction and settled immediately unlike trades

Liquidity Providers and Risks

Incentives for Liquidity Providers

  • AMMs rely on liquidity providers (LPs) to supply tokens to the liquidity pools that enable trading
  • Anyone can become a LP by depositing an equivalent value of two tokens into the pool and receiving LP tokens representing their share of the pool
  • LPs earn passive income from trading fees paid by users executing swaps in the pool (typically 0.3% on Uniswap and SushiSwap)
  • Certain liquidity pools also offer liquidity mining rewards in the form of additional tokens to incentivize LPs to provide liquidity
  • LP returns depend on the volume of trading in the pool and the relative price stability of the two assets

Slippage in AMM Trades

  • Slippage refers to the difference between the expected and actual price of a token swap due to the trade size relative to liquidity pool reserves
  • AMMs calculate token swap prices based on the constant product formula which changes the price as the ratio of tokens in the pool changes
  • Larger trades will "move the price" more resulting in the user receiving fewer tokens than expected based on the starting price
  • Slippage is higher in illiquid or unbalanced pools and can lead to failed transactions if it exceeds the user's maximum slippage tolerance
  • Some AMMs (Bancor) use elastic supply tokens or dynamic weights to reduce slippage

Impermanent Loss Risks for Liquidity Providers

  • Impermanent loss (IL) refers to the temporary loss of value when holding tokens in an AMM liquidity pool compared to simply holding them
  • IL occurs when the relative prices of tokens in the pool diverge from the price they were deposited at due to trading
  • If token prices change, the pool rebalances so the total value of the two assets is equivalent again, but the LP now has more of the lower value token and less of the higher value one
  • The more volatile or uncorrelated the assets, the greater the risk of IL for LPs (stablecoin pairs have minimal IL)
  • IL is only realized if the LP withdraws their tokens while relative prices are misaligned, hence it is considered impermanent
  • IL can be partially offset by trading fees earned but is a key risk for LPs to consider

Uniswap

  • Uniswap is the largest decentralized exchange by trading volume and helped popularize the AMM model
  • It is an open source protocol that allows anyone to create liquidity pools or execute token swaps
  • Uniswap uses the constant product market maker formula x*y=k to price trades based on the reserves in a liquidity pool
  • Version 2 added support for ERC20-ERC20 pairs and
  • Version 3 introduced concentrated liquidity positions and flexible fees to improve capital efficiency for LPs
  • Uniswap has a simple, intuitive interface for token swaps and a developer-friendly SDK and API
  • The UNI governance token was retroactively distributed to past protocol users and LPs

SushiSwap

  • SushiSwap is a community-driven fork of Uniswap that seeks to further decentralize control of the protocol and better reward participants
  • It started by forking Uniswap's open source smart contracts with added community governance and liquidity mining rewards
  • The SUSHI token governs protocol upgrades, fees, reward allocations and grants
  • Two thirds of trading fees go to LPs while one third goes to SUSHI stakers in the SushiBar
  • SushiSwap has expanded beyond AMM swaps to add an onchain order book exchange, lending market, and yield farming rewards
  • The project is managed by a decentralized collective of developers and operated by a DAO
  • SushiSwap has been innovative in optimizing gas costs, rewarding LPs, and creating a community-owned DeFi ecosystem
© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.

© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.
Glossary
Glossary