PancakeV3Aggregator
BSCPancakeV3Aggregator is a Uniswap v4 hook on BSC. Brand new: its first pool went live today.
- Contract name
- PancakeV3Aggregator
How this hook works
Trading taxA trading tax hook. It takes a cut of every trade, limits some actions to approved addresses and stops liquidity being added directly.
Takes a cut of every trade
On top of the normal pool fee, it keeps a share of each trade. It can never be above 0.05%. The fee is paid out in the same trade.
The code that does this (pancakeV3SwapCallback):function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external override { (PoolId poolId, bool isQuote) = abi.decode(data, (PoolId, bool)); if (isQuote) revert QuoteRevert(amount0Delta, amount1Delta); address expectedPool = _transientExpectedPool(); if (expectedPool == address(0)) revert CallbackOutsideActiveSwap(); if (msg.sender != expectedPool) revert UnauthorizedCallback(); if (PoolId.unwrap(poolId) != _transientExpectedPoolId()) revert UnauthorizedCallback(); if (poolIdToExternalPool[poolId] != msg.sender) revert UnauthorizedCallback(); PoolKey storage canonical = _canonicalPoolKeyByAddress[msg.sender]; Currency owedCurrency; uint256 owedAmt; if (amount0Delta > 0 && amount1Delta <= 0) { owedCurrency = canonical.currency0; owedAmt = uint256(amount0Delta); } else if (amount1Delta > 0 && amount0Delta <= 0) { owedCurrency = canonical.currency1; owedAmt = uint256(amount1Delta); } else { revert UnexpectedSwapOutputDelta(); } _setTransientSwapInputPaid(owedAmt); poolManager.take(owedCurrency, msg.sender, owedAmt); }Approved addresses only
Some actions are limited to addresses on an approved list.
The code that does this (beforeInitialize):function _beforeInitialize(address, PoolKey calldata key, uint160 sqrtPriceX96) internal override returns (bytes4) { if (sqrtPriceX96 != SQRT_PRICE_1_1) revert InvalidSqrtPrice(sqrtPriceX96); if (key.currency0.isAddressZero() || key.currency1.isAddressZero()) revert NativeCurrencyNotSupported(); if (key.fee == 0 || key.fee >= LPFeeLibrary.MAX_LP_FEE) revert ExternalPoolMismatch(); address token0 = Currency.unwrap(key.currency0); address token1 = Currency.unwrap(key.currency1); address poolAddr = IPancakeV3Factory(factory).getPool(token0, token1, key.fee); if (poolAddr == address(0)) revert ExternalPoolNotFound(); if (!isAllowedExternalPool[poolAddr]) revert ExternalPoolNotAllowed(); if (IPancakeV3Pool(poolAddr).token0() != token0 || IPancakeV3Pool(poolAddr).token1() != token1) { revert ExternalPoolMismatch(); } if (IPancakeV3Pool(poolAddr).fee() != key.fee) revert ExternalPoolMismatch(); if (IPancakeV3Pool(poolAddr).tickSpacing() != key.tickSpacing) revert ExternalPoolMismatch(); PoolKey storage existing = _canonicalPoolKeyByAddress[poolAddr]; if (address(existing.hooks) != address(0)) revert PairAlreadyHasCanonicalPool(existing.toId()); _canonicalPoolKeyByAddress[poolAddr] = key; PoolId id = key.toId(); poolIdToExternalPool[id] = poolAddr; _initializedPools.push(key); emit AggregatorPoolRegistered(id); pollTokenJar(); return IHooks.beforeInitialize.selector; // …Liquidity can’t be added directly
Nobody can add liquidity to its pools through Uniswap directly. Liquidity only comes in through the hook’s own code.
Only approved callers create pools
New pools with this hook can only be created by approved callers, for example its own factory or launcher.
The code that does this (beforeInitialize):function _beforeInitialize(address, PoolKey calldata key, uint160 sqrtPriceX96) internal override returns (bytes4) { if (sqrtPriceX96 != SQRT_PRICE_1_1) revert InvalidSqrtPrice(sqrtPriceX96); if (key.currency0.isAddressZero() || key.currency1.isAddressZero()) revert NativeCurrencyNotSupported(); if (key.fee == 0 || key.fee >= LPFeeLibrary.MAX_LP_FEE) revert ExternalPoolMismatch(); address token0 = Currency.unwrap(key.currency0); address token1 = Currency.unwrap(key.currency1); address poolAddr = IPancakeV3Factory(factory).getPool(token0, token1, key.fee); if (poolAddr == address(0)) revert ExternalPoolNotFound(); if (!isAllowedExternalPool[poolAddr]) revert ExternalPoolNotAllowed(); if (IPancakeV3Pool(poolAddr).token0() != token0 || IPancakeV3Pool(poolAddr).token1() != token1) { revert ExternalPoolMismatch(); } if (IPancakeV3Pool(poolAddr).fee() != key.fee) revert ExternalPoolMismatch(); if (IPancakeV3Pool(poolAddr).tickSpacing() != key.tickSpacing) revert ExternalPoolMismatch(); PoolKey storage existing = _canonicalPoolKeyByAddress[poolAddr]; if (address(existing.hooks) != address(0)) revert PairAlreadyHasCanonicalPool(existing.toId()); _canonicalPoolKeyByAddress[poolAddr] = key; PoolId id = key.toId(); poolIdToExternalPool[id] = poolAddr; _initializedPools.push(key); emit AggregatorPoolRegistered(id); pollTokenJar(); return IHooks.beforeInitialize.selector; // …
Who controls it: Nobody. The hook has no admin functions, and the code cannot be changed.
Based on the hook’s published code.What do these labels mean?
Safety report
Before you build on it. Automated checks, not an auditWhat it can do
Its code executes inside each trade in pools that use it.
It can take or add tokens during a swap. Fees, burns and custom curves work this way, and so do scams.
It checks every deposit before it goes in.
It runs when a pool is created, often to lock in that pool’s settings.
Hook history
Across all its pools, the hook handled a trade: $1.46, and took its fee from a trade: $0.000730.
- Handled a trade 1 time, worth $1.46
- Took its fee from a trade 1 time, worth $0.000730
Latest transactions
- 0xac19dffb…4a9e32 block 135,470,791 · 0.00000133 WBNB
- Registered an aggregator pool 13 times
Latest transactions
- 0x0eb62bab…4aa569 block 135,463,696
- 0x34a03f99…ba99cf block 135,463,676
- 0xfdc46310…be3221 block 135,463,654
- 0x5bf51e23…392a73 block 135,463,630
- 0x16e9e7cf…a1e942 block 135,463,608
- 0x0dfbba73…37af30 block 135,463,589
- 0x03e9ef1b…2c4db8 block 135,463,570
- 0xb0818374…1a805b block 135,463,555
- 0xc7671921…5472eb block 135,463,537
- 0x83b20d6b…2a671d block 135,463,522
Settings changes: changed the token jar (1 time).
Counted from what the hook recorded on-chain across all its pools, for every action in its published code, plus token transfers in and out of it. Dollar values count the amounts paid in ETH, stablecoins, BNB and BTC, at today’s prices.