https://github.com/Uniswap/v3-core
https://github.com/Uniswap/v3-periphery
ETH / USDC 0.05% pool Arbitrum
0xC31E54c7a869B9FcBEcc14363CF510d1c41fa443
-
Factory
-
Price oracle
-
Protocol fee
-
Flash swap
-
NFT
-
Solidity advanced math libraries
-
Callbacks
forge init clamm
forge build
forge fmt
-
-
constructor
- Price, tick and tick spacing
-
tickSpacingToMaxLiquidityPerTick
-
-
-
initialize
-
slot0
-
sqrtPriceX96
-
getTickAtSqrtRatio
, calculate tick fromsqrtPriceX96
-
-
-
-
mint
-
_modifyPosition
-
_updatePosition
-
position.get
-
positon.update
-
ticks.update
,ticks.clear
-
Tick.Info
- Liquidity, price and token reserves
- Liquidity net
-
-
-
getAmount0Delta
andgetAmount1Delta
- Curve of real reserves
- Reserve 0 and 1
- Liquidity
- Liquidity delta
-
-
-
-
TODO: fix burn 0
-
burn
-
-
-
collect
-
-
-
swap
- one tick
-
computeSwapStep
-
sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput
-
-
- multi ticks
-
nextInitializedTickWithInOneWord
- TickBitMap,
tickBitMap.flipTick
- TickBitMap,
-
ticks.cross
-
liquidityNet
-
-
- one tick
-
-
-
feeGrowthGlobal
-
tick.cross
-
getFeeGrowthInside
(burn + collect to earn fees)
-
-
sqrtPriceX96
-
get tick from sqrt price x 96
-
get price from sqrt price x 96
-
tick bitmap
-
getSqrtRatioAtTick
-
getTickAtSqrtRatio
-
getAmount0Delta, getAmount1Delta
-
liquidity delta
-
tick, liquidity, price directions and token 0 token 1
-
getNextSqrtPriceFromAmount0RoundingUp(
-
getNextSqrtPriceFromAmount1RoundingDown
-
why
fee = amountIN * fee / (1 - fee)
-
nextInitializedTickWithinOneWord
-
liquidityNet
-
fee growth (per liquidity)
-
how does burn update tokensOwed
https://blog.uniswap.org/uniswap-v3-math-primer
https://blog.uniswap.org/uniswap-v3-math-primer-2
https://trapdoortech.medium.com/uniswap-deep-dive-into-v3-technical-white-paper-2fe2b5c90d2