@rev-net/core-v6 0.0.11 → 0.0.13
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/ADMINISTRATION.md +7 -7
- package/ARCHITECTURE.md +11 -11
- package/AUDIT_INSTRUCTIONS.md +295 -0
- package/CHANGE_LOG.md +316 -0
- package/README.md +9 -6
- package/RISKS.md +180 -35
- package/SKILLS.md +9 -11
- package/STYLE_GUIDE.md +14 -1
- package/USER_JOURNEYS.md +489 -0
- package/package.json +9 -9
- package/script/Deploy.s.sol +124 -40
- package/script/helpers/RevnetCoreDeploymentLib.sol +19 -6
- package/src/REVDeployer.sol +183 -175
- package/src/REVLoans.sol +65 -28
- package/src/interfaces/IREVDeployer.sol +25 -23
- package/src/structs/REV721TiersHookFlags.sol +1 -0
- package/src/structs/REVAutoIssuance.sol +1 -0
- package/src/structs/REVBaseline721HookConfig.sol +1 -0
- package/src/structs/REVConfig.sol +1 -0
- package/src/structs/REVCroptopAllowedPost.sol +1 -0
- package/src/structs/REVDeploy721TiersHookConfig.sol +13 -14
- package/src/structs/REVDescription.sol +1 -0
- package/src/structs/REVLoan.sol +1 -0
- package/src/structs/REVLoanSource.sol +1 -0
- package/src/structs/REVStageConfig.sol +1 -0
- package/src/structs/REVSuckerDeploymentConfig.sol +1 -0
- package/test/REV.integrations.t.sol +148 -19
- package/test/REVAutoIssuanceFuzz.t.sol +31 -6
- package/test/REVDeployerRegressions.t.sol +47 -9
- package/test/REVInvincibility.t.sol +83 -19
- package/test/REVInvincibilityHandler.sol +29 -0
- package/test/REVLifecycle.t.sol +36 -6
- package/test/REVLoans.invariants.t.sol +64 -10
- package/test/REVLoansAttacks.t.sol +54 -9
- package/test/REVLoansFeeRecovery.t.sol +61 -15
- package/test/REVLoansFindings.t.sol +42 -9
- package/test/REVLoansRegressions.t.sol +33 -6
- package/test/REVLoansSourceFeeRecovery.t.sol +491 -0
- package/test/REVLoansSourced.t.sol +79 -17
- package/test/REVLoansUnSourced.t.sol +61 -10
- package/test/TestBurnHeldTokens.t.sol +47 -11
- package/test/TestCEIPattern.t.sol +37 -6
- package/test/TestCashOutCallerValidation.t.sol +41 -8
- package/test/TestConversionDocumentation.t.sol +50 -13
- package/test/TestCrossCurrencyReclaim.t.sol +584 -0
- package/test/TestCrossSourceReallocation.t.sol +37 -6
- package/test/TestERC2771MetaTx.t.sol +557 -0
- package/test/TestEmptyBuybackSpecs.t.sol +45 -10
- package/test/TestFlashLoanSurplus.t.sol +39 -7
- package/test/TestHookArrayOOB.t.sol +42 -13
- package/test/TestLiquidationBehavior.t.sol +37 -7
- package/test/TestLoanSourceRotation.t.sol +525 -0
- package/test/TestLongTailEconomics.t.sol +651 -0
- package/test/TestLowFindings.t.sol +80 -8
- package/test/TestMixedFixes.t.sol +43 -9
- package/test/TestPermit2Signatures.t.sol +657 -0
- package/test/TestReallocationSandwich.t.sol +384 -0
- package/test/TestRevnetRegressions.t.sol +324 -0
- package/test/TestSplitWeightAdjustment.t.sol +52 -13
- package/test/TestSplitWeightE2E.t.sol +53 -18
- package/test/TestSplitWeightFork.t.sol +66 -21
- package/test/TestStageTransitionBorrowable.t.sol +38 -6
- package/test/TestSwapTerminalPermission.t.sol +37 -7
- package/test/TestUint112Overflow.t.sol +39 -6
- package/test/TestZeroRepayment.t.sol +37 -6
- package/test/fork/ForkTestBase.sol +66 -17
- package/test/fork/TestCashOutFork.t.sol +9 -3
- package/test/fork/TestLoanBorrowFork.t.sol +1 -0
- package/test/fork/TestLoanCrossRulesetFork.t.sol +11 -3
- package/test/fork/TestLoanLiquidationFork.t.sol +1 -0
- package/test/fork/TestLoanReallocateFork.t.sol +1 -0
- package/test/fork/TestLoanRepayFork.t.sol +1 -0
- package/test/fork/TestLoanTransferFork.t.sol +133 -0
- package/test/fork/TestSplitWeightFork.t.sol +3 -0
- package/test/helpers/REVEmpty721Config.sol +46 -0
- package/test/mock/MockBuybackDataHook.sol +1 -0
- package/test/regression/TestBurnPermissionRequired.t.sol +267 -0
- package/test/regression/TestCrossRevnetLiquidation.t.sol +228 -0
- package/test/regression/TestCumulativeLoanCounter.t.sol +38 -8
- package/test/regression/TestLiquidateGapHandling.t.sol +40 -8
- package/test/regression/TestZeroPriceFeed.t.sol +396 -0
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.26;
|
|
3
3
|
|
|
4
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
4
5
|
import "forge-std/Test.sol";
|
|
6
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
5
7
|
import /* {*} from */ "@bananapus/core-v6/test/helpers/TestBaseWorkflow.sol";
|
|
6
|
-
import /* {*} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
8
|
+
// import /* {*} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
9
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
7
10
|
import /* {*} from */ "./../src/REVDeployer.sol";
|
|
11
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
8
12
|
import "@croptop/core-v6/src/CTPublisher.sol";
|
|
9
13
|
import {MockBuybackDataHook} from "./mock/MockBuybackDataHook.sol";
|
|
10
14
|
|
|
15
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
11
16
|
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
17
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
12
18
|
import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
|
|
19
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
13
20
|
import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
|
|
21
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
14
22
|
import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
|
|
23
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
15
24
|
import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
|
|
16
25
|
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
17
26
|
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
@@ -30,6 +39,7 @@ import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
|
|
|
30
39
|
import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
|
|
31
40
|
import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
|
|
32
41
|
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
42
|
+
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
33
43
|
|
|
34
44
|
struct FeeProjectConfig {
|
|
35
45
|
REVConfig configuration;
|
|
@@ -38,23 +48,38 @@ struct FeeProjectConfig {
|
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
contract TestLowFindings is TestBaseWorkflow {
|
|
51
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
41
52
|
bytes32 REV_DEPLOYER_SALT = "REVDeployer";
|
|
53
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
42
54
|
bytes32 ERC20_SALT = "REV_TOKEN";
|
|
43
55
|
|
|
56
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
44
57
|
REVDeployer REV_DEPLOYER;
|
|
58
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
45
59
|
JB721TiersHook EXAMPLE_HOOK;
|
|
60
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
46
61
|
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
62
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
47
63
|
IJB721TiersHookStore HOOK_STORE;
|
|
64
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
48
65
|
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
66
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
49
67
|
IREVLoans LOANS_CONTRACT;
|
|
68
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
50
69
|
MockERC20 TOKEN;
|
|
70
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
51
71
|
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
72
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
52
73
|
CTPublisher PUBLISHER;
|
|
74
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
53
75
|
MockBuybackDataHook MOCK_BUYBACK;
|
|
54
76
|
|
|
77
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
55
78
|
uint256 FEE_PROJECT_ID;
|
|
79
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
56
80
|
uint256 REVNET_ID;
|
|
57
81
|
|
|
82
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
58
83
|
address USER = makeAddr("user");
|
|
59
84
|
|
|
60
85
|
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
@@ -84,6 +109,7 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
84
109
|
autoIssuances: new REVAutoIssuance[](0),
|
|
85
110
|
splitPercent: 2000,
|
|
86
111
|
splits: splits,
|
|
112
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
87
113
|
initialIssuance: uint112(1000 * decimalMultiplier),
|
|
88
114
|
issuanceCutFrequency: 90 days,
|
|
89
115
|
issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
|
|
@@ -92,6 +118,7 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
92
118
|
});
|
|
93
119
|
|
|
94
120
|
REVConfig memory revnetConfiguration = REVConfig({
|
|
121
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
95
122
|
description: REVDescription("Revnet", "$REV", "ipfs://test", ERC20_SALT),
|
|
96
123
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
97
124
|
splitOperator: multisig(),
|
|
@@ -136,6 +163,7 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
136
163
|
autoIssuances: new REVAutoIssuance[](0),
|
|
137
164
|
splitPercent: 2000,
|
|
138
165
|
splits: splits,
|
|
166
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
139
167
|
initialIssuance: uint112(1000 * decimalMultiplier),
|
|
140
168
|
issuanceCutFrequency: 0,
|
|
141
169
|
issuanceCutPercent: 0,
|
|
@@ -160,19 +188,22 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
160
188
|
loanSources[0] = REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: jbMultiTerminal()});
|
|
161
189
|
|
|
162
190
|
REVConfig memory revnetConfiguration = REVConfig({
|
|
191
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
163
192
|
description: REVDescription("TwoStage", "$TWO", "ipfs://test", "TWO_TOKEN"),
|
|
164
193
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
165
194
|
splitOperator: multisig(),
|
|
166
195
|
stageConfigurations: stageConfigurations
|
|
167
196
|
});
|
|
168
197
|
|
|
169
|
-
revnetId = REV_DEPLOYER.deployFor({
|
|
198
|
+
(revnetId,) = REV_DEPLOYER.deployFor({
|
|
170
199
|
revnetId: 0,
|
|
171
200
|
configuration: revnetConfiguration,
|
|
172
201
|
terminalConfigurations: terminalConfigurations,
|
|
173
202
|
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
174
203
|
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256(abi.encodePacked("TWO"))
|
|
175
|
-
})
|
|
204
|
+
}),
|
|
205
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
206
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
176
207
|
});
|
|
177
208
|
}
|
|
178
209
|
|
|
@@ -202,6 +233,7 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
202
233
|
autoIssuances: new REVAutoIssuance[](0),
|
|
203
234
|
splitPercent: 2000,
|
|
204
235
|
splits: splits,
|
|
236
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
205
237
|
initialIssuance: uint112(1000 * decimalMultiplier),
|
|
206
238
|
issuanceCutFrequency: 0,
|
|
207
239
|
issuanceCutPercent: 0,
|
|
@@ -213,19 +245,22 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
213
245
|
loanSources[0] = REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: jbMultiTerminal()});
|
|
214
246
|
|
|
215
247
|
REVConfig memory revnetConfiguration = REVConfig({
|
|
248
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
216
249
|
description: REVDescription("Single", "$SGL", "ipfs://test", "SGL_TOKEN"),
|
|
217
250
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
218
251
|
splitOperator: multisig(),
|
|
219
252
|
stageConfigurations: stageConfigurations
|
|
220
253
|
});
|
|
221
254
|
|
|
222
|
-
revnetId = REV_DEPLOYER.deployFor({
|
|
255
|
+
(revnetId,) = REV_DEPLOYER.deployFor({
|
|
223
256
|
revnetId: 0,
|
|
224
257
|
configuration: revnetConfiguration,
|
|
225
258
|
terminalConfigurations: terminalConfigurations,
|
|
226
259
|
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
227
260
|
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256(abi.encodePacked("SGL"))
|
|
228
|
-
})
|
|
261
|
+
}),
|
|
262
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
263
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
229
264
|
});
|
|
230
265
|
}
|
|
231
266
|
|
|
@@ -235,8 +270,9 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
235
270
|
FEE_PROJECT_ID = jbProjects().createFor(multisig());
|
|
236
271
|
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
237
272
|
HOOK_STORE = new JB721TiersHookStore();
|
|
238
|
-
EXAMPLE_HOOK =
|
|
239
|
-
|
|
273
|
+
EXAMPLE_HOOK = new JB721TiersHook(
|
|
274
|
+
jbDirectory(), jbPermissions(), jbPrices(), jbRulesets(), HOOK_STORE, jbSplits(), multisig()
|
|
275
|
+
);
|
|
240
276
|
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
241
277
|
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
242
278
|
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
@@ -278,7 +314,9 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
278
314
|
revnetId: FEE_PROJECT_ID,
|
|
279
315
|
configuration: feeProjectConfig.configuration,
|
|
280
316
|
terminalConfigurations: feeProjectConfig.terminalConfigurations,
|
|
281
|
-
suckerDeploymentConfiguration: feeProjectConfig.suckerDeploymentConfiguration
|
|
317
|
+
suckerDeploymentConfiguration: feeProjectConfig.suckerDeploymentConfiguration,
|
|
318
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
319
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
282
320
|
});
|
|
283
321
|
|
|
284
322
|
vm.deal(USER, 1000 ether);
|
|
@@ -541,6 +579,7 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
541
579
|
|
|
542
580
|
// Increase surplus WITHOUT minting new tokens — makes existing collateral worth more.
|
|
543
581
|
// This allows reallocating collateral since borrowable(reduced collateral) > loan.amount.
|
|
582
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
544
583
|
address DONOR = makeAddr("donor");
|
|
545
584
|
vm.deal(DONOR, 100 ether);
|
|
546
585
|
vm.prank(DONOR);
|
|
@@ -569,4 +608,37 @@ contract TestLowFindings is TestBaseWorkflow {
|
|
|
569
608
|
assertTrue(newLoanId != loanId, "New loan should have different ID");
|
|
570
609
|
assertTrue(newLoanId != reallocatedLoanId, "New loan should differ from reallocated loan");
|
|
571
610
|
}
|
|
611
|
+
|
|
612
|
+
/// @notice Borrowing with a collateral count so small that the bonding curve rounds the borrow amount to zero
|
|
613
|
+
/// should revert with `REVLoans_ZeroBorrowAmount`.
|
|
614
|
+
function test_borrowFrom_revertsOnZeroBorrowAmount() public {
|
|
615
|
+
uint256 revnetId = _deploySingleStageRevnet();
|
|
616
|
+
|
|
617
|
+
// Pay ETH into revnet to create surplus and get tokens.
|
|
618
|
+
vm.prank(USER);
|
|
619
|
+
uint256 tokens =
|
|
620
|
+
jbMultiTerminal().pay{value: 10 ether}(revnetId, JBConstants.NATIVE_TOKEN, 10 ether, USER, 0, "", "");
|
|
621
|
+
assertGt(tokens, 0, "Should have received tokens");
|
|
622
|
+
|
|
623
|
+
// Confirm that 1 wei of collateral produces a zero borrowable amount.
|
|
624
|
+
// With surplus ~10e18 and totalSupply ~10_000e18, mulDiv(10e18, 1, 10_000e18) rounds to 0.
|
|
625
|
+
uint256 borrowable =
|
|
626
|
+
LOANS_CONTRACT.borrowableAmountFrom(revnetId, 1, 18, uint32(uint160(JBConstants.NATIVE_TOKEN)));
|
|
627
|
+
assertEq(borrowable, 0, "Borrowable amount for 1 wei of collateral should be 0");
|
|
628
|
+
|
|
629
|
+
// Mock the BURN permission (permission ID 11) for the loans contract.
|
|
630
|
+
mockExpect(
|
|
631
|
+
address(jbPermissions()),
|
|
632
|
+
abi.encodeCall(IJBPermissions.hasPermission, (address(LOANS_CONTRACT), USER, revnetId, 11, true, true)),
|
|
633
|
+
abi.encode(true)
|
|
634
|
+
);
|
|
635
|
+
|
|
636
|
+
REVLoanSource memory source = REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: jbMultiTerminal()});
|
|
637
|
+
uint256 minPrepaid = LOANS_CONTRACT.MIN_PREPAID_FEE_PERCENT();
|
|
638
|
+
|
|
639
|
+
// Attempt to borrow with 1 wei of collateral -- bonding curve returns 0, should revert.
|
|
640
|
+
vm.prank(USER);
|
|
641
|
+
vm.expectRevert(REVLoans.REVLoans_ZeroBorrowAmount.selector);
|
|
642
|
+
LOANS_CONTRACT.borrowFrom(revnetId, source, 0, 1, payable(USER), minPrepaid);
|
|
643
|
+
}
|
|
572
644
|
}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.26;
|
|
3
3
|
|
|
4
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
4
5
|
import "forge-std/Test.sol";
|
|
6
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
5
7
|
import /* {*} from */ "@bananapus/core-v6/test/helpers/TestBaseWorkflow.sol";
|
|
6
|
-
import /* {*} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
8
|
+
// import /* {*} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
9
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
7
10
|
import /* {*} from */ "./../src/REVDeployer.sol";
|
|
11
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
8
12
|
import "@croptop/core-v6/src/CTPublisher.sol";
|
|
9
13
|
import {MockBuybackDataHook} from "./mock/MockBuybackDataHook.sol";
|
|
14
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
10
15
|
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
16
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
11
17
|
import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
|
|
18
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
12
19
|
import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
|
|
20
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
13
21
|
import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
|
|
22
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
14
23
|
import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
|
|
15
24
|
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
16
25
|
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
@@ -21,7 +30,6 @@ import {REVLoan} from "../src/structs/REVLoan.sol";
|
|
|
21
30
|
import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
|
|
22
31
|
import {REVLoanSource} from "../src/structs/REVLoanSource.sol";
|
|
23
32
|
import {REVDescription} from "../src/structs/REVDescription.sol";
|
|
24
|
-
import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
|
|
25
33
|
import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
|
|
26
34
|
import {JBSuckerRegistry} from "@bananapus/suckers-v6/src/JBSuckerRegistry.sol";
|
|
27
35
|
import {JB721TiersHookDeployer} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
@@ -29,25 +37,40 @@ import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
|
|
|
29
37
|
import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
|
|
30
38
|
import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
|
|
31
39
|
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
40
|
+
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
32
41
|
|
|
33
42
|
/// @notice Tests for PR #32: liquidation boundary, reallocate msg.value, and decimal normalization fixes.
|
|
34
43
|
contract TestMixedFixes is TestBaseWorkflow {
|
|
44
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
35
45
|
bytes32 REV_DEPLOYER_SALT = "REVDeployer";
|
|
36
46
|
|
|
47
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
37
48
|
REVDeployer REV_DEPLOYER;
|
|
49
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
38
50
|
JB721TiersHook EXAMPLE_HOOK;
|
|
51
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
39
52
|
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
53
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
40
54
|
IJB721TiersHookStore HOOK_STORE;
|
|
55
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
41
56
|
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
57
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
42
58
|
REVLoans LOANS_CONTRACT;
|
|
59
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
43
60
|
MockERC20 TOKEN;
|
|
61
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
44
62
|
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
63
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
45
64
|
CTPublisher PUBLISHER;
|
|
65
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
46
66
|
MockBuybackDataHook MOCK_BUYBACK;
|
|
47
67
|
|
|
68
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
48
69
|
uint256 FEE_PROJECT_ID;
|
|
70
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
49
71
|
uint256 REVNET_ID;
|
|
50
72
|
|
|
73
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
51
74
|
address USER = makeAddr("user");
|
|
52
75
|
|
|
53
76
|
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
@@ -57,8 +80,9 @@ contract TestMixedFixes is TestBaseWorkflow {
|
|
|
57
80
|
FEE_PROJECT_ID = jbProjects().createFor(multisig());
|
|
58
81
|
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
59
82
|
HOOK_STORE = new JB721TiersHookStore();
|
|
60
|
-
EXAMPLE_HOOK =
|
|
61
|
-
|
|
83
|
+
EXAMPLE_HOOK = new JB721TiersHook(
|
|
84
|
+
jbDirectory(), jbPermissions(), jbPrices(), jbRulesets(), HOOK_STORE, jbSplits(), multisig()
|
|
85
|
+
);
|
|
62
86
|
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
63
87
|
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
64
88
|
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
@@ -119,6 +143,7 @@ contract TestMixedFixes is TestBaseWorkflow {
|
|
|
119
143
|
extraMetadata: 0
|
|
120
144
|
});
|
|
121
145
|
REVConfig memory cfg = REVConfig({
|
|
146
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
122
147
|
description: REVDescription("Revnet", "$REV", "ipfs://test", "REV_TOKEN"),
|
|
123
148
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
124
149
|
splitOperator: multisig(),
|
|
@@ -131,7 +156,9 @@ contract TestMixedFixes is TestBaseWorkflow {
|
|
|
131
156
|
terminalConfigurations: tc,
|
|
132
157
|
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
133
158
|
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("FEE")
|
|
134
|
-
})
|
|
159
|
+
}),
|
|
160
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
161
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
135
162
|
});
|
|
136
163
|
}
|
|
137
164
|
|
|
@@ -163,18 +190,21 @@ contract TestMixedFixes is TestBaseWorkflow {
|
|
|
163
190
|
REVLoanSource[] memory ls = new REVLoanSource[](1);
|
|
164
191
|
ls[0] = REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: jbMultiTerminal()});
|
|
165
192
|
REVConfig memory cfg = REVConfig({
|
|
193
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
166
194
|
description: REVDescription("NANA", "$NANA", "ipfs://test2", "NANA_TOKEN"),
|
|
167
195
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
168
196
|
splitOperator: multisig(),
|
|
169
197
|
stageConfigurations: stages
|
|
170
198
|
});
|
|
171
|
-
REVNET_ID = REV_DEPLOYER.deployFor({
|
|
199
|
+
(REVNET_ID,) = REV_DEPLOYER.deployFor({
|
|
172
200
|
revnetId: 0,
|
|
173
201
|
configuration: cfg,
|
|
174
202
|
terminalConfigurations: tc,
|
|
175
203
|
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
176
204
|
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("NANA")
|
|
177
|
-
})
|
|
205
|
+
}),
|
|
206
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
207
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
178
208
|
});
|
|
179
209
|
}
|
|
180
210
|
|
|
@@ -305,6 +335,7 @@ contract TestMixedFixes is TestBaseWorkflow {
|
|
|
305
335
|
|
|
306
336
|
// ==================== Mixed-Decimal Normalization Tests ====================
|
|
307
337
|
|
|
338
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
308
339
|
uint256 MIXED_REVNET_ID;
|
|
309
340
|
|
|
310
341
|
/// @notice Deploy a revnet with BOTH ETH (18 dec) and TOKEN (6 dec) as loan sources.
|
|
@@ -338,18 +369,21 @@ contract TestMixedFixes is TestBaseWorkflow {
|
|
|
338
369
|
ls[0] = REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: jbMultiTerminal()});
|
|
339
370
|
ls[1] = REVLoanSource({token: address(TOKEN), terminal: jbMultiTerminal()});
|
|
340
371
|
REVConfig memory cfg = REVConfig({
|
|
372
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
341
373
|
description: REVDescription("Mixed", "$MIX", "ipfs://mix", "MIX_TOKEN"),
|
|
342
374
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
343
375
|
splitOperator: multisig(),
|
|
344
376
|
stageConfigurations: stages
|
|
345
377
|
});
|
|
346
|
-
MIXED_REVNET_ID = REV_DEPLOYER.deployFor({
|
|
378
|
+
(MIXED_REVNET_ID,) = REV_DEPLOYER.deployFor({
|
|
347
379
|
revnetId: 0,
|
|
348
380
|
configuration: cfg,
|
|
349
381
|
terminalConfigurations: tc,
|
|
350
382
|
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
351
383
|
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("MIXED")
|
|
352
|
-
})
|
|
384
|
+
}),
|
|
385
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
386
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
353
387
|
});
|
|
354
388
|
}
|
|
355
389
|
|