Skip to content

Weight Splitter ​

Use fixed percentages to divide a node's output, such as 20% retained and 80% donated. Weights express these shares in millionths: 200,000 means 20%. Assign one positive weight per child, in child order, totaling 1,000,000.

Configuration ​

The settings are an ABI-encoded uint32[], in child order. For a recipe node with retention first and donation second, where node is a Setup.RecipeNode:

solidity
uint32[] memory weights = new uint32[](2);
weights[0] = 200_000; // 20% to the first child
weights[1] = 800_000; // 80% to the second child
node.splitter.id = bytes32("WeightSplitter@1");
node.splitter.settings = abi.encode(weights);

Small amounts and rounding ​

The largest share receives any rounding remainder; the first wins a tie. If a small output gives a child zero, the run reverts unless that child has skipWhenEmpty. Choose amounts that keep required branches funded.

Adjust the split ​

A manager with SET_SETTINGS_PERMISSION_ID can call setWeights(weights). The number of weights must stay the same; adding or removing children requires a flow update through setFlow. childCount() reports that number for the splitter interface.

See also ​