What is a DEX?
A decentralized exchange (DEX) is a peer-to-peer crypto trading platform that lets you exchange digital assets through smart contracts without handing custody of your funds to a centralized exchange operator. You connect a compatible wallet, authorize transactions, and interact with blockchain protocols that manage swaps, liquidity, and settlement according to their programmed rules.
That definition sounds straightforward, but the technology behind a DEX can vary considerably. Some platforms rely on automated market makers (AMMs), where liquidity pools determine prices through mathematical formulas. Others use order books to match buyers and sellers, while aggregators search across multiple venues to find a competitive route for your trade.
If you have used a centralized exchange such as Binance or Coinbase, the most noticeable difference is what happens to your assets before you trade. On a traditional custodial exchange, you typically deposit funds into an account controlled by the platform. On a non-custodial DEX, you generally keep your tokens in your own wallet and authorize specific on-chain actions when you want to trade.
I think that distinction is the best place to start because it explains both the appeal and the responsibility of decentralized trading. You have greater direct control over your funds, but you also take on more of the work involved in protecting your wallet, reviewing transactions, and choosing reliable protocols.
How a DEX works in practice
Imagine you hold ETH and want to exchange some of it for USDC. Rather than transferring your ETH to a centralized exchange, you connect a Web3 wallet to a DEX interface and enter the amount you want to swap.
A typical transaction follows this process:
- Connect your wallet. You connect a wallet such as MetaMask, Rabby, or Phantom. Connecting a wallet does not, by itself, transfer ownership of your assets to the website.
- Choose the trading pair. You select the token you want to sell and the token you want to receive.
- Review the quote. The interface displays an estimated output, applicable fees, and other execution details. The final amount can differ if market conditions change before execution.
- Authorize the transaction. Depending on the token and protocol, you may need to approve a smart contract to spend a token before submitting the swap. You then sign the required transaction or authorization.
- Wait for execution and settlement. The blockchain processes the transaction, and your wallet reflects the resulting balances once the transaction is confirmed and indexed.
Not every DEX follows exactly the same flow. An AMM may execute your swap against a liquidity pool, while an order-book venue may match your order with another trader. An intent-based protocol may let you sign an instruction that a third-party solver later fulfills.
The shared idea is that the trade is governed by blockchain infrastructure and protocol rules rather than a single exchange’s private account ledger.
What makes a DEX decentralized?

