@bananapus/core-v6 0.0.17 → 0.0.19

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 (107) hide show
  1. package/CHANGE_LOG.md +53 -13
  2. package/SKILLS.md +6 -0
  3. package/USER_JOURNEYS.md +4 -0
  4. package/package.json +1 -1
  5. package/src/JBTerminalStore.sol +357 -171
  6. package/src/interfaces/IJBTerminalStore.sol +70 -0
  7. package/test/fork/TestSequencerPriceFeedFork.sol +168 -0
  8. package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +215 -0
  9. package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +383 -0
  10. package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +415 -0
  11. package/docs/book.css +0 -13
  12. package/docs/book.toml +0 -12
  13. package/docs/solidity.min.js +0 -74
  14. package/docs/src/README.md +0 -703
  15. package/docs/src/SUMMARY.md +0 -94
  16. package/docs/src/src/JBChainlinkV3PriceFeed.sol/contract.JBChainlinkV3PriceFeed.md +0 -83
  17. package/docs/src/src/JBChainlinkV3SequencerPriceFeed.sol/contract.JBChainlinkV3SequencerPriceFeed.md +0 -88
  18. package/docs/src/src/JBController.sol/contract.JBController.md +0 -1121
  19. package/docs/src/src/JBDeadline.sol/contract.JBDeadline.md +0 -84
  20. package/docs/src/src/JBDirectory.sol/contract.JBDirectory.md +0 -294
  21. package/docs/src/src/JBERC20.sol/contract.JBERC20.md +0 -190
  22. package/docs/src/src/JBFeelessAddresses.sol/contract.JBFeelessAddresses.md +0 -80
  23. package/docs/src/src/JBFundAccessLimits.sol/contract.JBFundAccessLimits.md +0 -253
  24. package/docs/src/src/JBMultiTerminal.sol/contract.JBMultiTerminal.md +0 -1472
  25. package/docs/src/src/JBPermissions.sol/contract.JBPermissions.md +0 -199
  26. package/docs/src/src/JBPrices.sol/contract.JBPrices.md +0 -154
  27. package/docs/src/src/JBProjects.sol/contract.JBProjects.md +0 -131
  28. package/docs/src/src/JBRulesets.sol/contract.JBRulesets.md +0 -677
  29. package/docs/src/src/JBSplits.sol/contract.JBSplits.md +0 -237
  30. package/docs/src/src/JBTerminalStore.sol/contract.JBTerminalStore.md +0 -591
  31. package/docs/src/src/JBTokens.sol/contract.JBTokens.md +0 -353
  32. package/docs/src/src/README.md +0 -25
  33. package/docs/src/src/abstract/JBControlled.sol/abstract.JBControlled.md +0 -64
  34. package/docs/src/src/abstract/JBPermissioned.sol/abstract.JBPermissioned.md +0 -84
  35. package/docs/src/src/abstract/README.md +0 -5
  36. package/docs/src/src/enums/JBApprovalStatus.sol/enum.JBApprovalStatus.md +0 -17
  37. package/docs/src/src/enums/README.md +0 -4
  38. package/docs/src/src/interfaces/IJBCashOutHook.sol/interface.IJBCashOutHook.md +0 -29
  39. package/docs/src/src/interfaces/IJBCashOutTerminal.sol/interface.IJBCashOutTerminal.md +0 -57
  40. package/docs/src/src/interfaces/IJBControlled.sol/interface.IJBControlled.md +0 -12
  41. package/docs/src/src/interfaces/IJBController.sol/interface.IJBController.md +0 -334
  42. package/docs/src/src/interfaces/IJBDirectory.sol/interface.IJBDirectory.md +0 -108
  43. package/docs/src/src/interfaces/IJBDirectoryAccessControl.sol/interface.IJBDirectoryAccessControl.md +0 -19
  44. package/docs/src/src/interfaces/IJBFeeTerminal.sol/interface.IJBFeeTerminal.md +0 -91
  45. package/docs/src/src/interfaces/IJBFeelessAddresses.sol/interface.IJBFeelessAddresses.md +0 -26
  46. package/docs/src/src/interfaces/IJBFundAccessLimits.sol/interface.IJBFundAccessLimits.md +0 -88
  47. package/docs/src/src/interfaces/IJBMigratable.sol/interface.IJBMigratable.md +0 -29
  48. package/docs/src/src/interfaces/IJBMultiTerminal.sol/interface.IJBMultiTerminal.md +0 -50
  49. package/docs/src/src/interfaces/IJBPayHook.sol/interface.IJBPayHook.md +0 -28
  50. package/docs/src/src/interfaces/IJBPayoutTerminal.sol/interface.IJBPayoutTerminal.md +0 -105
  51. package/docs/src/src/interfaces/IJBPermissioned.sol/interface.IJBPermissioned.md +0 -12
  52. package/docs/src/src/interfaces/IJBPermissions.sol/interface.IJBPermissions.md +0 -74
  53. package/docs/src/src/interfaces/IJBPermitTerminal.sol/interface.IJBPermitTerminal.md +0 -15
  54. package/docs/src/src/interfaces/IJBPriceFeed.sol/interface.IJBPriceFeed.md +0 -12
  55. package/docs/src/src/interfaces/IJBPrices.sol/interface.IJBPrices.md +0 -74
  56. package/docs/src/src/interfaces/IJBProjectUriRegistry.sol/interface.IJBProjectUriRegistry.md +0 -19
  57. package/docs/src/src/interfaces/IJBProjects.sol/interface.IJBProjects.md +0 -49
  58. package/docs/src/src/interfaces/IJBRulesetApprovalHook.sol/interface.IJBRulesetApprovalHook.md +0 -35
  59. package/docs/src/src/interfaces/IJBRulesetDataHook.sol/interface.IJBRulesetDataHook.md +0 -97
  60. package/docs/src/src/interfaces/IJBRulesets.sol/interface.IJBRulesets.md +0 -165
  61. package/docs/src/src/interfaces/IJBSplitHook.sol/interface.IJBSplitHook.md +0 -31
  62. package/docs/src/src/interfaces/IJBSplits.sol/interface.IJBSplits.md +0 -35
  63. package/docs/src/src/interfaces/IJBTerminal.sol/interface.IJBTerminal.md +0 -141
  64. package/docs/src/src/interfaces/IJBTerminalStore.sol/interface.IJBTerminalStore.md +0 -198
  65. package/docs/src/src/interfaces/IJBToken.sol/interface.IJBToken.md +0 -54
  66. package/docs/src/src/interfaces/IJBTokenUriResolver.sol/interface.IJBTokenUriResolver.md +0 -12
  67. package/docs/src/src/interfaces/IJBTokens.sol/interface.IJBTokens.md +0 -151
  68. package/docs/src/src/interfaces/README.md +0 -33
  69. package/docs/src/src/libraries/JBCashOuts.sol/library.JBCashOuts.md +0 -40
  70. package/docs/src/src/libraries/JBConstants.sol/library.JBConstants.md +0 -52
  71. package/docs/src/src/libraries/JBCurrencyIds.sol/library.JBCurrencyIds.md +0 -19
  72. package/docs/src/src/libraries/JBFees.sol/library.JBFees.md +0 -52
  73. package/docs/src/src/libraries/JBFixedPointNumber.sol/library.JBFixedPointNumber.md +0 -12
  74. package/docs/src/src/libraries/JBMetadataResolver.sol/library.JBMetadataResolver.md +0 -242
  75. package/docs/src/src/libraries/JBRulesetMetadataResolver.sol/library.JBRulesetMetadataResolver.md +0 -180
  76. package/docs/src/src/libraries/JBSplitGroupIds.sol/library.JBSplitGroupIds.md +0 -14
  77. package/docs/src/src/libraries/JBSurplus.sol/library.JBSurplus.md +0 -44
  78. package/docs/src/src/libraries/README.md +0 -12
  79. package/docs/src/src/periphery/JBDeadline1Day.sol/contract.JBDeadline1Day.md +0 -15
  80. package/docs/src/src/periphery/JBDeadline3Days.sol/contract.JBDeadline3Days.md +0 -15
  81. package/docs/src/src/periphery/JBDeadline3Hours.sol/contract.JBDeadline3Hours.md +0 -15
  82. package/docs/src/src/periphery/JBDeadline7Days.sol/contract.JBDeadline7Days.md +0 -15
  83. package/docs/src/src/periphery/JBMatchingPriceFeed.sol/contract.JBMatchingPriceFeed.md +0 -22
  84. package/docs/src/src/periphery/README.md +0 -8
  85. package/docs/src/src/structs/JBAccountingContext.sol/struct.JBAccountingContext.md +0 -20
  86. package/docs/src/src/structs/JBAfterCashOutRecordedContext.sol/struct.JBAfterCashOutRecordedContext.md +0 -43
  87. package/docs/src/src/structs/JBAfterPayRecordedContext.sol/struct.JBAfterPayRecordedContext.md +0 -42
  88. package/docs/src/src/structs/JBBeforeCashOutRecordedContext.sol/struct.JBBeforeCashOutRecordedContext.md +0 -45
  89. package/docs/src/src/structs/JBBeforePayRecordedContext.sol/struct.JBBeforePayRecordedContext.md +0 -41
  90. package/docs/src/src/structs/JBCashOutHookSpecification.sol/struct.JBCashOutHookSpecification.md +0 -22
  91. package/docs/src/src/structs/JBCurrencyAmount.sol/struct.JBCurrencyAmount.md +0 -17
  92. package/docs/src/src/structs/JBFee.sol/struct.JBFee.md +0 -20
  93. package/docs/src/src/structs/JBFundAccessLimitGroup.sol/struct.JBFundAccessLimitGroup.md +0 -39
  94. package/docs/src/src/structs/JBPayHookSpecification.sol/struct.JBPayHookSpecification.md +0 -22
  95. package/docs/src/src/structs/JBPermissionsData.sol/struct.JBPermissionsData.md +0 -21
  96. package/docs/src/src/structs/JBRuleset.sol/struct.JBRuleset.md +0 -55
  97. package/docs/src/src/structs/JBRulesetConfig.sol/struct.JBRulesetConfig.md +0 -51
  98. package/docs/src/src/structs/JBRulesetMetadata.sol/struct.JBRulesetMetadata.md +0 -79
  99. package/docs/src/src/structs/JBRulesetWeightCache.sol/struct.JBRulesetWeightCache.md +0 -16
  100. package/docs/src/src/structs/JBRulesetWithMetadata.sol/struct.JBRulesetWithMetadata.md +0 -16
  101. package/docs/src/src/structs/JBSingleAllowance.sol/struct.JBSingleAllowance.md +0 -26
  102. package/docs/src/src/structs/JBSplit.sol/struct.JBSplit.md +0 -49
  103. package/docs/src/src/structs/JBSplitGroup.sol/struct.JBSplitGroup.md +0 -17
  104. package/docs/src/src/structs/JBSplitHookContext.sol/struct.JBSplitHookContext.md +0 -29
  105. package/docs/src/src/structs/JBTerminalConfig.sol/struct.JBTerminalConfig.md +0 -16
  106. package/docs/src/src/structs/JBTokenAmount.sol/struct.JBTokenAmount.md +0 -23
  107. package/docs/src/src/structs/README.md +0 -25
