Request form
Uniswap V4
  • Uniswap
  • DEX
  • Exchange
  • Token
  • Protocol
Docs
Source
ChefGPT

Web3 infrastructure and products

GasSnapshot.sol
UintString.sol
test.sol
Base.sol
Script.sol
StdAssertions.sol
StdChains.sol
StdCheats.sol
StdError.sol
StdInvariant.sol
StdJson.sol
StdMath.sol
StdStorage.sol
StdStyle.sol
StdUtils.sol
Test.sol
Vm.sol
console.sol
console2.sol
IMulticall3.sol
safeconsole.sol
Ownable.sol
ERC20.sol
IERC20.sol
ERC20Burnable.sol
IERC20Metadata.sol
ERC20PresetFixedSupply.sol
Context.sol
MockERC20.sol
ERC20.sol
FixedPointMathLib.sol
01_DeployVault.s.sol
02_DeployCLPoolManager.s.sol
03_DeployBinPoolManager.s.sol
BaseScript.sol
Extsload.sol
Fees.sol
Vault.sol
VaultToken.sol
IERC20Minimal.sol
IExtsload.sol
IFees.sol
IHooks.sol
ILockCallback.sol
IPoolManager.sol
IProtocolFeeController.sol
IVault.sol
IVaultToken.sol
FeeLibrary.sol
Hooks.sol
SafeCast.sol
SettlementGuard.sol
Encoded.sol
ParametersHelper.sol
BinPoolManager.sol
IBinDynamicFeeManager.sol
IBinHooks.sol
IBinLmPool.sol
IBinPoolManager.sol
BinHelper.sol
BinPool.sol
BinPoolParametersHelper.sol
BinPosition.sol
Constants.sol
FeeHelper.sol
PriceHelper.sol
BitMath.sol
LiquidityConfigurations.sol
PackedUint128Math.sol
SafeCast.sol
TreeMath.sol
Uint128x128Math.sol
Uint256x256Math.sol
CLPoolManager.sol
ICLDynamicFeeManager.sol
ICLHooks.sol
ICLLmPool.sol
ICLPoolManager.sol
BitMath.sol
CLPool.sol
CLPoolParametersHelper.sol
CLPosition.sol
FixedPoint128.sol
FixedPoint96.sol
FullMath.sol
LiquidityMath.sol
SqrtPriceMath.sol
SwapMath.sol
Tick.sol
TickBitmap.sol
TickMath.sol
UnsafeMath.sol
MockFeePoolManager.sol
MockVault.sol
MockFeeManagerHook.sol
MockProtocolFeeController.sol
MockBinHooks.sol
BalanceDelta.sol
Currency.sol
PoolId.sol
PoolKey.sol
Extsload.t.sol
Fees.t.sol
VaultToken.t.sol
SortTokens.sol
TokenFixture.sol
TokenRejecter.sol
BalanceDelta.t.sol
Currency.t.sol
FeeLibrary.sol
Hooks.t.sol
HooksContract.sol
SafeCast.t.sol
SettlementGuard.t.sol
Encoded.t.sol
BinHook.t.sol
BinPoolManager.t.sol
BaseBinTestHook.sol
BinDonateHelper.sol
BinFeeManagerHook.sol
BinLiquidityHelper.sol
BinNoOpTestHook.sol
BinSwapHelper.sol
BinTestHelper.sol
MockBinLmPool.sol
BinHelper.t.sol
BinPoolDonate.t.sol
BinPoolFee.t.sol
BinPoolLiquidity.t.sol
BinPoolParameterHelper.t.sol
BinPoolSwap.t.sol
BinPosition.t.sol
FeeHelper.t.sol
PriceHelper.t.sol
BitMath.t.sol
LiquidityConfigurations.t.sol
PackedUint128Math.t.sol
SafeCast.t.sol
TreeMath.t.sol
Uint128x128Math.t.sol
Uint256x256Math.t.sol
CLFees.t.sol
CLPoolManager.t.sol
BaseCLTestHook.sol
CLFeeManagerHook.sol
CLLmPool.sol
CLNoOpTestHook.sol
CLPoolManagerRouter.sol
CLPoolParametersHelper.t.sol
Constants.sol
Deployers.sol
LiquidityAmounts.sol
MockHooks.sol
NonStandardERC20.sol
PoolModifyPositionTest.sol
ProtocolFeeControllerTest.sol
TickMathTestHelper.sol
BitMath.t.sol
CLPool.t.sol
CLPoolParametersHelper.t.sol
CLPoolSwapFee.t.sol
CLPosition.t.sol
FullMath.t.sol
LiquidityMath.t.sol
SqrtPriceMath.t.sol
SwapMath.t.sol
Tick.t.sol
TickBitmap.t.sol
TickMath.t.sol
UnsafeMath.t.sol
FakePoolManager.sol
FakePoolManagerRouter.sol
Vault.t.sol
VaultInvariant.t.sol
VaultReentrancy.t.sol
StdToml.sol
IERC165.sol
IERC20.sol
IERC721.sol
MockERC20.sol
MockERC721.sol
Proxy.sol
Owned.sol
ERC6909.sol
ERC6909Claims.sol
Exttload.sol
NoDelegateCall.sol
PoolManager.sol
ProtocolFees.sol
IExttload.sol
IProtocolFees.sol
IUnlockCallback.sol
IERC20Minimal.sol
IERC6909Claims.sol
BitMath.sol
CurrencyDelta.sol
CurrencySettleTake.sol
FixedPoint128.sol
FixedPoint96.sol
FullMath.sol
LPFeeLibrary.sol
LiquidityMath.sol
Lock.sol
NonZeroDeltaCount.sol
ParseBytes.sol
Pool.sol
Position.sol
ProtocolFeeLibrary.sol
Reserves.sol
SqrtPriceMath.sol
StateLibrary.sol
SwapMath.sol
TickBitmap.sol
TickMath.sol
TransientStateLibrary.sol
UnsafeMath.sol
ActionsRouter.sol
BaseTestHooks.sol
CurrencyTest.sol
CustomCurveHook.sol
DeltaReturningHook.sol
DynamicFeesTestHook.sol
DynamicReturnFeeTestHook.sol
EmptyRevertHook.sol
EmptyTestHooks.sol
FeeTakingHook.sol
Fuzzers.sol
HooksTest.sol
LiquidityMathTest.sol
MockContract.sol
MockERC6909Claims.sol
MockHooks.sol
NoDelegateCallTest.sol
PoolClaimsTest.sol
PoolDonateTest.sol
PoolEmptyUnlockTest.sol
PoolModifyLiquidityTest.sol
PoolModifyLiquidityTestNoChecks.sol
PoolNestedActionsTest.sol
PoolSettleTest.sol
PoolSwapTest.sol
PoolTakeTest.sol
PoolTestBase.sol
ProtocolFeeControllerTest.sol
ProtocolFeesImplementation.sol
SkipCallsTestHook.sol
SqrtPriceMathEchidnaTest.sol
SwapRouterNoChecks.sol
TestERC20.sol
TestInvalidERC20.sol
TickMathEchidnaTest.sol
TickMathTest.sol
TickOverflowSafetyEchidnaTest.sol
BeforeSwapDelta.sol
Slot0.sol
DynamicFees.t.sol
DynamicReturnFees.t.sol
ERC6909Claims.t.sol
ModifyLiquidity.t.sol
NoDelegateCall.t.sol
PoolManager.t.sol
PoolManagerInitialize.t.sol
ProtocolFeesImplementation.t.sol
Reserves.t.sol
SkipCallsTestHook.t.sol
Sync.t.sol
Tick.t.sol
BitMath.t.sol
FullMath.t.sol
Hooks.t.sol
LPFeeLibrary.t.sol
LiquidityMath.t.sol
Lock.t.sol
NonZeroDeltaCount.t.sol
Pool.t.sol
PoolId.t.sol
Position.t.sol
ProtocolFeeLibrary.t.sol
SqrtPriceMath.t.sol
StateLibrary.t.sol
SwapMath.t.sol
TickBitmap.t.sol
TickMath.t.sol
UnsafeMath.t.sol
BalanceDelta.t.sol
Currency.t.sol
Slot0.t.sol
AmountHelpers.sol
Constants.sol
Deployers.sol
JavascriptFfi.sol
LiquidityAmounts.sol
NestedActions.t.sol
SortTokens.sol
SwapHelper.t.sol

