Quiz: Decentralized Exchanges and Automated Market Makers

Multiple Choice

1. In the constant product formula x * y = k, what happens to the price of Token A as Token A is removed from the pool?

(a) The price decreases linearly (b) The price increases nonlinearly (hyperbolically) (c) The price stays the same until a threshold is reached (d) The price increases linearly

2. A pool has 1,000 ETH and 2,000,000 USDC. What is the marginal price of ETH in USDC terms?

(a) $1,000 (b) $2,000 (c) $3,000 (d) $2,000,000

3. Which of the following is NOT a reason why on-chain order books are impractical on Ethereum L1?

(a) Gas costs make frequent order updates prohibitively expensive (b) 12-second block times create stale order risk for market makers (c) The EVM cannot perform multiplication and division operations (d) Pending orders in the mempool are visible, enabling front-running

4. A liquidity provider deposits $10,000 in a 50/50 ETH/USDC pool. The price of ETH triples. Using the IL formula, what is the impermanent loss?

(a) -5.72% (b) -13.40% (c) -20.00% (d) -25.46%

5. In Uniswap V3, what is the purpose of "ticks"?

(a) They measure the time between trades (b) They divide the price space into discrete points where liquidity can be bounded (c) They count the number of swaps processed by a pool (d) They represent gas price levels for priority ordering

6. Which of the following best describes how a sandwich attack works?

(a) The attacker places a large sell order to crash the price, then buys at the lower price (b) The attacker buys before the victim's trade (front-run), then sells after the victim's trade (back-run) (c) The attacker provides liquidity, waits for a large trade, then withdraws liquidity (d) The attacker manipulates the oracle price to trigger liquidations

7. What happens to a Uniswap V3 LP position when the price moves above the LP's specified upper tick?

(a) The position is liquidated automatically (b) The position holds 100% of the lower-valued token and earns no fees (c) The position continues to earn fees at a reduced rate (d) The position is automatically closed and LP tokens are burned

8. Why is the constant sum formula (x + y = k) unsuitable for a DEX pool with volatile assets?

(a) It cannot be computed on-chain (b) It allows one token to be completely drained from the pool (c) It produces prices that are always too high (d) It requires an external oracle

9. What role do arbitrageurs play in the AMM ecosystem?

(a) They provide the initial liquidity for new pools (b) They align AMM prices with external market prices by trading against mispricings (c) They set the fee structure for each pool (d) They approve which tokens can be listed on the DEX

10. A DEX aggregator like 1inch splits a large trade across multiple pools primarily to:

(a) Reduce gas fees (b) Minimize total price impact across all venues (c) Avoid KYC requirements (d) Increase the trading speed

11. Impermanent loss is symmetric, meaning:

(a) It is the same for all tokens in a pool (b) A 2x price increase and a 2x price decrease produce the same percentage loss (c) It affects buyers and sellers equally (d) It is offset by an equal amount of trading fees

12. Which protocol introduced the concept of "Coincidence of Wants" for MEV-resistant trading?

(a) Uniswap V3 (b) Curve Finance (c) CoW Protocol (d) Flashbots

13. In Uniswap V2, LP tokens are:

(a) Non-fungible tokens (NFTs) unique to each position (b) Fungible ERC-20 tokens proportional to pool share (c) Soulbound tokens that cannot be transferred (d) Governance tokens that control protocol parameters

14. A pool has reserves of 500 ETH and 1,000,000 USDC. A trader swaps 50,000 USDC for ETH (ignoring fees). How much ETH do they receive?

(a) 25 ETH (b) 23.81 ETH (c) 20 ETH (d) 50 ETH

15. Which of the following is an advantage of CEXs over DEXs?

(a) Self-custody of assets (b) Censorship resistance (c) Lower latency and tighter spreads (d) No counterparty risk

True or False

16. The constant product formula ensures that a pool can never be fully drained of either token. True / False

17. Uniswap V3 LP positions are represented as fungible ERC-20 tokens, just like V2. True / False

18. Impermanent loss is always negative (or zero) — the pool value is always less than or equal to the HODL value. True / False

19. Flash swaps, introduced in Uniswap V2, allow a trader to receive tokens before paying for them within the same transaction. True / False

20. A sandwich attacker's profit always exactly equals the victim's loss. True / False

Short Answer

21. Explain in two to three sentences why concentrated liquidity (Uniswap V3) increases both fee income and impermanent loss for a liquidity provider.

