Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/pages/contracts/infinity/guides/develop-a-hook.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
})
);
}
Expand Down Expand Up @@ -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()];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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().

<details>
<summary> View complete source code here </summary>
Expand Down
16 changes: 8 additions & 8 deletions docs/pages/contracts/infinity/overview/custom-layer-hook.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
);
}
Expand Down Expand Up @@ -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
})
);
}
Expand Down