diff --git a/docs/pages/contracts/infinity/guides/develop-a-hook.mdx b/docs/pages/contracts/infinity/guides/develop-a-hook.mdx index ab112de..34780b4 100644 --- a/docs/pages/contracts/infinity/guides/develop-a-hook.mdx +++ b/docs/pages/contracts/infinity/guides/develop-a-hook.mdx @@ -56,7 +56,7 @@ contract CLCounterHook is CLBaseHook { // 2. For each callback required, overwrite the method function _beforeAddLiquidity(address, PoolKey calldata key, ICLPoolManager.ModifyLiquidityParams calldata, bytes calldata) - external override poolManagerOnly returns (bytes4) { + internal override returns (bytes4) { // implement hook logic and then return selector return this.beforeAddLiquidity.selector; } @@ -119,10 +119,10 @@ contract VeCakeSwapDiscountHook is CLBaseHook { // [!code focus] afterSwap: false, beforeDonate: false, afterDonate: false, - beforeSwapReturnsDelta: false, - afterSwapReturnsDelta: false, - afterAddLiquidityReturnsDelta: false, - afterRemoveLiquidityReturnsDelta: false + beforeSwapReturnDelta: false, + afterSwapReturnDelta: false, + afterAddLiquidityReturnDelta: false, + afterRemoveLiquidityReturnDelta: false }) ); } @@ -151,8 +151,8 @@ function setLpFee(PoolKey calldata key, uint24 lpFee) external { Note the return value need to include `LPFeeLibrary.OVERRIDE_FEE_FLAG` so pool manager knows the intention is to override swap fee. ```solidity -function beforeSwap(address, PoolKey calldata key, ICLPoolManager.SwapParams calldata, bytes calldata) - external view override poolManagerOnly returns (bytes4, BeforeSwapDelta, uint24) +function _beforeSwap(address, PoolKey calldata key, ICLPoolManager.SwapParams calldata, bytes calldata) + internal view override returns (bytes4, BeforeSwapDelta, uint24) { uint24 lpFee = poolIdToLpFee[key.toId()]; diff --git a/docs/pages/contracts/infinity/guides/hook-examples/overwriting-amm-curve.mdx b/docs/pages/contracts/infinity/guides/hook-examples/overwriting-amm-curve.mdx index 1b4d43a..b8413bd 100644 --- a/docs/pages/contracts/infinity/guides/hook-examples/overwriting-amm-curve.mdx +++ b/docs/pages/contracts/infinity/guides/hook-examples/overwriting-amm-curve.mdx @@ -29,7 +29,7 @@ For example if the user swap `exactIn 100 token0 for token1` with `-100 amountSp Take note of -1. The hook permission which includes `beforeSwapReturnsDelta` as the hook modify the delta in beforeSwap. +1. The hook permission which includes `beforeSwapReturnDelta` as the hook modify the delta in beforeSwap. 2. How the hook take/settle the currency and the BeforeSwapDelta returned.
diff --git a/docs/pages/contracts/infinity/guides/hook-examples/taking-fee-via-hook.mdx b/docs/pages/contracts/infinity/guides/hook-examples/taking-fee-via-hook.mdx index 310adc9..ba00a87 100644 --- a/docs/pages/contracts/infinity/guides/hook-examples/taking-fee-via-hook.mdx +++ b/docs/pages/contracts/infinity/guides/hook-examples/taking-fee-via-hook.mdx @@ -21,14 +21,14 @@ In the `afterRemoveLiquidity()` callback, we calculate the fee based on the amou ```solidity /// @param delta The caller's balance delta after removing liquidity; the sum of principal delta, fees accrued, and hook delta -function afterRemoveLiquidity +function _afterRemoveLiquidity (address sender, PoolKey calldata key, ICLPoolManager.ModifyLiquidityParams calldata params, BalanceDelta delta, BalanceDelta feesAccrued, bytes calldata hookData -) external override poolManagerOnly returns (bytes4, BalanceDelta) { +) internal override returns (bytes4, BalanceDelta) { // calculate how much fee uint128 amt0Fee = uint128(delta.amount0()) / 10; @@ -39,7 +39,7 @@ function afterRemoveLiquidity Take note of -1. The hook permission which includes `afterRemoveLiquidityReturnsDelta` as the hook modify the delta in afterRemoveLiquidity(). +1. The hook permission which includes `afterRemoveLiquidityReturnDelta` as the hook modify the delta in afterRemoveLiquidity().
View complete source code here diff --git a/docs/pages/contracts/infinity/overview/custom-layer-hook.mdx b/docs/pages/contracts/infinity/overview/custom-layer-hook.mdx index 98e9cc5..c72c9d9 100644 --- a/docs/pages/contracts/infinity/overview/custom-layer-hook.mdx +++ b/docs/pages/contracts/infinity/overview/custom-layer-hook.mdx @@ -33,10 +33,10 @@ function getHooksRegistrationBitmap() external pure override returns (uint16) { afterDonate: false, // Hook return delta (documented below) - beforeSwapReturnsDelta: false, - afterSwapReturnsDelta: false, - afterAddLiquidityReturnsDelta: false, - afterRemoveLiquidityReturnsDelta: false + beforeSwapReturnDelta: false, + afterSwapReturnDelta: false, + afterAddLiquidityReturnDelta: false, + afterRemoveLiquidityReturnDelta: false }) ); } @@ -72,10 +72,10 @@ function getHooksRegistrationBitmap() external pure override returns (uint16) { Permissions({ // The 4 permissions around modifying return delta - beforeSwapReturnsDelta: false, // during beforeSwap - afterSwapReturnsDelta: false, // during afterSwap - afterAddLiquidityReturnsDelta: false, // during afterAddLiquidity - afterRemoveLiquidityReturnsDelta: false // during afterRemoveLiquidity + beforeSwapReturnDelta: false, // during beforeSwap + afterSwapReturnDelta: false, // during afterSwap + afterAddLiquidityReturnDelta: false, // during afterAddLiquidity + afterRemoveLiquidityReturnDelta: false // during afterRemoveLiquidity }) ); }