Skip to content

Solidity API

PropsUniswapHookInternal

_initialize

solidity
function _initialize(address _poolManager, address payable _universalRouter, address _permit2, address _quoter, uint24 fee, struct IPropsUniswapHook.HookPermissions _hookPermissions) internal

getHookPermissions

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

NameTypeDescription
[0]struct Hooks.PermissionsPermissions 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the initialize call
keystruct PoolKeyThe key for the pool being initialized
sqrtPriceX96uint160The sqrt(price) of the pool as a Q64.96

Return Values

NameTypeDescription
[0]bytes4bytes4 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the initialize call
keystruct PoolKeyThe key for the pool being initialized
sqrtPriceX96uint160The sqrt(price) of the pool as a Q64.96
tickint24The current tick after the state of a pool is initialized

Return Values

NameTypeDescription
[0]bytes4bytes4 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the add liquidity call
keystruct PoolKeyThe key for the pool
paramsstruct IPoolManager.ModifyLiquidityParamsThe parameters for adding liquidity
hookDatabytesArbitrary data handed into the PoolManager by the liquidity provider to be passed on to the hook

Return Values

NameTypeDescription
[0]bytes4bytes4 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the add liquidity call
keystruct PoolKeyThe key for the pool
paramsstruct IPoolManager.ModifyLiquidityParamsThe parameters for adding liquidity
deltaBalanceDeltaThe caller's balance delta after adding liquidity; the sum of principal delta, fees accrued, and hook delta
feesAccruedBalanceDeltaThe fees accrued since the last time fees were collected from this position
hookDatabytesArbitrary data handed into the PoolManager by the liquidity provider to be passed on to the hook

Return Values

NameTypeDescription
[0]bytes4bytes4 The function selector for the hook
[1]BalanceDeltaBalanceDelta 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the remove liquidity call
keystruct PoolKeyThe key for the pool
paramsstruct IPoolManager.ModifyLiquidityParamsThe parameters for removing liquidity
hookDatabytesArbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook

Return Values

NameTypeDescription
[0]bytes4bytes4 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the remove liquidity call
keystruct PoolKeyThe key for the pool
paramsstruct IPoolManager.ModifyLiquidityParamsThe parameters for removing liquidity
deltaBalanceDeltaThe caller's balance delta after removing liquidity; the sum of principal delta, fees accrued, and hook delta
feesAccruedBalanceDeltaThe fees accrued since the last time fees were collected from this position
hookDatabytesArbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook

Return Values

NameTypeDescription
[0]bytes4bytes4 The function selector for the hook
[1]BalanceDeltaBalanceDelta 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the swap call
keystruct PoolKeyThe key for the pool
paramsstruct IPoolManager.SwapParamsThe parameters for the swap
hookDatabytesArbitrary data handed into the PoolManager by the swapper to be be passed on to the hook

Return Values

NameTypeDescription
[0]bytes4bytes4 The function selector for the hook
[1]BeforeSwapDeltaBeforeSwapDelta The hook's delta in specified and unspecified currencies. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
[2]uint24uint24 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the swap call
keystruct PoolKeyThe key for the pool
paramsstruct IPoolManager.SwapParamsThe parameters for the swap
deltaBalanceDeltaThe amount owed to the caller (positive) or owed to the pool (negative)
hookDatabytesArbitrary data handed into the PoolManager by the swapper to be be passed on to the hook

Return Values

NameTypeDescription
[0]bytes4bytes4 The function selector for the hook
[1]int128int128 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the donate call
keystruct PoolKeyThe key for the pool
amount0uint256The amount of token0 being donated
amount1uint256The amount of token1 being donated
hookDatabytesArbitrary data handed into the PoolManager by the donor to be be passed on to the hook

Return Values

NameTypeDescription
[0]bytes4bytes4 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

NameTypeDescription
selectorbytes4The function selector of the hook
senderaddressThe initial msg.sender for the donate call
keystruct PoolKeyThe key for the pool
amount0uint256The amount of token0 being donated
amount1uint256The amount of token1 being donated
hookDatabytesArbitrary data handed into the PoolManager by the donor to be be passed on to the hook

Return Values

NameTypeDescription
[0]bytes4bytes4 The function selector for the hook