package/CHANGE_LOG.md CHANGED
@@ -10,6 +10,23 @@ This document describes all changes between `nana-core` (v5, Solidity 0.8.23) an
10
10
 
11
11
  `setSplitGroupsOf` self-auth now requires the upper 96 bits of the `groupId` to be non-zero. The full self-auth check is: `uint160(groupId) == msg.sender && groupId >> 160 != 0`. GroupIds with zero upper 96 bits (bare addresses like `uint256(uint160(tokenAddress))`) are protocol-reserved for terminal payout groups and always require controller authorization. This prevents accepted token contracts from writing a project's payout splits without controller auth. The 721 hook is unaffected since it already uses `hookAddress | tierId << 160` (non-zero upper bits).
12
12
 
13
+ ### 0.2 JBMultiTerminal -- Fee-Free Cashout Bypass Prevention
14
+
15
+ A new `_feeFreeSurplusOf` mapping (`projectId => token => uint256`) tracks cumulative fee-free intra-terminal payouts received by each project. When a split payout lands on the same terminal (intra-terminal routing, i.e. `terminal == this`), the net payout amount is added to `_feeFreeSurplusOf[projectId][token]`. During a cashout with `cashOutTaxRate == 0`, fees are now charged on the reclaim amount up to the tracked fee-free surplus (and the tracker is decremented accordingly). Cashouts beyond the fee-free surplus remain fee-free. This closes a round-trip fee bypass where funds could be routed fee-free into a project via an intra-terminal split payout and then cashed out fee-free via a zero-tax cashout.
16
+
17
+ ### 0.4 JBTerminalStore -- Preview Functions
18
+
19
+ Two new `view` functions added to `JBTerminalStore` and `IJBTerminalStore`:
20
+
21
+ - `previewPayFrom(address terminal, address payer, JBTokenAmount amount, uint256 projectId, address beneficiary, bytes metadata)` -- Simulates a payment and returns `(uint256 tokenCount, JBPayHookSpecification[] hookSpecifications)`. Invokes data hooks if configured. Does not modify state.
22
+ - `previewCashOutFrom(address terminal, address holder, uint256 projectId, uint256 cashOutCount, JBAccountingContext accountingContext, JBAccountingContext[] balanceAccountingContexts, bool beneficiaryIsFeeless, bytes metadata)` -- Simulates a cash out and returns `(uint256 reclaimAmount, uint256 cashOutTaxRate, JBCashOutHookSpecification[] hookSpecifications)`. Invokes data hooks if configured. Does not modify state.
23
+
24
+ Both functions use the explicit `terminal` parameter instead of `msg.sender`, allowing any caller to preview operations for any terminal. Internal computation logic was extracted into shared `_computePayFrom` and `_computeCashOutFrom` view helpers; the existing `recordPaymentFrom` and `recordCashOutFor` functions were refactored to call these helpers before writing state.
25
+
26
+ ### 0.3 JBBeforeCashOutRecordedContext -- beneficiaryIsFeeless Field
27
+
28
+ A `bool beneficiaryIsFeeless` field was added to the `JBBeforeCashOutRecordedContext` struct (before the `metadata` field). `recordCashOutFor` in `IJBTerminalStore` gained a corresponding `bool beneficiaryIsFeeless` parameter. The terminal passes the result of its feeless address check, allowing data hooks to skip their own fees when the beneficiary is already feeless (e.g., project-to-project routing via the router terminal). This is a **breaking change** to both the struct layout and the `recordCashOutFor` function signature.
29
+
13
30
  ---
