Repository navigation
Conversation
…tion Example hook: operators push-distribute ERC-20 or native tokens to up to 200 recipients per call through Spraay. afterInitialize registers pools, afterDonate emits PoolDonation for indexing; no deltas, swaps unaffected. Includes unit tests (incl. initialize/donate/settle round trip), Base + BNB fork tests, gas comparison, and a HookMiner-based deploy script.
This was referenced Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add BatchDistributeHook — Spraay multi-recipient batch distribution
What it does
BatchDistributeHooklets a pool's operators push ERC-20 or native tokens to up to 200 recipients in one transaction, routed through Spraay's on-chain batch contract. V4's own incentive paths (LP fees,donate()) are pull-based and only reach in-range LPs; this adds a push path to any address (contributors, market makers, airdrops, revenue shares) with no claim step for recipients.How it works
BaseHook, matching this template's stack (uniswap-hooks + hookmate).afterInitialize(registers pools created with the hook, so every distribution is attributed to a realPoolId) andafterDonate(emitsPoolDonationso indexers see pull-side and push-side incentives together). Neither returns a delta; swaps and liquidity are unaffected. Hook address flags:0x…1010.amount + Spraay feefrom the operator, approves Spraay for exactly that, and callssprayToken/sprayETH/sprayEqualin the same tx. Excess native currency is refunded.Ownable2Stepowner (operators, Spraay address, rescue) and operators (trigger + fund distributions).calculateTotalCost.Gas (ERC-20, fresh recipients, execution gas incl. 21k base)
A bare loop contract is 8–15% cheaper; the hook adds non-custodial funding, roles, native support with refunds, and pool attribution. Reproduce:
forge test --match-contract BatchDistributeHookGasTest -vv.Tests
donate→settleround trip through PoolManager.BASE_RPC_URL/BSC_RPC_URL).HookMinerand prints the verify command.Chain support
Base and BNB Chain (where Spraay and the V4 PoolManager are both live).
Links
@spraay/dex-adapters/uniswap-v4(CREATE2 mining + deploy, distribute, admin)