@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,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";
|
|
8
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
6
9
|
import /* {*} from */ "./../src/REVDeployer.sol";
|
|
10
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
7
11
|
import "@croptop/core-v6/src/CTPublisher.sol";
|
|
8
12
|
import {MockBuybackDataHookMintPath} from "./mock/MockBuybackDataHookMintPath.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
|
|
|
16
25
|
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
@@ -18,7 +27,6 @@ import {JBMetadataResolver} from "@bananapus/core-v6/src/libraries/JBMetadataRes
|
|
|
18
27
|
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
19
28
|
import {REVLoans} from "../src/REVLoans.sol";
|
|
20
29
|
import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
|
|
21
|
-
import {REVLoanSource} from "../src/structs/REVLoanSource.sol";
|
|
22
30
|
import {REVDescription} from "../src/structs/REVDescription.sol";
|
|
23
31
|
import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
|
|
24
32
|
import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
|
|
@@ -30,7 +38,6 @@ import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressReg
|
|
|
30
38
|
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
31
39
|
import {IJBRulesetDataHook} from "@bananapus/core-v6/src/interfaces/IJBRulesetDataHook.sol";
|
|
32
40
|
import {IJBBuybackHookRegistry} from "@bananapus/buyback-hook-v6/src/interfaces/IJBBuybackHookRegistry.sol";
|
|
33
|
-
import {IJBPayHook} from "@bananapus/core-v6/src/interfaces/IJBPayHook.sol";
|
|
34
41
|
import {JB721TierConfig} from "@bananapus/721-hook-v6/src/structs/JB721TierConfig.sol";
|
|
35
42
|
import {JB721InitTiersConfig} from "@bananapus/721-hook-v6/src/structs/JB721InitTiersConfig.sol";
|
|
36
43
|
import {IJB721TokenUriResolver} from "@bananapus/721-hook-v6/src/interfaces/IJB721TokenUriResolver.sol";
|
|
@@ -38,6 +45,7 @@ import {REVDeploy721TiersHookConfig} from "../src/structs/REVDeploy721TiersHookC
|
|
|
38
45
|
import {REVBaseline721HookConfig} from "../src/structs/REVBaseline721HookConfig.sol";
|
|
39
46
|
import {REV721TiersHookFlags} from "../src/structs/REV721TiersHookFlags.sol";
|
|
40
47
|
import {REVCroptopAllowedPost} from "../src/structs/REVCroptopAllowedPost.sol";
|
|
48
|
+
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
41
49
|
|
|
42
50
|
/// @notice E2E tests verifying that the split weight adjustment in REVDeployer produces correct token counts
|
|
43
51
|
/// when payments flow through the full terminal → store → dataHook → mint pipeline.
|
|
@@ -45,22 +53,35 @@ import {REVCroptopAllowedPost} from "../src/structs/REVCroptopAllowedPost.sol";
|
|
|
45
53
|
contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
46
54
|
using JBMetadataResolver for bytes;
|
|
47
55
|
|
|
56
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
48
57
|
bytes32 REV_DEPLOYER_SALT = "REVDeployer_E2E";
|
|
49
58
|
|
|
59
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
50
60
|
REVDeployer REV_DEPLOYER;
|
|
61
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
51
62
|
JB721TiersHook EXAMPLE_HOOK;
|
|
63
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
52
64
|
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
65
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
53
66
|
IJB721TiersHookStore HOOK_STORE;
|
|
67
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
54
68
|
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
69
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
55
70
|
IREVLoans LOANS_CONTRACT;
|
|
71
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
56
72
|
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
73
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
57
74
|
CTPublisher PUBLISHER;
|
|
75
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
58
76
|
MockBuybackDataHookMintPath MOCK_BUYBACK_MINT;
|
|
59
77
|
|
|
78
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
60
79
|
uint256 FEE_PROJECT_ID;
|
|
61
80
|
|
|
62
81
|
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
82
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
63
83
|
address PAYER = makeAddr("payer");
|
|
84
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
64
85
|
address SPLIT_BENEFICIARY = makeAddr("splitBeneficiary");
|
|
65
86
|
|
|
66
87
|
// Tier configuration: 1 ETH tier with 30% split.
|
|
@@ -75,8 +96,9 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
75
96
|
|
|
76
97
|
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
77
98
|
HOOK_STORE = new JB721TiersHookStore();
|
|
78
|
-
EXAMPLE_HOOK =
|
|
79
|
-
|
|
99
|
+
EXAMPLE_HOOK = new JB721TiersHook(
|
|
100
|
+
jbDirectory(), jbPermissions(), jbPrices(), jbRulesets(), HOOK_STORE, jbSplits(), multisig()
|
|
101
|
+
);
|
|
80
102
|
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
81
103
|
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
82
104
|
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
@@ -141,6 +163,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
141
163
|
});
|
|
142
164
|
|
|
143
165
|
cfg = REVConfig({
|
|
166
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
144
167
|
description: REVDescription("E2E Test", "E2E", "ipfs://e2e", "E2E_SALT"),
|
|
145
168
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
146
169
|
splitOperator: multisig(),
|
|
@@ -171,6 +194,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
171
194
|
votingUnits: 0,
|
|
172
195
|
reserveFrequency: 0,
|
|
173
196
|
reserveBeneficiary: address(0),
|
|
197
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
174
198
|
encodedIPFSUri: bytes32("tier1"),
|
|
175
199
|
category: 1,
|
|
176
200
|
discountPercent: 0,
|
|
@@ -192,10 +216,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
192
216
|
tokenUriResolver: IJB721TokenUriResolver(address(0)),
|
|
193
217
|
contractUri: "ipfs://contract",
|
|
194
218
|
tiersConfig: JB721InitTiersConfig({
|
|
195
|
-
tiers: tiers,
|
|
196
|
-
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
197
|
-
decimals: 18,
|
|
198
|
-
prices: IJBPrices(address(0))
|
|
219
|
+
tiers: tiers, currency: uint32(uint160(JBConstants.NATIVE_TOKEN)), decimals: 18
|
|
199
220
|
}),
|
|
200
221
|
reserveBeneficiary: address(0),
|
|
201
222
|
flags: REV721TiersHookFlags({
|
|
@@ -205,11 +226,12 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
205
226
|
preventOverspending: false
|
|
206
227
|
})
|
|
207
228
|
}),
|
|
229
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
208
230
|
salt: bytes32("E2E_721"),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
231
|
+
preventSplitOperatorAdjustingTiers: false,
|
|
232
|
+
preventSplitOperatorUpdatingMetadata: false,
|
|
233
|
+
preventSplitOperatorMinting: false,
|
|
234
|
+
preventSplitOperatorIncreasingDiscountPercent: false
|
|
213
235
|
});
|
|
214
236
|
}
|
|
215
237
|
|
|
@@ -218,6 +240,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
218
240
|
// Deploy fee project first.
|
|
219
241
|
(REVConfig memory feeCfg, JBTerminalConfig[] memory feeTc, REVSuckerDeploymentConfig memory feeSdc) =
|
|
220
242
|
_buildMinimalConfig();
|
|
243
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
221
244
|
feeCfg.description = REVDescription("Fee", "FEE", "ipfs://fee", "FEE_SALT");
|
|
222
245
|
|
|
223
246
|
vm.prank(multisig());
|
|
@@ -225,7 +248,9 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
225
248
|
revnetId: FEE_PROJECT_ID,
|
|
226
249
|
configuration: feeCfg,
|
|
227
250
|
terminalConfigurations: feeTc,
|
|
228
|
-
suckerDeploymentConfiguration: feeSdc
|
|
251
|
+
suckerDeploymentConfiguration: feeSdc,
|
|
252
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
253
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
229
254
|
});
|
|
230
255
|
|
|
231
256
|
// Deploy the revnet with 721 hook.
|
|
@@ -233,7 +258,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
233
258
|
_buildMinimalConfig();
|
|
234
259
|
REVDeploy721TiersHookConfig memory hookConfig = _build721Config();
|
|
235
260
|
|
|
236
|
-
(revnetId, hook) = REV_DEPLOYER.
|
|
261
|
+
(revnetId, hook) = REV_DEPLOYER.deployFor({
|
|
237
262
|
revnetId: 0,
|
|
238
263
|
configuration: cfg,
|
|
239
264
|
terminalConfigurations: tc,
|
|
@@ -398,6 +423,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
398
423
|
// Deploy fee project.
|
|
399
424
|
(REVConfig memory feeCfg, JBTerminalConfig[] memory feeTc, REVSuckerDeploymentConfig memory feeSdc) =
|
|
400
425
|
_buildMinimalConfig();
|
|
426
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
401
427
|
feeCfg.description = REVDescription("Fee AMM", "FEEA", "ipfs://feeamm", "FEEA_SALT");
|
|
402
428
|
|
|
403
429
|
vm.prank(multisig());
|
|
@@ -405,16 +431,19 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
405
431
|
revnetId: FEE_PROJECT_ID,
|
|
406
432
|
configuration: feeCfg,
|
|
407
433
|
terminalConfigurations: feeTc,
|
|
408
|
-
suckerDeploymentConfiguration: feeSdc
|
|
434
|
+
suckerDeploymentConfiguration: feeSdc,
|
|
435
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
436
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
409
437
|
});
|
|
410
438
|
|
|
411
439
|
// Deploy revnet with 721 hook.
|
|
412
440
|
(REVConfig memory cfg, JBTerminalConfig[] memory tc, REVSuckerDeploymentConfig memory sdc) =
|
|
413
441
|
_buildMinimalConfig();
|
|
442
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
414
443
|
cfg.description = REVDescription("AMM E2E", "AMME", "ipfs://amme2e", "AMME_SALT");
|
|
415
444
|
REVDeploy721TiersHookConfig memory hookConfig = _build721Config();
|
|
416
445
|
|
|
417
|
-
(uint256 revnetId, IJB721TiersHook hook) = ammDeployer.
|
|
446
|
+
(uint256 revnetId, IJB721TiersHook hook) = ammDeployer.deployFor({
|
|
418
447
|
revnetId: 0,
|
|
419
448
|
configuration: cfg,
|
|
420
449
|
terminalConfigurations: tc,
|
|
@@ -497,10 +526,16 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
497
526
|
// --- Revnet 2: no splits (plain payment, no tier metadata) ---
|
|
498
527
|
(REVConfig memory cfg2, JBTerminalConfig[] memory tc2, REVSuckerDeploymentConfig memory sdc2) =
|
|
499
528
|
_buildMinimalConfig();
|
|
529
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
500
530
|
cfg2.description = REVDescription("NoSplit", "NS", "ipfs://nosplit", "NOSPLIT_SALT");
|
|
501
531
|
|
|
502
|
-
uint256 revnetId2 = REV_DEPLOYER.deployFor({
|
|
503
|
-
revnetId: 0,
|
|
532
|
+
(uint256 revnetId2,) = REV_DEPLOYER.deployFor({
|
|
533
|
+
revnetId: 0,
|
|
534
|
+
configuration: cfg2,
|
|
535
|
+
terminalConfigurations: tc2,
|
|
536
|
+
suckerDeploymentConfiguration: sdc2,
|
|
537
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
538
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
504
539
|
});
|
|
505
540
|
|
|
506
541
|
vm.prank(PAYER);
|
|
@@ -1,14 +1,23 @@
|
|
|
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";
|
|
8
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
6
9
|
import /* {*} from */ "./../src/REVDeployer.sol";
|
|
10
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
7
11
|
import "@croptop/core-v6/src/CTPublisher.sol";
|
|
12
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
8
13
|
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
14
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
9
15
|
import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
|
|
16
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
10
17
|
import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
|
|
18
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
11
19
|
import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
|
|
20
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
12
21
|
import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
|
|
13
22
|
|
|
14
23
|
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
@@ -16,7 +25,6 @@ import {JBMetadataResolver} from "@bananapus/core-v6/src/libraries/JBMetadataRes
|
|
|
16
25
|
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
17
26
|
import {REVLoans} from "../src/REVLoans.sol";
|
|
18
27
|
import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
|
|
19
|
-
import {REVLoanSource} from "../src/structs/REVLoanSource.sol";
|
|
20
28
|
import {REVDescription} from "../src/structs/REVDescription.sol";
|
|
21
29
|
import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
|
|
22
30
|
import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
|
|
@@ -28,7 +36,6 @@ import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressReg
|
|
|
28
36
|
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
29
37
|
import {IJBRulesetDataHook} from "@bananapus/core-v6/src/interfaces/IJBRulesetDataHook.sol";
|
|
30
38
|
import {IJBBuybackHookRegistry} from "@bananapus/buyback-hook-v6/src/interfaces/IJBBuybackHookRegistry.sol";
|
|
31
|
-
import {IJBPayHook} from "@bananapus/core-v6/src/interfaces/IJBPayHook.sol";
|
|
32
39
|
import {REVBaseline721HookConfig} from "../src/structs/REVBaseline721HookConfig.sol";
|
|
33
40
|
import {REV721TiersHookFlags} from "../src/structs/REV721TiersHookFlags.sol";
|
|
34
41
|
import {JB721TierConfig} from "@bananapus/721-hook-v6/src/structs/JB721TierConfig.sol";
|
|
@@ -36,11 +43,11 @@ import {JB721InitTiersConfig} from "@bananapus/721-hook-v6/src/structs/JB721Init
|
|
|
36
43
|
import {IJB721TokenUriResolver} from "@bananapus/721-hook-v6/src/interfaces/IJB721TokenUriResolver.sol";
|
|
37
44
|
import {REVDeploy721TiersHookConfig} from "../src/structs/REVDeploy721TiersHookConfig.sol";
|
|
38
45
|
import {REVCroptopAllowedPost} from "../src/structs/REVCroptopAllowedPost.sol";
|
|
46
|
+
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
39
47
|
|
|
40
48
|
// Buyback hook
|
|
41
49
|
import {JBBuybackHook} from "@bananapus/buyback-hook-v6/src/JBBuybackHook.sol";
|
|
42
50
|
import {JBBuybackHookRegistry} from "@bananapus/buyback-hook-v6/src/JBBuybackHookRegistry.sol";
|
|
43
|
-
import {IJBBuybackHook} from "@bananapus/buyback-hook-v6/src/interfaces/IJBBuybackHook.sol";
|
|
44
51
|
import {IGeomeanOracle} from "@bananapus/buyback-hook-v6/src/interfaces/IGeomeanOracle.sol";
|
|
45
52
|
|
|
46
53
|
// Uniswap V4
|
|
@@ -48,7 +55,7 @@ import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
|
|
|
48
55
|
import {IUnlockCallback} from "@uniswap/v4-core/src/interfaces/callback/IUnlockCallback.sol";
|
|
49
56
|
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
|
|
50
57
|
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
|
|
51
|
-
import {
|
|
58
|
+
import {PoolIdLibrary} from "@uniswap/v4-core/src/types/PoolId.sol";
|
|
52
59
|
import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol";
|
|
53
60
|
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";
|
|
54
61
|
import {ModifyLiquidityParams, SwapParams} from "@uniswap/v4-core/src/types/PoolOperation.sol";
|
|
@@ -59,6 +66,7 @@ import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
|
|
|
59
66
|
|
|
60
67
|
/// @notice Helper that adds liquidity to and swaps on a V4 pool via the unlock/callback pattern.
|
|
61
68
|
contract LiquidityHelper is IUnlockCallback {
|
|
69
|
+
// forge-lint: disable-next-line(screaming-snake-case-immutable)
|
|
62
70
|
IPoolManager public immutable poolManager;
|
|
63
71
|
|
|
64
72
|
enum Action {
|
|
@@ -94,7 +102,8 @@ contract LiquidityHelper is IUnlockCallback {
|
|
|
94
102
|
payable
|
|
95
103
|
{
|
|
96
104
|
bytes memory data =
|
|
97
|
-
|
|
105
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
106
|
+
abi.encode(Action.ADD_LIQUIDITY, abi.encode(AddLiqParams(key, tickLower, tickUpper, liquidityDelta)));
|
|
98
107
|
poolManager.unlock(data);
|
|
99
108
|
}
|
|
100
109
|
|
|
@@ -108,7 +117,8 @@ contract LiquidityHelper is IUnlockCallback {
|
|
|
108
117
|
payable
|
|
109
118
|
{
|
|
110
119
|
bytes memory data =
|
|
111
|
-
|
|
120
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
121
|
+
abi.encode(Action.SWAP, abi.encode(DoSwapParams(key, zeroForOne, amountSpecified, sqrtPriceLimitX96)));
|
|
112
122
|
poolManager.unlock(data);
|
|
113
123
|
}
|
|
114
124
|
|
|
@@ -150,7 +160,11 @@ contract LiquidityHelper is IUnlockCallback {
|
|
|
150
160
|
DoSwapParams memory params = abi.decode(data, (DoSwapParams));
|
|
151
161
|
|
|
152
162
|
BalanceDelta delta = poolManager.swap(
|
|
153
|
-
|
|
163
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
164
|
+
params.key,
|
|
165
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
166
|
+
SwapParams(params.zeroForOne, params.amountSpecified, params.sqrtPriceLimitX96),
|
|
167
|
+
""
|
|
154
168
|
);
|
|
155
169
|
|
|
156
170
|
// Settle (pay) what we owe, take what we're owed.
|
|
@@ -170,12 +184,14 @@ contract LiquidityHelper is IUnlockCallback {
|
|
|
170
184
|
|
|
171
185
|
function _settleIfNegative(Currency currency, int128 delta) internal {
|
|
172
186
|
if (delta >= 0) return;
|
|
187
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
173
188
|
uint256 amount = uint256(uint128(-delta));
|
|
174
189
|
|
|
175
190
|
if (currency.isAddressZero()) {
|
|
176
191
|
poolManager.settle{value: amount}();
|
|
177
192
|
} else {
|
|
178
193
|
poolManager.sync(currency);
|
|
194
|
+
// forge-lint: disable-next-line(erc20-unchecked-transfer)
|
|
179
195
|
IERC20(Currency.unwrap(currency)).transfer(address(poolManager), amount);
|
|
180
196
|
poolManager.settle();
|
|
181
197
|
}
|
|
@@ -183,6 +199,7 @@ contract LiquidityHelper is IUnlockCallback {
|
|
|
183
199
|
|
|
184
200
|
function _takeIfPositive(Currency currency, int128 delta) internal {
|
|
185
201
|
if (delta <= 0) return;
|
|
202
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
186
203
|
uint256 amount = uint256(uint128(delta));
|
|
187
204
|
poolManager.take(currency, address(this), amount);
|
|
188
205
|
}
|
|
@@ -214,23 +231,36 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
214
231
|
// ───────────────────────── State
|
|
215
232
|
// ─────────────────────────
|
|
216
233
|
|
|
234
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
217
235
|
REVDeployer REV_DEPLOYER;
|
|
236
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
218
237
|
JBBuybackHook BUYBACK_HOOK;
|
|
238
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
219
239
|
JBBuybackHookRegistry BUYBACK_REGISTRY;
|
|
240
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
220
241
|
JB721TiersHook EXAMPLE_HOOK;
|
|
242
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
221
243
|
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
244
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
222
245
|
IJB721TiersHookStore HOOK_STORE;
|
|
246
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
223
247
|
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
248
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
224
249
|
IREVLoans LOANS_CONTRACT;
|
|
250
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
225
251
|
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
252
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
226
253
|
CTPublisher PUBLISHER;
|
|
227
254
|
IPoolManager poolManager;
|
|
228
255
|
LiquidityHelper liqHelper;
|
|
229
256
|
|
|
257
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
230
258
|
uint256 FEE_PROJECT_ID;
|
|
231
259
|
|
|
232
260
|
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
261
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
233
262
|
address PAYER = makeAddr("payer");
|
|
263
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
234
264
|
address SPLIT_BENEFICIARY = makeAddr("splitBeneficiary");
|
|
235
265
|
|
|
236
266
|
// Tier configuration: 1 ETH tier with 30% split.
|
|
@@ -258,8 +288,9 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
258
288
|
|
|
259
289
|
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
260
290
|
HOOK_STORE = new JB721TiersHookStore();
|
|
261
|
-
EXAMPLE_HOOK =
|
|
262
|
-
|
|
291
|
+
EXAMPLE_HOOK = new JB721TiersHook(
|
|
292
|
+
jbDirectory(), jbPermissions(), jbPrices(), jbRulesets(), HOOK_STORE, jbSplits(), multisig()
|
|
293
|
+
);
|
|
263
294
|
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
264
295
|
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
265
296
|
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
@@ -344,6 +375,7 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
344
375
|
});
|
|
345
376
|
|
|
346
377
|
cfg = REVConfig({
|
|
378
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
347
379
|
description: REVDescription("Fork Test", "FORK", "ipfs://fork", "FORK_SALT"),
|
|
348
380
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
349
381
|
splitOperator: multisig(),
|
|
@@ -373,6 +405,7 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
373
405
|
votingUnits: 0,
|
|
374
406
|
reserveFrequency: 0,
|
|
375
407
|
reserveBeneficiary: address(0),
|
|
408
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
376
409
|
encodedIPFSUri: bytes32("tier1"),
|
|
377
410
|
category: 1,
|
|
378
411
|
discountPercent: 0,
|
|
@@ -394,10 +427,7 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
394
427
|
tokenUriResolver: IJB721TokenUriResolver(address(0)),
|
|
395
428
|
contractUri: "ipfs://contract",
|
|
396
429
|
tiersConfig: JB721InitTiersConfig({
|
|
397
|
-
tiers: tiers,
|
|
398
|
-
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
399
|
-
decimals: 18,
|
|
400
|
-
prices: IJBPrices(address(0))
|
|
430
|
+
tiers: tiers, currency: uint32(uint160(JBConstants.NATIVE_TOKEN)), decimals: 18
|
|
401
431
|
}),
|
|
402
432
|
reserveBeneficiary: address(0),
|
|
403
433
|
flags: REV721TiersHookFlags({
|
|
@@ -407,11 +437,12 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
407
437
|
preventOverspending: false
|
|
408
438
|
})
|
|
409
439
|
}),
|
|
440
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
410
441
|
salt: bytes32("FORK_721"),
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
442
|
+
preventSplitOperatorAdjustingTiers: false,
|
|
443
|
+
preventSplitOperatorUpdatingMetadata: false,
|
|
444
|
+
preventSplitOperatorMinting: false,
|
|
445
|
+
preventSplitOperatorIncreasingDiscountPercent: false
|
|
415
446
|
});
|
|
416
447
|
}
|
|
417
448
|
|
|
@@ -420,6 +451,7 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
420
451
|
// Deploy fee project first.
|
|
421
452
|
(REVConfig memory feeCfg, JBTerminalConfig[] memory feeTc, REVSuckerDeploymentConfig memory feeSdc) =
|
|
422
453
|
_buildMinimalConfig();
|
|
454
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
423
455
|
feeCfg.description = REVDescription("Fee", "FEE", "ipfs://fee", "FEE_SALT");
|
|
424
456
|
|
|
425
457
|
vm.prank(multisig());
|
|
@@ -427,7 +459,9 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
427
459
|
revnetId: FEE_PROJECT_ID,
|
|
428
460
|
configuration: feeCfg,
|
|
429
461
|
terminalConfigurations: feeTc,
|
|
430
|
-
suckerDeploymentConfiguration: feeSdc
|
|
462
|
+
suckerDeploymentConfiguration: feeSdc,
|
|
463
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
464
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
431
465
|
});
|
|
432
466
|
|
|
433
467
|
// Deploy the revnet with 721 hook.
|
|
@@ -435,7 +469,7 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
435
469
|
_buildMinimalConfig();
|
|
436
470
|
REVDeploy721TiersHookConfig memory hookConfig = _build721Config();
|
|
437
471
|
|
|
438
|
-
(revnetId, hook) = REV_DEPLOYER.
|
|
472
|
+
(revnetId, hook) = REV_DEPLOYER.deployFor({
|
|
439
473
|
revnetId: 0,
|
|
440
474
|
configuration: cfg,
|
|
441
475
|
terminalConfigurations: tc,
|
|
@@ -477,6 +511,7 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
477
511
|
vm.stopPrank();
|
|
478
512
|
|
|
479
513
|
// Add full-range liquidity.
|
|
514
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
480
515
|
int256 liquidityDelta = int256(liquidityTokenAmount / 2);
|
|
481
516
|
vm.prank(address(liqHelper));
|
|
482
517
|
liqHelper.addLiquidity{value: liquidityTokenAmount}(key, TICK_LOWER, TICK_UPPER, liquidityDelta);
|
|
@@ -496,12 +531,14 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
496
531
|
int56[] memory tickCumulatives = new int56[](2);
|
|
497
532
|
tickCumulatives[0] = 0;
|
|
498
533
|
// arithmeticMeanTick = (tickCumulatives[1] - tickCumulatives[0]) / twapWindow = tick
|
|
534
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
499
535
|
tickCumulatives[1] = int56(tick) * int56(int32(twapWindow));
|
|
500
536
|
|
|
501
537
|
uint136[] memory secondsPerLiquidityCumulativeX128s = new uint136[](2);
|
|
502
538
|
secondsPerLiquidityCumulativeX128s[0] = 0;
|
|
503
539
|
uint256 liq = uint256(liquidity > 0 ? liquidity : -liquidity);
|
|
504
540
|
if (liq == 0) liq = 1;
|
|
541
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
505
542
|
secondsPerLiquidityCumulativeX128s[1] = uint136((uint256(twapWindow) << 128) / liq);
|
|
506
543
|
|
|
507
544
|
vm.mockCall(
|
|
@@ -597,6 +634,7 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
597
634
|
vm.stopPrank();
|
|
598
635
|
|
|
599
636
|
// Add full-range liquidity at tick 0 (1:1 price).
|
|
637
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
600
638
|
int256 liquidityDelta = int256(ethLiq / 4);
|
|
601
639
|
vm.prank(address(liqHelper));
|
|
602
640
|
liqHelper.addLiquidity{value: ethLiq}(key, TICK_LOWER, TICK_UPPER, liquidityDelta);
|
|
@@ -614,6 +652,7 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
614
652
|
uint160 sqrtPriceLimit = TickMath.getSqrtPriceAtTick(76_000);
|
|
615
653
|
|
|
616
654
|
vm.prank(address(liqHelper));
|
|
655
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
617
656
|
liqHelper.swap(key, zeroForOne, -int256(swapAmount), sqrtPriceLimit);
|
|
618
657
|
|
|
619
658
|
// Read the post-swap tick for the oracle mock.
|
|
@@ -746,10 +785,16 @@ contract TestSplitWeightFork is TestBaseWorkflow {
|
|
|
746
785
|
// Deploy a second revnet without 721 hook.
|
|
747
786
|
(REVConfig memory cfg2, JBTerminalConfig[] memory tc2, REVSuckerDeploymentConfig memory sdc2) =
|
|
748
787
|
_buildMinimalConfig();
|
|
788
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
749
789
|
cfg2.description = REVDescription("NoSplit Fork", "NSF", "ipfs://nosplit", "NSF_SALT");
|
|
750
790
|
|
|
751
|
-
uint256 revnetId2 = REV_DEPLOYER.deployFor({
|
|
752
|
-
revnetId: 0,
|
|
791
|
+
(uint256 revnetId2,) = REV_DEPLOYER.deployFor({
|
|
792
|
+
revnetId: 0,
|
|
793
|
+
configuration: cfg2,
|
|
794
|
+
terminalConfigurations: tc2,
|
|
795
|
+
suckerDeploymentConfiguration: sdc2,
|
|
796
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
797
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
753
798
|
});
|
|
754
799
|
|
|
755
800
|
// Set up pool for revnet2 too (so buyback hook has a pool, but will choose mint at 1:1).
|
|
@@ -1,21 +1,29 @@
|
|
|
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";
|
|
8
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
6
9
|
import /* {*} from */ "./../src/REVDeployer.sol";
|
|
10
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
7
11
|
import "@croptop/core-v6/src/CTPublisher.sol";
|
|
8
12
|
import {MockBuybackDataHook} from "./mock/MockBuybackDataHook.sol";
|
|
13
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
9
14
|
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
15
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
10
16
|
import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
|
|
17
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
11
18
|
import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
|
|
19
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
12
20
|
import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
|
|
21
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
13
22
|
import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
|
|
14
23
|
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
15
24
|
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
16
25
|
import {REVLoans} from "../src/REVLoans.sol";
|
|
17
26
|
import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
|
|
18
|
-
import {REVLoanSource} from "../src/structs/REVLoanSource.sol";
|
|
19
27
|
import {REVDescription} from "../src/structs/REVDescription.sol";
|
|
20
28
|
import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
|
|
21
29
|
import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
|
|
@@ -25,26 +33,40 @@ import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
|
|
|
25
33
|
import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
|
|
26
34
|
import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
|
|
27
35
|
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
36
|
+
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
28
37
|
|
|
29
38
|
/// @notice Documents and verifies that stage transitions change the borrowable amount for the same collateral.
|
|
30
39
|
/// This is by design: loan value tracks the current bonding curve parameters (cashOutTaxRate),
|
|
31
40
|
/// just as cash-out value does.
|
|
32
41
|
contract TestStageTransitionBorrowable is TestBaseWorkflow {
|
|
42
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
33
43
|
bytes32 REV_DEPLOYER_SALT = "REVDeployer";
|
|
34
44
|
|
|
45
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
35
46
|
REVDeployer REV_DEPLOYER;
|
|
47
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
36
48
|
JB721TiersHook EXAMPLE_HOOK;
|
|
49
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
37
50
|
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
51
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
38
52
|
IJB721TiersHookStore HOOK_STORE;
|
|
53
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
39
54
|
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
55
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
40
56
|
IREVLoans LOANS_CONTRACT;
|
|
57
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
41
58
|
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
59
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
42
60
|
CTPublisher PUBLISHER;
|
|
61
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
43
62
|
MockBuybackDataHook MOCK_BUYBACK;
|
|
44
63
|
|
|
64
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
45
65
|
uint256 FEE_PROJECT_ID;
|
|
66
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
46
67
|
uint256 REVNET_ID;
|
|
47
68
|
|
|
69
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
48
70
|
address USER = makeAddr("user");
|
|
49
71
|
|
|
50
72
|
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
@@ -94,6 +116,7 @@ contract TestStageTransitionBorrowable is TestBaseWorkflow {
|
|
|
94
116
|
});
|
|
95
117
|
|
|
96
118
|
cfg = REVConfig({
|
|
119
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
97
120
|
description: REVDescription("StageTest", "STG", "ipfs://test", "STG_SALT"),
|
|
98
121
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
99
122
|
splitOperator: multisig(),
|
|
@@ -110,8 +133,9 @@ contract TestStageTransitionBorrowable is TestBaseWorkflow {
|
|
|
110
133
|
FEE_PROJECT_ID = jbProjects().createFor(multisig());
|
|
111
134
|
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
112
135
|
HOOK_STORE = new JB721TiersHookStore();
|
|
113
|
-
EXAMPLE_HOOK =
|
|
114
|
-
|
|
136
|
+
EXAMPLE_HOOK = new JB721TiersHook(
|
|
137
|
+
jbDirectory(), jbPermissions(), jbPrices(), jbRulesets(), HOOK_STORE, jbSplits(), multisig()
|
|
138
|
+
);
|
|
115
139
|
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
116
140
|
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
117
141
|
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
@@ -145,14 +169,22 @@ contract TestStageTransitionBorrowable is TestBaseWorkflow {
|
|
|
145
169
|
revnetId: FEE_PROJECT_ID,
|
|
146
170
|
configuration: feeCfg,
|
|
147
171
|
terminalConfigurations: feeTc,
|
|
148
|
-
suckerDeploymentConfiguration: feeSdc
|
|
172
|
+
suckerDeploymentConfiguration: feeSdc,
|
|
173
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
174
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
149
175
|
});
|
|
150
176
|
|
|
151
177
|
// Deploy the test revnet.
|
|
152
178
|
(REVConfig memory cfg, JBTerminalConfig[] memory tc, REVSuckerDeploymentConfig memory sdc) = _buildConfig();
|
|
179
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
153
180
|
cfg.description = REVDescription("StageTest2", "ST2", "ipfs://test2", "STG_SALT_2");
|
|
154
|
-
REVNET_ID = REV_DEPLOYER.deployFor({
|
|
155
|
-
revnetId: 0,
|
|
181
|
+
(REVNET_ID,) = REV_DEPLOYER.deployFor({
|
|
182
|
+
revnetId: 0,
|
|
183
|
+
configuration: cfg,
|
|
184
|
+
terminalConfigurations: tc,
|
|
185
|
+
suckerDeploymentConfiguration: sdc,
|
|
186
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
187
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
156
188
|
});
|
|
157
189
|
|
|
158
190
|
vm.deal(USER, 100 ether);
|