跳到主要内容

JBSplits

Git Source

Inherits: JBControlled, IJBSplits

Stores and manages splits for each project.

State Variables

FALLBACK_RULESET_ID

The ID of the ruleset that will be checked if nothing was found in the provided rulesetId.

uint256 public constant override FALLBACK_RULESET_ID = 0;

_packedSplitParts1Of

Packed split data given the split's project, ruleset, and group IDs, as well as the split's index within that group.

preferAddToBalance in bit 0, percent in bits 1-32, projectId in bits 33-88, and beneficiary in bits 89-248

Note: return: The split's preferAddToBalance, percent, projectId, and beneficiary packed into one uint256.

mapping(
uint256 projectId => mapping(uint256 rulesetId => mapping(uint256 groupId => mapping(uint256 index => uint256)))
) internal _packedSplitParts1Of;

_packedSplitParts2Of

More packed split data given the split's project, ruleset, and group IDs, as well as the split's index within that group.

lockedUntil in bits 0-47, hook address in bits 48-207.

This packed data is often 0.

Note: return: The split's lockedUntil and hook packed into one uint256.

mapping(
uint256 projectId => mapping(uint256 rulesetId => mapping(uint256 groupId => mapping(uint256 index => uint256)))
) internal _packedSplitParts2Of;

_splitCountOf

The number of splits currently stored in a group given a project ID, ruleset ID, and group ID.

mapping(uint256 projectId => mapping(uint256 rulesetId => mapping(uint256 groupId => uint256))) internal _splitCountOf;

Functions

constructor

constructor(IJBDirectory directory) JBControlled(directory);

Parameters

NameTypeDescription
directoryIJBDirectoryA contract storing directories of terminals and controllers for each project.

splitsOf

Get the split structs for the specified project ID, within the specified ruleset, for the specified group. The splits stored at ruleset 0 are used by default during a ruleset if the splits for the specific ruleset aren't set.

If splits aren't found at the given rulesetId, they'll be sought in the FALLBACK_RULESET_ID of 0.

function splitsOf(
uint256 projectId,
uint256 rulesetId,
uint256 groupId
)
external
view
override
returns (JBSplit[] memory splits);

Parameters

NameTypeDescription
projectIduint256The ID of the project to get splits for.
rulesetIduint256An identifier within which the returned splits should be considered active.
groupIduint256The identifying group of the splits.

Returns

NameTypeDescription
splitsJBSplit[]An array of all splits for the project.

_getStructsFor

Unpack an array of JBSplit structs for all of the splits in a group, given project, ruleset, and group IDs.

function _getStructsFor(
uint256 projectId,
uint256 rulesetId,
uint256 groupId
)
internal
view
returns (JBSplit[] memory);

Parameters

NameTypeDescription
projectIduint256The ID of the project the splits belong to.
rulesetIduint256The ID of the ruleset the group of splits should be considered active within.
groupIduint256The ID of the group to get the splits structs of.

Returns

NameTypeDescription
<none>JBSplit[]splits The split structs, as an array of JBSplits.

_includesLockedSplits

Determine if the provided splits array includes the locked split.

function _includesLockedSplits(JBSplit[] memory splits, JBSplit memory lockedSplit) internal pure returns (bool);

Parameters

NameTypeDescription
splitsJBSplit[]The array of splits to check within.
lockedSplitJBSplitThe locked split.

Returns

NameTypeDescription
<none>boolA flag indicating if the lockedSplit is contained in the splits.

setSplitGroupsOf

Sets a project's split groups.

Only a project's controller can set its splits.

The new split groups must include any currently set splits that are locked.

function setSplitGroupsOf(
uint256 projectId,
uint256 rulesetId,
JBSplitGroup[] calldata splitGroups
)
external
override
onlyControllerOf(projectId);

Parameters

NameTypeDescription
projectIduint256The ID of the project to set the split groups of.
rulesetIduint256The ID of the ruleset the split groups should be active in. Send 0 to set the default split that'll be active if no ruleset has specific splits set. The default's default is the project's owner.
splitGroupsJBSplitGroup[]An array of split groups to set.

_setSplitsOf

Sets the splits for a group given a project, ruleset, and group ID.

The new splits must include any currently set splits that are locked.

The sum of the split percents within one group must be less than 100%.

function _setSplitsOf(uint256 projectId, uint256 rulesetId, uint256 groupId, JBSplit[] memory splits) internal;

Parameters

NameTypeDescription
projectIduint256The ID of the project splits are being set for.
rulesetIduint256The ID of the ruleset the splits should be considered active within.
groupIduint256The ID of the group to set the splits within.
splitsJBSplit[]An array of splits to set.

Errors

JBSplits_TotalPercentExceeds100

error JBSplits_TotalPercentExceeds100();

JBSplits_PreviousLockedSplitsNotIncluded

error JBSplits_PreviousLockedSplitsNotIncluded();

JBSplits_ZeroSplitPercent

error JBSplits_ZeroSplitPercent();