ποΈ Uniswap Core Concepts
Uniswap v4 is an automated market maker (AMM) facilitating efficient value exchange on the Ethereum Virtual Machine (EVM). Although Uniswap v4 introduces significant innovations, such as Hooks, the underlying mathematics remains rooted in V3 and will not change. Before we delve into the core of V4, let's take a moment to revisit the fundamental concepts behind Uniswap, particularly its mathematical framework.
ποΈ Create Pool
In Uniswap V3, creating a pool usually requires deploying a new contract. However, Uniswap V4 introduces a different approach. It operates in singleton mode, managed by PoolManager.sol, eliminating the need to deploy a separate contract for each pool. Let's take a closer look at how this works.
ποΈ Provide Liquidity Overview
Compared with initializing, providing liquidity is a little complicated. Let's start from testffiaddLiqudityweirdPool0_returnsCorrectLiquidityDelta function in test/ModifyLiquidity.t.sol
ποΈ Pool Liquidity Modify
Let's dive into how liquidity is modified within the pool. The source code can be found in src/libraries/Pool.sol.
ποΈ Swap Overview
This section explains how swaps function in Uniswap V4, beginning with a basic test case.
ποΈ Pool Swap
In the previous section, we provided an overview of the entire swap process, but we have not yet analyzed how pool.swap(params) is actually executed. Now, let's dive into src/libraries/Pool.sol to understand how token swaps occur within the contract.
ποΈ Flash Accounting
In the previous section, we frequently mentioned the variable delta and the concept of βFlash Accounting.β But what do these terms actually mean?