Skip to content

Commit

Permalink
Update v4 Technical Reference (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint authored Nov 14, 2024
1 parent dcc22c5 commit 46c2c78
Show file tree
Hide file tree
Showing 134 changed files with 2,090 additions and 692 deletions.
3 changes: 1 addition & 2 deletions docs/contracts/v4/reference/core/ERC6909.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# ERC6909
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/ERC6909.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/ERC6909.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

**Inherits:**
[IERC6909Claims](contracts/v4/reference/core/interfaces/IERC6909Claims.md)
Expand Down
3 changes: 1 addition & 2 deletions docs/contracts/v4/reference/core/ERC6909Claims.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# ERC6909Claims
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/ERC6909Claims.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/ERC6909Claims.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

**Inherits:**
[ERC6909](contracts/v4/reference/core/ERC6909.md)
Expand Down
3 changes: 1 addition & 2 deletions docs/contracts/v4/reference/core/Extsload.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Extsload
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/Extsload.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/Extsload.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

**Inherits:**
[IExtsload](contracts/v4/reference/core/interfaces/IExtsload.md)
Expand Down
3 changes: 1 addition & 2 deletions docs/contracts/v4/reference/core/Exttload.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Exttload
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/Exttload.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/Exttload.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

**Inherits:**
[IExttload](contracts/v4/reference/core/interfaces/IExttload.md)
Expand Down
3 changes: 1 addition & 2 deletions docs/contracts/v4/reference/core/NoDelegateCall.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# NoDelegateCall
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/NoDelegateCall.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/NoDelegateCall.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

Base contract that provides a modifier for preventing delegatecall to methods in a child contract

Expand Down
20 changes: 11 additions & 9 deletions docs/contracts/v4/reference/core/PoolManager.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# PoolManager
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/PoolManager.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/PoolManager.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

**Inherits:**
[IPoolManager](contracts/v4/reference/core/interfaces/IPoolManager.md), [ProtocolFees](contracts/v4/reference/core/ProtocolFees.md), [NoDelegateCall](contracts/v4/reference/core/NoDelegateCall.md), [ERC6909Claims](contracts/v4/reference/core/ERC6909Claims.md), [Extsload](contracts/v4/reference/core/Extsload.md), [Exttload](contracts/v4/reference/core/Exttload.md)
Expand Down Expand Up @@ -40,6 +39,13 @@ This will revert if the contract is locked
modifier onlyWhenUnlocked();
```

### constructor


```solidity
constructor(address initialOwner) ProtocolFees(initialOwner);
```

### unlock

All interactions on the contract that account deltas require unlocking. A caller that calls `unlock` must implement
Expand Down Expand Up @@ -72,18 +78,14 @@ Initialize the state for a given pool ID


```solidity
function initialize(PoolKey memory key, uint160 sqrtPriceX96, bytes calldata hookData)
external
noDelegateCall
returns (int24 tick);
function initialize(PoolKey memory key, uint160 sqrtPriceX96) external noDelegateCall returns (int24 tick);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`key`|`PoolKey`|The pool key for the pool to initialize|
|`sqrtPriceX96`|`uint160`|The initial square root price|
|`hookData`|`bytes`|The data to pass through to the initialize hooks|

**Returns**

Expand Down Expand Up @@ -207,14 +209,14 @@ native funds, this function can be called with the native currency to then be ab


```solidity
function sync(Currency currency) external onlyWhenUnlocked;
function sync(Currency currency) external;
```

### take

Called by the user to net out some value owed to the user

*Can also be used as a mechanism for _free_ flash loans*
*Will revert if the requested amount is not available, consider using `mint` instead*


```solidity
Expand Down
32 changes: 5 additions & 27 deletions docs/contracts/v4/reference/core/ProtocolFees.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# ProtocolFees
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/ProtocolFees.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/ProtocolFees.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

**Inherits:**
[IProtocolFees](contracts/v4/reference/core/interfaces/IProtocolFees.md), Owned
Expand All @@ -23,14 +22,7 @@ Returns the current protocol fee controller address


```solidity
IProtocolFeeController public protocolFeeController;
```


### BLOCK_LIMIT_BPS

```solidity
uint256 private constant BLOCK_LIMIT_BPS = 100;
address public protocolFeeController;
```


Expand All @@ -39,7 +31,7 @@ uint256 private constant BLOCK_LIMIT_BPS = 100;


```solidity
constructor() Owned(msg.sender);
constructor(address initialOwner) Owned(initialOwner);
```

### setProtocolFeeController
Expand All @@ -48,13 +40,13 @@ Sets the protocol fee controller


```solidity
function setProtocolFeeController(IProtocolFeeController controller) external onlyOwner;
function setProtocolFeeController(address controller) external onlyOwner;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`controller`|`IProtocolFeeController`|The new protocol fee controller|
|`controller`|`address`|The new protocol fee controller|


### setProtocolFee
Expand Down Expand Up @@ -120,20 +112,6 @@ function _isUnlocked() internal virtual returns (bool);
function _getPool(PoolId id) internal virtual returns (Pool.State storage);
```

### _fetchProtocolFee

Fetch the protocol fees for a given pool

*the success of this function is false if the call fails or the returned fees are invalid*

*to prevent an invalid protocol fee controller from blocking pools from being initialized
the success of this function is NOT checked on initialize and if the call fails, the protocol fees are set to 0.*


```solidity
function _fetchProtocolFee(PoolKey memory key) internal returns (uint24 protocolFee);
```

### _updateProtocolFees


Expand Down
3 changes: 1 addition & 2 deletions docs/contracts/v4/reference/core/interfaces/IERC20Minimal.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# IERC20Minimal
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/interfaces/external/IERC20Minimal.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/interfaces/external/IERC20Minimal.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

Contains a subset of the full ERC20 interface that is used in Uniswap V3

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# IERC6909Claims
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/interfaces/external/IERC6909Claims.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/interfaces/external/IERC6909Claims.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

Interface for claims over a contract balance, wrapped as a ERC6909

Expand Down
3 changes: 1 addition & 2 deletions docs/contracts/v4/reference/core/interfaces/IExtsload.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# IExtsload
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/interfaces/IExtsload.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/interfaces/IExtsload.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

Interface for functions to access any storage slot in a contract

Expand Down
3 changes: 1 addition & 2 deletions docs/contracts/v4/reference/core/interfaces/IExttload.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# IExttload
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/interfaces/IExttload.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/interfaces/IExttload.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

Interface for functions to access any transient storage slot in a contract

Expand Down
21 changes: 6 additions & 15 deletions docs/contracts/v4/reference/core/interfaces/IHooks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# IHooks
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/interfaces/IHooks.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/interfaces/IHooks.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

V4 decides whether to invoke specific hooks by inspecting the least significant bits
of the address that the hooks contract is deployed to.
Expand All @@ -18,9 +17,7 @@ The hook called before the state of a pool is initialized


```solidity
function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, bytes calldata hookData)
external
returns (bytes4);
function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96) external returns (bytes4);
```
**Parameters**

Expand All @@ -29,7 +26,6 @@ function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPric
|`sender`|`address`|The initial msg.sender for the initialize call|
|`key`|`PoolKey`|The key for the pool being initialized|
|`sqrtPriceX96`|`uint160`|The sqrt(price) of the pool as a Q64.96|
|`hookData`|`bytes`|Arbitrary data handed into the PoolManager by the initializer to be be passed on to the hook|

**Returns**

Expand All @@ -44,13 +40,9 @@ The hook called after the state of a pool is initialized


```solidity
function afterInitialize(
address sender,
PoolKey calldata key,
uint160 sqrtPriceX96,
int24 tick,
bytes calldata hookData
) external returns (bytes4);
function afterInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, int24 tick)
external
returns (bytes4);
```
**Parameters**

Expand All @@ -60,7 +52,6 @@ function afterInitialize(
|`key`|`PoolKey`|The key for the pool being initialized|
|`sqrtPriceX96`|`uint160`|The sqrt(price) of the pool as a Q64.96|
|`tick`|`int24`|The current tick after the state of a pool is initialized|
|`hookData`|`bytes`|Arbitrary data handed into the PoolManager by the initializer to be be passed on to the hook|

**Returns**

Expand Down Expand Up @@ -183,7 +174,7 @@ function afterRemoveLiquidity(
|`sender`|`address`|The initial msg.sender for the remove liquidity call|
|`key`|`PoolKey`|The key for the pool|
|`params`|`IPoolManager.ModifyLiquidityParams`|The parameters for removing liquidity|
|`delta`|`BalanceDelta`|The caller's balance delta after adding liquidity; the sum of principal delta, fees accrued, and hook delta|
|`delta`|`BalanceDelta`|The caller's balance delta after removing liquidity; the sum of principal delta, fees accrued, and hook delta|
|`feesAccrued`|`BalanceDelta`|The fees accrued since the last time fees were collected from this position|
|`hookData`|`bytes`|Arbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook|

Expand Down
12 changes: 6 additions & 6 deletions docs/contracts/v4/reference/core/interfaces/IPoolManager.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# IPoolManager
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/interfaces/IPoolManager.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/interfaces/IPoolManager.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

**Inherits:**
[IProtocolFees](contracts/v4/reference/core/interfaces/IProtocolFees.md), [IERC6909Claims](contracts/v4/reference/core/interfaces/IERC6909Claims.md), [IExtsload](contracts/v4/reference/core/interfaces/IExtsload.md), [IExttload](contracts/v4/reference/core/interfaces/IExttload.md)
Expand Down Expand Up @@ -41,15 +40,14 @@ Initialize the state for a given pool ID


```solidity
function initialize(PoolKey memory key, uint160 sqrtPriceX96, bytes calldata hookData) external returns (int24 tick);
function initialize(PoolKey memory key, uint160 sqrtPriceX96) external returns (int24 tick);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`key`|`PoolKey`|The pool key for the pool to initialize|
|`sqrtPriceX96`|`uint160`|The initial square root price|
|`hookData`|`bytes`|The data to pass through to the initialize hooks|

