@bananapus/core-v6 0.0.35 → 0.0.36

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/USER_JOURNEYS.md CHANGED
@@ -2,32 +2,30 @@
2
2
 
3
3
  ## Repo Purpose
4
4
 
5
- This repo is the canonical Juicebox V6 runtime surface.
6
- It owns project identity, rulesets, terminal execution, treasury accounting, permissions, price feeds, and migration
7
- paths. Most other V6 repos wrap or extend this behavior rather than replacing it.
5
+ This repo is the main runtime surface for Juicebox V6. It owns project identity, rulesets, terminal execution, treasury accounting, permissions, price feeds, and migration paths. Most other V6 repos build on this behavior instead of replacing it.
8
6
 
9
7
  ## Primary Actors
10
8
 
11
- - founders launching and evolving Juicebox projects
12
- - supporters paying projects in the asset a terminal accepts
9
+ - founders launching and updating Juicebox projects
10
+ - supporters paying projects in assets that a terminal accepts
13
11
  - token holders cashing out against project surplus
14
12
  - operators managing permissions, splits, fund access limits, and rulesets
15
- - integrators wiring hooks, terminals, price feeds, and migrations into the canonical protocol surface
13
+ - integrators wiring hooks, terminals, price feeds, and migrations into core
16
14
 
17
15
  ## Key Surfaces
18
16
 
19
17
  - `JBController`: project launch, ruleset queueing, token setup, splits, and controller migration
20
- - `JBMultiTerminal`: pay, payout, allowance, preview, and cash-out entrypoint
18
+ - `JBMultiTerminal`: pay, payout, allowance, preview, and cash-out entrypoints
21
19
  - `JBTerminalStore`: balance, surplus, fee, and reclaim accounting
22
20
  - `JBDirectory`: controller and terminal routing
23
21
  - `JBPermissions`: packed operator-permission registry
24
22
  - `JBProjects`, `JBRulesets`, `JBPrices`, `JBFundAccessLimits`, `JBSplits`, `JBTokens`: core state and helper surfaces
25
23
 
26
- ## Journey 1: Launch A Project With The Right Initial Shape
24
+ ## Journey 1: Launch A Project With The Right Initial Setup
27
25
 
28
26
  **Actor:** founder, deployer, or protocol integrator.
29
27
 
30
- **Intent:** create a project with the right owner, terminal, ruleset, and hook assumptions from block zero.
28
+ **Intent:** create a project with the right owner, terminal, ruleset, and hook assumptions from the start.
31
29
 
32
30
  **Preconditions**
33
31
  - the team knows who should own the project, which terminals it should use, and what the first ruleset should allow
@@ -35,20 +33,20 @@ paths. Most other V6 repos wrap or extend this behavior rather than replacing it
35
33
  **Main Flow**
36
34
  1. Call `JBController.launchProjectFor(...)` with the owner, URI, ruleset config, terminal configs, and any split or hook metadata.
37
35
  2. `JBProjects` mints the project NFT, `JBDirectory` records controller and terminal routing, and `JBRulesets` stores the first ruleset.
38
- 3. If the project wants ERC-20 tokens, reserved-rate behavior, or hook-driven behavior, that configuration is committed at launch instead of being inferred later.
36
+ 3. If the project wants ERC-20 tokens, reserved-rate behavior, or hook-driven behavior, that configuration is set at launch.
39
37
  4. The project can now accept payments and queue future rulesets without changing project identity.
40
38
 
41
39
  **Failure Modes**
42
40
  - accounting contexts do not match the intended terminal asset
43
41
  - hook metadata or split assumptions are invalid at launch
44
- - ownership or permission assumptions are wrong and expensive to repair later
42
+ - ownership or permission assumptions are wrong and expensive to fix later
45
43
 
46
44
  **Postconditions**
47
- - the project NFT exists, the initial ruleset is active, accepted terminals are installed, and downstream hooks or splits can begin working immediately
45
+ - the project NFT exists, the first ruleset is active, accepted terminals are installed, and hooks or splits can start immediately
48
46
 
49
47
  ## Journey 2: Accept A Payment And Issue The Right Token Exposure
50
48
 
51
- **Actor:** payer or integration paying on a user's behalf.
49
+ **Actor:** payer or integration paying for a user.
52
50
 
53
51
  **Intent:** settle a payment through the canonical terminal path and issue the correct token exposure.
54
52
 
@@ -58,18 +56,18 @@ paths. Most other V6 repos wrap or extend this behavior rather than replacing it
58
56
  **Main Flow**
59
57
  1. A payer calls `pay(...)` on `JBMultiTerminal`.
60
58
  2. The terminal validates the accounting context, records funds, and asks `JBTerminalStore` to derive issuance from the active ruleset.