14
31
 
15
32
  ## 1. Breaking Changes
@@ -29,16 +46,19 @@ A `rulesetId` parameter was added. Callers must now specify which ruleset to cac
29
46
  | Change | v5 | v6 |
30
47
  |--------|----|----|
31
48
  | `currentReclaimableSurplusOf` parameter rename | `uint256 tokenCount` (4-param overload) | `uint256 cashOutCount` |
49
+ | `recordCashOutFor` new parameter | No `beneficiaryIsFeeless` parameter | `bool beneficiaryIsFeeless` added after `balanceAccountingContexts` |
32
50
 
33
51
  The parameter was renamed from `tokenCount` to `cashOutCount` in the simple 4-parameter overload.
34
52
 
53
+ `recordCashOutFor` gained a `bool beneficiaryIsFeeless` parameter so the terminal can pass through its feeless address check to data hooks via the `JBBeforeCashOutRecordedContext` struct.
54
+
35
55
  #### IJBPayoutTerminal
36
56
 
37
57
  | Change | v5 | v6 |
38
58
  |--------|----|----|
39
59
  | `sendPayoutsOf` return value | `returns (uint256 netLeftoverPayoutAmount)` | `returns (uint256 amountPaidOut)` |
40
60
 
41
- The return value semantics changed: v5 returned the net leftover payout amount (sent to the project owner), while v6 returns the total amount paid out.
61
+ The return variable name was corrected from `netLeftoverPayoutAmount` to `amountPaidOut` to match the actual implementation semantics (total amount paid out). The v5 implementation already returned the total amount from `STORE.recordPayoutFor()`, not the leftover — only the interface had the misleading name.
42
62
 
