@rev-net/core-v6 0.0.36 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +6 -7
- package/foundry.toml +1 -1
- package/package.json +23 -16
- package/references/operations.md +1 -1
- package/references/runtime.md +1 -1
- package/script/Deploy.s.sol +12 -9
- package/src/REVDeployer.sol +60 -65
- package/src/REVHiddenTokens.sol +2 -2
- package/src/REVLoans.sol +134 -90
- package/src/REVOwner.sol +124 -17
- package/src/interfaces/IREVDeployer.sol +2 -1
- package/src/interfaces/IREVHiddenTokens.sol +4 -1
- package/src/interfaces/IREVOwner.sol +5 -0
- package/ADMINISTRATION.md +0 -73
- package/ARCHITECTURE.md +0 -116
- package/AUDIT_INSTRUCTIONS.md +0 -90
- package/RISKS.md +0 -97
- package/SKILLS.md +0 -46
- package/STYLE_GUIDE.md +0 -610
- package/USER_JOURNEYS.md +0 -195
- package/foundry.lock +0 -11
- package/slither-ci.config.json +0 -10
- package/sphinx.lock +0 -507
- package/test/REV.integrations.t.sol +0 -573
- package/test/REVAutoIssuanceFuzz.t.sol +0 -328
- package/test/REVDeployerRegressions.t.sol +0 -396
- package/test/REVInvincibility.t.sol +0 -1371
- package/test/REVInvincibilityHandler.sol +0 -387
- package/test/REVLifecycle.t.sol +0 -420
- package/test/REVLoans.invariants.t.sol +0 -724
- package/test/REVLoansAttacks.t.sol +0 -816
- package/test/REVLoansFeeRecovery.t.sol +0 -783
- package/test/REVLoansFindings.t.sol +0 -711
- package/test/REVLoansRegressions.t.sol +0 -364
- package/test/REVLoansSourceFeeRecovery.t.sol +0 -517
- package/test/REVLoansSourced.t.sol +0 -1839
- package/test/REVLoansUnSourced.t.sol +0 -409
- package/test/TestAuditFixVerification.t.sol +0 -675
- package/test/TestBurnHeldTokens.t.sol +0 -394
- package/test/TestCEIPattern.t.sol +0 -508
- package/test/TestCashOutCallerValidation.t.sol +0 -452
- package/test/TestConversionDocumentation.t.sol +0 -368
- package/test/TestCrossCurrencyReclaim.t.sol +0 -610
- package/test/TestCrossSourceReallocation.t.sol +0 -361
- package/test/TestERC2771MetaTx.t.sol +0 -585
- package/test/TestEmptyBuybackSpecs.t.sol +0 -300
- package/test/TestFlashLoanSurplus.t.sol +0 -365
- package/test/TestHiddenTokens.t.sol +0 -474
- package/test/TestHookArrayOOB.t.sol +0 -278
- package/test/TestLiquidationBehavior.t.sol +0 -398
- package/test/TestLoanSourceRotation.t.sol +0 -553
- package/test/TestLoansCashOutDelay.t.sol +0 -493
- package/test/TestLongTailEconomics.t.sol +0 -677
- package/test/TestLowFindings.t.sol +0 -677
- package/test/TestMixedFixes.t.sol +0 -593
- package/test/TestPermit2Signatures.t.sol +0 -683
- package/test/TestReallocationSandwich.t.sol +0 -412
- package/test/TestRevnetRegressions.t.sol +0 -350
- package/test/TestSplitWeightAdjustment.t.sol +0 -527
- package/test/TestSplitWeightE2E.t.sol +0 -605
- package/test/TestSplitWeightFork.t.sol +0 -855
- package/test/TestStageTransitionBorrowable.t.sol +0 -301
- package/test/TestSwapTerminalPermission.t.sol +0 -262
- package/test/TestTerminalEncodingInHash.t.sol +0 -326
- package/test/TestUint112Overflow.t.sol +0 -311
- package/test/TestZeroAmountLoanGuard.t.sol +0 -378
- package/test/TestZeroRepayment.t.sol +0 -354
- package/test/audit/CodexCrossChainBuybackRouteMismatch.t.sol +0 -184
- package/test/audit/CodexPhantomSurplusTerminal.t.sol +0 -367
- package/test/audit/CodexREVOwnerRemoteSurplusCurrencyMismatch.t.sol +0 -142
- package/test/audit/LoanIdOverflowGuard.t.sol +0 -523
- package/test/audit/NemesisOperatorDelegation.t.sol +0 -356
- package/test/audit/SupportsInterfaceTest.t.sol +0 -51
- package/test/audit/TestFeeAllowanceLeak.t.sol +0 -197
- package/test/audit/TestLoansAndDeployerFixes.t.sol +0 -576
- package/test/fork/ForkTestBase.sol +0 -727
- package/test/fork/TestAutoIssuanceFork.t.sol +0 -148
- package/test/fork/TestCashOutFork.t.sol +0 -253
- package/test/fork/TestIssuanceDecayFork.t.sol +0 -158
- package/test/fork/TestLoanBorrowFork.t.sol +0 -163
- package/test/fork/TestLoanCrossRulesetFork.t.sol +0 -308
- package/test/fork/TestLoanERC20Fork.t.sol +0 -465
- package/test/fork/TestLoanLiquidationFork.t.sol +0 -135
- package/test/fork/TestLoanReallocateFork.t.sol +0 -113
- package/test/fork/TestLoanRepayFork.t.sol +0 -188
- package/test/fork/TestLoanTransferFork.t.sol +0 -143
- package/test/fork/TestPermit2PaymentFork.t.sol +0 -300
- package/test/fork/TestSplitWeightFork.t.sol +0 -189
- package/test/helpers/MaliciousContracts.sol +0 -247
- package/test/helpers/REVEmpty721Config.sol +0 -45
- package/test/mock/MockBuybackCashOutRecorder.sol +0 -84
- package/test/mock/MockBuybackDataHook.sol +0 -112
- package/test/mock/MockBuybackDataHookMintPath.sol +0 -68
- package/test/mock/MockSuckerRegistry.sol +0 -17
- package/test/regression/TestBurnPermissionRequired.t.sol +0 -294
- package/test/regression/TestCashOutBuybackFeeLeak.t.sol +0 -232
- package/test/regression/TestCrossRevnetLiquidation.t.sol +0 -255
- package/test/regression/TestCumulativeLoanCounter.t.sol +0 -361
- package/test/regression/TestLiquidateGapHandling.t.sol +0 -394
- package/test/regression/TestZeroPriceFeed.t.sol +0 -422
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
5
|
-
import "forge-std/Test.sol";
|
|
6
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
7
|
-
import /* {*} from */ "@bananapus/core-v6/test/helpers/TestBaseWorkflow.sol";
|
|
8
|
-
// import /* {*} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
9
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
10
|
-
import /* {*} from */ "./../src/REVDeployer.sol";
|
|
11
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
12
|
-
import "@croptop/core-v6/src/CTPublisher.sol";
|
|
13
|
-
import {MockBuybackDataHook} from "./mock/MockBuybackDataHook.sol";
|
|
14
|
-
|
|
15
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
16
|
-
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
17
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
18
|
-
import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
|
|
19
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
20
|
-
import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
|
|
21
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
22
|
-
import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
|
|
23
|
-
// forge-lint: disable-next-line(unaliased-plain-import)
|
|
24
|
-
import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
|
|
25
|
-
|
|
26
|
-
import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
27
|
-
import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
28
|
-
import {REVLoans} from "../src/REVLoans.sol";
|
|
29
|
-
import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
|
|
30
|
-
import {REVLoanSource} from "../src/structs/REVLoanSource.sol";
|
|
31
|
-
import {REVDescription} from "../src/structs/REVDescription.sol";
|
|
32
|
-
import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
|
|
33
|
-
import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
|
|
34
|
-
import {JBSuckerRegistry} from "@bananapus/suckers-v6/src/JBSuckerRegistry.sol";
|
|
35
|
-
import {JB721TiersHookDeployer} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
36
|
-
import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
|
|
37
|
-
import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
|
|
38
|
-
import {JB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/JB721CheckpointsDeployer.sol";
|
|
39
|
-
import {IJB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/interfaces/IJB721CheckpointsDeployer.sol";
|
|
40
|
-
import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
|
|
41
|
-
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
42
|
-
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
43
|
-
import {JBRuleset} from "@bananapus/core-v6/src/structs/JBRuleset.sol";
|
|
44
|
-
import {JBPayHookSpecification} from "@bananapus/core-v6/src/structs/JBPayHookSpecification.sol";
|
|
45
|
-
import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
|
|
46
|
-
import {REVOwner} from "../src/REVOwner.sol";
|
|
47
|
-
import {IREVDeployer} from "../src/interfaces/IREVDeployer.sol";
|
|
48
|
-
import {MockSuckerRegistry} from "./mock/MockSuckerRegistry.sol";
|
|
49
|
-
|
|
50
|
-
/// @notice A fake terminal that tracks whether useAllowanceOf was called.
|
|
51
|
-
/// @dev REVLoans.borrowFrom does not validate source terminal registration.
|
|
52
|
-
contract FakeTerminal is ERC165, IJBPayoutTerminal {
|
|
53
|
-
bool public useAllowanceCalled;
|
|
54
|
-
uint256 public lastProjectId;
|
|
55
|
-
|
|
56
|
-
function useAllowanceOf(
|
|
57
|
-
uint256 projectId,
|
|
58
|
-
address,
|
|
59
|
-
uint256,
|
|
60
|
-
uint256,
|
|
61
|
-
uint256,
|
|
62
|
-
address payable,
|
|
63
|
-
address payable,
|
|
64
|
-
string calldata
|
|
65
|
-
)
|
|
66
|
-
external
|
|
67
|
-
override
|
|
68
|
-
returns (uint256)
|
|
69
|
-
{
|
|
70
|
-
useAllowanceCalled = true;
|
|
71
|
-
lastProjectId = projectId;
|
|
72
|
-
// Return 0 - no actual funds sent
|
|
73
|
-
return 0;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function accountingContextForTokenOf(uint256, address) external pure override returns (JBAccountingContext memory) {
|
|
77
|
-
return JBAccountingContext({
|
|
78
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Stub implementations for IJBTerminal
|
|
83
|
-
function accountingContextsOf(uint256) external pure override returns (JBAccountingContext[] memory) {
|
|
84
|
-
return new JBAccountingContext[](0);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function addAccountingContextsFor(uint256, JBAccountingContext[] calldata) external override {}
|
|
88
|
-
|
|
89
|
-
function addToBalanceOf(
|
|
90
|
-
uint256,
|
|
91
|
-
address,
|
|
92
|
-
uint256,
|
|
93
|
-
bool,
|
|
94
|
-
string calldata,
|
|
95
|
-
bytes calldata
|
|
96
|
-
)
|
|
97
|
-
external
|
|
98
|
-
payable
|
|
99
|
-
override
|
|
100
|
-
{}
|
|
101
|
-
|
|
102
|
-
function currentSurplusOf(uint256, address[] calldata, uint256, uint256) external pure override returns (uint256) {
|
|
103
|
-
return 0;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function migrateBalanceOf(uint256, address, IJBTerminal) external pure override returns (uint256) {
|
|
107
|
-
return 0;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function pay(
|
|
111
|
-
uint256,
|
|
112
|
-
address,
|
|
113
|
-
uint256,
|
|
114
|
-
address,
|
|
115
|
-
uint256,
|
|
116
|
-
string calldata,
|
|
117
|
-
bytes calldata
|
|
118
|
-
)
|
|
119
|
-
external
|
|
120
|
-
payable
|
|
121
|
-
override
|
|
122
|
-
returns (uint256)
|
|
123
|
-
{
|
|
124
|
-
return 0;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function sendPayoutsOf(uint256, address, uint256, uint256, uint256) external pure override returns (uint256) {
|
|
128
|
-
return 0;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function previewPayFor(
|
|
132
|
-
uint256,
|
|
133
|
-
address,
|
|
134
|
-
uint256,
|
|
135
|
-
address,
|
|
136
|
-
bytes calldata
|
|
137
|
-
)
|
|
138
|
-
external
|
|
139
|
-
pure
|
|
140
|
-
override
|
|
141
|
-
returns (JBRuleset memory, uint256, uint256, JBPayHookSpecification[] memory)
|
|
142
|
-
{
|
|
143
|
-
JBRuleset memory ruleset;
|
|
144
|
-
return (ruleset, 0, 0, new JBPayHookSpecification[](0));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
|
|
148
|
-
return interfaceId == type(IJBTerminal).interfaceId || interfaceId == type(IJBPayoutTerminal).interfaceId
|
|
149
|
-
|| super.supportsInterface(interfaceId);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/// @notice Regression tests for REVLoans unvalidated source terminal.
|
|
154
|
-
contract REVLoansRegressions is TestBaseWorkflow {
|
|
155
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
156
|
-
bytes32 REV_DEPLOYER_SALT = "REVDeployer";
|
|
157
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
158
|
-
bytes32 ERC20_SALT = "REV_TOKEN";
|
|
159
|
-
|
|
160
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
161
|
-
REVDeployer REV_DEPLOYER;
|
|
162
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
163
|
-
REVOwner REV_OWNER;
|
|
164
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
165
|
-
JB721TiersHook EXAMPLE_HOOK;
|
|
166
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
167
|
-
IJB721TiersHookDeployer HOOK_DEPLOYER;
|
|
168
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
169
|
-
IJB721TiersHookStore HOOK_STORE;
|
|
170
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
171
|
-
IJBAddressRegistry ADDRESS_REGISTRY;
|
|
172
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
173
|
-
IREVLoans LOANS_CONTRACT;
|
|
174
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
175
|
-
IJBSuckerRegistry SUCKER_REGISTRY;
|
|
176
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
177
|
-
CTPublisher PUBLISHER;
|
|
178
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
179
|
-
MockBuybackDataHook MOCK_BUYBACK;
|
|
180
|
-
|
|
181
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
182
|
-
uint256 FEE_PROJECT_ID;
|
|
183
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
184
|
-
uint256 REVNET_ID;
|
|
185
|
-
|
|
186
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
187
|
-
address USER = makeAddr("user");
|
|
188
|
-
|
|
189
|
-
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
190
|
-
|
|
191
|
-
function setUp() public override {
|
|
192
|
-
super.setUp();
|
|
193
|
-
|
|
194
|
-
FEE_PROJECT_ID = jbProjects().createFor(multisig());
|
|
195
|
-
|
|
196
|
-
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
197
|
-
HOOK_STORE = new JB721TiersHookStore();
|
|
198
|
-
EXAMPLE_HOOK = new JB721TiersHook(
|
|
199
|
-
jbDirectory(),
|
|
200
|
-
jbPermissions(),
|
|
201
|
-
jbPrices(),
|
|
202
|
-
jbRulesets(),
|
|
203
|
-
HOOK_STORE,
|
|
204
|
-
jbSplits(),
|
|
205
|
-
IJB721CheckpointsDeployer(address(new JB721CheckpointsDeployer())),
|
|
206
|
-
multisig()
|
|
207
|
-
);
|
|
208
|
-
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
209
|
-
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
210
|
-
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
211
|
-
MOCK_BUYBACK = new MockBuybackDataHook();
|
|
212
|
-
|
|
213
|
-
LOANS_CONTRACT = new REVLoans({
|
|
214
|
-
controller: jbController(),
|
|
215
|
-
suckerRegistry: IJBSuckerRegistry(address(new MockSuckerRegistry())),
|
|
216
|
-
revId: FEE_PROJECT_ID,
|
|
217
|
-
owner: address(this),
|
|
218
|
-
permit2: permit2(),
|
|
219
|
-
trustedForwarder: TRUSTED_FORWARDER
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
REV_OWNER = new REVOwner(
|
|
223
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
224
|
-
jbDirectory(),
|
|
225
|
-
FEE_PROJECT_ID,
|
|
226
|
-
SUCKER_REGISTRY,
|
|
227
|
-
address(LOANS_CONTRACT),
|
|
228
|
-
address(0)
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
REV_DEPLOYER = new REVDeployer{salt: REV_DEPLOYER_SALT}(
|
|
232
|
-
jbController(),
|
|
233
|
-
SUCKER_REGISTRY,
|
|
234
|
-
FEE_PROJECT_ID,
|
|
235
|
-
HOOK_DEPLOYER,
|
|
236
|
-
PUBLISHER,
|
|
237
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
238
|
-
address(LOANS_CONTRACT),
|
|
239
|
-
TRUSTED_FORWARDER,
|
|
240
|
-
address(REV_OWNER)
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
REV_OWNER.setDeployer(REV_DEPLOYER);
|
|
244
|
-
|
|
245
|
-
vm.prank(multisig());
|
|
246
|
-
jbProjects().approve(address(REV_DEPLOYER), FEE_PROJECT_ID);
|
|
247
|
-
|
|
248
|
-
// Deploy a revnet with loans enabled
|
|
249
|
-
_deployRevnet();
|
|
250
|
-
|
|
251
|
-
// Give user ETH
|
|
252
|
-
vm.deal(USER, 100e18);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function _deployRevnet() internal {
|
|
256
|
-
JBAccountingContext[] memory accountingContextsToAccept = new JBAccountingContext[](1);
|
|
257
|
-
accountingContextsToAccept[0] = JBAccountingContext({
|
|
258
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
|
|
262
|
-
terminalConfigurations[0] =
|
|
263
|
-
JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: accountingContextsToAccept});
|
|
264
|
-
|
|
265
|
-
REVStageConfig[] memory stageConfigurations = new REVStageConfig[](1);
|
|
266
|
-
JBSplit[] memory splits = new JBSplit[](1);
|
|
267
|
-
splits[0].beneficiary = payable(multisig());
|
|
268
|
-
splits[0].percent = 10_000;
|
|
269
|
-
|
|
270
|
-
stageConfigurations[0] = REVStageConfig({
|
|
271
|
-
startsAtOrAfter: uint40(block.timestamp),
|
|
272
|
-
autoIssuances: new REVAutoIssuance[](0),
|
|
273
|
-
splitPercent: 0,
|
|
274
|
-
splits: splits,
|
|
275
|
-
initialIssuance: uint112(1000e18),
|
|
276
|
-
issuanceCutFrequency: 0,
|
|
277
|
-
issuanceCutPercent: 0,
|
|
278
|
-
cashOutTaxRate: 5000,
|
|
279
|
-
extraMetadata: 0
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
REVConfig memory revnetConfiguration = REVConfig({
|
|
283
|
-
// forge-lint: disable-next-line(named-struct-fields)
|
|
284
|
-
description: REVDescription("H6Test", "H6T", "ipfs://h6test", "H6_TOKEN"),
|
|
285
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
286
|
-
splitOperator: multisig(),
|
|
287
|
-
stageConfigurations: stageConfigurations
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
vm.prank(multisig());
|
|
291
|
-
(REVNET_ID,) = REV_DEPLOYER.deployFor({
|
|
292
|
-
revnetId: FEE_PROJECT_ID,
|
|
293
|
-
configuration: revnetConfiguration,
|
|
294
|
-
terminalConfigurations: terminalConfigurations,
|
|
295
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
296
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("H6_TEST")
|
|
297
|
-
}),
|
|
298
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
299
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
//*********************************************************************//
|
|
304
|
-
// --- Unvalidated Source Terminal in REVLoans ---------------------- //
|
|
305
|
-
//*********************************************************************//
|
|
306
|
-
|
|
307
|
-
/// @notice Demonstrates that borrowFrom accepts any terminal without validating
|
|
308
|
-
/// it is registered in the JBDirectory for the project.
|
|
309
|
-
/// @dev The fake terminal's useAllowanceOf is called, showing no directory check occurs.
|
|
310
|
-
/// In production, a malicious terminal could return fake amounts or misroute funds.
|
|
311
|
-
/// @notice Verifies that borrowFrom now rejects unregistered terminals.
|
|
312
|
-
/// @dev Previously this test demonstrated the vulnerability. After the fix,
|
|
313
|
-
/// borrowFrom reverts with REVLoans_InvalidTerminal before reaching the fake terminal.
|
|
314
|
-
function test_unvalidatedSourceTerminal() public {
|
|
315
|
-
// Step 1: User pays into the revnet to get tokens (collateral)
|
|
316
|
-
vm.prank(USER);
|
|
317
|
-
uint256 tokens = jbMultiTerminal().pay{value: 1e18}(REVNET_ID, JBConstants.NATIVE_TOKEN, 1e18, USER, 0, "", "");
|
|
318
|
-
assertGt(tokens, 0, "user should receive tokens");
|
|
319
|
-
|
|
320
|
-
// Step 2: Create a fake terminal NOT registered in the directory
|
|
321
|
-
FakeTerminal fakeTerminal = new FakeTerminal();
|
|
322
|
-
|
|
323
|
-
// Verify the fake terminal is NOT in the directory
|
|
324
|
-
IJBTerminal[] memory registeredTerminals = jbDirectory().terminalsOf(REVNET_ID);
|
|
325
|
-
bool found = false;
|
|
326
|
-
for (uint256 i = 0; i < registeredTerminals.length; i++) {
|
|
327
|
-
if (address(registeredTerminals[i]) == address(fakeTerminal)) {
|
|
328
|
-
found = true;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
assertFalse(found, "fake terminal should NOT be in the directory");
|
|
332
|
-
|
|
333
|
-
// Step 3: Try to borrow using the fake terminal as the source.
|
|
334
|
-
// This now correctly reverts with REVLoans_InvalidTerminal.
|
|
335
|
-
REVLoanSource memory fakeSource =
|
|
336
|
-
REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: IJBPayoutTerminal(address(fakeTerminal))});
|
|
337
|
-
|
|
338
|
-
uint256 borrowable =
|
|
339
|
-
LOANS_CONTRACT.borrowableAmountFrom(REVNET_ID, tokens, 18, uint32(uint160(JBConstants.NATIVE_TOKEN)));
|
|
340
|
-
assertGt(borrowable, 0, "should have borrowable amount");
|
|
341
|
-
|
|
342
|
-
// The borrow should revert with REVLoans_InvalidTerminal because the fake terminal
|
|
343
|
-
// is not registered in the directory. The fake terminal is never called.
|
|
344
|
-
vm.expectRevert(
|
|
345
|
-
abi.encodeWithSelector(REVLoans.REVLoans_InvalidTerminal.selector, address(fakeTerminal), REVNET_ID)
|
|
346
|
-
);
|
|
347
|
-
|
|
348
|
-
vm.prank(USER);
|
|
349
|
-
LOANS_CONTRACT.borrowFrom(REVNET_ID, fakeSource, borrowable, tokens, payable(USER), 500, USER);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/// @notice Verify that the configured loan source (real terminal) is properly registered.
|
|
353
|
-
function test_configuredSourceIsRegistered() public view {
|
|
354
|
-
// The real terminal should be in the directory
|
|
355
|
-
IJBTerminal[] memory terminals = jbDirectory().terminalsOf(REVNET_ID);
|
|
356
|
-
bool found = false;
|
|
357
|
-
for (uint256 i = 0; i < terminals.length; i++) {
|
|
358
|
-
if (address(terminals[i]) == address(jbMultiTerminal())) {
|
|
359
|
-
found = true;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
assertTrue(found, "real terminal should be in the directory");
|
|
363
|
-
}
|
|
364
|
-
}
|