@bananapus/core-v6 0.0.9 → 0.0.11
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 +327 -0
- package/ARCHITECTURE.md +115 -0
- package/RISKS.md +68 -0
- package/SKILLS.md +5 -0
- package/STYLE_GUIDE.md +465 -0
- package/foundry.toml +1 -2
- 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/JBDirectory.sol
CHANGED
|
@@ -79,102 +79,10 @@ contract JBDirectory is JBPermissioned, Ownable, IJBDirectory {
|
|
|
79
79
|
PROJECTS = projects;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
//*********************************************************************//
|
|
83
|
-
// ------------------------- external views -------------------------- //
|
|
84
|
-
//*********************************************************************//
|
|
85
|
-
|
|
86
|
-
/// @notice The primary terminal that a project uses for the specified token.
|
|
87
|
-
/// @dev Returns the first terminal that accepts the token if the project hasn't explicitly set a primary terminal
|
|
88
|
-
/// for it.
|
|
89
|
-
/// @dev Returns the zero address if no terminal accepts the token.
|
|
90
|
-
/// @param projectId The ID of the project to get the primary terminal of.
|
|
91
|
-
/// @param token The token that the terminal accepts.
|
|
92
|
-
/// @return The primary terminal's address.
|
|
93
|
-
function primaryTerminalOf(uint256 projectId, address token) external view override returns (IJBTerminal) {
|
|
94
|
-
// Keep a reference to the primary terminal for the provided project ID and token.
|
|
95
|
-
IJBTerminal primaryTerminal = _primaryTerminalOf[projectId][token];
|
|
96
|
-
|
|
97
|
-
// If a primary terminal for the token was explicitly set and it's one of the project's terminals, return it.
|
|
98
|
-
if (
|
|
99
|
-
primaryTerminal != IJBTerminal(address(0))
|
|
100
|
-
&& isTerminalOf({projectId: projectId, terminal: primaryTerminal})
|
|
101
|
-
) {
|
|
102
|
-
return primaryTerminal;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Keep a reference to the project's terminals.
|
|
106
|
-
IJBTerminal[] memory terminals = _terminalsOf[projectId];
|
|
107
|
-
|
|
108
|
-
// Keep a reference to the number of terminals the project has.
|
|
109
|
-
uint256 numberOfTerminals = terminals.length;
|
|
110
|
-
|
|
111
|
-
// Return the first terminal which accepts the specified token.
|
|
112
|
-
for (uint256 i; i < numberOfTerminals; i++) {
|
|
113
|
-
// Keep a reference to the terminal being iterated on.
|
|
114
|
-
IJBTerminal terminal = terminals[i];
|
|
115
|
-
|
|
116
|
-
// If the terminal accepts the specified token, return it.
|
|
117
|
-
// slither-disable-next-line calls-loop
|
|
118
|
-
if (terminal.accountingContextForTokenOf({projectId: projectId, token: token}).token != address(0)) {
|
|
119
|
-
return terminal;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Not found.
|
|
124
|
-
return IJBTerminal(address(0));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/// @notice The specified project's terminals.
|
|
128
|
-
/// @param projectId The ID of the project to get the terminals of.
|
|
129
|
-
/// @return An array of the project's terminal addresses.
|
|
130
|
-
function terminalsOf(uint256 projectId) external view override returns (IJBTerminal[] memory) {
|
|
131
|
-
return _terminalsOf[projectId];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
//*********************************************************************//
|
|
135
|
-
// -------------------------- public views --------------------------- //
|
|
136
|
-
//*********************************************************************//
|
|
137
|
-
|
|
138
|
-
/// @notice Check if a project uses a specific terminal.
|
|
139
|
-
/// @param projectId The ID of the project to check.
|
|
140
|
-
/// @param terminal The terminal to check for.
|
|
141
|
-
/// @return A flag indicating whether the project uses the terminal.
|
|
142
|
-
function isTerminalOf(uint256 projectId, IJBTerminal terminal) public view override returns (bool) {
|
|
143
|
-
// Keep a reference to the project's terminals.
|
|
144
|
-
IJBTerminal[] memory terminals = _terminalsOf[projectId];
|
|
145
|
-
|
|
146
|
-
// Keep a reference to the number of terminals the project has.
|
|
147
|
-
uint256 numberOfTerminals = terminals.length;
|
|
148
|
-
|
|
149
|
-
// Loop through and return true if the terminal is found.
|
|
150
|
-
for (uint256 i; i < numberOfTerminals; i++) {
|
|
151
|
-
if (terminals[i] == terminal) return true;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Otherwise, return false.
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
82
|
//*********************************************************************//
|
|
159
83
|
// ---------------------- external transactions ---------------------- //
|
|
160
84
|
//*********************************************************************//
|
|
161
85
|
|
|
162
|
-
/// @notice Add or remove an address/contract from a list of trusted addresses which are allowed to set a first
|
|
163
|
-
/// controller for projects.
|
|
164
|
-
/// @dev Only this contract's owner can call this function.
|
|
165
|
-
/// @dev These addresses are vetted controllers as well as contracts designed to launch new projects.
|
|
166
|
-
/// @dev A project can set its own controller without being on this list.
|
|
167
|
-
/// @dev If you would like to add an address/contract to this list, please reach out to this contract's owner.
|
|
168
|
-
/// @param addr The address to allow or not allow.
|
|
169
|
-
/// @param flag Whether the address is allowed to set first controllers for projects. Use `true` to allow and
|
|
170
|
-
/// `false` to not allow.
|
|
171
|
-
function setIsAllowedToSetFirstController(address addr, bool flag) external override onlyOwner {
|
|
172
|
-
// Set the flag in the allowlist.
|
|
173
|
-
isAllowedToSetFirstController[addr] = flag;
|
|
174
|
-
|
|
175
|
-
emit SetIsAllowedToSetFirstController({addr: addr, isAllowed: flag, caller: msg.sender});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
86
|
/// @notice Set a project's controller. Controllers manage how terminals interact with tokens and rulesets.
|
|
179
87
|
/// @dev Can only be called if:
|
|
180
88
|
/// - The ruleset's metadata has `allowSetController` enabled, and the message's sender is the project's owner or an
|
|
@@ -240,6 +148,22 @@ contract JBDirectory is JBPermissioned, Ownable, IJBDirectory {
|
|
|
240
148
|
}
|
|
241
149
|
}
|
|
242
150
|
|
|
151
|
+
/// @notice Add or remove an address/contract from a list of trusted addresses which are allowed to set a first
|
|
152
|
+
/// controller for projects.
|
|
153
|
+
/// @dev Only this contract's owner can call this function.
|
|
154
|
+
/// @dev These addresses are vetted controllers as well as contracts designed to launch new projects.
|
|
155
|
+
/// @dev A project can set its own controller without being on this list.
|
|
156
|
+
/// @dev If you would like to add an address/contract to this list, please reach out to this contract's owner.
|
|
157
|
+
/// @param addr The address to allow or not allow.
|
|
158
|
+
/// @param flag Whether the address is allowed to set first controllers for projects. Use `true` to allow and
|
|
159
|
+
/// `false` to not allow.
|
|
160
|
+
function setIsAllowedToSetFirstController(address addr, bool flag) external override onlyOwner {
|
|
161
|
+
// Set the flag in the allowlist.
|
|
162
|
+
isAllowedToSetFirstController[addr] = flag;
|
|
163
|
+
|
|
164
|
+
emit SetIsAllowedToSetFirstController({addr: addr, isAllowed: flag, caller: msg.sender});
|
|
165
|
+
}
|
|
166
|
+
|
|
243
167
|
/// @notice Set a project's primary terminal for a token.
|
|
244
168
|
/// @dev The primary terminal for a token is where payments in that token are routed to by default.
|
|
245
169
|
/// @dev This is useful in cases where a project has multiple terminals which accept the same token.
|
|
@@ -312,7 +236,83 @@ contract JBDirectory is JBPermissioned, Ownable, IJBDirectory {
|
|
|
312
236
|
}
|
|
313
237
|
|
|
314
238
|
//*********************************************************************//
|
|
315
|
-
//
|
|
239
|
+
// ------------------------- external views -------------------------- //
|
|
240
|
+
//*********************************************************************//
|
|
241
|
+
|
|
242
|
+
/// @notice The primary terminal that a project uses for the specified token.
|
|
243
|
+
/// @dev Returns the first terminal that accepts the token if the project hasn't explicitly set a primary terminal
|
|
244
|
+
/// for it.
|
|
245
|
+
/// @dev Returns the zero address if no terminal accepts the token.
|
|
246
|
+
/// @param projectId The ID of the project to get the primary terminal of.
|
|
247
|
+
/// @param token The token that the terminal accepts.
|
|
248
|
+
/// @return The primary terminal's address.
|
|
249
|
+
function primaryTerminalOf(uint256 projectId, address token) external view override returns (IJBTerminal) {
|
|
250
|
+
// Keep a reference to the primary terminal for the provided project ID and token.
|
|
251
|
+
IJBTerminal primaryTerminal = _primaryTerminalOf[projectId][token];
|
|
252
|
+
|
|
253
|
+
// If a primary terminal for the token was explicitly set and it's one of the project's terminals, return it.
|
|
254
|
+
if (
|
|
255
|
+
primaryTerminal != IJBTerminal(address(0))
|
|
256
|
+
&& isTerminalOf({projectId: projectId, terminal: primaryTerminal})
|
|
257
|
+
) {
|
|
258
|
+
return primaryTerminal;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Keep a reference to the project's terminals.
|
|
262
|
+
IJBTerminal[] memory terminals = _terminalsOf[projectId];
|
|
263
|
+
|
|
264
|
+
// Keep a reference to the number of terminals the project has.
|
|
265
|
+
uint256 numberOfTerminals = terminals.length;
|
|
266
|
+
|
|
267
|
+
// Return the first terminal which accepts the specified token.
|
|
268
|
+
for (uint256 i; i < numberOfTerminals; i++) {
|
|
269
|
+
// Keep a reference to the terminal being iterated on.
|
|
270
|
+
IJBTerminal terminal = terminals[i];
|
|
271
|
+
|
|
272
|
+
// If the terminal accepts the specified token, return it.
|
|
273
|
+
// slither-disable-next-line calls-loop
|
|
274
|
+
if (terminal.accountingContextForTokenOf({projectId: projectId, token: token}).token != address(0)) {
|
|
275
|
+
return terminal;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Not found.
|
|
280
|
+
return IJBTerminal(address(0));
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/// @notice The specified project's terminals.
|
|
284
|
+
/// @param projectId The ID of the project to get the terminals of.
|
|
285
|
+
/// @return An array of the project's terminal addresses.
|
|
286
|
+
function terminalsOf(uint256 projectId) external view override returns (IJBTerminal[] memory) {
|
|
287
|
+
return _terminalsOf[projectId];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
//*********************************************************************//
|
|
291
|
+
// -------------------------- public views --------------------------- //
|
|
292
|
+
//*********************************************************************//
|
|
293
|
+
|
|
294
|
+
/// @notice Check if a project uses a specific terminal.
|
|
295
|
+
/// @param projectId The ID of the project to check.
|
|
296
|
+
/// @param terminal The terminal to check for.
|
|
297
|
+
/// @return A flag indicating whether the project uses the terminal.
|
|
298
|
+
function isTerminalOf(uint256 projectId, IJBTerminal terminal) public view override returns (bool) {
|
|
299
|
+
// Keep a reference to the project's terminals.
|
|
300
|
+
IJBTerminal[] memory terminals = _terminalsOf[projectId];
|
|
301
|
+
|
|
302
|
+
// Keep a reference to the number of terminals the project has.
|
|
303
|
+
uint256 numberOfTerminals = terminals.length;
|
|
304
|
+
|
|
305
|
+
// Loop through and return true if the terminal is found.
|
|
306
|
+
for (uint256 i; i < numberOfTerminals; i++) {
|
|
307
|
+
if (terminals[i] == terminal) return true;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Otherwise, return false.
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
//*********************************************************************//
|
|
315
|
+
// ---------------------- internal transactions ---------------------- //
|
|
316
316
|
//*********************************************************************//
|
|
317
317
|
|
|
318
318
|
/// @notice If a terminal hasn't already been added to a project's list of terminals, add it.
|
package/src/JBERC20.sol
CHANGED
|
@@ -38,44 +38,6 @@ contract JBERC20 is ERC20Votes, ERC20Permit, Ownable, IJBToken {
|
|
|
38
38
|
|
|
39
39
|
constructor() Ownable(address(this)) ERC20("invalid", "invalid") ERC20Permit("JBToken") {}
|
|
40
40
|
|
|
41
|
-
//*********************************************************************//
|
|
42
|
-
// -------------------------- public views --------------------------- //
|
|
43
|
-
//*********************************************************************//
|
|
44
|
-
|
|
45
|
-
/// @notice The balance of the given address.
|
|
46
|
-
/// @param account The account to get the balance of.
|
|
47
|
-
/// @return The number of tokens owned by the `account`, as a fixed point number with 18 decimals.
|
|
48
|
-
function balanceOf(address account) public view override(ERC20, IJBToken) returns (uint256) {
|
|
49
|
-
return super.balanceOf(account);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/// @notice This token can only be added to a project when its created by the `JBTokens` contract.
|
|
53
|
-
function canBeAddedTo(uint256) external pure override returns (bool) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/// @notice The number of decimals used for this token's fixed point accounting.
|
|
58
|
-
/// @return The number of decimals.
|
|
59
|
-
function decimals() public view override(ERC20, IJBToken) returns (uint8) {
|
|
60
|
-
return super.decimals();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/// @notice The token's name.
|
|
64
|
-
function name() public view virtual override returns (string memory) {
|
|
65
|
-
return _name;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/// @notice The token's symbol.
|
|
69
|
-
function symbol() public view virtual override returns (string memory) {
|
|
70
|
-
return _symbol;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/// @notice The total supply of this ERC20 i.e. the total number of tokens in existence.
|
|
74
|
-
/// @return The total supply of this ERC20, as a fixed point number.
|
|
75
|
-
function totalSupply() public view override(ERC20, IJBToken) returns (uint256) {
|
|
76
|
-
return super.totalSupply();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
41
|
//*********************************************************************//
|
|
80
42
|
// ---------------------- external transactions ---------------------- //
|
|
81
43
|
//*********************************************************************//
|
|
@@ -115,13 +77,55 @@ contract JBERC20 is ERC20Votes, ERC20Permit, Ownable, IJBToken {
|
|
|
115
77
|
_transferOwnership(owner);
|
|
116
78
|
}
|
|
117
79
|
|
|
80
|
+
//*********************************************************************//
|
|
81
|
+
// ------------------------- external views -------------------------- //
|
|
82
|
+
//*********************************************************************//
|
|
83
|
+
|
|
84
|
+
/// @notice This token can only be added to a project when its created by the `JBTokens` contract.
|
|
85
|
+
function canBeAddedTo(uint256) external pure override returns (bool) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//*********************************************************************//
|
|
90
|
+
// -------------------------- public views --------------------------- //
|
|
91
|
+
//*********************************************************************//
|
|
92
|
+
|
|
93
|
+
/// @notice The balance of the given address.
|
|
94
|
+
/// @param account The account to get the balance of.
|
|
95
|
+
/// @return The number of tokens owned by the `account`, as a fixed point number with 18 decimals.
|
|
96
|
+
function balanceOf(address account) public view override(ERC20, IJBToken) returns (uint256) {
|
|
97
|
+
return super.balanceOf(account);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// @notice The number of decimals used for this token's fixed point accounting.
|
|
101
|
+
/// @return The number of decimals.
|
|
102
|
+
function decimals() public view override(ERC20, IJBToken) returns (uint8) {
|
|
103
|
+
return super.decimals();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// @notice The token's name.
|
|
107
|
+
function name() public view virtual override returns (string memory) {
|
|
108
|
+
return _name;
|
|
109
|
+
}
|
|
110
|
+
|
|
118
111
|
/// @notice Required override.
|
|
119
112
|
function nonces(address owner) public view virtual override(ERC20Permit, Nonces) returns (uint256) {
|
|
120
113
|
return super.nonces(owner);
|
|
121
114
|
}
|
|
122
115
|
|
|
116
|
+
/// @notice The token's symbol.
|
|
117
|
+
function symbol() public view virtual override returns (string memory) {
|
|
118
|
+
return _symbol;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/// @notice The total supply of this ERC20 i.e. the total number of tokens in existence.
|
|
122
|
+
/// @return The total supply of this ERC20, as a fixed point number.
|
|
123
|
+
function totalSupply() public view override(ERC20, IJBToken) returns (uint256) {
|
|
124
|
+
return super.totalSupply();
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
//*********************************************************************//
|
|
124
|
-
//
|
|
128
|
+
// ---------------------- internal transactions ---------------------- //
|
|
125
129
|
//*********************************************************************//
|
|
126
130
|
|
|
127
131
|
/// @notice Required override.
|
|
@@ -26,18 +26,6 @@ contract JBFeelessAddresses is Ownable, IJBFeelessAddresses, IERC165 {
|
|
|
26
26
|
/// @param owner This contract's owner.
|
|
27
27
|
constructor(address owner) Ownable(owner) {}
|
|
28
28
|
|
|
29
|
-
//*********************************************************************//
|
|
30
|
-
// -------------------------- public views --------------------------- //
|
|
31
|
-
//*********************************************************************//
|
|
32
|
-
|
|
33
|
-
/// @notice Indicates whether this contract adheres to the specified interface.
|
|
34
|
-
/// @dev See {IERC165-supportsInterface}.
|
|
35
|
-
/// @param interfaceId The ID of the interface to check for adherence to.
|
|
36
|
-
/// @return A flag indicating if the provided interface ID is supported.
|
|
37
|
-
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
38
|
-
return interfaceId == type(IJBFeelessAddresses).interfaceId || interfaceId == type(IERC165).interfaceId;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
29
|
//*********************************************************************//
|
|
42
30
|
// ---------------------- external transactions ---------------------- //
|
|
43
31
|
//*********************************************************************//
|
|
@@ -51,4 +39,16 @@ contract JBFeelessAddresses is Ownable, IJBFeelessAddresses, IERC165 {
|
|
|
51
39
|
|
|
52
40
|
emit SetFeelessAddress({addr: addr, isFeeless: flag, caller: _msgSender()});
|
|
53
41
|
}
|
|
42
|
+
|
|
43
|
+
//*********************************************************************//
|
|
44
|
+
// -------------------------- public views --------------------------- //
|
|
45
|
+
//*********************************************************************//
|
|
46
|
+
|
|
47
|
+
/// @notice Indicates whether this contract adheres to the specified interface.
|
|
48
|
+
/// @dev See {IERC165-supportsInterface}.
|
|
49
|
+
/// @param interfaceId The ID of the interface to check for adherence to.
|
|
50
|
+
/// @return A flag indicating if the provided interface ID is supported.
|
|
51
|
+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
52
|
+
return interfaceId == type(IJBFeelessAddresses).interfaceId || interfaceId == type(IERC165).interfaceId;
|
|
53
|
+
}
|
|
54
54
|
}
|
|
@@ -57,6 +57,88 @@ contract JBFundAccessLimits is JBControlled, IJBFundAccessLimits {
|
|
|
57
57
|
// solhint-disable-next-line no-empty-blocks
|
|
58
58
|
constructor(IJBDirectory directory) JBControlled(directory) {}
|
|
59
59
|
|
|
60
|
+
//*********************************************************************//
|
|
61
|
+
// ---------------------- external transactions ---------------------- //
|
|
62
|
+
//*********************************************************************//
|
|
63
|
+
|
|
64
|
+
/// @notice Sets limits on the amount of funds a project can access from its terminals during a ruleset.
|
|
65
|
+
/// @dev Only a project's controller can set its fund access limits.
|
|
66
|
+
/// @dev Payout limits and surplus allowances must be specified in strictly increasing order (by currency) to
|
|
67
|
+
/// prevent duplicates.
|
|
68
|
+
/// @param projectId The ID of the project whose fund access limits are being set.
|
|
69
|
+
/// @param rulesetId The ID of the ruleset that the limits will apply within.
|
|
70
|
+
/// @param fundAccessLimitGroups An array containing payout limits and surplus allowances for each payment terminal.
|
|
71
|
+
/// Amounts are fixed point numbers using the same number of decimals as the associated terminal.
|
|
72
|
+
function setFundAccessLimitsFor(
|
|
73
|
+
uint256 projectId,
|
|
74
|
+
uint256 rulesetId,
|
|
75
|
+
JBFundAccessLimitGroup[] calldata fundAccessLimitGroups
|
|
76
|
+
)
|
|
77
|
+
external
|
|
78
|
+
override
|
|
79
|
+
onlyControllerOf(projectId)
|
|
80
|
+
{
|
|
81
|
+
// Save the number of fund access limit groups.
|
|
82
|
+
uint256 numberOfFundAccessLimitGroups = fundAccessLimitGroups.length;
|
|
83
|
+
|
|
84
|
+
// Set payout limits if there are any.
|
|
85
|
+
for (uint256 i; i < numberOfFundAccessLimitGroups; i++) {
|
|
86
|
+
// Set the limits being iterated on.
|
|
87
|
+
JBFundAccessLimitGroup calldata fundAccessLimitGroup = fundAccessLimitGroups[i];
|
|
88
|
+
|
|
89
|
+
// Keep a reference to the number of payout limits.
|
|
90
|
+
uint256 numberOfPayoutLimits = fundAccessLimitGroup.payoutLimits.length;
|
|
91
|
+
|
|
92
|
+
// Iterate through each payout limit to validate and store them.
|
|
93
|
+
for (uint256 j; j < numberOfPayoutLimits; j++) {
|
|
94
|
+
// Set the payout limit being iterated on.
|
|
95
|
+
JBCurrencyAmount calldata payoutLimit = fundAccessLimitGroup.payoutLimits[j];
|
|
96
|
+
|
|
97
|
+
// Make sure the payout limits are passed in strictly increasing order (sorted by currency) to prevent
|
|
98
|
+
// duplicates.
|
|
99
|
+
if (j != 0 && payoutLimit.currency <= fundAccessLimitGroup.payoutLimits[j - 1].currency) {
|
|
100
|
+
revert JBFundAccessLimits_InvalidPayoutLimitCurrencyOrdering();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Set the payout limit if there is one.
|
|
104
|
+
if (payoutLimit.amount > 0) {
|
|
105
|
+
_packedPayoutLimitsDataOf[projectId][rulesetId][fundAccessLimitGroup.terminal][fundAccessLimitGroup.token].push(
|
|
106
|
+
uint256(payoutLimit.amount) | (uint256(payoutLimit.currency) << 224)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Keep a reference to the number of surplus allowances.
|
|
112
|
+
uint256 numberOfSurplusAllowances = fundAccessLimitGroup.surplusAllowances.length;
|
|
113
|
+
|
|
114
|
+
// Iterate through each surplus allowance to validate and store them.
|
|
115
|
+
for (uint256 j; j < numberOfSurplusAllowances; j++) {
|
|
116
|
+
// Set the surplus allowance being iterated on.
|
|
117
|
+
JBCurrencyAmount calldata surplusAllowance = fundAccessLimitGroup.surplusAllowances[j];
|
|
118
|
+
|
|
119
|
+
// Make sure the surplus allowances are passed in strictly increasing order (sorted by currency) to
|
|
120
|
+
// prevent duplicates.
|
|
121
|
+
if (j != 0 && surplusAllowance.currency <= fundAccessLimitGroup.surplusAllowances[j - 1].currency) {
|
|
122
|
+
revert JBFundAccessLimits_InvalidSurplusAllowanceCurrencyOrdering();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Set the surplus allowance if there is one.
|
|
126
|
+
if (surplusAllowance.amount > 0) {
|
|
127
|
+
_packedSurplusAllowancesDataOf[projectId][rulesetId][fundAccessLimitGroup.terminal][fundAccessLimitGroup.token].push(
|
|
128
|
+
uint256(surplusAllowance.amount) | (uint256(surplusAllowance.currency) << 224)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
emit SetFundAccessLimits({
|
|
134
|
+
rulesetId: rulesetId,
|
|
135
|
+
projectId: projectId,
|
|
136
|
+
fundAccessLimitGroup: fundAccessLimitGroup,
|
|
137
|
+
caller: msg.sender
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
60
142
|
//*********************************************************************//
|
|
61
143
|
// ------------------------- external views -------------------------- //
|
|
62
144
|
//*********************************************************************//
|
|
@@ -223,86 +305,4 @@ contract JBFundAccessLimits is JBControlled, IJBFundAccessLimits {
|
|
|
223
305
|
});
|
|
224
306
|
}
|
|
225
307
|
}
|
|
226
|
-
|
|
227
|
-
//*********************************************************************//
|
|
228
|
-
// --------------------- external transactions ----------------------- //
|
|
229
|
-
//*********************************************************************//
|
|
230
|
-
|
|
231
|
-
/// @notice Sets limits on the amount of funds a project can access from its terminals during a ruleset.
|
|
232
|
-
/// @dev Only a project's controller can set its fund access limits.
|
|
233
|
-
/// @dev Payout limits and surplus allowances must be specified in strictly increasing order (by currency) to
|
|
234
|
-
/// prevent duplicates.
|
|
235
|
-
/// @param projectId The ID of the project whose fund access limits are being set.
|
|
236
|
-
/// @param rulesetId The ID of the ruleset that the limits will apply within.
|
|
237
|
-
/// @param fundAccessLimitGroups An array containing payout limits and surplus allowances for each payment terminal.
|
|
238
|
-
/// Amounts are fixed point numbers using the same number of decimals as the associated terminal.
|
|
239
|
-
function setFundAccessLimitsFor(
|
|
240
|
-
uint256 projectId,
|
|
241
|
-
uint256 rulesetId,
|
|
242
|
-
JBFundAccessLimitGroup[] calldata fundAccessLimitGroups
|
|
243
|
-
)
|
|
244
|
-
external
|
|
245
|
-
override
|
|
246
|
-
onlyControllerOf(projectId)
|
|
247
|
-
{
|
|
248
|
-
// Save the number of fund access limit groups.
|
|
249
|
-
uint256 numberOfFundAccessLimitGroups = fundAccessLimitGroups.length;
|
|
250
|
-
|
|
251
|
-
// Set payout limits if there are any.
|
|
252
|
-
for (uint256 i; i < numberOfFundAccessLimitGroups; i++) {
|
|
253
|
-
// Set the limits being iterated on.
|
|
254
|
-
JBFundAccessLimitGroup calldata fundAccessLimitGroup = fundAccessLimitGroups[i];
|
|
255
|
-
|
|
256
|
-
// Keep a reference to the number of payout limits.
|
|
257
|
-
uint256 numberOfPayoutLimits = fundAccessLimitGroup.payoutLimits.length;
|
|
258
|
-
|
|
259
|
-
// Iterate through each payout limit to validate and store them.
|
|
260
|
-
for (uint256 j; j < numberOfPayoutLimits; j++) {
|
|
261
|
-
// Set the payout limit being iterated on.
|
|
262
|
-
JBCurrencyAmount calldata payoutLimit = fundAccessLimitGroup.payoutLimits[j];
|
|
263
|
-
|
|
264
|
-
// Make sure the payout limits are passed in strictly increasing order (sorted by currency) to prevent
|
|
265
|
-
// duplicates.
|
|
266
|
-
if (j != 0 && payoutLimit.currency <= fundAccessLimitGroup.payoutLimits[j - 1].currency) {
|
|
267
|
-
revert JBFundAccessLimits_InvalidPayoutLimitCurrencyOrdering();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// Set the payout limit if there is one.
|
|
271
|
-
if (payoutLimit.amount > 0) {
|
|
272
|
-
_packedPayoutLimitsDataOf[projectId][rulesetId][fundAccessLimitGroup.terminal][fundAccessLimitGroup.token].push(
|
|
273
|
-
uint256(payoutLimit.amount) | (uint256(payoutLimit.currency) << 224)
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Keep a reference to the number of surplus allowances.
|
|
279
|
-
uint256 numberOfSurplusAllowances = fundAccessLimitGroup.surplusAllowances.length;
|
|
280
|
-
|
|
281
|
-
// Iterate through each surplus allowance to validate and store them.
|
|
282
|
-
for (uint256 j; j < numberOfSurplusAllowances; j++) {
|
|
283
|
-
// Set the surplus allowance being iterated on.
|
|
284
|
-
JBCurrencyAmount calldata surplusAllowance = fundAccessLimitGroup.surplusAllowances[j];
|
|
285
|
-
|
|
286
|
-
// Make sure the surplus allowances are passed in strictly increasing order (sorted by currency) to
|
|
287
|
-
// prevent duplicates.
|
|
288
|
-
if (j != 0 && surplusAllowance.currency <= fundAccessLimitGroup.surplusAllowances[j - 1].currency) {
|
|
289
|
-
revert JBFundAccessLimits_InvalidSurplusAllowanceCurrencyOrdering();
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// Set the surplus allowance if there is one.
|
|
293
|
-
if (surplusAllowance.amount > 0) {
|
|
294
|
-
_packedSurplusAllowancesDataOf[projectId][rulesetId][fundAccessLimitGroup.terminal][fundAccessLimitGroup.token].push(
|
|
295
|
-
uint256(surplusAllowance.amount) | (uint256(surplusAllowance.currency) << 224)
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
emit SetFundAccessLimits({
|
|
301
|
-
rulesetId: rulesetId,
|
|
302
|
-
projectId: projectId,
|
|
303
|
-
fundAccessLimitGroup: fundAccessLimitGroup,
|
|
304
|
-
caller: msg.sender
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
308
|
}
|