@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,247 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
5
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
- import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
7
- import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
8
- import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
9
- import {IJBPayoutTerminal} from "@bananapus/core-v6/src/interfaces/IJBPayoutTerminal.sol";
10
- import {JBRuleset} from "@bananapus/core-v6/src/structs/JBRuleset.sol";
11
- import {JBPayHookSpecification} from "@bananapus/core-v6/src/structs/JBPayHookSpecification.sol";
12
- import {IREVLoans} from "../../src/interfaces/IREVLoans.sol";
13
- import {REVLoanSource} from "../../src/structs/REVLoanSource.sol";
14
-
15
- /// @notice A terminal that reverts on both pay() and addToBalanceOf().
16
- /// @dev If the fee terminal breaks, cash-outs brick because
17
- /// afterCashOutRecordedWith's fallback addToBalanceOf also reverts.
18
- contract BrokenFeeTerminal is ERC165, IJBPayoutTerminal {
19
- bool public payReverts = true;
20
- bool public addToBalanceReverts = true;
21
-
22
- function setPayReverts(bool _reverts) external {
23
- payReverts = _reverts;
24
- }
25
-
26
- function setAddToBalanceReverts(bool _reverts) external {
27
- addToBalanceReverts = _reverts;
28
- }
29
-
30
- function pay(
31
- uint256,
32
- address,
33
- uint256,
34
- address,
35
- uint256,
36
- string calldata,
37
- bytes calldata
38
- )
39
- external
40
- payable
41
- override
42
- returns (uint256)
43
- {
44
- if (payReverts) revert("BrokenFeeTerminal: pay reverts");
45
- return 0;
46
- }
47
-
48
- function addToBalanceOf(
49
- uint256,
50
- address,
51
- uint256,
52
- bool,
53
- string calldata,
54
- bytes calldata
55
- )
56
- external
57
- payable
58
- override
59
- {
60
- if (addToBalanceReverts) revert("BrokenFeeTerminal: addToBalance reverts");
61
- }
62
-
63
- function accountingContextForTokenOf(uint256, address) external pure override returns (JBAccountingContext memory) {
64
- return JBAccountingContext({
65
- token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
66
- });
67
- }
68
-
69
- function accountingContextsOf(uint256) external pure override returns (JBAccountingContext[] memory) {
70
- return new JBAccountingContext[](0);
71
- }
72
-
73
- function addAccountingContextsFor(uint256, JBAccountingContext[] calldata) external override {}
74
-
75
- function currentSurplusOf(uint256, address[] calldata, uint256, uint256) external pure override returns (uint256) {
76
- return 0;
77
- }
78
-
79
- function migrateBalanceOf(uint256, address, IJBTerminal) external pure override returns (uint256) {
80
- return 0;
81
- }
82
-
83
- function sendPayoutsOf(uint256, address, uint256, uint256, uint256) external pure override returns (uint256) {
84
- return 0;
85
- }
86
-
87
- function useAllowanceOf(
88
- uint256,
89
- address,
90
- uint256,
91
- uint256,
92
- uint256,
93
- address payable,
94
- address payable,
95
- string calldata
96
- )
97
- external
98
- pure
99
- override
100
- returns (uint256)
101
- {
102
- return 0;
103
- }
104
-
105
- function previewPayFor(
106
- uint256,
107
- address,
108
- uint256,
109
- address,
110
- bytes calldata
111
- )
112
- external
113
- pure
114
- override
115
- returns (JBRuleset memory, uint256, uint256, JBPayHookSpecification[] memory)
116
- {
117
- JBRuleset memory ruleset;
118
- return (ruleset, 0, 0, new JBPayHookSpecification[](0));
119
- }
120
-
121
- function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
122
- return interfaceId == type(IJBTerminal).interfaceId || interfaceId == type(IJBPayoutTerminal).interfaceId
123
- || super.supportsInterface(interfaceId);
124
- }
125
-
126
- receive() external payable {}
127
- }
128
-
129
- /// @notice A terminal that attempts to addToBalance + borrow in a single tx.
130
- /// @dev Flash loan surplus inflation via live surplus read.
131
- contract SurplusInflator is ERC165, IJBPayoutTerminal {
132
- IREVLoans public loans;
133
- uint256 public revnetId;
134
- IJBPayoutTerminal public realTerminal;
135
- bool public shouldInflate;
136
-
137
- function configure(IREVLoans _loans, uint256 _revnetId, IJBPayoutTerminal _realTerminal) external {
138
- loans = _loans;
139
- revnetId = _revnetId;
140
- realTerminal = _realTerminal;
141
- }
142
-
143
- function setShouldInflate(bool _should) external {
144
- shouldInflate = _should;
145
- }
146
-
147
- function pay(
148
- uint256,
149
- address,
150
- uint256,
151
- address,
152
- uint256,
153
- string calldata,
154
- bytes calldata
155
- )
156
- external
157
- payable
158
- override
159
- returns (uint256)
160
- {
161
- if (shouldInflate) {
162
- shouldInflate = false;
163
- // Try to borrow at the inflated surplus
164
- REVLoanSource memory source = REVLoanSource({token: JBConstants.NATIVE_TOKEN, terminal: realTerminal});
165
- try loans.borrowFrom(revnetId, source, 0, 1e18, payable(address(this)), 25, address(this)) {} catch {}
166
- }
167
- return 0;
168
- }
169
-
170
- function addToBalanceOf(
171
- uint256,
172
- address,
173
- uint256,
174
- bool,
175
- string calldata,
176
- bytes calldata
177
- )
178
- external
179
- payable
180
- override
181
- {}
182
-
183
- function accountingContextForTokenOf(uint256, address) external pure override returns (JBAccountingContext memory) {
184
- return JBAccountingContext({
185
- token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
186
- });
187
- }
188
-
189
- function accountingContextsOf(uint256) external pure override returns (JBAccountingContext[] memory) {
190
- return new JBAccountingContext[](0);
191
- }
192
-
193
- function addAccountingContextsFor(uint256, JBAccountingContext[] calldata) external override {}
194
-
195
- function currentSurplusOf(uint256, address[] calldata, uint256, uint256) external pure override returns (uint256) {
196
- return 0;
197
- }
198
-
199
- function migrateBalanceOf(uint256, address, IJBTerminal) external pure override returns (uint256) {
200
- return 0;
201
- }
202
-
203
- function sendPayoutsOf(uint256, address, uint256, uint256, uint256) external pure override returns (uint256) {
204
- return 0;
205
- }
206
-
207
- function useAllowanceOf(
208
- uint256,
209
- address,
210
- uint256,
211
- uint256,
212
- uint256,
213
- address payable,
214
- address payable,
215
- string calldata
216
- )
217
- external
218
- pure
219
- override
220
- returns (uint256)
221
- {
222
- return 0;
223
- }
224
-
225
- function previewPayFor(
226
- uint256,
227
- address,
228
- uint256,
229
- address,
230
- bytes calldata
231
- )
232
- external
233
- pure
234
- override
235
- returns (JBRuleset memory, uint256, uint256, JBPayHookSpecification[] memory)
236
- {
237
- JBRuleset memory ruleset;
238
- return (ruleset, 0, 0, new JBPayHookSpecification[](0));
239
- }
240
-
241
- function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
242
- return interfaceId == type(IJBTerminal).interfaceId || interfaceId == type(IJBPayoutTerminal).interfaceId
243
- || super.supportsInterface(interfaceId);
244
- }
245
-
246
- receive() external payable {}
247
- }
@@ -1,45 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.0;
3
-
4
- import {IJB721TokenUriResolver} from "@bananapus/721-hook-v6/src/interfaces/IJB721TokenUriResolver.sol";
5
- // forge-lint: disable-next-line(unused-import)
6
- import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
7
- import {JB721InitTiersConfig} from "@bananapus/721-hook-v6/src/structs/JB721InitTiersConfig.sol";
8
- import {JB721TierConfig} from "@bananapus/721-hook-v6/src/structs/JB721TierConfig.sol";
9
- import {REVBaseline721HookConfig} from "../../src/structs/REVBaseline721HookConfig.sol";
10
- import {REVDeploy721TiersHookConfig} from "../../src/structs/REVDeploy721TiersHookConfig.sol";
11
- import {REV721TiersHookFlags} from "../../src/structs/REV721TiersHookFlags.sol";
12
- import {REVCroptopAllowedPost} from "../../src/structs/REVCroptopAllowedPost.sol";
13
-
14
- /// @notice Helpers for constructing empty 721 hook configs in tests.
15
- library REVEmpty721Config {
16
- function empty721Config(uint32 baseCurrency) internal pure returns (REVDeploy721TiersHookConfig memory) {
17
- return REVDeploy721TiersHookConfig({
18
- baseline721HookConfiguration: REVBaseline721HookConfig({
19
- name: "",
20
- symbol: "",
21
- baseUri: "",
22
- tokenUriResolver: IJB721TokenUriResolver(address(0)),
23
- contractUri: "",
24
- tiersConfig: JB721InitTiersConfig({
25
- tiers: new JB721TierConfig[](0), currency: baseCurrency, decimals: 18
26
- }),
27
- flags: REV721TiersHookFlags({
28
- noNewTiersWithReserves: false,
29
- noNewTiersWithVotes: false,
30
- noNewTiersWithOwnerMinting: false,
31
- preventOverspending: false
32
- })
33
- }),
34
- salt: bytes32(0),
35
- preventSplitOperatorAdjustingTiers: false,
36
- preventSplitOperatorUpdatingMetadata: false,
37
- preventSplitOperatorMinting: false,
38
- preventSplitOperatorIncreasingDiscountPercent: false
39
- });
40
- }
41
-
42
- function emptyAllowedPosts() internal pure returns (REVCroptopAllowedPost[] memory) {
43
- return new REVCroptopAllowedPost[](0);
44
- }
45
- }
@@ -1,84 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {IJBCashOutHook} from "@bananapus/core-v6/src/interfaces/IJBCashOutHook.sol";
5
- import {IJBPayHook} from "@bananapus/core-v6/src/interfaces/IJBPayHook.sol";
6
- import {IJBRulesetDataHook} from "@bananapus/core-v6/src/interfaces/IJBRulesetDataHook.sol";
7
- import {JBAfterCashOutRecordedContext} from "@bananapus/core-v6/src/structs/JBAfterCashOutRecordedContext.sol";
8
- import {JBAfterPayRecordedContext} from "@bananapus/core-v6/src/structs/JBAfterPayRecordedContext.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 {JBRuleset} from "@bananapus/core-v6/src/structs/JBRuleset.sol";
14
- import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
15
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
16
- import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
17
-
18
- contract MockBuybackCashOutRecorder is IJBRulesetDataHook, IJBPayHook, IJBCashOutHook {
19
- uint256 public afterCashOutCount;
20
- address public lastBeneficiary;
21
-
22
- // Pure: does not read or modify state, only returns values derived from calldata.
23
- function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
24
- external
25
- pure
26
- override
27
- returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications)
28
- {
29
- weight = context.weight;
30
- hookSpecifications = new JBPayHookSpecification[](0);
31
- }
32
-
33
- function beforeCashOutRecordedWith(JBBeforeCashOutRecordedContext calldata context)
34
- external
35
- view
36
- override
37
- returns (
38
- uint256 cashOutTaxRate,
39
- uint256 cashOutCount,
40
- uint256 totalSupply,
41
- uint256 effectiveSurplusValue,
42
- JBCashOutHookSpecification[] memory hookSpecifications
43
- )
44
- {
45
- cashOutTaxRate = JBConstants.MAX_CASH_OUT_TAX_RATE;
46
- cashOutCount = context.cashOutCount;
47
- totalSupply = context.totalSupply;
48
- effectiveSurplusValue = 0;
49
- hookSpecifications = new JBCashOutHookSpecification[](1);
50
- hookSpecifications[0] = JBCashOutHookSpecification({
51
- hook: IJBCashOutHook(address(this)),
52
- noop: false,
53
- amount: 0,
54
- metadata: abi.encode(uint256(0), context.cashOutCount)
55
- });
56
- }
57
-
58
- function afterCashOutRecordedWith(JBAfterCashOutRecordedContext calldata context) external payable override {
59
- // Decode the cashOutCount from metadata (matching the real buyback hook's metadata passthrough).
60
- if (context.hookMetadata.length != 0) {
61
- (, afterCashOutCount) = abi.decode(context.hookMetadata, (uint256, uint256));
62
- } else {
63
- afterCashOutCount = context.cashOutCount;
64
- }
65
- lastBeneficiary = context.beneficiary;
66
- }
67
-
68
- function afterPayRecordedWith(JBAfterPayRecordedContext calldata) external payable override {}
69
-
70
- function hasMintPermissionFor(uint256, JBRuleset memory, address) external pure override returns (bool) {
71
- return false;
72
- }
73
-
74
- function setPoolFor(uint256, PoolKey calldata, uint256, address) external pure {}
75
-
76
- function setPoolFor(uint256, uint24, int24, uint256, address) external pure {}
77
-
78
- function initializePoolFor(uint256, uint24, int24, uint256, address, uint160) external pure {}
79
-
80
- function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
81
- return interfaceId == type(IJBRulesetDataHook).interfaceId || interfaceId == type(IJBCashOutHook).interfaceId
82
- || interfaceId == type(IJBPayHook).interfaceId || interfaceId == type(IERC165).interfaceId;
83
- }
84
- }
@@ -1,112 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {IJBRulesetDataHook} from "@bananapus/core-v6/src/interfaces/IJBRulesetDataHook.sol";
5
- import {IJBCashOutHook} from "@bananapus/core-v6/src/interfaces/IJBCashOutHook.sol";
6
- import {IJBPayHook} from "@bananapus/core-v6/src/interfaces/IJBPayHook.sol";
7
- // forge-lint: disable-next-line(unused-import)
8
- import {IJBBuybackHook} from "@bananapus/buyback-hook-v6/src/interfaces/IJBBuybackHook.sol";
9
- import {JBBeforePayRecordedContext} from "@bananapus/core-v6/src/structs/JBBeforePayRecordedContext.sol";
10
- import {JBBeforeCashOutRecordedContext} from "@bananapus/core-v6/src/structs/JBBeforeCashOutRecordedContext.sol";
11
- import {JBPayHookSpecification} from "@bananapus/core-v6/src/structs/JBPayHookSpecification.sol";
12
- import {JBCashOutHookSpecification} from "@bananapus/core-v6/src/structs/JBCashOutHookSpecification.sol";
13
- import {JBAfterPayRecordedContext} from "@bananapus/core-v6/src/structs/JBAfterPayRecordedContext.sol";
14
- import {JBRuleset} from "@bananapus/core-v6/src/structs/JBRuleset.sol";
15
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
16
- import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
17
-
18
- /// @notice A minimal mock buyback data hook for tests. Returns the default weight and a no-op pay hook specification.
19
- contract MockBuybackDataHook is IJBRulesetDataHook, IJBPayHook {
20
- bool public shouldReturnCashOutHookSpec;
21
- uint256 public cashOutCountToReturn;
22
- bytes public cashOutHookMetadata;
23
- uint256 public cashOutHookAmount;
24
- uint256 public cashOutTaxRateToReturn;
25
- uint256 public totalSupplyToReturn;
26
-
27
- function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
28
- external
29
- view
30
- override
31
- returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications)
32
- {
33
- weight = context.weight;
34
- hookSpecifications = new JBPayHookSpecification[](1);
35
- hookSpecifications[0] =
36
- JBPayHookSpecification({hook: IJBPayHook(address(this)), noop: false, amount: 0, metadata: ""});
37
- }
38
-
39
- function beforeCashOutRecordedWith(JBBeforeCashOutRecordedContext calldata context)
40
- external
41
- view
42
- override
43
- returns (
44
- uint256 cashOutTaxRate,
45
- uint256 cashOutCount,
46
- uint256 totalSupply,
47
- uint256 effectiveSurplusValue,
48
- JBCashOutHookSpecification[] memory hookSpecifications
49
- )
50
- {
51
- cashOutTaxRate = cashOutTaxRateToReturn == 0 ? context.cashOutTaxRate : cashOutTaxRateToReturn;
52
- cashOutCount = cashOutCountToReturn == 0 ? context.cashOutCount : cashOutCountToReturn;
53
- totalSupply = totalSupplyToReturn == 0 ? context.totalSupply : totalSupplyToReturn;
54
- effectiveSurplusValue = 0;
55
-
56
- if (!shouldReturnCashOutHookSpec) {
57
- hookSpecifications = new JBCashOutHookSpecification[](0);
58
- return (cashOutTaxRate, cashOutCount, totalSupply, effectiveSurplusValue, hookSpecifications);
59
- }
60
-
61
- hookSpecifications = new JBCashOutHookSpecification[](1);
62
- hookSpecifications[0] = JBCashOutHookSpecification({
63
- hook: IJBCashOutHook(address(this)), noop: false, amount: cashOutHookAmount, metadata: cashOutHookMetadata
64
- });
65
- }
66
-
67
- function configureCashOutResult(
68
- uint256 cashOutTaxRate,
69
- uint256 cashOutCount,
70
- uint256 totalSupply,
71
- uint256 hookAmount,
72
- bytes calldata hookMetadata
73
- )
74
- external
75
- {
76
- shouldReturnCashOutHookSpec = true;
77
- cashOutTaxRateToReturn = cashOutTaxRate;
78
- cashOutCountToReturn = cashOutCount;
79
- totalSupplyToReturn = totalSupply;
80
- cashOutHookAmount = hookAmount;
81
- cashOutHookMetadata = hookMetadata;
82
- }
83
-
84
- function resetCashOutResult() external {
85
- shouldReturnCashOutHookSpec = false;
86
- cashOutTaxRateToReturn = 0;
87
- cashOutCountToReturn = 0;
88
- totalSupplyToReturn = 0;
89
- cashOutHookAmount = 0;
90
- cashOutHookMetadata = "";
91
- }
92
-
93
- function hasMintPermissionFor(uint256, JBRuleset calldata, address) external pure override returns (bool) {
94
- return false;
95
- }
96
-
97
- function afterPayRecordedWith(JBAfterPayRecordedContext calldata) external payable override {}
98
-
99
- /// @notice No-op pool configuration for tests (PoolKey overload).
100
- function setPoolFor(uint256, PoolKey calldata, uint256, address) external pure {}
101
-
102
- /// @notice No-op pool configuration for tests (simplified overload).
103
- function setPoolFor(uint256, uint24, int24, uint256, address) external pure {}
104
-
105
- /// @notice No-op pool initialization for tests.
106
- function initializePoolFor(uint256, uint24, int24, uint256, address, uint160) external pure {}
107
-
108
- function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
109
- return interfaceId == type(IJBRulesetDataHook).interfaceId || interfaceId == type(IJBPayHook).interfaceId
110
- || interfaceId == type(IERC165).interfaceId;
111
- }
112
- }
@@ -1,68 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {IJBRulesetDataHook} from "@bananapus/core-v6/src/interfaces/IJBRulesetDataHook.sol";
5
- import {IJBPayHook} from "@bananapus/core-v6/src/interfaces/IJBPayHook.sol";
6
- import {JBBeforePayRecordedContext} from "@bananapus/core-v6/src/structs/JBBeforePayRecordedContext.sol";
7
- import {JBBeforeCashOutRecordedContext} from "@bananapus/core-v6/src/structs/JBBeforeCashOutRecordedContext.sol";
8
- import {JBPayHookSpecification} from "@bananapus/core-v6/src/structs/JBPayHookSpecification.sol";
9
- import {JBCashOutHookSpecification} from "@bananapus/core-v6/src/structs/JBCashOutHookSpecification.sol";
10
- import {JBAfterPayRecordedContext} from "@bananapus/core-v6/src/structs/JBAfterPayRecordedContext.sol";
11
- import {JBRuleset} from "@bananapus/core-v6/src/structs/JBRuleset.sol";
12
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
13
- import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
14
-
15
- /// @notice Mock buyback hook that simulates the "mint path" — returns EMPTY hookSpecifications.
16
- /// This is what the real JBBuybackHook does when direct minting is cheaper than swapping
17
- /// (i.e., tokenCountWithoutHook >= minimumSwapAmountOut).
18
- contract MockBuybackDataHookMintPath is IJBRulesetDataHook, IJBPayHook {
19
- function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
20
- external
21
- pure
22
- override
23
- returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications)
24
- {
25
- weight = context.weight;
26
- // Return EMPTY hookSpecifications — simulating the mint path where no swap is needed.
27
- hookSpecifications = new JBPayHookSpecification[](0);
28
- }
29
-
30
- function beforeCashOutRecordedWith(JBBeforeCashOutRecordedContext calldata context)
31
- external
32
- pure
33
- override
34
- returns (
35
- uint256 cashOutTaxRate,
36
- uint256 cashOutCount,
37
- uint256 totalSupply,
38
- uint256 effectiveSurplusValue,
39
- JBCashOutHookSpecification[] memory hookSpecifications
40
- )
41
- {
42
- cashOutTaxRate = context.cashOutTaxRate;
43
- cashOutCount = context.cashOutCount;
44
- totalSupply = context.totalSupply;
45
- effectiveSurplusValue = 0;
46
- hookSpecifications = new JBCashOutHookSpecification[](0);
47
- }
48
-
49
- function hasMintPermissionFor(uint256, JBRuleset calldata, address) external pure override returns (bool) {
50
- return false;
51
- }
52
-
53
- function afterPayRecordedWith(JBAfterPayRecordedContext calldata) external payable override {}
54
-
55
- /// @notice No-op pool configuration for tests (PoolKey overload).
56
- function setPoolFor(uint256, PoolKey calldata, uint256, address) external pure {}
57
-
58
- /// @notice No-op pool configuration for tests (simplified overload).
59
- function setPoolFor(uint256, uint24, int24, uint256, address) external pure {}
60
-
61
- /// @notice No-op pool initialization for tests.
62
- function initializePoolFor(uint256, uint24, int24, uint256, address, uint160) external pure {}
63
-
64
- function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
65
- return interfaceId == type(IJBRulesetDataHook).interfaceId || interfaceId == type(IJBPayHook).interfaceId
66
- || interfaceId == type(IERC165).interfaceId;
67
- }
68
- }
@@ -1,17 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- /// @notice Minimal mock that returns zeros for all cross-chain queries.
5
- contract MockSuckerRegistry {
6
- function isSuckerOf(uint256, address) external pure returns (bool) {
7
- return false;
8
- }
9
-
10
- function remoteTotalSupplyOf(uint256) external pure returns (uint256) {
11
- return 0;
12
- }
13
-
14
- function remoteSurplusOf(uint256, uint256, uint256) external pure returns (uint256) {
15
- return 0;
16
- }
17
- }