**Returns**

Expand Down Expand Up @@ -168,7 +166,9 @@ function sync(Currency currency) external;

Called by the user to net out some value owed to the user

*Can also be used as a mechanism for _free_ flash loans*
*Will revert if the requested amount is not available, consider using `mint` instead*

*Can also be used as a mechanism for free flash loans*


```solidity
Expand Down Expand Up @@ -319,7 +319,7 @@ event Initialize(
|`tickSpacing`|`int24`|The minimum number of ticks between initialized ticks|
|`hooks`|`IHooks`|The hooks contract address for the pool, or address(0) if none|
|`sqrtPriceX96`|`uint160`|The price of the pool on initialization|
|`tick`|`int24`|The initial tick of the pool corresponding to the intialized price|
|`tick`|`int24`|The initial tick of the pool corresponding to the initialized price|

### ModifyLiquidity
Emitted when a liquidity position is modified
Expand Down
31 changes: 11 additions & 20 deletions docs/contracts/v4/reference/core/interfaces/IProtocolFees.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# IProtocolFees
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/interfaces/IProtocolFees.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/interfaces/IProtocolFees.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

Interface for all protocol-fee related functions in the pool manager

Expand Down Expand Up @@ -49,13 +48,13 @@ Sets the protocol fee controller


```solidity
function setProtocolFeeController(IProtocolFeeController controller) external;
function setProtocolFeeController(address controller) external;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`controller`|`IProtocolFeeController`|The new protocol fee controller|
|`controller`|`address`|The new protocol fee controller|


