@rev-net/core-v6 0.0.1

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.
Files changed (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -0
  3. package/REVNET_SECURITY_CHECKLIST.md +164 -0
  4. package/SECURITY.md +68 -0
  5. package/SKILLS.md +166 -0
  6. package/deployments/revnet-core-v5/arbitrum/REVDeployer.json +2821 -0
  7. package/deployments/revnet-core-v5/arbitrum/REVLoans.json +2260 -0
  8. package/deployments/revnet-core-v5/arbitrum_sepolia/REVDeployer.json +2821 -0
  9. package/deployments/revnet-core-v5/arbitrum_sepolia/REVLoans.json +2260 -0
  10. package/deployments/revnet-core-v5/base/REVDeployer.json +2825 -0
  11. package/deployments/revnet-core-v5/base/REVLoans.json +2264 -0
  12. package/deployments/revnet-core-v5/base_sepolia/REVDeployer.json +2825 -0
  13. package/deployments/revnet-core-v5/base_sepolia/REVLoans.json +2264 -0
  14. package/deployments/revnet-core-v5/ethereum/REVDeployer.json +2825 -0
  15. package/deployments/revnet-core-v5/ethereum/REVLoans.json +2264 -0
  16. package/deployments/revnet-core-v5/optimism/REVDeployer.json +2821 -0
  17. package/deployments/revnet-core-v5/optimism/REVLoans.json +2260 -0
  18. package/deployments/revnet-core-v5/optimism_sepolia/REVDeployer.json +2825 -0
  19. package/deployments/revnet-core-v5/optimism_sepolia/REVLoans.json +2264 -0
  20. package/deployments/revnet-core-v5/sepolia/REVDeployer.json +2825 -0
  21. package/deployments/revnet-core-v5/sepolia/REVLoans.json +2264 -0
  22. package/docs/book.css +13 -0
  23. package/docs/book.toml +13 -0
  24. package/docs/solidity.min.js +74 -0
  25. package/docs/src/README.md +88 -0
  26. package/docs/src/SUMMARY.md +20 -0
  27. package/docs/src/src/README.md +7 -0
  28. package/docs/src/src/REVDeployer.sol/contract.REVDeployer.md +968 -0
  29. package/docs/src/src/REVLoans.sol/contract.REVLoans.md +1047 -0
  30. package/docs/src/src/interfaces/IREVDeployer.sol/interface.IREVDeployer.md +243 -0
  31. package/docs/src/src/interfaces/IREVLoans.sol/interface.IREVLoans.md +296 -0
  32. package/docs/src/src/interfaces/README.md +5 -0
  33. package/docs/src/src/structs/README.md +14 -0
  34. package/docs/src/src/structs/REVAutoIssuance.sol/struct.REVAutoIssuance.md +19 -0
  35. package/docs/src/src/structs/REVBuybackHookConfig.sol/struct.REVBuybackHookConfig.md +19 -0
  36. package/docs/src/src/structs/REVBuybackPoolConfig.sol/struct.REVBuybackPoolConfig.md +21 -0
  37. package/docs/src/src/structs/REVConfig.sol/struct.REVConfig.md +35 -0
  38. package/docs/src/src/structs/REVCroptopAllowedPost.sol/struct.REVCroptopAllowedPost.md +28 -0
  39. package/docs/src/src/structs/REVDeploy721TiersHookConfig.sol/struct.REVDeploy721TiersHookConfig.md +34 -0
  40. package/docs/src/src/structs/REVDescription.sol/struct.REVDescription.md +23 -0
  41. package/docs/src/src/structs/REVLoan.sol/struct.REVLoan.md +28 -0
  42. package/docs/src/src/structs/REVLoanSource.sol/struct.REVLoanSource.md +16 -0
  43. package/docs/src/src/structs/REVStageConfig.sol/struct.REVStageConfig.md +44 -0
  44. package/docs/src/src/structs/REVSuckerDeploymentConfig.sol/struct.REVSuckerDeploymentConfig.md +16 -0
  45. package/foundry.lock +11 -0
  46. package/foundry.toml +23 -0
  47. package/package.json +31 -0
  48. package/remappings.txt +1 -0
  49. package/script/Deploy.s.sol +350 -0
  50. package/script/helpers/RevnetCoreDeploymentLib.sol +72 -0
  51. package/slither-ci.config.json +10 -0
  52. package/sphinx.lock +507 -0
  53. package/src/REVDeployer.sol +1257 -0
  54. package/src/REVLoans.sol +1333 -0
  55. package/src/interfaces/IREVDeployer.sol +198 -0
  56. package/src/interfaces/IREVLoans.sol +241 -0
  57. package/src/structs/REVAutoIssuance.sol +11 -0
  58. package/src/structs/REVConfig.sol +17 -0
  59. package/src/structs/REVCroptopAllowedPost.sol +20 -0
  60. package/src/structs/REVDeploy721TiersHookConfig.sol +25 -0
  61. package/src/structs/REVDescription.sol +14 -0
  62. package/src/structs/REVLoan.sol +19 -0
  63. package/src/structs/REVLoanSource.sol +11 -0
  64. package/src/structs/REVStageConfig.sol +34 -0
  65. package/src/structs/REVSuckerDeploymentConfig.sol +11 -0
  66. package/test/REV.integrations.t.sol +420 -0
  67. package/test/REVAutoIssuanceFuzz.t.sol +276 -0
  68. package/test/REVDeployerAuditRegressions.t.sol +328 -0
  69. package/test/REVInvincibility.t.sol +1275 -0
  70. package/test/REVInvincibilityHandler.sol +357 -0
  71. package/test/REVLifecycle.t.sol +364 -0
  72. package/test/REVLoans.invariants.t.sol +642 -0
  73. package/test/REVLoansAttacks.t.sol +739 -0
  74. package/test/REVLoansAuditRegressions.t.sol +314 -0
  75. package/test/REVLoansFeeRecovery.t.sol +704 -0
  76. package/test/REVLoansSourced.t.sol +1732 -0
  77. package/test/REVLoansUnSourced.t.sol +331 -0
  78. package/test/TestPR09_ConversionDocumentation.t.sol +304 -0
  79. package/test/TestPR10_LiquidationBehavior.t.sol +340 -0
  80. package/test/TestPR11_LowFindings.t.sol +571 -0
  81. package/test/TestPR12_FlashLoanSurplus.t.sol +305 -0
  82. package/test/TestPR13_CrossSourceReallocation.t.sol +302 -0
  83. package/test/TestPR15_CashOutCallerValidation.t.sol +320 -0
  84. package/test/TestPR16_ZeroRepayment.t.sol +297 -0
  85. package/test/TestPR21_Uint112Overflow.t.sol +251 -0
  86. package/test/TestPR22_HookArrayOOB.t.sol +221 -0
  87. package/test/TestPR26_BurnHeldTokens.t.sol +331 -0
  88. package/test/TestPR27_CEIPattern.t.sol +448 -0
  89. package/test/TestPR29_SwapTerminalPermission.t.sol +206 -0
  90. package/test/TestPR32_MixedFixes.t.sol +529 -0
  91. package/test/helpers/MaliciousContracts.sol +233 -0
  92. package/test/mock/MockBuybackDataHook.sol +61 -0
@@ -0,0 +1,968 @@
1
+ # REVDeployer
2
+ [Git Source](https://github.com/rev-net/revnet-core-v5/blob/364afaae78a8f60af2b98252dc96af1c2e4760d3/src/REVDeployer.sol)
3
+
4
+ **Inherits:**
5
+ ERC2771Context, [IREVDeployer](/src/interfaces/IREVDeployer.sol/interface.IREVDeployer.md), IJBRulesetDataHook, IJBCashOutHook, IERC721Receiver
6
+
7
+ `REVDeployer` deploys, manages, and operates Revnets.
8
+
9
+ *Revnets are unowned Juicebox projects which operate autonomously after deployment.*
10
+
11
+
12
+ ## State Variables
13
+ ### CASH_OUT_DELAY
14
+ The number of seconds until a revnet's participants can cash out, starting from the time when that
15
+ revnet is deployed to a new network.
16
+ - Only applies to existing revnets which are deploying onto a new network.
17
+ - To prevent liquidity/arbitrage issues which might arise when an existing revnet adds a brand-new treasury.
18
+
19
+ *30 days, in seconds.*
20
+
21
+
22
+ ```solidity
23
+ uint256 public constant override CASH_OUT_DELAY = 2_592_000;
24
+ ```
25
+
26
+
27
+ ### FEE
28
+ The cash out fee (as a fraction out of `JBConstants.MAX_FEE`).
29
+ Cashout fees are paid to the revnet with the `FEE_REVNET_ID`.
30
+
31
+ *Fees are charged on cashouts if the cash out tax rate is greater than 0%.*
32
+
33
+ *When suckers withdraw funds, they do not pay cash out fees.*
34
+
35
+
36
+ ```solidity
37
+ uint256 public constant override FEE = 25;
38
+ ```
39
+
40
+
41
+ ### CONTROLLER
42
+ The controller used to create and manage Juicebox projects for revnets.
43
+
44
+
45
+ ```solidity
46
+ IJBController public immutable override CONTROLLER;
47
+ ```
48
+
49
+
50
+ ### DIRECTORY
51
+ The directory of terminals and controllers for Juicebox projects (and revnets).
52
+
53
+
54
+ ```solidity
55
+ IJBDirectory public immutable override DIRECTORY;
56
+ ```
57
+
58
+
59
+ ### FEE_REVNET_ID
60
+ The Juicebox project ID of the revnet that receives cash out fees.
61
+
62
+
63
+ ```solidity
64
+ uint256 public immutable override FEE_REVNET_ID;
65
+ ```
66
+
67
+
68
+ ### HOOK_DEPLOYER
69
+ Deploys tiered ERC-721 hooks for revnets.
70
+
71
+
72
+ ```solidity
73
+ IJB721TiersHookDeployer public immutable override HOOK_DEPLOYER;
74
+ ```
75
+
76
+
77
+ ### PERMISSIONS
78
+ Stores Juicebox project (and revnet) access permissions.
79
+
80
+
81
+ ```solidity
82
+ IJBPermissions public immutable override PERMISSIONS;
83
+ ```
84
+
85
+
86
+ ### PROJECTS
87
+ Mints ERC-721s that represent Juicebox project (and revnet) ownership and transfers.
88
+
89
+
90
+ ```solidity
91
+ IJBProjects public immutable override PROJECTS;
92
+ ```
93
+
94
+
95
+ ### PUBLISHER
96
+ Manages the publishing of ERC-721 posts to revnet's tiered ERC-721 hooks.
97
+
98
+
99
+ ```solidity
100
+ CTPublisher public immutable override PUBLISHER;
101
+ ```
102
+
103
+
104
+ ### SUCKER_REGISTRY
105
+ Deploys and tracks suckers for revnets.
106
+
107
+
108
+ ```solidity
109
+ IJBSuckerRegistry public immutable override SUCKER_REGISTRY;
110
+ ```
111
+
112
+
113
+ ### amountToAutoIssue
114
+ The number of revnet tokens which can be "auto-minted" (minted without payments)
115
+ for a specific beneficiary during a stage. Think of this as a per-stage premint.
116
+
117
+ *These tokens can be minted with `autoIssueFor(…)`.*
118
+
119
+
120
+ ```solidity
121
+ mapping(uint256 revnetId => mapping(uint256 stageId => mapping(address beneficiary => uint256))) public override
122
+ amountToAutoIssue;
123
+ ```
124
+
125
+
126
+ ### buybackHookOf
127
+ Each revnet's buyback data hook. These return buyback hook data.
128
+
129
+ *Buyback hooks are a combined data hook/pay hook.*
130
+
131
+
132
+ ```solidity
133
+ mapping(uint256 revnetId => IJBRulesetDataHook buybackHook) public override buybackHookOf;
134
+ ```
135
+
136
+
137
+ ### cashOutDelayOf
138
+ The timestamp of when cashouts will become available to a specific revnet's participants.
139
+
140
+ *Only applies to existing revnets which are deploying onto a new network.*
141
+
142
+
143
+ ```solidity
144
+ mapping(uint256 revnetId => uint256 cashOutDelay) public override cashOutDelayOf;
145
+ ```
146
+
147
+
148
+ ### hashedEncodedConfigurationOf
149
+ The hashed encoded configuration of each revnet.
150
+
151
+ *This is used to ensure that the encoded configuration of a revnet is the same when deploying suckers for
152
+ omnichain operations.*
153
+
154
+
155
+ ```solidity
156
+ mapping(uint256 revnetId => bytes32 hashedEncodedConfiguration) public override hashedEncodedConfigurationOf;
157
+ ```
158
+
159
+
160
+ ### loansOf
161
+ Each revnet's loan contract.
162
+
163
+ *Revnets can offer loans to their participants, collateralized by their tokens.
164
+ Participants can borrow up to the current cash out value of their tokens.*
165
+
166
+
167
+ ```solidity
168
+ mapping(uint256 revnetId => address) public override loansOf;
169
+ ```
170
+
171
+
172
+ ### tiered721HookOf
173
+ Each revnet's tiered ERC-721 hook.
174
+
175
+
176
+ ```solidity
177
+ mapping(uint256 revnetId => IJB721TiersHook tiered721Hook) public override tiered721HookOf;
178
+ ```
179
+
180
+
181
+ ### _extraOperatorPermissions
182
+ A list of `JBPermissonIds` indices to grant to the split operator of a specific revnet.
183
+
184
+ *These should be set in the revnet's deployment process.*
185
+
186
+
187
+ ```solidity
188
+ mapping(uint256 revnetId => uint256[]) internal _extraOperatorPermissions;
189
+ ```
190
+
191
+
192
+ ## Functions
193
+ ### constructor
194
+
195
+
196
+ ```solidity
197
+ constructor(
198
+ IJBController controller,
199
+ IJBSuckerRegistry suckerRegistry,
200
+ uint256 feeRevnetId,
201
+ IJB721TiersHookDeployer hookDeployer,
202
+ CTPublisher publisher,
203
+ address trustedForwarder
204
+ )
205
+ ERC2771Context(trustedForwarder);
206
+ ```
207
+ **Parameters**
208
+
209
+ |Name|Type|Description|
210
+ |----|----|-----------|
211
+ |`controller`|`IJBController`|The controller to use for launching and operating the Juicebox projects which will be revnets.|
212
+ |`suckerRegistry`|`IJBSuckerRegistry`|The registry to use for deploying and tracking each revnet's suckers.|
213
+ |`feeRevnetId`|`uint256`|The Juicebox project ID of the revnet that will receive fees.|
214
+ |`hookDeployer`|`IJB721TiersHookDeployer`|The deployer to use for revnet's tiered ERC-721 hooks.|
215
+ |`publisher`|`CTPublisher`|The croptop publisher revnets can use to publish ERC-721 posts to their tiered ERC-721 hooks.|
216
+ |`trustedForwarder`|`address`|The trusted forwarder for the ERC2771Context.|
217
+
218
+
219
+ ### beforePayRecordedWith
220
+
221
+ Before a revnet processes an incoming payment, determine the weight and pay hooks to use.
222
+
223
+ *This function is part of `IJBRulesetDataHook`, and gets called before the revnet processes a payment.*
224
+
225
+
226
+ ```solidity
227
+ function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
228
+ external
229
+ view
230
+ override
231
+ returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications);
232
+ ```
233
+ **Parameters**
234
+
235
+ |Name|Type|Description|
236
+ |----|----|-----------|
237
+ |`context`|`JBBeforePayRecordedContext`|Standard Juicebox payment context. See `JBBeforePayRecordedContext`.|
238
+
239
+ **Returns**
240
+
241
+ |Name|Type|Description|
242
+ |----|----|-----------|
243
+ |`weight`|`uint256`|The weight which revnet tokens are minted relative to. This can be used to customize how many tokens get minted by a payment.|
244
+ |`hookSpecifications`|`JBPayHookSpecification[]`|Amounts (out of what's being paid in) to be sent to pay hooks instead of being paid into the revnet. Useful for automatically routing funds from a treasury as payments come in.|
245
+
246
+
247
+ ### beforeCashOutRecordedWith
248
+
249
+ Determine how a cash out from a revnet should be processed.
250
+
251
+ *This function is part of `IJBRulesetDataHook`, and gets called before the revnet processes a cash out.*
252
+
253
+ *If a sucker is cashing out, no taxes or fees are imposed.*
254
+
255
+
256
+ ```solidity
257
+ function beforeCashOutRecordedWith(JBBeforeCashOutRecordedContext calldata context)
258
+ external
259
+ view
260
+ override
261
+ returns (
262
+ uint256 cashOutTaxRate,
263
+ uint256 cashOutCount,
264
+ uint256 totalSupply,
265
+ JBCashOutHookSpecification[] memory hookSpecifications
266
+ );
267
+ ```
268
+ **Parameters**
269
+
270
+ |Name|Type|Description|
271
+ |----|----|-----------|
272
+ |`context`|`JBBeforeCashOutRecordedContext`|Standard Juicebox cash out context. See `JBBeforeCashOutRecordedContext`.|
273
+
274
+ **Returns**
275
+
276
+ |Name|Type|Description|
277
+ |----|----|-----------|
278
+ |`cashOutTaxRate`|`uint256`|The cash out tax rate, which influences the amount of terminal tokens which get cashed out.|
279
+ |`cashOutCount`|`uint256`|The number of revnet tokens that are cashed out.|
280
+ |`totalSupply`|`uint256`|The total revnet token supply.|
281
+ |`hookSpecifications`|`JBCashOutHookSpecification[]`|The amount of funds and the data to send to cash out hooks (this contract).|
282
+
283
+
284
+ ### hasMintPermissionFor
285
+
286
+ A flag indicating whether an address has permission to mint a revnet's tokens on-demand.
287
+
288
+ *Required by the `IJBRulesetDataHook` interface.*
289
+
290
+
291
+ ```solidity
292
+ function hasMintPermissionFor(
293
+ uint256 revnetId,
294
+ JBRuleset calldata ruleset,
295
+ address addr
296
+ )
297
+ external
298
+ view
299
+ override
300
+ returns (bool);
301
+ ```
302
+ **Parameters**
303
+
304
+ |Name|Type|Description|
305
+ |----|----|-----------|
306
+ |`revnetId`|`uint256`|The ID of the revnet to check permissions for.|
307
+ |`ruleset`|`JBRuleset`|The ruleset to check the mint permission for.|
308
+ |`addr`|`address`|The address to check the mint permission of.|
309
+
310
+ **Returns**
311
+
312
+ |Name|Type|Description|
313
+ |----|----|-----------|
314
+ |`<none>`|`bool`|flag A flag indicating whether the address has permission to mint the revnet's tokens on-demand.|
315
+
316
+
317
+ ### onERC721Received
318
+
319
+ *Make sure this contract can only receive project NFTs from `JBProjects`.*
320
+
321
+
322
+ ```solidity
323
+ function onERC721Received(address, address, uint256, bytes calldata) external view returns (bytes4);
324
+ ```
325
+
326
+ ### isSplitOperatorOf
327
+
328
+ A flag indicating whether an address is a revnet's split operator.
329
+
330
+
331
+ ```solidity
332
+ function isSplitOperatorOf(uint256 revnetId, address addr) public view override returns (bool);
333
+ ```
334
+ **Parameters**
335
+
336
+ |Name|Type|Description|
337
+ |----|----|-----------|
338
+ |`revnetId`|`uint256`|The ID of the revnet.|
339
+ |`addr`|`address`|The address to check.|
340
+
341
+ **Returns**
342
+
343
+ |Name|Type|Description|
344
+ |----|----|-----------|
345
+ |`<none>`|`bool`|flag A flag indicating whether the address is the revnet's split operator.|
346
+
347
+
348
+ ### supportsInterface
349
+
350
+ Indicates if this contract adheres to the specified interface.
351
+
352
+ *See `IERC165.supportsInterface`.*
353
+
354
+
355
+ ```solidity
356
+ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);
357
+ ```
358
+ **Returns**
359
+
360
+ |Name|Type|Description|
361
+ |----|----|-----------|
362
+ |`<none>`|`bool`|A flag indicating if the provided interface ID is supported.|
363
+
364
+
365
+ ### _checkIfIsSplitOperatorOf
366
+
367
+ If the specified address is not the revnet's current split operator, revert.
368
+
369
+
370
+ ```solidity
371
+ function _checkIfIsSplitOperatorOf(uint256 revnetId, address operator) internal view;
372
+ ```
373
+ **Parameters**
374
+
375
+ |Name|Type|Description|
376
+ |----|----|-----------|
377
+ |`revnetId`|`uint256`|The ID of the revnet to check split operator status for.|
378
+ |`operator`|`address`|The address being checked.|
379
+
380
+
381
+ ### _isSuckerOf
382
+
383
+ A flag indicating whether an address is a revnet's sucker.
384
+
385
+
386
+ ```solidity
387
+ function _isSuckerOf(uint256 revnetId, address addr) internal view returns (bool);
388
+ ```
389
+ **Parameters**
390
+
391
+ |Name|Type|Description|
392
+ |----|----|-----------|
393
+ |`revnetId`|`uint256`|The ID of the revnet to check sucker status for.|
394
+ |`addr`|`address`|The address being checked.|
395
+
396
+ **Returns**
397
+
398
+ |Name|Type|Description|
399
+ |----|----|-----------|
400
+ |`<none>`|`bool`|isSucker A flag indicating whether the address is one of the revnet's suckers.|
401
+
402
+
403
+ ### _makeLoanFundAccessLimits
404
+
405
+ Initialize a fund access limit group for the loan contract to use.
406
+
407
+ *Returns an unlimited surplus allowance for each token which can be loaned out.*
408
+
409
+
410
+ ```solidity
411
+ function _makeLoanFundAccessLimits(
412
+ REVConfig calldata configuration,
413
+ JBTerminalConfig[] calldata terminalConfigurations
414
+ )
415
+ internal
416
+ pure
417
+ returns (JBFundAccessLimitGroup[] memory fundAccessLimitGroups);
418
+ ```
419
+ **Parameters**
420
+
421
+ |Name|Type|Description|
422
+ |----|----|-----------|
423
+ |`configuration`|`REVConfig`|The revnet's configuration.|
424
+ |`terminalConfigurations`|`JBTerminalConfig[]`|The terminals to set up for the revnet. Used for payments and cash outs.|
425
+
426
+ **Returns**
427
+
428
+ |Name|Type|Description|
429
+ |----|----|-----------|
430
+ |`fundAccessLimitGroups`|`JBFundAccessLimitGroup[]`|The fund access limit groups for the loans.|
431
+
432
+
433
+ ### _makeRulesetConfiguration
434
+
435
+ Make a ruleset configuration for a revnet's stage.
436
+
437
+
438
+ ```solidity
439
+ function _makeRulesetConfiguration(
440
+ uint32 baseCurrency,
441
+ REVStageConfig calldata stageConfiguration,
442
+ JBFundAccessLimitGroup[] memory fundAccessLimitGroups
443
+ )
444
+ internal
445
+ view
446
+ returns (JBRulesetConfig memory);
447
+ ```
448
+ **Parameters**
449
+
450
+ |Name|Type|Description|
451
+ |----|----|-----------|
452
+ |`baseCurrency`|`uint32`|The base currency of the revnet.|
453
+ |`stageConfiguration`|`REVStageConfig`|The stage configuration to make a ruleset for.|
454
+ |`fundAccessLimitGroups`|`JBFundAccessLimitGroup[]`|The fund access limit groups to set up for the ruleset.|
455
+
456
+ **Returns**
457
+
458
+ |Name|Type|Description|
459
+ |----|----|-----------|
460
+ |`<none>`|`JBRulesetConfig`|rulesetConfiguration The ruleset configuration.|
461
+
462
+
463
+ ### _matchingCurrencyOf
464
+
465
+ Returns the currency of the loan source, if a matching terminal configuration is found.
466
+
467
+
468
+ ```solidity
469
+ function _matchingCurrencyOf(
470
+ JBTerminalConfig[] calldata terminalConfigurations,
471
+ REVLoanSource calldata loanSource
472
+ )
473
+ internal
474
+ pure
475
+ returns (uint32);
476
+ ```
477
+ **Parameters**
478
+
479
+ |Name|Type|Description|
480
+ |----|----|-----------|
481
+ |`terminalConfigurations`|`JBTerminalConfig[]`|The terminals to check.|
482
+ |`loanSource`|`REVLoanSource`|The loan source to check.|
483
+
484
+ **Returns**
485
+
486
+ |Name|Type|Description|
487
+ |----|----|-----------|
488
+ |`<none>`|`uint32`|currency The currency of the loan source.|
489
+
490
+
491
+ ### _nextProjectId
492
+
493
+ Returns the next project ID.
494
+
495
+
496
+ ```solidity
497
+ function _nextProjectId() internal view returns (uint256);
498
+ ```
499
+ **Returns**
500
+
501
+ |Name|Type|Description|
502
+ |----|----|-----------|
503
+ |`<none>`|`uint256`|nextProjectId The next project ID.|
504
+
505
+
506
+ ### _splitOperatorPermissionIndexesOf
507
+
508
+ Returns the permissions that the split operator should be granted for a revnet.
509
+
510
+
511
+ ```solidity
512
+ function _splitOperatorPermissionIndexesOf(uint256 revnetId)
513
+ internal
514
+ view
515
+ returns (uint256[] memory allOperatorPermissions);
516
+ ```
517
+ **Parameters**
518
+
519
+ |Name|Type|Description|
520
+ |----|----|-----------|
521
+ |`revnetId`|`uint256`|The ID of the revnet to get split operator permissions for.|
522
+
523
+ **Returns**
524
+
525
+ |Name|Type|Description|
526
+ |----|----|-----------|
527
+ |`allOperatorPermissions`|`uint256[]`|The permissions that the split operator should be granted for the revnet, including both default and custom permissions.|
528
+
529
+
530
+ ### afterCashOutRecordedWith
531
+
532
+ Processes the fee from a cash out.
533
+
534
+
535
+ ```solidity
536
+ function afterCashOutRecordedWith(JBAfterCashOutRecordedContext calldata context) external payable;
537
+ ```
538
+ **Parameters**
539
+
540
+ |Name|Type|Description|
541
+ |----|----|-----------|
542
+ |`context`|`JBAfterCashOutRecordedContext`|Cash out context passed in by the terminal.|
543
+
544
+
545
+ ### autoIssueFor
546
+
547
+ Auto-mint a revnet's tokens from a stage for a beneficiary.
548
+
549
+
550
+ ```solidity
551
+ function autoIssueFor(uint256 revnetId, uint256 stageId, address beneficiary) external override;
552
+ ```
553
+ **Parameters**
554
+
555
+ |Name|Type|Description|
556
+ |----|----|-----------|
557
+ |`revnetId`|`uint256`|The ID of the revnet to auto-mint tokens from.|
558
+ |`stageId`|`uint256`|The ID of the stage auto-mint tokens are available from.|
559
+ |`beneficiary`|`address`|The address to auto-mint tokens to.|
560
+
561
+
562
+ ### deployFor
563
+
564
+ Launch a revnet, or convert an existing Juicebox project into a revnet.
565
+
566
+
567
+ ```solidity
568
+ function deployFor(
569
+ uint256 revnetId,
570
+ REVConfig calldata configuration,
571
+ JBTerminalConfig[] calldata terminalConfigurations,
572
+ REVBuybackHookConfig calldata buybackHookConfiguration,
573
+ REVSuckerDeploymentConfig calldata suckerDeploymentConfiguration
574
+ )
575
+ external
576
+ override
577
+ returns (uint256);
578
+ ```
579
+ **Parameters**
580
+
581
+ |Name|Type|Description|
582
+ |----|----|-----------|
583
+ |`revnetId`|`uint256`|The ID of the Juicebox project to turn into a revnet. Send 0 to deploy a new revnet.|
584
+ |`configuration`|`REVConfig`|Core revnet configuration. See `REVConfig`.|
585
+ |`terminalConfigurations`|`JBTerminalConfig[]`|The terminals to set up for the revnet. Used for payments and cash outs.|
586
+ |`buybackHookConfiguration`|`REVBuybackHookConfig`|The buyback hook and pools to set up for the revnet. The buyback hook buys tokens from a Uniswap pool if minting new tokens would be more expensive.|
587
+ |`suckerDeploymentConfiguration`|`REVSuckerDeploymentConfig`|The suckers to set up for the revnet. Suckers facilitate cross-chain token transfers between peer revnets on different networks.|
588
+
589
+ **Returns**
590
+
591
+ |Name|Type|Description|
592
+ |----|----|-----------|
593
+ |`<none>`|`uint256`|revnetId The ID of the newly created revnet.|
594
+
595
+
596
+ ### deploySuckersFor
597
+
598
+ Deploy new suckers for an existing revnet.
599
+
600
+ *Only the revnet's split operator can deploy new suckers.*
601
+
602
+
603
+ ```solidity
604
+ function deploySuckersFor(
605
+ uint256 revnetId,
606
+ REVSuckerDeploymentConfig calldata suckerDeploymentConfiguration
607
+ )
608
+ external
609
+ override
610
+ returns (address[] memory suckers);
611
+ ```
612
+ **Parameters**
613
+
614
+ |Name|Type|Description|
615
+ |----|----|-----------|
616
+ |`revnetId`|`uint256`|The ID of the revnet to deploy suckers for. See `_makeRulesetConfigurations(…)` for encoding details. Clients can read the encoded configuration from the `DeployRevnet` event emitted by this contract.|
617
+ |`suckerDeploymentConfiguration`|`REVSuckerDeploymentConfig`|The suckers to set up for the revnet.|
618
+
619
+
620
+ ### deployWith721sFor
621
+
622
+ Launch a revnet which sells tiered ERC-721s and (optionally) allows croptop posts to its ERC-721 tiers.
623
+
624
+
625
+ ```solidity
626
+ function deployWith721sFor(
627
+ uint256 revnetId,
628
+ REVConfig calldata configuration,
629
+ JBTerminalConfig[] calldata terminalConfigurations,
630
+ REVBuybackHookConfig calldata buybackHookConfiguration,
631
+ REVSuckerDeploymentConfig calldata suckerDeploymentConfiguration,
632
+ REVDeploy721TiersHookConfig calldata tiered721HookConfiguration,
633
+ REVCroptopAllowedPost[] calldata allowedPosts
634
+ )
635
+ external
636
+ override
637
+ returns (uint256, IJB721TiersHook hook);
638
+ ```
639
+ **Parameters**
640
+
641
+ |Name|Type|Description|
642
+ |----|----|-----------|
643
+ |`revnetId`|`uint256`|The ID of the Juicebox project to turn into a revnet. Send 0 to deploy a new revnet.|
644
+ |`configuration`|`REVConfig`|Core revnet configuration. See `REVConfig`.|
645
+ |`terminalConfigurations`|`JBTerminalConfig[]`|The terminals to set up for the revnet. Used for payments and cash outs.|
646
+ |`buybackHookConfiguration`|`REVBuybackHookConfig`|The buyback hook and pools to set up for the revnet. The buyback hook buys tokens from a Uniswap pool if minting new tokens would be more expensive.|
647
+ |`suckerDeploymentConfiguration`|`REVSuckerDeploymentConfig`|The suckers to set up for the revnet. Suckers facilitate cross-chain token transfers between peer revnets on different networks.|
648
+ |`tiered721HookConfiguration`|`REVDeploy721TiersHookConfig`|How to set up the tiered ERC-721 hook for the revnet.|
649
+ |`allowedPosts`|`REVCroptopAllowedPost[]`|Restrictions on which croptop posts are allowed on the revnet's ERC-721 tiers.|
650
+
651
+ **Returns**
652
+
653
+ |Name|Type|Description|
654
+ |----|----|-----------|
655
+ |`<none>`|`uint256`|revnetId The ID of the newly created revnet.|
656
+ |`hook`|`IJB721TiersHook`|The address of the tiered ERC-721 hook that was deployed for the revnet.|
657
+
658
+
659
+ ### setSplitOperatorOf
660
+
661
+ Change a revnet's split operator.
662
+
663
+ *Only a revnet's current split operator can set a new split operator.*
664
+
665
+
666
+ ```solidity
667
+ function setSplitOperatorOf(uint256 revnetId, address newSplitOperator) external override;
668
+ ```
669
+ **Parameters**
670
+
671
+ |Name|Type|Description|
672
+ |----|----|-----------|
673
+ |`revnetId`|`uint256`|The ID of the revnet to set the split operator of.|
674
+ |`newSplitOperator`|`address`|The new split operator's address.|
675
+
676
+
677
+ ### _beforeTransferTo
678
+
679
+ Logic to be triggered before transferring tokens from this contract.
680
+
681
+
682
+ ```solidity
683
+ function _beforeTransferTo(address to, address token, uint256 amount) internal returns (uint256);
684
+ ```
685
+ **Parameters**
686
+
687
+ |Name|Type|Description|
688
+ |----|----|-----------|
689
+ |`to`|`address`|The address the transfer is going to.|
690
+ |`token`|`address`|The token being transferred.|
691
+ |`amount`|`uint256`|The number of tokens being transferred, as a fixed point number with the same number of decimals as the token specifies.|
692
+
693
+ **Returns**
694
+
695
+ |Name|Type|Description|
696
+ |----|----|-----------|
697
+ |`<none>`|`uint256`|payValue The value to attach to the transaction being sent.|
698
+
699
+
700
+ ### _deploy721RevnetFor
701
+
702
+ Deploy a revnet which sells tiered ERC-721s and (optionally) allows croptop posts to its ERC-721 tiers.
703
+
704
+
705
+ ```solidity
706
+ function _deploy721RevnetFor(
707
+ uint256 revnetId,
708
+ bool shouldDeployNewRevnet,
709
+ REVConfig calldata configuration,
710
+ JBTerminalConfig[] calldata terminalConfigurations,
711
+ REVBuybackHookConfig calldata buybackHookConfiguration,
712
+ REVSuckerDeploymentConfig calldata suckerDeploymentConfiguration,
713
+ REVDeploy721TiersHookConfig calldata tiered721HookConfiguration,
714
+ REVCroptopAllowedPost[] calldata allowedPosts
715
+ )
716
+ internal
717
+ returns (IJB721TiersHook hook);
718
+ ```
719
+ **Parameters**
720
+
721
+ |Name|Type|Description|
722
+ |----|----|-----------|
723
+ |`revnetId`|`uint256`|The ID of the Juicebox project to turn into a revnet. Send 0 to deploy a new revnet.|
724
+ |`shouldDeployNewRevnet`|`bool`|Whether to deploy a new revnet or convert an existing Juicebox project into a revnet.|
725
+ |`configuration`|`REVConfig`|Core revnet configuration. See `REVConfig`.|
726
+ |`terminalConfigurations`|`JBTerminalConfig[]`|The terminals to set up for the revnet. Used for payments and cash outs.|
727
+ |`buybackHookConfiguration`|`REVBuybackHookConfig`|The buyback hook and pools to set up for the revnet. The buyback hook buys tokens from a Uniswap pool if minting new tokens would be more expensive.|
728
+ |`suckerDeploymentConfiguration`|`REVSuckerDeploymentConfig`|The suckers to set up for the revnet. Suckers facilitate cross-chain token transfers between peer revnets on different networks.|
729
+ |`tiered721HookConfiguration`|`REVDeploy721TiersHookConfig`|How to set up the tiered ERC-721 hook for the revnet.|
730
+ |`allowedPosts`|`REVCroptopAllowedPost[]`|Restrictions on which croptop posts are allowed on the revnet's ERC-721 tiers.|
731
+
732
+ **Returns**
733
+
734
+ |Name|Type|Description|
735
+ |----|----|-----------|
736
+ |`hook`|`IJB721TiersHook`|The address of the tiered ERC-721 hook that was deployed for the revnet.|
737
+
738
+
739
+ ### _deployRevnetFor
740
+
741
+ Deploy a revnet, or convert an existing Juicebox project into a revnet.
742
+
743
+
744
+ ```solidity
745
+ function _deployRevnetFor(
746
+ uint256 revnetId,
747
+ bool shouldDeployNewRevnet,
748
+ REVConfig calldata configuration,
749
+ JBTerminalConfig[] calldata terminalConfigurations,
750
+ REVBuybackHookConfig calldata buybackHookConfiguration,
751
+ REVSuckerDeploymentConfig calldata suckerDeploymentConfiguration,
752
+ JBRulesetConfig[] memory rulesetConfigurations,
753
+ bytes32 encodedConfigurationHash
754
+ )
755
+ internal;
756
+ ```
757
+ **Parameters**
758
+
759
+ |Name|Type|Description|
760
+ |----|----|-----------|
761
+ |`revnetId`|`uint256`|The ID of the Juicebox project to turn into a revnet. Send 0 to deploy a new revnet.|
762
+ |`shouldDeployNewRevnet`|`bool`|Whether to deploy a new revnet or convert an existing Juicebox project into a revnet.|
763
+ |`configuration`|`REVConfig`|Core revnet configuration. See `REVConfig`.|
764
+ |`terminalConfigurations`|`JBTerminalConfig[]`|The terminals to set up for the revnet. Used for payments and cash outs.|
765
+ |`buybackHookConfiguration`|`REVBuybackHookConfig`|The buyback hook and pools to set up for the revnet. The buyback hook buys tokens from a Uniswap pool if minting new tokens would be more expensive.|
766
+ |`suckerDeploymentConfiguration`|`REVSuckerDeploymentConfig`|The suckers to set up for the revnet. Suckers facilitate cross-chain token transfers between peer revnets on different networks.|
767
+ |`rulesetConfigurations`|`JBRulesetConfig[]`|The rulesets to set up for the revnet.|
768
+ |`encodedConfigurationHash`|`bytes32`|A hash that represents the revnet's configuration. See `_makeRulesetConfigurations(…)` for encoding details. Clients can read the encoded configuration from the `DeployRevnet` event emitted by this contract.|
769
+
770
+
771
+ ### _deploySuckersFor
772
+
773
+ Deploy suckers for a revnet.
774
+
775
+
776
+ ```solidity
777
+ function _deploySuckersFor(
778
+ uint256 revnetId,
779
+ bytes32 encodedConfigurationHash,
780
+ REVSuckerDeploymentConfig calldata suckerDeploymentConfiguration
781
+ )
782
+ internal
783
+ returns (address[] memory suckers);
784
+ ```
785
+ **Parameters**
786
+
787
+ |Name|Type|Description|
788
+ |----|----|-----------|
789
+ |`revnetId`|`uint256`|The ID of the revnet to deploy suckers for.|
790
+ |`encodedConfigurationHash`|`bytes32`|A hash that represents the revnet's configuration. See `_makeRulesetConfigurations(…)` for encoding details. Clients can read the encoded configuration from the `DeployRevnet` event emitted by this contract.|
791
+ |`suckerDeploymentConfiguration`|`REVSuckerDeploymentConfig`|The suckers to set up for the revnet.|
792
+
793
+
794
+ ### _makeRulesetConfigurations
795
+
796
+ Convert a revnet's stages into a series of Juicebox project rulesets.
797
+
798
+
799
+ ```solidity
800
+ function _makeRulesetConfigurations(
801
+ uint256 revnetId,
802
+ REVConfig calldata configuration,
803
+ JBTerminalConfig[] calldata terminalConfigurations
804
+ )
805
+ internal
806
+ returns (JBRulesetConfig[] memory rulesetConfigurations, bytes32 encodedConfigurationHash);
807
+ ```
808
+ **Parameters**
809
+
810
+ |Name|Type|Description|
811
+ |----|----|-----------|
812
+ |`revnetId`|`uint256`|The ID of the revnet to make rulesets for.|
813
+ |`configuration`|`REVConfig`|The configuration containing the revnet's stages.|
814
+ |`terminalConfigurations`|`JBTerminalConfig[]`|The terminals to set up for the revnet. Used for payments and cash outs.|
815
+
816
+ **Returns**
817
+
818
+ |Name|Type|Description|
819
+ |----|----|-----------|
820
+ |`rulesetConfigurations`|`JBRulesetConfig[]`|A list of ruleset configurations defined by the stages.|
821
+ |`encodedConfigurationHash`|`bytes32`|A hash that represents the revnet's configuration. Used for sucker deployment salts.|
822
+
823
+
824
+ ### _setCashOutDelayIfNeeded
825
+
826
+ Sets the cash out delay if the revnet's stages are already in progress.
827
+
828
+ *This prevents cash out liquidity/arbitrage issues for existing revnets which
829
+ are deploying to a new chain.*
830
+
831
+
832
+ ```solidity
833
+ function _setCashOutDelayIfNeeded(uint256 revnetId, REVStageConfig calldata firstStageConfig) internal;
834
+ ```
835
+ **Parameters**
836
+
837
+ |Name|Type|Description|
838
+ |----|----|-----------|
839
+ |`revnetId`|`uint256`|The ID of the revnet to set the cash out delay for.|
840
+ |`firstStageConfig`|`REVStageConfig`|The revnet's first stage.|
841
+
842
+
843
+ ### _setPermission
844
+
845
+ Grants a permission to an address (an "operator").
846
+
847
+
848
+ ```solidity
849
+ function _setPermission(address operator, uint256 revnetId, uint8 permissionId) internal;
850
+ ```
851
+ **Parameters**
852
+
853
+ |Name|Type|Description|
854
+ |----|----|-----------|
855
+ |`operator`|`address`|The address to give the permission to.|
856
+ |`revnetId`|`uint256`|The ID of the revnet to scope the permission for.|
857
+ |`permissionId`|`uint8`|The ID of the permission to set. See `JBPermissionIds`.|
858
+
859
+
860
+ ### _setPermissionsFor
861
+
862
+ Grants a permission to an address (an "operator").
863
+
864
+
865
+ ```solidity
866
+ function _setPermissionsFor(
867
+ address account,
868
+ address operator,
869
+ uint256 revnetId,
870
+ uint8[] memory permissionIds
871
+ )
872
+ internal;
873
+ ```
874
+ **Parameters**
875
+
876
+ |Name|Type|Description|
877
+ |----|----|-----------|
878
+ |`account`|`address`|The account granting the permission.|
879
+ |`operator`|`address`|The address to give the permission to.|
880
+ |`revnetId`|`uint256`|The ID of the revnet to scope the permission for.|
881
+ |`permissionIds`|`uint8[]`|An array of permission IDs to set. See `JBPermissionIds`.|
882
+
883
+
884
+ ### _setSplitOperatorOf
885
+
886
+ Give a split operator their permissions.
887
+
888
+ *Only a revnet's current split operator can set a new split operator, by calling `setSplitOperatorOf(…)`.*
889
+
890
+
891
+ ```solidity
892
+ function _setSplitOperatorOf(uint256 revnetId, address operator) internal;
893
+ ```
894
+ **Parameters**
895
+
896
+ |Name|Type|Description|
897
+ |----|----|-----------|
898
+ |`revnetId`|`uint256`|The ID of the revnet to set the split operator of.|
899
+ |`operator`|`address`|The new split operator's address.|
900
+
901
+
902
+ ## Errors
903
+ ### REVDeployer_LoanSourceDoesntMatchTerminalConfigurations
904
+
905
+ ```solidity
906
+ error REVDeployer_LoanSourceDoesntMatchTerminalConfigurations(address token, address terminal);
907
+ ```
908
+
909
+ ### REVDeployer_AutoIssuanceBeneficiaryZeroAddress
910
+
911
+ ```solidity
912
+ error REVDeployer_AutoIssuanceBeneficiaryZeroAddress();
913
+ ```
914
+
915
+ ### REVDeployer_CashOutDelayNotFinished
916
+
917
+ ```solidity
918
+ error REVDeployer_CashOutDelayNotFinished(uint256 cashOutDelay, uint256 blockTimestamp);
919
+ ```
920
+
921
+ ### REVDeployer_CashOutsCantBeTurnedOffCompletely
922
+
923
+ ```solidity
924
+ error REVDeployer_CashOutsCantBeTurnedOffCompletely(uint256 cashOutTaxRate, uint256 maxCashOutTaxRate);
925
+ ```
926
+
927
+ ### REVDeployer_MustHaveSplits
928
+
929
+ ```solidity
930
+ error REVDeployer_MustHaveSplits();
931
+ ```
932
+
933
+ ### REVDeployer_NothingToAutoIssue
934
+
935
+ ```solidity
936
+ error REVDeployer_NothingToAutoIssue();
937
+ ```
938
+
939
+ ### REVDeployer_RulesetDoesNotAllowDeployingSuckers
940
+
941
+ ```solidity
942
+ error REVDeployer_RulesetDoesNotAllowDeployingSuckers();
943
+ ```
944
+
945
+ ### REVDeployer_StageNotStarted
946
+
947
+ ```solidity
948
+ error REVDeployer_StageNotStarted(uint256 stageId);
949
+ ```
950
+
951
+ ### REVDeployer_StagesRequired
952
+
953
+ ```solidity
954
+ error REVDeployer_StagesRequired();
955
+ ```
956
+
957
+ ### REVDeployer_StageTimesMustIncrease
958
+
959
+ ```solidity
960
+ error REVDeployer_StageTimesMustIncrease();
961
+ ```
962
+
963
+ ### REVDeployer_Unauthorized
964
+
965
+ ```solidity
966
+ error REVDeployer_Unauthorized(uint256 revnetId, address caller);
967
+ ```
968
+