---
# System prepended metadata

title: 20230525 class notes

---

# 20230525 class notes

## Sandwich Attack 
在某人的交易之前，先發起一筆交易，把 token價格墊高(但 token 價格還是要寫於被夾的 tx)，等某人買完 token 馬上賣出


## example 
1. Victim send swap tx (pending tx in mempool)
- Swap 1 ETH, amountOutMin is 80
2. Sandwich process
- Swap 1 ETH first
    - Pool become 101 ETH, 9,900.9900990099 USDC (attacker will get ~= 99.0099009901 USDC)
- Victim Buy 1 ETH
    - Pool become 102 ETH, 9,803.9215686275 USDC (victim will get ~= 97.0685303824, must >= 80)
- Sell ?s USDC
    - Pool become ? ETH, ? USDC
    - Profit ? ETH

## Uniswap V3

- liquidity 是 nft，紀錄了提供流動性的價格區間
- 