43
63
  #### IJBController
44
64
 
@@ -80,6 +100,12 @@ Parameters changed from `memory` to `calldata` for gas efficiency.
80
100
  | `setTokenMetadataOf(uint256 projectId, string name, string symbol)` | Sets the name and symbol of a project's ERC-20 token. Requires the `SET_TOKEN_METADATA` permission. |
81
101
  | `afterReceiveMigrationFrom(IERC165 from, uint256 projectId)` | Called by the directory after this controller has been set as the active controller. Added to the `IJBMigratable` interface. |
82
102
 
103
+ #### IJBTerminalStore / JBTerminalStore
104
+
105
+ | Function | Description |
106
+ |----------|-------------|
107
+ | `currentTotalReclaimableSurplusOf(uint256 projectId, uint256 cashOutCount, uint256 decimals, uint256 currency)` | Convenience view that returns the reclaimable surplus across all terminals using all accounting contexts. Delegates to `currentReclaimableSurplusOf` with empty `terminals` and `accountingContexts` arrays. Mirrors the `currentTotalSurplusOf` pattern. |
108
+
83
109
  #### IJBTokens / JBTokens
84
110
 
85
111
  | Function | Description |
@@ -141,8 +167,8 @@ See section 2.2 above.
141
167
 
142
168
  | Contract | Event | Change |