TVL

$6.23B

455 downloads

Chains

Authors

Uniswap V4
  • Uniswap
  • DEX
  • Exchange
  • Token
  • Protocol
Info
Source
ChefGPT
Expand
Share

Get Cookin'

455 downloads

Authors

Uniswap v4 Core

Lint Tests

Uniswap v4 is a new automated market maker protocol that provides extensible and customizable pools. v4-core hosts the core pool logic for creating pools and executing pool actions like swapping and providing liquidity.

The contracts in this repo are in early stages - we are releasing the draft code now so that v4 can be built in public, with open feedback and meaningful community contribution. We expect this will be a months-long process, and we appreciate any kind of contribution, no matter how small.

Contributing

If you’re interested in contributing please see our contribution guidelines!

Whitepaper

A more detailed description of Uniswap v4 Core can be found in the draft of the Uniswap v4 Core Whitepaper.

Architecture

v4-core uses a singleton-style architecture, where all pool state is managed in the PoolManager.sol contract. Pool actions can be taken after an initial call to unlock. Integrators implement the unlockCallback and proceed with any of the following actions on the pools:

  • swap
  • modifyLiquidity
  • donate
  • take
  • settle
  • mint
  • burn

Note that pool initialization can happen outside the context of unlocking the PoolManager.

Only the net balances owed to the user (positive) or to the pool (negative) are tracked throughout the duration of an unlock. This is the delta field held in the unlock state. Any number of actions can be run on the pools, as long as the deltas accumulated during the unlock reach 0 by the unlock’s release. This unlock and call style architecture gives callers maximum flexibility in integrating with the core code.

