@rev-net/core-v6 0.0.37 → 0.0.39

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 (107) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +6 -7
  3. package/foundry.toml +1 -1
  4. package/package.json +23 -16
  5. package/references/operations.md +1 -1
  6. package/references/runtime.md +1 -1
  7. package/script/Deploy.s.sol +12 -9
  8. package/src/REVDeployer.sol +60 -65
  9. package/src/REVHiddenTokens.sol +2 -2
  10. package/src/REVLoans.sol +17 -10
  11. package/src/REVOwner.sol +121 -14
  12. package/src/interfaces/IREVDeployer.sol +2 -1
  13. package/src/interfaces/IREVHiddenTokens.sol +4 -1
  14. package/src/interfaces/IREVOwner.sol +5 -0
  15. package/ADMINISTRATION.md +0 -73
  16. package/ARCHITECTURE.md +0 -116
  17. package/AUDIT_INSTRUCTIONS.md +0 -90
  18. package/RISKS.md +0 -107
  19. package/SKILLS.md +0 -46
  20. package/STYLE_GUIDE.md +0 -610
  21. package/USER_JOURNEYS.md +0 -195
  22. package/foundry.lock +0 -11
  23. package/slither-ci.config.json +0 -10
  24. package/sphinx.lock +0 -507
  25. package/test/REV.integrations.t.sol +0 -573
  26. package/test/REVAutoIssuanceFuzz.t.sol +0 -328
  27. package/test/REVDeployerRegressions.t.sol +0 -396
  28. package/test/REVInvincibility.t.sol +0 -1371
  29. package/test/REVInvincibilityHandler.sol +0 -387
  30. package/test/REVLifecycle.t.sol +0 -420
  31. package/test/REVLoans.invariants.t.sol +0 -724
  32. package/test/REVLoansAttacks.t.sol +0 -816
  33. package/test/REVLoansFeeRecovery.t.sol +0 -783
  34. package/test/REVLoansFindings.t.sol +0 -711
  35. package/test/REVLoansRegressions.t.sol +0 -364
  36. package/test/REVLoansSourceFeeRecovery.t.sol +0 -517
  37. package/test/REVLoansSourced.t.sol +0 -1839
  38. package/test/REVLoansUnSourced.t.sol +0 -409
  39. package/test/TestAuditFixVerification.t.sol +0 -675
  40. package/test/TestBurnHeldTokens.t.sol +0 -394
  41. package/test/TestCEIPattern.t.sol +0 -508
  42. package/test/TestCashOutCallerValidation.t.sol +0 -452
  43. package/test/TestConversionDocumentation.t.sol +0 -365
  44. package/test/TestCrossCurrencyReclaim.t.sol +0 -610
  45. package/test/TestCrossSourceReallocation.t.sol +0 -361
  46. package/test/TestERC2771MetaTx.t.sol +0 -585
  47. package/test/TestEmptyBuybackSpecs.t.sol +0 -300
  48. package/test/TestFlashLoanSurplus.t.sol +0 -365
  49. package/test/TestHiddenTokens.t.sol +0 -474
  50. package/test/TestHookArrayOOB.t.sol +0 -278
  51. package/test/TestLiquidationBehavior.t.sol +0 -398
  52. package/test/TestLoanSourceRotation.t.sol +0 -553
  53. package/test/TestLoansCashOutDelay.t.sol +0 -493
  54. package/test/TestLongTailEconomics.t.sol +0 -677
  55. package/test/TestLowFindings.t.sol +0 -677
  56. package/test/TestMixedFixes.t.sol +0 -593
  57. package/test/TestPermit2Signatures.t.sol +0 -683
  58. package/test/TestReallocationSandwich.t.sol +0 -412
  59. package/test/TestRevnetRegressions.t.sol +0 -350
  60. package/test/TestSplitWeightAdjustment.t.sol +0 -527
  61. package/test/TestSplitWeightE2E.t.sol +0 -605
  62. package/test/TestSplitWeightFork.t.sol +0 -855
  63. package/test/TestStageTransitionBorrowable.t.sol +0 -301
  64. package/test/TestSwapTerminalPermission.t.sol +0 -262
  65. package/test/TestTerminalEncodingInHash.t.sol +0 -326
  66. package/test/TestUint112Overflow.t.sol +0 -311
  67. package/test/TestZeroAmountLoanGuard.t.sol +0 -378
  68. package/test/TestZeroRepayment.t.sol +0 -354
  69. package/test/audit/CrossChainBuybackRouteMismatch.t.sol +0 -184
  70. package/test/audit/HiddenSupplyCashout.t.sol +0 -61
  71. package/test/audit/LoanIdOverflowGuard.t.sol +0 -523
  72. package/test/audit/NemesisVerification.t.sol +0 -97
  73. package/test/audit/OperatorDelegation.t.sol +0 -356
  74. package/test/audit/PhantomSurplusTerminal.t.sol +0 -367
  75. package/test/audit/REVOwnerCurrencyMismatch.t.sol +0 -188
  76. package/test/audit/REVOwnerRemoteSurplusCurrencyMismatch.t.sol +0 -140
  77. package/test/audit/ReallocatePermission.t.sol +0 -363
  78. package/test/audit/RemoteLoanAccountingGap.t.sol +0 -74
  79. package/test/audit/SupportsInterfaceTest.t.sol +0 -51
  80. package/test/audit/TestFeeAllowanceLeak.t.sol +0 -197
  81. package/test/audit/TestLoansAndDeployerFixes.t.sol +0 -576
  82. package/test/fork/ForkTestBase.sol +0 -727
  83. package/test/fork/TestAutoIssuanceFork.t.sol +0 -148
  84. package/test/fork/TestCashOutFork.t.sol +0 -253
  85. package/test/fork/TestIssuanceDecayFork.t.sol +0 -158
  86. package/test/fork/TestLoanAdversarialFork.t.sol +0 -744
  87. package/test/fork/TestLoanBorrowFork.t.sol +0 -163
  88. package/test/fork/TestLoanCrossRulesetFork.t.sol +0 -308
  89. package/test/fork/TestLoanERC20Fork.t.sol +0 -459
  90. package/test/fork/TestLoanLiquidationFork.t.sol +0 -135
  91. package/test/fork/TestLoanReallocateFork.t.sol +0 -113
  92. package/test/fork/TestLoanRepayFork.t.sol +0 -188
  93. package/test/fork/TestLoanTransferFork.t.sol +0 -143
  94. package/test/fork/TestPermit2PaymentFork.t.sol +0 -300
  95. package/test/fork/TestSplitWeightFork.t.sol +0 -189
  96. package/test/helpers/MaliciousContracts.sol +0 -247
  97. package/test/helpers/REVEmpty721Config.sol +0 -45
  98. package/test/mock/MockBuybackCashOutRecorder.sol +0 -84
  99. package/test/mock/MockBuybackDataHook.sol +0 -112
  100. package/test/mock/MockBuybackDataHookMintPath.sol +0 -68
  101. package/test/mock/MockSuckerRegistry.sol +0 -17
  102. package/test/regression/TestBurnPermissionRequired.t.sol +0 -294
  103. package/test/regression/TestCashOutBuybackFeeLeak.t.sol +0 -232
  104. package/test/regression/TestCrossRevnetLiquidation.t.sol +0 -255
  105. package/test/regression/TestCumulativeLoanCounter.t.sol +0 -361
  106. package/test/regression/TestLiquidateGapHandling.t.sol +0 -394
  107. package/test/regression/TestZeroPriceFeed.t.sol +0 -422
