@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.
- package/CHANGELOG.md +2 -2
- package/README.md +6 -7
- package/foundry.toml +1 -1
- package/package.json +23 -16
- package/references/operations.md +1 -1
- package/references/runtime.md +1 -1
- package/script/Deploy.s.sol +12 -9
- package/src/REVDeployer.sol +60 -65
- package/src/REVHiddenTokens.sol +2 -2
- package/src/REVLoans.sol +17 -10
- package/src/REVOwner.sol +121 -14
- package/src/interfaces/IREVDeployer.sol +2 -1
- package/src/interfaces/IREVHiddenTokens.sol +4 -1
- package/src/interfaces/IREVOwner.sol +5 -0
- package/ADMINISTRATION.md +0 -73
- package/ARCHITECTURE.md +0 -116
- package/AUDIT_INSTRUCTIONS.md +0 -90
- package/RISKS.md +0 -107
- package/SKILLS.md +0 -46
- package/STYLE_GUIDE.md +0 -610
- package/USER_JOURNEYS.md +0 -195
- package/foundry.lock +0 -11
- package/slither-ci.config.json +0 -10
- package/sphinx.lock +0 -507
- package/test/REV.integrations.t.sol +0 -573
- package/test/REVAutoIssuanceFuzz.t.sol +0 -328
- package/test/REVDeployerRegressions.t.sol +0 -396
- package/test/REVInvincibility.t.sol +0 -1371
- package/test/REVInvincibilityHandler.sol +0 -387
- package/test/REVLifecycle.t.sol +0 -420
- package/test/REVLoans.invariants.t.sol +0 -724
- package/test/REVLoansAttacks.t.sol +0 -816
- package/test/REVLoansFeeRecovery.t.sol +0 -783
- package/test/REVLoansFindings.t.sol +0 -711
- package/test/REVLoansRegressions.t.sol +0 -364
- package/test/REVLoansSourceFeeRecovery.t.sol +0 -517
- package/test/REVLoansSourced.t.sol +0 -1839
- package/test/REVLoansUnSourced.t.sol +0 -409
- package/test/TestAuditFixVerification.t.sol +0 -675
- package/test/TestBurnHeldTokens.t.sol +0 -394
- package/test/TestCEIPattern.t.sol +0 -508
- package/test/TestCashOutCallerValidation.t.sol +0 -452
- package/test/TestConversionDocumentation.t.sol +0 -365
- package/test/TestCrossCurrencyReclaim.t.sol +0 -610
- package/test/TestCrossSourceReallocation.t.sol +0 -361
- package/test/TestERC2771MetaTx.t.sol +0 -585
- package/test/TestEmptyBuybackSpecs.t.sol +0 -300
- package/test/TestFlashLoanSurplus.t.sol +0 -365
- package/test/TestHiddenTokens.t.sol +0 -474
- package/test/TestHookArrayOOB.t.sol +0 -278
- package/test/TestLiquidationBehavior.t.sol +0 -398
- package/test/TestLoanSourceRotation.t.sol +0 -553
- package/test/TestLoansCashOutDelay.t.sol +0 -493
- package/test/TestLongTailEconomics.t.sol +0 -677
- package/test/TestLowFindings.t.sol +0 -677
- package/test/TestMixedFixes.t.sol +0 -593
- package/test/TestPermit2Signatures.t.sol +0 -683
- package/test/TestReallocationSandwich.t.sol +0 -412
- package/test/TestRevnetRegressions.t.sol +0 -350
- package/test/TestSplitWeightAdjustment.t.sol +0 -527
- package/test/TestSplitWeightE2E.t.sol +0 -605
- package/test/TestSplitWeightFork.t.sol +0 -855
- package/test/TestStageTransitionBorrowable.t.sol +0 -301
- package/test/TestSwapTerminalPermission.t.sol +0 -262
- package/test/TestTerminalEncodingInHash.t.sol +0 -326
- package/test/TestUint112Overflow.t.sol +0 -311
- package/test/TestZeroAmountLoanGuard.t.sol +0 -378
- package/test/TestZeroRepayment.t.sol +0 -354
- package/test/audit/CrossChainBuybackRouteMismatch.t.sol +0 -184
- package/test/audit/HiddenSupplyCashout.t.sol +0 -61
- package/test/audit/LoanIdOverflowGuard.t.sol +0 -523
- package/test/audit/NemesisVerification.t.sol +0 -97
- package/test/audit/OperatorDelegation.t.sol +0 -356
- package/test/audit/PhantomSurplusTerminal.t.sol +0 -367
- package/test/audit/REVOwnerCurrencyMismatch.t.sol +0 -188
- package/test/audit/REVOwnerRemoteSurplusCurrencyMismatch.t.sol +0 -140
- package/test/audit/ReallocatePermission.t.sol +0 -363
- package/test/audit/RemoteLoanAccountingGap.t.sol +0 -74
- package/test/audit/SupportsInterfaceTest.t.sol +0 -51
- package/test/audit/TestFeeAllowanceLeak.t.sol +0 -197
- package/test/audit/TestLoansAndDeployerFixes.t.sol +0 -576
- package/test/fork/ForkTestBase.sol +0 -727
- package/test/fork/TestAutoIssuanceFork.t.sol +0 -148
- package/test/fork/TestCashOutFork.t.sol +0 -253
- package/test/fork/TestIssuanceDecayFork.t.sol +0 -158
- package/test/fork/TestLoanAdversarialFork.t.sol +0 -744
- package/test/fork/TestLoanBorrowFork.t.sol +0 -163
- package/test/fork/TestLoanCrossRulesetFork.t.sol +0 -308
- package/test/fork/TestLoanERC20Fork.t.sol +0 -459
- package/test/fork/TestLoanLiquidationFork.t.sol +0 -135
- package/test/fork/TestLoanReallocateFork.t.sol +0 -113
- package/test/fork/TestLoanRepayFork.t.sol +0 -188
- package/test/fork/TestLoanTransferFork.t.sol +0 -143
- package/test/fork/TestPermit2PaymentFork.t.sol +0 -300
- package/test/fork/TestSplitWeightFork.t.sol +0 -189
- package/test/helpers/MaliciousContracts.sol +0 -247
- package/test/helpers/REVEmpty721Config.sol +0 -45
- package/test/mock/MockBuybackCashOutRecorder.sol +0 -84
- package/test/mock/MockBuybackDataHook.sol +0 -112
- package/test/mock/MockBuybackDataHookMintPath.sol +0 -68
- package/test/mock/MockSuckerRegistry.sol +0 -17
- package/test/regression/TestBurnPermissionRequired.t.sol +0 -294
- package/test/regression/TestCashOutBuybackFeeLeak.t.sol +0 -232
- package/test/regression/TestCrossRevnetLiquidation.t.sol +0 -255
- package/test/regression/TestCumulativeLoanCounter.t.sol +0 -361
- package/test/regression/TestLiquidateGapHandling.t.sol +0 -394
- package/test/regression/TestZeroPriceFeed.t.sol +0 -422
|
@@ -1,328 +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
|
-
|
|
15
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
16
|
-
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
17
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
18
|
-
import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
|
|
19
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
20
|
-
import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
|
|
21
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
22
|
-
import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
|
|
23
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
24
|
-
import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
|
|
25
|
-
|
|
26
|
-
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
27
|
-
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
28
|
-
import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
|
|
29
|
-
import {REVDescription} from "../src/structs/REVDescription.sol";
|
|
30
|
-
import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
|
|
31
|
-
import {JBSuckerRegistry} from "@bananapus/suckers-v6/src/JBSuckerRegistry.sol";
|
|
32
|
-
import {JB721TiersHookDeployer} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
33
|
-
import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
|
|
34
|
-
import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
|
|
35
|
-
import {JB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/JB721CheckpointsDeployer.sol";
|
|
36
|
-
import {IJB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/interfaces/IJB721CheckpointsDeployer.sol";
|
|
37
|
-
import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
|
|
38
|
-
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
39
|
-
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
40
|
-
import {REVOwner} from "../src/REVOwner.sol";
|
|
41
|
-
import {IREVDeployer} from "../src/interfaces/IREVDeployer.sol";
|
|
42
|
-
|
|
43
|
-
/// @notice Fuzz tests for REVDeployer multi-stage auto-issuance.
|
|
44
|
-
/// Tests stage ID computation consistency and multi-stage claiming behavior.
|
|
45
|
-
/// Stage IDs use block.timestamp + i which may mismatch actual ruleset IDs.
|
|
46
|
-
contract REVAutoIssuanceFuzz_Local is TestBaseWorkflow {
|
|
47
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
48
|
-
bytes32 REV_DEPLOYER_SALT = "REVDeployer";
|
|
49
|
-
|
|
50
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
51
|
-
REVDeployer REV_DEPLOYER;
|
|
52
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
53
|
-
JB721TiersHook EXAMPLE_HOOK;
|
|
54
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
55
|
-
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
56
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
57
|
-
IJB721TiersHookStore HOOK_STORE;
|
|
58
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
59
|
-
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
60
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
61
|
-
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
62
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
63
|
-
CTPublisher PUBLISHER;
|
|
64
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
65
|
-
MockBuybackDataHook MOCK_BUYBACK;
|
|
66
|
-
|
|
67
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
68
|
-
uint256 FEE_PROJECT_ID;
|
|
69
|
-
uint256 decimals = 18;
|
|
70
|
-
uint256 decimalMultiplier = 10 ** decimals;
|
|
71
|
-
|
|
72
|
-
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
73
|
-
|
|
74
|
-
function setUp() public override {
|
|
75
|
-
super.setUp();
|
|
76
|
-
|
|
77
|
-
FEE_PROJECT_ID = jbProjects().createFor(multisig());
|
|
78
|
-
|
|
79
|
-
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
80
|
-
HOOK_STORE = new JB721TiersHookStore();
|
|
81
|
-
EXAMPLE_HOOK = new JB721TiersHook(
|
|
82
|
-
jbDirectory(),
|
|
83
|
-
jbPermissions(),
|
|
84
|
-
jbPrices(),
|
|
85
|
-
jbRulesets(),
|
|
86
|
-
HOOK_STORE,
|
|
87
|
-
jbSplits(),
|
|
88
|
-
IJB721CheckpointsDeployer(address(new JB721CheckpointsDeployer())),
|
|
89
|
-
multisig()
|
|
90
|
-
);
|
|
91
|
-
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
92
|
-
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
93
|
-
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
94
|
-
MOCK_BUYBACK = new MockBuybackDataHook();
|
|
95
|
-
|
|
96
|
-
REVOwner revOwner = new REVOwner(
|
|
97
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
98
|
-
jbDirectory(),
|
|
99
|
-
FEE_PROJECT_ID,
|
|
100
|
-
SUCKER_REGISTRY,
|
|
101
|
-
makeAddr("loans"),
|
|
102
|
-
address(0)
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
REV_DEPLOYER = new REVDeployer{salt: REV_DEPLOYER_SALT}(
|
|
106
|
-
jbController(),
|
|
107
|
-
SUCKER_REGISTRY,
|
|
108
|
-
FEE_PROJECT_ID,
|
|
109
|
-
HOOK_DEPLOYER,
|
|
110
|
-
PUBLISHER,
|
|
111
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
112
|
-
makeAddr("loans"),
|
|
113
|
-
TRUSTED_FORWARDER,
|
|
114
|
-
address(revOwner)
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
revOwner.setDeployer(REV_DEPLOYER);
|
|
118
|
-
|
|
119
|
-
vm.prank(multisig());
|
|
120
|
-
jbProjects().approve(address(REV_DEPLOYER), FEE_PROJECT_ID);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/// @dev Deploy a revnet with N stages, each with auto-issuance.
|
|
124
|
-
function _deployMultiStageRevnet(uint256 numStages) internal returns (uint256 revnetId, uint256[] memory stageIds) {
|
|
125
|
-
require(numStages >= 1 && numStages <= 5, "1-5 stages");
|
|
126
|
-
|
|
127
|
-
JBAccountingContext[] memory tokensToAccept = new JBAccountingContext[](1);
|
|
128
|
-
tokensToAccept[0] = JBAccountingContext({
|
|
129
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
JBTerminalConfig[] memory terminalConfigs = new JBTerminalConfig[](1);
|
|
133
|
-
terminalConfigs[0] = JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: tokensToAccept});
|
|
134
|
-
|
|
135
|
-
REVStageConfig[] memory stages = new REVStageConfig[](numStages);
|
|
136
|
-
stageIds = new uint256[](numStages);
|
|
137
|
-
|
|
138
|
-
for (uint256 i; i < numStages; i++) {
|
|
139
|
-
REVAutoIssuance[] memory autoIssuances = new REVAutoIssuance[](1);
|
|
140
|
-
autoIssuances[0] = REVAutoIssuance({
|
|
141
|
-
chainId: uint32(block.chainid),
|
|
142
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
143
|
-
count: uint104((10_000 + i * 1000) * decimalMultiplier),
|
|
144
|
-
beneficiary: multisig()
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
JBSplit[] memory splits = new JBSplit[](1);
|
|
148
|
-
splits[0].beneficiary = payable(multisig());
|
|
149
|
-
splits[0].percent = 10_000;
|
|
150
|
-
|
|
151
|
-
uint40 startsAt;
|
|
152
|
-
if (i == 0) {
|
|
153
|
-
startsAt = uint40(block.timestamp);
|
|
154
|
-
} else {
|
|
155
|
-
startsAt = uint40(stages[i - 1].startsAtOrAfter + 180 days);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
stages[i] = REVStageConfig({
|
|
159
|
-
startsAtOrAfter: startsAt,
|
|
160
|
-
autoIssuances: autoIssuances,
|
|
161
|
-
splitPercent: 2000,
|
|
162
|
-
splits: splits,
|
|
163
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
164
|
-
initialIssuance: uint112(1000 * decimalMultiplier),
|
|
165
|
-
issuanceCutFrequency: 90 days,
|
|
166
|
-
issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
|
|
167
|
-
cashOutTaxRate: 6000,
|
|
168
|
-
extraMetadata: 0
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Stage IDs are stored as block.timestamp + i.
|
|
172
|
-
stageIds[i] = block.timestamp + i;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
REVConfig memory config = REVConfig({
|
|
176
|
-
// forge-lint: disable-next-line(named-struct-fields)
|
|
177
|
-
description: REVDescription("TestRevnet", "TREV", "ipfs://test", bytes32(uint256(numStages))),
|
|
178
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
179
|
-
splitOperator: multisig(),
|
|
180
|
-
stageConfigurations: stages
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
vm.prank(multisig());
|
|
184
|
-
(revnetId,) = REV_DEPLOYER.deployFor({
|
|
185
|
-
revnetId: 0,
|
|
186
|
-
configuration: config,
|
|
187
|
-
terminalConfigurations: terminalConfigs,
|
|
188
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
189
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0),
|
|
190
|
-
salt: keccak256(abi.encodePacked("AUTOISSUE", numStages))
|
|
191
|
-
}),
|
|
192
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
193
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// ───────────────── Stage ID computation
|
|
198
|
-
// ─────────────────────
|
|
199
|
-
|
|
200
|
-
/// @notice Verify all auto-issuance storage keys match block.timestamp + i for 3 stages.
|
|
201
|
-
function test_stageIdComputation_3stages() external {
|
|
202
|
-
(uint256 revnetId, uint256[] memory stageIds) = _deployMultiStageRevnet(3);
|
|
203
|
-
|
|
204
|
-
// Verify storage keys.
|
|
205
|
-
for (uint256 i; i < 3; i++) {
|
|
206
|
-
uint256 storedAmount = REV_DEPLOYER.amountToAutoIssue(revnetId, stageIds[i], multisig());
|
|
207
|
-
uint256 expectedAmount = (10_000 + i * 1000) * decimalMultiplier;
|
|
208
|
-
assertEq(storedAmount, expectedAmount, string.concat("Stage ", vm.toString(i), " storage mismatch"));
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// ───────────────── Multi-stage claiming
|
|
213
|
-
// ─────────────────────
|
|
214
|
-
|
|
215
|
-
/// @notice Deploy 3-stage revnet, advance time, claim auto-issuance from each stage.
|
|
216
|
-
function test_multiStage_allStagesClaimable() external {
|
|
217
|
-
// Save the deploy timestamp for absolute warp targets.
|
|
218
|
-
uint256 deployTs = block.timestamp;
|
|
219
|
-
|
|
220
|
-
(uint256 revnetId, uint256[] memory stageIds) = _deployMultiStageRevnet(3);
|
|
221
|
-
|
|
222
|
-
// Stage 0 starts at deploy time — immediately claimable.
|
|
223
|
-
REV_DEPLOYER.autoIssueFor(revnetId, stageIds[0], multisig());
|
|
224
|
-
|
|
225
|
-
uint256 stage0Amount = (10_000) * decimalMultiplier;
|
|
226
|
-
assertEq(
|
|
227
|
-
IJBToken(jbTokens().tokenOf(revnetId)).balanceOf(multisig()), stage0Amount, "Stage 0 auto-issuance claimed"
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
// Stage 1 starts at deployTs + 180 days.
|
|
231
|
-
vm.warp(deployTs + 180 days);
|
|
232
|
-
REV_DEPLOYER.autoIssueFor(revnetId, stageIds[1], multisig());
|
|
233
|
-
|
|
234
|
-
uint256 stage1Amount = (11_000) * decimalMultiplier;
|
|
235
|
-
assertEq(
|
|
236
|
-
IJBToken(jbTokens().tokenOf(revnetId)).balanceOf(multisig()),
|
|
237
|
-
stage0Amount + stage1Amount,
|
|
238
|
-
"Stage 1 auto-issuance claimed"
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
// Stage 2 starts at deployTs + 360 days.
|
|
242
|
-
vm.warp(deployTs + 360 days);
|
|
243
|
-
REV_DEPLOYER.autoIssueFor(revnetId, stageIds[2], multisig());
|
|
244
|
-
|
|
245
|
-
uint256 stage2Amount = (12_000) * decimalMultiplier;
|
|
246
|
-
assertEq(
|
|
247
|
-
IJBToken(jbTokens().tokenOf(revnetId)).balanceOf(multisig()),
|
|
248
|
-
stage0Amount + stage1Amount + stage2Amount,
|
|
249
|
-
"Stage 2 auto-issuance claimed"
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// ───────────────── Wrong stageId reverts
|
|
254
|
-
// ─────────────────────
|
|
255
|
-
|
|
256
|
-
/// @notice Calling autoIssueFor with wrong stageId reverts with NothingToAutoIssue.
|
|
257
|
-
function test_stageIdMismatch_nothingToAutoIssue() external {
|
|
258
|
-
(uint256 revnetId,) = _deployMultiStageRevnet(1);
|
|
259
|
-
|
|
260
|
-
// Use a wrong stageId.
|
|
261
|
-
uint256 wrongStageId = block.timestamp + 999;
|
|
262
|
-
|
|
263
|
-
vm.expectRevert(REVDeployer.REVDeployer_NothingToAutoIssue.selector);
|
|
264
|
-
REV_DEPLOYER.autoIssueFor(revnetId, wrongStageId, multisig());
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// ───────────────── Double claim prevented
|
|
268
|
-
// ─────────────────────
|
|
269
|
-
|
|
270
|
-
/// @notice Claiming once zeroes storage; second claim reverts.
|
|
271
|
-
function test_autoIssue_doubleClaimPrevented() external {
|
|
272
|
-
(uint256 revnetId, uint256[] memory stageIds) = _deployMultiStageRevnet(1);
|
|
273
|
-
|
|
274
|
-
// First claim succeeds.
|
|
275
|
-
REV_DEPLOYER.autoIssueFor(revnetId, stageIds[0], multisig());
|
|
276
|
-
|
|
277
|
-
// Storage should be zeroed.
|
|
278
|
-
assertEq(
|
|
279
|
-
REV_DEPLOYER.amountToAutoIssue(revnetId, stageIds[0], multisig()), 0, "Storage should be zeroed after claim"
|
|
280
|
-
);
|
|
281
|
-
|
|
282
|
-
// Second claim reverts.
|
|
283
|
-
vm.expectRevert(REVDeployer.REVDeployer_NothingToAutoIssue.selector);
|
|
284
|
-
REV_DEPLOYER.autoIssueFor(revnetId, stageIds[0], multisig());
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// ───────────────── Stage not started
|
|
288
|
-
// ─────────────────────
|
|
289
|
-
|
|
290
|
-
/// @notice Calling autoIssueFor before stage start time reverts.
|
|
291
|
-
function test_stageNotStarted_reverts() external {
|
|
292
|
-
(uint256 revnetId, uint256[] memory stageIds) = _deployMultiStageRevnet(2);
|
|
293
|
-
|
|
294
|
-
// Stage 1 starts at block.timestamp + 180 days.
|
|
295
|
-
// Try to claim it now (before it starts).
|
|
296
|
-
vm.expectRevert(abi.encodeWithSelector(REVDeployer.REVDeployer_StageNotStarted.selector, stageIds[1]));
|
|
297
|
-
REV_DEPLOYER.autoIssueFor(revnetId, stageIds[1], multisig());
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// ───────────────── Stage ID vs Ruleset ID comparison
|
|
301
|
-
// ─────────────────────
|
|
302
|
-
|
|
303
|
-
/// @notice Compare stored stageIds with actual ruleset IDs.
|
|
304
|
-
/// Stage IDs use block.timestamp + i during deployment.
|
|
305
|
-
/// If actual ruleset IDs differ (e.g., on cross-chain deployment), auto-issuance breaks.
|
|
306
|
-
function test_stageId_vs_rulesetId_comparison() external {
|
|
307
|
-
(uint256 revnetId, uint256[] memory stageIds) = _deployMultiStageRevnet(3);
|
|
308
|
-
|
|
309
|
-
// Get the actual rulesets from the controller.
|
|
310
|
-
(JBRuleset memory currentRuleset,) = jbController().currentRulesetOf(revnetId);
|
|
311
|
-
|
|
312
|
-
// The first ruleset's ID should match stageIds[0] (both are block.timestamp).
|
|
313
|
-
assertEq(currentRuleset.id, stageIds[0], "First ruleset ID should match stage 0 ID (both block.timestamp)");
|
|
314
|
-
|
|
315
|
-
// For stage 1, the stored key is block.timestamp + 1.
|
|
316
|
-
// The actual ruleset ID depends on when JBRulesets creates it.
|
|
317
|
-
// If the ruleset hasn't started yet, getRulesetOf will use the queued ruleset.
|
|
318
|
-
// The actual ID may differ from block.timestamp + 1.
|
|
319
|
-
uint256 stage1StoredKey = stageIds[1]; // block.timestamp + 1
|
|
320
|
-
uint256 storedAmount = REV_DEPLOYER.amountToAutoIssue(revnetId, stage1StoredKey, multisig());
|
|
321
|
-
assertGt(storedAmount, 0, "Auto-issuance stored at block.timestamp + 1");
|
|
322
|
-
|
|
323
|
-
// Check if the stored key actually corresponds to a valid ruleset.
|
|
324
|
-
// On the same chain/deployment tx, getRulesetOf(block.timestamp + 1) typically works
|
|
325
|
-
// because JBRulesets stores the queued ruleset with that ID.
|
|
326
|
-
// But on a different chain, block.timestamp would differ entirely.
|
|
327
|
-
}
|
|
328
|
-
}
|