61
- 3. `JBController` and `JBTokens` decide whether the beneficiary gets project token credits, ERC-20s, or no issuance because weight is zero.
59
+ 3. `JBController` and `JBTokens` decide whether the beneficiary gets project credits, ERC-20s, or no issuance because weight is zero.
62
60
  4. Any configured pay hooks or data hooks run around the accounting path.
63
61
 
64
62
  **Failure Modes**
65
63
  - payments are paused or the token is unsupported for the target accounting context
66
64
  - fee-on-transfer behavior or price-feed assumptions break the intended issuance path
67
- - hooks add side effects the payer or integrator did not account for
65
+ - hooks add side effects that the payer or integrator did not account for
68
66
 
69
67
  **Postconditions**
70
- - treasury balances increase, hooks run in the right order, and the beneficiary receives credits or ERC-20 tokens consistent with the ruleset
68
+ - treasury balances increase, hooks run in the right order, and the beneficiary receives credits or ERC-20 tokens that match the ruleset
71
69
 
72
- ## Journey 3: Turn Credits Into ERC-20 Tokens Once A Project Wants A Transferable Token
70
+ ## Journey 3: Turn Credits Into ERC-20 Tokens
73
71
 
74
72
  **Actor:** holder or operator acting for a holder.
75
73
 
@@ -82,30 +80,30 @@ paths. Most other V6 repos wrap or extend this behavior rather than replacing it
82
80
  **Main Flow**
83
81
  1. Deploy or set the project's ERC-20 token through `JBController`.
84
82
  2. Holders or operators call `claimTokensFor(...)` to convert credits into ERC-20 balances for a beneficiary.
85
- 3. Future issuance can continue using the same project identity while users now interact with a standard token surface.
83
+ 3. Future issuance can continue under the same project identity while users now interact with a standard token surface.
86
84
 
87
85
  **Failure Modes**
88
86
  - the wrong token is installed for the project
89
- - integrations assume credits are automatically ERC-20 balances after token installation
87
+ - integrations assume credits automatically become ERC-20 balances after token installation
90
88
 
91
89
  **Postconditions**
92
- - the project deploys or installs its ERC-20 token and holders can claim credits into transferable balances
90
+ - the project has an ERC-20 token and holders can claim credits into transferable balances
93
91
 
94
92
  ## Journey 4: Distribute Treasury Funds Through Governed Paths
95
93
 
96
94
  **Actor:** owner or authorized operator.
97
95
 
98
- **Intent:** move value out of the treasury through configured payouts or allowance surfaces.
96
+ **Intent:** move value out of the treasury through configured payout or allowance paths.
99
97
 
100
98
  **Preconditions**
101
99
  - the project has terminal balances
102
100
  - the caller is allowed to use payout or allowance paths
103
101
 
104
102
  **Main Flow**
105
- 1. Authorized actors call payout or allowance surfaces on the terminal.
103
+ 1. An authorized caller uses payout or allowance entrypoints on the terminal.
106
104
  2. `JBFundAccessLimits` bounds how much may leave for the current ruleset cycle.
107
- 3. `JBSplits` fans value out to beneficiaries, projects, hooks, or fee recipients as configured.
108
- 4. `JBTerminalStore` updates balances and fee accounting so later previews and cash outs remain consistent.
105
+ 3. `JBSplits` routes value to beneficiaries, projects, hooks, or fee recipients as configured.
106
+ 4. `JBTerminalStore` updates balances and fee accounting so later previews and cash outs stay consistent.
109
107
 
110
108
  **Failure Modes**
111
109
  - splits or access limits no longer match operator expectations
@@ -113,7 +111,7 @@ paths. Most other V6 repos wrap or extend this behavior rather than replacing it
113
111
  - operators assume allowance withdrawals behave exactly like payouts when fee treatment differs
114
112
 
115
113
  **Postconditions**
116
- - treasury value leaves only through configured limits, recipients, and fee logic instead of arbitrary admin withdrawals
114
+ - value leaves the treasury only through configured limits, recipients, and fee logic
117
115
 
118
116
  ## Journey 5: Let Holders Cash Out Against Surplus
119
117
 
@@ -127,42 +125,42 @@ paths. Most other V6 repos wrap or extend this behavior rather than replacing it
127
125
 
128
126
  **Main Flow**
129
127
  1. The holder calls `cashOutTokensOf(...)` on the relevant terminal.
130
- 2. `JBTerminalStore` calculates reclaim value using surplus, outstanding token supply, cash-out tax rate, and any pending reserved token effects.
131
- 3. Cash-out hooks can modify behavior or side effects, but the core accounting remains anchored in the terminal store.
132
- 4. Tokens burn and value exits the treasury through the terminal that actually held the asset.
128
+ 2. `JBTerminalStore` calculates reclaim value using surplus, total supply, cash-out tax rate, and any pending reserved-token effects.
129
+ 3. Cash-out hooks can change behavior or side effects, but core accounting still comes from the terminal store.
130
+ 4. Tokens burn and value exits the treasury through the terminal that held the asset.
133
131
 
