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
- Registered an aggregator pool 5 times
Latest transactions
- 0x208472df…9ad118 block 135,508,151
- 0x2eb1c18a…ecc39c block 135,508,126
- 0x0c13efab…f4cf8f block 135,508,089
- 0xd69a9c54…b565aa block 135,508,060
- 0x98092476…06343f block 135,508,028
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.