🌳
Bonsai Docs
  • Introduction
    • Bonsai
    • What is Smart Media?
  • Platform
    • No-code creator studio
    • Guide: Create a post
  • Smart Media
    • Framework for builders
  • Building Smart Media
    • ElizaOS server setup
    • Bonsai Client
    • Templates
  • Guide: Create a Template
  • Client Integrations
    • Showing whether a post is Smart Media
    • Linking to Bonsai for remixes
    • Creating a smart media post
  • Actions
    • Reward Swap
  • Launchpad
    • Overview
    • Getting Started
    • Launchpad Contract
    • Vesting ERC20 Contract
    • Hooks
    • API
      • Tokens
      • Token Balances
      • Buy / Sell Quotes
      • Link your token to a Lens Post & Account
  • ElizaOS
    • plugin-bonsai-launchpad
    • client-lens
Powered by GitBook
On this page
  1. Launchpad

Hooks

Create your own hooks to use on the Launchpad.

PreviousVesting ERC20 ContractNextAPI

Last updated 2 months ago

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

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. .

  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
        });
    }
    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.

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

Override the beforeSwapfunction to get the fee value from the Default Settings contract. Default Settings is deployed to 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.

Fill out the form on to apply to have you hook whitelisted. Once we've verified it it will become available on the website for anyone to use.

you can submit your own hook for whitelisting on the Launchpad here.
The default hook source code can be referenced here
0x419F1450368F63A8C7aB67BD96B6d0ff2E062329
https://app.onbons.ai/hooks