Additionally, a pool may be initialized with a hook contract, that can implement any of the following callbacks in the lifecycle of pool actions:

  • {before,after}Initialize
  • {before,after}AddLiquidity
  • {before,after}RemoveLiquidity
  • {before,after}Swap
  • {before,after}Donate

The callback logic, may be updated by the hooks dependent on their implementation. However which callbacks are executed on a pool cannot change after pool initialization.

Repository Structure

All contracts are held within the v4-core/src folder.

Note that helper contracts used by tests are held in the v4-core/src/test subfolder within the src folder. Any new test helper contracts should be added here, but all foundry tests are in the v4-core/test folder.

src/
----interfaces/
    | IPoolManager.sol
    | ...
----libraries/
    | Position.sol
    | Pool.sol
    | ...
----test
----PoolManager.sol
...
test/
----libraries/
    | Position.t.sol
    | Pool.t.sol

Local deployment and Usage

To utilize the contracts and deploy to a local testnet, you can install the code in your repo with forge:

forge install https://github.com/Uniswap/v4-core

To integrate with the contracts, the interfaces are available to use:


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) {
        // perform pool actions
        poolManager.swap(...)
    }
}

License

The primary license for Uniswap V4 Core is the Business Source License 1.1 (BUSL-1.1), see LICENSE. Minus the following exceptions:

Each of these files states their license type.

