Skip to content
Merged
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
7 changes: 5 additions & 2 deletions docs/contracts/v4/guides/08-custom-accounting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ uint256 feeAmount = (swapAmount * HOOK_FEE_PERCENTAGE) / FEE_DENOMINATOR;
We use `poolManager.take` to collect the fee. This creates a debt for our hook in the specified currency.

```solidity
Currency feeCurrency = params.zeroForOne ? key.currency0 : key.currency1;
Currency feeCurrency;

feeCurrency = params.amountSpecified < 0 == params.zeroForOne ? key.currency0 : key.currency1;

poolManager.take(feeCurrency, address(this), feeAmount);

```
Expand Down Expand Up @@ -235,4 +238,4 @@ This process demonstrates how `BeforeSwapDelta` effectively "transfers" the hook

## Conclusion

By implementing hook fees this way, we've leveraged Uniswap v4's delta accounting system to create a seamless fee collection mechanism. This approach allows for complex fee structures and behaviors without disrupting the core swap process or requiring separate fee transfers.
By implementing hook fees this way, we've leveraged Uniswap v4's delta accounting system to create a seamless fee collection mechanism. This approach allows for complex fee structures and behaviors without disrupting the core swap process or requiring separate fee transfers.