Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is an Automated Market Maker (AMM)?
An AMM is a smart contract on a blockchain that allows users to trade cryptocurrencies directly without needing a traditional order book. It uses a mathematical formula to price assets.
Click to reveal answer
intermediate
How does the constant product formula work in AMMs?
The constant product formula keeps the product of the two token reserves constant (x * y = k). When one token is bought, its reserve decreases and the other token's reserve increases to keep the product the same.
Click to reveal answer
beginner
What role do liquidity providers play in AMMs?
Liquidity providers add equal value of two tokens to the pool, enabling trades. They earn fees from trades proportional to their share of the pool.
Click to reveal answer
intermediate
What is impermanent loss in AMMs?
Impermanent loss happens when the price of tokens in the pool changes compared to holding them outside. Liquidity providers may lose value compared to just holding tokens.
Click to reveal answer
beginner
Name a popular AMM protocol on Ethereum.
Uniswap is a popular AMM protocol on Ethereum that uses the constant product formula to enable decentralized token swaps.
Click to reveal answer
What does an AMM use to determine token prices?
AA mathematical formula
BA traditional order book
CManual price setting
DRandom number generation
✗ Incorrect
AMMs use mathematical formulas like the constant product formula to set prices automatically.
In the constant product formula x * y = k, what does 'k' represent?
AA fixed constant value
BThe product of token reserves
CThe trading fee
DThe total number of tokens
✗ Incorrect
'k' is the product of the two token reserves and remains constant during trades.
Who earns fees in an AMM?
ALiquidity providers
BTraders only
CBlockchain miners
DSmart contract developers
✗ Incorrect
Liquidity providers earn fees from trades proportional to their share of the pool.
What is impermanent loss?
ALoss from failed transactions
BPermanent loss of tokens due to hacking
CLoss from trading fees
DLoss from token price changes while providing liquidity
✗ Incorrect
Impermanent loss is the temporary loss liquidity providers face when token prices change compared to holding tokens.
Which blockchain is Uniswap built on?
ASolana
BBitcoin
CEthereum
DBinance Smart Chain
✗ Incorrect
Uniswap is a decentralized AMM protocol built on the Ethereum blockchain.
Explain how an Automated Market Maker (AMM) enables token trading without an order book.
Think about how prices adjust when tokens are swapped in the pool.
You got /4 concepts.
Describe the risks liquidity providers face when adding tokens to an AMM pool.
Consider what happens if token prices move after you add liquidity.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of an Automated Market Maker (AMM) in blockchain?
easy
A. To enable token trading without a middleman using math formulas
B. To store user passwords securely
C. To mine new blocks in the blockchain
D. To create new tokens automatically
Solution
Step 1: Understand AMM's role
AMMs allow users to trade tokens directly without needing a traditional exchange or middleman.
Step 2: Identify the key feature
They use mathematical formulas and token reserves to set prices and enable swaps.
Final Answer:
To enable token trading without a middleman using math formulas -> Option A
Quick Check:
AMM = trading without middleman [OK]
Hint: AMMs trade tokens using formulas, no middleman needed [OK]
Common Mistakes:
Confusing AMM with mining or token creation
Thinking AMM stores passwords
Assuming AMM creates tokens automatically
2. Which of the following is the correct formula used by a constant product AMM to maintain balance?
easy
A. x + y = k
B. x - y = k
C. x / y = k
D. x * y = k
Solution
Step 1: Recall AMM constant product formula
AMMs use the formula where the product of token reserves remains constant.
Step 2: Identify the correct formula
The formula is x * y = k, where x and y are token reserves and k is constant.
Final Answer:
x * y = k -> Option D
Quick Check:
Product of reserves = constant [OK]
Hint: Remember: AMM uses multiplication for constant product [OK]
Common Mistakes:
Using addition or subtraction instead of multiplication
Confusing division with the formula
Mixing up variables and constants
3. Given an AMM with reserves x = 100 and y = 200, what is the new y reserve after adding 10 tokens to x and keeping k constant?
medium
A. 181.82
B. 220
C. 190
D. 200
Solution
Step 1: Calculate constant k
k = x * y = 100 * 200 = 20000.
Step 2: Calculate new y after adding 10 to x
New x = 100 + 10 = 110. New y = k / new x = 20000 / 110 ≈ 181.82.
Final Answer:
181.82 -> Option A
Quick Check:
New y = 20000 / 110 ≈ 181.82 [OK]
Hint: Divide k by new x to find new y quickly [OK]
Common Mistakes:
Adding instead of dividing to find new y
Using old y value without adjustment
Forgetting to add tokens to x before calculation
4. Identify the error in this Python function that calculates output tokens from an AMM swap:
A. The function returns new_y instead of the difference
B. The function uses addition instead of multiplication for k
C. The function does not account for swap fees
D. The function uses integer division instead of float division
Solution
Step 1: Review function logic
The function calculates k correctly and finds new reserves after swap.
Step 2: Check for missing AMM details
It does not include swap fees, which reduce the effective input amount.
Final Answer:
The function does not account for swap fees -> Option C
Quick Check:
Missing fees in calculation [OK]
Hint: Remember to subtract swap fees from input amount [OK]
Common Mistakes:
Ignoring swap fees in calculations
Confusing return values
Using integer division in Python 3 (which is float by default)
5. You want to implement a function that calculates the output token amount from a swap on an AMM with a 0.3% fee. Given reserves x=500, y=1000, and input x_in=50, which code snippet correctly calculates the output amount?
hard
A. def swap_output(x, y, x_in):
fee = 0.003
x_in_with_fee = x_in + fee
k = x * y
new_x = x + x_in_with_fee
new_y = k / new_x
return y - new_y
B. def swap_output(x, y, x_in):
fee = 0.003
x_in_with_fee = x_in * (1 - fee)
k = x * y
new_x = x + x_in_with_fee
new_y = k / new_x
return y - new_y
C. def swap_output(x, y, x_in):
fee = 0.003
x_in_with_fee = x_in * fee
k = x * y
new_x = x + x_in_with_fee
new_y = k / new_x
return y - new_y
D. def swap_output(x, y, x_in):
fee = 0.003
x_in_with_fee = x_in / (1 - fee)
k = x * y
new_x = x + x_in_with_fee
new_y = k / new_x
return y - new_y
Solution
Step 1: Calculate effective input after fee
The input tokens are reduced by the fee: x_in_with_fee = x_in * (1 - 0.003).
Step 2: Calculate new reserves and output
Use constant product k = x * y, then new_x = x + x_in_with_fee, new_y = k / new_x, output = y - new_y.
Final Answer:
Code snippet B correctly applies the fee and calculates output -> Option B
Quick Check:
Subtract fee before adding input [OK]
Hint: Multiply input by (1 - fee) before calculation [OK]