Appearance
Solidity API
PropsUniswapHookInternal
_initialize
solidity
function _initialize(address _poolManager, address payable _universalRouter, address _permit2, address _quoter, uint24 fee, struct IPropsUniswapHook.HookPermissions _hookPermissions) internalgetHookPermissions
solidity
function getHookPermissions() public pure returns (struct Hooks.Permissions)Returns the permissions for the hook This is a default implementation that allows all hooks to be called, individual hooks will run/skip based on the hook permissions set in storage
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | struct Hooks.Permissions | Permissions The permissions for the hook |
NotPoolManager
solidity
error NotPoolManager()onlyPoolManager
solidity
modifier onlyPoolManager()Only allow calls from the PoolManager contract
_setHookPermissions
solidity
function _setHookPermissions(struct IPropsUniswapHook.HookPermissions _hookPermissions) internal_getPoolManager
solidity
function _getPoolManager() internal view returns (contract IPoolManager)_getUniversalRouter
solidity
function _getUniversalRouter() internal view returns (contract UniversalRouter)_getPermit2
solidity
function _getPermit2() internal view returns (contract IPermit2)_approveTokenWithPermit2
solidity
function _approveTokenWithPermit2(address token, uint160 amount, uint48 expiration) internal_beforeInitialize
solidity
function _beforeInitialize(bytes4 selector, address sender, struct PoolKey key, uint160 sqrtPriceX96) internal virtual returns (bytes4)The hook called before the state of a pool is initialized
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the initialize call |
| key | struct PoolKey | The key for the pool being initialized |
| sqrtPriceX96 | uint160 | The sqrt(price) of the pool as a Q64.96 |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |
_afterInitialize
solidity
function _afterInitialize(bytes4 selector, address sender, struct PoolKey key, uint160 sqrtPriceX96, int24 tick) internal virtual returns (bytes4)The hook called after the state of a pool is initialized
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the initialize call |
| key | struct 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 |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |
_beforeAddLiquidity
solidity
function _beforeAddLiquidity(bytes4 selector, address sender, struct PoolKey key, struct IPoolManager.ModifyLiquidityParams params, bytes hookData) internal virtual returns (bytes4)The hook called before liquidity is added
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the add liquidity call |
| key | struct PoolKey | The key for the pool |
| params | struct IPoolManager.ModifyLiquidityParams | The parameters for adding liquidity |
| hookData | bytes | Arbitrary data handed into the PoolManager by the liquidity provider to be passed on to the hook |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |
_afterAddLiquidity
solidity
function _afterAddLiquidity(bytes4 selector, address sender, struct PoolKey key, struct IPoolManager.ModifyLiquidityParams params, BalanceDelta delta, BalanceDelta feesAccrued, bytes hookData) internal virtual returns (bytes4, BalanceDelta)The hook called after liquidity is added
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the add liquidity call |
| key | struct PoolKey | The key for the pool |
| params | struct IPoolManager.ModifyLiquidityParams | The parameters for adding liquidity |
| delta | BalanceDelta | The caller's balance delta after adding 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 passed on to the hook |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |
| [1] | BalanceDelta | BalanceDelta The hook's delta in token0 and token1. Positive: the hook is owed/took currency, negative: the hook owes/sent currency |
_beforeRemoveLiquidity
solidity
function _beforeRemoveLiquidity(bytes4 selector, address sender, struct PoolKey key, struct IPoolManager.ModifyLiquidityParams params, bytes hookData) internal virtual returns (bytes4)The hook called before liquidity is removed
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the remove liquidity call |
| key | struct PoolKey | The key for the pool |
| params | struct IPoolManager.ModifyLiquidityParams | The parameters for removing liquidity |
| hookData | bytes | Arbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |
_afterRemoveLiquidity
solidity
function _afterRemoveLiquidity(bytes4 selector, address sender, struct PoolKey key, struct IPoolManager.ModifyLiquidityParams params, BalanceDelta delta, BalanceDelta feesAccrued, bytes hookData) internal virtual returns (bytes4, BalanceDelta)The hook called after liquidity is removed
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the remove liquidity call |
| key | struct PoolKey | The key for the pool |
| params | struct IPoolManager.ModifyLiquidityParams | The parameters for removing liquidity |
| 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 |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |
| [1] | BalanceDelta | BalanceDelta The hook's delta in token0 and token1. Positive: the hook is owed/took currency, negative: the hook owes/sent currency |
_beforeSwap
solidity
function _beforeSwap(bytes4 selector, address sender, struct PoolKey key, struct IPoolManager.SwapParams params, bytes hookData) internal virtual returns (bytes4, BeforeSwapDelta, uint24)The hook called before a swap
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the swap call |
| key | struct PoolKey | The key for the pool |
| params | struct IPoolManager.SwapParams | The parameters for the swap |
| hookData | bytes | Arbitrary data handed into the PoolManager by the swapper to be be passed on to the hook |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |
| [1] | BeforeSwapDelta | BeforeSwapDelta The hook's delta in specified and unspecified currencies. Positive: the hook is owed/took currency, negative: the hook owes/sent currency |
| [2] | uint24 | uint24 Optionally override the lp fee, only used if three conditions are met: 1. the Pool has a dynamic fee, 2. the value's 2nd highest bit is set (23rd bit, 0x400000), and 3. the value is less than or equal to the maximum fee (1 million) |
_afterSwap
solidity
function _afterSwap(bytes4 selector, address sender, struct PoolKey key, struct IPoolManager.SwapParams params, BalanceDelta delta, bytes hookData) internal virtual returns (bytes4, int128)The hook called after a swap
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the swap call |
| key | struct PoolKey | The key for the pool |
| params | struct IPoolManager.SwapParams | The parameters for the swap |
| delta | BalanceDelta | The amount owed to the caller (positive) or owed to the pool (negative) |
| hookData | bytes | Arbitrary data handed into the PoolManager by the swapper to be be passed on to the hook |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |
| [1] | int128 | int128 The hook's delta in unspecified currency. Positive: the hook is owed/took currency, negative: the hook owes/sent currency |
_beforeDonate
solidity
function _beforeDonate(bytes4 selector, address sender, struct PoolKey key, uint256 amount0, uint256 amount1, bytes hookData) internal virtual returns (bytes4)The hook called before donate
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the donate call |
| key | struct PoolKey | The key for the pool |
| amount0 | uint256 | The amount of token0 being donated |
| amount1 | uint256 | The amount of token1 being donated |
| hookData | bytes | Arbitrary data handed into the PoolManager by the donor to be be passed on to the hook |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |
_afterDonate
solidity
function _afterDonate(bytes4 selector, address sender, struct PoolKey key, uint256 amount0, uint256 amount1, bytes hookData) internal virtual returns (bytes4)The hook called after donate
Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | The function selector of the hook |
| sender | address | The initial msg.sender for the donate call |
| key | struct PoolKey | The key for the pool |
| amount0 | uint256 | The amount of token0 being donated |
| amount1 | uint256 | The amount of token1 being donated |
| hookData | bytes | Arbitrary data handed into the PoolManager by the donor to be be passed on to the hook |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes4 | bytes4 The function selector for the hook |