@@ -1,573 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- // forge-lint: disable-next-line(unaliased-plain-import)
5
- import "forge-std/Test.sol";
6
- // forge-lint: disable-next-line(unaliased-plain-import)
7
- import /* {*} from */ "@bananapus/core-v6/test/helpers/TestBaseWorkflow.sol";
8
- // import /* {*} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
9
- // forge-lint: disable-next-line(unaliased-plain-import)
10
- import /* {*} from */ "./../src/REVDeployer.sol";
11
- // forge-lint: disable-next-line(unaliased-plain-import)
12
- import "@croptop/core-v6/src/CTPublisher.sol";
13
- import {MockBuybackDataHook} from "./mock/MockBuybackDataHook.sol";
14
- import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
15
- import {REVOwner} from "../src/REVOwner.sol";
16
- import {IREVDeployer} from "../src/interfaces/IREVDeployer.sol";
17
-
18
- // forge-lint: disable-next-line(unaliased-plain-import)
19
- import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
20
- // forge-lint: disable-next-line(unaliased-plain-import)
21
- import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
22
- // forge-lint: disable-next-line(unaliased-plain-import)
23
- import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
24
- // forge-lint: disable-next-line(unaliased-plain-import)
25
- import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
26
- // forge-lint: disable-next-line(unaliased-plain-import)
27
- import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
28
-
29
- import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
30
- import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
31
- import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
32
- import {REVDescription} from "../src/structs/REVDescription.sol";
33
- import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
34
- import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
35
- import {JBSuckerRegistry} from "@bananapus/suckers-v6/src/JBSuckerRegistry.sol";
36
- import {JBTokenMapping} from "@bananapus/suckers-v6/src/structs/JBTokenMapping.sol";
37
- import {JB721TiersHookDeployer} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
38
- import {JBArbitrumSuckerDeployer} from "@bananapus/suckers-v6/src/deployers/JBArbitrumSuckerDeployer.sol";
39
- import {JBArbitrumSucker, JBLayer, IArbGatewayRouter, IInbox} from "@bananapus/suckers-v6/src/JBArbitrumSucker.sol";
40
-
41
- import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
42
- import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
43
- import {JB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/JB721CheckpointsDeployer.sol";
44
- import {IJB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/interfaces/IJB721CheckpointsDeployer.sol";
45
- import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
46
- import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
47
-
48
- struct FeeProjectConfig {
49
- REVConfig configuration;
50
- JBTerminalConfig[] terminalConfigurations;
51
- REVSuckerDeploymentConfig suckerDeploymentConfiguration;
52
- }
53
-
54
- contract REVnet_Integrations is TestBaseWorkflow {
55
- /// @notice the salts that are used to deploy the contracts.
56
- // forge-lint: disable-next-line(mixed-case-variable)
57
- bytes32 REV_DEPLOYER_SALT = "REVDeployer";
58
- // forge-lint: disable-next-line(mixed-case-variable)
59
- bytes32 ERC20_SALT = "REV_TOKEN";
60
-
61
- // forge-lint: disable-next-line(mixed-case-variable)
62
- REVDeployer REV_DEPLOYER;
63
- // forge-lint: disable-next-line(mixed-case-variable)
64
- JB721TiersHook EXAMPLE_HOOK;
65
-
66
- /// @notice Deploys tiered ERC-721 hooks for revnets.
67
- // forge-lint: disable-next-line(mixed-case-variable)
68
- IJB721TiersHookDeployer HOOK_DEPLOYER;
69
- // forge-lint: disable-next-line(mixed-case-variable)
70
- IJB721TiersHookStore HOOK_STORE;
71
- // forge-lint: disable-next-line(mixed-case-variable)
72
- IJBAddressRegistry ADDRESS_REGISTRY;
73
-
74
- // forge-lint: disable-next-line(mixed-case-variable)
75
- IREVLoans LOANS_CONTRACT;
76
-
77
- /// @notice Deploys and tracks suckers for revnets.
78
- // forge-lint: disable-next-line(mixed-case-variable)
79
- IJBSuckerRegistry SUCKER_REGISTRY;
80
- // forge-lint: disable-next-line(mixed-case-variable)
81
- IJBSuckerDeployer ARB_SUCKER_DEPLOYER;
82
- // forge-lint: disable-next-line(mixed-case-variable)
83
- bytes ENCODED_CONFIG;
84
-
85
- // forge-lint: disable-next-line(mixed-case-variable)
86
- CTPublisher PUBLISHER;
87
- // forge-lint: disable-next-line(mixed-case-variable)
88
- MockBuybackDataHook MOCK_BUYBACK;
89
-
90
- // forge-lint: disable-next-line(mixed-case-variable)
91
- uint256 FEE_PROJECT_ID;
92
- // forge-lint: disable-next-line(mixed-case-variable)
93
- uint256 REVNET_ID;
94
- uint256 decimals = 18;
95
- uint256 decimalMultiplier = 10 ** decimals;
96
-
97
- /// @notice The address that is allowed to forward calls.
98
- address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
99
-
100
- uint256 firstStageId;
101
-
102
- // forge-lint: disable-next-line(mixed-case-variable)
103
- address USER = makeAddr("user");
104
-
105
- function getFeeProjectConfig() internal returns (FeeProjectConfig memory) {
106
- // Define constants
107
- string memory name = "Revnet";
108
- string memory symbol = "$REV";
109
- string memory projectUri = "ipfs://QmNRHT91HcDgMcenebYX7rJigt77cgNcosvuhX21wkF3tx";
110
-
111
- // The tokens that the project accepts and stores.
112
- JBAccountingContext[] memory accountingContextsToAccept = new JBAccountingContext[](1);
113
-
114
- // Accept the chain's native currency through the multi terminal.
115
- accountingContextsToAccept[0] = JBAccountingContext({
116
- token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
117
- });
118
-
119
- // The terminals that the project will accept funds through.
120
- JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
121
- terminalConfigurations[0] =
122
- JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: accountingContextsToAccept});
123
-
124
- // The project's revnet stage configurations.
125
- REVStageConfig[] memory stageConfigurations = new REVStageConfig[](3);
126
-
127
- REVAutoIssuance[] memory issuanceConfs = new REVAutoIssuance[](1);
128
- issuanceConfs[0] = REVAutoIssuance({
129
- // forge-lint: disable-next-line(unsafe-typecast)
130
- chainId: uint32(block.chainid),
131
- // forge-lint: disable-next-line(unsafe-typecast)
132
- count: uint104(70_000 * decimalMultiplier),
133
- beneficiary: multisig()
134
- });
135
-
136
- JBSplit[] memory splits = new JBSplit[](1);
137
- splits[0].beneficiary = payable(multisig());
138
- splits[0].percent = 10_000;
139
-
140
- {
141
- firstStageId = block.timestamp;
142
-
143
- stageConfigurations[0] = REVStageConfig({
144
- startsAtOrAfter: uint40(block.timestamp),
145
- autoIssuances: issuanceConfs,
146
- splitPercent: 2000, // 20%
147
- splits: splits,
148
- // forge-lint: disable-next-line(unsafe-typecast)
149
- initialIssuance: uint112(1000 * decimalMultiplier),
150
- issuanceCutFrequency: 90 days,
151
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
152
- cashOutTaxRate: 6000, // 0.6
153
- extraMetadata: (1 << 2) // Enable adding new suckers.
154
- });
155
- }
156
-
157
- stageConfigurations[1] = REVStageConfig({
158
- startsAtOrAfter: uint40(stageConfigurations[0].startsAtOrAfter + 720 days),
159
- autoIssuances: issuanceConfs,
160
- splitPercent: 2000, // 20%
161
- splits: splits,
162
- initialIssuance: 0, // inherit from previous cycle.
163
- issuanceCutFrequency: 180 days,
164
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
165
- cashOutTaxRate: 6000, // 0.6
166
- extraMetadata: (1 << 2) // Enable adding new suckers.
167
- });
168
-
169
- stageConfigurations[2] = REVStageConfig({
170
- startsAtOrAfter: uint40(stageConfigurations[1].startsAtOrAfter + (20 * 365 days)),
171
- autoIssuances: new REVAutoIssuance[](0),
172
- splitPercent: 0,
173
- splits: splits,
174
- initialIssuance: 1,
175
- issuanceCutFrequency: 0,
176
- issuanceCutPercent: 0,
177
- cashOutTaxRate: 6000, // 0.6
178
- extraMetadata: (1 << 2) // Enable adding new suckers.
179
- });
180
-
181
- // The project's revnet configuration
182
- REVConfig memory revnetConfiguration = REVConfig({
183
- // forge-lint: disable-next-line(named-struct-fields)
184
- description: REVDescription(name, symbol, projectUri, ERC20_SALT),
185
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
186
- splitOperator: multisig(),
187
- stageConfigurations: stageConfigurations
188
- });
189
-
190
- ENCODED_CONFIG = abi.encode(
191
- revnetConfiguration.baseCurrency,
192
- revnetConfiguration.description.name,
193
- revnetConfiguration.description.ticker,
194
- revnetConfiguration.description.salt
195
- );
196
-
197
- return FeeProjectConfig({
198
- configuration: revnetConfiguration,
199
- terminalConfigurations: terminalConfigurations,
200
- suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
201
- deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256(abi.encodePacked("REV"))
202
- })
203
- });
204
- }
205
-
206
- function setUp() public override {
207
- super.setUp();
208
-
209
- FEE_PROJECT_ID = jbProjects().createFor(multisig());
210
-
211
- SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
212
-
213
- HOOK_STORE = new JB721TiersHookStore();
214
-
215
- EXAMPLE_HOOK = new JB721TiersHook(
216
- jbDirectory(),
217
- jbPermissions(),
218
- jbPrices(),
219
- jbRulesets(),
220
- HOOK_STORE,
221
- jbSplits(),
222
- IJB721CheckpointsDeployer(address(new JB721CheckpointsDeployer())),
223
- multisig()
224
- );
225
-
226
- ADDRESS_REGISTRY = new JBAddressRegistry();
227
-
228
- HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
229
-
230
- PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
231
- MOCK_BUYBACK = new MockBuybackDataHook();
232
-
233
- REVOwner revOwner = new REVOwner(
234
- IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
235
- jbDirectory(),
236
- FEE_PROJECT_ID,
237
- SUCKER_REGISTRY,
238
- makeAddr("loans"),
239
- address(0)
240
- );
241
-
242
- REV_DEPLOYER = new REVDeployer{salt: REV_DEPLOYER_SALT}(
243
- jbController(),
244
- SUCKER_REGISTRY,
245
- FEE_PROJECT_ID,
246
- HOOK_DEPLOYER,
247
- PUBLISHER,
248
- IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
249
- makeAddr("loans"),
250
- TRUSTED_FORWARDER,
251
- address(revOwner)
252
- );
253
-
254
- revOwner.setDeployer(REV_DEPLOYER);
255
-
256
- // Deploy the ARB sucker deployer.
257
- JBArbitrumSuckerDeployer _deployer =
258
- new JBArbitrumSuckerDeployer(jbDirectory(), jbPermissions(), jbTokens(), address(this), address(0));
259
- ARB_SUCKER_DEPLOYER = IJBSuckerDeployer(address(_deployer));
260
-
261
- // Deploy the ARB sucker singleton.
262
- JBArbitrumSucker _singleton =
263
- new JBArbitrumSucker(_deployer, jbDirectory(), jbPermissions(), jbTokens(), 1, SUCKER_REGISTRY, address(0));
264
-
265
- // Set the layer specific confguration.
266
- _deployer.setChainSpecificConstants(JBLayer.L1, IInbox(address(1)), IArbGatewayRouter(address(1)));
267
-
268
- // Set the singleton for the deployer.
269
- _deployer.configureSingleton(_singleton);
270
-
271
- // Approve the basic deployer to configure the project.
272
- vm.startPrank(address(multisig()));
273
- jbProjects().approve(address(REV_DEPLOYER), FEE_PROJECT_ID);
274
- SUCKER_REGISTRY.allowSuckerDeployer(address(ARB_SUCKER_DEPLOYER));
275
-
276
- vm.stopPrank();
277
-
278
- // Build the config.
279
- FeeProjectConfig memory feeProjectConfig = getFeeProjectConfig();
280
-
281
- // Configure the project.
282
- vm.prank(address(multisig()));
283
- (REVNET_ID,) = REV_DEPLOYER.deployFor({
284
- revnetId: FEE_PROJECT_ID, // Zero to deploy a new revnet
285
- configuration: feeProjectConfig.configuration,
286
- terminalConfigurations: feeProjectConfig.terminalConfigurations,
287
- suckerDeploymentConfiguration: feeProjectConfig.suckerDeploymentConfiguration,
288
- tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
289
- allowedPosts: REVEmpty721Config.emptyAllowedPosts()
290
- });
291
- }
292
-
293
- function test_Is_Setup() public view {
294
- assertGt(uint160(address(jbDirectory())), uint160(0));
295
- assertGt(FEE_PROJECT_ID, 0);
296
- assertGt(jbProjects().count(), 0);
297
- assertGt(REVNET_ID, 0);
298
- }
299
-
300
- function test_preMint() public {
301
- uint256 perStageMintAmount = 70_000 * decimalMultiplier;
302
- vm.expectEmit();
303
- emit IREVDeployer.AutoIssue(REVNET_ID, firstStageId, multisig(), perStageMintAmount, address(this));
304
- REV_DEPLOYER.autoIssueFor(REVNET_ID, firstStageId, multisig());
305
-
306
- assertEq(70_000 * decimalMultiplier, IJBToken(jbTokens().tokenOf(REVNET_ID)).balanceOf(multisig()));
307
- }
308
-
309
- function test_realize_autoissuance() public {
310
- uint256 perStageMintAmount = 70_000 * decimalMultiplier;
311
-
312
- vm.expectEmit();
313
- emit IREVDeployer.AutoIssue(REVNET_ID, firstStageId, multisig(), perStageMintAmount, address(this));
314
- REV_DEPLOYER.autoIssueFor(REVNET_ID, firstStageId, multisig());
315
- assertEq(REV_DEPLOYER.amountToAutoIssue(REVNET_ID, firstStageId, multisig()), 0);
316
-
317
- assertEq(perStageMintAmount, IJBToken(jbTokens().tokenOf(REVNET_ID)).balanceOf(multisig()));
318
-
319
- vm.warp(firstStageId + 720 days);
320
- assertEq(perStageMintAmount, REV_DEPLOYER.amountToAutoIssue(REVNET_ID, firstStageId + 1, multisig()));
321
-
322
- vm.expectEmit();
323
- emit IREVDeployer.AutoIssue(REVNET_ID, firstStageId + 1, multisig(), perStageMintAmount, address(this));
324
- REV_DEPLOYER.autoIssueFor(REVNET_ID, firstStageId + 1, multisig());
325
-
326
- assertEq(perStageMintAmount * 2, IJBToken(jbTokens().tokenOf(REVNET_ID)).balanceOf(multisig()));
327
- }
328
-
329
- function test_change_split_operator() public {
330
- vm.prank(multisig());
331
- REV_DEPLOYER.setSplitOperatorOf(REVNET_ID, address(this));
332
-
333
- bool isNewOperator = REV_DEPLOYER.isSplitOperatorOf(REVNET_ID, address(this));
334
-
335
- assertEq(isNewOperator, true);
336
- }
337
-
338
- function test_operator_has_default_permissions() public view {
339
- address operator = multisig();
340
-
341
- // Base permissions every split operator should have.
342
- assertTrue(
343
- jbPermissions()
344
- .hasPermission(
345
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SET_SPLIT_GROUPS, false, false
346
- ),
347
- "operator missing SET_SPLIT_GROUPS"
348
- );
349
- assertTrue(
350
- jbPermissions()
351
- .hasPermission(
352
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SET_BUYBACK_POOL, false, false
353
- ),
354
- "operator missing SET_BUYBACK_POOL"
355
- );
356
- assertTrue(
357
- jbPermissions()
358
- .hasPermission(
359
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SET_BUYBACK_TWAP, false, false
360
- ),
361
- "operator missing SET_BUYBACK_TWAP"
362
- );
363
- assertTrue(
364
- jbPermissions()
365
- .hasPermission(
366
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SET_PROJECT_URI, false, false
367
- ),
368
- "operator missing SET_PROJECT_URI"
369
- );
370
- assertTrue(
371
- jbPermissions()
372
- .hasPermission(
373
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.ADD_PRICE_FEED, false, false
374
- ),
375
- "operator missing ADD_PRICE_FEED"
376
- );
377
- assertTrue(
378
- jbPermissions()
379
- .hasPermission(operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SUCKER_SAFETY, false, false),
380
- "operator missing SUCKER_SAFETY"
381
- );
382
- assertTrue(
383
- jbPermissions()
384
- .hasPermission(
385
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SET_BUYBACK_HOOK, false, false
386
- ),
387
- "operator missing SET_BUYBACK_HOOK"
388
- );
389
- assertTrue(
390
- jbPermissions()
391
- .hasPermission(
392
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SET_ROUTER_TERMINAL, false, false
393
- ),
394
- "operator missing SET_ROUTER_TERMINAL"
395
- );
396
- assertTrue(
397
- jbPermissions()
398
- .hasPermission(
399
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SET_TOKEN_METADATA, false, false
400
- ),
401
- "operator missing SET_TOKEN_METADATA"
402
- );
403
-
404
- // 721 hook permissions (always granted since every revnet gets a 721 hook).
405
- assertTrue(
406
- jbPermissions()
407
- .hasPermission(
408
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.ADJUST_721_TIERS, false, false
409
- ),
410
- "operator missing ADJUST_721_TIERS"
411
- );
412
- assertTrue(
413
- jbPermissions()
414
- .hasPermission(
415
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SET_721_METADATA, false, false
416
- ),
417
- "operator missing SET_721_METADATA"
418
- );
419
- assertTrue(
420
- jbPermissions()
421
- .hasPermission(operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.MINT_721, false, false),
422
- "operator missing MINT_721"
423
- );
424
- assertTrue(
425
- jbPermissions()
426
- .hasPermission(
427
- operator, address(REV_DEPLOYER), REVNET_ID, JBPermissionIds.SET_721_DISCOUNT_PERCENT, false, false
428
- ),
429
- "operator missing SET_721_DISCOUNT_PERCENT"
430
- );
431
- }
432
-
433
- function test_sucker_deploy() public {
434
- JBSuckerDeployerConfig[] memory suckerDeployerConfig = new JBSuckerDeployerConfig[](1);
435
-
436
- JBTokenMapping[] memory tokenMapping = new JBTokenMapping[](1);
437
-
438
- address token = makeAddr("someToken");
439
- tokenMapping[0] = JBTokenMapping({
440
- localToken: token, minGas: 200_000, remoteToken: bytes32(uint256(uint160(makeAddr("someOtherToken"))))
441
- });
442
-
443
- suckerDeployerConfig[0] = JBSuckerDeployerConfig({deployer: ARB_SUCKER_DEPLOYER, mappings: tokenMapping});
444
-
445
- REVSuckerDeploymentConfig memory revConfig =
446
- REVSuckerDeploymentConfig({deployerConfigurations: suckerDeployerConfig, salt: "SALTY"});
447
-
448
- // Arbitrum chainid so the deployer works
449
- vm.chainId(42_161);
450
- vm.prank(multisig());
451
-
452
- // As a safety measure the newly created sucker will check that it has not missed a crosschain call.
453
- // which wil call the balanceOf to check its own balance.
454
- vm.mockCall(address(token), abi.encodeWithSelector(IERC20.balanceOf.selector), abi.encode(0));
455
-
456
- address[] memory suckers = REV_DEPLOYER.deploySuckersFor(REVNET_ID, revConfig);
457
-
458
- // Ensure it's registered
459
- bool isSucker = SUCKER_REGISTRY.isSuckerOf(REVNET_ID, suckers[0]);
460
- assertEq(isSucker, true);
461
- }
462
-
463
- /// Test that ensures that the splits are being configured for the new project.
464
- function test_configure_split(address payable beneficiaryA, address payable beneficiaryB) public {
465
- JBSplit[] memory splitsA = new JBSplit[](1);
466
- splitsA[0].beneficiary = beneficiaryA;
467
- splitsA[0].percent = 10_000;
468
-
469
- JBSplit[] memory splitsB = new JBSplit[](1);
470
- splitsB[0].beneficiary = beneficiaryB;
471
- splitsB[0].percent = 10_000;
472
-
473
- // Deploy a new REVNET, it has two configurations, we give each its own split and then check if the splits were
474
- // set correctly for each of the stages.
475
- FeeProjectConfig memory projectConfig = getFeeProjectConfig();
476
-
477
- REVStageConfig[] memory stageConfigurations = new REVStageConfig[](2);
478
- stageConfigurations[0] = REVStageConfig({
479
- startsAtOrAfter: uint40(block.timestamp),
480
- autoIssuances: new REVAutoIssuance[](0),
481
- splitPercent: 2000, // 20%
482
- splits: splitsA,
483
- initialIssuance: 1000e18,
484
- issuanceCutFrequency: 180 days,
485
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
486
- cashOutTaxRate: 2000, // 20%
487
- extraMetadata: 0
488
- });
489
-
490
- stageConfigurations[1] = REVStageConfig({
491
- startsAtOrAfter: uint40(block.timestamp + 720 days),
492
- autoIssuances: new REVAutoIssuance[](0),
493
- splitPercent: 2000, // 20%
494
- splits: splitsB,
495
- initialIssuance: 0, // inherit from previous cycle.
496
- issuanceCutFrequency: 180 days,
497
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
498
- cashOutTaxRate: 0, // 40%
499
- extraMetadata: 0
500
- });
501
-
502
- // Replace the configuration.
503
- projectConfig.configuration.stageConfigurations = stageConfigurations;
504
- projectConfig.configuration.description.salt = "FeeChange";
505
-
506
- (uint256 revnetProjectId,) = REV_DEPLOYER.deployFor({
507
- revnetId: 0, // Zero to deploy a new revnet
508
- configuration: projectConfig.configuration,
509
- terminalConfigurations: projectConfig.terminalConfigurations,
510
- suckerDeploymentConfiguration: projectConfig.suckerDeploymentConfiguration,
511
- tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
512
- allowedPosts: REVEmpty721Config.emptyAllowedPosts()
513
- });
514
-
515
- {
516
- JBSplit[] memory configuredSplits = jbSplits()
517
- .splitsOf(revnetProjectId, jbRulesets().currentOf(revnetProjectId).id, JBSplitGroupIds.RESERVED_TOKENS);
518
- assertEq(keccak256(abi.encode(configuredSplits)), keccak256(abi.encode(splitsA)));
519
- }
520
-
521
- {
522
- JBSplit[] memory configuredSplits = jbSplits()
523
- .splitsOf(
524
- revnetProjectId, jbRulesets().latestRulesetIdOf(revnetProjectId), JBSplitGroupIds.RESERVED_TOKENS
525
- );
526
- assertEq(keccak256(abi.encode(configuredSplits)), keccak256(abi.encode(splitsB)));
527
- }
528
- }
529
-
530
- function test_loans_has_use_allowance_permission() public view {
531
- // The loans contract should have USE_ALLOWANCE permission for any revnet via the wildcard grant.
532
- bool hasPermission = jbPermissions()
533
- .hasPermission({
534
- operator: address(REV_DEPLOYER.LOANS()),
535
- account: address(REV_DEPLOYER),
536
- projectId: REVNET_ID,
537
- permissionId: JBPermissionIds.USE_ALLOWANCE,
538
- includeRoot: false,
539
- includeWildcardProjectId: true
540
- });
541
- assertTrue(hasPermission, "LOANS should have USE_ALLOWANCE for deployed revnet");
542
-
543
- // Also holds for a revnet that doesn't exist yet — the wildcard covers all projects.
544
- bool hasPermissionForFuture = jbPermissions()
545
- .hasPermission({
546
- operator: address(REV_DEPLOYER.LOANS()),
547
- account: address(REV_DEPLOYER),
548
- projectId: 999,
549
- permissionId: JBPermissionIds.USE_ALLOWANCE,
550
- includeRoot: false,
551
- includeWildcardProjectId: true
552
- });
553
- assertTrue(hasPermissionForFuture, "LOANS should have USE_ALLOWANCE for any project via wildcard");
554
- }
555
-
556
- function test_deployer_not_owner() public {
557
- // Build the config.
558
- FeeProjectConfig memory feeProjectConfig = getFeeProjectConfig();
559
-
560
- vm.expectRevert(
561
- abi.encodeWithSelector(REVDeployer.REVDeployer_Unauthorized.selector, FEE_PROJECT_ID, address(this))
562
- );
563
- // Configure the project.
564
- (REVNET_ID,) = REV_DEPLOYER.deployFor({
565
- revnetId: FEE_PROJECT_ID, // Zero to deploy a new revnet
566
- configuration: feeProjectConfig.configuration,
567
- terminalConfigurations: feeProjectConfig.terminalConfigurations,
568
- suckerDeploymentConfiguration: feeProjectConfig.suckerDeploymentConfiguration,
569
- tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
570
- allowedPosts: REVEmpty721Config.emptyAllowedPosts()
571
- });
572
- }
573
- }