@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.
- 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 +134 -90
- package/src/REVOwner.sol +124 -17
- 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 -97
- 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 -368
- 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/CodexCrossChainBuybackRouteMismatch.t.sol +0 -184
- package/test/audit/CodexPhantomSurplusTerminal.t.sol +0 -367
- package/test/audit/CodexREVOwnerRemoteSurplusCurrencyMismatch.t.sol +0 -142
- package/test/audit/LoanIdOverflowGuard.t.sol +0 -523
- package/test/audit/NemesisOperatorDelegation.t.sol +0 -356
- 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/TestLoanBorrowFork.t.sol +0 -163
- package/test/fork/TestLoanCrossRulesetFork.t.sol +0 -308
- package/test/fork/TestLoanERC20Fork.t.sol +0 -465
- 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,326 +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
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
9
|
-
import /* {*} from */ "./../src/REVDeployer.sol";
|
|
10
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
11
|
-
import "@croptop/core-v6/src/CTPublisher.sol";
|
|
12
|
-
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
13
|
-
|
|
14
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
15
|
-
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
16
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
17
|
-
import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
|
|
18
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
19
|
-
import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
|
|
20
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
21
|
-
import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
|
|
22
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
23
|
-
import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
|
|
24
|
-
|
|
25
|
-
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
26
|
-
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
27
|
-
import {REVLoans} from "../src/REVLoans.sol";
|
|
28
|
-
import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
|
|
29
|
-
import {REVDescription} from "../src/structs/REVDescription.sol";
|
|
30
|
-
import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
|
|
31
|
-
import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
|
|
32
|
-
import {JBSuckerRegistry} from "@bananapus/suckers-v6/src/JBSuckerRegistry.sol";
|
|
33
|
-
import {JB721TiersHookDeployer} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
34
|
-
import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
|
|
35
|
-
import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
|
|
36
|
-
import {JB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/JB721CheckpointsDeployer.sol";
|
|
37
|
-
import {IJB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/interfaces/IJB721CheckpointsDeployer.sol";
|
|
38
|
-
import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
|
|
39
|
-
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
40
|
-
import {REVOwner} from "../src/REVOwner.sol";
|
|
41
|
-
import {IREVDeployer} from "../src/interfaces/IREVDeployer.sol";
|
|
42
|
-
import {MockSuckerRegistry} from "./mock/MockSuckerRegistry.sol";
|
|
43
|
-
import {MockBuybackDataHook} from "./mock/MockBuybackDataHook.sol";
|
|
44
|
-
|
|
45
|
-
/// @notice Tests that terminal addresses are included in the encoded configuration hash.
|
|
46
|
-
contract TestTerminalEncodingInHash is TestBaseWorkflow {
|
|
47
|
-
using JBRulesetMetadataResolver for JBRuleset;
|
|
48
|
-
|
|
49
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
50
|
-
bytes32 REV_DEPLOYER_SALT = "REVDeployer";
|
|
51
|
-
|
|
52
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
53
|
-
REVDeployer REV_DEPLOYER;
|
|
54
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
55
|
-
REVOwner REV_OWNER;
|
|
56
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
57
|
-
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
58
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
59
|
-
IJB721TiersHookStore HOOK_STORE;
|
|
60
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
61
|
-
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
62
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
63
|
-
IREVLoans LOANS_CONTRACT;
|
|
64
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
65
|
-
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
66
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
67
|
-
CTPublisher PUBLISHER;
|
|
68
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
69
|
-
MockBuybackDataHook MOCK_BUYBACK;
|
|
70
|
-
|
|
71
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
72
|
-
uint256 FEE_PROJECT_ID;
|
|
73
|
-
|
|
74
|
-
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
75
|
-
|
|
76
|
-
function setUp() public override {
|
|
77
|
-
super.setUp();
|
|
78
|
-
|
|
79
|
-
FEE_PROJECT_ID = jbProjects().createFor(multisig());
|
|
80
|
-
|
|
81
|
-
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
82
|
-
HOOK_STORE = new JB721TiersHookStore();
|
|
83
|
-
JB721TiersHook exampleHook = new JB721TiersHook(
|
|
84
|
-
jbDirectory(),
|
|
85
|
-
jbPermissions(),
|
|
86
|
-
jbPrices(),
|
|
87
|
-
jbRulesets(),
|
|
88
|
-
HOOK_STORE,
|
|
89
|
-
jbSplits(),
|
|
90
|
-
IJB721CheckpointsDeployer(address(new JB721CheckpointsDeployer())),
|
|
91
|
-
multisig()
|
|
92
|
-
);
|
|
93
|
-
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
94
|
-
HOOK_DEPLOYER = new JB721TiersHookDeployer(exampleHook, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
95
|
-
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
96
|
-
MOCK_BUYBACK = new MockBuybackDataHook();
|
|
97
|
-
|
|
98
|
-
LOANS_CONTRACT = new REVLoans({
|
|
99
|
-
controller: jbController(),
|
|
100
|
-
suckerRegistry: IJBSuckerRegistry(address(new MockSuckerRegistry())),
|
|
101
|
-
revId: FEE_PROJECT_ID,
|
|
102
|
-
owner: address(this),
|
|
103
|
-
permit2: permit2(),
|
|
104
|
-
trustedForwarder: TRUSTED_FORWARDER
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
REV_OWNER = new REVOwner(
|
|
108
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
109
|
-
jbDirectory(),
|
|
110
|
-
FEE_PROJECT_ID,
|
|
111
|
-
SUCKER_REGISTRY,
|
|
112
|
-
address(LOANS_CONTRACT),
|
|
113
|
-
address(0)
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
REV_DEPLOYER = new REVDeployer{salt: REV_DEPLOYER_SALT}(
|
|
117
|
-
jbController(),
|
|
118
|
-
SUCKER_REGISTRY,
|
|
119
|
-
FEE_PROJECT_ID,
|
|
120
|
-
HOOK_DEPLOYER,
|
|
121
|
-
PUBLISHER,
|
|
122
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
123
|
-
address(LOANS_CONTRACT),
|
|
124
|
-
TRUSTED_FORWARDER,
|
|
125
|
-
address(REV_OWNER)
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
REV_OWNER.setDeployer(REV_DEPLOYER);
|
|
129
|
-
|
|
130
|
-
vm.prank(multisig());
|
|
131
|
-
jbProjects().approve(address(REV_DEPLOYER), FEE_PROJECT_ID);
|
|
132
|
-
|
|
133
|
-
// Deploy fee project.
|
|
134
|
-
_deployFeeProject();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/// @notice Two revnets with identical base config but different terminals produce different hashes.
|
|
138
|
-
function test_differentTerminals_produceDifferentHashes() public {
|
|
139
|
-
// Deploy revnet A with the primary multi-terminal (same description salt for both).
|
|
140
|
-
(uint256 revnetA,) = REV_DEPLOYER.deployFor({
|
|
141
|
-
revnetId: 0,
|
|
142
|
-
configuration: _baseRevConfig("DIFF_TERM"),
|
|
143
|
-
terminalConfigurations: _terminalConfigs(jbMultiTerminal()),
|
|
144
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
145
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("A")
|
|
146
|
-
}),
|
|
147
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
148
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// Deploy revnet B with the secondary multi-terminal (same config, only terminal differs).
|
|
152
|
-
(uint256 revnetB,) = REV_DEPLOYER.deployFor({
|
|
153
|
-
revnetId: 0,
|
|
154
|
-
configuration: _baseRevConfig("DIFF_TERM"),
|
|
155
|
-
terminalConfigurations: _terminalConfigs(jbMultiTerminal2()),
|
|
156
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
157
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("B")
|
|
158
|
-
}),
|
|
159
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
160
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
bytes32 hashA = REV_DEPLOYER.hashedEncodedConfigurationOf(revnetA);
|
|
164
|
-
bytes32 hashB = REV_DEPLOYER.hashedEncodedConfigurationOf(revnetB);
|
|
165
|
-
|
|
166
|
-
assertNotEq(hashA, hashB, "Different terminals must produce different configuration hashes");
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/// @notice The hash includes the terminal address — verify by computing it off-chain.
|
|
170
|
-
function test_hashIncludesTerminalAddress() public {
|
|
171
|
-
// Deploy a revnet.
|
|
172
|
-
(uint256 revnetId,) = REV_DEPLOYER.deployFor({
|
|
173
|
-
revnetId: 0,
|
|
174
|
-
configuration: _baseRevConfig("VERIFY"),
|
|
175
|
-
terminalConfigurations: _terminalConfigs(jbMultiTerminal()),
|
|
176
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
177
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("VERIFY")
|
|
178
|
-
}),
|
|
179
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
180
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
// Recompute the expected hash manually.
|
|
184
|
-
bytes memory encodedConfiguration = abi.encode(
|
|
185
|
-
uint32(uint160(JBConstants.NATIVE_TOKEN)), // baseCurrency
|
|
186
|
-
"Terminal Test", // name
|
|
187
|
-
"TERM", // ticker
|
|
188
|
-
bytes32("VERIFY") // salt
|
|
189
|
-
);
|
|
190
|
-
// Terminal address encoding.
|
|
191
|
-
encodedConfiguration = abi.encode(encodedConfiguration, jbMultiTerminal());
|
|
192
|
-
// Stage encoding.
|
|
193
|
-
encodedConfiguration = abi.encode(
|
|
194
|
-
encodedConfiguration,
|
|
195
|
-
block.timestamp, // startsAtOrAfter
|
|
196
|
-
uint256(0), // splitPercent
|
|
197
|
-
uint112(1000e18), // initialIssuance
|
|
198
|
-
uint256(0), // issuanceCutFrequency
|
|
199
|
-
uint256(0), // issuanceCutPercent
|
|
200
|
-
uint256(5000) // cashOutTaxRate
|
|
201
|
-
);
|
|
202
|
-
bytes32 expectedHash = keccak256(encodedConfiguration);
|
|
203
|
-
|
|
204
|
-
assertEq(
|
|
205
|
-
REV_DEPLOYER.hashedEncodedConfigurationOf(revnetId),
|
|
206
|
-
expectedHash,
|
|
207
|
-
"On-chain hash must match off-chain computation including terminal address"
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/// @notice Terminal ordering matters — [A, B] != [B, A].
|
|
212
|
-
function test_terminalOrder_affectsHash() public {
|
|
213
|
-
// Deploy revnet with terminals in order [main, alt].
|
|
214
|
-
JBTerminalConfig[] memory tcAB = new JBTerminalConfig[](2);
|
|
215
|
-
JBAccountingContext[] memory acc = new JBAccountingContext[](1);
|
|
216
|
-
acc[0] = JBAccountingContext({
|
|
217
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
218
|
-
});
|
|
219
|
-
tcAB[0] = JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: acc});
|
|
220
|
-
tcAB[1] = JBTerminalConfig({terminal: jbMultiTerminal2(), accountingContextsToAccept: acc});
|
|
221
|
-
|
|
222
|
-
(uint256 revnetAB,) = REV_DEPLOYER.deployFor({
|
|
223
|
-
revnetId: 0,
|
|
224
|
-
configuration: _baseRevConfig("ORDER"),
|
|
225
|
-
terminalConfigurations: tcAB,
|
|
226
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
227
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("AB")
|
|
228
|
-
}),
|
|
229
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
230
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
// Deploy revnet with terminals in order [alt, main].
|
|
234
|
-
JBTerminalConfig[] memory tcBA = new JBTerminalConfig[](2);
|
|
235
|
-
tcBA[0] = JBTerminalConfig({terminal: jbMultiTerminal2(), accountingContextsToAccept: acc});
|
|
236
|
-
tcBA[1] = JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: acc});
|
|
237
|
-
|
|
238
|
-
(uint256 revnetBA,) = REV_DEPLOYER.deployFor({
|
|
239
|
-
revnetId: 0,
|
|
240
|
-
configuration: _baseRevConfig("ORDER"),
|
|
241
|
-
terminalConfigurations: tcBA,
|
|
242
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
243
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("BA")
|
|
244
|
-
}),
|
|
245
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
246
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
bytes32 hashAB = REV_DEPLOYER.hashedEncodedConfigurationOf(revnetAB);
|
|
250
|
-
bytes32 hashBA = REV_DEPLOYER.hashedEncodedConfigurationOf(revnetBA);
|
|
251
|
-
|
|
252
|
-
assertNotEq(hashAB, hashBA, "Terminal order must affect the configuration hash");
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// ─── Helpers
|
|
256
|
-
// ───────────────────────────────────────────────────────────────
|
|
257
|
-
// //
|
|
258
|
-
|
|
259
|
-
function _baseRevConfig(bytes32 salt) internal view returns (REVConfig memory) {
|
|
260
|
-
REVStageConfig[] memory stages = new REVStageConfig[](1);
|
|
261
|
-
stages[0] = REVStageConfig({
|
|
262
|
-
startsAtOrAfter: uint48(block.timestamp),
|
|
263
|
-
autoIssuances: new REVAutoIssuance[](0),
|
|
264
|
-
splitPercent: 0,
|
|
265
|
-
splits: new JBSplit[](0),
|
|
266
|
-
initialIssuance: uint112(1000e18),
|
|
267
|
-
issuanceCutFrequency: 0,
|
|
268
|
-
issuanceCutPercent: 0,
|
|
269
|
-
cashOutTaxRate: 5000,
|
|
270
|
-
extraMetadata: 0
|
|
271
|
-
});
|
|
272
|
-
return REVConfig({
|
|
273
|
-
description: REVDescription("Terminal Test", "TERM", "", salt),
|
|
274
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
275
|
-
splitOperator: multisig(),
|
|
276
|
-
stageConfigurations: stages
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function _terminalConfigs(IJBMultiTerminal terminal) internal pure returns (JBTerminalConfig[] memory tc) {
|
|
281
|
-
JBAccountingContext[] memory acc = new JBAccountingContext[](1);
|
|
282
|
-
acc[0] = JBAccountingContext({
|
|
283
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
284
|
-
});
|
|
285
|
-
tc = new JBTerminalConfig[](1);
|
|
286
|
-
tc[0] = JBTerminalConfig({terminal: terminal, accountingContextsToAccept: acc});
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function _deployFeeProject() internal {
|
|
290
|
-
JBAccountingContext[] memory acc = new JBAccountingContext[](1);
|
|
291
|
-
acc[0] = JBAccountingContext({
|
|
292
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
293
|
-
});
|
|
294
|
-
JBTerminalConfig[] memory tc = new JBTerminalConfig[](1);
|
|
295
|
-
tc[0] = JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: acc});
|
|
296
|
-
REVStageConfig[] memory stages = new REVStageConfig[](1);
|
|
297
|
-
stages[0] = REVStageConfig({
|
|
298
|
-
startsAtOrAfter: uint48(block.timestamp),
|
|
299
|
-
autoIssuances: new REVAutoIssuance[](0),
|
|
300
|
-
splitPercent: 0,
|
|
301
|
-
splits: new JBSplit[](0),
|
|
302
|
-
initialIssuance: uint112(1000e18),
|
|
303
|
-
issuanceCutFrequency: 0,
|
|
304
|
-
issuanceCutPercent: 0,
|
|
305
|
-
cashOutTaxRate: 0,
|
|
306
|
-
extraMetadata: 0
|
|
307
|
-
});
|
|
308
|
-
REVConfig memory feeConfig = REVConfig({
|
|
309
|
-
description: REVDescription("Fee Project", "FEE", "", bytes32("FEE")),
|
|
310
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
311
|
-
splitOperator: multisig(),
|
|
312
|
-
stageConfigurations: stages
|
|
313
|
-
});
|
|
314
|
-
vm.prank(multisig());
|
|
315
|
-
REV_DEPLOYER.deployFor({
|
|
316
|
-
revnetId: FEE_PROJECT_ID,
|
|
317
|
-
configuration: feeConfig,
|
|
318
|
-
terminalConfigurations: tc,
|
|
319
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
320
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("FEE")
|
|
321
|
-
}),
|
|
322
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
323
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
@@ -1,311 +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
|
-
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
27
|
-
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
28
|
-
import {MockPriceFeed} from "@bananapus/core-v6/test/mock/MockPriceFeed.sol";
|
|
29
|
-
import {MockERC20} from "@bananapus/core-v6/test/mock/MockERC20.sol";
|
|
30
|
-
import {REVLoans} from "../src/REVLoans.sol";
|
|
31
|
-
import {REVLoan} from "../src/structs/REVLoan.sol";
|
|
32
|
-
import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
|
|
33
|
-
import {REVLoanSource} from "../src/structs/REVLoanSource.sol";
|
|
34
|
-
import {REVDescription} from "../src/structs/REVDescription.sol";
|
|
35
|
-
import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
|
|
36
|
-
import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
|
|
37
|
-
import {JBSuckerRegistry} from "@bananapus/suckers-v6/src/JBSuckerRegistry.sol";
|
|
38
|
-
import {JB721TiersHookDeployer} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
39
|
-
import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
|
|
40
|
-
import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
|
|
41
|
-
import {JB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/JB721CheckpointsDeployer.sol";
|
|
42
|
-
import {IJB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/interfaces/IJB721CheckpointsDeployer.sol";
|
|
43
|
-
import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
|
|
44
|
-
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
45
|
-
import {REVOwner} from "../src/REVOwner.sol";
|
|
46
|
-
import {IREVDeployer} from "../src/interfaces/IREVDeployer.sol";
|
|
47
|
-
import {MockSuckerRegistry} from "./mock/MockSuckerRegistry.sol";
|
|
48
|
-
|
|
49
|
-
/// @title TestUint112Overflow
|
|
50
|
-
/// @notice Tests for uint112 truncation fix in REVLoans._adjust()
|
|
51
|
-
contract TestUint112Overflow is TestBaseWorkflow {
|
|
52
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
53
|
-
bytes32 REV_DEPLOYER_SALT = "REVDeployer";
|
|
54
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
55
|
-
bytes32 ERC20_SALT = "REV_TOKEN";
|
|
56
|
-
|
|
57
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
58
|
-
REVDeployer REV_DEPLOYER;
|
|
59
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
60
|
-
REVOwner REV_OWNER;
|
|
61
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
62
|
-
JB721TiersHook EXAMPLE_HOOK;
|
|
63
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
64
|
-
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
65
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
66
|
-
IJB721TiersHookStore HOOK_STORE;
|
|
67
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
68
|
-
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
69
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
70
|
-
IREVLoans LOANS_CONTRACT;
|
|
71
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
72
|
-
MockERC20 TOKEN;
|
|
73
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
74
|
-
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
75
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
76
|
-
CTPublisher PUBLISHER;
|
|
77
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
78
|
-
MockBuybackDataHook MOCK_BUYBACK;
|
|
79
|
-
|
|
80
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
81
|
-
uint256 FEE_PROJECT_ID;
|
|
82
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
83
|
-
uint256 REVNET_ID;
|
|
84
|
-
|
|
85
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
86
|
-
address USER = makeAddr("user");
|
|
87
|
-
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
88
|
-
|
|
89
|
-
function setUp() public override {
|
|
90
|
-
super.setUp();
|
|
91
|
-
|
|
92
|
-
FEE_PROJECT_ID = jbProjects().createFor(multisig());
|
|
93
|
-
|
|
94
|
-
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
95
|
-
HOOK_STORE = new JB721TiersHookStore();
|
|
96
|
-
EXAMPLE_HOOK = new JB721TiersHook(
|
|
97
|
-
jbDirectory(),
|
|
98
|
-
jbPermissions(),
|
|
99
|
-
jbPrices(),
|
|
100
|
-
jbRulesets(),
|
|
101
|
-
HOOK_STORE,
|
|
102
|
-
jbSplits(),
|
|
103
|
-
IJB721CheckpointsDeployer(address(new JB721CheckpointsDeployer())),
|
|
104
|
-
multisig()
|
|
105
|
-
);
|
|
106
|
-
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
107
|
-
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
108
|
-
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
109
|
-
MOCK_BUYBACK = new MockBuybackDataHook();
|
|
110
|
-
TOKEN = new MockERC20("1/2 ETH", "1/2");
|
|
111
|
-
|
|
112
|
-
MockPriceFeed priceFeed = new MockPriceFeed(1e21, 6);
|
|
113
|
-
vm.prank(multisig());
|
|
114
|
-
jbPrices()
|
|
115
|
-
.addPriceFeedFor(0, uint32(uint160(address(TOKEN))), uint32(uint160(JBConstants.NATIVE_TOKEN)), priceFeed);
|
|
116
|
-
|
|
117
|
-
LOANS_CONTRACT = new REVLoans({
|
|
118
|
-
controller: jbController(),
|
|
119
|
-
suckerRegistry: IJBSuckerRegistry(address(new MockSuckerRegistry())),
|
|
120
|
-
revId: FEE_PROJECT_ID,
|
|
121
|
-
owner: address(this),
|
|
122
|
-
permit2: permit2(),
|
|
123
|
-
trustedForwarder: TRUSTED_FORWARDER
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
REV_OWNER = new REVOwner(
|
|
127
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
128
|
-
jbDirectory(),
|
|
129
|
-
FEE_PROJECT_ID,
|
|
130
|
-
SUCKER_REGISTRY,
|
|
131
|
-
address(LOANS_CONTRACT),
|
|
132
|
-
address(0)
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
REV_DEPLOYER = new REVDeployer{salt: REV_DEPLOYER_SALT}(
|
|
136
|
-
jbController(),
|
|
137
|
-
SUCKER_REGISTRY,
|
|
138
|
-
FEE_PROJECT_ID,
|
|
139
|
-
HOOK_DEPLOYER,
|
|
140
|
-
PUBLISHER,
|
|
141
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
142
|
-
address(LOANS_CONTRACT),
|
|
143
|
-
TRUSTED_FORWARDER,
|
|
144
|
-
address(REV_OWNER)
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
REV_OWNER.setDeployer(REV_DEPLOYER);
|
|
148
|
-
|
|
149
|
-
// Deploy fee project
|
|
150
|
-
vm.prank(multisig());
|
|
151
|
-
jbProjects().approve(address(REV_DEPLOYER), FEE_PROJECT_ID);
|
|
152
|
-
|
|
153
|
-
_deployFeeProject();
|
|
154
|
-
_deployRevnet();
|
|
155
|
-
|
|
156
|
-
vm.deal(USER, 1000e18);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function _deployFeeProject() internal {
|
|
160
|
-
JBAccountingContext[] memory acc = new JBAccountingContext[](2);
|
|
161
|
-
acc[0] = JBAccountingContext({
|
|
162
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
163
|
-
});
|
|
164
|
-
acc[1] = JBAccountingContext({token: address(TOKEN), decimals: 6, currency: uint32(uint160(address(TOKEN)))});
|
|
165
|
-
JBTerminalConfig[] memory tc = new JBTerminalConfig[](1);
|
|
166
|
-
tc[0] = JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: acc});
|
|
167
|
-
|
|
168
|
-
REVStageConfig[] memory stages = new REVStageConfig[](1);
|
|
169
|
-
JBSplit[] memory splits = new JBSplit[](1);
|
|
170
|
-
splits[0].beneficiary = payable(multisig());
|
|
171
|
-
splits[0].percent = 10_000;
|
|
172
|
-
REVAutoIssuance[] memory ai = new REVAutoIssuance[](1);
|
|
173
|
-
ai[0] = REVAutoIssuance({chainId: uint32(block.chainid), count: uint104(70_000e18), beneficiary: multisig()});
|
|
174
|
-
stages[0] = REVStageConfig({
|
|
175
|
-
startsAtOrAfter: uint40(block.timestamp),
|
|
176
|
-
autoIssuances: ai,
|
|
177
|
-
splitPercent: 2000,
|
|
178
|
-
splits: splits,
|
|
179
|
-
initialIssuance: uint112(1000e18),
|
|
180
|
-
issuanceCutFrequency: 90 days,
|
|
181
|
-
issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
|
|
182
|
-
cashOutTaxRate: 6000,
|
|
183
|
-
extraMetadata: 0
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
REVConfig memory cfg = REVConfig({
|
|
187
|
-
// forge-lint: disable-next-line(named-struct-fields)
|
|
188
|
-
description: REVDescription("Revnet", "$REV", "ipfs://test", ERC20_SALT),
|
|
189
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
190
|
-
splitOperator: multisig(),
|
|
191
|
-
stageConfigurations: stages
|
|
192
|
-
});
|
|
193
|
-
vm.prank(multisig());
|
|
194
|
-
REV_DEPLOYER.deployFor({
|
|
195
|
-
revnetId: FEE_PROJECT_ID,
|
|
196
|
-
configuration: cfg,
|
|
197
|
-
terminalConfigurations: tc,
|
|
198
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
199
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("FEE")
|
|
200
|
-
}),
|
|
201
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
202
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function _deployRevnet() internal {
|
|
207
|
-
JBAccountingContext[] memory acc = new JBAccountingContext[](2);
|
|
208
|
-
acc[0] = JBAccountingContext({
|
|
209
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
210
|
-
});
|
|
211
|
-
acc[1] = JBAccountingContext({token: address(TOKEN), decimals: 6, currency: uint32(uint160(address(TOKEN)))});
|
|
212
|
-
JBTerminalConfig[] memory tc = new JBTerminalConfig[](1);
|
|
213
|
-
tc[0] = JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: acc});
|
|
214
|
-
|
|
215
|
-
REVStageConfig[] memory stages = new REVStageConfig[](1);
|
|
216
|
-
JBSplit[] memory splits = new JBSplit[](1);
|
|
217
|
-
splits[0].beneficiary = payable(multisig());
|
|
218
|
-
splits[0].percent = 10_000;
|
|
219
|
-
REVAutoIssuance[] memory ai = new REVAutoIssuance[](1);
|
|
220
|
-
ai[0] = REVAutoIssuance({chainId: uint32(block.chainid), count: uint104(70_000e18), beneficiary: multisig()});
|
|
221
|
-
stages[0] = REVStageConfig({
|
|
222
|
-
startsAtOrAfter: uint40(block.timestamp),
|
|
223
|
-
autoIssuances: ai,
|
|
224
|
-
splitPercent: 2000,
|
|
225
|
-
splits: splits,
|
|
226
|
-
initialIssuance: uint112(1000e18),
|
|
227
|
-
issuanceCutFrequency: 90 days,
|
|
228
|
-
issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
|
|
229
|
-
cashOutTaxRate: 6000,
|
|
230
|
-
extraMetadata: 0
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
REVLoanSource[] memory ls = new REVLoanSource[](1);
|
|
234
|
-
ls[0] = REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: jbMultiTerminal()});
|
|
235
|
-
|
|
236
|
-
REVConfig memory cfg = REVConfig({
|
|
237
|
-
// forge-lint: disable-next-line(named-struct-fields)
|
|
238
|
-
description: REVDescription("NANA", "$NANA", "ipfs://test2", "NANA_TOKEN"),
|
|
239
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
240
|
-
splitOperator: multisig(),
|
|
241
|
-
stageConfigurations: stages
|
|
242
|
-
});
|
|
243
|
-
(REVNET_ID,) = REV_DEPLOYER.deployFor({
|
|
244
|
-
revnetId: 0,
|
|
245
|
-
configuration: cfg,
|
|
246
|
-
terminalConfigurations: tc,
|
|
247
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
248
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("NANA")
|
|
249
|
-
}),
|
|
250
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
251
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function _setupLoan(
|
|
256
|
-
address user,
|
|
257
|
-
uint256 ethAmount,
|
|
258
|
-
uint256 prepaidFee
|
|
259
|
-
)
|
|
260
|
-
internal
|
|
261
|
-
returns (uint256 loanId, uint256 tokenCount, uint256 borrowAmount)
|
|
262
|
-
{
|
|
263
|
-
vm.prank(user);
|
|
264
|
-
tokenCount =
|
|
265
|
-
jbMultiTerminal().pay{value: ethAmount}(REVNET_ID, JBConstants.NATIVE_TOKEN, ethAmount, user, 0, "", "");
|
|
266
|
-
|
|
267
|
-
borrowAmount =
|
|
268
|
-
LOANS_CONTRACT.borrowableAmountFrom(REVNET_ID, tokenCount, 18, uint32(uint160(JBConstants.NATIVE_TOKEN)));
|
|
269
|
-
if (borrowAmount == 0) return (0, tokenCount, 0);
|
|
270
|
-
|
|
271
|
-
mockExpect(
|
|
272
|
-
address(jbPermissions()),
|
|
273
|
-
abi.encodeCall(IJBPermissions.hasPermission, (address(LOANS_CONTRACT), user, REVNET_ID, 11, true, true)),
|
|
274
|
-
abi.encode(true)
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
REVLoanSource memory source = REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: jbMultiTerminal()});
|
|
278
|
-
vm.prank(user);
|
|
279
|
-
(loanId,) = LOANS_CONTRACT.borrowFrom(REVNET_ID, source, 0, tokenCount, payable(user), prepaidFee, user);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/// @notice Verify loan creation with a reasonable borrow amount succeeds.
|
|
283
|
-
function test_borrowNormalAmount_succeeds() public {
|
|
284
|
-
(uint256 loanId, uint256 tokenCount, uint256 borrowAmount) = _setupLoan(USER, 10e18, 25);
|
|
285
|
-
assertTrue(borrowAmount > 0, "Should have nonzero borrow amount");
|
|
286
|
-
assertTrue(loanId > 0, "Should have created a loan");
|
|
287
|
-
|
|
288
|
-
REVLoan memory loan = LOANS_CONTRACT.loanOf(loanId);
|
|
289
|
-
assertEq(loan.amount, borrowAmount, "Loan amount should match borrowed amount");
|
|
290
|
-
assertEq(loan.collateral, tokenCount, "Loan collateral should match token count");
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/// @notice Verify that uint112.max exactly does NOT revert (boundary test).
|
|
294
|
-
function test_boundaryValue_exactlyUint112Max() public pure {
|
|
295
|
-
// uint112.max is the boundary — the check is `>`, not `>=`
|
|
296
|
-
// So exactly uint112.max should NOT revert
|
|
297
|
-
uint256 maxVal = type(uint112).max;
|
|
298
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
299
|
-
uint112 casted = uint112(maxVal);
|
|
300
|
-
assertEq(uint256(casted), maxVal, "Casting uint112.max should not truncate");
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/// @notice Verify the overflow check exists: values > uint112.max are rejected.
|
|
304
|
-
/// @dev We verify this by checking the error selector exists on the contract.
|
|
305
|
-
function test_overflowRevert_errorExists() public pure {
|
|
306
|
-
// The fix adds REVLoans_OverflowAlert error. Verify the error exists
|
|
307
|
-
// by encoding it. If this compiles, the error exists.
|
|
308
|
-
bytes4 selector = REVLoans.REVLoans_OverflowAlert.selector;
|
|
309
|
-
assertTrue(selector != bytes4(0), "OverflowAlert error should exist");
|
|
310
|
-
}
|
|
311
|
-
}
|