The word decentralized deserves a closer look. A protocol can use smart contracts for settlement and still depend on a team, a particular interface, privileged administrators, or a limited group of validators and market makers.
I would look at several separate dimensions instead of treating decentralization as a simple yes-or-no label:
- Custody: Do you retain control of the wallet and private keys, or does an operator control the assets?
- Execution: Are swaps settled by public smart contracts, or does a centralized operator maintain the authoritative trading ledger?
- Administration: Can a team upgrade contracts, pause trading, change fees, or modify important protocol parameters?
- Access: Can users interact directly with the contracts, or must they go through an approved account or service?
- Infrastructure: Does the platform rely on centralized servers, APIs, or order-matching services that could become unavailable?
These distinctions matter because a DEX interface can go offline even when its smart contracts remain operational. Equally, a protocol may offer non-custodial swaps while still giving administrators considerable power over how the system operates.
If you are evaluating a platform, read its documentation and inspect its permission model where possible. A familiar interface is useful, but it tells you very little about who can change the underlying contracts or what happens if a critical component fails.
DEX vs CEX
A centralized exchange (CEX) and a decentralized exchange can both help you trade crypto, but they handle ownership, execution, and risk differently. Neither model is automatically safer or cheaper in every situation. Your experience depends on the specific platform, the assets you trade, the network you use, and how carefully you manage your funds.
Self-sovereignty and custody models
On a custodial exchange, your account balance usually represents a claim against the exchange’s internal ledger. You log in, place an order, and the platform updates its records when the trade executes. The exchange controls the wallets holding the underlying assets and processes withdrawals according to its own systems and policies.
This setup can be convenient. A centralized exchange may offer a familiar interface, customer support, account recovery, deep liquidity, and advanced order types without requiring you to manage every blockchain transaction yourself. But you also depend on the operator to safeguard assets and honor withdrawals.
With a non-custodial DEX, you generally retain control of your wallet’s private keys. Your swap is authorized through a wallet signature or transaction, and the protocol executes it under its smart contract rules. Ethereum‘s documentation explains how smart contract interactions are submitted and processed as blockchain transactions, which is why a DEX trade can incur crypto gas fees rather than simply updating a private account balance (Ethereum transaction documentation).
The trade-off is simple: you reduce reliance on a custodial intermediary, but you take on more personal responsibility.
If you lose your seed phrase, approve a malicious contract, or send assets to the wrong address, there may be no customer service team able to reverse the mistake. A non-custodial wallet does not automatically protect you from phishing, compromised devices, or unsafe smart contracts.
| Feature | Centralized exchange (CEX) | Decentralized exchange (DEX)
|
|---|---|---|
| Asset custody | Exchange typically controls the deposited assets and private keys | User generally retains control through a self-custody wallet |
| Trade execution | Often matched through an internal order book and ledger | Executed through AMMs, on-chain order books, or other protocol designs |
| Settlement | Internal trades may settle on the exchange’s ledger; withdrawals use blockchains | Usually settled through blockchain transactions or protocol-specific execution |
| Access | Account creation and identity checks may be required | Often accessible through a compatible wallet, subject to protocol and local restrictions |
| Transaction costs | Trading fees and withdrawal fees may apply | Network gas, swap fees, and possible routing costs may apply |
| Main risks | Custodian failure, insolvency, account restrictions, hacks | Contract vulnerabilities, wallet compromise, MEV, liquidity risk |
| Customer support | Often available for account and platform issues | Usually limited; on-chain transactions are generally irreversible |
| Order features | Often includes limit orders, stop orders, and derivatives | Varies by protocol; some DEXs support sophisticated order types |
KYC-free access vs regulatory compliance
Many DEX interfaces let you connect a wallet and trade without completing the same account-opening process commonly found on centralized exchanges. That can lower the barrier to entry for users who want direct access to on-chain markets.
However, “permissionless” does not mean “legal everywhere” or “free from restrictions.” Regulatory requirements depend on your jurisdiction, the type of service, the assets involved, and whether an operator or intermediary is participating. Some interfaces, front ends, or protocols may apply geographic restrictions or other compliance measures.
The distinction is especially important for leveraged trading. On October 5, 2026, Reuters reported that the US Commodity Futures Trading Commission had proposed a framework for federal oversight of certain cryptocurrency trading platforms offering leveraged or margined trades. The proposal is a regulatory development, not proof that every DEX is subject to the same requirements; you can read the Reuters report on the proposed framework.
From a user’s perspective, I would separate three questions:
- Can I access the protocol? This depends on the blockchain, interface, wallet, and any technical or geographic restrictions.
- Can I legally use the service where I live? This depends on applicable local law and the product being offered.
- Is the trade safe? This depends on contract security, liquidity, token legitimacy, execution quality, and your own transaction settings.
Those questions are related, but they are not interchangeable. A wallet connection is not a legal approval, and a protocol being available online is not evidence that it is safe.
How automated market makers (AMMs) work
Automated market makers are among the best-known mechanisms for decentralized spot trading. Instead of requiring a buyer and seller to submit matching orders, an AMM lets traders swap against a pool of tokens according to a mathematical pricing rule encoded in smart contracts.
That change is more significant than it might first appear. A traditional order book depends on bids and asks from individual market participants. An AMM can quote a trade using the pool’s existing reserves, provided there is enough liquidity to complete the swap. Liquidity providers supply the assets that make those trades possible and receive a share of applicable fees under the pool’s rules.
A classic constant-product AMM, such as the design used in Uniswap UNI v2, follows this invariant:
x · y = k
Here, $x$ and $y$ represent the pool’s token reserves, while $k$ represents their product. The formula helps explain why a trade’s size relative to pool depth affects its execution price. Uniswap’s official explanation of how swaps work describes this relationship and how larger trades cause greater price impact.
The constant product formula mechanics
Let’s use a simplified pool containing ETH and USDC. Suppose the pool starts with:
- 100 ETH
- 200,000 USDC
Ignoring fees for the moment, the constant product is:
k = 100 × 200,000 = 20,000,000
The pool’s initial reserve ratio is 2,000 USDC per ETH. That ratio gives us a useful reference price, but it does not mean every trade will execute at exactly 2,000 USDC per ETH.
Suppose you put 10 ETH into the pool to receive USDC. The pool now has 110 ETH. To preserve the constant product in this simplified model, the USDC reserve after the swap must satisfy:
110 × ynew = 20,000,000
Therefore:
ynew = 20,000,000⁄110 ≈ 181,818.18
The pool started with 200,000 USDC and ends with approximately 181,818.18 USDC, meaning the trader receives around 18,181.82 USDC before fees.
Notice what happened: at the initial reference price of 2,000 USDC per ETH, 10 ETH would appear to be worth 20,000 USDC. But the pool actually returns less because your trade changes the reserve ratio as it executes.
That difference is the core of AMM price impact. You are trading against the liquidity available across a curve, not buying every unit at the initial spot price.
The simplified calculation excludes swap fees, token transfer behavior, rounding, and implementation-specific rules. Real pools calculate the output using the exact contract logic, so treat the example as a way to understand the mathematics rather than a live quote.
Why the price moves after a swap
For a constant-product pool, the reserve ratio changes whenever someone swaps one token for the other. If traders buy ETH from the pool, the pool holds less ETH and more USDC. ETH becomes more expensive relative to USDC within that pool. If traders sell ETH into the pool, the opposite happens.
This mechanism creates several practical effects:
- Small trades generally have less price impact. They consume a smaller share of the available liquidity.
- Large trades can move the price sharply. The pool must adjust its reserve ratio to supply the requested output.
- Deeper liquidity usually improves execution. For the same trade size, a deeper pool generally experiences less price impact.
- Fees reduce the amount received. The pool’s fee rules may deduct a portion of the input or otherwise adjust the swap calculation.
The AMM’s quoted price can also differ from the price on another DEX or centralized exchange. Arbitrage traders often buy the cheaper asset in one venue and sell it in another, helping bring prices closer together. This process can improve consistency between markets, but it does not eliminate price differences, and arbitrage activity can change the token balances held by liquidity providers.
One point worth remembering: the constant product invariant is a pricing mechanism, not a guarantee that the pool’s total dollar value remains constant. Token prices can change dramatically, and the dollar value of the assets you hold in a liquidity position can rise or fall.
Calculating price impact and slippage
People often use price impact and slippage as if they mean the same thing. They are related, but the distinction is useful if you want to compare quotes and troubleshoot poor execution.
Price impact is the difference between the market price before your trade and the effective price implied by the trade itself. In an AMM, it mainly reflects how your order changes the pool’s reserve ratio.
A simplified expression is:
Priceimpact = 1 – Actualoutputreceived⁄Expectedoutputatspotprice
If the spot price suggests that your trade should return 10,000 USDC but the AMM quote returns 9,700 USDC, the simplified price-impact calculation is:
1 – 9,700⁄10,000 = 0.03 = 3%
In this example, the quoted output is 3% below the reference amount. In practice, be careful about which reference price you use and whether fees are included, because interfaces and analytics tools may calculate or display price impact differently.
Slippage, by contrast, describes the difference between an expected execution and the actual execution. It can arise because the market changes between quote and settlement, because other transactions are processed first, or because liquidity conditions shift before your transaction executes. Some interfaces also use slippage tolerance to mean the maximum adverse movement the trader is willing to accept before the swap reverts.
For example, imagine a DEX quotes 1 ETH for 2,000 USDC. While your transaction is pending, other trades change the pool price. Your swap may execute at a worse price if it remains within your allowed tolerance. If the execution would violate your minimum-output setting, the transaction may fail instead.
This is why setting an extremely high slippage tolerance is not a universal solution. It may make a trade more likely to execute under volatile conditions, but it can also expose you to a worse execution price and certain forms of transaction exploitation. A very low tolerance can protect your minimum output but lead to failed swaps when the market moves quickly.
For a better trading routine, I would compare the expected output, the minimum output, the pool’s liquidity, and the estimated gas cost before signing. If a quote looks unusually poor, try a smaller trade, compare routes, or wait for conditions to improve instead of simply raising the tolerance.
Concentrated liquidity: Uniswap v3 and newer AMM designs
Traditional constant-product pools spread liquidity across the full theoretical price range from zero to infinity. That approach is simple and allows swaps across a wide range of prices, but much of the capital can sit outside the range where a pair normally trades.
Concentrated liquidity changes the arrangement. Instead of spreading capital across the entire curve, a liquidity provider chooses a lower and upper price boundary. Within that range, the position can provide more liquidity per dollar of capital than a comparable full-range position.
Uniswap introduced this model in v3 and continues to support it in v4. Its concentrated liquidity documentation explains how providers select price ranges and how liquidity becomes inactive when the market moves outside them.
Imagine ETH trades around 2,000 USDC. A full-range position supplies liquidity across the entire price curve. A concentrated position might instead cover the range from 1,800 to 2,200 USDC per ETH. If the market stays within that band, the provider’s capital can be used more intensively around the prevailing price.
That can improve capital efficiency, but there is a catch: the provider must actively manage the position’s range.
If ETH rises above 2,200 USDC, the position can become entirely composed of the other token and stop earning swap fees until the price returns to the selected range or the provider adjusts the position. If ETH falls below 1,800 USDC, the position can similarly end up concentrated in ETH. The exact token composition depends on the position’s range and the direction of the price movement.
| Feature | Full-range liquidity | Concentrated liquidity
|
|---|---|---|
| Capital distribution | Spread across the full price curve | Focused within a chosen price interval |
| Capital efficiency | Lower around a typical trading price | Potentially higher within the active range |
| Fee opportunities | Can remain active across a wider range of prices | Earns fees while the position is active and in range |
| Management | Often simpler | Requires range selection and monitoring |
| Main trade-off | Capital may be underused at typical prices | Price movement can leave the position inactive or heavily weighted toward one asset |
Concentrated liquidity is not a free yield upgrade. A narrower range may produce more fees per unit of capital while the market stays inside it, but it also makes the position more sensitive to price movements. Your outcome depends on trading volume, fee competition, the path taken by the market, and how much time your liquidity stays active.
I would think of concentrated liquidity as a more hands-on market-making strategy rather than a set-and-forget deposit. If you do not have a plan for rebalancing, fees, and adverse price moves, the extra capital efficiency may not compensate for the added management risk.
The economics of supplying liquidity

