@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.
Files changed (101) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +6 -7
  3. package/foundry.toml +1 -1
  4. package/package.json +23 -16
  5. package/references/operations.md +1 -1
  6. package/references/runtime.md +1 -1
  7. package/script/Deploy.s.sol +12 -9
  8. package/src/REVDeployer.sol +60 -65
  9. package/src/REVHiddenTokens.sol +2 -2
  10. package/src/REVLoans.sol +134 -90
  11. package/src/REVOwner.sol +124 -17
  12. package/src/interfaces/IREVDeployer.sol +2 -1
  13. package/src/interfaces/IREVHiddenTokens.sol +4 -1
  14. package/src/interfaces/IREVOwner.sol +5 -0
  15. package/ADMINISTRATION.md +0 -73
  16. package/ARCHITECTURE.md +0 -116
  17. package/AUDIT_INSTRUCTIONS.md +0 -90
  18. package/RISKS.md +0 -97
  19. package/SKILLS.md +0 -46
  20. package/STYLE_GUIDE.md +0 -610
  21. package/USER_JOURNEYS.md +0 -195
  22. package/foundry.lock +0 -11
  23. package/slither-ci.config.json +0 -10
  24. package/sphinx.lock +0 -507
  25. package/test/REV.integrations.t.sol +0 -573
  26. package/test/REVAutoIssuanceFuzz.t.sol +0 -328
  27. package/test/REVDeployerRegressions.t.sol +0 -396
  28. package/test/REVInvincibility.t.sol +0 -1371
  29. package/test/REVInvincibilityHandler.sol +0 -387
  30. package/test/REVLifecycle.t.sol +0 -420
  31. package/test/REVLoans.invariants.t.sol +0 -724
  32. package/test/REVLoansAttacks.t.sol +0 -816
  33. package/test/REVLoansFeeRecovery.t.sol +0 -783
  34. package/test/REVLoansFindings.t.sol +0 -711
  35. package/test/REVLoansRegressions.t.sol +0 -364
  36. package/test/REVLoansSourceFeeRecovery.t.sol +0 -517
  37. package/test/REVLoansSourced.t.sol +0 -1839
  38. package/test/REVLoansUnSourced.t.sol +0 -409
  39. package/test/TestAuditFixVerification.t.sol +0 -675
  40. package/test/TestBurnHeldTokens.t.sol +0 -394
  41. package/test/TestCEIPattern.t.sol +0 -508
  42. package/test/TestCashOutCallerValidation.t.sol +0 -452
  43. package/test/TestConversionDocumentation.t.sol +0 -368
  44. package/test/TestCrossCurrencyReclaim.t.sol +0 -610
  45. package/test/TestCrossSourceReallocation.t.sol +0 -361
  46. package/test/TestERC2771MetaTx.t.sol +0 -585
  47. package/test/TestEmptyBuybackSpecs.t.sol +0 -300
  48. package/test/TestFlashLoanSurplus.t.sol +0 -365
  49. package/test/TestHiddenTokens.t.sol +0 -474
  50. package/test/TestHookArrayOOB.t.sol +0 -278
  51. package/test/TestLiquidationBehavior.t.sol +0 -398
  52. package/test/TestLoanSourceRotation.t.sol +0 -553
  53. package/test/TestLoansCashOutDelay.t.sol +0 -493
  54. package/test/TestLongTailEconomics.t.sol +0 -677
  55. package/test/TestLowFindings.t.sol +0 -677
  56. package/test/TestMixedFixes.t.sol +0 -593
  57. package/test/TestPermit2Signatures.t.sol +0 -683
  58. package/test/TestReallocationSandwich.t.sol +0 -412
  59. package/test/TestRevnetRegressions.t.sol +0 -350
  60. package/test/TestSplitWeightAdjustment.t.sol +0 -527
  61. package/test/TestSplitWeightE2E.t.sol +0 -605
  62. package/test/TestSplitWeightFork.t.sol +0 -855
  63. package/test/TestStageTransitionBorrowable.t.sol +0 -301
  64. package/test/TestSwapTerminalPermission.t.sol +0 -262
  65. package/test/TestTerminalEncodingInHash.t.sol +0 -326
  66. package/test/TestUint112Overflow.t.sol +0 -311
  67. package/test/TestZeroAmountLoanGuard.t.sol +0 -378
  68. package/test/TestZeroRepayment.t.sol +0 -354
  69. package/test/audit/CodexCrossChainBuybackRouteMismatch.t.sol +0 -184
  70. package/test/audit/CodexPhantomSurplusTerminal.t.sol +0 -367
  71. package/test/audit/CodexREVOwnerRemoteSurplusCurrencyMismatch.t.sol +0 -142
  72. package/test/audit/LoanIdOverflowGuard.t.sol +0 -523
  73. package/test/audit/NemesisOperatorDelegation.t.sol +0 -356
  74. package/test/audit/SupportsInterfaceTest.t.sol +0 -51
  75. package/test/audit/TestFeeAllowanceLeak.t.sol +0 -197
  76. package/test/audit/TestLoansAndDeployerFixes.t.sol +0 -576
  77. package/test/fork/ForkTestBase.sol +0 -727
  78. package/test/fork/TestAutoIssuanceFork.t.sol +0 -148
  79. package/test/fork/TestCashOutFork.t.sol +0 -253
  80. package/test/fork/TestIssuanceDecayFork.t.sol +0 -158
  81. package/test/fork/TestLoanBorrowFork.t.sol +0 -163
  82. package/test/fork/TestLoanCrossRulesetFork.t.sol +0 -308
  83. package/test/fork/TestLoanERC20Fork.t.sol +0 -465
  84. package/test/fork/TestLoanLiquidationFork.t.sol +0 -135
  85. package/test/fork/TestLoanReallocateFork.t.sol +0 -113
  86. package/test/fork/TestLoanRepayFork.t.sol +0 -188
  87. package/test/fork/TestLoanTransferFork.t.sol +0 -143
  88. package/test/fork/TestPermit2PaymentFork.t.sol +0 -300
  89. package/test/fork/TestSplitWeightFork.t.sol +0 -189
  90. package/test/helpers/MaliciousContracts.sol +0 -247
  91. package/test/helpers/REVEmpty721Config.sol +0 -45
  92. package/test/mock/MockBuybackCashOutRecorder.sol +0 -84
  93. package/test/mock/MockBuybackDataHook.sol +0 -112
  94. package/test/mock/MockBuybackDataHookMintPath.sol +0 -68
  95. package/test/mock/MockSuckerRegistry.sol +0 -17
  96. package/test/regression/TestBurnPermissionRequired.t.sol +0 -294
  97. package/test/regression/TestCashOutBuybackFeeLeak.t.sol +0 -232
  98. package/test/regression/TestCrossRevnetLiquidation.t.sol +0 -255
  99. package/test/regression/TestCumulativeLoanCounter.t.sol +0 -361
  100. package/test/regression/TestLiquidateGapHandling.t.sol +0 -394
  101. package/test/regression/TestZeroPriceFeed.t.sol +0 -422
