Hooks

Create your own hooks to use on the Launchpad.

Every token launches with a hook. If no hook is specified it uses the default hook which gives 0% trading fees to Bonsai NFT holders (anyone with 100k $BONSAI since it is a DN404 token). If you are a hook developer you can submit your own hook for whitelisting on the Launchpad here.

In order for your hook to be eligible it must have a 1.5% trading fee that is overriden to 0% when you are holding a Bonsai NFT. The default hook source code can be referenced here.

  1. Make the beforeSwap flag true

    function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
        return Hooks.Permissions({
            beforeInitialize: false,
            afterInitialize: false,
            beforeAddLiquidity: false,
            afterAddLiquidity: false,
            beforeRemoveLiquidity: false,
            afterRemoveLiquidity: false,
            // the beforeSwap flag must be true
            beforeSwap: true,
            afterSwap: false,
            beforeDonate: false,
            afterDonate: false,
            beforeSwapReturnDelta: false,
            afterSwapReturnDelta: false,
            afterAddLiquidityReturnDelta: false,
            afterRemoveLiquidityReturnDelta: false
        });
    }
  1. Override the beforeSwapfunction to get the fee value from the Default Settings contract. Default Settings is deployed to 0x419F1450368F63A8C7aB67BD96B6d0ff2E062329 on Base mainnet. Be aware that the balance of Bonsai NFTs is checked based on tx.origin . While not ideal Uniswap has not provided a way to get the user's address inside of a hook.

    function beforeSwap(address, PoolKey calldata, IPoolManager.SwapParams calldata, bytes calldata)
        external
        view
        override
        returns (bytes4, BeforeSwapDelta, uint24)
    {
        // override swap fee by making a call to the DefaultSettings contract
        uint24 protocolFeePercentage = defaultSettings.beforeSwapFeeOverride();

        // The protocol fee will be applied as part of the LP fees in the PoolManager
        return (BaseHook.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, protocolFeePercentage);
    }
  1. Include any other features you would like, publish the contract as an open source project and deploy to Base and verify with basescan.

  2. Fill out the form on https://launch.bonsai.meme/hooks to apply to have you hook whitelisted. Once we've verified it it will become available on the website for anyone to use.\

We reserve the right to refuse whitelisting to any hook we deem to be malicious or to have a negative impact on the ecosystem.

Last updated