Uniswap v4 Core: Automated market maker protocol
Core smart contracts for Uniswap v4's extensible and customizable automated market maker pools.
Learn more about Uniswap v4 Core
Uniswap v4 Core is an automated market maker protocol that provides extensible and customizable liquidity pools. The system uses a singleton-style architecture where all pool state is managed in the PoolManager.sol contract, with pool actions executed through an unlock/callback pattern. The protocol supports customizable hook contracts that can execute callbacks during pool lifecycle events like swaps, liquidity modifications, and donations. It is designed for creating decentralized exchange functionality with flexible integration patterns for developers.
Singleton Architecture
All pool state is managed in a single PoolManager contract, with actions executed through an unlock/callback pattern that tracks net balance deltas.
Customizable Hooks
Pools can be initialized with hook contracts that implement callbacks during pool lifecycle events, providing extensible functionality.
Flexible Integration
The unlock and call style architecture allows multiple pool actions within a single transaction as long as net deltas reach zero.
import {IPoolManager} from 'v4-core/contracts/interfaces/IPoolManager.sol';
import {IUnlockCallback} from 'v4-core/contracts/interfaces/callback/IUnlockCallback.sol';
contract MyContract is IUnlockCallback {
IPoolManager poolManager;
function doSomethingWithPools() {
// this function will call `unlockCallback` below
poolManager.unlock(...);
}
function unlockCallback(bytes calldata data) external returns (bytes memory) {
// disallow arbitrary caller
if (msg.sender != address(poolManager)) revert Unauthorized();
// perform pool actions
poolManager.swap(...)
}
}
error Unauthorized();Uniswap Protocol v4
Related Repositories
Discover similar tools and frameworks used by developers
Hardhat
Development environment for compiling, deploying, testing, and debugging Ethereum smart contracts and dApps.
Solmate
A collection of gas-optimized Solidity contracts including ERC token implementations and utility libraries.
rippled
C++ XRP Ledger implementation operating as a P2P node for transaction processing and consensus.
Solana Explorer
Web application for exploring Solana blockchain transactions, accounts, blocks, and on-chain data.
Lotus
Go-based reference implementation of the Filecoin distributed storage network protocol.