@bananapus/core-v6 0.0.15 → 0.0.17

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 (231) hide show
  1. package/ADMINISTRATION.md +5 -1
  2. package/ARCHITECTURE.md +2 -1
  3. package/AUDIT_INSTRUCTIONS.md +342 -0
  4. package/CHANGE_LOG.md +375 -0
  5. package/README.md +6 -6
  6. package/RISKS.md +171 -50
  7. package/SKILLS.md +11 -6
  8. package/STYLE_GUIDE.md +16 -2
  9. package/USER_JOURNEYS.md +622 -0
  10. package/package.json +2 -2
  11. package/script/Deploy.s.sol +22 -13
  12. package/script/DeployPeriphery.s.sol +76 -52
  13. package/script/helpers/CoreDeploymentLib.sol +83 -35
  14. package/src/JBChainlinkV3PriceFeed.sol +1 -0
  15. package/src/JBController.sol +23 -3
  16. package/src/JBDeadline.sol +3 -0
  17. package/src/JBDirectory.sol +2 -1
  18. package/src/JBERC20.sol +12 -3
  19. package/src/JBFundAccessLimits.sol +12 -2
  20. package/src/JBMultiTerminal.sol +53 -10
  21. package/src/JBPermissions.sol +3 -0
  22. package/src/JBPrices.sol +8 -2
  23. package/src/JBProjects.sol +1 -1
  24. package/src/JBRulesets.sol +14 -0
  25. package/src/JBSplits.sol +14 -5
  26. package/src/JBTerminalStore.sol +57 -47
  27. package/src/JBTokens.sol +43 -4
  28. package/src/interfaces/IJBController.sol +6 -0
  29. package/src/interfaces/IJBPermitTerminal.sol +1 -0
  30. package/src/interfaces/IJBTerminalStore.sol +3 -0
  31. package/src/interfaces/IJBToken.sol +5 -0
  32. package/src/interfaces/IJBTokens.sol +13 -0
  33. package/src/libraries/JBFees.sol +2 -0
  34. package/src/libraries/JBMetadataResolver.sol +24 -7
  35. package/src/libraries/JBRulesetMetadataResolver.sol +21 -21
  36. package/src/structs/JBAccountingContext.sol +1 -0
  37. package/src/structs/JBAfterCashOutRecordedContext.sol +1 -0
  38. package/src/structs/JBAfterPayRecordedContext.sol +1 -0
  39. package/src/structs/JBBeforeCashOutRecordedContext.sol +5 -0
  40. package/src/structs/JBBeforePayRecordedContext.sol +1 -0
  41. package/src/structs/JBCashOutHookSpecification.sol +1 -0
  42. package/src/structs/JBCurrencyAmount.sol +1 -0
  43. package/src/structs/JBFee.sol +1 -0
  44. package/src/structs/JBFundAccessLimitGroup.sol +1 -0
  45. package/src/structs/JBPayHookSpecification.sol +1 -0
  46. package/src/structs/JBPermissionsData.sol +1 -0
  47. package/src/structs/JBRuleset.sol +1 -0
  48. package/src/structs/JBRulesetConfig.sol +1 -0
  49. package/src/structs/JBRulesetMetadata.sol +1 -0
  50. package/src/structs/JBRulesetWeightCache.sol +1 -0
  51. package/src/structs/JBRulesetWithMetadata.sol +1 -0
  52. package/src/structs/JBSingleAllowance.sol +1 -0
  53. package/src/structs/JBSplit.sol +1 -0
  54. package/src/structs/JBSplitGroup.sol +1 -0
  55. package/src/structs/JBSplitHookContext.sol +1 -0
  56. package/src/structs/JBTerminalConfig.sol +1 -0
  57. package/src/structs/JBTokenAmount.sol +1 -0
  58. package/test/ComprehensiveInvariant.t.sol +15 -2
  59. package/test/CoreExploitTests.t.sol +34 -1
  60. package/test/EconomicSimulation.t.sol +10 -2
  61. package/test/EntryPointPermutations.t.sol +17 -3
  62. package/test/FlashLoanAttacks.t.sol +12 -1
  63. package/test/PermissionEscalation.t.sol +53 -10
  64. package/test/RulesetTransitions.t.sol +15 -1
  65. package/test/SplitLoopTests.t.sol +25 -2
  66. package/test/TestAccessToFunds.sol +17 -2
  67. package/test/TestAuditResponseDesignProofs.sol +434 -0
  68. package/test/TestCashOut.sol +15 -1
  69. package/test/TestCashOutCountFor.sol +1 -1
  70. package/test/TestCashOutHooks.sol +47 -25
  71. package/test/TestCashOutTimingEdge.sol +13 -1
  72. package/test/TestDataHookFuzzing.sol +520 -0
  73. package/test/TestDurationUnderflow.sol +13 -1
  74. package/test/TestFeeFreeCashOutBypass.sol +617 -0
  75. package/test/TestFeeProcessingFailure.sol +16 -1
  76. package/test/TestFees.sol +14 -1
  77. package/test/TestInterfaceSupport.sol +20 -1
  78. package/test/TestJBERC20Inheritance.sol +11 -1
  79. package/test/TestL2SequencerPriceFeed.sol +292 -0
  80. package/test/TestLaunchProject.sol +13 -1
  81. package/test/TestMetaTx.sol +15 -1
  82. package/test/TestMetadataOffsetOverflow.sol +179 -0
  83. package/test/TestMetadataParserLib.sol +37 -4
  84. package/test/TestMigrationHeldFees.sol +16 -1
  85. package/test/TestMintTokensOf.sol +14 -1
  86. package/test/TestMultiTerminalSurplus.sol +348 -0
  87. package/test/TestMultiTokenSurplus.sol +14 -1
  88. package/test/TestMultipleAccessLimits.sol +23 -1
  89. package/test/TestPayBurnRedeemFlow.sol +16 -1
  90. package/test/TestPayHooks.sol +33 -14
  91. package/test/TestPermissions.sol +20 -1
  92. package/test/TestPermissionsEdge.sol +5 -1
  93. package/test/TestPermit2DataHook.t.sol +360 -0
  94. package/test/TestPermit2Terminal.sol +36 -3
  95. package/test/TestRulesetQueueing.sol +23 -1
  96. package/test/TestRulesetQueuingStress.sol +20 -1
  97. package/test/TestRulesetWeightCaching.sol +127 -125
  98. package/test/TestSplits.sol +23 -1
  99. package/test/TestTerminalMigration.sol +11 -1
  100. package/test/TestTokenFlow.sol +18 -1
  101. package/test/TestWeightCacheStaleAfterRejection.sol +15 -1
  102. package/test/WeirdTokenTests.t.sol +54 -1
  103. package/test/fork/TestChainlinkPriceFeedFork.sol +6 -1
  104. package/test/formal/BondingCurveProperties.t.sol +8 -1
  105. package/test/formal/FeeProperties.t.sol +7 -1
  106. package/test/helpers/JBTest.sol +1 -1
  107. package/test/helpers/TestBaseWorkflow.sol +84 -1
  108. package/test/invariants/Phase3DeepInvariant.t.sol +13 -2
  109. package/test/invariants/RulesetsInvariant.t.sol +12 -2
  110. package/test/invariants/TerminalStoreInvariant.t.sol +11 -2
  111. package/test/invariants/TokensInvariant.t.sol +13 -2
  112. package/test/invariants/handlers/ComprehensiveHandler.sol +19 -1
  113. package/test/invariants/handlers/EconomicHandler.sol +31 -1
  114. package/test/invariants/handlers/Phase3Handler.sol +31 -1
  115. package/test/invariants/handlers/RulesetsHandler.sol +5 -1
  116. package/test/invariants/handlers/TerminalStoreHandler.sol +6 -1
  117. package/test/invariants/handlers/TokensHandler.sol +1 -1
  118. package/test/mock/MockERC20.sol +0 -2
  119. package/test/mock/MockMaliciousBeneficiary.sol +2 -1
  120. package/test/mock/MockMaliciousSplitHook.sol +2 -1
  121. package/test/mock/MockPriceFeed.sol +1 -1
  122. package/test/regression/HoldFeesCashOutReserved.t.sol +415 -0
  123. package/test/regression/WeightCacheBoundary.t.sol +291 -0
  124. package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -1
  125. package/test/units/static/JBController/JBControllerSetup.sol +10 -1
  126. package/test/units/static/JBController/TestBurnTokensOf.sol +8 -1
  127. package/test/units/static/JBController/TestClaimTokensFor.sol +4 -1
  128. package/test/units/static/JBController/TestDeployErc20For.sol +7 -1
  129. package/test/units/static/JBController/TestLaunchProjectFor.sol +21 -1
  130. package/test/units/static/JBController/TestLaunchRulesetsFor.sol +21 -1
  131. package/test/units/static/JBController/TestMigrateController.sol +10 -1
  132. package/test/units/static/JBController/TestMintTokensOfUnits.sol +10 -1
  133. package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +4 -1
  134. package/test/units/static/JBController/TestReceiveMigrationFrom.sol +5 -1
  135. package/test/units/static/JBController/TestRulesetViews.sol +7 -1
  136. package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +21 -1
  137. package/test/units/static/JBController/TestSetSplitGroupsOf.sol +6 -1
  138. package/test/units/static/JBController/TestSetTokenFor.sol +13 -1
  139. package/test/units/static/JBController/TestSetUriOf.sol +5 -1
  140. package/test/units/static/JBController/TestTransferCreditsFrom.sol +11 -1
  141. package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +12 -1
  142. package/test/units/static/JBDirectory/JBDirectorySetup.sol +4 -1
  143. package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +5 -1
  144. package/test/units/static/JBDirectory/TestSetControllerOf.sol +11 -1
  145. package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +7 -1
  146. package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +11 -1
  147. package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +10 -1
  148. package/test/units/static/JBERC20/JBERC20Setup.sol +2 -1
  149. package/test/units/static/JBERC20/SigUtils.sol +2 -0
  150. package/test/units/static/JBERC20/TestInitialize.sol +1 -1
  151. package/test/units/static/JBERC20/TestName.sol +1 -1
  152. package/test/units/static/JBERC20/TestNonces.sol +3 -1
  153. package/test/units/static/JBERC20/TestSymbol.sol +1 -1
  154. package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +2 -1
  155. package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +2 -1
  156. package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +1 -1
  157. package/test/units/static/JBFees/TestFeesFuzz.sol +1 -1
  158. package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -1
  159. package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -1
  160. package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +3 -1
  161. package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +4 -1
  162. package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +4 -1
  163. package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +8 -1
  164. package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +8 -1
  165. package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +4 -1
  166. package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +7 -1
  167. package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +1 -1
  168. package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +2 -1
  169. package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +2 -1
  170. package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +12 -1
  171. package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +9 -1
  172. package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +18 -2
  173. package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +44 -9
  174. package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +48 -23
  175. package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +18 -2
  176. package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +13 -3
  177. package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +21 -4
  178. package/test/units/static/JBMultiTerminal/TestPay.sol +35 -7
  179. package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +206 -19
  180. package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +15 -1
  181. package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +297 -1
  182. package/test/units/static/JBPermissions/JBPermissionsSetup.sol +2 -1
  183. package/test/units/static/JBPermissions/TestHasPermission.sol +1 -1
  184. package/test/units/static/JBPermissions/TestHasPermissions.sol +1 -1
  185. package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +3 -1
  186. package/test/units/static/JBPrices/JBPricesSetup.sol +6 -1
  187. package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +6 -1
  188. package/test/units/static/JBPrices/TestPricePerUnitOf.sol +4 -1
  189. package/test/units/static/JBPrices/TestPrices.sol +4 -1
  190. package/test/units/static/JBProjects/JBProjectsSetup.sol +2 -1
  191. package/test/units/static/JBProjects/TestCreateFor.sol +3 -1
  192. package/test/units/static/JBProjects/TestInitialProject.sol +2 -1
  193. package/test/units/static/JBProjects/TestInterfaces.sol +0 -1
  194. package/test/units/static/JBProjects/TestSetResolver.sol +2 -1
  195. package/test/units/static/JBProjects/TestTokenUri.sol +3 -1
  196. package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +9 -1
  197. package/test/units/static/JBRulesets/JBRulesetsSetup.sol +3 -1
  198. package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +9 -1
  199. package/test/units/static/JBRulesets/TestCurrentOf.sol +10 -1
  200. package/test/units/static/JBRulesets/TestGetRulesetOf.sol +7 -1
  201. package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +9 -1
  202. package/test/units/static/JBRulesets/TestRulesets.sol +12 -1
  203. package/test/units/static/JBRulesets/TestRulesetsOf.sol +1 -1
  204. package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +10 -1
  205. package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +6 -1
  206. package/test/units/static/JBSplits/JBSplitsSetup.sol +3 -1
  207. package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +63 -13
  208. package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +8 -1
  209. package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +6 -1
  210. package/test/units/static/JBSplits/TestSplitsOf.sol +1 -1
  211. package/test/units/static/JBSplits/TestSplitsPacking.sol +5 -2
  212. package/test/units/static/JBSurplus/TestSurplusFuzz.sol +3 -1
  213. package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +5 -1
  214. package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +14 -1
  215. package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +14 -1
  216. package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +3 -1
  217. package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +92 -1
  218. package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +15 -1
  219. package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +13 -1
  220. package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +8 -1
  221. package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +16 -1
  222. package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +15 -1
  223. package/test/units/static/JBTokens/JBTokensSetup.sol +5 -1
  224. package/test/units/static/JBTokens/TestBurnFrom.sol +4 -1
  225. package/test/units/static/JBTokens/TestClaimTokensFor.sol +4 -1
  226. package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +4 -1
  227. package/test/units/static/JBTokens/TestMintFor.sol +4 -1
  228. package/test/units/static/JBTokens/TestSetTokenFor.sol +4 -1
  229. package/test/units/static/JBTokens/TestTotalBalanceOf.sol +1 -1
  230. package/test/units/static/JBTokens/TestTotalSupplyOf.sol +1 -1
  231. package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +3 -1
