@rev-net/core-v6 0.0.39 → 0.0.41
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/package.json +1 -1
- package/src/REVDeployer.sol +53 -54
- package/src/REVHiddenTokens.sol +1 -1
- package/src/REVLoans.sol +141 -150
- package/src/REVOwner.sol +48 -39
- package/src/interfaces/IREVDeployer.sol +10 -10
- package/src/interfaces/IREVHiddenTokens.sol +4 -4
- package/src/interfaces/IREVLoans.sol +28 -28
- package/src/structs/REV721TiersHookFlags.sol +4 -5
- package/src/structs/REVAutoIssuance.sol +4 -2
- package/src/structs/REVConfig.sol +8 -5
- package/src/structs/REVCroptopAllowedPost.sol +7 -8
- package/src/structs/REVDeploy721TiersHookConfig.sol +10 -10
- package/src/structs/REVDescription.sol +6 -5
- package/src/structs/REVLoan.sol +9 -5
- package/src/structs/REVLoanSource.sol +2 -2
- package/src/structs/REVStageConfig.sol +14 -16
- package/src/structs/REVSuckerDeploymentConfig.sol +2 -2
package/package.json
CHANGED
package/src/REVDeployer.sol
CHANGED
|
@@ -43,8 +43,15 @@ import {REVDeploy721TiersHookConfig} from "./structs/REVDeploy721TiersHookConfig
|
|
|
43
43
|
import {REVStageConfig} from "./structs/REVStageConfig.sol";
|
|
44
44
|
import {REVSuckerDeploymentConfig} from "./structs/REVSuckerDeploymentConfig.sol";
|
|
45
45
|
|
|
46
|
-
/// @notice
|
|
47
|
-
///
|
|
46
|
+
/// @notice Deploys and configures Revnets — autonomous Juicebox projects with pre-programmed tokenomics that cannot
|
|
47
|
+
/// be
|
|
48
|
+
/// changed after launch. Each revnet progresses through stages that define issuance rate, decay schedule, cash-out tax,
|
|
49
|
+
/// split allocations, and auto-issuances. The deployer translates these stage configurations into Juicebox rulesets,
|
|
50
|
+
/// sets up a buyback hook for secondary market routing, deploys a tiered 721 hook, optionally configures Croptop
|
|
51
|
+
/// posting, and can deploy cross-chain suckers. Once deployed, the project NFT is held by this contract — no single
|
|
52
|
+
/// address can modify the revnet's rules.
|
|
53
|
+
/// @dev Revnets are unowned Juicebox projects which operate autonomously after deployment. Runtime data hook logic
|
|
54
|
+
/// (pay/cash-out callbacks) is handled by the separate `REVOwner` contract to stay within EIP-170 size limits.
|
|
48
55
|
contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
49
56
|
//*********************************************************************//
|
|
50
57
|
// --------------------------- custom errors ------------------------- //
|
|
@@ -137,9 +144,9 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
137
144
|
/// @notice The number of revnet tokens which can be "auto-minted" (minted without payments)
|
|
138
145
|
/// for a specific beneficiary during a stage. Think of this as a per-stage premint.
|
|
139
146
|
/// @dev These tokens can be minted with `autoIssueFor(…)`.
|
|
140
|
-
/// @custom:param revnetId The ID of the revnet to
|
|
141
|
-
/// @custom:param stageId The ID of the stage to
|
|
142
|
-
/// @custom:param beneficiary The beneficiary
|
|
147
|
+
/// @custom:param revnetId The ID of the revnet to check.
|
|
148
|
+
/// @custom:param stageId The ID of the stage to check.
|
|
149
|
+
/// @custom:param beneficiary The beneficiary to check.
|
|
143
150
|
mapping(uint256 revnetId => mapping(uint256 stageId => mapping(address beneficiary => uint256)))
|
|
144
151
|
public
|
|
145
152
|
override amountToAutoIssue;
|
|
@@ -147,7 +154,7 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
147
154
|
/// @notice The hashed encoded configuration of each revnet.
|
|
148
155
|
/// @dev This is used to ensure that the encoded configuration of a revnet is the same when deploying suckers for
|
|
149
156
|
/// omnichain operations.
|
|
150
|
-
/// @custom:param revnetId The ID of the revnet to
|
|
157
|
+
/// @custom:param revnetId The ID of the revnet to look up.
|
|
151
158
|
mapping(uint256 revnetId => bytes32 hashedEncodedConfiguration) public override hashedEncodedConfigurationOf;
|
|
152
159
|
|
|
153
160
|
//*********************************************************************//
|
|
@@ -156,7 +163,7 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
156
163
|
|
|
157
164
|
/// @notice A list of `JBPermissonIds` indices to grant to the split operator of a specific revnet.
|
|
158
165
|
/// @dev These should be set in the revnet's deployment process.
|
|
159
|
-
/// @custom:param revnetId The ID of the revnet to
|
|
166
|
+
/// @custom:param revnetId The ID of the revnet to look up.
|
|
160
167
|
// slither-disable-next-line uninitialized-state
|
|
161
168
|
mapping(uint256 revnetId => uint256[]) internal _extraOperatorPermissions;
|
|
162
169
|
|
|
@@ -224,8 +231,8 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
224
231
|
// -------------------------- public views --------------------------- //
|
|
225
232
|
//*********************************************************************//
|
|
226
233
|
|
|
227
|
-
/// @notice
|
|
228
|
-
/// @param revnetId The ID of the revnet.
|
|
234
|
+
/// @notice Check whether an address is a revnet's split operator.
|
|
235
|
+
/// @param revnetId The ID of the revnet to check.
|
|
229
236
|
/// @param addr The address to check.
|
|
230
237
|
/// @return flag A flag indicating whether the address is the revnet's split operator.
|
|
231
238
|
function isSplitOperatorOf(uint256 revnetId, address addr) public view override returns (bool) {
|
|
@@ -251,8 +258,8 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
251
258
|
//*********************************************************************//
|
|
252
259
|
|
|
253
260
|
/// @notice If the specified address is not the revnet's current split operator, revert.
|
|
254
|
-
/// @param revnetId The ID of the revnet to check
|
|
255
|
-
/// @param operator The address
|
|
261
|
+
/// @param revnetId The ID of the revnet to check.
|
|
262
|
+
/// @param operator The address to check.
|
|
256
263
|
function _checkIfIsSplitOperatorOf(uint256 revnetId, address operator) internal view {
|
|
257
264
|
if (!isSplitOperatorOf({revnetId: revnetId, addr: operator})) {
|
|
258
265
|
revert REVDeployer_Unauthorized(revnetId, operator);
|
|
@@ -262,7 +269,7 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
262
269
|
/// @notice Initialize fund access limits for the loan contract.
|
|
263
270
|
/// @dev Returns an unlimited surplus allowance for each terminal+token pair derived from the terminal
|
|
264
271
|
/// configurations.
|
|
265
|
-
/// @param terminalConfigurations The terminals to set up for the revnet.
|
|
272
|
+
/// @param terminalConfigurations The terminals to set up for the revnet.
|
|
266
273
|
/// @return fundAccessLimitGroups The fund access limit groups for the loans.
|
|
267
274
|
function _makeLoanFundAccessLimits(JBTerminalConfig[] calldata terminalConfigurations)
|
|
268
275
|
internal
|
|
@@ -311,8 +318,8 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
311
318
|
|
|
312
319
|
/// @notice Make a ruleset configuration for a revnet's stage.
|
|
313
320
|
/// @param baseCurrency The base currency of the revnet.
|
|
314
|
-
/// @param stageConfiguration The stage configuration to
|
|
315
|
-
/// @param fundAccessLimitGroups The fund access limit groups to
|
|
321
|
+
/// @param stageConfiguration The stage configuration to build a ruleset from.
|
|
322
|
+
/// @param fundAccessLimitGroups The fund access limit groups to include in the ruleset.
|
|
316
323
|
/// @return rulesetConfiguration The ruleset configuration.
|
|
317
324
|
function _makeRulesetConfiguration(
|
|
318
325
|
uint32 baseCurrency,
|
|
@@ -352,9 +359,9 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
352
359
|
});
|
|
353
360
|
}
|
|
354
361
|
|
|
355
|
-
/// @notice Returns the permissions that the split operator should
|
|
356
|
-
/// @param revnetId The ID of the revnet to
|
|
357
|
-
/// @return allOperatorPermissions The permissions
|
|
362
|
+
/// @notice Returns the permissions that the split operator should have for a revnet.
|
|
363
|
+
/// @param revnetId The ID of the revnet to look up.
|
|
364
|
+
/// @return allOperatorPermissions The permissions the split operator should have for the revnet,
|
|
358
365
|
/// including both default and custom permissions.
|
|
359
366
|
function _splitOperatorPermissionIndexesOf(uint256 revnetId)
|
|
360
367
|
internal
|
|
@@ -390,8 +397,8 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
390
397
|
/// @dev Called after the ERC-20 token is deployed so the pool can be initialized in the PoolManager.
|
|
391
398
|
/// Computes `sqrtPriceX96` from `initialIssuance` so the pool starts at the same price as the bonding curve.
|
|
392
399
|
/// Silently catches failures (e.g., if the pool is already initialized).
|
|
393
|
-
/// @param revnetId The ID of the revnet.
|
|
394
|
-
/// @param terminalToken The terminal token to
|
|
400
|
+
/// @param revnetId The ID of the revnet to initialize a pool for.
|
|
401
|
+
/// @param terminalToken The terminal token to create a buyback pool for.
|
|
395
402
|
/// @param initialIssuance The initial issuance rate (project tokens per terminal token, 18 decimals).
|
|
396
403
|
function _tryInitializeBuybackPoolFor(uint256 revnetId, address terminalToken, uint112 initialIssuance) internal {
|
|
397
404
|
uint160 sqrtPriceX96;
|
|
@@ -431,9 +438,9 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
431
438
|
//*********************************************************************//
|
|
432
439
|
|
|
433
440
|
/// @notice Auto-mint a revnet's tokens from a stage for a beneficiary.
|
|
434
|
-
/// @param revnetId The ID of the revnet to auto-mint tokens
|
|
435
|
-
/// @param stageId The ID of the stage auto-mint tokens
|
|
436
|
-
/// @param beneficiary The address to auto-
|
|
441
|
+
/// @param revnetId The ID of the revnet to auto-mint tokens for.
|
|
442
|
+
/// @param stageId The ID of the stage to auto-mint tokens from.
|
|
443
|
+
/// @param beneficiary The address to send auto-minted tokens to.
|
|
437
444
|
function autoIssueFor(uint256 revnetId, uint256 stageId, address beneficiary) external override {
|
|
438
445
|
// Get the ruleset for the stage to check if it has started.
|
|
439
446
|
// Stage IDs are `block.timestamp + i` where `i` is the stage index. These match real JB ruleset IDs
|
|
@@ -472,7 +479,7 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
472
479
|
|
|
473
480
|
/// @notice Burn any of a revnet's tokens held by this contract.
|
|
474
481
|
/// @dev Project tokens can end up here from reserved token distribution when splits don't sum to 100%.
|
|
475
|
-
/// @param revnetId The ID of the revnet
|
|
482
|
+
/// @param revnetId The ID of the revnet to burn tokens for.
|
|
476
483
|
function burnHeldTokensOf(uint256 revnetId) external override {
|
|
477
484
|
uint256 balance = CONTROLLER.TOKENS().totalBalanceOf({holder: address(this), projectId: revnetId});
|
|
478
485
|
if (balance == 0) revert REVDeployer_NothingToBurn();
|
|
@@ -492,13 +499,12 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
492
499
|
/// REVDeployer, and the project becomes subject to immutable revnet rules. This cannot be undone.
|
|
493
500
|
/// @param revnetId The ID of the Juicebox project to initialize as a revnet. Send 0 to deploy a new revnet.
|
|
494
501
|
/// @param configuration Core revnet configuration. See `REVConfig`.
|
|
495
|
-
/// @param terminalConfigurations The terminals to set up for the revnet.
|
|
496
|
-
/// @param suckerDeploymentConfiguration The suckers to set up for
|
|
497
|
-
///
|
|
498
|
-
/// @param
|
|
499
|
-
/// @param allowedPosts Restrictions on which croptop posts are allowed on the revnet's ERC-721 tiers.
|
|
502
|
+
/// @param terminalConfigurations The terminals to set up for the revnet.
|
|
503
|
+
/// @param suckerDeploymentConfiguration The suckers to set up for cross-chain token transfers.
|
|
504
|
+
/// @param tiered721HookConfiguration How to configure the tiered ERC-721 hook for the revnet.
|
|
505
|
+
/// @param allowedPosts Restrictions on which croptop posts to allow on the revnet's ERC-721 tiers.
|
|
500
506
|
/// @return revnetId The ID of the newly created revnet.
|
|
501
|
-
/// @return hook The address of the tiered ERC-721 hook
|
|
507
|
+
/// @return hook The address of the tiered ERC-721 hook deployed for the revnet.
|
|
502
508
|
// The deployment flow makes external setup calls, but any observed state is revnet-scoped and reverts atomically.
|
|
503
509
|
// slither-disable-next-line reentrancy-benign
|
|
504
510
|
function deployFor(
|
|
@@ -591,8 +597,6 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
591
597
|
/// @notice Deploy new suckers for an existing revnet.
|
|
592
598
|
/// @dev Only the revnet's split operator can deploy new suckers.
|
|
593
599
|
/// @param revnetId The ID of the revnet to deploy suckers for.
|
|
594
|
-
/// See `_makeRulesetConfigurations(…)` for encoding details. Clients can read the encoded configuration
|
|
595
|
-
/// from the `DeployRevnet` event emitted by this contract.
|
|
596
600
|
/// @param suckerDeploymentConfiguration The suckers to set up for the revnet.
|
|
597
601
|
function deploySuckersFor(
|
|
598
602
|
uint256 revnetId,
|
|
@@ -628,7 +632,7 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
628
632
|
/// @dev Only a revnet's current split operator can set a new split operator.
|
|
629
633
|
/// @dev Passing `address(0)` as `newSplitOperator` relinquishes operator powers permanently — the permissions
|
|
630
634
|
/// are granted to the zero address (which cannot execute transactions), effectively burning them.
|
|
631
|
-
/// @param revnetId The ID of the revnet to
|
|
635
|
+
/// @param revnetId The ID of the revnet to change the split operator for.
|
|
632
636
|
/// @param newSplitOperator The new split operator's address. Use `address(0)` to relinquish operator powers.
|
|
633
637
|
function setSplitOperatorOf(uint256 revnetId, address newSplitOperator) external override {
|
|
634
638
|
// Enforce permissions.
|
|
@@ -775,9 +779,8 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
775
779
|
/// @param shouldDeployNewRevnet Whether the revnet ID was reserved by this deployment call, or the caller is
|
|
776
780
|
/// converting an existing Juicebox project into a revnet.
|
|
777
781
|
/// @param configuration Core revnet configuration. See `REVConfig`.
|
|
778
|
-
/// @param terminalConfigurations The terminals to set up for the revnet.
|
|
779
|
-
/// @param suckerDeploymentConfiguration The suckers to set up for
|
|
780
|
-
/// token transfers between peer revnets on different networks.
|
|
782
|
+
/// @param terminalConfigurations The terminals to set up for the revnet.
|
|
783
|
+
/// @param suckerDeploymentConfiguration The suckers to set up for cross-chain token transfers.
|
|
781
784
|
/// @return encodedConfigurationHash A hash that represents the revnet's configuration.
|
|
782
785
|
function _deployRevnetFor(
|
|
783
786
|
uint256 revnetId,
|
|
@@ -880,8 +883,6 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
880
883
|
}
|
|
881
884
|
|
|
882
885
|
/// @param encodedConfigurationHash A hash that represents the revnet's configuration.
|
|
883
|
-
/// See `_makeRulesetConfigurations(…)` for encoding details. Clients can read the encoded configuration
|
|
884
|
-
/// from the `DeployRevnet` event emitted by this contract.
|
|
885
886
|
/// @param suckerDeploymentConfiguration The suckers to set up for the revnet.
|
|
886
887
|
function _deploySuckersFor(
|
|
887
888
|
uint256 revnetId,
|
|
@@ -919,12 +920,11 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
919
920
|
/// @dev `cashOutTaxRate` changes at stage boundaries may allow users to cash out just before a rate increase.
|
|
920
921
|
/// This is accepted behavior — the arbitrage window is bounded by the ruleset design, and all stages are
|
|
921
922
|
/// configured immutably at deployment time.
|
|
922
|
-
/// @param revnetId The ID of the revnet to
|
|
923
|
+
/// @param revnetId The ID of the revnet to build rulesets for.
|
|
923
924
|
/// @param configuration The configuration containing the revnet's stages.
|
|
924
|
-
/// @param terminalConfigurations The terminals to set up for the revnet.
|
|
925
|
-
/// @return rulesetConfigurations A list of ruleset configurations
|
|
926
|
-
/// @return encodedConfigurationHash A hash that represents the revnet's configuration.
|
|
927
|
-
/// deployment salts.
|
|
925
|
+
/// @param terminalConfigurations The terminals to set up for the revnet.
|
|
926
|
+
/// @return rulesetConfigurations A list of ruleset configurations derived from the stages.
|
|
927
|
+
/// @return encodedConfigurationHash A hash that represents the revnet's configuration.
|
|
928
928
|
function _makeRulesetConfigurations(
|
|
929
929
|
uint256 revnetId,
|
|
930
930
|
REVConfig calldata configuration,
|
|
@@ -1066,9 +1066,8 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
1066
1066
|
encodedConfigurationHash = keccak256(encodedConfiguration);
|
|
1067
1067
|
}
|
|
1068
1068
|
|
|
1069
|
-
/// @notice
|
|
1070
|
-
/// @dev This prevents cash out liquidity/arbitrage issues for existing revnets
|
|
1071
|
-
/// are deploying to a new chain.
|
|
1069
|
+
/// @notice Set the cash out delay if the revnet's stages are already in progress.
|
|
1070
|
+
/// @dev This prevents cash out liquidity/arbitrage issues for existing revnets deploying to a new chain.
|
|
1072
1071
|
/// @param revnetId The ID of the revnet to set the cash out delay for.
|
|
1073
1072
|
/// @param firstStageConfig The revnet's first stage.
|
|
1074
1073
|
function _setCashOutDelayIfNeeded(uint256 revnetId, REVStageConfig calldata firstStageConfig) internal {
|
|
@@ -1086,10 +1085,10 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
1086
1085
|
emit SetCashOutDelay({revnetId: revnetId, cashOutDelay: cashOutDelay, caller: _msgSender()});
|
|
1087
1086
|
}
|
|
1088
1087
|
|
|
1089
|
-
/// @notice
|
|
1090
|
-
/// @param operator The address to
|
|
1088
|
+
/// @notice Grant a permission to an address (an "operator").
|
|
1089
|
+
/// @param operator The address to grant the permission to.
|
|
1091
1090
|
/// @param revnetId The ID of the revnet to scope the permission for.
|
|
1092
|
-
/// @param permissionId The ID of the permission to
|
|
1091
|
+
/// @param permissionId The ID of the permission to grant. See `JBPermissionIds`.
|
|
1093
1092
|
function _setPermission(address operator, uint256 revnetId, uint8 permissionId) internal {
|
|
1094
1093
|
uint8[] memory permissionsIds = new uint8[](1);
|
|
1095
1094
|
permissionsIds[0] = permissionId;
|
|
@@ -1100,11 +1099,11 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
1100
1099
|
});
|
|
1101
1100
|
}
|
|
1102
1101
|
|
|
1103
|
-
/// @notice
|
|
1104
|
-
/// @param account The account granting the
|
|
1105
|
-
/// @param operator The address to
|
|
1106
|
-
/// @param revnetId The ID of the revnet to scope the
|
|
1107
|
-
/// @param permissionIds An array of permission IDs to
|
|
1102
|
+
/// @notice Grant permissions to an address (an "operator").
|
|
1103
|
+
/// @param account The account granting the permissions.
|
|
1104
|
+
/// @param operator The address to grant the permissions to.
|
|
1105
|
+
/// @param revnetId The ID of the revnet to scope the permissions for.
|
|
1106
|
+
/// @param permissionIds An array of permission IDs to grant. See `JBPermissionIds`.
|
|
1108
1107
|
function _setPermissionsFor(
|
|
1109
1108
|
address account,
|
|
1110
1109
|
address operator,
|
|
@@ -1124,7 +1123,7 @@ contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
|
|
|
1124
1123
|
|
|
1125
1124
|
/// @notice Give a split operator their permissions.
|
|
1126
1125
|
/// @dev Only a revnet's current split operator can set a new split operator, by calling `setSplitOperatorOf(…)`.
|
|
1127
|
-
/// @param revnetId The ID of the revnet to
|
|
1126
|
+
/// @param revnetId The ID of the revnet to grant split operator permissions for.
|
|
1128
1127
|
/// @param operator The new split operator's address.
|
|
1129
1128
|
function _setSplitOperatorOf(uint256 revnetId, address operator) internal {
|
|
1130
1129
|
// Get the permission indexes for the split operator.
|
package/src/REVHiddenTokens.sol
CHANGED
|
@@ -48,7 +48,7 @@ contract REVHiddenTokens is ERC2771Context, JBPermissioned, IREVHiddenTokens {
|
|
|
48
48
|
mapping(uint256 revnetId => uint256 count) public override totalHiddenOf;
|
|
49
49
|
|
|
50
50
|
/// @notice Whether a holder is allowed to hide their own tokens.
|
|
51
|
-
/// @custom:param holder The holder
|
|
51
|
+
/// @custom:param holder The holder to check.
|
|
52
52
|
/// @custom:param revnetId The ID of the revnet.
|
|
53
53
|
mapping(address holder => mapping(uint256 revnetId => bool isAllowed)) public override tokenHidingIsAllowedFor;
|
|
54
54
|
|