22. A pool has 200 ETH and 400,000 USDC. Calculate the constant product k, the current marginal price of ETH, and the amount of ETH a trader receives for swapping 10,000 USDC (ignore fees). Show your work.

23. Describe two specific mitigation strategies that a DEX trader can use to protect against sandwich attacks, and explain the trade-off of each strategy.

24. Explain why the term "impermanent loss" is considered misleading by many DeFi researchers and practitioners. What would be a more accurate name?

25. In one to two sentences, explain why Curve's StableSwap invariant is superior to x * y = k for stablecoin-to-stablecoin trading.


Answer Key

1. (b) — The constant product curve is a hyperbola; as x decreases, y/x increases nonlinearly.

2. (b) — P = y/x = 2,000,000/1,000 = $2,000.

3. (c) — The EVM can perform multiplication and division. The other three are genuine constraints.

4. (b) — r = 3, IL = 2sqrt(3)/(1+3) - 1 = 21.732/4 - 1 = 3.464/4 - 1 = 0.866 - 1 = -13.4%.

5. (b) — Ticks divide the price space into discrete points; LPs provide liquidity between specific ticks.

6. (b) — The attacker buys before the victim (front-run) to push the price up, then sells after (back-run).

7. (b) — When price exceeds the upper tick, the position is fully converted to the lower-valued token and stops earning fees.

8. (b) — The constant sum allows x to reach 0 (all of Token A drained), which breaks the market.

9. (b) — Arbitrageurs are the mechanism by which AMM prices stay aligned with external market prices.

10. (b) — Splitting reduces price impact by distributing volume across multiple liquidity sources.

11. (b) — IL depends on the magnitude of price change, not the direction; 2x up and 0.5x (=1/2x) down give identical IL.

12. (c) — CoW Protocol (Coincidence of Wants Protocol) batches trades and matches counterparties.

13. (b) — V2 LP tokens are fungible ERC-20 tokens. V3 positions are NFTs (ERC-721).

14. (b) — delta_x = 500 * 50,000 / (1,000,000 + 50,000) = 25,000,000 / 1,050,000 = 23.81 ETH.

15. (c) — CEXs offer lower latency (milliseconds vs. seconds) and tighter spreads due to professional market makers.

16. True — As one reserve approaches 0, its price approaches infinity, preventing full drainage.

17. False — V3 positions are non-fungible (ERC-721 NFTs) because each position has a unique price range.

18. True — Mathematically, 2*sqrt(r)/(1+r) <= 1 for all r > 0, with equality only at r = 1.

19. True — Flash swaps allow receiving tokens first, as long as they are paid for (or returned) atomically.

20. False — The attacker's profit is less than the victim's loss; the difference goes to the pool as fees and to block producers as priority fees.

21. Concentrated liquidity compresses a position's capital into a narrower price range, making it behave as if it were a much larger V2 position. This increases fee income (more capital per unit of trading volume within the range) but also amplifies impermanent loss (the position rebalances more aggressively as the price moves within the range, and goes to 100% of one token if the price exits the range).

22. k = 200 * 400,000 = 80,000,000. Marginal price = 400,000 / 200 = $2,000/ETH. ETH received = 200 * 10,000 / (400,000 + 10,000) = 2,000,000 / 410,000 = 4.878 ETH.

23. (1) Set a low slippage tolerance (e.g., 0.1%) — this makes sandwich attacks unprofitable for smaller trades because the attacker cannot push the price far enough without causing the victim's transaction to revert. Trade-off: higher risk of transaction failure in volatile markets. (2) Use a private transaction relay like Flashbots Protect — this prevents the transaction from appearing in the public mempool, so searchers cannot detect it. Trade-off: reliance on a centralized relay service and potentially slower inclusion times.

24. The term "impermanent" misleadingly suggests the loss will eventually disappear. While the loss does reverse if the price returns to its starting point, this is not guaranteed — and if the LP withdraws at any other price, the loss is permanent. A more accurate term would be "divergence loss" (reflecting that it measures the divergence between pool value and hold value) or "rebalancing loss" (reflecting that it results from the AMM's continuous rebalancing as prices move).

25. Curve's StableSwap invariant combines constant-sum behavior (near-zero slippage at the 1:1 exchange rate) with constant-product behavior (preventing drainage when prices diverge). For stablecoins that should trade near parity, this produces dramatically lower slippage than x*y=k, where even small trades incur price impact proportional to the trade size relative to pool depth.