143
169
  |----------|-------|--------|
144
- | `IJBCashOutTerminal` | `CashOut` | Event order changed in the interface (moved before `HookAfterRecordCashOut`); NatSpec added. No field changes. |
145
- | `IJBCashOutTerminal` | `HookAfterRecordCashOut` | Event order changed in the interface (moved after `CashOut`); NatSpec added. No field changes. |
170
+ | `IJBCashOutTerminal` | `CashOutTokens` | Event order changed in the interface (moved before `HookAfterRecordCashOut`); NatSpec added. No field changes. |
171
+ | `IJBCashOutTerminal` | `HookAfterRecordCashOut` | Event order changed in the interface (moved after `CashOutTokens`); NatSpec added. No field changes. |
146
172
 
147
173
  ### 3.3 All Interfaces Gained NatSpec
148
174
 
@@ -189,7 +215,13 @@ See section 2.3 above.
189
215
 
190
216
  ## 5. Struct Changes
191
217
 
192
- All structs are **identical** between v5 and v6. The only differences are:
218
+ All structs are identical between v5 and v6 except:
219
+
220
+ | Struct | Change |
221
+ |--------|--------|
222
+ | `JBBeforeCashOutRecordedContext` | New `bool beneficiaryIsFeeless` field added before `metadata`. Indicates whether the cash out's beneficiary is a feeless address, allowing data hooks to skip their own fees for in-protocol routing. |
223
+
224
+ Other struct-level differences (non-functional):
193
225
  - `forge-lint: disable-next-line(pascal-case-struct)` comments added to all struct definitions.
