ThePathMark
Chapter 20 DeFi basics Medium risk

How to swap on a DEX

What a decentralized exchange swap actually is, what happens when you connect your wallet, and how to read slippage, approvals, and gas before you confirm.

The short version
  • A DEX (decentralized exchange) lets you trade one token for another through smart contracts — no account signup, but you pay gas and sign every step yourself.
  • Most beginner swaps use an AMM (automated market maker): a pool of two tokens, and a formula that sets the price based on how much is in each side.
  • The usual flow is connect wallet → approve the token you're selling → confirm the swap. Two or three wallet popups, not one.
  • Slippage is how much worse a price you'll accept if the pool moves while your transaction is pending — too loose and you can get a bad fill; too tight and the swap may fail.
  • Fake swap sites copy real interfaces. Bookmark official URLs, check the token contract address, and start with a tiny test amount.

A DEX (decentralized exchange) is a trading service that runs on a blockchain through smart contracts instead of a company’s private order book. When you swap on a DEX, you trade one token (a coin tracked on-chain) for another — from a wallet you control, without creating an exchange account.

If you have not used a dApp (decentralized app) yet, read What is a dApp? first. This guide assumes you have a wallet with a small amount of crypto and know what gas fees are.

01

What a swap is — and what it is not

On Coinbase or Kraken, you click Buy and the exchange updates its internal database. Your coins sit on their books until you withdraw.

On a DEX, nothing updates a company ledger. You send a transaction — a signed instruction — that tells a smart contract to pull token A from your wallet and send token B back. The trade is recorded on the public blockchain for anyone to read.

Centralized exchange (CEX)DEX swap
AccountEmail, password, KYCJust a wallet address
Who holds coinsThe exchange, until withdrawalYou, in your wallet
How price is setOrder book or internal pricingPool math or on-chain order book
Undo buttonSometimes support can helpNo — confirmed means final
FeesTrading fee + spreadGas + often a small pool fee

A swap is not “free trading.” You pay gas (network fee) on every step, and the pool usually takes a cut of the trade.

02

How most DEX swaps work (AMM)

Most beginner-friendly DEXs — Uniswap, SushiSwap, Project X on HyperEVM — use an AMM (automated market maker). Instead of matching your order with another person’s bid, you trade against a liquidity pool: a smart-contract vault holding two tokens (for example ETH and USDC).

The pool uses a formula (often “constant product”) to quote a price. When you buy ETH with USDC, you add USDC and remove ETH. The ratio shifts, so larger trades move the price more — especially in thin pools with little liquidity (not much money sitting in the vault).

Typical flow:

  1. Connect wallet — the site reads your address and balances; it does not get your private keys. See What is a dApp?.
  2. Choose tokens — what you are selling (“From”) and what you want (“To”). Double-check the contract address on obscure tokens — same name, different scam coin happens daily.
  3. Approve (first time only per token/router) — you grant the swap contract permission to move the token you are selling. See Token approvals.
  4. Review slippage and output — the interface shows expected receive amount and slippage tolerance (explained below).
  5. Confirm swap — your wallet shows gas cost; you sign; you wait for confirmation on-chain.

Some platforms (including Hyperliquid’s Core trading side) use an order book instead — bids and asks matched like a traditional exchange. Same word “trade,” different machinery. See Hyperliquid map for when you are on a pool vs an order book.

03

Slippage, price impact, and minimum received

Between clicking Swap and your transaction landing in a block, other trades can move the pool price. Slippage tolerance is the worst price you agree to accept if the market shifts.

TermPlain meaning
Expected outputWhat the interface thinks you will receive right now
Minimum receivedThe floor after slippage — if the pool moves worse than this, the swap reverts (fails)
Price impactHow much your own trade size moves the pool price before anyone else trades
Slippage %Your buffer for movement while the transaction is pending

Default slippage (often 0.5%–1%) is fine for large pools and small trades. Thin pools, volatile tokens, or large sizes may need a higher setting — or should prompt you to trade smaller chunks instead.

Failed swaps still cost gas. The network ran your transaction even if the contract rejected it. Budget for that when experimenting.

04

Why people swap on a DEX

Honest reasons — not hype:

  • Access tokens not listed on your local exchange.
  • Stay self-custodied — coins never leave your wallet except for the swap itself.
  • Trade on-chain where a specific DeFi app or network needs a particular token (e.g. swap to USDC before lending — see Stablecoins and Lending & borrowing).
  • Move between assets without selling through a bank-linked CEX.

Swapping is a utility, not a strategy. The question is whether you need on-chain assets for something you understand — not whether “DEX volume” is trending.

05

Risks beginners should know

  • Phishing sites — fake Uniswap clones with one letter changed in the URL. They drain wallets on the first approval. Bookmark official links; never trust DMs.
  • Wrong token — scammers deploy “USDC” lookalikes. Verify contract address on a block explorer or the project’s official docs.
  • Bad fills — low liquidity means high price impact. A meme coin pool can eat 10% on a modest trade.
  • Slippage set too high — protects against failure but lets a frontrunner or sudden move give you far less than you expected.
  • Unlimited approvals — convenient for repeat swaps; dangerous if the router contract is exploited. Prefer exact approvals when offered. See Token approvals.
  • Wrong network — your wallet must be on the chain where the pool lives. Sending tokens on the wrong crypto network is a separate disaster.
  • Gas without native token — you cannot pay gas in USDC on Ethereum; you need ETH (or the chain’s native gas token). See Gas fees.
06

A sensible first swap — checklist

  1. Pick a well-known DEX on a chain with cheap gas for learning (an L2 like Base or Arbitrum, or HyperEVM if you are already on Hyperliquid).
  2. Type the URL yourself or use a bookmark — not a search ad or Discord link.
  3. Hold a little native gas token in the same wallet (ETH, HYPE, etc.).
  4. Swap a tiny test amount — ten dollars worth is enough to learn the popups.
  5. Read both popups — approval first, swap second. Check token names and amounts.
  6. Leave slippage at default unless the interface warns you; note minimum received.
  7. Wait for confirmation — check a block explorer if the UI lags.
  8. Revoke or limit approvals if this was a one-off experiment on a site you will not reuse.

After one clean swap, you have the template for staking, lending, and yield farming — same connect-approve-confirm rhythm, different contracts.

⚑ One honest flag

A DEX swap is irreversible the moment it confirms. There is no support desk to email. If the URL, token address, or approval looks off — close the tab. Missing a trade beats funding a lesson you cannot unlearn.

If this cleared something up, you can buy me a coffee — or say hi on X.

← All guides