@@ -1,409 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- // forge-lint: disable-next-line(unaliased-plain-import)
5
- import "forge-std/Test.sol";
6
- // forge-lint: disable-next-line(unaliased-plain-import)
7
- import /* {*} from */ "@bananapus/core-v6/test/helpers/TestBaseWorkflow.sol";
8
- // import /* {*} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
9
- // forge-lint: disable-next-line(unaliased-plain-import)
10
- import /* {*} from */ "./../src/REVDeployer.sol";
11
- // forge-lint: disable-next-line(unaliased-plain-import)
12
- import "@croptop/core-v6/src/CTPublisher.sol";
13
- import {MockBuybackDataHook} from "./mock/MockBuybackDataHook.sol";
14
- import {REVEmpty721Config} from "./helpers/REVEmpty721Config.sol";
15
-
16
- // forge-lint: disable-next-line(unaliased-plain-import)
17
- import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
18
- // forge-lint: disable-next-line(unaliased-plain-import)
19
- import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
20
- // forge-lint: disable-next-line(unaliased-plain-import)
21
- import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
22
- // forge-lint: disable-next-line(unaliased-plain-import)
23
- import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
24
- // forge-lint: disable-next-line(unaliased-plain-import)
25
- import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
26
-
27
- import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
28
- import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
29
- import {REVLoans} from "../src/REVLoans.sol";
30
- import {REVStageConfig, REVAutoIssuance} from "../src/structs/REVStageConfig.sol";
31
- import {REVLoanSource} from "../src/structs/REVLoanSource.sol";
32
- import {REVDescription} from "../src/structs/REVDescription.sol";
33
- import {IREVLoans} from "./../src/interfaces/IREVLoans.sol";
34
- import {JBPermissioned} from "@bananapus/core-v6/src/abstract/JBPermissioned.sol";
35
- import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
36
- import {JBSuckerDeployerConfig} from "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
37
- import {JBSuckerRegistry} from "@bananapus/suckers-v6/src/JBSuckerRegistry.sol";
38
- import {JB721TiersHookDeployer} from "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
39
- import {JB721TiersHook} from "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
40
- import {JB721TiersHookStore} from "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
41
- import {JB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/JB721CheckpointsDeployer.sol";
42
- import {IJB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/interfaces/IJB721CheckpointsDeployer.sol";
43
- import {JBAddressRegistry} from "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
44
- import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
45
- import {REVOwner} from "../src/REVOwner.sol";
46
- import {IREVDeployer} from "../src/interfaces/IREVDeployer.sol";
47
- import {MockSuckerRegistry} from "./mock/MockSuckerRegistry.sol";
48
-
49
- struct FeeProjectConfig {
50
- REVConfig configuration;
51
- JBTerminalConfig[] terminalConfigurations;
52
- REVSuckerDeploymentConfig suckerDeploymentConfiguration;
53
- }
54
-
55
- contract REVLoansUnsourcedTests is TestBaseWorkflow {
56
- /// @notice the salts that are used to deploy the contracts.
57
- // forge-lint: disable-next-line(mixed-case-variable)
58
- bytes32 REV_DEPLOYER_SALT = "REVDeployer";
59
- // forge-lint: disable-next-line(mixed-case-variable)
60
- bytes32 ERC20_SALT = "REV_TOKEN";
61
-
62
- // forge-lint: disable-next-line(mixed-case-variable)
63
- REVDeployer REV_DEPLOYER;
64
- // forge-lint: disable-next-line(mixed-case-variable)
65
- REVOwner REV_OWNER;
66
- // forge-lint: disable-next-line(mixed-case-variable)
67
- JB721TiersHook EXAMPLE_HOOK;
68
-
69
- /// @notice Deploys tiered ERC-721 hooks for revnets.
70
- // forge-lint: disable-next-line(mixed-case-variable)
71
- IJB721TiersHookDeployer HOOK_DEPLOYER;
72
- // forge-lint: disable-next-line(mixed-case-variable)
73
- IJB721TiersHookStore HOOK_STORE;
74
- // forge-lint: disable-next-line(mixed-case-variable)
75
- IJBAddressRegistry ADDRESS_REGISTRY;
76
-
77
- // forge-lint: disable-next-line(mixed-case-variable)
78
- IREVLoans LOANS_CONTRACT;
79
-
80
- /// @notice Deploys and tracks suckers for revnets.
81
- // forge-lint: disable-next-line(mixed-case-variable)
82
- IJBSuckerRegistry SUCKER_REGISTRY;
83
-
84
- // forge-lint: disable-next-line(mixed-case-variable)
85
- CTPublisher PUBLISHER;
86
- // forge-lint: disable-next-line(mixed-case-variable)
87
- MockBuybackDataHook MOCK_BUYBACK;
88
-
89
- // forge-lint: disable-next-line(mixed-case-variable)
90
- uint256 FEE_PROJECT_ID;
91
- // forge-lint: disable-next-line(mixed-case-variable)
92
- uint256 REVNET_ID;
93
-
94
- // forge-lint: disable-next-line(mixed-case-variable)
95
- address USER = makeAddr("user");
96
-
97
- /// @notice The address that is allowed to forward calls.
98
- address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
99
-
100
- function getFeeProjectConfig() internal view returns (FeeProjectConfig memory) {
101
- // Define constants
102
- string memory name = "Revnet";
103
- string memory symbol = "$REV";
104
- string memory projectUri = "ipfs://QmNRHT91HcDgMcenebYX7rJigt77cgNcosvuhX21wkF3tx";
105
- uint8 decimals = 18;
106
- uint256 decimalMultiplier = 10 ** decimals;
107
-
108
- // The tokens that the project accepts and stores.
109
- JBAccountingContext[] memory accountingContextsToAccept = new JBAccountingContext[](1);
110
-
111
- // Accept the chain's native currency through the multi terminal.
112
- accountingContextsToAccept[0] = JBAccountingContext({
113
- token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
114
- });
115
-
116
- // The terminals that the project will accept funds through.
117
- JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
118
- terminalConfigurations[0] =
119
- JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: accountingContextsToAccept});
120
-
121
- // The project's revnet stage configurations.
122
- REVStageConfig[] memory stageConfigurations = new REVStageConfig[](3);
123
-
124
- JBSplit[] memory splits = new JBSplit[](1);
125
- splits[0].beneficiary = payable(multisig());
126
- splits[0].percent = 10_000;
127
-
128
- {
129
- REVAutoIssuance[] memory issuanceConfs = new REVAutoIssuance[](1);
130
- issuanceConfs[0] = REVAutoIssuance({
131
- // forge-lint: disable-next-line(unsafe-typecast)
132
- chainId: uint32(block.chainid),
133
- // forge-lint: disable-next-line(unsafe-typecast)
134
- count: uint104(70_000 * decimalMultiplier),
135
- beneficiary: multisig()
136
- });
137
-
138
- stageConfigurations[0] = REVStageConfig({
139
- startsAtOrAfter: uint40(block.timestamp),
140
- autoIssuances: issuanceConfs,
141
- splitPercent: 2000, // 20%
142
- splits: splits,
143
- // forge-lint: disable-next-line(unsafe-typecast)
144
- initialIssuance: uint112(1000 * decimalMultiplier),
145
- issuanceCutFrequency: 90 days,
146
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
147
- cashOutTaxRate: 6000, // 0.6
148
- extraMetadata: 0
149
- });
150
- }
151
-
152
- stageConfigurations[1] = REVStageConfig({
153
- startsAtOrAfter: uint40(stageConfigurations[0].startsAtOrAfter + 720 days),
154
- autoIssuances: new REVAutoIssuance[](0),
155
- splitPercent: 2000, // 20%
156
- splits: splits,
157
- initialIssuance: 0, // inherit from previous cycle.
158
- issuanceCutFrequency: 180 days,
159
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
160
- cashOutTaxRate: 6000, // 0.6
161
- extraMetadata: 0
162
- });
163
-
164
- stageConfigurations[2] = REVStageConfig({
165
- startsAtOrAfter: uint40(stageConfigurations[1].startsAtOrAfter + (20 * 365 days)),
166
- autoIssuances: new REVAutoIssuance[](0),
167
- splits: splits,
168
- splitPercent: 0,
169
- initialIssuance: 1, // this is a special number that is as close to max price as we can get.
170
- issuanceCutFrequency: 0,
171
- issuanceCutPercent: 0,
172
- cashOutTaxRate: 6000, // 0.6
173
- extraMetadata: 0
174
- });
175
-
176
- // The project's revnet configuration
177
- REVConfig memory revnetConfiguration = REVConfig({
178
- // forge-lint: disable-next-line(named-struct-fields)
179
- description: REVDescription(name, symbol, projectUri, ERC20_SALT),
180
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
181
- splitOperator: multisig(),
182
- stageConfigurations: stageConfigurations
183
- });
184
-
185
- return FeeProjectConfig({
186
- configuration: revnetConfiguration,
187
- terminalConfigurations: terminalConfigurations,
188
- suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
189
- deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256(abi.encodePacked("REV"))
190
- })
191
- });
192
- }
193
-
194
- function getSecondProjectConfig() internal view returns (FeeProjectConfig memory) {
195
- // Define constants
196
- string memory name = "NANA";
197
- string memory symbol = "$NANA";
198
- string memory projectUri = "ipfs://QmNRHT91HcDgMcenebYX7rJigt77cgNxosvuhX21wkF3tx";
199
- uint8 decimals = 18;
200
- uint256 decimalMultiplier = 10 ** decimals;
201
-
202
- // The tokens that the project accepts and stores.
203
- JBAccountingContext[] memory accountingContextsToAccept = new JBAccountingContext[](1);
204
-
205
- // Accept the chain's native currency through the multi terminal.
206
- accountingContextsToAccept[0] = JBAccountingContext({
207
- token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
208
- });
209
-
210
- // The terminals that the project will accept funds through.
211
- JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
212
- terminalConfigurations[0] =
213
- JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: accountingContextsToAccept});
214
-
215
- JBSplit[] memory splits = new JBSplit[](1);
216
- splits[0].beneficiary = payable(multisig());
217
- splits[0].percent = 10_000;
218
-
219
- // The project's revnet stage configurations.
220
- REVStageConfig[] memory stageConfigurations = new REVStageConfig[](3);
221
-
222
- {
223
- REVAutoIssuance[] memory issuanceConfs = new REVAutoIssuance[](1);
224
- issuanceConfs[0] = REVAutoIssuance({
225
- // forge-lint: disable-next-line(unsafe-typecast)
226
- chainId: uint32(block.chainid),
227
- // forge-lint: disable-next-line(unsafe-typecast)
228
- count: uint104(70_000 * decimalMultiplier),
229
- beneficiary: multisig()
230
- });
231
-
232
- stageConfigurations[0] = REVStageConfig({
233
- startsAtOrAfter: uint40(block.timestamp),
234
- autoIssuances: issuanceConfs,
235
- splitPercent: 2000, // 20%
236
- splits: splits,
237
- // forge-lint: disable-next-line(unsafe-typecast)
238
- initialIssuance: uint112(1000 * decimalMultiplier),
239
- issuanceCutFrequency: 90 days,
240
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
241
- cashOutTaxRate: 6000, // 0.6
242
- extraMetadata: 0
243
- });
244
- }
245
-
246
- stageConfigurations[1] = REVStageConfig({
247
- startsAtOrAfter: uint40(stageConfigurations[0].startsAtOrAfter + 720 days),
248
- autoIssuances: new REVAutoIssuance[](0),
249
- splitPercent: 2000, // 20%
250
- splits: splits,
251
- initialIssuance: 0, // inherit from previous cycle.
252
- issuanceCutFrequency: 180 days,
253
- issuanceCutPercent: JBConstants.MAX_WEIGHT_CUT_PERCENT / 2,
254
- cashOutTaxRate: 6000, // 0.6
255
- extraMetadata: 0
256
- });
257
-
258
- stageConfigurations[2] = REVStageConfig({
259
- startsAtOrAfter: uint40(stageConfigurations[1].startsAtOrAfter + (20 * 365 days)),
260
- autoIssuances: new REVAutoIssuance[](0),
261
- splits: splits,
262
- splitPercent: 0,
263
- initialIssuance: 1, // this is a special number that is as close to max price as we can get.
264
- issuanceCutFrequency: 0,
265
- issuanceCutPercent: 0,
266
- cashOutTaxRate: 6000, // 0.6
267
- extraMetadata: 0
268
- });
269
-
270
- // The project's revnet configuration
271
- REVConfig memory revnetConfiguration = REVConfig({
272
- // forge-lint: disable-next-line(named-struct-fields)
273
- description: REVDescription(name, symbol, projectUri, "NANA_TOKEN"),
274
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
275
- splitOperator: multisig(),
276
- stageConfigurations: stageConfigurations
277
- });
278
-
279
- return FeeProjectConfig({
280
- configuration: revnetConfiguration,
281
- terminalConfigurations: terminalConfigurations,
282
- suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
283
- deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256(abi.encodePacked("NANA"))
284
- })
285
- });
286
- }
287
-
288
- function setUp() public override {
289
- super.setUp();
290
-
291
- FEE_PROJECT_ID = jbProjects().createFor(multisig());
292
-
293
- SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
294
-
295
- HOOK_STORE = new JB721TiersHookStore();
296
-
297
- EXAMPLE_HOOK = new JB721TiersHook(
298
- jbDirectory(),
299
- jbPermissions(),
300
- jbPrices(),
301
- jbRulesets(),
302
- HOOK_STORE,
303
- jbSplits(),
304
- IJB721CheckpointsDeployer(address(new JB721CheckpointsDeployer())),
305
- multisig()
306
- );
307
-
308
- ADDRESS_REGISTRY = new JBAddressRegistry();
309
-
310
- HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
311
-
312
- PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
313
- MOCK_BUYBACK = new MockBuybackDataHook();
314
-
315
- LOANS_CONTRACT = new REVLoans({
316
- controller: jbController(),
317
- suckerRegistry: IJBSuckerRegistry(address(new MockSuckerRegistry())),
318
- revId: FEE_PROJECT_ID,
319
- owner: address(this),
320
- permit2: permit2(),
321
- trustedForwarder: TRUSTED_FORWARDER
322
- });
323
-
324
- REV_OWNER = new REVOwner(
325
- IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
326
- jbDirectory(),
327
- FEE_PROJECT_ID,
328
- SUCKER_REGISTRY,
329
- address(LOANS_CONTRACT),
330
- address(0)
331
- );
332
-
333
- REV_DEPLOYER = new REVDeployer{salt: REV_DEPLOYER_SALT}(
334
- jbController(),
335
- SUCKER_REGISTRY,
336
- FEE_PROJECT_ID,
337
- HOOK_DEPLOYER,
338
- PUBLISHER,
339
- IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
340
- address(LOANS_CONTRACT),
341
- TRUSTED_FORWARDER,
342
- address(REV_OWNER)
343
- );
344
-
345
- REV_OWNER.setDeployer(REV_DEPLOYER);
346
-
347
- // Approve the basic deployer to configure the project.
348
- vm.prank(address(multisig()));
349
- jbProjects().approve(address(REV_DEPLOYER), FEE_PROJECT_ID);
350
-
351
- // Build the config.
352
- FeeProjectConfig memory feeProjectConfig = getFeeProjectConfig();
353
-
354
- vm.prank(address(multisig()));
355
- // Configure the project.
356
- (REVNET_ID,) = REV_DEPLOYER.deployFor({
357
- revnetId: FEE_PROJECT_ID, // Zero to deploy a new revnet
358
- configuration: feeProjectConfig.configuration,
359
- terminalConfigurations: feeProjectConfig.terminalConfigurations,
360
- suckerDeploymentConfiguration: feeProjectConfig.suckerDeploymentConfiguration,
361
- tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
362
- allowedPosts: REVEmpty721Config.emptyAllowedPosts()
363
- });
364
-
365
- // Configure second revnet
366
- FeeProjectConfig memory fee2Config = getSecondProjectConfig();
367
-
368
- // Configure the project.
369
- (REVNET_ID,) = REV_DEPLOYER.deployFor({
370
- revnetId: 0, // Zero to deploy a new revnet
371
- configuration: fee2Config.configuration,
372
- terminalConfigurations: fee2Config.terminalConfigurations,
373
- suckerDeploymentConfiguration: fee2Config.suckerDeploymentConfiguration,
374
- tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
375
- allowedPosts: REVEmpty721Config.emptyAllowedPosts()
376
- });
377
-
378
- // Give Eth for the user experience
379
- vm.deal(USER, 100e18);
380
- }
381
-
382
- /// @notice Loan fund access limits are now auto-derived from terminal configs.
383
- /// Borrowing still fails if the user hasn't approved LOANS to burn their tokens as collateral.
384
- function test_Pay_Borrow_Without_Loan_Source() public {
385
- vm.prank(USER);
386
- uint256 tokens = jbMultiTerminal().pay{value: 1e18}(REVNET_ID, JBConstants.NATIVE_TOKEN, 1e18, USER, 0, "", "");
387
-
388
- uint256 loanable =
389
- LOANS_CONTRACT.borrowableAmountFrom(REVNET_ID, tokens, 18, uint32(uint160(JBConstants.NATIVE_TOKEN)));
390
- assertGt(loanable, 0);
391
-
392
- // Loan fund access limits are now auto-derived from terminal configs, so the surplus allowance exists.
393
- // The borrow still fails because USER hasn't approved LOANS to burn their tokens as collateral.
394
- vm.expectRevert(
395
- abi.encodeWithSelector(
396
- JBPermissioned.JBPermissioned_Unauthorized.selector,
397
- USER, // account (the token holder)
398
- address(LOANS_CONTRACT), // sender (the contract trying to burn)
399
- REVNET_ID, // projectId
400
- JBPermissionIds.BURN_TOKENS // permissionId
401
- )
402
- );
403
-
404
- REVLoanSource memory sauce = REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: jbMultiTerminal()});
405
-
406
- vm.prank(USER);
407
- LOANS_CONTRACT.borrowFrom(REVNET_ID, sauce, loanable, tokens, payable(USER), 500, USER);
408
- }
409
- }