134
132
  **Failure Modes**
135
133
  - fee-free or custom hook paths produce different outcomes than the holder expected
136
- - preview-versus-execution drift appears under volatile routing or multi-terminal liquidity
137
- - users misread multi-terminal surplus as one homogeneous pool
134
+ - preview and execution drift under changing routing or multi-terminal liquidity
135
+ - users treat multi-terminal surplus like one simple pool when it is not
138
136
 
139
137
  **Postconditions**
140
- - the holder burns the intended amount of token exposure and receives the correct reclaim amount under the current ruleset
138
+ - the holder burns the intended token exposure and receives the reclaim amount allowed by the current ruleset
141
139
 
142
140
  ## Journey 6: Queue New Rulesets Without Migrating The Project
143
141
 
144
142
  **Actor:** owner or authorized operator.
145
143
 
146
- **Intent:** change future project economics without changing the project's identity or existing balances.
144
+ **Intent:** change future project economics without changing identity or existing balances.
147
145
 
148
146
  **Preconditions**
149
147
  - the project is live and future economics need to change
150
148
 
151
149
  **Main Flow**
152
- 1. The owner or an operator with the right permission queues one or more new rulesets through `JBController`.
153
- 2. `JBRulesets` stores the proposed future configuration and any approval hook requirements.
154
- 3. When the active duration elapses, the next approved ruleset becomes live and future pays, payouts, and cash outs follow the new terms.
155
- 4. Existing balances and token history remain intact because only future behavior changed.
150
+ 1. The owner or an allowed operator queues one or more new rulesets through `JBController`.
151
+ 2. `JBRulesets` stores the future configuration and any approval-hook requirements.
152
+ 3. When the active duration ends, the next approved ruleset becomes live and later pays, payouts, and cash outs follow the new terms.
153
+ 4. Existing balances and token history stay intact because only future behavior changed.
156
154
 
157
155
  **Failure Modes**
158
156
  - approval-hook requirements are forgotten or misunderstood
159
157
  - queued metadata is incompatible with installed hooks
160
- - teams assume a ruleset change can retroactively fix prior accounting
158
+ - teams assume a ruleset change can fix past accounting
161
159
 
162
160
  **Postconditions**
163
- - the next ruleset activates on schedule while the project keeps the same identity, treasury, and downstream integrations
161
+ - the next ruleset activates on schedule while the project keeps the same identity, treasury, and integrations
164
162
 
165
- ## Journey 7: Migrate A Project To New Terminal Or Controller Surfaces Deliberately
163
+ ## Journey 7: Migrate To New Terminal Or Controller Surfaces
166
164
 
167
165
  **Actor:** owner or migration operator.
168
166
 
@@ -173,13 +171,13 @@ paths. Most other V6 repos wrap or extend this behavior rather than replacing it
173
171
  - the destination surface is understood and intended
174
172
 
175
173
  **Main Flow**
176
- 1. Confirm the active ruleset permits migration and the destination surface is the intended successor.
174
+ 1. Confirm the active ruleset allows migration and the destination is the intended successor.
177
175
  2. Use `JBController.migrate(...)` and the terminal-store migration paths instead of manually repointing addresses.
178
- 3. Recheck directory routing and accepted accounting contexts after migration completes.
176
+ 3. Recheck directory routing and accepted accounting contexts after migration.
179
177
 
180
178
  **Failure Modes**
181
- - migration targets are wrong or only partially configured
182
- - operators manually repoint routing without using the protocol's migration surfaces
179
+ - migration targets are wrong or only partly configured
180
+ - operators manually repoint routing without using protocol migration paths
183
181
 
184
182
  **Postconditions**
185
183
  - balances, permissions, and future routing stay coherent after migration
@@ -188,7 +186,7 @@ paths. Most other V6 repos wrap or extend this behavior rather than replacing it
188
186
 
189
187
  **Actor:** project owner.
190
188
 
191
- **Intent:** delegate project operations narrowly instead of transferring blanket control.
189
+ **Intent:** delegate narrow project operations instead of blanket control.
192
190
 
193
191
  **Preconditions**
194
192
  - the owner wants operators, delegates, or automation to manage only specific surfaces
@@ -196,10 +194,10 @@ paths. Most other V6 repos wrap or extend this behavior rather than replacing it
196
194
  **Main Flow**
197
195
  1. The owner configures operator permissions in `JBPermissions`.
198
196
  2. Downstream calls check those packed permission bits instead of assuming project ownership.
199
- 3. Integrations such as ownable wrappers, hook deployers, and router registries can now respect project-scoped delegation without custom ACL logic.
197
+ 3. Ownable wrappers, hook deployers, and router registries can respect project-scoped delegation without custom ACL logic.
200
198
 