194
226
  - `JBSplit`: Additional NatSpec documentation on the `beneficiary` field behavior when set to `address(0)`.
195
227
 
@@ -269,6 +301,8 @@ No changes.
269
301
  | **Migration held fees** | Migration intentionally does not transfer held fees (documented: held fees belong to fee beneficiary, not the migrating project). |
270
302
  | **Held fee processing (reentrancy hardening)** | `processHeldFeesOf` now re-reads the storage index each iteration (instead of caching), deletes the entry before the external call, and updates the index before the external call. |
271
303
  | **Split payout documentation** | Failed split payouts documented as consuming payout limit by design. |
304
+ | **Fee-free cashout bypass prevention** | New `_feeFreeSurplusOf` mapping tracks cumulative fee-free intra-terminal payouts per project/token. During zero-tax cashouts, fees are charged up to this tracked amount (then decremented), preventing round-trip fee bypass. See Section 0.2. |
305
+ | **beneficiaryIsFeeless passthrough** | `cashOutTokensOf` now passes `_isFeeless(beneficiary)` to `recordCashOutFor`, which forwards it to data hooks via `JBBeforeCashOutRecordedContext.beneficiaryIsFeeless`. |
272
306
 
273
307
  ### 8.3 JBRulesets
274
308
 
@@ -285,36 +319,42 @@ No changes.
285
319
  |--------|-------------|
286
320
  | **Migration ordering** | `setControllerOf` now calls `migrate()` on the old controller BEFORE updating `controllerOf` in storage (so `migrate()` runs while the directory still points to the old controller). After updating storage, it calls `afterReceiveMigrationFrom` on the new controller. |
287
321
 
288
- ### 8.5 JBTokens
322
+ ### 8.5 JBSplits
323
+
324
+ | Change | Description |
325
+ |--------|-------------|
326
+ | **Stale storage cleanup** | `_setSplitsOf` now deletes stale packed split data when the new split count is smaller than the previous count, preventing leftover storage from prior configurations. |
327
+
328
+ ### 8.6 JBTokens
289
329
 
290
330
  | Change | Description |
291
331
  |--------|-------------|
292
332
  | **Overflow check timing** | `mintFor` now checks `totalSupplyOf(projectId) + count > type(uint208).max` BEFORE minting (v5 checked after). |
293
333
 
294
- ### 8.6 JBERC20
334
+ ### 8.7 JBERC20
295
335
 
296
336
  | Change | Description |
297
337
  |--------|-------------|
298
338
  | **Named revert** | `initialize()` now reverts with `JBERC20_AlreadyInitialized()` instead of a bare `revert()`. |
299
339
 
300
- ### 8.7 JBChainlinkV3PriceFeed
340
+ ### 8.8 JBChainlinkV3PriceFeed
301
341
 
302
342
  | Change | Description |
303
343
  |--------|-------------|
304
344
  | **Incomplete round check order** | The check for `updatedAt == 0` (incomplete round) now runs BEFORE the stale price check, avoiding false stale errors on incomplete rounds. |
305
345
 
306
- ### 8.8 JBChainlinkV3SequencerPriceFeed
346
+ ### 8.9 JBChainlinkV3SequencerPriceFeed
307
347
 
308
348
  | Change | Description |
309
349
  |--------|-------------|
310
350
  | **Typo fix** | Error parameter `gradePeriodTime` corrected to `gracePeriodTime` in `JBChainlinkV3SequencerPriceFeed_SequencerDown`. |
311
351
  | **Threshold docs** | Constructor parameter `threshold` documentation corrected from "blocks" to "seconds". |
312
352
 
313
- ### 8.9 Solidity Version
353
+ ### 8.10 Solidity Version
314
354
 
315
355
  All contracts upgraded from `pragma solidity 0.8.23` to `pragma solidity 0.8.26`.
