@rev-net/core-v6 0.0.12 → 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/AUDIT_INSTRUCTIONS.md +295 -0
- package/CHANGE_LOG.md +316 -0
- package/README.md +2 -2
- package/RISKS.md +180 -35
- package/SKILLS.md +1 -1
- package/USER_JOURNEYS.md +489 -0
- package/package.json +9 -9
- package/script/Deploy.s.sol +40 -6
- package/script/helpers/RevnetCoreDeploymentLib.sol +7 -1
- package/src/REVDeployer.sol +63 -47
- package/src/REVLoans.sol +51 -15
- package/src/interfaces/IREVDeployer.sol +0 -1
- 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 +1 -0
- 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 +132 -12
- package/test/REVAutoIssuanceFuzz.t.sol +23 -3
- package/test/REVDeployerRegressions.t.sol +35 -4
- package/test/REVInvincibility.t.sol +58 -8
- package/test/REVInvincibilityHandler.sol +29 -0
- package/test/REVLifecycle.t.sol +28 -3
- package/test/REVLoans.invariants.t.sol +52 -5
- package/test/REVLoansAttacks.t.sol +43 -5
- package/test/REVLoansFeeRecovery.t.sol +50 -11
- package/test/REVLoansFindings.t.sol +27 -3
- package/test/REVLoansRegressions.t.sol +25 -3
- package/test/REVLoansSourceFeeRecovery.t.sol +491 -0
- package/test/REVLoansSourced.t.sol +56 -7
- package/test/REVLoansUnSourced.t.sol +49 -5
- package/test/TestBurnHeldTokens.t.sol +32 -5
- package/test/TestCEIPattern.t.sol +26 -2
- package/test/TestCashOutCallerValidation.t.sol +30 -4
- package/test/TestConversionDocumentation.t.sol +26 -5
- package/test/TestCrossCurrencyReclaim.t.sol +584 -0
- package/test/TestCrossSourceReallocation.t.sol +26 -2
- package/test/TestERC2771MetaTx.t.sol +557 -0
- package/test/TestEmptyBuybackSpecs.t.sol +23 -3
- package/test/TestFlashLoanSurplus.t.sol +28 -3
- package/test/TestHookArrayOOB.t.sol +24 -4
- package/test/TestLiquidationBehavior.t.sol +26 -3
- package/test/TestLoanSourceRotation.t.sol +525 -0
- package/test/TestLongTailEconomics.t.sol +651 -0
- package/test/TestLowFindings.t.sol +65 -2
- package/test/TestMixedFixes.t.sol +28 -3
- 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 +24 -2
- package/test/TestSplitWeightE2E.t.sol +29 -2
- package/test/TestSplitWeightFork.t.sol +46 -7
- package/test/TestStageTransitionBorrowable.t.sol +24 -2
- package/test/TestSwapTerminalPermission.t.sol +23 -3
- package/test/TestUint112Overflow.t.sol +28 -2
- package/test/TestZeroRepayment.t.sol +26 -2
- package/test/fork/ForkTestBase.sol +46 -3
- package/test/fork/TestCashOutFork.t.sol +1 -1
- package/test/fork/TestLoanBorrowFork.t.sol +1 -0
- package/test/fork/TestLoanCrossRulesetFork.t.sol +3 -1
- 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 +1 -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 +27 -4
- package/test/regression/TestLiquidateGapHandling.t.sol +29 -4
- package/test/regression/TestZeroPriceFeed.t.sol +396 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.26;
|
|
3
|
+
|
|
4
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
5
|
+
import "forge-std/Test.sol";
|
|
6
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
7
|
+
import /* {*} from */ "@bananapus/core-v6/test/helpers/TestBaseWorkflow.sol";
|
|
8
|
+
// import /* {*} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
9
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
10
|
+
import /* {*} from */ "./../src/REVDeployer.sol";
|
|
11
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
12
|
+
import "@croptop/core-v6/src/CTPublisher.sol";
|
|
13
|
+
import {MockBuybackDataHook} from "./mock/MockBuybackDataHook.sol";
|
|
14
|
+
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
15
|
+
|
|
16
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
17
|
+
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
18
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
19
|
+
import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
|
|
20
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
21
|
+
import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
|
|
22
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
23
|
+
import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
|
|
24
|
+
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
25
|
+
import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
|
|
26
|
+
|
|
27
|
+
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
28
|
+
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
29
|
+
import {JBSingleAllowance} from "@bananapus/core-v6/src/structs/JBSingleAllowance.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 {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
|
|
42
|
+
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
43
|
+
|
|
44
|
+
/// @notice A test harness that exposes REVLoans internal functions for direct testing.
|
|
45
|
+
/// Used to test _totalBorrowedFrom without needing to set up a full borrow flow.
|
|
46
|
+
contract REVLoansHarness is REVLoans {
|
|
47
|
+
constructor(
|
|
48
|
+
IJBController controller,
|
|
49
|
+
IJBProjects projects,
|
|
50
|
+
uint256 revId,
|
|
51
|
+
address owner,
|
|
52
|
+
IPermit2 permit2,
|
|
53
|
+
address trustedForwarder
|
|
54
|
+
)
|
|
55
|
+
REVLoans(controller, projects, revId, owner, permit2, trustedForwarder)
|
|
56
|
+
{}
|
|
57
|
+
|
|
58
|
+
/// @notice Expose _totalBorrowedFrom for testing.
|
|
59
|
+
function exposed_totalBorrowedFrom(
|
|
60
|
+
uint256 revnetId,
|
|
61
|
+
uint256 decimals,
|
|
62
|
+
uint256 currency
|
|
63
|
+
)
|
|
64
|
+
external
|
|
65
|
+
view
|
|
66
|
+
returns (uint256)
|
|
67
|
+
{
|
|
68
|
+
return _totalBorrowedFrom(revnetId, decimals, currency);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/// @notice Set totalBorrowedFrom for testing.
|
|
72
|
+
function setTotalBorrowedFrom(
|
|
73
|
+
uint256 revnetId,
|
|
74
|
+
IJBPayoutTerminal terminal,
|
|
75
|
+
address token,
|
|
76
|
+
uint256 amount
|
|
77
|
+
)
|
|
78
|
+
external
|
|
79
|
+
{
|
|
80
|
+
totalBorrowedFrom[revnetId][terminal][token] = amount;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/// @notice Register a loan source for testing.
|
|
84
|
+
function addLoanSource(uint256 revnetId, REVLoanSource memory source) external {
|
|
85
|
+
_loanSourcesOf[revnetId].push(source);
|
|
86
|
+
isLoanSourceOf[revnetId][source.terminal][source.token] = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// @notice Regression tests for zero price feed DoS in REVLoans._totalBorrowedFrom.
|
|
91
|
+
contract TestRevnetRegressions is TestBaseWorkflow {
|
|
92
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
93
|
+
bytes32 REV_DEPLOYER_SALT = "REVDeployer";
|
|
94
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
95
|
+
bytes32 ERC20_SALT = "REV_TOKEN";
|
|
96
|
+
|
|
97
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
98
|
+
REVDeployer REV_DEPLOYER;
|
|
99
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
100
|
+
JB721TiersHook EXAMPLE_HOOK;
|
|
101
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
102
|
+
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
103
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
104
|
+
IJB721TiersHookStore HOOK_STORE;
|
|
105
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
106
|
+
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
107
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
108
|
+
REVLoansHarness LOANS_CONTRACT;
|
|
109
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
110
|
+
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
111
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
112
|
+
CTPublisher PUBLISHER;
|
|
113
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
114
|
+
MockBuybackDataHook MOCK_BUYBACK;
|
|
115
|
+
|
|
116
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
117
|
+
uint256 FEE_PROJECT_ID;
|
|
118
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
119
|
+
address USER = makeAddr("user");
|
|
120
|
+
|
|
121
|
+
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
122
|
+
|
|
123
|
+
function setUp() public override {
|
|
124
|
+
super.setUp();
|
|
125
|
+
|
|
126
|
+
FEE_PROJECT_ID = jbProjects().createFor(multisig());
|
|
127
|
+
|
|
128
|
+
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
129
|
+
HOOK_STORE = new JB721TiersHookStore();
|
|
130
|
+
EXAMPLE_HOOK = new JB721TiersHook(
|
|
131
|
+
jbDirectory(), jbPermissions(), jbPrices(), jbRulesets(), HOOK_STORE, jbSplits(), multisig()
|
|
132
|
+
);
|
|
133
|
+
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
134
|
+
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
135
|
+
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
136
|
+
MOCK_BUYBACK = new MockBuybackDataHook();
|
|
137
|
+
|
|
138
|
+
LOANS_CONTRACT = new REVLoansHarness({
|
|
139
|
+
controller: jbController(),
|
|
140
|
+
projects: jbProjects(),
|
|
141
|
+
revId: FEE_PROJECT_ID,
|
|
142
|
+
owner: address(this),
|
|
143
|
+
permit2: permit2(),
|
|
144
|
+
trustedForwarder: TRUSTED_FORWARDER
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
REV_DEPLOYER = new REVDeployer{salt: REV_DEPLOYER_SALT}(
|
|
148
|
+
jbController(),
|
|
149
|
+
SUCKER_REGISTRY,
|
|
150
|
+
FEE_PROJECT_ID,
|
|
151
|
+
HOOK_DEPLOYER,
|
|
152
|
+
PUBLISHER,
|
|
153
|
+
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
154
|
+
address(LOANS_CONTRACT),
|
|
155
|
+
TRUSTED_FORWARDER
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
vm.prank(multisig());
|
|
159
|
+
jbProjects().approve(address(REV_DEPLOYER), FEE_PROJECT_ID);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//*********************************************************************//
|
|
163
|
+
// ---- Zero price feed return causes DoS in _totalBorrowedFrom ----- //
|
|
164
|
+
//*********************************************************************//
|
|
165
|
+
|
|
166
|
+
/// @notice Demonstrates that `_totalBorrowedFrom` does not revert when
|
|
167
|
+
/// `pricePerUnitOf` returns 0 for a cross-currency loan source.
|
|
168
|
+
/// Before the fix, `mulDiv(x, y, 0)` would panic with a division-by-zero,
|
|
169
|
+
/// blocking all loan operations that aggregate cross-currency borrowed amounts.
|
|
170
|
+
function test_zeroPriceFeedSkippedInTotalBorrowed() public {
|
|
171
|
+
// Deploy the fee revnet (required by the system).
|
|
172
|
+
_deployFeeRevnet();
|
|
173
|
+
|
|
174
|
+
// Deploy a borrowable revnet.
|
|
175
|
+
uint256 revnetId = _deployBorrowableRevnet();
|
|
176
|
+
|
|
177
|
+
// Manually register a loan source with a DIFFERENT currency (fakeCurrency = 999).
|
|
178
|
+
// This simulates having an outstanding loan in a token with a different accounting currency.
|
|
179
|
+
uint32 fakeCurrency = 999;
|
|
180
|
+
address fakeToken = address(0xDEAD);
|
|
181
|
+
|
|
182
|
+
// Create a mock terminal that reports the fake accounting context.
|
|
183
|
+
// We use vm.mockCall to make the terminal report the fake currency.
|
|
184
|
+
address mockTerminal = makeAddr("mockTerminal");
|
|
185
|
+
vm.mockCall(
|
|
186
|
+
mockTerminal,
|
|
187
|
+
abi.encodeWithSelector(IJBTerminal.accountingContextForTokenOf.selector, revnetId, fakeToken),
|
|
188
|
+
abi.encode(JBAccountingContext({token: fakeToken, decimals: 18, currency: fakeCurrency}))
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
// Register the loan source and set a non-zero borrowed amount via the harness.
|
|
192
|
+
LOANS_CONTRACT.addLoanSource(
|
|
193
|
+
revnetId, REVLoanSource({token: fakeToken, terminal: IJBPayoutTerminal(mockTerminal)})
|
|
194
|
+
);
|
|
195
|
+
LOANS_CONTRACT.setTotalBorrowedFrom(revnetId, IJBPayoutTerminal(mockTerminal), fakeToken, 1e18);
|
|
196
|
+
|
|
197
|
+
// Mock PRICES.pricePerUnitOf to return 0 for the cross-currency conversion.
|
|
198
|
+
// This simulates a broken, stale, or uninitialized price feed.
|
|
199
|
+
vm.mockCall(
|
|
200
|
+
address(jbPrices()),
|
|
201
|
+
abi.encodeWithSelector(
|
|
202
|
+
IJBPrices.pricePerUnitOf.selector,
|
|
203
|
+
revnetId,
|
|
204
|
+
uint256(fakeCurrency),
|
|
205
|
+
uint256(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
206
|
+
uint256(18)
|
|
207
|
+
),
|
|
208
|
+
abi.encode(uint256(0))
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
// Call _totalBorrowedFrom via the harness.
|
|
212
|
+
// Before the fix: this would panic with division-by-zero in mulDiv.
|
|
213
|
+
// After the fix: the zero-price source is skipped with `continue`.
|
|
214
|
+
uint256 totalBorrowed =
|
|
215
|
+
LOANS_CONTRACT.exposed_totalBorrowedFrom(revnetId, 18, uint32(uint160(JBConstants.NATIVE_TOKEN)));
|
|
216
|
+
|
|
217
|
+
// The source with zero price should be skipped, so the total is 0
|
|
218
|
+
// (the fake source is not counted because its price feed returned 0).
|
|
219
|
+
assertEq(totalBorrowed, 0, "_totalBorrowedFrom should return 0 when price feed returns 0, not panic");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
//*********************************************************************//
|
|
223
|
+
// ---- Helpers ------------------------------------------------------ //
|
|
224
|
+
//*********************************************************************//
|
|
225
|
+
|
|
226
|
+
function _deployFeeRevnet() internal {
|
|
227
|
+
JBAccountingContext[] memory accountingContextsToAccept = new JBAccountingContext[](1);
|
|
228
|
+
accountingContextsToAccept[0] = JBAccountingContext({
|
|
229
|
+
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
|
|
233
|
+
terminalConfigurations[0] =
|
|
234
|
+
JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: accountingContextsToAccept});
|
|
235
|
+
|
|
236
|
+
REVStageConfig[] memory stageConfigurations = new REVStageConfig[](1);
|
|
237
|
+
JBSplit[] memory splits = new JBSplit[](1);
|
|
238
|
+
splits[0].beneficiary = payable(multisig());
|
|
239
|
+
splits[0].percent = 10_000;
|
|
240
|
+
|
|
241
|
+
REVAutoIssuance[] memory issuanceConfs = new REVAutoIssuance[](1);
|
|
242
|
+
issuanceConfs[0] =
|
|
243
|
+
REVAutoIssuance({chainId: uint32(block.chainid), count: uint104(70_000e18), beneficiary: multisig()});
|
|
244
|
+
|
|
245
|
+
stageConfigurations[0] = REVStageConfig({
|
|
246
|
+
startsAtOrAfter: uint40(block.timestamp),
|
|
247
|
+
autoIssuances: issuanceConfs,
|
|
248
|
+
splitPercent: 2000,
|
|
249
|
+
splits: splits,
|
|
250
|
+
initialIssuance: uint112(1000e18),
|
|
251
|
+
issuanceCutFrequency: 90 days,
|
|
252
|
+
issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
|
|
253
|
+
cashOutTaxRate: 6000,
|
|
254
|
+
extraMetadata: 0
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
REVConfig memory revnetConfiguration = REVConfig({
|
|
258
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
259
|
+
description: REVDescription("Revnet", "$REV", "ipfs://test", ERC20_SALT),
|
|
260
|
+
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
261
|
+
splitOperator: multisig(),
|
|
262
|
+
stageConfigurations: stageConfigurations
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
vm.prank(multisig());
|
|
266
|
+
REV_DEPLOYER.deployFor({
|
|
267
|
+
revnetId: FEE_PROJECT_ID,
|
|
268
|
+
configuration: revnetConfiguration,
|
|
269
|
+
terminalConfigurations: terminalConfigurations,
|
|
270
|
+
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
271
|
+
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256(abi.encodePacked("REV"))
|
|
272
|
+
}),
|
|
273
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
274
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function _deployBorrowableRevnet() internal returns (uint256 revnetId) {
|
|
279
|
+
JBAccountingContext[] memory accountingContextsToAccept = new JBAccountingContext[](1);
|
|
280
|
+
accountingContextsToAccept[0] = JBAccountingContext({
|
|
281
|
+
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
|
|
285
|
+
terminalConfigurations[0] =
|
|
286
|
+
JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: accountingContextsToAccept});
|
|
287
|
+
|
|
288
|
+
REVStageConfig[] memory stageConfigurations = new REVStageConfig[](1);
|
|
289
|
+
JBSplit[] memory splits = new JBSplit[](1);
|
|
290
|
+
splits[0].beneficiary = payable(multisig());
|
|
291
|
+
splits[0].percent = 10_000;
|
|
292
|
+
|
|
293
|
+
stageConfigurations[0] = REVStageConfig({
|
|
294
|
+
startsAtOrAfter: uint40(block.timestamp),
|
|
295
|
+
autoIssuances: new REVAutoIssuance[](0),
|
|
296
|
+
splitPercent: 0,
|
|
297
|
+
splits: splits,
|
|
298
|
+
initialIssuance: uint112(1000e18),
|
|
299
|
+
issuanceCutFrequency: 0,
|
|
300
|
+
issuanceCutPercent: 0,
|
|
301
|
+
cashOutTaxRate: 5000,
|
|
302
|
+
extraMetadata: 0
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
REVConfig memory revnetConfiguration = REVConfig({
|
|
306
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
307
|
+
description: REVDescription("Borrowable", "BRW", "ipfs://brw", "BRW_TOKEN"),
|
|
308
|
+
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
309
|
+
splitOperator: multisig(),
|
|
310
|
+
stageConfigurations: stageConfigurations
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
(revnetId,) = REV_DEPLOYER.deployFor({
|
|
314
|
+
revnetId: 0,
|
|
315
|
+
configuration: revnetConfiguration,
|
|
316
|
+
terminalConfigurations: terminalConfigurations,
|
|
317
|
+
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
318
|
+
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256(abi.encodePacked("BRW"))
|
|
319
|
+
}),
|
|
320
|
+
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
321
|
+
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
@@ -1,22 +1,30 @@
|
|
|
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
|
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
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";
|
|
@@ -33,25 +41,36 @@ import {JBBeforePayRecordedContext} from "@bananapus/core-v6/src/structs/JBBefor
|
|
|
33
41
|
import {JBPayHookSpecification} from "@bananapus/core-v6/src/structs/JBPayHookSpecification.sol";
|
|
34
42
|
import {JBTokenAmount} from "@bananapus/core-v6/src/structs/JBTokenAmount.sol";
|
|
35
43
|
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
36
|
-
import {REVCroptopAllowedPost} from "../src/structs/REVCroptopAllowedPost.sol";
|
|
37
44
|
|
|
38
45
|
/// @notice Tests for the split weight adjustment in REVDeployer.beforePayRecordedWith.
|
|
39
46
|
contract TestSplitWeightAdjustment is TestBaseWorkflow {
|
|
47
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
40
48
|
bytes32 REV_DEPLOYER_SALT = "REVDeployer_SWA";
|
|
41
49
|
|
|
50
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
42
51
|
REVDeployer REV_DEPLOYER;
|
|
52
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
43
53
|
JB721TiersHook EXAMPLE_HOOK;
|
|
54
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
44
55
|
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
56
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
45
57
|
IJB721TiersHookStore HOOK_STORE;
|
|
58
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
46
59
|
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
60
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
47
61
|
IREVLoans LOANS_CONTRACT;
|
|
62
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
48
63
|
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
64
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
49
65
|
CTPublisher PUBLISHER;
|
|
66
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
50
67
|
MockBuybackDataHookMintPath MOCK_BUYBACK;
|
|
51
68
|
|
|
69
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
52
70
|
uint256 FEE_PROJECT_ID;
|
|
53
71
|
|
|
54
72
|
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
73
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
55
74
|
address USER = makeAddr("user");
|
|
56
75
|
|
|
57
76
|
function setUp() public override {
|
|
@@ -117,6 +136,7 @@ contract TestSplitWeightAdjustment is TestBaseWorkflow {
|
|
|
117
136
|
});
|
|
118
137
|
|
|
119
138
|
cfg = REVConfig({
|
|
139
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
120
140
|
description: REVDescription("Test", "TST", "ipfs://test", "TEST_SALT"),
|
|
121
141
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
122
142
|
splitOperator: multisig(),
|
|
@@ -145,6 +165,7 @@ contract TestSplitWeightAdjustment is TestBaseWorkflow {
|
|
|
145
165
|
// Deploy the revnet.
|
|
146
166
|
(REVConfig memory cfg, JBTerminalConfig[] memory tc, REVSuckerDeploymentConfig memory sdc) =
|
|
147
167
|
_buildMinimalConfig();
|
|
168
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
148
169
|
cfg.description = REVDescription("Test2", "TS2", "ipfs://test2", "TEST_SALT_2");
|
|
149
170
|
(revnetId,) = REV_DEPLOYER.deployFor({
|
|
150
171
|
revnetId: 0,
|
|
@@ -311,6 +332,7 @@ contract TestSplitWeightAdjustment is TestBaseWorkflow {
|
|
|
311
332
|
|
|
312
333
|
(REVConfig memory cfg, JBTerminalConfig[] memory tc, REVSuckerDeploymentConfig memory sdc) =
|
|
313
334
|
_buildMinimalConfig();
|
|
335
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
314
336
|
cfg.description = REVDescription("AMM", "AMM", "ipfs://amm", "AMM_SALT");
|
|
315
337
|
(uint256 revnetId,) = ammDeployer.deployFor({
|
|
316
338
|
revnetId: 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";
|
|
@@ -46,22 +53,35 @@ import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
|
46
53
|
contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
47
54
|
using JBMetadataResolver for bytes;
|
|
48
55
|
|
|
56
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
49
57
|
bytes32 REV_DEPLOYER_SALT = "REVDeployer_E2E";
|
|
50
58
|
|
|
59
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
51
60
|
REVDeployer REV_DEPLOYER;
|
|
61
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
52
62
|
JB721TiersHook EXAMPLE_HOOK;
|
|
63
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
53
64
|
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
65
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
54
66
|
IJB721TiersHookStore HOOK_STORE;
|
|
67
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
55
68
|
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
69
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
56
70
|
IREVLoans LOANS_CONTRACT;
|
|
71
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
57
72
|
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
73
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
58
74
|
CTPublisher PUBLISHER;
|
|
75
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
59
76
|
MockBuybackDataHookMintPath MOCK_BUYBACK_MINT;
|
|
60
77
|
|
|
78
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
61
79
|
uint256 FEE_PROJECT_ID;
|
|
62
80
|
|
|
63
81
|
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
82
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
64
83
|
address PAYER = makeAddr("payer");
|
|
84
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
65
85
|
address SPLIT_BENEFICIARY = makeAddr("splitBeneficiary");
|
|
66
86
|
|
|
67
87
|
// Tier configuration: 1 ETH tier with 30% split.
|
|
@@ -143,6 +163,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
143
163
|
});
|
|
144
164
|
|
|
145
165
|
cfg = REVConfig({
|
|
166
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
146
167
|
description: REVDescription("E2E Test", "E2E", "ipfs://e2e", "E2E_SALT"),
|
|
147
168
|
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
148
169
|
splitOperator: multisig(),
|
|
@@ -173,6 +194,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
173
194
|
votingUnits: 0,
|
|
174
195
|
reserveFrequency: 0,
|
|
175
196
|
reserveBeneficiary: address(0),
|
|
197
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
176
198
|
encodedIPFSUri: bytes32("tier1"),
|
|
177
199
|
category: 1,
|
|
178
200
|
discountPercent: 0,
|
|
@@ -204,6 +226,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
204
226
|
preventOverspending: false
|
|
205
227
|
})
|
|
206
228
|
}),
|
|
229
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
207
230
|
salt: bytes32("E2E_721"),
|
|
208
231
|
preventSplitOperatorAdjustingTiers: false,
|
|
209
232
|
preventSplitOperatorUpdatingMetadata: false,
|
|
@@ -217,6 +240,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
217
240
|
// Deploy fee project first.
|
|
218
241
|
(REVConfig memory feeCfg, JBTerminalConfig[] memory feeTc, REVSuckerDeploymentConfig memory feeSdc) =
|
|
219
242
|
_buildMinimalConfig();
|
|
243
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
220
244
|
feeCfg.description = REVDescription("Fee", "FEE", "ipfs://fee", "FEE_SALT");
|
|
221
245
|
|
|
222
246
|
vm.prank(multisig());
|
|
@@ -399,6 +423,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
399
423
|
// Deploy fee project.
|
|
400
424
|
(REVConfig memory feeCfg, JBTerminalConfig[] memory feeTc, REVSuckerDeploymentConfig memory feeSdc) =
|
|
401
425
|
_buildMinimalConfig();
|
|
426
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
402
427
|
feeCfg.description = REVDescription("Fee AMM", "FEEA", "ipfs://feeamm", "FEEA_SALT");
|
|
403
428
|
|
|
404
429
|
vm.prank(multisig());
|
|
@@ -414,6 +439,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
414
439
|
// Deploy revnet with 721 hook.
|
|
415
440
|
(REVConfig memory cfg, JBTerminalConfig[] memory tc, REVSuckerDeploymentConfig memory sdc) =
|
|
416
441
|
_buildMinimalConfig();
|
|
442
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
417
443
|
cfg.description = REVDescription("AMM E2E", "AMME", "ipfs://amme2e", "AMME_SALT");
|
|
418
444
|
REVDeploy721TiersHookConfig memory hookConfig = _build721Config();
|
|
419
445
|
|
|
@@ -500,6 +526,7 @@ contract TestSplitWeightE2E is TestBaseWorkflow {
|
|
|
500
526
|
// --- Revnet 2: no splits (plain payment, no tier metadata) ---
|
|
501
527
|
(REVConfig memory cfg2, JBTerminalConfig[] memory tc2, REVSuckerDeploymentConfig memory sdc2) =
|
|
502
528
|
_buildMinimalConfig();
|
|
529
|
+
// forge-lint: disable-next-line(named-struct-fields)
|
|
503
530
|
cfg2.description = REVDescription("NoSplit", "NS", "ipfs://nosplit", "NOSPLIT_SALT");
|
|
504
531
|
|
|
505
532
|
(uint256 revnetId2,) = REV_DEPLOYER.deployFor({
|