Liquidity providers (LPs) make decentralized trading possible by depositing assets into pools or creating liquidity positions. In return, they may receive a share of swap fees and, on some protocols, token incentives.

At first glance, this looks like a straightforward way to earn yield on crypto you already own. The important detail is that supplying liquidity changes how you hold those assets. You are allowing traders to exchange one token for another against your position, and the pool adjusts your token exposure as prices move.
Your return therefore depends on more than the fee rate advertised on a dashboard. You need to consider trading volume, your share of active liquidity, token price movements, incentive emissions, transaction costs, and the risk that a smart contract or one of the pool’s assets fails.
What is impermanent loss?
Impermanent loss (IL) describes the difference in value between holding your original assets and supplying them as liquidity, assuming the same external token prices at the point of comparison. It is a relative loss compared with simply holding the assets, not necessarily a loss in absolute dollar value.
Uniswap’s guide to impermanent loss explains how changes in token prices alter the composition of a liquidity position. The effect is especially relevant to pools where arbitrage and swaps continuously adjust token reserves.
Consider a simplified pool where you deposit equal dollar values of ETH and USDC. If ETH rises substantially, traders tend to buy ETH from the pool, leaving the pool with less ETH and more USDC. Your liquidity position may therefore end up holding less of the asset that appreciated and more of the asset that did not rise as much.
You could still finish with more dollars than you started with. The issue is that you might have earned less than if you had simply held the original ETH and USDC outside the pool.
For a standard, fee-free constant-product position with two assets, the impermanent-loss formula relative to holding is:
IL = 2√Pr⁄1 + Pr – 1
Here, Pr is the ratio of the token’s new price to its initial price. The formula assumes a conventional constant-product position and a single relative price change; concentrated liquidity and other AMM designs can produce different results.
Let’s put some numbers around it. If the relative price of one token doubles, then Pr = 2:
IL = 2√2⁄3 – 1 ≈ -5.72%
That means the liquidity position is worth approximately 5.72% less than the hold-only portfolio under these simplified assumptions, before accounting for fees, incentives, gas, or other costs.
The same relative effect can occur when the price halves. The formula measures divergence in the relative price ratio, not whether the asset went up or down in isolation.
The following examples use the standard constant-product formula:
| Relative price change | Approximate impermanent loss vs. holding
|
|---|---|
| 1.25× | -0.62% |
| 1.5× | -2.02% |
| 2× | -5.72% |
| 3× | -13.40% |
| 4× | -20.00% |
These figures are illustrative, not forecasts. They do not say that your position will necessarily lose money in dollar terms. They show how the pool position compares with holding the same initial assets when the relative price changes.
The term impermanent can also be misleading if you interpret it as “temporary, so I can ignore it.” The relative loss can shrink if the price ratio returns to its starting point, but there is no guarantee it will. If you withdraw while the prices have diverged, that difference becomes part of your realized outcome. Trading fees may offset some or all of the difference, but they are not guaranteed to do so.
Evaluating real yield vs. token inflation emissions
When you compare liquidity pools, you may see annual percentage yield (APY) figures that look far more attractive than ordinary lending or staking rates. Before committing funds, ask where that yield comes from.
There are two broad sources of return:
- Trading-fee revenue: Traders pay fees when they swap through the pool. Liquidity providers may receive a share of those fees according to the protocol’s rules and their share of active liquidity.
- Token incentives: A protocol or third party distributes tokens to encourage users to supply liquidity. Those rewards can attract deposits, but their market value can fall, and the emissions may stop or change.
Trading fees are linked to actual usage, though a high volume of trades does not automatically mean high net returns for every LP. The provider’s share depends on the pool’s fee structure, how much liquidity competes for fees, and-in concentrated-liquidity systems-whether the position remains active.
For context, Uniswap v2 charges a 0.30% swap fee under its standard model, while Uniswap v3 offers different fee tiers, including 0.05%, 0.30%, and 1% pools. Fee structures differ by version and may change through protocol governance; consult the current Uniswap fee documentation rather than assuming every pool uses the same rate.
A pool displaying 40% APY is not necessarily better than one displaying 8%. The first might be paying out a volatile incentive token, while the second may generate more of its return from sustained trading activity. Neither headline rate tells you how much impermanent loss you could experience or whether you can exit without substantial costs.
A more useful way to evaluate a liquidity position is to estimate:
$Netreturn = Tradingfees + Incentivevalue – Impermanentloss – Transactioncosts – Otherlosses$
This is a decision framework, not a universal accounting identity. Your actual return also reflects token price movements, the amount of time capital is deployed, changes in pool composition, and any contract or protocol failure.
Before depositing, I would check:
- Trading volume over time: Is activity consistent, or did a short-lived spike inflate the latest yield?
- Total liquidity: A small pool can produce impressive fee percentages while remaining vulnerable to large trades and volatile withdrawals.
- Fee competition: Other providers can enter the pool, reducing your share of fee revenue.
- Incentive sustainability: Who funds the rewards, how long do they last, and what happens when emissions end?
- Token quality: A high nominal yield is of little comfort if one token loses its peg or collapses in price.
- Exit costs and risks: Consider gas fees, slippage, the position’s active range, and any withdrawal restrictions.
There is no yield figure that makes these checks unnecessary. Liquidity provision is a market-making activity with real risks, not a guaranteed-interest account.
DEX architecture types
“DEX” is an umbrella term rather than one specific trading design. Two platforms may both call themselves decentralized exchanges while using very different systems to quote prices, match orders, route trades, and manage risk.
Knowing the architecture helps you choose the right venue. If you are swapping a small amount of a major token, an AMM may be all you need. If you trade actively, care about execution quality, or use derivatives, you may prefer an order-book platform, an aggregator, or a specialized perpetuals exchange.
Automated market makers: Uniswap, Curve, and Raydium
AMMs use pools and pricing rules to let traders exchange assets without requiring a traditional order book. Liquidity providers supply the tokens, and the protocol calculates the output based on its design.
Different AMMs are built for different markets:
- Constant-product AMMs: These use the familiar $x\cdot y=k$ relationship. They are flexible and can support volatile token pairs, but large swaps can have substantial price impact when pool depth is limited.
- Stable-swap AMMs: These are built to trade assets expected to maintain similar values, such as certain stablecoin pairs or wrapped versions of the same asset. Their pricing curves aim to reduce price impact near the expected peg, although depegging and liquidity risks remain.
- Concentrated-liquidity AMMs: These let providers choose price ranges, focusing liquidity where they expect trading to occur. They can improve capital efficiency but require more active management.
Uniswap is a widely known example of an AMM design on EVM-compatible networks. Curve focuses on efficient trading between assets that are expected to have similar values. Raydium is part of the Solana DeFi ecosystem and supports pool-based trading.
The names alone do not tell you which pool is best. A token pair may have several pools with different liquidity levels, fee settings, and risks. Always compare the actual market and the contract you are about to use.
On-chain and hybrid order books: Hyperliquid, Phoenix, and dYdX
An order book organizes buy and sell orders by price. Traders submit bids and asks, and a matching engine pairs compatible orders. A central limit order book (CLOB) generally gives active traders more familiar control over limit prices and order placement than a basic pool swap.
Building this kind of trading system on blockchain infrastructure is challenging. An order book can generate frequent updates, cancellations, and matching operations, so the underlying network needs to handle the workload efficiently. Some platforms use specialized chains or architectures to support the required throughput and execution experience.
dYdX provides a useful example of a specialized architecture: its official documentation describes dYdX Chain as open-source blockchain software for a decentralized perpetuals exchange, with the order book and matching engine included in its architecture (dYdX Chain documentation).
Hyperliquid is another order-book-oriented trading platform, particularly known for perpetual markets. Phoenix provides an on-chain order-book model on Solana.
The benefits and trade-offs depend on the implementation. Order books can provide familiar trading controls, but users still need to evaluate custody assumptions, validator and sequencer dependencies, network performance, liquidation mechanics, and how the platform handles outages or upgrades.
If you trade frequently, I would compare more than the quoted spread. Look at order-book depth near the price you want, expected fees, cancellation behavior, latency, and what happens if the system becomes congested. A narrow spread is useful, but it does not guarantee that a large order will execute at the displayed price.
DEX aggregators: 1inch, Jupiter, and ParaSwap
A DEX aggregator searches across multiple liquidity sources and routes a trade through one or more of them. Instead of making you compare every pool manually, it attempts to identify a competitive route for the tokens and amount you specify.
Suppose you want to swap a large amount of Token A for Token C. One pool might offer a good rate for A to B, while another offers a better rate for B to C. An aggregator can evaluate a multi-hop route through B, compare it with direct pools, and estimate which option produces the best output after applicable costs.
Some aggregators can also split a trade across several pools. For example, part of your order may go through one venue and the rest through another, potentially reducing price impact compared with sending the entire trade through a single shallow pool.
Examples include:
- 1inch for routing swaps across supported liquidity sources.
- Jupiter for routing and trading tools in the Solana ecosystem.
- ParaSwap for aggregating liquidity and swap execution across supported networks.
An aggregator does not create liquidity out of thin air. Its result is only as good as the routes, pools, and execution mechanisms available to it. A route with a better quoted output might also involve more complex execution, higher gas costs, or a greater chance of failing before settlement.
When comparing aggregators, focus on net output, not just the displayed token price. Check whether the quote includes network fees, protocol fees, and any additional charges. Also verify that you are using the official interface and that the token addresses are correct; an aggregator’s popularity does not make every token listed through it legitimate.
Perpetual and derivatives DEXs: GMX, Hyperliquid, and Drift
Spot trading exchanges one asset for another. Derivatives platforms let traders take positions based on an asset’s price without necessarily buying and holding the underlying token.
Perpetual futures are a common example. They have no fixed expiry date and typically use a funding mechanism to help keep the contract price aligned with the underlying market. Traders can use margin to gain leveraged exposure, which magnifies both potential gains and losses.
Some derivatives DEXs use order books, while others rely on liquidity pools or synthetic pricing mechanisms. A virtual AMM (vAMM), for example, can use a mathematical curve to determine trade prices without functioning exactly like a traditional pool containing all the tokens represented by that curve. The actual collateral and risk-management architecture depends on the protocol.
Examples include GMX and Drift, alongside order-book-based venues such as Hyperliquid.
These platforms need additional safeguards because leveraged positions can be liquidated when collateral falls below the required level. You should understand:
- Margin requirements: How much collateral is needed to open and maintain a position.
- Liquidation rules: What triggers liquidation and how the system closes positions.
- Funding payments: Whether you pay or receive funding, and how frequently it is charged.
- Oracle and mark prices: How the platform determines a position’s value and liquidation threshold.
- Liquidity and insurance mechanisms: How the platform handles rapid price moves, liquidations, and losses that exceed a trader’s collateral.
A DEX may give you non-custodial access to a derivatives protocol, but that does not make leveraged trading low-risk. You can lose your collateral quickly, particularly during volatile market conditions or when liquidity becomes thin.
MEV sandwich attacks and intent-based swaps