201
199
  **Failure Modes**
202
- - operators receive permissions broader than they need
200
+ - operators receive broader permissions than they need
203
201
  - auditors assume downstream access still depends only on project ownership
204
202
 
205
203
  **Postconditions**
@@ -207,11 +205,11 @@ paths. Most other V6 repos wrap or extend this behavior rather than replacing it
207
205
 
208
206
  ## Trust Boundaries
209
207
 
210
- - `JBTerminalStore` is the accounting truth for balances, surplus, fees, and reclaim behavior
211
- - hooks, approval hooks, pay hooks, and cash-out hooks are trusted extension surfaces, not cosmetic plugins
212
- - price feeds and directory routing are critical external-context surfaces inherited by many downstream repos
208
+ - `JBTerminalStore` is the accounting source of truth for balances, surplus, fees, and reclaim behavior
209
+ - hooks, approval hooks, pay hooks, and cash-out hooks are trusted extension surfaces
210
+ - price feeds and directory routing are critical shared-context surfaces
213
211
 
214
212
  ## Hand-Offs
215
213
 
216
- - Use [nana-permission-ids-v6](../nana-permission-ids-v6/USER_JOURNEYS.md) for the shared permission vocabulary that downstream repos import.
217
- - Use [nana-721-hook-v6](../nana-721-hook-v6/USER_JOURNEYS.md), [nana-router-terminal-v6](../nana-router-terminal-v6/USER_JOURNEYS.md), and [nana-buyback-hook-v6](../nana-buyback-hook-v6/USER_JOURNEYS.md) for opinionated layers on top of the core terminal and ruleset surfaces.
214
+ - Use [nana-permission-ids-v6](../nana-permission-ids-v6/USER_JOURNEYS.md) for the shared permission vocabulary used by downstream repos.
215
+ - Use [nana-721-hook-v6](../nana-721-hook-v6/USER_JOURNEYS.md), [nana-router-terminal-v6](../nana-router-terminal-v6/USER_JOURNEYS.md), and [nana-buyback-hook-v6](../nana-buyback-hook-v6/USER_JOURNEYS.md) for opinionated layers built on the core terminal and ruleset surfaces.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bananapus/core-v6",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1146,6 +1146,20 @@ contract TestAccessToFunds_Local is TestBaseWorkflow {
1146
1146
  : _nativePayAmount - _nativeCurrencyPayoutLimit > 1
1147
1147
  );
1148
1148
 
1149
+ // Skip inputs where cross-currency payout limit rounding could flip the revert/succeed outcome.
1150
+ // The test's `_toNative` helper may round differently than the contract's multi-step conversion
1151
+ // (which uses 18-decimal intermediate fidelity). A 1 wei difference at the boundary is enough
1152
+ // to cause the test to expect a revert that doesn't happen, or vice versa.
1153
+ {
1154
+ uint256 _nativePLTotal = uint256(_nativeCurrencyPayoutLimit) + _toNative(_usdCurrencyPayoutLimit);
1155
+ uint256 _predicted = uint256(_nativeCurrencySurplusAllowance) + _nativePLTotal;
1156
+ // If the predicted total is within 2 of the pay amount, rounding can go either way.
1157
+ if (_predicted > _nativePayAmount ? _predicted - _nativePayAmount <= 2 : _nativePayAmount - _predicted <= 2)
1158
+ {
1159
+ vm.assume(false);
1160
+ }
1161
+ }
1162
+
1149
1163
  {
1150
1164
  // Package up the limits for the given terminal.
1151
1165
  JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](1);
@@ -1371,6 +1385,16 @@ contract TestAccessToFunds_Local is TestBaseWorkflow {
1371
1385
  && _toNative(_usdCurrencySurplusAllowance + _usdCurrencyPayoutLimit) + _nativeCurrencyPayoutLimit
1372
1386
  + _nativeCurrencySurplusAllowance > _nativePayAmount
1373
1387
  ) {
1388
+ // Skip inputs near the rounding boundary for the second allowance call too.
1389
+ {
1390
+ uint256 _predicted2 = _toNative(_usdCurrencySurplusAllowance + _usdCurrencyPayoutLimit)
1391
+ + _nativeCurrencyPayoutLimit + _nativeCurrencySurplusAllowance;
1392
+ if (_predicted2 > _nativePayAmount
1393
+ ? _predicted2 - _nativePayAmount <= 2
1394
+ : _nativePayAmount - _predicted2 <= 2) {
1395
+ return; // Too close to boundary — rounding may differ between test helper and contract.
1396
+ }
1397
+ }
1374
1398
  vm.expectRevert(
1375
1399
  abi.encodeWithSelector(
1376
1400
  JBTerminalStore.JBTerminalStore_InadequateTerminalStoreBalance.selector,