@bananapus/core-v6 0.0.21 → 0.0.23

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 (48) hide show
  1. package/ADMINISTRATION.md +0 -1
  2. package/AUDIT_INSTRUCTIONS.md +1 -1
  3. package/CHANGE_LOG.md +3 -3
  4. package/RISKS.md +3 -3
  5. package/SKILLS.md +8 -8
  6. package/USER_JOURNEYS.md +1 -1
  7. package/foundry.toml +0 -1
  8. package/package.json +1 -1
  9. package/src/JBMultiTerminal.sol +92 -192
  10. package/src/JBTerminalStore.sol +414 -256
  11. package/src/interfaces/IJBMultiTerminal.sol +0 -4
  12. package/src/interfaces/IJBTerminal.sol +4 -4
  13. package/src/interfaces/IJBTerminalStore.sol +65 -33
  14. package/src/libraries/JBPayoutSplitGroupLib.sol +0 -1
  15. package/src/libraries/JBSurplus.sol +3 -4
  16. package/test/ComprehensiveInvariant.t.sol +5 -7
  17. package/test/CoreExploitTests.t.sol +18 -23
  18. package/test/TestCashOut.sol +6 -6
  19. package/test/TestMultiTerminalSurplus.sol +4 -4
  20. package/test/TestMultiTokenSurplus.sol +6 -23
  21. package/test/TestTerminalMigration.sol +2 -7
  22. package/test/fork/TestSequencerPriceFeedFork.sol +1 -1
  23. package/test/fork/TestTerminalPreviewParityFork.sol +0 -1
  24. package/test/invariants/TerminalStoreInvariant.t.sol +5 -7
  25. package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +1 -2
  26. package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +23 -24
  27. package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +79 -119
  28. package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +33 -26
  29. package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +32 -27
  30. package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +22 -4
  31. package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +8 -5
  32. package/test/units/static/JBMultiTerminal/TestPay.sol +41 -33
  33. package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +19 -18
  34. package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +38 -22
  35. package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +9 -6
  36. package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +4 -4
  37. package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +37 -32
  38. package/test/units/static/JBSurplus/TestSurplusFuzz.sol +5 -20
  39. package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +17 -0
  40. package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +120 -246
  41. package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +29 -7
  42. package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +88 -20
  43. package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +30 -29
  44. package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +46 -16
  45. package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +24 -53
  46. package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +24 -4
  47. package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +14 -4
  48. package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +21 -3
@@ -19,17 +19,7 @@ contract MockSurplusTerminal is ERC165, IJBCashOutTerminal {
19
19
  surplusAmount = _surplus;
20
20
  }
21
21
 
22
- function currentSurplusOf(
23
- uint256,
24
- JBAccountingContext[] memory,
25
- uint256,
26
- uint256
27
- )
28
- external
29
- view
30
- override
31
- returns (uint256)
32
- {
22
+ function currentSurplusOf(uint256, address[] calldata, uint256, uint256) external view override returns (uint256) {
33
23
  return surplusAmount;
34
24
  }
35
25
 
@@ -131,9 +121,8 @@ contract TestSurplusFuzz_Local is JBTest {
131
121
  /// @notice Surplus with no terminals is 0.
132
122
  function testFuzz_noTerminals_returnsZero(uint256 projectId) external view {
133
123
  IJBTerminal[] memory terminals = new IJBTerminal[](0);
134
- JBAccountingContext[] memory contexts = new JBAccountingContext[](0);
135
124
 
136
- uint256 surplus = JBSurplus.currentSurplusOf(projectId, terminals, contexts, 18, 1);
125
+ uint256 surplus = JBSurplus.currentSurplusOf(projectId, terminals, new address[](0), 18, 1);
137
126
  assertEq(surplus, 0, "surplus with no terminals should be 0");
138
127
  }
139
128
 
@@ -146,9 +135,7 @@ contract TestSurplusFuzz_Local is JBTest {
146
135
  terminals[0] = terminal1;
147
136
  terminals[1] = terminal2;
148
137
 
149
- JBAccountingContext[] memory contexts = new JBAccountingContext[](0);
150
-
151
- uint256 total = JBSurplus.currentSurplusOf(1, terminals, contexts, 18, 1);
138
+ uint256 total = JBSurplus.currentSurplusOf(1, terminals, new address[](0), 18, 1);
152
139
  assertEq(total, uint256(surplus1) + uint256(surplus2), "surplus should be sum of all terminals");
153
140
  }
154
141
 
@@ -165,10 +152,8 @@ contract TestSurplusFuzz_Local is JBTest {
165
152
  IJBTerminal[] memory terminals2 = new IJBTerminal[](1);
166
153
  terminals2[0] = terminal2;
167
154
 
168
- JBAccountingContext[] memory contexts = new JBAccountingContext[](0);
169
-
170
- uint256 total1 = JBSurplus.currentSurplusOf(1, terminals1, contexts, 18, 1);
171
- uint256 total2 = JBSurplus.currentSurplusOf(1, terminals2, contexts, 18, 1);
155
+ uint256 total1 = JBSurplus.currentSurplusOf(1, terminals1, new address[](0), 18, 1);
156
+ uint256 total2 = JBSurplus.currentSurplusOf(1, terminals2, new address[](0), 18, 1);
172
157
 
173
158
  assertLe(total1, total2, "surplus should be monotonically increasing");
174
159
  }
@@ -4,8 +4,10 @@ pragma solidity 0.8.26;
4
4
  import {JBTerminalStore} from "../../../../src/JBTerminalStore.sol";
5
5
  import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
6
6
  import {IJBPrices} from "../../../../src/interfaces/IJBPrices.sol";
7
+ import {IJBRulesetApprovalHook} from "../../../../src/interfaces/IJBRulesetApprovalHook.sol";
7
8
  import {IJBRulesets} from "../../../../src/interfaces/IJBRulesets.sol";
8
9
  import {IJBTerminalStore} from "../../../../src/interfaces/IJBTerminalStore.sol";
10
+ import {JBRuleset} from "../../../../src/structs/JBRuleset.sol";
9
11
  import {JBTest} from "../../../helpers/JBTest.sol";
10
12
 
11
13
  /*
@@ -24,5 +26,20 @@ contract JBTerminalStoreSetup is JBTest {
24
26
  function terminalStoreSetup() public virtual {
25
27
  // Instantiate the contract being tested
26
28
  _store = new JBTerminalStore(directory, prices, rulesets);
29
+
30
+ // Default mock: allow adding accounting contexts (return zero-id ruleset to bypass the
31
+ // allowAddAccountingContext check in recordAccountingContextOf).
32
+ JBRuleset memory _zeroRuleset = JBRuleset({
33
+ cycleNumber: 0,
34
+ id: 0,
35
+ basedOnId: 0,
36
+ start: 0,
37
+ duration: 0,
38
+ weight: 0,
39
+ weightCutPercent: 0,
40
+ approvalHook: IJBRulesetApprovalHook(address(0)),
41
+ metadata: 0
42
+ });
43
+ vm.mockCall(address(rulesets), abi.encodeWithSelector(IJBRulesets.currentOf.selector), abi.encode(_zeroRuleset));
27
44
  }
28
45
  }