@bananapus/721-hook-v6 0.0.11 → 0.0.13
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/ADMINISTRATION.md +151 -0
- package/ARCHITECTURE.md +70 -0
- package/RISKS.md +311 -0
- package/SKILLS.md +6 -6
- package/STYLE_GUIDE.md +470 -0
- package/foundry.toml +1 -1
- package/package.json +5 -5
- package/script/Deploy.s.sol +2 -2
- package/src/JB721TiersHook.sol +15 -5
- package/src/interfaces/IJB721TiersHook.sol +5 -0
- package/src/libraries/JB721TiersHookLib.sol +39 -11
- package/test/E2E/Pay_Mint_Redeem_E2E.t.sol +3 -1
- package/test/Fork.t.sol +2272 -0
- package/test/regression/L36_SplitNoBeneficiary.t.sol +2 -10
- package/test/unit/adjustTier_Unit.t.sol +119 -98
- package/test/unit/tierSplitRouting_Unit.t.sol +2 -10
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.26;
|
|
3
3
|
|
|
4
|
-
import {IJBController} from "@bananapus/core-v6/src/interfaces/IJBController.sol";
|
|
5
4
|
import {IJBDirectory} from "@bananapus/core-v6/src/interfaces/IJBDirectory.sol";
|
|
6
5
|
import {IJBPrices} from "@bananapus/core-v6/src/interfaces/IJBPrices.sol";
|
|
7
6
|
import {IJBSplits} from "@bananapus/core-v6/src/interfaces/IJBSplits.sol";
|
|
@@ -31,7 +30,7 @@ library JB721TiersHookLib {
|
|
|
31
30
|
/// @notice Handles the full tier adjustment logic: removes tiers, adds tiers, emits events, and sets splits.
|
|
32
31
|
/// @dev Called via DELEGATECALL from the hook, so events are emitted from the hook's address.
|
|
33
32
|
/// @param store The 721 tiers hook store.
|
|
34
|
-
/// @param
|
|
33
|
+
/// @param splits The splits contract to register tier split groups in.
|
|
35
34
|
/// @param projectId The project ID.
|
|
36
35
|
/// @param hookAddress The hook address.
|
|
37
36
|
/// @param caller The msg.sender of the original call (for event emission).
|
|
@@ -39,7 +38,7 @@ library JB721TiersHookLib {
|
|
|
39
38
|
/// @param tierIdsToRemove The tier IDs to remove.
|
|
40
39
|
function adjustTiersFor(
|
|
41
40
|
IJB721TiersHookStore store,
|
|
42
|
-
|
|
41
|
+
IJBSplits splits,
|
|
43
42
|
uint256 projectId,
|
|
44
43
|
address hookAddress,
|
|
45
44
|
address caller,
|
|
@@ -67,8 +66,37 @@ library JB721TiersHookLib {
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
// Set split groups for tiers that have splits configured.
|
|
70
|
-
_setSplitGroupsFor(
|
|
69
|
+
_setSplitGroupsFor(splits, projectId, hookAddress, tiersToAdd, tierIdsAdded);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// @notice Records new tiers, emits events, and sets their split groups.
|
|
74
|
+
/// @dev Used during initialization when tier configs are in memory.
|
|
75
|
+
/// @param store The 721 tiers hook store.
|
|
76
|
+
/// @param splits The splits contract to register tier split groups in.
|
|
77
|
+
/// @param projectId The project ID.
|
|
78
|
+
/// @param hookAddress The hook address.
|
|
79
|
+
/// @param caller The msg.sender of the original call (for event emission).
|
|
80
|
+
/// @param tiersToAdd The tier configs to add.
|
|
81
|
+
function recordAddTiersFor(
|
|
82
|
+
IJB721TiersHookStore store,
|
|
83
|
+
IJBSplits splits,
|
|
84
|
+
uint256 projectId,
|
|
85
|
+
address hookAddress,
|
|
86
|
+
address caller,
|
|
87
|
+
JB721TierConfig[] memory tiersToAdd
|
|
88
|
+
)
|
|
89
|
+
external
|
|
90
|
+
{
|
|
91
|
+
uint256[] memory tierIdsAdded = store.recordAddTiers(tiersToAdd);
|
|
92
|
+
|
|
93
|
+
// slither-disable-next-line reentrancy-events
|
|
94
|
+
for (uint256 i; i < tiersToAdd.length; i++) {
|
|
95
|
+
emit AddTier({tierId: tierIdsAdded[i], tier: tiersToAdd[i], caller: caller});
|
|
71
96
|
}
|
|
97
|
+
|
|
98
|
+
// Set split groups for tiers that have splits configured.
|
|
99
|
+
_setSplitGroupsFor(splits, projectId, hookAddress, tiersToAdd, tierIdsAdded);
|
|
72
100
|
}
|
|
73
101
|
|
|
74
102
|
/// @notice Normalizes a payment value based on the packed pricing context.
|
|
@@ -163,10 +191,10 @@ library JB721TiersHookLib {
|
|
|
163
191
|
|
|
164
192
|
/// @notice Sets split groups in JBSplits for tiers that have splits configured.
|
|
165
193
|
function _setSplitGroupsFor(
|
|
166
|
-
|
|
194
|
+
IJBSplits splits,
|
|
167
195
|
uint256 projectId,
|
|
168
196
|
address hookAddress,
|
|
169
|
-
JB721TierConfig[]
|
|
197
|
+
JB721TierConfig[] memory tiersToAdd,
|
|
170
198
|
uint256[] memory tierIdsAdded
|
|
171
199
|
)
|
|
172
200
|
private
|
|
@@ -187,17 +215,19 @@ library JB721TiersHookLib {
|
|
|
187
215
|
groupIndex++;
|
|
188
216
|
}
|
|
189
217
|
}
|
|
190
|
-
|
|
218
|
+
splits.setSplitGroupsOf(projectId, 0, splitGroups);
|
|
191
219
|
}
|
|
192
220
|
|
|
193
221
|
/// @notice Distributes forwarded funds for all tiers in the hook metadata.
|
|
194
|
-
/// @param directory The directory to look up
|
|
222
|
+
/// @param directory The directory to look up terminals.
|
|
223
|
+
/// @param splits The splits contract to read tier split groups from.
|
|
195
224
|
/// @param projectId The project ID of the hook.
|
|
196
225
|
/// @param hookAddress The hook address (for computing split group IDs).
|
|
197
226
|
/// @param token The token being distributed.
|
|
198
227
|
/// @param encodedSplitData The encoded per-tier breakdown from hookMetadata.
|
|
199
228
|
function distributeAll(
|
|
200
229
|
IJBDirectory directory,
|
|
230
|
+
IJBSplits splits,
|
|
201
231
|
uint256 projectId,
|
|
202
232
|
address hookAddress,
|
|
203
233
|
address token,
|
|
@@ -207,12 +237,10 @@ library JB721TiersHookLib {
|
|
|
207
237
|
{
|
|
208
238
|
(uint16[] memory tierIds, uint256[] memory amounts) = abi.decode(encodedSplitData, (uint16[], uint256[]));
|
|
209
239
|
|
|
210
|
-
IJBSplits splitsContract = IJBController(address(directory.controllerOf(projectId))).SPLITS();
|
|
211
|
-
|
|
212
240
|
for (uint256 i; i < tierIds.length; i++) {
|
|
213
241
|
if (amounts[i] == 0) continue;
|
|
214
242
|
uint256 groupId = uint256(uint160(hookAddress)) | (uint256(tierIds[i]) << 160);
|
|
215
|
-
_distributeSingleSplit(directory,
|
|
243
|
+
_distributeSingleSplit(directory, splits, projectId, token, groupId, amounts[i]);
|
|
216
244
|
}
|
|
217
245
|
}
|
|
218
246
|
|
|
@@ -59,7 +59,9 @@ contract Test_TiersHook_E2E is TestBaseWorkflow {
|
|
|
59
59
|
function setUp() public override {
|
|
60
60
|
super.setUp();
|
|
61
61
|
store = new JB721TiersHookStore();
|
|
62
|
-
hook = new JB721TiersHook(
|
|
62
|
+
hook = new JB721TiersHook(
|
|
63
|
+
jbDirectory, jbPermissions, jbRulesets, store, IJBSplits(address(jbSplits)), trustedForwarder
|
|
64
|
+
);
|
|
63
65
|
addressRegistry = new JBAddressRegistry();
|
|
64
66
|
JB721TiersHookDeployer hookDeployer = new JB721TiersHookDeployer(hook, store, addressRegistry, trustedForwarder);
|
|
65
67
|
deployer = new JB721TiersHookProjectDeployer(
|