Web3 infrastructure and products
GasSnapshot.sol
UintString.sol
test.sol
Base.sol
Script.sol
StdAssertions.sol
StdChains.sol
StdCheats.sol
StdError.sol
StdInvariant.sol
StdJson.sol
StdMath.sol
StdStorage.sol
StdStyle.sol
StdUtils.sol
Test.sol
Vm.sol
console.sol
console2.sol
IMulticall3.sol
safeconsole.sol
Ownable.sol
ERC20.sol
IERC20.sol
ERC20Burnable.sol
IERC20Metadata.sol
ERC20PresetFixedSupply.sol
Context.sol
MockERC20.sol
ERC20.sol
FixedPointMathLib.sol
01_DeployVault.s.sol
02_DeployCLPoolManager.s.sol
03_DeployBinPoolManager.s.sol
BaseScript.sol
Extsload.sol
Fees.sol
Vault.sol
VaultToken.sol
IERC20Minimal.sol
IExtsload.sol
IFees.sol
IHooks.sol
ILockCallback.sol
IPoolManager.sol
IProtocolFeeController.sol
IVault.sol
IVaultToken.sol
FeeLibrary.sol
Hooks.sol
SafeCast.sol
SettlementGuard.sol
Encoded.sol
ParametersHelper.sol
BinPoolManager.sol
IBinDynamicFeeManager.sol
IBinHooks.sol
IBinLmPool.sol
IBinPoolManager.sol
BinHelper.sol
BinPool.sol
BinPoolParametersHelper.sol
BinPosition.sol
Constants.sol
FeeHelper.sol
PriceHelper.sol
BitMath.sol
LiquidityConfigurations.sol
PackedUint128Math.sol
SafeCast.sol
TreeMath.sol
Uint128x128Math.sol
Uint256x256Math.sol
CLPoolManager.sol
ICLDynamicFeeManager.sol
ICLHooks.sol
ICLLmPool.sol
ICLPoolManager.sol
BitMath.sol
CLPool.sol
CLPoolParametersHelper.sol
CLPosition.sol
FixedPoint128.sol
FixedPoint96.sol
FullMath.sol
LiquidityMath.sol
SqrtPriceMath.sol
SwapMath.sol
Tick.sol
TickBitmap.sol
TickMath.sol
UnsafeMath.sol
MockFeePoolManager.sol
MockVault.sol
MockFeeManagerHook.sol
MockProtocolFeeController.sol
MockBinHooks.sol
BalanceDelta.sol
Currency.sol
PoolId.sol
PoolKey.sol
Extsload.t.sol
Fees.t.sol
VaultToken.t.sol
SortTokens.sol
TokenFixture.sol
TokenRejecter.sol
BalanceDelta.t.sol
Currency.t.sol
FeeLibrary.sol
Hooks.t.sol
HooksContract.sol
SafeCast.t.sol
SettlementGuard.t.sol
Encoded.t.sol
BinHook.t.sol
BinPoolManager.t.sol
BaseBinTestHook.sol
BinDonateHelper.sol
BinFeeManagerHook.sol
BinLiquidityHelper.sol
BinNoOpTestHook.sol
BinSwapHelper.sol
BinTestHelper.sol
MockBinLmPool.sol
BinHelper.t.sol
BinPoolDonate.t.sol
BinPoolFee.t.sol
BinPoolLiquidity.t.sol
BinPoolParameterHelper.t.sol
BinPoolSwap.t.sol
BinPosition.t.sol
FeeHelper.t.sol
PriceHelper.t.sol
BitMath.t.sol
LiquidityConfigurations.t.sol
PackedUint128Math.t.sol
SafeCast.t.sol
TreeMath.t.sol
Uint128x128Math.t.sol
Uint256x256Math.t.sol
CLFees.t.sol
CLPoolManager.t.sol
BaseCLTestHook.sol
CLFeeManagerHook.sol
CLLmPool.sol
CLNoOpTestHook.sol
CLPoolManagerRouter.sol
CLPoolParametersHelper.t.sol
Constants.sol
Deployers.sol
LiquidityAmounts.sol
MockHooks.sol
NonStandardERC20.sol
PoolModifyPositionTest.sol
ProtocolFeeControllerTest.sol
TickMathTestHelper.sol
BitMath.t.sol
CLPool.t.sol
CLPoolParametersHelper.t.sol
CLPoolSwapFee.t.sol
CLPosition.t.sol
FullMath.t.sol
LiquidityMath.t.sol
SqrtPriceMath.t.sol
SwapMath.t.sol
Tick.t.sol
TickBitmap.t.sol
TickMath.t.sol
UnsafeMath.t.sol
FakePoolManager.sol
FakePoolManagerRouter.sol
Vault.t.sol
VaultInvariant.t.sol
VaultReentrancy.t.sol
StdToml.sol
IERC165.sol
IERC20.sol
IERC721.sol
MockERC20.sol
MockERC721.sol
Proxy.sol
Owned.sol
ERC6909.sol
ERC6909Claims.sol
Exttload.sol
NoDelegateCall.sol
PoolManager.sol
ProtocolFees.sol
IExttload.sol
IProtocolFees.sol
IUnlockCallback.sol
IERC20Minimal.sol
IERC6909Claims.sol
BitMath.sol
CurrencyDelta.sol
CurrencySettleTake.sol
FixedPoint128.sol
FixedPoint96.sol
FullMath.sol
LPFeeLibrary.sol
LiquidityMath.sol
Lock.sol
NonZeroDeltaCount.sol
ParseBytes.sol
Pool.sol
Position.sol
ProtocolFeeLibrary.sol
Reserves.sol
SqrtPriceMath.sol
StateLibrary.sol
SwapMath.sol
TickBitmap.sol
TickMath.sol
TransientStateLibrary.sol
UnsafeMath.sol
ActionsRouter.sol
BaseTestHooks.sol
CurrencyTest.sol
CustomCurveHook.sol
DeltaReturningHook.sol
DynamicFeesTestHook.sol
DynamicReturnFeeTestHook.sol
EmptyRevertHook.sol
EmptyTestHooks.sol
FeeTakingHook.sol
Fuzzers.sol
HooksTest.sol
LiquidityMathTest.sol
MockContract.sol
MockERC6909Claims.sol
MockHooks.sol
NoDelegateCallTest.sol
PoolClaimsTest.sol
PoolDonateTest.sol
PoolEmptyUnlockTest.sol
PoolModifyLiquidityTest.sol
PoolModifyLiquidityTestNoChecks.sol
PoolNestedActionsTest.sol
PoolSettleTest.sol
PoolSwapTest.sol
PoolTakeTest.sol
PoolTestBase.sol
ProtocolFeeControllerTest.sol
ProtocolFeesImplementation.sol
SkipCallsTestHook.sol
SqrtPriceMathEchidnaTest.sol
SwapRouterNoChecks.sol
TestERC20.sol
TestInvalidERC20.sol
TickMathEchidnaTest.sol
TickMathTest.sol
TickOverflowSafetyEchidnaTest.sol
BeforeSwapDelta.sol
Slot0.sol
DynamicFees.t.sol
DynamicReturnFees.t.sol
ERC6909Claims.t.sol
ModifyLiquidity.t.sol
NoDelegateCall.t.sol
PoolManager.t.sol
PoolManagerInitialize.t.sol
ProtocolFeesImplementation.t.sol
Reserves.t.sol
SkipCallsTestHook.t.sol
Sync.t.sol
Tick.t.sol
BitMath.t.sol
FullMath.t.sol
Hooks.t.sol
LPFeeLibrary.t.sol
LiquidityMath.t.sol
Lock.t.sol
NonZeroDeltaCount.t.sol
Pool.t.sol
PoolId.t.sol
Position.t.sol
ProtocolFeeLibrary.t.sol
SqrtPriceMath.t.sol
StateLibrary.t.sol
SwapMath.t.sol
TickBitmap.t.sol
TickMath.t.sol
UnsafeMath.t.sol
BalanceDelta.t.sol
Currency.t.sol
Slot0.t.sol
AmountHelpers.sol
Constants.sol
Deployers.sol
JavascriptFfi.sol
LiquidityAmounts.sol
NestedActions.t.sol
SortTokens.sol
SwapHelper.t.sol