@bananapus/core-v6 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/foundry.toml +0 -1
- package/package.json +2 -2
- package/src/JBChainlinkV3PriceFeed.sol +1 -5
- package/src/JBChainlinkV3SequencerPriceFeed.sol +1 -1
- package/src/JBController.sol +277 -277
- package/src/JBDeadline.sol +1 -1
- package/src/JBDirectory.sol +93 -93
- package/src/JBERC20.sol +43 -39
- package/src/JBFeelessAddresses.sol +12 -12
- package/src/JBFundAccessLimits.sol +82 -82
- package/src/JBMultiTerminal.sol +313 -313
- package/src/JBPermissions.sol +104 -100
- package/src/JBPrices.sol +68 -68
- package/src/JBProjects.sol +31 -31
- package/src/JBRulesets.sol +422 -422
- package/src/JBSplits.sol +116 -116
- package/src/JBTerminalStore.sol +651 -651
- package/src/JBTokens.sol +41 -41
- package/src/interfaces/IJBCashOutTerminal.sol +25 -7
- package/src/interfaces/IJBController.sol +78 -3
- package/src/interfaces/IJBDirectory.sol +25 -0
- package/src/interfaces/IJBFeeTerminal.sol +31 -0
- package/src/interfaces/IJBFeelessAddresses.sol +4 -0
- package/src/interfaces/IJBFundAccessLimits.sol +5 -0
- package/src/interfaces/IJBMigratable.sol +12 -8
- package/src/interfaces/IJBPayoutTerminal.sol +56 -9
- package/src/interfaces/IJBPermissions.sol +14 -7
- package/src/interfaces/IJBPermitTerminal.sol +4 -0
- package/src/interfaces/IJBPrices.sol +6 -0
- package/src/interfaces/IJBProjects.sol +8 -0
- package/src/interfaces/IJBRulesetApprovalHook.sol +1 -1
- package/src/interfaces/IJBRulesetDataHook.sol +23 -23
- package/src/interfaces/IJBRulesets.sol +54 -33
- package/src/interfaces/IJBSplits.sol +6 -0
- package/src/interfaces/IJBTerminal.sol +36 -0
- package/src/interfaces/IJBTerminalStore.sol +63 -63
- package/src/interfaces/IJBToken.sol +5 -5
- package/src/interfaces/IJBTokens.sol +50 -8
- package/test/TestDurationUnderflow.sol +3 -2
package/src/JBSplits.sol
CHANGED
|
@@ -71,121 +71,6 @@ contract JBSplits is JBControlled, IJBSplits {
|
|
|
71
71
|
/// @param directory A contract storing directories of terminals and controllers for each project.
|
|
72
72
|
constructor(IJBDirectory directory) JBControlled(directory) {}
|
|
73
73
|
|
|
74
|
-
//*********************************************************************//
|
|
75
|
-
// ------------------------- external views -------------------------- //
|
|
76
|
-
//*********************************************************************//
|
|
77
|
-
|
|
78
|
-
/// @notice Get the split structs for the specified project ID, within the specified ruleset, for the specified
|
|
79
|
-
/// group. The splits stored at ruleset 0 are used by default during a ruleset if the splits for the specific
|
|
80
|
-
/// ruleset aren't set.
|
|
81
|
-
/// @dev If splits aren't found at the given `rulesetId`, they'll be sought in the FALLBACK_RULESET_ID of 0.
|
|
82
|
-
/// @param projectId The ID of the project to get splits for.
|
|
83
|
-
/// @param rulesetId An identifier within which the returned splits should be considered active.
|
|
84
|
-
/// @param groupId The identifying group of the splits.
|
|
85
|
-
/// @return splits An array of all splits for the project.
|
|
86
|
-
function splitsOf(
|
|
87
|
-
uint256 projectId,
|
|
88
|
-
uint256 rulesetId,
|
|
89
|
-
uint256 groupId
|
|
90
|
-
)
|
|
91
|
-
external
|
|
92
|
-
view
|
|
93
|
-
override
|
|
94
|
-
returns (JBSplit[] memory splits)
|
|
95
|
-
{
|
|
96
|
-
splits = _getStructsFor({projectId: projectId, rulesetId: rulesetId, groupId: groupId});
|
|
97
|
-
|
|
98
|
-
// Use the default splits if there aren't any for the ruleset.
|
|
99
|
-
if (splits.length == 0) {
|
|
100
|
-
splits = _getStructsFor({projectId: projectId, rulesetId: FALLBACK_RULESET_ID, groupId: groupId});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//*********************************************************************//
|
|
105
|
-
// -------------------------- internal views ------------------------- //
|
|
106
|
-
//*********************************************************************//
|
|
107
|
-
|
|
108
|
-
/// @notice Unpack an array of `JBSplit` structs for all of the splits in a group, given project, ruleset, and group
|
|
109
|
-
/// IDs.
|
|
110
|
-
/// @param projectId The ID of the project the splits belong to.
|
|
111
|
-
/// @param rulesetId The ID of the ruleset the group of splits should be considered active within.
|
|
112
|
-
/// @param groupId The ID of the group to get the splits structs of.
|
|
113
|
-
/// @return splits The split structs, as an array of `JBSplit`s.
|
|
114
|
-
function _getStructsFor(
|
|
115
|
-
uint256 projectId,
|
|
116
|
-
uint256 rulesetId,
|
|
117
|
-
uint256 groupId
|
|
118
|
-
)
|
|
119
|
-
internal
|
|
120
|
-
view
|
|
121
|
-
returns (JBSplit[] memory)
|
|
122
|
-
{
|
|
123
|
-
// Get a reference to the number of splits that need to be added to the returned array.
|
|
124
|
-
uint256 splitCount = _splitCountOf[projectId][rulesetId][groupId];
|
|
125
|
-
|
|
126
|
-
// Initialize an array to be returned that has the appropriate length.
|
|
127
|
-
JBSplit[] memory splits = new JBSplit[](splitCount);
|
|
128
|
-
|
|
129
|
-
// Loop through each split and unpack the values into structs.
|
|
130
|
-
for (uint256 i; i < splitCount; i++) {
|
|
131
|
-
// Get a reference to the first part of the split's packed data.
|
|
132
|
-
uint256 packedSplitPart1 = _packedSplitParts1Of[projectId][rulesetId][groupId][i];
|
|
133
|
-
|
|
134
|
-
// Populate the split struct.
|
|
135
|
-
JBSplit memory split;
|
|
136
|
-
|
|
137
|
-
// `percent` in bits 0-31.
|
|
138
|
-
split.percent = uint32(packedSplitPart1);
|
|
139
|
-
// `projectId` in bits 32-95.
|
|
140
|
-
split.projectId = uint64(packedSplitPart1 >> 32);
|
|
141
|
-
// `beneficiary` in bits 96-255.
|
|
142
|
-
split.beneficiary = payable(address(uint160(packedSplitPart1 >> 96)));
|
|
143
|
-
|
|
144
|
-
// Get a reference to the second part of the split's packed data.
|
|
145
|
-
uint256 packedSplitPart2 = _packedSplitParts2Of[projectId][rulesetId][groupId][i];
|
|
146
|
-
|
|
147
|
-
// If there's anything in it, unpack.
|
|
148
|
-
if (packedSplitPart2 > 0) {
|
|
149
|
-
// `preferAddToBalance` in bit 0.
|
|
150
|
-
split.preferAddToBalance = packedSplitPart2 & 1 == 1;
|
|
151
|
-
// `lockedUntil` in bits 1-48.
|
|
152
|
-
split.lockedUntil = uint48(packedSplitPart2 >> 1);
|
|
153
|
-
// `hook` in bits 49-208.
|
|
154
|
-
split.hook = IJBSplitHook(address(uint160(packedSplitPart2 >> 49)));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Add the split to the value being returned.
|
|
158
|
-
splits[i] = split;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return splits;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/// @notice Determine if the provided splits array includes the locked split.
|
|
165
|
-
/// @param splits The array of splits to check within.
|
|
166
|
-
/// @param lockedSplit The locked split.
|
|
167
|
-
/// @return A flag indicating if the `lockedSplit` is contained in the `splits`.
|
|
168
|
-
function _includesLockedSplits(JBSplit[] memory splits, JBSplit memory lockedSplit) internal pure returns (bool) {
|
|
169
|
-
// Keep a reference to the number of splits.
|
|
170
|
-
uint256 numberOfSplits = splits.length;
|
|
171
|
-
|
|
172
|
-
for (uint256 i; i < numberOfSplits; i++) {
|
|
173
|
-
// Set the split being iterated on.
|
|
174
|
-
JBSplit memory split = splits[i];
|
|
175
|
-
|
|
176
|
-
// Check for sameness.
|
|
177
|
-
if (
|
|
178
|
-
// Allow the lock to be extended.
|
|
179
|
-
split.percent == lockedSplit.percent && split.beneficiary == lockedSplit.beneficiary
|
|
180
|
-
&& split.hook == lockedSplit.hook && split.projectId == lockedSplit.projectId
|
|
181
|
-
&& split.preferAddToBalance == lockedSplit.preferAddToBalance
|
|
182
|
-
&& split.lockedUntil >= lockedSplit.lockedUntil
|
|
183
|
-
) return true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
74
|
//*********************************************************************//
|
|
190
75
|
// ---------------------- external transactions ---------------------- //
|
|
191
76
|
//*********************************************************************//
|
|
@@ -231,7 +116,37 @@ contract JBSplits is JBControlled, IJBSplits {
|
|
|
231
116
|
}
|
|
232
117
|
|
|
233
118
|
//*********************************************************************//
|
|
234
|
-
//
|
|
119
|
+
// ------------------------- external views -------------------------- //
|
|
120
|
+
//*********************************************************************//
|
|
121
|
+
|
|
122
|
+
/// @notice Get the split structs for the specified project ID, within the specified ruleset, for the specified
|
|
123
|
+
/// group. The splits stored at ruleset 0 are used by default during a ruleset if the splits for the specific
|
|
124
|
+
/// ruleset aren't set.
|
|
125
|
+
/// @dev If splits aren't found at the given `rulesetId`, they'll be sought in the FALLBACK_RULESET_ID of 0.
|
|
126
|
+
/// @param projectId The ID of the project to get splits for.
|
|
127
|
+
/// @param rulesetId An identifier within which the returned splits should be considered active.
|
|
128
|
+
/// @param groupId The identifying group of the splits.
|
|
129
|
+
/// @return splits An array of all splits for the project.
|
|
130
|
+
function splitsOf(
|
|
131
|
+
uint256 projectId,
|
|
132
|
+
uint256 rulesetId,
|
|
133
|
+
uint256 groupId
|
|
134
|
+
)
|
|
135
|
+
external
|
|
136
|
+
view
|
|
137
|
+
override
|
|
138
|
+
returns (JBSplit[] memory splits)
|
|
139
|
+
{
|
|
140
|
+
splits = _getStructsFor({projectId: projectId, rulesetId: rulesetId, groupId: groupId});
|
|
141
|
+
|
|
142
|
+
// Use the default splits if there aren't any for the ruleset.
|
|
143
|
+
if (splits.length == 0) {
|
|
144
|
+
splits = _getStructsFor({projectId: projectId, rulesetId: FALLBACK_RULESET_ID, groupId: groupId});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//*********************************************************************//
|
|
149
|
+
// ---------------------- internal transactions ---------------------- //
|
|
235
150
|
//*********************************************************************//
|
|
236
151
|
|
|
237
152
|
/// @notice Sets the splits for a group given a project, ruleset, and group ID.
|
|
@@ -321,4 +236,89 @@ contract JBSplits is JBControlled, IJBSplits {
|
|
|
321
236
|
delete _packedSplitParts2Of[projectId][rulesetId][groupId][i];
|
|
322
237
|
}
|
|
323
238
|
}
|
|
239
|
+
|
|
240
|
+
//*********************************************************************//
|
|
241
|
+
// -------------------------- internal views ------------------------- //
|
|
242
|
+
//*********************************************************************//
|
|
243
|
+
|
|
244
|
+
/// @notice Unpack an array of `JBSplit` structs for all of the splits in a group, given project, ruleset, and group
|
|
245
|
+
/// IDs.
|
|
246
|
+
/// @param projectId The ID of the project the splits belong to.
|
|
247
|
+
/// @param rulesetId The ID of the ruleset the group of splits should be considered active within.
|
|
248
|
+
/// @param groupId The ID of the group to get the splits structs of.
|
|
249
|
+
/// @return splits The split structs, as an array of `JBSplit`s.
|
|
250
|
+
function _getStructsFor(
|
|
251
|
+
uint256 projectId,
|
|
252
|
+
uint256 rulesetId,
|
|
253
|
+
uint256 groupId
|
|
254
|
+
)
|
|
255
|
+
internal
|
|
256
|
+
view
|
|
257
|
+
returns (JBSplit[] memory)
|
|
258
|
+
{
|
|
259
|
+
// Get a reference to the number of splits that need to be added to the returned array.
|
|
260
|
+
uint256 splitCount = _splitCountOf[projectId][rulesetId][groupId];
|
|
261
|
+
|
|
262
|
+
// Initialize an array to be returned that has the appropriate length.
|
|
263
|
+
JBSplit[] memory splits = new JBSplit[](splitCount);
|
|
264
|
+
|
|
265
|
+
// Loop through each split and unpack the values into structs.
|
|
266
|
+
for (uint256 i; i < splitCount; i++) {
|
|
267
|
+
// Get a reference to the first part of the split's packed data.
|
|
268
|
+
uint256 packedSplitPart1 = _packedSplitParts1Of[projectId][rulesetId][groupId][i];
|
|
269
|
+
|
|
270
|
+
// Populate the split struct.
|
|
271
|
+
JBSplit memory split;
|
|
272
|
+
|
|
273
|
+
// `percent` in bits 0-31.
|
|
274
|
+
split.percent = uint32(packedSplitPart1);
|
|
275
|
+
// `projectId` in bits 32-95.
|
|
276
|
+
split.projectId = uint64(packedSplitPart1 >> 32);
|
|
277
|
+
// `beneficiary` in bits 96-255.
|
|
278
|
+
split.beneficiary = payable(address(uint160(packedSplitPart1 >> 96)));
|
|
279
|
+
|
|
280
|
+
// Get a reference to the second part of the split's packed data.
|
|
281
|
+
uint256 packedSplitPart2 = _packedSplitParts2Of[projectId][rulesetId][groupId][i];
|
|
282
|
+
|
|
283
|
+
// If there's anything in it, unpack.
|
|
284
|
+
if (packedSplitPart2 > 0) {
|
|
285
|
+
// `preferAddToBalance` in bit 0.
|
|
286
|
+
split.preferAddToBalance = packedSplitPart2 & 1 == 1;
|
|
287
|
+
// `lockedUntil` in bits 1-48.
|
|
288
|
+
split.lockedUntil = uint48(packedSplitPart2 >> 1);
|
|
289
|
+
// `hook` in bits 49-208.
|
|
290
|
+
split.hook = IJBSplitHook(address(uint160(packedSplitPart2 >> 49)));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Add the split to the value being returned.
|
|
294
|
+
splits[i] = split;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return splits;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/// @notice Determine if the provided splits array includes the locked split.
|
|
301
|
+
/// @param splits The array of splits to check within.
|
|
302
|
+
/// @param lockedSplit The locked split.
|
|
303
|
+
/// @return A flag indicating if the `lockedSplit` is contained in the `splits`.
|
|
304
|
+
function _includesLockedSplits(JBSplit[] memory splits, JBSplit memory lockedSplit) internal pure returns (bool) {
|
|
305
|
+
// Keep a reference to the number of splits.
|
|
306
|
+
uint256 numberOfSplits = splits.length;
|
|
307
|
+
|
|
308
|
+
for (uint256 i; i < numberOfSplits; i++) {
|
|
309
|
+
// Set the split being iterated on.
|
|
310
|
+
JBSplit memory split = splits[i];
|
|
311
|
+
|
|
312
|
+
// Check for sameness.
|
|
313
|
+
if (
|
|
314
|
+
// Allow the lock to be extended.
|
|
315
|
+
split.percent == lockedSplit.percent && split.beneficiary == lockedSplit.beneficiary
|
|
316
|
+
&& split.hook == lockedSplit.hook && split.projectId == lockedSplit.projectId
|
|
317
|
+
&& split.preferAddToBalance == lockedSplit.preferAddToBalance
|
|
318
|
+
&& split.lockedUntil >= lockedSplit.lockedUntil
|
|
319
|
+
) return true;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
324
|
}
|