@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,367 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Test.sol";
|
|
5
|
-
import "@bananapus/core-v6/test/helpers/TestBaseWorkflow.sol";
|
|
6
|
-
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
7
|
-
import "@bananapus/721-hook-v6/script/helpers/Hook721DeploymentLib.sol";
|
|
8
|
-
import "@bananapus/suckers-v6/script/helpers/SuckerDeploymentLib.sol";
|
|
9
|
-
import "@croptop/core-v6/script/helpers/CroptopDeploymentLib.sol";
|
|
10
|
-
import "@bananapus/router-terminal-v6/script/helpers/RouterTerminalDeploymentLib.sol";
|
|
11
|
-
import "@croptop/core-v6/src/CTPublisher.sol";
|
|
12
|
-
import "@bananapus/suckers-v6/src/JBSuckerRegistry.sol";
|
|
13
|
-
import "@bananapus/721-hook-v6/src/JB721TiersHook.sol";
|
|
14
|
-
import "@bananapus/721-hook-v6/src/JB721TiersHookDeployer.sol";
|
|
15
|
-
import "@bananapus/721-hook-v6/src/JB721TiersHookStore.sol";
|
|
16
|
-
import "@bananapus/721-hook-v6/src/JB721CheckpointsDeployer.sol";
|
|
17
|
-
import {IJB721CheckpointsDeployer} from "@bananapus/721-hook-v6/src/interfaces/IJB721CheckpointsDeployer.sol";
|
|
18
|
-
import "@bananapus/address-registry-v6/src/JBAddressRegistry.sol";
|
|
19
|
-
import "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
20
|
-
import "@bananapus/buyback-hook-v6/src/interfaces/IJBBuybackHookRegistry.sol";
|
|
21
|
-
import "@bananapus/core-v6/src/interfaces/IJBPermissions.sol";
|
|
22
|
-
import "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
|
|
23
|
-
import "@bananapus/core-v6/src/interfaces/IJBPayoutTerminal.sol";
|
|
24
|
-
import "@bananapus/core-v6/src/libraries/JBCashOuts.sol";
|
|
25
|
-
import "@bananapus/core-v6/src/libraries/JBConstants.sol";
|
|
26
|
-
import "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
|
|
27
|
-
import "@bananapus/core-v6/src/structs/JBPermissionsData.sol";
|
|
28
|
-
import "@bananapus/core-v6/src/structs/JBTerminalConfig.sol";
|
|
29
|
-
import "@bananapus/core-v6/src/structs/JBSplit.sol";
|
|
30
|
-
import "@bananapus/core-v6/src/structs/JBRuleset.sol";
|
|
31
|
-
import "@bananapus/core-v6/src/structs/JBPayHookSpecification.sol";
|
|
32
|
-
import "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
|
|
33
|
-
import "@bananapus/suckers-v6/src/structs/JBSuckerDeployerConfig.sol";
|
|
34
|
-
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
35
|
-
|
|
36
|
-
import {MockBuybackDataHook} from "../mock/MockBuybackDataHook.sol";
|
|
37
|
-
import {REVEmpty721Config} from "../helpers/REVEmpty721Config.sol";
|
|
38
|
-
import {REVDeployer} from "../../src/REVDeployer.sol";
|
|
39
|
-
import {REVLoans} from "../../src/REVLoans.sol";
|
|
40
|
-
import {REVOwner} from "../../src/REVOwner.sol";
|
|
41
|
-
import {IREVLoans} from "../../src/interfaces/IREVLoans.sol";
|
|
42
|
-
import {IREVDeployer} from "../../src/interfaces/IREVDeployer.sol";
|
|
43
|
-
import {REVConfig} from "../../src/structs/REVConfig.sol";
|
|
44
|
-
import {REVDescription} from "../../src/structs/REVDescription.sol";
|
|
45
|
-
import {REVLoanSource} from "../../src/structs/REVLoanSource.sol";
|
|
46
|
-
import {REVStageConfig} from "../../src/structs/REVStageConfig.sol";
|
|
47
|
-
import {REVAutoIssuance} from "../../src/structs/REVStageConfig.sol";
|
|
48
|
-
import {REVSuckerDeploymentConfig} from "../../src/structs/REVSuckerDeploymentConfig.sol";
|
|
49
|
-
import {MockSuckerRegistry} from "../mock/MockSuckerRegistry.sol";
|
|
50
|
-
|
|
51
|
-
contract PhantomSurplusTerminal is ERC165, IJBPayoutTerminal {
|
|
52
|
-
uint256 public fakeSurplus;
|
|
53
|
-
|
|
54
|
-
function setFakeSurplus(uint256 newFakeSurplus) external {
|
|
55
|
-
fakeSurplus = newFakeSurplus;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function currentSurplusOf(uint256, address[] calldata, uint256, uint256) external view override returns (uint256) {
|
|
59
|
-
return fakeSurplus;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function accountingContextForTokenOf(uint256, address) external pure override returns (JBAccountingContext memory) {
|
|
63
|
-
return JBAccountingContext({
|
|
64
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function accountingContextsOf(uint256) external pure override returns (JBAccountingContext[] memory) {
|
|
69
|
-
return new JBAccountingContext[](0);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function addAccountingContextsFor(uint256, JBAccountingContext[] calldata) external override {}
|
|
73
|
-
|
|
74
|
-
function addToBalanceOf(
|
|
75
|
-
uint256,
|
|
76
|
-
address,
|
|
77
|
-
uint256,
|
|
78
|
-
bool,
|
|
79
|
-
string calldata,
|
|
80
|
-
bytes calldata
|
|
81
|
-
)
|
|
82
|
-
external
|
|
83
|
-
payable
|
|
84
|
-
override
|
|
85
|
-
{}
|
|
86
|
-
|
|
87
|
-
function migrateBalanceOf(uint256, address, IJBTerminal) external pure override returns (uint256) {
|
|
88
|
-
return 0;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function pay(
|
|
92
|
-
uint256,
|
|
93
|
-
address,
|
|
94
|
-
uint256,
|
|
95
|
-
address,
|
|
96
|
-
uint256,
|
|
97
|
-
string calldata,
|
|
98
|
-
bytes calldata
|
|
99
|
-
)
|
|
100
|
-
external
|
|
101
|
-
payable
|
|
102
|
-
override
|
|
103
|
-
returns (uint256)
|
|
104
|
-
{
|
|
105
|
-
return 0;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function previewPayFor(
|
|
109
|
-
uint256,
|
|
110
|
-
address,
|
|
111
|
-
uint256,
|
|
112
|
-
address,
|
|
113
|
-
bytes calldata
|
|
114
|
-
)
|
|
115
|
-
external
|
|
116
|
-
pure
|
|
117
|
-
override
|
|
118
|
-
returns (JBRuleset memory, uint256, uint256, JBPayHookSpecification[] memory)
|
|
119
|
-
{
|
|
120
|
-
JBRuleset memory ruleset;
|
|
121
|
-
return (ruleset, 0, 0, new JBPayHookSpecification[](0));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function sendPayoutsOf(uint256, address, uint256, uint256, uint256) external pure override returns (uint256) {
|
|
125
|
-
return 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
|
|
129
|
-
return interfaceId == type(IJBTerminal).interfaceId || interfaceId == type(IJBPayoutTerminal).interfaceId
|
|
130
|
-
|| super.supportsInterface(interfaceId);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function useAllowanceOf(
|
|
134
|
-
uint256,
|
|
135
|
-
address,
|
|
136
|
-
uint256,
|
|
137
|
-
uint256,
|
|
138
|
-
uint256,
|
|
139
|
-
address payable,
|
|
140
|
-
address payable,
|
|
141
|
-
string calldata
|
|
142
|
-
)
|
|
143
|
-
external
|
|
144
|
-
pure
|
|
145
|
-
override
|
|
146
|
-
returns (uint256)
|
|
147
|
-
{
|
|
148
|
-
return 0;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
contract CodexPhantomSurplusTerminalTest is TestBaseWorkflow {
|
|
153
|
-
bytes32 internal constant REV_DEPLOYER_SALT = "REVDeployer";
|
|
154
|
-
address internal constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
|
|
155
|
-
|
|
156
|
-
address internal USER = makeAddr("user");
|
|
157
|
-
|
|
158
|
-
REVDeployer internal REV_DEPLOYER;
|
|
159
|
-
REVOwner internal REV_OWNER;
|
|
160
|
-
REVLoans internal LOANS;
|
|
161
|
-
JB721TiersHook internal EXAMPLE_HOOK;
|
|
162
|
-
IJB721TiersHookDeployer internal HOOK_DEPLOYER;
|
|
163
|
-
IJB721TiersHookStore internal HOOK_STORE;
|
|
164
|
-
IJBAddressRegistry internal ADDRESS_REGISTRY;
|
|
165
|
-
IJBSuckerRegistry internal SUCKER_REGISTRY;
|
|
166
|
-
CTPublisher internal PUBLISHER;
|
|
167
|
-
MockBuybackDataHook internal MOCK_BUYBACK;
|
|
168
|
-
PhantomSurplusTerminal internal PHANTOM_TERMINAL;
|
|
169
|
-
|
|
170
|
-
uint256 internal FEE_PROJECT_ID;
|
|
171
|
-
uint256 internal REVNET_ID;
|
|
172
|
-
|
|
173
|
-
function setUp() public override {
|
|
174
|
-
super.setUp();
|
|
175
|
-
|
|
176
|
-
FEE_PROJECT_ID = jbProjects().createFor(multisig());
|
|
177
|
-
SUCKER_REGISTRY = new JBSuckerRegistry(jbDirectory(), jbPermissions(), multisig(), address(0));
|
|
178
|
-
HOOK_STORE = new JB721TiersHookStore();
|
|
179
|
-
EXAMPLE_HOOK = new JB721TiersHook(
|
|
180
|
-
jbDirectory(),
|
|
181
|
-
jbPermissions(),
|
|
182
|
-
jbPrices(),
|
|
183
|
-
jbRulesets(),
|
|
184
|
-
HOOK_STORE,
|
|
185
|
-
jbSplits(),
|
|
186
|
-
IJB721CheckpointsDeployer(address(new JB721CheckpointsDeployer())),
|
|
187
|
-
multisig()
|
|
188
|
-
);
|
|
189
|
-
ADDRESS_REGISTRY = new JBAddressRegistry();
|
|
190
|
-
HOOK_DEPLOYER = new JB721TiersHookDeployer(EXAMPLE_HOOK, HOOK_STORE, ADDRESS_REGISTRY, multisig());
|
|
191
|
-
PUBLISHER = new CTPublisher(jbDirectory(), jbPermissions(), FEE_PROJECT_ID, multisig());
|
|
192
|
-
MOCK_BUYBACK = new MockBuybackDataHook();
|
|
193
|
-
LOANS = new REVLoans({
|
|
194
|
-
controller: jbController(),
|
|
195
|
-
suckerRegistry: IJBSuckerRegistry(address(new MockSuckerRegistry())),
|
|
196
|
-
revId: FEE_PROJECT_ID,
|
|
197
|
-
owner: address(this),
|
|
198
|
-
permit2: permit2(),
|
|
199
|
-
trustedForwarder: TRUSTED_FORWARDER
|
|
200
|
-
});
|
|
201
|
-
REV_OWNER = new REVOwner(
|
|
202
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
203
|
-
jbDirectory(),
|
|
204
|
-
FEE_PROJECT_ID,
|
|
205
|
-
SUCKER_REGISTRY,
|
|
206
|
-
address(LOANS),
|
|
207
|
-
address(0)
|
|
208
|
-
);
|
|
209
|
-
REV_DEPLOYER = new REVDeployer{salt: REV_DEPLOYER_SALT}(
|
|
210
|
-
jbController(),
|
|
211
|
-
SUCKER_REGISTRY,
|
|
212
|
-
FEE_PROJECT_ID,
|
|
213
|
-
HOOK_DEPLOYER,
|
|
214
|
-
PUBLISHER,
|
|
215
|
-
IJBBuybackHookRegistry(address(MOCK_BUYBACK)),
|
|
216
|
-
address(LOANS),
|
|
217
|
-
TRUSTED_FORWARDER,
|
|
218
|
-
address(REV_OWNER)
|
|
219
|
-
);
|
|
220
|
-
REV_OWNER.setDeployer(IREVDeployer(REV_DEPLOYER));
|
|
221
|
-
PHANTOM_TERMINAL = new PhantomSurplusTerminal();
|
|
222
|
-
|
|
223
|
-
vm.prank(multisig());
|
|
224
|
-
jbProjects().approve(address(REV_DEPLOYER), FEE_PROJECT_ID);
|
|
225
|
-
|
|
226
|
-
_deployFeeProject();
|
|
227
|
-
REVNET_ID = _deployRevnetWithPhantomTerminal();
|
|
228
|
-
vm.deal(USER, 200 ether);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function test_registeredPhantomTerminalInflatesBorrowAgainstRealTreasury() public {
|
|
232
|
-
uint256 realSurplus = 100 ether;
|
|
233
|
-
uint256 phantomSurplus = 100 ether;
|
|
234
|
-
|
|
235
|
-
PHANTOM_TERMINAL.setFakeSurplus(phantomSurplus);
|
|
236
|
-
|
|
237
|
-
vm.prank(USER);
|
|
238
|
-
uint256 userTokens = jbMultiTerminal().pay{value: realSurplus}(
|
|
239
|
-
REVNET_ID, JBConstants.NATIVE_TOKEN, realSurplus, USER, 0, "", ""
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
uint256 collateral = userTokens / 10;
|
|
243
|
-
uint256 taxRate = 5000;
|
|
244
|
-
|
|
245
|
-
uint256 honestBorrowable = JBCashOuts.cashOutFrom({
|
|
246
|
-
surplus: realSurplus, cashOutCount: collateral, totalSupply: userTokens, cashOutTaxRate: taxRate
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
uint256 inflatedBorrowable =
|
|
250
|
-
LOANS.borrowableAmountFrom(REVNET_ID, collateral, 18, uint32(uint160(JBConstants.NATIVE_TOKEN)));
|
|
251
|
-
|
|
252
|
-
assertGt(inflatedBorrowable, honestBorrowable, "phantom terminal should inflate borrow quote");
|
|
253
|
-
assertLe(inflatedBorrowable, realSurplus, "PoC should remain payable by the honest terminal");
|
|
254
|
-
|
|
255
|
-
_grantBurnPermission(USER, REVNET_ID, address(LOANS));
|
|
256
|
-
|
|
257
|
-
uint256 balanceBefore = USER.balance;
|
|
258
|
-
vm.prank(USER);
|
|
259
|
-
LOANS.borrowFrom(
|
|
260
|
-
REVNET_ID,
|
|
261
|
-
REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: jbMultiTerminal()}),
|
|
262
|
-
inflatedBorrowable,
|
|
263
|
-
collateral,
|
|
264
|
-
payable(USER),
|
|
265
|
-
25,
|
|
266
|
-
USER
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
uint256 balanceDelta = USER.balance - balanceBefore;
|
|
270
|
-
assertGt(balanceDelta, honestBorrowable, "borrower extracts more ETH than real treasury surplus supports");
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function _deployFeeProject() internal {
|
|
274
|
-
JBAccountingContext[] memory acc = new JBAccountingContext[](1);
|
|
275
|
-
acc[0] = JBAccountingContext({
|
|
276
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
277
|
-
});
|
|
278
|
-
JBTerminalConfig[] memory tc = new JBTerminalConfig[](1);
|
|
279
|
-
tc[0] = JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: acc});
|
|
280
|
-
REVStageConfig[] memory stages = new REVStageConfig[](1);
|
|
281
|
-
stages[0] = REVStageConfig({
|
|
282
|
-
startsAtOrAfter: uint40(block.timestamp),
|
|
283
|
-
autoIssuances: new REVAutoIssuance[](0),
|
|
284
|
-
splitPercent: 0,
|
|
285
|
-
splits: new JBSplit[](0),
|
|
286
|
-
initialIssuance: uint112(1000e18),
|
|
287
|
-
issuanceCutFrequency: 0,
|
|
288
|
-
issuanceCutPercent: 0,
|
|
289
|
-
cashOutTaxRate: 0,
|
|
290
|
-
extraMetadata: 0
|
|
291
|
-
});
|
|
292
|
-
REVConfig memory feeConfig = REVConfig({
|
|
293
|
-
description: REVDescription("Fee Revnet", "FEE", "", "FEE_TOKEN"),
|
|
294
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
295
|
-
splitOperator: multisig(),
|
|
296
|
-
stageConfigurations: stages
|
|
297
|
-
});
|
|
298
|
-
vm.prank(multisig());
|
|
299
|
-
REV_DEPLOYER.deployFor({
|
|
300
|
-
revnetId: FEE_PROJECT_ID,
|
|
301
|
-
configuration: feeConfig,
|
|
302
|
-
terminalConfigurations: tc,
|
|
303
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
304
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("FEE")
|
|
305
|
-
}),
|
|
306
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
307
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function _deployRevnetWithPhantomTerminal() internal returns (uint256 revnetId) {
|
|
312
|
-
JBAccountingContext[] memory acc = new JBAccountingContext[](1);
|
|
313
|
-
acc[0] = JBAccountingContext({
|
|
314
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
315
|
-
});
|
|
316
|
-
JBTerminalConfig[] memory tc = new JBTerminalConfig[](2);
|
|
317
|
-
tc[0] = JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: acc});
|
|
318
|
-
tc[1] = JBTerminalConfig({terminal: PHANTOM_TERMINAL, accountingContextsToAccept: acc});
|
|
319
|
-
|
|
320
|
-
REVStageConfig[] memory stages = new REVStageConfig[](1);
|
|
321
|
-
JBSplit[] memory splits = new JBSplit[](1);
|
|
322
|
-
splits[0].beneficiary = payable(multisig());
|
|
323
|
-
splits[0].percent = 10_000;
|
|
324
|
-
stages[0] = REVStageConfig({
|
|
325
|
-
startsAtOrAfter: uint40(block.timestamp),
|
|
326
|
-
autoIssuances: new REVAutoIssuance[](0),
|
|
327
|
-
splitPercent: 0,
|
|
328
|
-
splits: splits,
|
|
329
|
-
initialIssuance: uint112(1000e18),
|
|
330
|
-
issuanceCutFrequency: 0,
|
|
331
|
-
issuanceCutPercent: 0,
|
|
332
|
-
cashOutTaxRate: 5000,
|
|
333
|
-
extraMetadata: 0
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
REVConfig memory config = REVConfig({
|
|
337
|
-
description: REVDescription("Phantom", "PHM", "", "PHM_TOKEN"),
|
|
338
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
339
|
-
splitOperator: multisig(),
|
|
340
|
-
stageConfigurations: stages
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
vm.prank(multisig());
|
|
344
|
-
(revnetId,) = REV_DEPLOYER.deployFor({
|
|
345
|
-
revnetId: 0,
|
|
346
|
-
configuration: config,
|
|
347
|
-
terminalConfigurations: tc,
|
|
348
|
-
suckerDeploymentConfiguration: REVSuckerDeploymentConfig({
|
|
349
|
-
deployerConfigurations: new JBSuckerDeployerConfig[](0), salt: keccak256("PHANTOM")
|
|
350
|
-
}),
|
|
351
|
-
tiered721HookConfiguration: REVEmpty721Config.empty721Config(uint32(uint160(JBConstants.NATIVE_TOKEN))),
|
|
352
|
-
allowedPosts: REVEmpty721Config.emptyAllowedPosts()
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function _grantBurnPermission(address account, uint256 revnetId, address operator) internal {
|
|
357
|
-
uint8[] memory permissionIds = new uint8[](1);
|
|
358
|
-
permissionIds[0] = JBPermissionIds.BURN_TOKENS;
|
|
359
|
-
|
|
360
|
-
vm.prank(account);
|
|
361
|
-
jbPermissions()
|
|
362
|
-
.setPermissionsFor(
|
|
363
|
-
account,
|
|
364
|
-
JBPermissionsData({operator: operator, projectId: uint56(revnetId), permissionIds: permissionIds})
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Test.sol";
|
|
5
|
-
import "@bananapus/core-v6/test/helpers/TestBaseWorkflow.sol";
|
|
6
|
-
import {IJBBuybackHookRegistry} from "@bananapus/buyback-hook-v6/src/interfaces/IJBBuybackHookRegistry.sol";
|
|
7
|
-
import {IJBCashOutHook} from "@bananapus/core-v6/src/interfaces/IJBCashOutHook.sol";
|
|
8
|
-
import {IJBRulesetDataHook} from "@bananapus/core-v6/src/interfaces/IJBRulesetDataHook.sol";
|
|
9
|
-
import {JBBeforeCashOutRecordedContext} from "@bananapus/core-v6/src/structs/JBBeforeCashOutRecordedContext.sol";
|
|
10
|
-
import {JBBeforePayRecordedContext} from "@bananapus/core-v6/src/structs/JBBeforePayRecordedContext.sol";
|
|
11
|
-
import {JBCashOutHookSpecification} from "@bananapus/core-v6/src/structs/JBCashOutHookSpecification.sol";
|
|
12
|
-
import {JBPayHookSpecification} from "@bananapus/core-v6/src/structs/JBPayHookSpecification.sol";
|
|
13
|
-
import {JBTokenAmount} from "@bananapus/core-v6/src/structs/JBTokenAmount.sol";
|
|
14
|
-
import {JBRuleset} from "@bananapus/core-v6/src/structs/JBRuleset.sol";
|
|
15
|
-
import {IJBSuckerRegistry} from "@bananapus/suckers-v6/src/interfaces/IJBSuckerRegistry.sol";
|
|
16
|
-
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
17
|
-
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
|
|
18
|
-
|
|
19
|
-
import {REVOwner} from "../../src/REVOwner.sol";
|
|
20
|
-
|
|
21
|
-
contract CurrencyAwareSuckerRegistry {
|
|
22
|
-
uint256 public expectedCurrency;
|
|
23
|
-
uint256 public remoteSupply;
|
|
24
|
-
uint256 public remoteSurplus;
|
|
25
|
-
|
|
26
|
-
function setRemoteValues(uint256 currency, uint256 supply, uint256 surplus) external {
|
|
27
|
-
expectedCurrency = currency;
|
|
28
|
-
remoteSupply = supply;
|
|
29
|
-
remoteSurplus = surplus;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function isSuckerOf(uint256, address) external pure returns (bool) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function remoteTotalSupplyOf(uint256) external view returns (uint256) {
|
|
37
|
-
return remoteSupply;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function remoteSurplusOf(uint256, uint256, uint256 currency) external view returns (uint256) {
|
|
41
|
-
return currency == expectedCurrency ? remoteSurplus : 0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
contract EchoBuybackRegistry is IJBRulesetDataHook {
|
|
46
|
-
function beforeCashOutRecordedWith(JBBeforeCashOutRecordedContext calldata context)
|
|
47
|
-
external
|
|
48
|
-
pure
|
|
49
|
-
returns (
|
|
50
|
-
uint256 cashOutTaxRate,
|
|
51
|
-
uint256 cashOutCount,
|
|
52
|
-
uint256 totalSupply,
|
|
53
|
-
uint256 effectiveSurplusValue,
|
|
54
|
-
JBCashOutHookSpecification[] memory hookSpecifications
|
|
55
|
-
)
|
|
56
|
-
{
|
|
57
|
-
cashOutTaxRate = context.cashOutTaxRate;
|
|
58
|
-
cashOutCount = context.cashOutCount;
|
|
59
|
-
totalSupply = context.totalSupply;
|
|
60
|
-
effectiveSurplusValue = context.surplus.value;
|
|
61
|
-
hookSpecifications = new JBCashOutHookSpecification[](0);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
|
|
65
|
-
external
|
|
66
|
-
pure
|
|
67
|
-
returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications)
|
|
68
|
-
{
|
|
69
|
-
weight = context.weight;
|
|
70
|
-
hookSpecifications = new JBPayHookSpecification[](0);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function hasMintPermissionFor(uint256, JBRuleset calldata, address) external pure returns (bool) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function setPoolFor(uint256, PoolKey calldata, uint256, address) external pure {}
|
|
78
|
-
function setPoolFor(uint256, uint24, int24, uint256, address) external pure {}
|
|
79
|
-
function initializePoolFor(uint256, uint24, int24, uint256, address, uint160) external pure {}
|
|
80
|
-
|
|
81
|
-
function supportsInterface(bytes4 interfaceId) external pure returns (bool) {
|
|
82
|
-
return interfaceId == type(IJBRulesetDataHook).interfaceId || interfaceId == type(IERC165).interfaceId;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
contract CodexREVOwnerRemoteSurplusCurrencyMismatchTest is TestBaseWorkflow {
|
|
87
|
-
REVOwner internal ownerHook;
|
|
88
|
-
CurrencyAwareSuckerRegistry internal suckerRegistry;
|
|
89
|
-
EchoBuybackRegistry internal buybackRegistry;
|
|
90
|
-
|
|
91
|
-
uint32 internal constant ETH_CURRENCY = 1;
|
|
92
|
-
|
|
93
|
-
function setUp() public override {
|
|
94
|
-
super.setUp();
|
|
95
|
-
|
|
96
|
-
suckerRegistry = new CurrencyAwareSuckerRegistry();
|
|
97
|
-
buybackRegistry = new EchoBuybackRegistry();
|
|
98
|
-
|
|
99
|
-
ownerHook = new REVOwner(
|
|
100
|
-
IJBBuybackHookRegistry(address(buybackRegistry)),
|
|
101
|
-
jbDirectory(),
|
|
102
|
-
999_999,
|
|
103
|
-
IJBSuckerRegistry(address(suckerRegistry)),
|
|
104
|
-
address(0),
|
|
105
|
-
address(0)
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function test_beforeCashOutRecordedWith_usesTokenAddressInsteadOfCurrencyForRemoteSurplus() public {
|
|
110
|
-
suckerRegistry.setRemoteValues(ETH_CURRENCY, 500 ether, 900 ether);
|
|
111
|
-
|
|
112
|
-
address usdToken = address(0xBEEF);
|
|
113
|
-
|
|
114
|
-
JBBeforeCashOutRecordedContext memory context = JBBeforeCashOutRecordedContext({
|
|
115
|
-
terminal: address(jbMultiTerminal()),
|
|
116
|
-
holder: address(0xCAFE),
|
|
117
|
-
projectId: 1,
|
|
118
|
-
rulesetId: 0,
|
|
119
|
-
cashOutCount: 100 ether,
|
|
120
|
-
totalSupply: 1000 ether,
|
|
121
|
-
surplus: JBTokenAmount({token: usdToken, value: 100 ether, decimals: 18, currency: ETH_CURRENCY}),
|
|
122
|
-
useTotalSurplus: true,
|
|
123
|
-
cashOutTaxRate: 0,
|
|
124
|
-
beneficiaryIsFeeless: false,
|
|
125
|
-
metadata: ""
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
(,, uint256 returnedSupply, uint256 returnedSurplus,) = ownerHook.beforeCashOutRecordedWith(context);
|
|
129
|
-
|
|
130
|
-
assertEq(returnedSupply, 1500 ether, "remote supply should still be included");
|
|
131
|
-
assertEq(
|
|
132
|
-
returnedSurplus,
|
|
133
|
-
100 ether,
|
|
134
|
-
"remote surplus is incorrectly dropped because REVOwner keys by token address instead of currency"
|
|
135
|
-
);
|
|
136
|
-
assertEq(
|
|
137
|
-
suckerRegistry.remoteSurplusOf(1, 18, ETH_CURRENCY),
|
|
138
|
-
900 ether,
|
|
139
|
-
"registry confirms surplus exists for the requested currency"
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|