316
356
 
317
- ### 8.10 Named Arguments
357
+ ### 8.11 Named Arguments
318
358
 
319
359
  Throughout the codebase, function calls were updated to use named argument syntax (e.g., `foo({bar: 1, baz: 2})`) for improved readability.
320
360
 
@@ -328,7 +368,7 @@ Throughout the codebase, function calls were updated to use named argument synta
328
368
  |----|----|-------|
329
369
  | `IJBController` | `IJBController` | Gained `setTokenMetadataOf`. `calldata` for terminal configs. |
330
370
  | `IJBRulesets` | `IJBRulesets` | `updateRulesetWeightCache` gained `rulesetId` parameter |
331
- | `IJBTerminalStore` | `IJBTerminalStore` | `tokenCount` renamed to `cashOutCount` in `currentReclaimableSurplusOf`. View functions reordered. |
371
+ | `IJBTerminalStore` | `IJBTerminalStore` | `tokenCount` renamed to `cashOutCount` in `currentReclaimableSurplusOf`. `recordCashOutFor` gained `beneficiaryIsFeeless` param. New `currentTotalReclaimableSurplusOf` convenience view. View functions reordered. |
332
372
  | `IJBPayoutTerminal` | `IJBPayoutTerminal` | `sendPayoutsOf` returns `amountPaidOut` (was `netLeftoverPayoutAmount`). `SendPayoutToSplit` event moved. |
333
373
  | `IJBPermitTerminal` | `IJBPermitTerminal` | Gained `Permit2AllowanceFailed` event |
334
374
  | `IJBMigratable` | `IJBMigratable` | Gained `afterReceiveMigrationFrom` function |
@@ -344,7 +384,7 @@ Throughout the codebase, function calls were updated to use named argument synta
344
384
  | v5 | v6 | Notes |
345
385
  |----|----|-------|
346
386
  | `JBController` | `JBController` | Token metadata, migration lifecycle (`afterReceiveMigrationFrom`), `LAUNCH_RULESETS` permission |
347
- | `JBMultiTerminal` | `JBMultiTerminal` | Reentrancy hardening, decimal validation rename, Permit2 event |
387
+ | `JBMultiTerminal` | `JBMultiTerminal` | Reentrancy hardening, decimal validation rename, Permit2 event, fee-free bypass prevention (`_feeFreeSurplusOf`), `beneficiaryIsFeeless` passthrough |
348
388
  | `JBRulesets` | `JBRulesets` | Approval hook try/catch, weight cache changes, threshold increase |
349
389
  | `JBDirectory` | `JBDirectory` | Migration ordering fix, afterReceiveMigration call |
350
390
  | `JBTokens` | `JBTokens` | Token metadata support, overflow check timing |
@@ -366,7 +406,7 @@ Throughout the codebase, function calls were updated to use named argument synta
366
406
 
367
407
  | v5 | v6 | Notes |
368
408
  |----|----|-------|
369
- | All 22 structs | Same names, same fields | Only lint comments added |
409
+ | All 22 structs | Same names | All identical except `JBBeforeCashOutRecordedContext` (gained `beneficiaryIsFeeless` field). Lint comments added to all. |
370
410
 
371
411
  ### Enums
372
412
 
package/SKILLS.md CHANGED
@@ -83,7 +83,13 @@ The core Juicebox V6 protocol on EVM: a modular system for launching treasury-ba
83
83
  | `balanceOf(address terminal, uint256 projectId, address token)` | Returns the balance of a project at a terminal for a given token. |
84
84
  | `usedPayoutLimitOf(address terminal, uint256 projectId, address token, uint256 rulesetCycleNumber, uint256 currency)` | Returns the used payout limit for a project in a given cycle. |
85
85
  | `usedSurplusAllowanceOf(address terminal, uint256 projectId, address token, uint256 rulesetId, uint256 currency)` | Returns the used surplus allowance for a project in a given ruleset. |
