@rev-net/core-v6 0.0.36 → 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 (101) 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 +134 -90
  11. package/src/REVOwner.sol +124 -17
  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 -97
  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 -368
  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/CodexCrossChainBuybackRouteMismatch.t.sol +0 -184
  70. package/test/audit/CodexPhantomSurplusTerminal.t.sol +0 -367
  71. package/test/audit/CodexREVOwnerRemoteSurplusCurrencyMismatch.t.sol +0 -142
  72. package/test/audit/LoanIdOverflowGuard.t.sol +0 -523
  73. package/test/audit/NemesisOperatorDelegation.t.sol +0 -356
  74. package/test/audit/SupportsInterfaceTest.t.sol +0 -51
  75. package/test/audit/TestFeeAllowanceLeak.t.sol +0 -197
  76. package/test/audit/TestLoansAndDeployerFixes.t.sol +0 -576
  77. package/test/fork/ForkTestBase.sol +0 -727
  78. package/test/fork/TestAutoIssuanceFork.t.sol +0 -148
  79. package/test/fork/TestCashOutFork.t.sol +0 -253
  80. package/test/fork/TestIssuanceDecayFork.t.sol +0 -158
  81. package/test/fork/TestLoanBorrowFork.t.sol +0 -163
  82. package/test/fork/TestLoanCrossRulesetFork.t.sol +0 -308
  83. package/test/fork/TestLoanERC20Fork.t.sol +0 -465
  84. package/test/fork/TestLoanLiquidationFork.t.sol +0 -135
  85. package/test/fork/TestLoanReallocateFork.t.sol +0 -113
  86. package/test/fork/TestLoanRepayFork.t.sol +0 -188
  87. package/test/fork/TestLoanTransferFork.t.sol +0 -143
  88. package/test/fork/TestPermit2PaymentFork.t.sol +0 -300
  89. package/test/fork/TestSplitWeightFork.t.sol +0 -189
  90. package/test/helpers/MaliciousContracts.sol +0 -247
  91. package/test/helpers/REVEmpty721Config.sol +0 -45
  92. package/test/mock/MockBuybackCashOutRecorder.sol +0 -84
  93. package/test/mock/MockBuybackDataHook.sol +0 -112
  94. package/test/mock/MockBuybackDataHookMintPath.sol +0 -68
  95. package/test/mock/MockSuckerRegistry.sol +0 -17
  96. package/test/regression/TestBurnPermissionRequired.t.sol +0 -294
  97. package/test/regression/TestCashOutBuybackFeeLeak.t.sol +0 -232
  98. package/test/regression/TestCrossRevnetLiquidation.t.sol +0 -255
  99. package/test/regression/TestCumulativeLoanCounter.t.sol +0 -361
  100. package/test/regression/TestLiquidateGapHandling.t.sol +0 -394
  101. package/test/regression/TestZeroPriceFeed.t.sol +0 -422
