jb-split-hook

0
0
Source

Generate custom Juicebox V5 split hooks from natural language specifications. Creates Solidity contracts implementing IJBSplitHook with Foundry tests. Split hooks process individual payout or reserved token splits with custom logic like DeFi integrations.

Install

mkdir -p .claude/skills/jb-split-hook && curl -L -o skill.zip "https://mcp.directory/api/skills/download/8942" && unzip -o skill.zip -d .claude/skills/jb-split-hook && rm skill.zip

Installs to .claude/skills/jb-split-hook

About this skill

Juicebox V5 Split Hook Generator

Generate custom split hooks for Juicebox V5 projects based on natural language specifications.

What Are Split Hooks?

Split hooks allow custom processing when funds are distributed through payout splits or reserved token splits. They're useful for:

  • DeFi integrations: Route payouts to liquidity pools, staking, or yield protocols
  • Multi-recipient routing: Split a single split further among multiple addresses
  • Token swaps: Convert received tokens before forwarding
  • Custom accounting: Track or transform distributions

Note: Split hooks can be added to Revnets for token distribution just like any other Juicebox project.

V5 Split Hook Architecture

Split hooks implement a single function that receives funds optimistically and processes them.

interface IJBSplitHook is IERC165 {
    /// @notice Process a single split with custom logic.
    /// @dev Tokens and native currency are optimistically transferred to the hook.
    /// @param context The context passed by the terminal or controller.
    function processSplitWith(JBSplitHookContext calldata context) external payable;
}

JBSplitHookContext Fields

struct JBSplitHookContext {
    address token;          // Token being distributed (address(0) for native)
    uint256 amount;         // Amount sent to this split
    uint256 decimals;       // Token decimals
    uint256 projectId;      // Project distributing funds
    uint256 groupId;        // Split group ID
    JBSplit split;          // The split configuration
}

JBSplit Configuration

struct JBSplit {
    bool preferAddToBalance;    // Add to project balance instead of paying
    uint256 percent;            // Percent of distribution (out of 1000000000)
    uint256 projectId;          // Project to pay (0 for wallet)
    address payable beneficiary; // Wallet if projectId is 0
    uint256 lockedUntil;        // Timestamp until split is locked
    IJBSplitHook hook;          // This split hook address
}

Design Patterns

Basic Split Hook

contract BasicSplitHook is IJBSplitHook, ERC165 {
    function processSplitWith(JBSplitHookContext calldata context) external payable override {
        // Funds have been transferred to this contract
        // Process them according to custom logic

        if (context.token == address(0)) {
            // Handle native currency (ETH)
            uint256 amount = address(this).balance;
            // ... custom logic
        } else {
            // Handle ERC20 token
            uint256 amount = IERC20(context.token).balanceOf(address(this));
            // ... custom logic
        }
    }

    function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
        return interfaceId == type(IJBSplitHook).interfaceId || super.supportsInterface(interfaceId);
    }
}

Uniswap V3 LP Split Hook Pattern

Route payouts to a Uniswap V3 liquidity position.

contract UniswapV3LPSplitHook is IJBSplitHook, ERC165 {
    INonfungiblePositionManager public immutable POSITION_MANAGER;
    uint256 public tokenId; // LP position NFT ID

    function processSplitWith(JBSplitHookContext calldata context) external payable override {
        if (context.token == address(0)) {
            // Wrap ETH to WETH
            WETH.deposit{value: msg.value}();
        }

        // Add liquidity to existing position or create new one
        // ...
    }
}

Multi-Recipient Split Hook

Split funds further among multiple recipients.

contract MultiRecipientSplitHook is IJBSplitHook, ERC165 {
    struct Recipient {
        address payable addr;
        uint256 percent; // Out of 10000
    }

    Recipient[] public recipients;

    function processSplitWith(JBSplitHookContext calldata context) external payable override {
        uint256 total = context.amount;

        for (uint256 i; i < recipients.length; i++) {
            uint256 share = (total * recipients[i].percent) / 10000;

            if (context.token == address(0)) {
                recipients[i].addr.transfer(share);
            } else {
                IERC20(context.token).transfer(recipients[i].addr, share);
            }
        }
    }
}

Token Swap Split Hook

Swap received tokens before forwarding.

contract SwapSplitHook is IJBSplitHook, ERC165 {
    ISwapRouter public immutable ROUTER;
    address public immutable OUTPUT_TOKEN;
    address public immutable BENEFICIARY;

    function processSplitWith(JBSplitHookContext calldata context) external payable override {
        // Approve router
        IERC20(context.token).approve(address(ROUTER), context.amount);

        // Swap to output token
        uint256 amountOut = ROUTER.exactInputSingle(
            ISwapRouter.ExactInputSingleParams({
                tokenIn: context.token,
                tokenOut: OUTPUT_TOKEN,
                fee: 3000,
                recipient: BENEFICIARY,
                amountIn: context.amount,
                amountOutMinimum: 0,
                sqrtPriceLimitX96: 0
            })
        );
    }
}

Configuring Split Hooks

To use a split hook, configure it in a project's split group:

JBSplit memory split = JBSplit({
    preferAddToBalance: false,
    percent: 100_000_000, // 10% (out of 1_000_000_000)
    projectId: 0,
    beneficiary: payable(address(0)),
    lockedUntil: 0,
    hook: IJBSplitHook(address(mySplitHook))
});

Generation Guidelines

  1. Understand the distribution flow - splits receive funds during payout or reserved token distribution
  2. Handle both ETH and ERC20 - check context.token to determine token type
  3. Consider gas costs - complex DeFi operations may be expensive
  4. Include proper error handling - failed external calls should be handled gracefully
  5. Generate Foundry tests with fork testing for DeFi integrations

Example Prompts

  • "Create a split hook that deposits ETH into Lido and sends stETH to a beneficiary"
  • "I want to route 50% of payouts to a Uniswap V3 LP position"
  • "Build a split hook that swaps tokens to USDC before sending to treasury"
  • "Create a hook that splits incoming funds among 5 DAO multisigs"

Reference Implementations

Output Format

Generate:

  1. Main contract in src/
  2. Interface in src/interfaces/ if needed
  3. Test file in test/
  4. Deployment script in script/ if requested

Use Foundry project structure with forge-std.

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,4071,302

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,2201,024

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

9001,013

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

958658

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

970608

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,033496

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.