@@ -1,7 +1,9 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity 0.8.26;
3
3
 
4
- import /* {*} from */ "./helpers/TestBaseWorkflow.sol";
4
+ import {Test} from "forge-std/Test.sol";
5
+ import {MetadataResolverHelper} from "./helpers/MetadataResolverHelper.sol";
6
+ import {JBMetadataResolver} from "../src/libraries/JBMetadataResolver.sol";
5
7
 
6
8
  /**
7
9
  * @notice Test the `JBDelegateMetadata` library and helper contract.
@@ -62,9 +64,15 @@ contract JBDelegateMetadataLib_Test_Local is Test {
62
64
  bytes[] memory _datas = new bytes[](10);
63
65
 
64
66
  for (uint256 _i; _i < _ids.length; _i++) {
67
+ // forge-lint: disable-next-line(unsafe-typecast)
65
68
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
66
69
  _datas[_i] = abi.encode(
67
- bytes1(uint8(_i + 1)), uint32(69), bytes2(uint16(_i + 69)), bytes32(uint256(type(uint256).max))
70
+ // forge-lint: disable-next-line(unsafe-typecast)
71
+ bytes1(uint8(_i + 1)),
72
+ uint32(69),
73
+ // forge-lint: disable-next-line(unsafe-typecast)
74
+ bytes2(uint16(_i + 69)),
75
+ bytes32(uint256(type(uint256).max))
68
76
  );
69
77
  }
70
78
 
@@ -95,6 +103,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
95
103
  bytes[] memory _datas = new bytes[](_numberOfIds);
96
104
 
97
105
  for (uint256 _i; _i < _ids.length; _i++) {
106
+ // forge-lint: disable-next-line(unsafe-typecast)
98
107
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
99
108
  _datas[_i] = abi.encode(type(uint256).max - _i);
100
109
  }
@@ -122,7 +131,9 @@ contract JBDelegateMetadataLib_Test_Local is Test {
122
131
  bytes[] memory _datas = new bytes[](_numberOfIds);
123
132
 
124
133
  for (uint256 _i; _i < _ids.length; _i++) {
134
+ // forge-lint: disable-next-line(unsafe-typecast)
125
135
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
136
+ // forge-lint: disable-next-line(incorrect-shift)
126
137
  _datas[_i] = abi.encode(69 << _i * 20);
127
138
  }
128
139
 
@@ -133,6 +144,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
133
144
  uint256 _data = abi.decode(_dataParsed, (uint256));
134
145
 
135
146
  assertTrue(_found);
147
+ // forge-lint: disable-next-line(incorrect-shift)
136
148
  assertEq(_data, 69 << _i * 20);
137
149
  }
138
150
  }
@@ -148,6 +160,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
148
160
  bytes[] memory _datas = new bytes[](_numberOfIds);
149
161
 
150
162
  for (uint256 _i; _i < _ids.length; _i++) {
163
+ // forge-lint: disable-next-line(unsafe-typecast)
151
164
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
152
165
  _datas[_i] = abi.encode(type(uint256).max - _i);
153
166
  }
@@ -166,6 +179,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
166
179
  bytes[] memory _datas = new bytes[](_numberOfIds);
167
180
 
168
181
  for (uint256 _i; _i < _ids.length; _i++) {
182
+ // forge-lint: disable-next-line(unsafe-typecast)
169
183
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
170
184
  _datas[_i] = abi.encode(type(uint256).max - _i);
171
185
  }
@@ -199,9 +213,15 @@ contract JBDelegateMetadataLib_Test_Local is Test {
199
213
  bytes[] memory _datas = new bytes[](2);
200
214
 
201
215
  for (uint256 _i; _i < _ids.length; _i++) {
216
+ // forge-lint: disable-next-line(unsafe-typecast)
202
217
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
203
218
  _datas[_i] = abi.encode(
204
- bytes1(uint8(_i + 1)), uint32(69), bytes2(uint16(_i + 69)), bytes32(uint256(type(uint256).max))
219
+ // forge-lint: disable-next-line(unsafe-typecast)
220
+ bytes1(uint8(_i + 1)),
221
+ uint32(69),
222
+ // forge-lint: disable-next-line(unsafe-typecast)
223
+ bytes2(uint16(_i + 69)),
224
+ bytes32(uint256(type(uint256).max))
205
225
  );
206
226
  }
207
227
 
@@ -210,6 +230,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
210
230
  bytes memory _modifiedMetadata = parser.addDataToMetadata(
211
231
  _metadata,
212
232
  bytes4(uint32(type(uint32).max)),
233
+ // forge-lint: disable-next-line(unsafe-typecast)
213
234
  abi.encode(bytes32(uint256(type(uint256).max)), bytes32(hex"123456"))
214
235
  );
215
236
 
@@ -218,6 +239,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
218
239
 
219
240
  assertTrue(_found);
220
241
  assertEq(bytes32(uint256(type(uint256).max)), _a);
242
+ // forge-lint: disable-next-line(unsafe-typecast)
221
243
  assertEq(bytes32(hex"123456"), _b);
222
244
 
223
245
  for (uint256 _i; _i < _ids.length; _i++) {
@@ -243,6 +265,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
243
265
  bytes[] memory _datas = new bytes[](_numberOfIds);
244
266
 
245
267
  for (uint256 _i; _i < _ids.length; _i++) {
268
+ // forge-lint: disable-next-line(unsafe-typecast)
246
269
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
247
270
  _datas[_i] = abi.encode(_i * 4);
248
271
  }
@@ -304,6 +327,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
304
327
  assertEq(_a, uint32(69));
305
328
  assertEq(_b, bytes32(uint256(type(uint256).max)));
306
329
 
330
+ // forge-lint: disable-next-line(unsafe-typecast)
307
331
  assertEq(uint256(bytes32(_modifiedMetadata)), _reserved);
308
332
  }
309
333
 
@@ -339,6 +363,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
339
363
  bytes[] memory _datas = new bytes[](_numberOfIds);
340
364
 
341
365
  for (uint256 _i; _i < _ids.length; _i++) {
366
+ // forge-lint: disable-next-line(unsafe-typecast)
342
367
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
343
368
  _datas[_i] = abi.encode(_i * 4);
344
369
  }
@@ -383,6 +408,7 @@ contract JBDelegateMetadataLib_Test_Local is Test {
383
408
  bytes[] memory _datas = new bytes[](_numberOfMetadatas);
384
409
 
385
410
  for (uint256 _i; _i < _ids.length; _i++) {
411
+ // forge-lint: disable-next-line(unsafe-typecast)
386
412
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
387
413
  }
388
414
 
@@ -420,10 +446,17 @@ contract JBDelegateMetadataLib_Test_Local is Test {
420
446
  bytes[] memory _datas = new bytes[](10);
421
447
 
422
448
  for (uint256 _i; _i < _ids.length; _i++) {
449
+ // forge-lint: disable-next-line(unsafe-typecast)
423
450
  _ids[_i] = bytes4(uint32(_i + 1 * 1000));
424
451
 
452
+ // forge-lint: disable-next-line(unsafe-typecast)
425
453
  _datas[_i] = abi.encodePacked(
426
- bytes1(uint8(_i + 1)), uint32(69), bytes2(uint16(_i + 69)), bytes32(uint256(type(uint256).max))
454
+ // forge-lint: disable-next-line(unsafe-typecast)
455
+ bytes1(uint8(_i + 1)),
456
+ uint32(69),
457
+ // forge-lint: disable-next-line(unsafe-typecast)
458
+ bytes2(uint16(_i + 69)),
459
+ bytes32(uint256(type(uint256).max))
427
460
  );
428
461
  }
429
462
 
@@ -1,7 +1,22 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.6;
3
3
 
4
- import /* {*} from */ "./helpers/TestBaseWorkflow.sol";
4
+ import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
5
+ import {JBMultiTerminal} from "../src/JBMultiTerminal.sol";
6
+ import {JBTerminalStore} from "../src/JBTerminalStore.sol";
7
+ import {JBTokens} from "../src/JBTokens.sol";
8
+ import {IJBController} from "../src/interfaces/IJBController.sol";
9
+ import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
10
+ import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
11
+ import {JBConstants} from "../src/libraries/JBConstants.sol";
12
+ import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
13
+ import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
14
+ import {JBFee} from "../src/structs/JBFee.sol";
15
+ import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
16
+ import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
17
+ import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
18
+ import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
19
+ import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
5
20
 