@@ -1,396 +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
-
16
- // forge-lint: disable-next-line(unaliased-plain-import)
17
- import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
18
- // forge-lint: disable-next-line(unaliased-plain-import)
19
- import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
20
- // forge-lint: disable-next-line(unaliased-plain-import)
21
- import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
22
- // forge-lint: disable-next-line(unaliased-plain-import)
23
- import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
24
- // forge-lint: disable-next-line(unaliased-plain-import)
25
- import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
26
-
27
- import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
28
- import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
29
- import {REVLoans} from "../src/REVLoans.sol";
30
- import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
31
- import {REVDescription} from "../src/structs/REVDescription.sol";
32
- import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
33
- import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
34
- import {JBSuckerRegistry} from "@bananapus/suckers-v6/src/JBSuckerRegistry.sol";
35
- import {JB721TiersHookDeployer} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
36
- import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
37
- import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
38
- import {JB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/JB721CheckpointsDeployer.sol";
39
- import {IJB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/interfaces/IJB721CheckpointsDeployer.sol";
40
- import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
41
- import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
42
- import {REVOwner} from "../src/REVOwner.sol";
43
- import {IREVDeployer} from "../src/interfaces/IREVDeployer.sol";
44
- import {MockSuckerRegistry} from "./mock/MockSuckerRegistry.sol";
45
-
46
- /// @notice Regression tests for REVDeployer.
47
- contract REVDeployerRegressions is TestBaseWorkflow {
48
- using JBRulesetMetadataResolver for JBRuleset;
49
-
50
- // forge-lint: disable-next-line(mixed-case-variable)
51
- bytes32 REV_DEPLOYER_SALT = "REVDeployer";
52
- // forge-lint: disable-next-line(mixed-case-variable)
53
- bytes32 ERC20_SALT = "REV_TOKEN";
54
-
55
- // forge-lint: disable-next-line(mixed-case-variable)
56
- REVDeployer REV_DEPLOYER;
57
- // forge-lint: disable-next-line(mixed-case-variable)
58
- JB721TiersHook EXAMPLE_HOOK;
59
- // forge-lint: disable-next-line(mixed-case-variable)
60
- IJB721TiersHookDeployer HOOK_DEPLOYER;
61
- // forge-lint: disable-next-line(mixed-case-variable)
62
- IJB721TiersHookStore HOOK_STORE;
63
- // forge-lint: disable-next-line(mixed-case-variable)
64
- IJBAddressRegistry ADDRESS_REGISTRY;
65
- // forge-lint: disable-next-line(mixed-case-variable)
66
- IREVLoans LOANS_CONTRACT;
67
- // forge-lint: disable-next-line(mixed-case-variable)
68
- IJBSuckerRegistry SUCKER_REGISTRY;
69
- // forge-lint: disable-next-line(mixed-case-variable)
70
- CTPublisher PUBLISHER;
71
- // forge-lint: disable-next-line(mixed-case-variable)
72
- MockBuybackDataHook MOCK_BUYBACK;
73
- // forge-lint: disable-next-line(mixed-case-variable)
74
- REVOwner REV_OWNER;
75
-
76
- // forge-lint: disable-next-line(mixed-case-variable)
77
- uint256 FEE_PROJECT_ID;
78
-
79
- address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
80
-
81
- function setUp() public override {
82
- super.setUp();
83
-
84
- FEE_PROJECT_ID = jbProjects().createFor(multisig());
85
-
86
- SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
87
- HOOK_STORE = new JB721TiersHookStore();
88
- EXAMPLE_HOOK = new JB721TiersHook(
89
- jbDirectory(),
90
- jbPermissions(),
91
- jbPrices(),
92
- jbRulesets(),
93
- HOOK_STORE,
94
- jbSplits(),
95
- IJB721CheckpointsDeployer(address(new JB721CheckpointsDeployer())),
96
- multisig()
97
- );
98
- ADDRESS_REGISTRY = new JBAddressRegistry();
99
- HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
100
- PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
101
- MOCK_BUYBACK = new MockBuybackDataHook();
102
-
103
- LOANS_CONTRACT = new REVLoans({
104
- controller: jbController(),
105
- suckerRegistry: IJBSuckerRegistry(address(new MockSuckerRegistry())),
106
- revId: FEE_PROJECT_ID,
107
- owner: address(this),
108
- permit2: permit2(),
109
- trustedForwarder: TRUSTED_FORWARDER
110
- });
111
-
112
- REV_OWNER = new REVOwner(
113
- IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
114
- jbDirectory(),
115
- FEE_PROJECT_ID,
116
- SUCKER_REGISTRY,
117
- address(LOANS_CONTRACT),
118
- address(0)
119
- );
120
-
121
- REV_DEPLOYER = new REVDeployer{salt: REV_DEPLOYER_SALT}(
122
- jbController(),
123
- SUCKER_REGISTRY,
124
- FEE_PROJECT_ID,
125
- HOOK_DEPLOYER,
126
- PUBLISHER,
127
- IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
128
- address(LOANS_CONTRACT),
129
- TRUSTED_FORWARDER,
130
- address(REV_OWNER)
131
- );
132
-
133
- REV_OWNER.setDeployer(REV_DEPLOYER);
134
-
135
- vm.prank(multisig());
136
- jbProjects().approve(address(REV_DEPLOYER), FEE_PROJECT_ID);
137
- }
138
-
139
- //*********************************************************************//
140
- // --- REVDeployer.beforePayRecordedWith Array OOB Regression ------- //
141
- //*********************************************************************//
142
-
143
- /// @notice Tests that the array OOB pattern manifests when only buybackHook is present.
144
- /// @dev REVDeployer line 258: hookSpecifications[1] = buybackHookSpecifications[0]
145
- /// always writes to index [1], even when the array has size 1 (no tiered721Hook).
146
- function test_arrayOOB_onlyBuybackHook() public pure {
147
- // Simulate: usesTiered721Hook=false, usesBuybackHook=true
148
- bool usesTiered721Hook = false;
149
- bool usesBuybackHook = true;
150
-
151
- uint256 arraySize = (usesTiered721Hook ? 1 : 0) + (usesBuybackHook ? 1 : 0);
152
- assertEq(arraySize, 1, "array should be size 1");
153
-
154
- JBPayHookSpecification[] memory specs = new JBPayHookSpecification[](arraySize);
155
-
156
- // Index [0] is NOT written (usesTiered721Hook is false)
157
- // Index [1] WOULD be written by the bug, but that's OOB
158
- // Verify the pattern: writing to index 1 of a size-1 array should revert
159
- bool wouldRevert = (!usesTiered721Hook && usesBuybackHook);
160
- assertTrue(wouldRevert, "this combination triggers the OOB bug");
161
-
162
- // Verify the safe index: the buyback hook should go at index 0 when no tiered hook
163
- uint256 correctIndex = usesTiered721Hook ? 1 : 0;
164
- assertEq(correctIndex, 0, "buyback hook should use index 0 when no tiered hook");
165
-
166
- // Write to the correct index (no revert)
167
- specs[correctIndex] =
168
- JBPayHookSpecification({hook: IJBPayHook(address(0xbeef)), noop: false, amount: 1 ether, metadata: ""});
169
- }
170
-
171
- /// @notice Verify both hooks present works fine (no OOB).
172
- function test_noOOB_bothHooksPresent() public pure {
173
- bool usesTiered721Hook = true;
174
- bool usesBuybackHook = true;
175
-
176
- uint256 arraySize = (usesTiered721Hook ? 1 : 0) + (usesBuybackHook ? 1 : 0);
177
- assertEq(arraySize, 2, "array should be size 2");
178
-
179
- JBPayHookSpecification[] memory specs = new JBPayHookSpecification[](arraySize);
180
- specs[0] =
181
- JBPayHookSpecification({hook: IJBPayHook(address(0xdead)), noop: false, amount: 1 ether, metadata: ""});
182
- specs[1] =
183
- JBPayHookSpecification({hook: IJBPayHook(address(0xbeef)), noop: false, amount: 2 ether, metadata: ""});
184
- }
185
-
186
- //*********************************************************************//
187
- // --- hasMintPermissionFor returns false for random addresses ------- //
188
- //*********************************************************************//
189
-
190
- /// @notice Tests that calling hasMintPermissionFor returns false for random addresses.
191
- /// @dev With the buyback hook removed, hasMintPermissionFor should return false
192
- /// for addresses that are not the loans contract or a sucker.
193
- function test_hasMintPermissionFor_noBuybackHook() public {
194
- // Deploy a revnet WITHOUT a buyback hook
195
- JBAccountingContext[] memory accountingContextsToAccept = new JBAccountingContext[](1);
196
- accountingContextsToAccept[0] = JBAccountingContext({
197
- token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
198
- });
199
-
200
- JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
201
- terminalConfigurations[0] =
202
- JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: accountingContextsToAccept});
203
-
204
- REVStageConfig[] memory stageConfigurations = new REVStageConfig[](1);
205
- JBSplit[] memory splits = new JBSplit[](1);
206
- splits[0].beneficiary = payable(multisig());
207
- splits[0].percent = 10_000;
208
-
209
- stageConfigurations[0] = REVStageConfig({
210
- startsAtOrAfter: uint40(block.timestamp),
211
- autoIssuances: new REVAutoIssuance[](0),
212
- splitPercent: 0,
213
- splits: splits,
214
- initialIssuance: uint112(1000e18),
215
- issuanceCutFrequency: 0,
216
- issuanceCutPercent: 0,
217
- cashOutTaxRate: 5000,
218
- extraMetadata: 0
219
- });
220
-
221
- REVConfig memory revnetConfiguration = REVConfig({
222
- // forge-lint: disable-next-line(named-struct-fields)
223
- description: REVDescription("Test", "TST", "ipfs://test", "TEST_SALT"),
224
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
225
- splitOperator: multisig(),
226
- stageConfigurations: stageConfigurations
227
- });
228
-
229
- vm.prank(multisig());
230
- (uint256 revnetId,) = REV_DEPLOYER.deployFor({
231
- revnetId: FEE_PROJECT_ID,
232
- configuration: revnetConfiguration,
233
- terminalConfigurations: terminalConfigurations,
234
- suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
235
- deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("C4_TEST")
236
- }),
237
- tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
238
- allowedPosts: REVEmpty721Config.emptyAllowedPosts()
239
- });
240
-
241
- // hasMintPermissionFor should return false for random addresses
242
- address someRandomAddr = address(0x12345);
243
-
244
- // Get the current ruleset for the call
245
- JBRuleset memory currentRuleset = jbRulesets().currentOf(revnetId);
246
-
247
- // With buyback hook removed, hasMintPermissionFor should return false
248
- // for addresses that are not the loans contract or a sucker.
249
- bool hasPerm = REV_OWNER.hasMintPermissionFor(revnetId, currentRuleset, someRandomAddr);
250
- assertFalse(hasPerm, "random address should not have mint permission");
251
- }
252
-
253
- //*********************************************************************//
254
- // --- Auto-Issuance Stage ID Mismatch ------------------------------ //
255
- //*********************************************************************//
256
-
257
- /// @notice Tests that auto-issuance stage IDs are computed correctly for multi-stage revnets.
258
- /// @dev The stage ID is computed as `block.timestamp + i` which only works if stages
259
- /// are deployed in a specific order at a specific time.
260
- function test_autoIssuanceStageIdMismatch() public {
261
- JBAccountingContext[] memory accountingContextsToAccept = new JBAccountingContext[](1);
262
- accountingContextsToAccept[0] = JBAccountingContext({
263
- token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
264
- });
265
-
266
- JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
267
- terminalConfigurations[0] =
268
- JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: accountingContextsToAccept});
269
-
270
- JBSplit[] memory splits = new JBSplit[](1);
271
- splits[0].beneficiary = payable(multisig());
272
- splits[0].percent = 10_000;
273
-
274
- uint8 decimals = 18;
275
- uint256 decimalMultiplier = 10 ** decimals;
276
-
277
- // Configure 3 stages with auto-issuance on stages 0 AND 1
278
- REVStageConfig[] memory stageConfigurations = new REVStageConfig[](3);
279
-
280
- // Stage 0: has auto-issuance
281
- {
282
- REVAutoIssuance[] memory issuanceConfs = new REVAutoIssuance[](1);
283
- issuanceConfs[0] = REVAutoIssuance({
284
- // forge-lint: disable-next-line(unsafe-typecast)
285
- chainId: uint32(block.chainid),
286
- // forge-lint: disable-next-line(unsafe-typecast)
287
- count: uint104(50_000 * decimalMultiplier),
288
- beneficiary: multisig()
289
- });
290
-
291
- stageConfigurations[0] = REVStageConfig({
292
- startsAtOrAfter: uint40(block.timestamp),
293
- autoIssuances: issuanceConfs,
294
- splitPercent: 2000,
295
- splits: splits,
296
- // forge-lint: disable-next-line(unsafe-typecast)
297
- initialIssuance: uint112(1000 * decimalMultiplier),
298
- issuanceCutFrequency: 90 days,
299
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
300
- cashOutTaxRate: 6000,
301
- extraMetadata: 0
302
- });
303
- }
304
-
305
- // Stage 1: also has auto-issuance — this is where the mismatch manifests
306
- {
307
- REVAutoIssuance[] memory issuanceConfs = new REVAutoIssuance[](1);
308
- issuanceConfs[0] = REVAutoIssuance({
309
- // forge-lint: disable-next-line(unsafe-typecast)
310
- chainId: uint32(block.chainid),
311
- // forge-lint: disable-next-line(unsafe-typecast)
312
- count: uint104(30_000 * decimalMultiplier),
313
- beneficiary: multisig()
314
- });
315
-
316
- stageConfigurations[1] = REVStageConfig({
317
- startsAtOrAfter: uint40(stageConfigurations[0].startsAtOrAfter + 365 days),
318
- autoIssuances: issuanceConfs,
319
- splitPercent: 1000,
320
- splits: splits,
321
- initialIssuance: 0, // inherit
322
- issuanceCutFrequency: 180 days,
323
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
324
- cashOutTaxRate: 3000,
325
- extraMetadata: 0
326
- });
327
- }
328
-
329
- // Stage 2: no auto-issuance
330
- stageConfigurations[2] = REVStageConfig({
331
- startsAtOrAfter: uint40(stageConfigurations[1].startsAtOrAfter + (5 * 365 days)),
332
- autoIssuances: new REVAutoIssuance[](0),
333
- splitPercent: 0,
334
- splits: splits,
335
- initialIssuance: 1,
336
- issuanceCutFrequency: 0,
337
- issuanceCutPercent: 0,
338
- cashOutTaxRate: 500,
339
- extraMetadata: 0
340
- });
341
-
342
- REVConfig memory revnetConfiguration = REVConfig({
343
- // forge-lint: disable-next-line(named-struct-fields)
344
- description: REVDescription("H5Test", "H5T", "ipfs://h5test", "H5_TOKEN"),
345
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
346
- splitOperator: multisig(),
347
- stageConfigurations: stageConfigurations
348
- });
349
-
350
- vm.prank(multisig());
351
- (uint256 revnetId,) = REV_DEPLOYER.deployFor({
352
- revnetId: 0,
353
- configuration: revnetConfiguration,
354
- terminalConfigurations: terminalConfigurations,
355
- suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
356
- deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("H5_TEST")
357
- }),
358
- tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
359
- allowedPosts: REVEmpty721Config.emptyAllowedPosts()
360
- });
361
-
362
- // Verify the revnet was deployed
363
- assertGt(revnetId, 0, "revnet should be deployed");
364
-
365
- // The bug: auto-issuance for stage 1 is stored at key (block.timestamp + 1),
366
- // but the actual ruleset ID for stage 1 is the timestamp when that stage's ruleset
367
- // was queued. These may not match.
368
- // We verify the auto-issuance amounts are stored and can be queried.
369
- uint256 stage0Amount = REV_DEPLOYER.amountToAutoIssue(revnetId, block.timestamp, multisig());
370
-
371
- // Stage 0 auto-issuance should be stored at block.timestamp
372
- assertEq(stage0Amount, 50_000 * decimalMultiplier, "Stage 0 auto-issuance should be stored at block.timestamp");
373
-
374
- // Stage 1 auto-issuance is stored at (block.timestamp + 1)
375
- uint256 stage1Amount = REV_DEPLOYER.amountToAutoIssue(revnetId, block.timestamp + 1, multisig());
376
- assertEq(
377
- stage1Amount,
378
- 30_000 * decimalMultiplier,
379
- "Stage 1 auto-issuance stored at block.timestamp + 1 (may not match ruleset ID)"
380
- );
381
-
382
- // Now check the actual ruleset IDs to demonstrate the mismatch
383
- JBRuleset[] memory rulesets = jbRulesets().allOf(revnetId, 0, 3);
384
- if (rulesets.length >= 2) {
385
- uint256 actualStage1RulesetId = rulesets[1].id;
386
-
387
- // The mismatch: the storage key (block.timestamp + 1) likely != the actual ruleset ID
388
- // If they don't match, auto-issuance tokens for stage 1 become unclaimable
389
- if (actualStage1RulesetId != block.timestamp + 1) {
390
- // Verify the amount at the ACTUAL ruleset ID is 0 (the mismatch)
391
- uint256 amountAtActualId = REV_DEPLOYER.amountToAutoIssue(revnetId, actualStage1RulesetId, multisig());
392
- assertEq(amountAtActualId, 0, "auto-issuance at actual ruleset ID is 0 (mismatch)");
393
- }
394
- }
395
- }
396
- }