Skip to content

feat: add BatchDistributeHook with @spraay/dex-adapters SDK - #31

Open
plagtech wants to merge 1 commit into
pancakeswap:mainfrom
plagtech:feat/batch-distribute-hook
Open

plagtech wants to merge 1 commit into
pancakeswap:mainfrom
plagtech:feat/batch-distribute-hook

Conversation

@plagtech

@plagtech plagtech commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

Adds a BatchDistributeHook that connects Spraay Protocol's on-chain batch payment contract to PancakeSwap Infinity, giving pool operators push-model token distribution — send ERC-20 tokens or native BNB/ETH to up to 200 recipients in one transaction.

This hook is now part of the @spraay/dex-adapters SDK on npm, which provides a unified TypeScript interface for batch distribution across DEXes (PancakeSwap, SushiSwap, and direct Spraay calls). Developers can integrate without touching Solidity:

npm install @spraay/dex-adapters viem
import { deployHook, distribute } from '@spraay/dex-adapters/pancakeswap'

const { address: hook } = await deployHook({ chain: bsc, walletClient, publicClient, operator: account })
await distribute({ hook, poolId, token: TOKEN, recipients, amounts, chain: bsc, walletClient, publicClient })

The SDK handles deployment, operator management, pool registration, fee calculation, allowance checks, and simulation — all through the same distribute / distributeEqual / estimateCost interface shared across adapters.

Source: github.com/plagtech/spraay-dex-adapters

How it works

  • Operators call batchDistribute or batchDistributeEqual on the hook, which forwards to Spraay's verified sprayToken / sprayETH / sprayEqual contracts
  • afterInitialize registers pools; afterDonate emits DonationReceived events for indexer correlation
  • The hook is non-custodial — each call pulls exactly amount + fee from the operator, approves Spraay, and calls it in the same transaction. Nothing stays in the hook
  • The 30 bps protocol fee is handled inside the Spraay contract
  • Constructor takes the Spraay contract address as a parameter — deploy with different addresses per chain

Files added

This PR adds files only — no existing files are modified.

  • src/pool-cl/batch-distribute/BatchDistributeHook.sol — hook contract
  • src/pool-cl/batch-distribute/interfaces/ISpraay.sol — Spraay interface (matches deployed bytecode)
  • src/pool-cl/batch-distribute/SpraayAddresses.sol — verified contract addresses
  • script/06_DeployBatchDistributeHook.s.sol + config files — deployment scripts for BNB Chain and Base
  • test/pool-cl/BatchDistributeHook.t.sol — 26 unit tests
  • test/pool-cl/BatchDistributeHook.fork.t.sol — 2 fork tests against live Spraay contracts

Supported chains

Chain Spraay Contract Status
BNB Chain 0x3093a2951FB77b3beDfB8BA20De645F7413432C1 ✅ Verified on Sourcify
Base 0x1646452F98E36A3c9Cfc3eDD8868221E207B5eEC ✅ Verified on Sourcify

Test plan

  • 26 unit tests passing (mock Spraay contract)
  • 2 fork tests against live Spraay contracts on BNB Chain and Base
  • Mainnet deploy

Disclosure

I am the author of Spraay Protocol. This PR and the @spraay/dex-adapters SDK are offered as open-source tooling for the PancakeSwap ecosystem.

## Summary

Adds a BatchDistributeHook that connects [Spraay Protocol](https://spraay.app)'s on-chain batch payment contract to PancakeSwap Infinity, giving pool operators push-model token distribution — send ERC-20 tokens or native BNB/ETH to up to 200 recipients in one transaction.

This hook is now part of the [@spraay/dex-adapters](https://www.npmjs.com/package/@spraay/dex-adapters) SDK on npm, which provides a unified TypeScript interface for batch distribution across DEXes (PancakeSwap, SushiSwap, and direct Spraay calls). Developers can integrate without touching Solidity:

npm install @spraay/dex-adapters viem
import { deployHook, distribute } from '@spraay/dex-adapters/pancakeswap'

const { address: hook } = await deployHook({ chain: bsc, walletClient, publicClient, operator: account })
await distribute({ hook, poolId, token: TOKEN, recipients, amounts, chain: bsc, walletClient, publicClient })

The SDK handles deployment, operator management, pool registration, fee calculation, allowance checks, and simulation — all through the same distribute / distributeEqual / estimateCost interface shared across adapters.

Source: [github.com/plagtech/spraay-dex-adapters](https://github.com/plagtech/spraay-dex-adapters)

How it works

  • Operators call batchDistribute or batchDistributeEqual on the hook, which forwards to Spraay's verified sprayToken / sprayETH / sprayEqual contracts
  • afterInitialize registers pools; afterDonate emits DonationReceived events for indexer correlation
  • The hook is non-custodial — each call pulls exactly amount + fee from the operator, approves Spraay, and calls it in the same transaction. Nothing stays in the hook
  • The 30 bps protocol fee is handled inside the Spraay contract
  • Constructor takes the Spraay contract address as a parameter — deploy with different addresses per chain

Files added

This PR adds files only — no existing files are modified.

  • src/pool-cl/batch-distribute/BatchDistributeHook.sol — hook contract
  • src/pool-cl/batch-distribute/interfaces/ISpraay.sol — Spraay interface (matches deployed bytecode)
  • src/pool-cl/batch-distribute/SpraayAddresses.sol — verified contract addresses
  • script/06_DeployBatchDistributeHook.s.sol + config files — deployment scripts for BNB Chain and Base
  • test/pool-cl/BatchDistributeHook.t.sol — 26 unit tests
  • test/pool-cl/BatchDistributeHook.fork.t.sol — 2 fork tests against live Spraay contracts

Supported chains

Chain Spraay Contract Status
BNB Chain 0x3093a2951FB77b3beDfB8BA20De645F7413432C1 ✅ Verified on Sourcify
Base 0x1646452F98E36A3c9Cfc3eDD8868221E207B5eEC ✅ Verified on Sourcify

Test plan

  • 26 unit tests passing (mock Spraay contract)
  • 2 fork tests against live Spraay contracts on BNB Chain and Base
  • Mainnet deploy

Disclosure

I am the author of Spraay Protocol. This PR and the @spraay/dex-adapters SDK are offered as open-source tooling for the PancakeSwap ecosystem.

Adds a PancakeSwap Infinity hook that integrates Spraay Protocol's
on-chain batch payment contract, enabling pool operators to push-distribute
tokens (ERC-20 and native BNB/ETH) to up to 200 recipients in a single
transaction. Supports BNB Chain and Base.

- src/pool-cl/batch-distribute/BatchDistributeHook.sol
- Deploy scripts and chain configs for BSC and Base mainnet
- 26 unit tests + 2 live fork tests (all passing)
- No existing files modified
@plagtech plagtech changed the title feat: add BatchDistributeHook for Spraay push-model batch distribution feat: add BatchDistributeHook with @spraay/dex-adapters SDK Oct 13, 2026
@plagtech

Copy link
Copy Markdown
Author

Cross-link: the same push-model BatchDistributeHook is now available for Uniswap V4.

The Solidity logic is identical to this PR; only the hook harness changed (V4 encodes permissions in the hook address instead of PoolKey.parameters).

Other DEX integrations: sushi-labs/sushiswap#2324, balancer/scaffold-balancer-v3#138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant