@bananapus/core-v6 0.0.30 → 0.0.31
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 +43 -13
- package/ARCHITECTURE.md +62 -137
- package/AUDIT_INSTRUCTIONS.md +149 -428
- package/CHANGELOG.md +73 -0
- package/README.md +90 -201
- package/RISKS.md +27 -12
- package/SKILLS.md +31 -441
- package/STYLE_GUIDE.md +52 -19
- package/USER_JOURNEYS.md +76 -627
- package/package.json +1 -2
- package/references/entrypoints.md +160 -0
- package/references/types-errors-events.md +297 -0
- package/script/Deploy.s.sol +7 -2
- package/script/DeployPeriphery.s.sol +51 -4
- package/src/JBController.sol +11 -3
- package/src/JBDirectory.sol +1 -0
- package/src/JBMultiTerminal.sol +126 -72
- package/src/JBRulesets.sol +2 -1
- package/src/JBTerminalStore.sol +22 -11
- package/src/abstract/JBControlled.sol +7 -1
- package/src/abstract/JBPermissioned.sol +1 -1
- package/src/interfaces/IJBRulesetDataHook.sol +5 -4
- package/src/libraries/JBCashOuts.sol +1 -1
- package/src/libraries/JBConstants.sol +1 -1
- package/src/libraries/JBCurrencyIds.sol +1 -1
- package/src/libraries/JBFees.sol +1 -1
- package/src/libraries/JBFixedPointNumber.sol +1 -1
- package/src/libraries/JBMetadataResolver.sol +1 -1
- package/src/libraries/JBPayoutSplitGroupLib.sol +3 -1
- package/src/libraries/JBRulesetMetadataResolver.sol +1 -1
- package/src/libraries/JBSplitGroupIds.sol +1 -1
- package/src/libraries/JBSurplus.sol +1 -1
- package/src/structs/JBSplit.sol +4 -1
- package/test/TestForwardedTokenConsumption.sol +418 -0
- package/test/audit/CycledSurplusAllowanceReset.t.sol +184 -0
- package/test/units/static/JBController/TestPreviewMintOf.sol +5 -3
- package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +15 -11
- package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +6 -0
- package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +3 -0
- package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +3 -0
- package/test/units/static/JBMultiTerminal/TestPay.sol +7 -15
- package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +1 -1
- package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +1 -1
- package/CHANGE_LOG.md +0 -479
package/src/libraries/JBFees.sol
CHANGED
|
@@ -77,6 +77,7 @@ library JBPayoutSplitGroupLib {
|
|
|
77
77
|
uint256 payoutAmount = mulDiv(leftoverAmount, split.percent, leftoverPercentage);
|
|
78
78
|
|
|
79
79
|
// The final payout amount after taking out any fees.
|
|
80
|
+
// slither-disable-next-line calls-loop
|
|
80
81
|
uint256 netPayoutAmount = _sendPayoutToSplit({
|
|
81
82
|
store: store, split: split, projectId: projectId, token: token, amount: payoutAmount, caller: caller
|
|
82
83
|
});
|
|
@@ -133,7 +134,7 @@ library JBPayoutSplitGroupLib {
|
|
|
133
134
|
// split from DoS-ing the entire payout. Failed splits' amounts are returned to the project balance via
|
|
134
135
|
// `recordAddedBalanceFor`. Payout limit consumption is correct because the project authorized the
|
|
135
136
|
// distribution.
|
|
136
|
-
// slither-disable-next-line reentrancy-events
|
|
137
|
+
// slither-disable-next-line reentrancy-events,calls-loop
|
|
137
138
|
try IJBPayoutSplitGroupExecutor(address(this))
|
|
138
139
|
.executePayout({
|
|
139
140
|
split: split, projectId: projectId, token: token, amount: amount, originalMessageSender: caller
|
|
@@ -147,6 +148,7 @@ library JBPayoutSplitGroupLib {
|
|
|
147
148
|
});
|
|
148
149
|
|
|
149
150
|
// Add balance back to the project.
|
|
151
|
+
// slither-disable-next-line calls-loop
|
|
150
152
|
store.recordAddedBalanceFor({projectId: projectId, token: token, amount: amount});
|
|
151
153
|
|
|
152
154
|
// Since the payout failed the netPayoutAmount is zero.
|
package/src/structs/JBSplit.sol
CHANGED
|
@@ -24,7 +24,10 @@ import {IJBSplitHook} from "./../interfaces/IJBSplitHook.sol";
|
|
|
24
24
|
/// @custom:member preferAddToBalance If this split were to `pay` a project through its terminal, this flag indicates
|
|
25
25
|
/// whether it should prefer using the terminal's `addToBalance` function instead.
|
|
26
26
|
/// @custom:member lockedUntil The split cannot be changed until this timestamp. The `lockedUntil` timestamp can be
|
|
27
|
-
/// increased while a split is locked. If `lockedUntil` is zero, this split can be changed at any time.
|
|
27
|
+
/// increased while a split is locked. If `lockedUntil` is zero, this split can be changed at any time. This lock is
|
|
28
|
+
/// enforced only when rewriting the same split table. Queueing a successor ruleset with a different `rulesetId` can
|
|
29
|
+
/// still replace future payout behavior before `lockedUntil`, so applications that need cross-ruleset continuity must
|
|
30
|
+
/// preserve those splits at the governance/configuration layer.
|
|
28
31
|
/// @custom:member hook A contract which will receive this split's tokens and properties, and can define custom
|
|
29
32
|
/// behavior.
|
|
30
33
|
// forge-lint: disable-next-line(pascal-case-struct)
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.8.6;
|
|
3
|
+
|
|
4
|
+
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
5
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
|
+
|
|
7
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
8
|
+
import {JBMultiTerminal} from "../src/JBMultiTerminal.sol";
|
|
9
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
10
|
+
import {IJBCashOutHook} from "../src/interfaces/IJBCashOutHook.sol";
|
|
11
|
+
import {IJBMultiTerminal} from "../src/interfaces/IJBMultiTerminal.sol";
|
|
12
|
+
import {IJBPayHook} from "../src/interfaces/IJBPayHook.sol";
|
|
13
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
14
|
+
import {IJBRulesetDataHook} from "../src/interfaces/IJBRulesetDataHook.sol";
|
|
15
|
+
import {IJBSplitHook} from "../src/interfaces/IJBSplitHook.sol";
|
|
16
|
+
import {IJBTokens} from "../src/interfaces/IJBTokens.sol";
|
|
17
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
18
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
19
|
+
import {JBAfterCashOutRecordedContext} from "../src/structs/JBAfterCashOutRecordedContext.sol";
|
|
20
|
+
import {JBAfterPayRecordedContext} from "../src/structs/JBAfterPayRecordedContext.sol";
|
|
21
|
+
import {JBCashOutHookSpecification} from "../src/structs/JBCashOutHookSpecification.sol";
|
|
22
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
23
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
24
|
+
import {JBPayHookSpecification} from "../src/structs/JBPayHookSpecification.sol";
|
|
25
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
26
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
27
|
+
import {JBSplit} from "../src/structs/JBSplit.sol";
|
|
28
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
29
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
30
|
+
|
|
31
|
+
contract TestForwardedTokenConsumption_Local is TestBaseWorkflow {
|
|
32
|
+
uint112 private constant _WEIGHT = 1000 * 10 ** 18;
|
|
33
|
+
uint256 private constant _PAY_AMOUNT = 10 * 10 ** 6;
|
|
34
|
+
uint256 private constant _HOOK_FORWARD_AMOUNT = 1 * 10 ** 6;
|
|
35
|
+
uint256 private constant _PAYOUT_AMOUNT = 4 * 10 ** 6;
|
|
36
|
+
address private constant _DATA_HOOK = address(bytes20(keccak256("datahook")));
|
|
37
|
+
|
|
38
|
+
IJBController private _controller;
|
|
39
|
+
IJBMultiTerminal private _terminal;
|
|
40
|
+
IJBMultiTerminal private _terminal2;
|
|
41
|
+
IJBTokens private _tokens;
|
|
42
|
+
address private _projectOwner;
|
|
43
|
+
|
|
44
|
+
uint64 private _projectId;
|
|
45
|
+
|
|
46
|
+
function setUp() public override {
|
|
47
|
+
super.setUp();
|
|
48
|
+
|
|
49
|
+
_controller = jbController();
|
|
50
|
+
_terminal = jbMultiTerminal();
|
|
51
|
+
_terminal2 = jbMultiTerminal2();
|
|
52
|
+
_tokens = jbTokens();
|
|
53
|
+
_projectOwner = multisig();
|
|
54
|
+
|
|
55
|
+
// Launch the fee beneficiary project first so project ID 1 has a terminal and accounting context.
|
|
56
|
+
_launchProject({
|
|
57
|
+
terminal: _terminal,
|
|
58
|
+
projectUri: "fee-project",
|
|
59
|
+
metadata: _metadataWithHooks({useDataHookForPay: true, useDataHookForCashOut: true, dataHook: _DATA_HOOK}),
|
|
60
|
+
splitGroups: new JBSplitGroup[](0),
|
|
61
|
+
fundAccessLimitGroups: new JBFundAccessLimitGroup[](0)
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
_projectId = uint64(
|
|
65
|
+
_launchProject({
|
|
66
|
+
terminal: _terminal,
|
|
67
|
+
projectUri: "hook-project",
|
|
68
|
+
metadata: _metadataWithHooks({
|
|
69
|
+
useDataHookForPay: true, useDataHookForCashOut: true, dataHook: _DATA_HOOK
|
|
70
|
+
}),
|
|
71
|
+
splitGroups: new JBSplitGroup[](0),
|
|
72
|
+
fundAccessLimitGroups: new JBFundAccessLimitGroup[](0)
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function test_RevertIfERC20PayHookDoesNotConsumeForwardedTokens() external {
|
|
78
|
+
NonConsumingPayHook hook = new NonConsumingPayHook();
|
|
79
|
+
JBPayHookSpecification[] memory specifications = new JBPayHookSpecification[](1);
|
|
80
|
+
specifications[0] =
|
|
81
|
+
JBPayHookSpecification({hook: hook, noop: false, amount: _HOOK_FORWARD_AMOUNT, metadata: ""});
|
|
82
|
+
|
|
83
|
+
vm.mockCall(
|
|
84
|
+
_DATA_HOOK,
|
|
85
|
+
abi.encodeWithSelector(IJBRulesetDataHook.beforePayRecordedWith.selector),
|
|
86
|
+
abi.encode(_WEIGHT, specifications)
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
vm.prank(multisig());
|
|
90
|
+
jbFeelessAddresses().setFeelessAddress(address(hook), true);
|
|
91
|
+
|
|
92
|
+
address payer = makeAddr("payer");
|
|
93
|
+
usdcToken().mint(payer, _PAY_AMOUNT);
|
|
94
|
+
vm.prank(payer);
|
|
95
|
+
usdcToken().approve(address(_terminal), _PAY_AMOUNT);
|
|
96
|
+
|
|
97
|
+
vm.expectRevert(
|
|
98
|
+
abi.encodeWithSelector(
|
|
99
|
+
JBMultiTerminal.JBMultiTerminal_TemporaryAllowanceNotConsumed.selector,
|
|
100
|
+
address(usdcToken()),
|
|
101
|
+
address(hook),
|
|
102
|
+
_HOOK_FORWARD_AMOUNT
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
vm.prank(payer);
|
|
106
|
+
_terminal.pay({
|
|
107
|
+
projectId: _projectId,
|
|
108
|
+
token: address(usdcToken()),
|
|
109
|
+
amount: _PAY_AMOUNT,
|
|
110
|
+
beneficiary: payer,
|
|
111
|
+
minReturnedTokens: 0,
|
|
112
|
+
memo: "",
|
|
113
|
+
metadata: ""
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function test_RevertIfERC20CashOutHookDoesNotConsumeForwardedTokens() external {
|
|
118
|
+
JBPayHookSpecification[] memory emptyPaySpecifications = new JBPayHookSpecification[](0);
|
|
119
|
+
vm.mockCall(
|
|
120
|
+
_DATA_HOOK,
|
|
121
|
+
abi.encodeWithSelector(IJBRulesetDataHook.beforePayRecordedWith.selector),
|
|
122
|
+
abi.encode(_WEIGHT, emptyPaySpecifications)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
usdcToken().mint(address(this), _PAY_AMOUNT);
|
|
126
|
+
usdcToken().approve(address(_terminal), _PAY_AMOUNT);
|
|
127
|
+
|
|
128
|
+
_terminal.pay({
|
|
129
|
+
projectId: _projectId,
|
|
130
|
+
token: address(usdcToken()),
|
|
131
|
+
amount: _PAY_AMOUNT,
|
|
132
|
+
beneficiary: address(this),
|
|
133
|
+
minReturnedTokens: 0,
|
|
134
|
+
memo: "",
|
|
135
|
+
metadata: ""
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
uint256 cashOutCount = _tokens.totalBalanceOf(address(this), _projectId) / 2;
|
|
139
|
+
|
|
140
|
+
NonConsumingCashOutHook hook = new NonConsumingCashOutHook();
|
|
141
|
+
JBCashOutHookSpecification[] memory specifications = new JBCashOutHookSpecification[](1);
|
|
142
|
+
specifications[0] =
|
|
143
|
+
JBCashOutHookSpecification({hook: hook, noop: false, amount: _HOOK_FORWARD_AMOUNT, metadata: ""});
|
|
144
|
+
|
|
145
|
+
vm.mockCall(
|
|
146
|
+
_DATA_HOOK,
|
|
147
|
+
abi.encodeWithSelector(IJBRulesetDataHook.beforeCashOutRecordedWith.selector),
|
|
148
|
+
abi.encode(0, cashOutCount, _controller.totalTokenSupplyWithReservedTokensOf(_projectId), specifications)
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
vm.prank(multisig());
|
|
152
|
+
jbFeelessAddresses().setFeelessAddress(address(hook), true);
|
|
153
|
+
|
|
154
|
+
vm.expectRevert(
|
|
155
|
+
abi.encodeWithSelector(
|
|
156
|
+
JBMultiTerminal.JBMultiTerminal_TemporaryAllowanceNotConsumed.selector,
|
|
157
|
+
address(usdcToken()),
|
|
158
|
+
address(hook),
|
|
159
|
+
_HOOK_FORWARD_AMOUNT
|
|
160
|
+
)
|
|
161
|
+
);
|
|
162
|
+
_terminal.cashOutTokensOf({
|
|
163
|
+
holder: address(this),
|
|
164
|
+
projectId: _projectId,
|
|
165
|
+
cashOutCount: cashOutCount,
|
|
166
|
+
tokenToReclaim: address(usdcToken()),
|
|
167
|
+
minTokensReclaimed: 0,
|
|
168
|
+
beneficiary: payable(address(this)),
|
|
169
|
+
metadata: ""
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function test_SendPayoutsToMultiTerminalAddToBalanceConsumesForwardedAllowance() external {
|
|
174
|
+
uint256 recipientProjectId = _launchProject({
|
|
175
|
+
terminal: _terminal2,
|
|
176
|
+
projectUri: "recipient-add-to-balance",
|
|
177
|
+
metadata: _metadataWithHooks({
|
|
178
|
+
useDataHookForPay: false, useDataHookForCashOut: false, dataHook: address(0)
|
|
179
|
+
}),
|
|
180
|
+
splitGroups: new JBSplitGroup[](0),
|
|
181
|
+
fundAccessLimitGroups: new JBFundAccessLimitGroup[](0)
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
uint256 sourceProjectId = _launchProject({
|
|
185
|
+
terminal: _terminal,
|
|
186
|
+
projectUri: "source-add-to-balance",
|
|
187
|
+
metadata: _metadataWithHooks({
|
|
188
|
+
useDataHookForPay: false, useDataHookForCashOut: false, dataHook: address(0)
|
|
189
|
+
}),
|
|
190
|
+
splitGroups: _splitGroupsToProject({targetProjectId: recipientProjectId, preferAddToBalance: true}),
|
|
191
|
+
fundAccessLimitGroups: _usdcPayoutLimitGroups({terminal: _terminal, payoutAmount: _PAYOUT_AMOUNT})
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
usdcToken().mint(address(this), _PAYOUT_AMOUNT);
|
|
195
|
+
usdcToken().approve(address(_terminal), _PAYOUT_AMOUNT);
|
|
196
|
+
|
|
197
|
+
_terminal.pay({
|
|
198
|
+
projectId: sourceProjectId,
|
|
199
|
+
token: address(usdcToken()),
|
|
200
|
+
amount: _PAYOUT_AMOUNT,
|
|
201
|
+
beneficiary: address(this),
|
|
202
|
+
minReturnedTokens: 0,
|
|
203
|
+
memo: "",
|
|
204
|
+
metadata: ""
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
uint256 fee = _PAYOUT_AMOUNT * _terminal.FEE() / JBConstants.MAX_FEE;
|
|
208
|
+
uint256 expectedNetPayout = _PAYOUT_AMOUNT - fee;
|
|
209
|
+
|
|
210
|
+
_terminal.sendPayoutsOf({
|
|
211
|
+
projectId: sourceProjectId,
|
|
212
|
+
amount: _PAYOUT_AMOUNT,
|
|
213
|
+
currency: uint32(uint160(address(usdcToken()))),
|
|
214
|
+
token: address(usdcToken()),
|
|
215
|
+
minTokensPaidOut: 0
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
assertEq(usdcToken().allowance(address(_terminal), address(_terminal2)), 0);
|
|
219
|
+
assertEq(jbTerminalStore().balanceOf(address(_terminal), sourceProjectId, address(usdcToken())), fee);
|
|
220
|
+
assertEq(
|
|
221
|
+
jbTerminalStore().balanceOf(address(_terminal2), recipientProjectId, address(usdcToken())),
|
|
222
|
+
expectedNetPayout
|
|
223
|
+
);
|
|
224
|
+
assertEq(usdcToken().balanceOf(address(_terminal2)), expectedNetPayout);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function test_SendPayoutsToMultiTerminalPayConsumesForwardedAllowance() external {
|
|
228
|
+
uint256 recipientProjectId = _launchProject({
|
|
229
|
+
terminal: _terminal2,
|
|
230
|
+
projectUri: "recipient-pay",
|
|
231
|
+
metadata: _metadataWithHooks({
|
|
232
|
+
useDataHookForPay: false, useDataHookForCashOut: false, dataHook: address(0)
|
|
233
|
+
}),
|
|
234
|
+
splitGroups: new JBSplitGroup[](0),
|
|
235
|
+
fundAccessLimitGroups: new JBFundAccessLimitGroup[](0)
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
uint256 sourceProjectId = _launchProject({
|
|
239
|
+
terminal: _terminal,
|
|
240
|
+
projectUri: "source-pay",
|
|
241
|
+
metadata: _metadataWithHooks({
|
|
242
|
+
useDataHookForPay: false, useDataHookForCashOut: false, dataHook: address(0)
|
|
243
|
+
}),
|
|
244
|
+
splitGroups: _splitGroupsToProject({targetProjectId: recipientProjectId, preferAddToBalance: false}),
|
|
245
|
+
fundAccessLimitGroups: _usdcPayoutLimitGroups({terminal: _terminal, payoutAmount: _PAYOUT_AMOUNT})
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
usdcToken().mint(address(this), _PAYOUT_AMOUNT);
|
|
249
|
+
usdcToken().approve(address(_terminal), _PAYOUT_AMOUNT);
|
|
250
|
+
|
|
251
|
+
_terminal.pay({
|
|
252
|
+
projectId: sourceProjectId,
|
|
253
|
+
token: address(usdcToken()),
|
|
254
|
+
amount: _PAYOUT_AMOUNT,
|
|
255
|
+
beneficiary: address(this),
|
|
256
|
+
minReturnedTokens: 0,
|
|
257
|
+
memo: "",
|
|
258
|
+
metadata: ""
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
uint256 fee = _PAYOUT_AMOUNT * _terminal.FEE() / JBConstants.MAX_FEE;
|
|
262
|
+
uint256 expectedNetPayout = _PAYOUT_AMOUNT - fee;
|
|
263
|
+
|
|
264
|
+
_terminal.sendPayoutsOf({
|
|
265
|
+
projectId: sourceProjectId,
|
|
266
|
+
amount: _PAYOUT_AMOUNT,
|
|
267
|
+
currency: uint32(uint160(address(usdcToken()))),
|
|
268
|
+
token: address(usdcToken()),
|
|
269
|
+
minTokensPaidOut: 0
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
assertEq(usdcToken().allowance(address(_terminal), address(_terminal2)), 0);
|
|
273
|
+
assertEq(jbTerminalStore().balanceOf(address(_terminal), sourceProjectId, address(usdcToken())), fee);
|
|
274
|
+
assertEq(
|
|
275
|
+
jbTerminalStore().balanceOf(address(_terminal2), recipientProjectId, address(usdcToken())),
|
|
276
|
+
expectedNetPayout
|
|
277
|
+
);
|
|
278
|
+
assertEq(usdcToken().balanceOf(address(_terminal2)), expectedNetPayout);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function _launchProject(
|
|
282
|
+
IJBMultiTerminal terminal,
|
|
283
|
+
string memory projectUri,
|
|
284
|
+
JBRulesetMetadata memory metadata,
|
|
285
|
+
JBSplitGroup[] memory splitGroups,
|
|
286
|
+
JBFundAccessLimitGroup[] memory fundAccessLimitGroups
|
|
287
|
+
)
|
|
288
|
+
internal
|
|
289
|
+
returns (uint256)
|
|
290
|
+
{
|
|
291
|
+
JBRulesetConfig[] memory rulesetConfigurations = new JBRulesetConfig[](1);
|
|
292
|
+
rulesetConfigurations[0].mustStartAtOrAfter = 0;
|
|
293
|
+
rulesetConfigurations[0].duration = 0;
|
|
294
|
+
rulesetConfigurations[0].weight = _WEIGHT;
|
|
295
|
+
rulesetConfigurations[0].weightCutPercent = 0;
|
|
296
|
+
rulesetConfigurations[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
297
|
+
rulesetConfigurations[0].metadata = metadata;
|
|
298
|
+
rulesetConfigurations[0].splitGroups = splitGroups;
|
|
299
|
+
rulesetConfigurations[0].fundAccessLimitGroups = fundAccessLimitGroups;
|
|
300
|
+
|
|
301
|
+
JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
|
|
302
|
+
terminalConfigurations[0] =
|
|
303
|
+
JBTerminalConfig({terminal: terminal, accountingContextsToAccept: _usdcAccountingContexts()});
|
|
304
|
+
|
|
305
|
+
return _controller.launchProjectFor({
|
|
306
|
+
owner: _projectOwner,
|
|
307
|
+
projectUri: projectUri,
|
|
308
|
+
rulesetConfigurations: rulesetConfigurations,
|
|
309
|
+
terminalConfigurations: terminalConfigurations,
|
|
310
|
+
memo: ""
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function _metadataWithHooks(
|
|
315
|
+
bool useDataHookForPay,
|
|
316
|
+
bool useDataHookForCashOut,
|
|
317
|
+
address dataHook
|
|
318
|
+
)
|
|
319
|
+
internal
|
|
320
|
+
view
|
|
321
|
+
returns (JBRulesetMetadata memory)
|
|
322
|
+
{
|
|
323
|
+
return JBRulesetMetadata({
|
|
324
|
+
reservedPercent: 0,
|
|
325
|
+
cashOutTaxRate: 0,
|
|
326
|
+
baseCurrency: uint32(uint160(address(usdcToken()))),
|
|
327
|
+
pausePay: false,
|
|
328
|
+
pauseCreditTransfers: false,
|
|
329
|
+
allowOwnerMinting: false,
|
|
330
|
+
allowSetCustomToken: false,
|
|
331
|
+
allowTerminalMigration: false,
|
|
332
|
+
allowSetTerminals: false,
|
|
333
|
+
ownerMustSendPayouts: false,
|
|
334
|
+
allowSetController: false,
|
|
335
|
+
allowAddAccountingContext: true,
|
|
336
|
+
allowAddPriceFeed: false,
|
|
337
|
+
holdFees: false,
|
|
338
|
+
useTotalSurplusForCashOuts: false,
|
|
339
|
+
useDataHookForPay: useDataHookForPay,
|
|
340
|
+
useDataHookForCashOut: useDataHookForCashOut,
|
|
341
|
+
dataHook: dataHook,
|
|
342
|
+
metadata: 0
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function _splitGroupsToProject(
|
|
347
|
+
uint256 targetProjectId,
|
|
348
|
+
bool preferAddToBalance
|
|
349
|
+
)
|
|
350
|
+
internal
|
|
351
|
+
view
|
|
352
|
+
returns (JBSplitGroup[] memory)
|
|
353
|
+
{
|
|
354
|
+
JBSplit[] memory splits = new JBSplit[](1);
|
|
355
|
+
splits[0].percent = uint32(JBConstants.SPLITS_TOTAL_PERCENT);
|
|
356
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
357
|
+
splits[0].projectId = uint64(targetProjectId);
|
|
358
|
+
splits[0].beneficiary = payable(address(0));
|
|
359
|
+
splits[0].preferAddToBalance = preferAddToBalance;
|
|
360
|
+
splits[0].lockedUntil = 0;
|
|
361
|
+
splits[0].hook = IJBSplitHook(address(0));
|
|
362
|
+
|
|
363
|
+
JBSplitGroup[] memory splitGroups = new JBSplitGroup[](1);
|
|
364
|
+
splitGroups[0] = JBSplitGroup({groupId: uint256(uint160(address(usdcToken()))), splits: splits});
|
|
365
|
+
|
|
366
|
+
return splitGroups;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function _usdcAccountingContexts() internal view returns (JBAccountingContext[] memory) {
|
|
370
|
+
JBAccountingContext[] memory accountingContexts = new JBAccountingContext[](1);
|
|
371
|
+
accountingContexts[0] = JBAccountingContext({
|
|
372
|
+
token: address(usdcToken()),
|
|
373
|
+
decimals: usdcToken().decimals(),
|
|
374
|
+
currency: uint32(uint160(address(usdcToken())))
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
return accountingContexts;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function _usdcPayoutLimitGroups(
|
|
381
|
+
IJBMultiTerminal terminal,
|
|
382
|
+
uint256 payoutAmount
|
|
383
|
+
)
|
|
384
|
+
internal
|
|
385
|
+
view
|
|
386
|
+
returns (JBFundAccessLimitGroup[] memory)
|
|
387
|
+
{
|
|
388
|
+
JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](1);
|
|
389
|
+
payoutLimits[0] =
|
|
390
|
+
JBCurrencyAmount({amount: uint224(payoutAmount), currency: uint32(uint160(address(usdcToken())))});
|
|
391
|
+
|
|
392
|
+
JBFundAccessLimitGroup[] memory fundAccessLimitGroups = new JBFundAccessLimitGroup[](1);
|
|
393
|
+
fundAccessLimitGroups[0] = JBFundAccessLimitGroup({
|
|
394
|
+
terminal: address(terminal),
|
|
395
|
+
token: address(usdcToken()),
|
|
396
|
+
payoutLimits: payoutLimits,
|
|
397
|
+
surplusAllowances: new JBCurrencyAmount[](0)
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
return fundAccessLimitGroups;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
contract NonConsumingPayHook is ERC165, IJBPayHook {
|
|
405
|
+
function afterPayRecordedWith(JBAfterPayRecordedContext calldata) external payable override {}
|
|
406
|
+
|
|
407
|
+
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
|
|
408
|
+
return interfaceId == type(IJBPayHook).interfaceId || super.supportsInterface(interfaceId);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
contract NonConsumingCashOutHook is ERC165, IJBCashOutHook {
|
|
413
|
+
function afterCashOutRecordedWith(JBAfterCashOutRecordedContext calldata) external payable override {}
|
|
414
|
+
|
|
415
|
+
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
|
|
416
|
+
return interfaceId == type(IJBCashOutHook).interfaceId || super.supportsInterface(interfaceId);
|
|
417
|
+
}
|
|
418
|
+
}
|