6
21
  /// @notice Confirms held fees are stranded when a terminal migrates.
7
22
  /// The migration calls addToBalanceOf with shouldReturnHeldFees: false,
@@ -1,7 +1,20 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.6;
3
3
 
4
- import /* {*} from */ "./helpers/TestBaseWorkflow.sol";
4
+ import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
5
+ import {IJBController} from "../src/interfaces/IJBController.sol";
6
+ import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
7
+ import {IJBRulesetDataHook} from "../src/interfaces/IJBRulesetDataHook.sol";
8
+ import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
9
+ import {IJBTokens} from "../src/interfaces/IJBTokens.sol";
10
+ import {JBConstants} from "../src/libraries/JBConstants.sol";
11
+ import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
12
+ import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
13
+ import {JBRuleset} from "../src/structs/JBRuleset.sol";
14
+ import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
15
+ import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
16
+ import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
17
+ import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
5
18
 
6
19
  contract TestMintTokensOf_Local is TestBaseWorkflow {
7
20
  uint8 private constant _WEIGHT_DECIMALS = 18;
@@ -0,0 +1,348 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.6;
3
+
4
+ import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
5
+ import {JBMultiTerminal} from "../src/JBMultiTerminal.sol";
6
+ import {IJBController} from "../src/interfaces/IJBController.sol";
7
+ import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
8
+ import {IJBTokens} from "../src/interfaces/IJBTokens.sol";
9
+ import {JBConstants} from "../src/libraries/JBConstants.sol";
10
+ import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
11
+ import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
12
+ import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
13
+ import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
14
+ import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
15
+ import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
16
+ import {MockPriceFeed} from "./mock/MockPriceFeed.sol";
17
+ import {MockERC20} from "./mock/MockERC20.sol";
18
+
19
+ /// @notice Tests for multi-terminal surplus aggregation edge cases, including cross-terminal
20
+ /// surplus with useTotalSurplusForCashOuts, cash out balance limits, and price conversion.
21
+ contract TestMultiTerminalSurplus_Local is TestBaseWorkflow {
22
+ IJBController private _controller;
23
+ JBMultiTerminal private _terminal1;
24
+ JBMultiTerminal private _terminal2;
25
+ IJBTokens private _tokens;
26
+ address private _projectOwner;
27
+ address private _user;
28
+
29
+ MockPriceFeed private _ethToUsdcFeed;
30
+ MockERC20 private _usdc;
31
+
32
+ uint32 private _nativeCurrency;
33
+ uint32 private _usdcCurrency;
34
+
35
+ uint256 private _projectId;
36
+
37
+ function setUp() public override {
38
+ super.setUp();
39
+
40
+ _projectOwner = multisig();
41
+ _user = beneficiary();
42
+ _controller = jbController();
43
+ _terminal1 = jbMultiTerminal();
44
+ _terminal2 = jbMultiTerminal2();
45
+ _tokens = jbTokens();
46
+ _usdc = usdcToken();
47
+
48
+ _nativeCurrency = uint32(uint160(JBConstants.NATIVE_TOKEN));
49
+ _usdcCurrency = uint32(uint160(address(_usdc)));
50
+
51
+ // Price feed: 1 ETH = 2000 USDC (6 decimals).
52
+ _ethToUsdcFeed = new MockPriceFeed(2000e6, 6);
53
+
54
+ // Metadata with useTotalSurplusForCashOuts = true.
55
+ JBRulesetMetadata memory _metadata = JBRulesetMetadata({
56
+ reservedPercent: 0,
57
+ cashOutTaxRate: 0,
58
+ baseCurrency: _nativeCurrency,
59
+ pausePay: false,
60
+ pauseCreditTransfers: false,
61
+ allowOwnerMinting: true,
62
+ allowSetCustomToken: true,
63
+ allowTerminalMigration: false,
64
+ allowSetTerminals: false,
65
+ allowSetController: false,
66
+ allowAddAccountingContext: true,
67
+ allowAddPriceFeed: true,
68
+ ownerMustSendPayouts: false,
69
+ holdFees: false,
70
+ useTotalSurplusForCashOuts: true,
71
+ useDataHookForPay: false,
72
+ useDataHookForCashOut: false,
73
+ dataHook: address(0),
74
+ metadata: 0
75
+ });
76
+
77
+ JBRulesetConfig[] memory _rulesetConfig = new JBRulesetConfig[](1);
78
+ _rulesetConfig[0].mustStartAtOrAfter = 0;
79
+ _rulesetConfig[0].duration = 0;
80
+ _rulesetConfig[0].weight = 1000 * 10 ** 18;
81
+ _rulesetConfig[0].weightCutPercent = 0;
82
+ _rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
83
+ _rulesetConfig[0].metadata = _metadata;
84
+ _rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
85
+ _rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
86
+
87
+ // Terminal 1 accepts ETH; Terminal 2 accepts USDC.
88
+ JBAccountingContext[] memory _ethContext = new JBAccountingContext[](1);
89
+ _ethContext[0] = JBAccountingContext({token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: _nativeCurrency});
90
+
91
+ JBAccountingContext[] memory _usdcContext = new JBAccountingContext[](1);
92
+ _usdcContext[0] = JBAccountingContext({token: address(_usdc), decimals: 6, currency: _usdcCurrency});
93
+
94
+ JBTerminalConfig[] memory _terminalConfigs = new JBTerminalConfig[](2);
95
+ _terminalConfigs[0] = JBTerminalConfig({terminal: _terminal1, accountingContextsToAccept: _ethContext});
96
+ _terminalConfigs[1] = JBTerminalConfig({terminal: _terminal2, accountingContextsToAccept: _usdcContext});
97
+
98
+ // Launch project with both terminals.
99
+ _projectId = _controller.launchProjectFor({
100
+ owner: _projectOwner,
101
+ projectUri: "multi-terminal-surplus-test",
102
+ rulesetConfigurations: _rulesetConfig,
103
+ terminalConfigurations: _terminalConfigs,
104
+ memo: ""
105
+ });
106
+
107
+ // Add price feed: USDC priced in native token terms.
108
+ vm.prank(_projectOwner);
109
+ _controller.addPriceFeed({
110
+ projectId: _projectId, pricingCurrency: _usdcCurrency, unitCurrency: _nativeCurrency, feed: _ethToUsdcFeed
111
+ });
112
+
113
+ // Deploy ERC-20 for the project.
114
+ vm.prank(_projectOwner);
115
+ _controller.deployERC20For(_projectId, "MultiTermToken", "MTT", bytes32(0));
116
+ }
117
+
118
+ /// @notice Helper: pay ETH into terminal 1.
119
+ function _payEth(address payer, uint256 amount) internal returns (uint256 tokensReceived) {
120
+ vm.deal(payer, amount);
121
+ vm.prank(payer);
122
+ tokensReceived = _terminal1.pay{value: amount}({
123
+ projectId: _projectId,
124
+ amount: amount,
125
+ token: JBConstants.NATIVE_TOKEN,
126
+ beneficiary: payer,
127
+ minReturnedTokens: 0,
128
+ memo: "",
129
+ metadata: ""
130
+ });
131
+ }
132
+
133
+ /// @notice Helper: pay USDC into terminal 2.
134
+ function _payUsdc(address payer, uint256 amount) internal returns (uint256 tokensReceived) {
135
+ _usdc.mint(payer, amount);
136
+ vm.prank(payer);
137
+ _usdc.approve(address(permit2()), amount);
138
+ vm.prank(payer);
139
+ // forge-lint: disable-next-line(unsafe-typecast)
140
+ permit2().approve(address(_usdc), address(_terminal2), uint160(amount), type(uint48).max);
141
+
142
+ vm.prank(payer);
143
+ tokensReceived = _terminal2.pay({
144
+ projectId: _projectId,
145
+ amount: amount,
146
+ token: address(_usdc),
147
+ beneficiary: payer,
148
+ minReturnedTokens: 0,
149
+ memo: "",
150
+ metadata: ""
151
+ });
152
+ }
153
+
154
+ /// @notice Surplus aggregation across 2 terminals with different tokens.
155
+ function test_surplusAcrossTwoTerminals() public {
156
+ uint256 ethAmount = 2 ether;
157
+ uint256 usdcAmount = 4000e6; // $4000 = 2 ETH
158
+
159
+ _payEth(_user, ethAmount);
160
+ _payUsdc(_user, usdcAmount);
161
+
162
+ // Check ETH-only surplus from terminal 1.
163
+ JBAccountingContext[] memory ethCtx = new JBAccountingContext[](1);
164
+ ethCtx[0] = JBAccountingContext({token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: _nativeCurrency});
165
+ uint256 ethSurplus = _terminal1.currentSurplusOf(_projectId, ethCtx, 18, _nativeCurrency);
166
+ assertEq(ethSurplus, ethAmount, "terminal1 ETH surplus should match payment");
167
+
168
+ // Check USDC-only surplus from terminal 2.
169
+ JBAccountingContext[] memory usdcCtx = new JBAccountingContext[](1);
170
+ usdcCtx[0] = JBAccountingContext({token: address(_usdc), decimals: 6, currency: _usdcCurrency});
171
+ uint256 usdcSurplus = _terminal2.currentSurplusOf(_projectId, usdcCtx, 6, _usdcCurrency);
172
+ assertEq(usdcSurplus, usdcAmount, "terminal2 USDC surplus should match payment");
173
+
174
+ // Check total surplus in ETH terms from the store.
175
+ uint256 totalSurplusEth = jbTerminalStore().currentTotalSurplusOf(_projectId, 18, _nativeCurrency);
176
+ // Should be ETH amount + USDC-converted-to-ETH.
177
+ // The total should be greater than just the ETH amount.
178
+ assertGt(totalSurplusEth, ethAmount, "total surplus should include converted USDC value");
179
+ }
180
+
181
+ /// @notice With useTotalSurplusForCashOuts enabled, cash out from terminal 1 uses combined surplus.
182
+ function test_cashOutUsesTotalSurplusWhenEnabled() public {
183
+ uint256 ethAmount = 1 ether;
184
+ uint256 usdcAmount = 2000e6; // $2000 = 1 ETH
185
+
186
+ uint256 userEthTokens = _payEth(_user, ethAmount);
187
+ _payUsdc(_user, usdcAmount);
188
+
189
+ // User cashes out from terminal 1 (ETH).
190
+ // useTotalSurplusForCashOuts is enabled, so the bonding curve should consider
191
+ // the total surplus across both terminals, not just terminal 1's ETH balance.
192
+ uint256 userBalanceBefore = _user.balance;
193
+
194
+ vm.prank(_user);
195
+ uint256 reclaimed = _terminal1.cashOutTokensOf({
196
+ holder: _user,
197
+ projectId: _projectId,
198
+ cashOutCount: userEthTokens / 4, // cash out 25% of tokens from ETH payment
199
+ tokenToReclaim: JBConstants.NATIVE_TOKEN,
200
+ minTokensReclaimed: 0,
201
+ beneficiary: payable(_user),
202
+ metadata: new bytes(0)
203
+ });
204
+
205
+ // Reclaim amount should be > 0.
206
+ assertGt(reclaimed, 0, "should reclaim some ETH");
207
+
208
+ // Verify the user received ETH.
209
+ assertGt(_user.balance, userBalanceBefore, "user balance should increase");
210
+ }
211
+
212
+ /// @notice Cash out from terminal 1 cannot extract more ETH than terminal 1 holds,
213
+ /// even with useTotalSurplusForCashOuts enabled.
214
+ function test_cashOutCannotExceedTerminalBalance() public {
215
+ uint256 ethAmount = 1 ether;
216
+ uint256 usdcAmount = 20_000e6; // $20,000 = 10 ETH -- much more value than in terminal 1
217
+
218
+ uint256 userEthTokens = _payEth(_user, ethAmount);
219
+ _payUsdc(_user, usdcAmount);
220
+
221
+ // The total surplus in ETH terms is ~11 ETH, but terminal 1 only holds 1 ETH.
222
+ // Cashing out all tokens from terminal 1 should be bounded by the terminal's ETH balance.
223
+ // With cashOutTaxRate=0 and useTotalSurplusForCashOuts=true, the reclaim amount
224
+ // = totalSurplus * cashOutCount / totalSupply.
225
+ // The total token supply includes tokens from both payments.
226
+
227
+ // Get total token balance.
228
+ uint256 totalTokenBalance = _tokens.totalBalanceOf(_user, _projectId);
229
+ assertGt(totalTokenBalance, userEthTokens, "total tokens should include USDC payment tokens");
230
+
231
+ // Cash out a large fraction -- the reclaim may be limited by what terminal 1 actually holds.
232
+ // If reclaimAmount + hookAmounts > terminal balance, the store should revert.
233
+ // Let us try cashing out enough tokens that the calculated reclaim exceeds terminal 1's balance.
234
+ // With 1 ETH in terminal 1 and ~11 ETH total surplus, cashing out all tokens
235
+ // would try to reclaim ~11 ETH from a terminal that only has 1 ETH.
236
+
237
+ vm.prank(_user);
238
+ vm.expectRevert(); // Should revert with InadequateTerminalStoreBalance
239
+ _terminal1.cashOutTokensOf({
240
+ holder: _user,
241
+ projectId: _projectId,
242
+ cashOutCount: totalTokenBalance,
243
+ tokenToReclaim: JBConstants.NATIVE_TOKEN,
244
+ minTokensReclaimed: 0,
245
+ beneficiary: payable(_user),
246
+ metadata: new bytes(0)
247
+ });
248
+ }
249
+
250
+ /// @notice Surplus aggregation with price conversion rounding: small amounts.
251
+ function test_surplusAggregationRounding() public {
252
+ // Pay a very small amount of ETH.
253
+ uint256 ethAmount = 1 wei;
254
+ _payEth(_user, ethAmount);
255
+
256
+ // Pay a very small amount of USDC.
257
+ uint256 usdcAmount = 1; // 1e-6 USDC = $0.000001
258
+ _payUsdc(_user, usdcAmount);
259
+
260
+ // Total surplus should be >= the ETH amount (even if USDC rounds to 0 when converted).
261
+ uint256 totalSurplus = jbTerminalStore().currentTotalSurplusOf(_projectId, 18, _nativeCurrency);
262
+ assertGe(totalSurplus, ethAmount, "total surplus should be at least the ETH amount");
263
+ }
264
+
265
+ /// @notice Per-terminal balance tracking is independent across terminals.
266
+ function test_perTerminalBalanceIndependence() public {
267
+ uint256 ethAmount = 5 ether;
268
+ uint256 usdcAmount = 3000e6;
269
+
270
+ _payEth(_user, ethAmount);
271
+ _payUsdc(_user, usdcAmount);
272
+
273
+ // Terminal 1 balance (ETH) should be unaffected by terminal 2's USDC.
274
+ uint256 t1EthBalance = jbTerminalStore().balanceOf(address(_terminal1), _projectId, JBConstants.NATIVE_TOKEN);
275
+ assertEq(t1EthBalance, ethAmount, "terminal 1 ETH balance should match");
276
+
277
+ // Terminal 2 balance (USDC) should be unaffected by terminal 1's ETH.
278
+ uint256 t2UsdcBalance = jbTerminalStore().balanceOf(address(_terminal2), _projectId, address(_usdc));
279
+ assertEq(t2UsdcBalance, usdcAmount, "terminal 2 USDC balance should match");
280
+
281
+ // Terminal 1 should have no USDC balance.
282
+ uint256 t1UsdcBalance = jbTerminalStore().balanceOf(address(_terminal1), _projectId, address(_usdc));
283
+ assertEq(t1UsdcBalance, 0, "terminal 1 should have no USDC balance");
284
+
285
+ // Terminal 2 should have no ETH balance.
286
+ uint256 t2EthBalance = jbTerminalStore().balanceOf(address(_terminal2), _projectId, JBConstants.NATIVE_TOKEN);
287
+ assertEq(t2EthBalance, 0, "terminal 2 should have no ETH balance");
288
+ }
289
+
290
+ /// @notice Small cash out from terminal with most funds -- verifiable amount.
291
+ function test_smallCashOutFromTerminalWithFunds() public {
292
+ uint256 ethAmount = 10 ether;
293
+ uint256 usdcAmount = 2000e6; // = 1 ETH equivalent
294
+
295
+ uint256 userTokens = _payEth(_user, ethAmount);
296
+ _payUsdc(_user, usdcAmount);
297
+
298
+ // Cash out a small fraction of tokens from the ETH terminal.
299
+ uint256 cashOutCount = userTokens / 100; // 1% of ETH-minted tokens
300
+
301
+ uint256 balanceBefore = _user.balance;
302
+ vm.prank(_user);
303
+ uint256 reclaimed = _terminal1.cashOutTokensOf({
304
+ holder: _user,
305
+ projectId: _projectId,
306
+ cashOutCount: cashOutCount,
307
+ tokenToReclaim: JBConstants.NATIVE_TOKEN,
308
+ minTokensReclaimed: 0,
309
+ beneficiary: payable(_user),
310
+ metadata: new bytes(0)
311
+ });
312
+
313
+ assertGt(reclaimed, 0, "should reclaim something for 1% cash out");
314
+ assertEq(_user.balance - balanceBefore, reclaimed, "user balance increase should match reclaimed amount");
315
+
316
+ // After small cash out, terminal 1 should still have most of its ETH.
317
+ uint256 remainingBalance =
318
+ jbTerminalStore().balanceOf(address(_terminal1), _projectId, JBConstants.NATIVE_TOKEN);
319
+ assertGt(remainingBalance, 9 ether, "most of the ETH should remain");
320
+ }
321
+
322
+ /// @notice Total surplus query from terminal store matches sum of individual terminal surpluses.
323
+ function test_totalSurplusConsistency() public {
324
+ uint256 ethAmount = 3 ether;
325
+ uint256 usdcAmount = 6000e6; // $6000 = 3 ETH
326
+
327
+ _payEth(_user, ethAmount);
328
+ _payUsdc(_user, usdcAmount);
329
+
330
+ // Get individual surpluses in ETH terms.
331
+ JBAccountingContext[] memory ethCtx = new JBAccountingContext[](1);
332
+ ethCtx[0] = JBAccountingContext({token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: _nativeCurrency});
333
+ uint256 t1Surplus = _terminal1.currentSurplusOf(_projectId, ethCtx, 18, _nativeCurrency);
334
+
335
+ JBAccountingContext[] memory usdcCtx = new JBAccountingContext[](1);
336
+ usdcCtx[0] = JBAccountingContext({token: address(_usdc), decimals: 6, currency: _usdcCurrency});
337
+ // Get terminal 2 surplus in ETH terms.
338
+ uint256 t2SurplusInEth = _terminal2.currentSurplusOf(_projectId, usdcCtx, 18, _nativeCurrency);
339
+
340
+ // Get total surplus from the store.
341
+ uint256 totalSurplus = jbTerminalStore().currentTotalSurplusOf(_projectId, 18, _nativeCurrency);
342
+
343
+ // Total should equal sum of individual surpluses (both converted to ETH).
344
+ assertEq(totalSurplus, t1Surplus + t2SurplusInEth, "total surplus should equal sum of terminal surpluses");
345
+ }
346
+
347
+ receive() external payable {}
348
+ }
@@ -1,7 +1,17 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.6;
3
3
 
4
- import /* {*} from */ "./helpers/TestBaseWorkflow.sol";
4
+ import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
5
+ import {JBMultiTerminal} from "../src/JBMultiTerminal.sol";
6
+ import {IJBController} from "../src/interfaces/IJBController.sol";
7
+ import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
8
+ import {JBConstants} from "../src/libraries/JBConstants.sol";
9
+ import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
10
+ import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
11
+ import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
12
+ import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
13
+ import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
14
+ import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
5
15
  import {MockPriceFeed} from "./mock/MockPriceFeed.sol";
6
16
  import {MockERC20} from "./mock/MockERC20.sol";
7
17
 
@@ -117,6 +127,7 @@ contract TestMultiTokenSurplus_Local is TestBaseWorkflow {
117
127
  vm.prank(_beneficiary);
118
128
  _usdc.approve(address(permit2()), usdcAmount);
119
129
  vm.prank(_beneficiary);
130
+ // forge-lint: disable-next-line(unsafe-typecast)
120
131
  permit2().approve(address(_usdc), address(_terminal), uint160(usdcAmount), type(uint48).max);
121
132
 
122
133
  vm.prank(_beneficiary);
@@ -145,6 +156,7 @@ contract TestMultiTokenSurplus_Local is TestBaseWorkflow {
145
156
  vm.prank(_beneficiary);
146
157
  _usdc.approve(address(permit2()), usdcAmount);
147
158
  vm.prank(_beneficiary);
159
+ // forge-lint: disable-next-line(unsafe-typecast)
148
160
  permit2().approve(address(_usdc), address(_terminal), uint160(usdcAmount), type(uint48).max);
149
161
 
150
162
  vm.prank(_beneficiary);
@@ -191,6 +203,7 @@ contract TestMultiTokenSurplus_Local is TestBaseWorkflow {
191
203
  vm.prank(_beneficiary);
192
204
  _usdc.approve(address(permit2()), usdcAmount);
193
205
  vm.prank(_beneficiary);
206
+ // forge-lint: disable-next-line(unsafe-typecast)
194
207
  permit2().approve(address(_usdc), address(_terminal), uint160(usdcAmount), type(uint48).max);
195
208
 
196
209
  vm.prank(_beneficiary);
@@ -1,12 +1,32 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.6;
3
3
 
4
- import /* {*} from */ "./helpers/TestBaseWorkflow.sol";
4
+ import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
5
+ import {JBFundAccessLimits} from "../src/JBFundAccessLimits.sol";
6
+ import {JBTerminalStore} from "../src/JBTerminalStore.sol";
7
+ import {JBTokens} from "../src/JBTokens.sol";
8
+ import {IJBController} from "../src/interfaces/IJBController.sol";
9
+ import {IJBMultiTerminal} from "../src/interfaces/IJBMultiTerminal.sol";
10
+ import {IJBPriceFeed} from "../src/interfaces/IJBPriceFeed.sol";
11
+ import {IJBPrices} from "../src/interfaces/IJBPrices.sol";
12
+ import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
13
+ import {JBConstants} from "../src/libraries/JBConstants.sol";
14
+ import {JBCurrencyIds} from "../src/libraries/JBCurrencyIds.sol";
15
+ import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
16
+ import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
17
+ import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
18
+ import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
19
+ import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
20
+ import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
21
+ import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
22
+ import {mulDiv} from "@prb/math/src/Common.sol";
23
+ import {mul as UD60x18mul, unwrap as UD60x18unwrap, wrap as UD60x18wrap} from "@prb/math/src/UD60x18.sol";
5
24
  import {MockPriceFeed} from "./mock/MockPriceFeed.sol";
6
25
 
7
26
  contract TestMultipleAccessLimits_Local is TestBaseWorkflow {
8
27
  uint32 private _nativeCurrency;
9
28
  IJBController private _controller;
29
+ // forge-lint: disable-next-line(mixed-case-variable)
10
30
  IJBMultiTerminal private __terminal;
11
31
  IJBPrices private _prices;
12
32
  JBTokens private _tokens;
@@ -225,6 +245,7 @@ contract TestMultipleAccessLimits_Local is TestBaseWorkflow {
225
245
  });
226
246
  }
227
247
 
248
+ // forge-lint: disable-next-line(mixed-case-variable)
228
249
  function testFuzzedInvalidAllowanceCurrencyOrdering(uint24 ALLOWCURRENCY) external {
229
250
  JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](1);
230
251
  JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](1);
@@ -336,6 +357,7 @@ contract TestMultipleAccessLimits_Local is TestBaseWorkflow {
336
357
  uint224 _payoutLimit,
337
358
  uint224 _surplusAllowance,
338
359
  uint32 _payoutCurrency,
360
+ // forge-lint: disable-next-line(mixed-case-variable)
339
361
  uint32 ALLOWCURRENCY
340
362
  )
341
363
  external
@@ -1,7 +1,22 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.6;
3
3
 
4
- import /* {*} from */ "./helpers/TestBaseWorkflow.sol";
4
+ import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
5
+ import {JBController} from "../src/JBController.sol";
6
+ import {JBTerminalStore} from "../src/JBTerminalStore.sol";
7
+ import {JBTokens} from "../src/JBTokens.sol";
8
+ import {IJBController} from "../src/interfaces/IJBController.sol";
9
+ import {IJBMultiTerminal} from "../src/interfaces/IJBMultiTerminal.sol";
10
+ import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
11
+ import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
12
+ import {JBConstants} from "../src/libraries/JBConstants.sol";
13
+ import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
14
+ import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
15
+ import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
16
+ import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
17
+ import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
18
+ import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
19
+ import {mul as UD60x18mul, unwrap as UD60x18unwrap, wrap as UD60x18wrap} from "@prb/math/src/UD60x18.sol";
5
20
 
6
21
  // Project can issue token, receive payments in exchange for tokens, burn some of the claimed tokens, and allow holders
7
22
  // to cash out the rest of tokens.