Smart contracts can make trading more transparent and programmable, but they also create new ways for transactions to be observed, ordered, and exploited. One important example is maximal extractable value (MEV), which refers broadly to value that block producers or other transaction-ordering participants can capture by including, excluding, or ordering transactions in particular ways.
MEV is not always malicious. Arbitrage can help align prices across markets, and liquidations can keep lending systems solvent. The concern is that some strategies extract value from ordinary traders through unfavorable execution.
How MEV bots execute sandwich attacks
A sandwich attack targets a pending trade. An attacker sees a transaction that is likely to move a pool’s price, places a transaction before it to move the price in an advantageous direction, and then places another transaction after the victim’s trade to profit from the resulting price movement.
The attack is often explained in three steps:
- Front-running: The attacker buys the asset before the victim’s swap, pushing the pool price in a direction that makes the victim’s trade more expensive.
- Victim transaction: The user’s swap executes at a worse price than it would have received without the attack, provided the transaction remains within its slippage tolerance.
- Back-running: The attacker sells into the price movement created by the combined transactions, attempting to capture the difference after accounting for fees and execution costs.
This kind of attack is especially relevant to public transaction flows where pending swaps can be observed before they are included in a block. Ethereum’s transaction documentation describes how submitted transactions are broadcast and enter a transaction pool before a validator includes them in a block. Actual visibility and ordering depend on the network, transaction submission method, and infrastructure involved.
Let’s say a user intends to swap a token for 10,000 USDC and allows a relatively wide slippage tolerance. A bot may be able to move the pool price before the swap, let the victim trade at the worse price, and then unwind its position afterward. Whether a specific attack is profitable depends on pool depth, the trade size, transaction fees, ordering competition, and the victim’s minimum-output setting.
A high slippage tolerance does not cause every swap to be attacked, but it can give an attacker more room to manipulate execution without causing the transaction to revert. This is why I would avoid setting tolerance far above what the market conditions require.
Practical ways to reduce exposure include:
- Use a sensible slippage tolerance. Choose a level that reflects the asset’s volatility and liquidity rather than raising it automatically whenever a trade fails.
- Compare routes and split large trades where appropriate. A smaller price impact can reduce the incentive for certain attacks, although splitting a trade may also increase gas costs.
- Use reputable protected execution options. Private transaction submission or specialized swap mechanisms may reduce public-mempool exposure, but their protections depend on the provider and design.
- Check the minimum output. Make sure the transaction’s limit is consistent with the price you are willing to accept.
- Avoid rushed trades in thin pools. Low liquidity and volatile token prices can make execution both expensive and vulnerable to manipulation.
No single setting eliminates all MEV risk. Even a protected route may face other execution risks, and a transaction can still fail because of changing market conditions or insufficient liquidity.
Intent-based architecture: UniswapX, CoW Protocol, and 1inch Fusion
Traditional DEX swaps often ask the user to submit a transaction that directly calls a pool or router contract. Intent-based systems change how the trade is expressed and fulfilled.
Instead of specifying every on-chain step, the trader signs an instruction describing the desired outcome-for example, selling a certain amount of one token while receiving at least a specified amount of another. Third-party participants, often called solvers, fillers, or resolvers, compete or otherwise work to execute the order under the protocol’s rules.
This design can improve execution in several ways. A solver may combine liquidity from different sources, use its own inventory, or choose a route that would be inconvenient for the user to construct manually. Some systems also let the solver pay the on-chain gas costs, so the user does not need to hold the network’s native token specifically to pay for that swap. The cost is not necessarily eliminated; it may be incorporated into the solver’s economics or the resulting price.
UniswapX is an example of an auction-based swapping protocol. Its documentation describes signed orders that specify the swap’s desired output and allow fillers to compete to execute them across supported liquidity sources. It also lists gas-free swapping, protection against MEV, and no cost for failed swaps among its supported features (UniswapX overview).
1inch Fusion uses a related model in which resolvers compete to fill orders and pay associated gas costs under the protocol’s design. Its official Fusion explanation describes how the system handles order execution and its approach to front-running protection.
CoW Protocol is another example of intent-based trading, using solver competition to find execution paths that satisfy user orders. It also supports batch auctions, where compatible trades can be matched with one another before remaining liquidity is sourced externally. You can learn more from the CoW Protocol documentation.
These systems can offer better execution, but it is important to understand what the terms mean in practice:
- Intent: The user’s signed instruction, including the desired trade outcome and relevant constraints.
- Solver or filler: A participant that competes to fulfill the order under the protocol’s rules.
- Settlement contract: The on-chain component that verifies and settles the resulting trade.
- Auction or competition mechanism: The process used to encourage competing participants to offer acceptable execution.
Intent-based execution does not remove the need to verify token approvals, understand the protocol’s permissions, and review the trade details. A signed order may authorize a particular token transfer under specific conditions, so users should understand the scope and expiration of their authorizations.
Nor does “gasless” necessarily mean the trade has zero cost. It usually means that the user does not directly pay the blockchain transaction fee in the conventional way. The solver or resolver still incurs costs, and the economics of fulfilling the order may affect the price or minimum output offered to the user.
I see intent-based systems as an important evolution in DEX execution because they separate the user’s desired outcome from the low-level mechanics used to achieve it. But the right question is still the same: How much of the asset you sell must you give up, and how much of the asset you want to buy will you actually receive?
Frequently asked questions about decentralized exchanges
What is a DEX and how does non-custodial trading work?
A decentralized exchange (DEX) lets you trade digital assets through blockchain protocols and smart contracts without depositing your funds with a conventional centralized exchange. You connect a compatible wallet, authorize the required transactions, and receive the assets according to the protocol’s execution rules. You retain control of your wallet keys, but you are responsible for protecting them and checking every transaction.
What is the difference between a DEX and a CEX?
A centralized exchange (CEX) generally manages customer assets through its own custody and internal account system, while a DEX typically lets users trade directly from self-custody wallets. CEXs often provide customer support and familiar order types, whereas DEXs offer direct on-chain access and reduce reliance on a custodian. Both have risks, including exchange failure on CEXs and smart contract or wallet vulnerabilities on DEXs.
How does an automated market maker calculate prices using $x\cdot y=k$?
A constant-product AMM uses the formula $x\cdot y=k$, where $x$ and $y$ represent the pool’s token reserves and $k$ is their product. When a trader buys one token from the pool, its reserve decreases while the other reserve increases, changing the exchange rate. Larger trades relative to available liquidity generally cause greater price impact.
What is impermanent loss, and how can liquidity providers manage it?
Impermanent loss is the difference between the value of a liquidity position and the value of holding the same original assets outside the pool, measured at the same token prices. Providers can evaluate fee income against potential losses, choose pools whose assets they understand, monitor concentrated-liquidity ranges, and account for incentives and transaction costs. They cannot eliminate impermanent loss simply by choosing a pool with a high advertised APY.
What is a DEX aggregator, and why should traders use one?
A DEX aggregator compares liquidity sources and routes trades through one or more pools to seek a competitive execution result. It may split an order across multiple venues or use a multi-hop route to improve the amount received. Traders should compare net output after fees and gas, since the route with the best displayed token price may not deliver the best final result.
What is the difference between slippage and price impact?
Price impact is the effect your trade has on the market price, particularly when it consumes liquidity in an AMM pool. Slippage is the difference between the expected execution and the actual execution, often because prices or liquidity conditions change before the transaction settles. A large trade can have high price impact even if the pool does not change between the quote and execution.
How do MEV sandwich attacks work, and how can traders avoid them?
A sandwich attacker places a transaction before a victim’s swap to move the price, lets the victim execute at a worse rate, and then places another transaction afterward to attempt to profit from the price movement. Traders can reduce exposure by using sensible slippage tolerances, checking minimum-output settings, avoiding thin pools for large orders, and considering reputable protected execution mechanisms. No single measure guarantees protection against every form of MEV.
What are intent-based swaps, such as UniswapX and CoW Swap?
Intent-based swaps let users sign instructions describing the desired trade outcome rather than manually specifying every execution step. Solvers or fillers compete to fulfill those instructions through available liquidity sources, subject to protocol rules. These systems can improve routing and reduce direct gas-management burdens, but users still need to review permissions, minimum outputs, and the economics of the final trade.
Final thoughts: How to choose and use a DEX
A DEX is more than a website for swapping tokens. It is a collection of trading mechanisms, smart contracts, liquidity sources, and execution systems that determine how your assets move from one form to another. Understanding those pieces makes it much easier to choose the right platform and avoid costly mistakes.
If you mainly swap major tokens, start by comparing liquidity depth, expected output, fees, and the reliability of the interface. If you plan to supply liquidity, go beyond headline APY and estimate how fees, price divergence, incentives, and transaction costs could affect your returns. If you trade actively or use derivatives, investigate execution quality, order-book depth, margin rules, and the risks associated with the platform’s architecture.
I would make these checks part of every trade, even when using a familiar protocol:
- Verify the protocol and token addresses. Fake websites and imitation tokens can look convincing.
- Read the transaction details. Check token approvals, spending limits, minimum output, and the network you are using.
- Compare the net result. Account for swap fees, gas, routing costs, and expected price impact.
- Understand the risks you are taking. Self-custody, liquidity provision, and leveraged trading introduce different kinds of exposure.
- Keep records of important positions. Track entry prices, fees, incentives, withdrawals, and the value of your holdings so you can evaluate actual performance rather than relying on an advertised yield.
You do not need to understand every smart contract line before making your first swap, but you should know who controls your funds, how the trade will execute, and what could go wrong. That basic discipline is useful whether you are making a small stablecoin conversion, providing liquidity to an AMM, or routing a large order across several markets.
Ultimately, a good DEX is not simply the one with the lowest advertised fee or the highest APY. It is the one whose liquidity, execution design, security assumptions, and costs fit the trade you want to make-and whose risks you understand before you sign.