86
+ | `currentReclaimableSurplusOf(uint256 projectId, uint256 cashOutCount, uint256 totalSupply, uint256 surplus)` | Returns the reclaimable surplus given raw total supply and surplus values. Applies bonding curve from current ruleset. |
87
+ | `currentReclaimableSurplusOf(uint256 projectId, uint256 cashOutCount, IJBTerminal[] terminals, JBAccountingContext[] accountingContexts, uint256 decimals, uint256 currency)` | Returns the reclaimable surplus across specified terminals. Empty arrays default to all terminals/contexts. |
88
+ | `currentTotalReclaimableSurplusOf(uint256 projectId, uint256 cashOutCount, uint256 decimals, uint256 currency)` | Convenience view: reclaimable surplus across all terminals using all accounting contexts. Mirrors `currentTotalSurplusOf`. |
86
89
  | `currentSurplusOf(address terminal, uint256 projectId, JBAccountingContext[] accountingContexts, uint256 decimals, uint256 currency)` | Returns the current surplus for a project at a terminal. |
90
+ | `currentTotalSurplusOf(uint256 projectId, uint256 decimals, uint256 currency)` | Returns the total surplus across all terminals. |
91
+ | `previewPayFrom(address terminal, address payer, JBTokenAmount amount, uint256 projectId, address beneficiary, bytes metadata)` | Simulates a payment without modifying state. Invokes data hooks if configured. Returns token count and hook specifications. |
92
+ | `previewCashOutFrom(address terminal, address holder, uint256 projectId, uint256 cashOutCount, JBAccountingContext accountingContext, JBAccountingContext[] balanceAccountingContexts, bool beneficiaryIsFeeless, bytes metadata)` | Simulates a cash out without modifying state. Invokes data hooks if configured. Returns reclaim amount, tax rate, and hook specifications. |
87
93
 
88
94
  ### JBRulesets
89
95
 
package/USER_JOURNEYS.md CHANGED
@@ -69,6 +69,8 @@ All user paths through the Juicebox V6 core protocol. For each journey: entry po
69
69
  - Data hook can return empty weight (0) to suppress minting while still recording payment
70
70
  - Fee-on-transfer tokens: actual amount received is `_balanceOf(token) - balanceBefore` (measured via balance diff)
71
71
 
72
+ **Preview**: Call `JBTerminalStore.previewPayFrom(terminal, payer, amount, projectId, beneficiary, metadata)` to simulate the payment on-chain and see the exact token count and hook specifications that would be produced -- including data hook effects. This is a `view` function that does not modify state.
73
+
72
74
  ---
73
75
 
74
76
  ## 3. Cash Out Tokens
@@ -95,6 +97,8 @@ All user paths through the Juicebox V6 core protocol. For each journey: entry po
95
97
 
96
98
  **Events**: `CashOutTokens(rulesetId, rulesetCycleNumber, projectId, holder, beneficiary, cashOutCount, cashOutTaxRate, reclaimAmount, metadata, caller)`
97
99
 
100
+ **Preview**: Call `JBTerminalStore.previewCashOutFrom(terminal, holder, projectId, cashOutCount, accountingContext, balanceAccountingContexts, beneficiaryIsFeeless, metadata)` to simulate the full cash out on-chain -- including data hook effects on tax rate, supply, and hook specifications. This is a `view` function that does not modify state. For a simpler estimate without data hook effects, use `currentTotalReclaimableSurplusOf(projectId, cashOutCount, decimals, currency)` or the 6-param `currentReclaimableSurplusOf` overload.
101
+
98
102
  **Edge cases**:
99
103
  - `cashOutCount = 0` with `totalSupply = 0` -- returns entire surplus (C-5 known bug)
100
104
  - `cashOutTaxRate = MAX (10,000)` -- returns 0 (all surplus locked)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bananapus/core-v6",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",