MemespadHook
BSCMemespadHook is a Uniswap v4 hook on BSC. Runs code on every swap. Can take tokens from swaps.
- Contract name
- MemespadHook
How this hook works
Trading taxA trading tax hook. It takes a tax on trades, manages its own liquidity and trades on its own.
Takes a tax on trades
On top of the normal pool fee, it keeps part of each trade as a tax. Buys and sells can be taxed differently.
The code that does this (beforeSwap):function beforeSwap( address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata ) external onlyPoolManager returns (bytes4, BeforeSwapDelta, uint24) { if (sender == address(this) || sender == address(factory)) return (this.beforeSwap.selector, toBeforeSwapDelta(0, 0), 0); (address tokenAddr, bool tokenIsZero_) = _identifyToken(key); if (tokenAddr == address(0)) return (this.beforeSwap.selector, toBeforeSwapDelta(0, 0), 0); bool isBuy_ = tokenIsZero_ ? !params.zeroForOne : params.zeroForOne; if (isBuy_ && sender != address(factory) && block.timestamp < snipeWindowEnd[tokenAddr]) { revert SnipeWindowActive(); } if (isBuy_ && params.amountSpecified < 0 && sender != address(factory)) { uint256 mbc = maxBuyQuoteByToken[_poolQuote(key, tokenIsZero_)]; if (mbc > 0 && block.timestamp < fairLaunchEnd[tokenAddr]) { if (SafeCast.toUint256(-params.amountSpecified) > mbc) revert MaxBuyExceeded(); } } TaxParams storage p = taxParams[tokenAddr]; uint256 totalTaxBps = isBuy_ ? uint256(p.buyTaxBps) : uint256(p.sellTaxBps); if (totalTaxBps == 0) return (this.beforeSwap.selector, toBeforeSwapDelta(0, 0), 0); bool ethIsSpecified = params.zeroForOne == (params.amountSpecified < 0); // …Manages its own liquidity
It adds and removes liquidity itself, so it can own part or all of the pool.
The code that does this (tryAddLiquidity):function _tryAddLiquidity( PoolKey calldata key, address tokenAddr, bool tokenIsZero_ ) internal { address quoteToken_ = _poolQuote(key, tokenIsZero_); if (quoteToken_ != taxParams[tokenAddr].quoteToken) return; // auto-liquidity: main pool only uint256 pending = pendingLiq[tokenAddr][quoteToken_]; uint256 threshold = liquidityThreshold[tokenAddr]; if (threshold == 0 || pending < threshold) return; pendingLiq[tokenAddr][quoteToken_] = 0; // Step 1: swap ~45% of accumulated quote for tokens (slightly under half to // avoid ratio mismatch when providing two-sided liquidity) uint256 swapAmt = (pending * 45) / 100; uint256 keepAmt = pending - swapAmt; bool zeroForOne = !tokenIsZero_; // sell quote to buy tokens BalanceDelta swapDelta = IPoolManager(poolManager).swap( key, SwapParams({ zeroForOne: zeroForOne, amountSpecified: -int256(swapAmt), sqrtPriceLimitX96: zeroForOne ? MIN_SQRT_PRICE_LIMIT : MAX_SQRT_PRICE_LIMIT }), "" ); // Settle the quote we sold // …Trades on its own
It makes trades itself, for example to convert the fees it collected.
The code that does this (tryExecuteBurn):function _tryExecuteBurn( PoolKey calldata key, address tokenAddr, bool tokenIsZero_ ) internal { address quoteToken_ = _poolQuote(key, tokenIsZero_); uint256 pending = pendingBurn[tokenAddr][quoteToken_]; if (pending == 0) return; uint256 threshold = quoteToken_ == taxParams[tokenAddr].quoteToken ? burnThreshold[tokenAddr] : extraBurnThreshold[tokenAddr][quoteToken_]; if (threshold == 0) threshold = burnDustThresholdByToken[quoteToken_]; if (threshold > 0 && pending < threshold) return; pendingBurn[tokenAddr][quoteToken_] = 0; bool zeroForOne = !tokenIsZero_; BalanceDelta delta = IPoolManager(poolManager).swap( key, SwapParams({ zeroForOne: zeroForOne, amountSpecified: -int256(pending), sqrtPriceLimitX96: zeroForOne ? MIN_SQRT_PRICE_LIMIT : MAX_SQRT_PRICE_LIMIT }), "" ); if (quoteToken_ == address(0)) { uint256 ethOwed = tokenIsZero_ ? SafeCast.toUint256(-int256(delta.amount1())) // …Launch protection
It limits trading, for example a max buy or wallet size or a cooldown, to stop bots grabbing the supply before real traders.
The code that does this (beforeSwap):function beforeSwap( address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata ) external onlyPoolManager returns (bytes4, BeforeSwapDelta, uint24) { if (sender == address(this) || sender == address(factory)) return (this.beforeSwap.selector, toBeforeSwapDelta(0, 0), 0); (address tokenAddr, bool tokenIsZero_) = _identifyToken(key); if (tokenAddr == address(0)) return (this.beforeSwap.selector, toBeforeSwapDelta(0, 0), 0); bool isBuy_ = tokenIsZero_ ? !params.zeroForOne : params.zeroForOne; if (isBuy_ && sender != address(factory) && block.timestamp < snipeWindowEnd[tokenAddr]) { revert SnipeWindowActive(); } if (isBuy_ && params.amountSpecified < 0 && sender != address(factory)) { uint256 mbc = maxBuyQuoteByToken[_poolQuote(key, tokenIsZero_)]; if (mbc > 0 && block.timestamp < fairLaunchEnd[tokenAddr]) { if (SafeCast.toUint256(-params.amountSpecified) > mbc) revert MaxBuyExceeded(); } } TaxParams storage p = taxParams[tokenAddr]; uint256 totalTaxBps = isBuy_ ? uint256(p.buyTaxBps) : uint256(p.sellTaxBps); if (totalTaxBps == 0) return (this.beforeSwap.selector, toBeforeSwapDelta(0, 0), 0); bool ethIsSpecified = params.zeroForOne == (params.amountSpecified < 0); // …
Who controls it: The code itself can’t be changed. The hook developer can change: treasury, fair launch window, max buy quote, token tax, factory, dividend pool and 6 more. The hook developer can also call: emergency withdraw.
Based on the hook’s published code.
What 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.
Hook history
- Trades 6 times
Latest transactions
- 0x2884c859…420fd5 block 132,712,104 · 0.000376 MULTIPAIR
- 0x337496fd…325d97 block 132,712,098 · 0.000380 MULTIPAIR
- 0x4add5c63…11c912 block 132,712,094 · 0.000376 MULTIPAIR
- 0xf92ca66b…9658e0 block 132,712,042 · 0.000380 MULTIPAIR
- 0xa3587767…4540cf block 132,712,033 · 0.000376 MULTIPAIR
- 0x8cc71cd3…02687a block 132,712,023 · 0.000380 MULTIPAIR
- Added extra quote 5 times
Latest transactions
- 0x743fea3a…9179f7 block 132,711,927
- 0x743fea3a…9179f7 block 132,711,927
- 0x743fea3a…9179f7 block 132,711,927
- 0x75e9aa19…e83c97 block 132,708,610
- 0x75e9aa19…e83c97 block 132,708,610
- Registered token 2 times
Latest transactions
- 0x743fea3a…9179f7 block 132,711,927
- 0x75e9aa19…e83c97 block 132,708,610
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.