### collectProtocolFees
Expand Down Expand Up @@ -91,13 +90,13 @@ Returns the current protocol fee controller address


```solidity
function protocolFeeController() external view returns (IProtocolFeeController);
function protocolFeeController() external view returns (address);
```
**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`IProtocolFeeController`|IProtocolFeeController The currency protocol fee controller|
|`<none>`|`address`|address The current protocol fee controller address|


## Events
Expand All @@ -118,14 +117,6 @@ event ProtocolFeeUpdated(PoolId indexed id, uint24 protocolFee);
```

## Errors
### ProtocolFeeCannotBeFetched
Thrown when not enough gas is provided to look up the protocol fee


```solidity
error ProtocolFeeCannotBeFetched();
```

### ProtocolFeeTooLarge
Thrown when protocol fee is set too high

Expand All @@ -134,19 +125,19 @@ Thrown when protocol fee is set too high
error ProtocolFeeTooLarge(uint24 fee);
```

### ContractUnlocked
Thrown when the contract is unlocked
### InvalidCaller
Thrown when collectProtocolFees or setProtocolFee is not called by the controller.


```solidity
error ContractUnlocked();
error InvalidCaller();
```

### InvalidCaller
Thrown when collectProtocolFees or setProtocolFee is not called by the controller.
### ProtocolFeeCurrencySynced
Thrown when collectProtocolFees is attempted on a token that is synced.


```solidity
error InvalidCaller();
error ProtocolFeeCurrencySynced();
```

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# IUnlockCallback
[Git Source](https://github.com/Uniswap/v4-core/blob/1141642f8ba4665a50660886a8a8401526677045/src/interfaces/callback/IUnlockCallback.sol)
| Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)
[Git Source](https://github.com/uniswap/v4-core/blob/b619b6718e31aa5b4fa0286520c455ceb950276d/src/interfaces/callback/IUnlockCallback.sol) - Generated with [forge doc](https://book.getfoundry.sh/reference/forge/forge-doc)

Interface for the callback executed when an address unlocks the pool manager

Expand Down
Loading

0 comments on commit 46c2c78

Please sign in to comment.