@bananapus/core-v6 0.0.36 → 0.0.38

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 (286) hide show
  1. package/foundry.lock +1 -7
  2. package/foundry.toml +1 -1
  3. package/package.json +19 -7
  4. package/src/JBController.sol +26 -5
  5. package/src/JBMultiTerminal.sol +85 -47
  6. package/src/JBTerminalStore.sol +6 -6
  7. package/src/interfaces/IJBController.sol +4 -1
  8. package/src/libraries/JBFees.sol +47 -9
  9. package/src/libraries/JBPayoutSplitGroupLib.sol +2 -2
  10. package/src/periphery/JBMatchingPriceFeed.sol +1 -1
  11. package/test/mock/MockMaliciousBeneficiary.sol +15 -15
  12. package/ADMINISTRATION.md +0 -103
  13. package/ARCHITECTURE.md +0 -133
  14. package/AUDIT_INSTRUCTIONS.md +0 -139
  15. package/RISKS.md +0 -215
  16. package/SKILLS.md +0 -55
  17. package/STYLE_GUIDE.md +0 -610
  18. package/USER_JOURNEYS.md +0 -215
  19. package/script/Deploy.s.sol +0 -124
  20. package/script/DeployPeriphery.s.sol +0 -354
  21. package/slither-ci.config.json +0 -10
  22. package/test/AuditFixes.t.sol +0 -808
  23. package/test/ComprehensiveInvariant.t.sol +0 -306
  24. package/test/CoreExploitTests.t.sol +0 -2741
  25. package/test/EconomicSimulation.t.sol +0 -348
  26. package/test/EntryPointPermutations.t.sol +0 -684
  27. package/test/FlashLoanAttacks.t.sol +0 -797
  28. package/test/PermissionEscalation.t.sol +0 -711
  29. package/test/PermissionsInvariant.t.sol +0 -403
  30. package/test/RulesetTransitions.t.sol +0 -713
  31. package/test/SplitLoopTests.t.sol +0 -752
  32. package/test/TestAccessToFunds.sol +0 -2683
  33. package/test/TestAuditResponseDesignProofs.sol +0 -434
  34. package/test/TestCashOut.sol +0 -198
  35. package/test/TestCashOutCountFor.sol +0 -271
  36. package/test/TestCashOutHooks.sol +0 -351
  37. package/test/TestCashOutTimingEdge.sol +0 -241
  38. package/test/TestDataHookFuzzing.sol +0 -524
  39. package/test/TestDurationUnderflow.sol +0 -233
  40. package/test/TestFeeFreeCashOutBypass.sol +0 -949
  41. package/test/TestFeeProcessingFailure.sol +0 -218
  42. package/test/TestFees.sol +0 -619
  43. package/test/TestForwardedTokenConsumption.sol +0 -425
  44. package/test/TestInterfaceSupport.sol +0 -81
  45. package/test/TestJBERC20Inheritance.sol +0 -103
  46. package/test/TestL2SequencerPriceFeed.sol +0 -292
  47. package/test/TestLaunchProject.sol +0 -188
  48. package/test/TestMetaTx.sol +0 -217
  49. package/test/TestMetadataOffsetOverflow.sol +0 -179
  50. package/test/TestMetadataParserLib.sol +0 -471
  51. package/test/TestMigrationHeldFees.sol +0 -255
  52. package/test/TestMintTokensOf.sol +0 -185
  53. package/test/TestMultiTerminalSurplus.sol +0 -348
  54. package/test/TestMultiTokenSurplus.sol +0 -202
  55. package/test/TestMultipleAccessLimits.sol +0 -664
  56. package/test/TestPayBurnRedeemFlow.sol +0 -195
  57. package/test/TestPayHooks.sol +0 -209
  58. package/test/TestPermissions.sol +0 -324
  59. package/test/TestPermissionsEdge.sol +0 -290
  60. package/test/TestPermit2DataHook.t.sol +0 -360
  61. package/test/TestPermit2Terminal.sol +0 -372
  62. package/test/TestRulesetQueueing.sol +0 -1025
  63. package/test/TestRulesetQueuingStress.sol +0 -806
  64. package/test/TestRulesetWeightCaching.sol +0 -178
  65. package/test/TestSplits.sol +0 -391
  66. package/test/TestTerminalMigration.sol +0 -274
  67. package/test/TestTerminalPreviewParity.sol +0 -208
  68. package/test/TestTokenFlow.sol +0 -191
  69. package/test/TestWeightCacheStaleAfterRejection.sol +0 -303
  70. package/test/WeirdTokenTests.t.sol +0 -817
  71. package/test/audit/CashOutReenterPay.t.sol +0 -501
  72. package/test/audit/CodexHeldFeeRounding.t.sol +0 -159
  73. package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
  74. package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
  75. package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
  76. package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
  77. package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
  78. package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
  79. package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
  80. package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
  81. package/test/formal/BondingCurveProperties.t.sol +0 -420
  82. package/test/formal/FeeProperties.t.sol +0 -252
  83. package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
  84. package/test/invariants/RulesetsInvariant.t.sol +0 -125
  85. package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
  86. package/test/invariants/TokensInvariant.t.sol +0 -195
  87. package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
  88. package/test/invariants/handlers/EconomicHandler.sol +0 -377
  89. package/test/invariants/handlers/Phase3Handler.sol +0 -443
  90. package/test/invariants/handlers/RulesetsHandler.sol +0 -115
  91. package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
  92. package/test/invariants/handlers/TokensHandler.sol +0 -126
  93. package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
  94. package/test/regression/WeightCacheBoundary.t.sol +0 -291
  95. package/test/trees/JBController/burnTokensOf.tree +0 -9
  96. package/test/trees/JBController/claimTokensFor.tree +0 -5
  97. package/test/trees/JBController/deployERC20For.tree +0 -5
  98. package/test/trees/JBController/getRulesetOf.tree +0 -5
  99. package/test/trees/JBController/launchProjectFor.tree +0 -12
  100. package/test/trees/JBController/launchRulesetsFor.tree +0 -8
  101. package/test/trees/JBController/migrateController.tree +0 -12
  102. package/test/trees/JBController/mintTokensOf.tree +0 -12
  103. package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
  104. package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
  105. package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
  106. package/test/trees/JBController/setMetadataOf.tree +0 -5
  107. package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
  108. package/test/trees/JBController/setTokenFor.tree +0 -5
  109. package/test/trees/JBController/transferCreditsFrom.tree +0 -8
  110. package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
  111. package/test/trees/JBDirectory/setControllerOf.tree +0 -11
  112. package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
  113. package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
  114. package/test/trees/JBERC20/initialize.tree +0 -7
  115. package/test/trees/JBERC20/name.tree +0 -5
  116. package/test/trees/JBERC20/nonces.tree +0 -5
  117. package/test/trees/JBERC20/symbol.tree +0 -5
  118. package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
  119. package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
  120. package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
  121. package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
  122. package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
  123. package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
  124. package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
  125. package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
  126. package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
  127. package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
  128. package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
  129. package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
  130. package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
  131. package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
  132. package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
  133. package/test/trees/JBMultiTerminal/pay.tree +0 -23
  134. package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
  135. package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
  136. package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
  137. package/test/trees/JBPermissions/hasPermission.tree +0 -8
  138. package/test/trees/JBPermissions/hasPermissions.tree +0 -8
  139. package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
  140. package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
  141. package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
  142. package/test/trees/JBProjects/createFor.tree +0 -11
  143. package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
  144. package/test/trees/JBProjects/supportsInterface.tree +0 -9
  145. package/test/trees/JBProjects/tokenURI.tree +0 -5
  146. package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
  147. package/test/trees/JBRulesets/currentOf.tree +0 -12
  148. package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
  149. package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
  150. package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
  151. package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
  152. package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
  153. package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
  154. package/test/trees/JBSplits/splitsOf.tree +0 -5
  155. package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
  156. package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
  157. package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
  158. package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
  159. package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
  160. package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
  161. package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
  162. package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
  163. package/test/trees/JBTokens/burnFrom.tree +0 -10
  164. package/test/trees/JBTokens/claimTokensFor.tree +0 -10
  165. package/test/trees/JBTokens/deployERC20For.tree +0 -12
  166. package/test/trees/JBTokens/mintFor.tree +0 -10
  167. package/test/trees/JBTokens/setTokenFor.tree +0 -11
  168. package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
  169. package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
  170. package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
  171. package/test/trees/mintTokensOf.tree +0 -12
  172. package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
  173. package/test/units/static/JBController/JBControllerSetup.sol +0 -50
  174. package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
  175. package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
  176. package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
  177. package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
  178. package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
  179. package/test/units/static/JBController/TestMigrateController.sol +0 -157
  180. package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
  181. package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
  182. package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
  183. package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
  184. package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
  185. package/test/units/static/JBController/TestRulesetViews.sol +0 -225
  186. package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
  187. package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
  188. package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
  189. package/test/units/static/JBController/TestSetUriOf.sol +0 -57
  190. package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
  191. package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
  192. package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
  193. package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
  194. package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
  195. package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
  196. package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
  197. package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
  198. package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
  199. package/test/units/static/JBERC20/SigUtils.sol +0 -36
  200. package/test/units/static/JBERC20/TestInitialize.sol +0 -60
  201. package/test/units/static/JBERC20/TestName.sol +0 -30
  202. package/test/units/static/JBERC20/TestNonces.sol +0 -62
  203. package/test/units/static/JBERC20/TestSymbol.sol +0 -31
  204. package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
  205. package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
  206. package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
  207. package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
  208. package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
  209. package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
  210. package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
  211. package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
  212. package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
  213. package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
  214. package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
  215. package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
  216. package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
  217. package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
  218. package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
  219. package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
  220. package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
  221. package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
  222. package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
  223. package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
  224. package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
  225. package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
  226. package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
  227. package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
  228. package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
  229. package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
  230. package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
  231. package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
  232. package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
  233. package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
  234. package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
  235. package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
  236. package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
  237. package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
  238. package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
  239. package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
  240. package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
  241. package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
  242. package/test/units/static/JBPrices/TestPrices.sol +0 -265
  243. package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
  244. package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
  245. package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
  246. package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
  247. package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
  248. package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
  249. package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
  250. package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
  251. package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
  252. package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
  253. package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
  254. package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
  255. package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
  256. package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
  257. package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
  258. package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
  259. package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
  260. package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
  261. package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
  262. package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
  263. package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
  264. package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
  265. package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
  266. package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
  267. package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
  268. package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
  269. package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
  270. package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
  271. package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
  272. package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
  273. package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
  274. package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
  275. package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
  276. package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
  277. package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
  278. package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
  279. package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
  280. package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
  281. package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
  282. package/test/units/static/JBTokens/TestMintFor.sol +0 -100
  283. package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
  284. package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
  285. package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
  286. package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +0 -56
@@ -1,24 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {JBFundAccessLimits} from "../../../../src/JBFundAccessLimits.sol";
5
- import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
6
- import {IJBFundAccessLimits} from "../../../../src/interfaces/IJBFundAccessLimits.sol";
7
- import {JBTest} from "../../../helpers/JBTest.sol";
8
-
9
- /*
10
- Contract that deploys a target contract with other mock contracts to satisfy the constructor.
11
- Tests relative to this contract will be dependent on mock calls/emits and stdStorage.
12
- */
13
- contract JBFundAccessSetup is JBTest {
14
- // Target Contract
15
- IJBFundAccessLimits public _fundAccess;
16
-
17
- // Mocks
18
- IJBDirectory public directory = IJBDirectory(makeAddr("directory"));
19
-
20
- function fundAccessSetup() public virtual {
21
- // Instantiate the contract being tested
22
- _fundAccess = new JBFundAccessLimits(directory);
23
- }
24
- }
@@ -1,163 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {JBFundAccessLimits} from "../../../../src/JBFundAccessLimits.sol";
5
- import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
6
- import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
7
- import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
8
- import {JBTest} from "../../../helpers/JBTest.sol";
9
-
10
- /// @notice Edge case tests for JBFundAccessLimits append behavior and packing.
11
- /// The key finding is that setFundAccessLimitsFor uses .push() (append), not replace.
12
- /// If called twice for the same rulesetId, limits accumulate rather than being replaced.
13
- contract TestFundAccessLimitsEdge_Local is JBTest {
14
- IJBDirectory public directory = IJBDirectory(makeAddr("directory"));
15
- JBFundAccessLimits public limits;
16
-
17
- uint256 constant PROJECT_ID = 1;
18
- uint256 constant RULESET_ID = 100;
19
- address constant TERMINAL = address(0xBEEF);
20
- address constant TOKEN = address(0xCAFE);
21
-
22
- function setUp() public {
23
- limits = new JBFundAccessLimits(directory);
24
-
25
- // Mock controllerOf to return this contract (so we can call setFundAccessLimitsFor).
26
- vm.mockCall(
27
- address(directory), abi.encodeCall(IJBDirectory.controllerOf, (PROJECT_ID)), abi.encode(address(this))
28
- );
29
- }
30
-
31
- // ───────────────────── Append-not-replace bug
32
- // ─────────────────────
33
-
34
- /// @notice BUG: Calling setFundAccessLimitsFor twice accumulates limits instead of replacing.
35
- /// If a controller ever calls this twice for the same rulesetId (e.g., custom controller,
36
- /// reentrancy, or migration bug), limits double.
37
- function test_doubleSetting_accumulatesLimits() external {
38
- JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](1);
39
- payoutLimits[0] = JBCurrencyAmount({amount: 1000, currency: 1});
40
-
41
- JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
42
- groups[0] = JBFundAccessLimitGroup({
43
- terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
44
- });
45
-
46
- // First call — sets limit to 1000.
47
- limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
48
-
49
- // Verify first limit.
50
- uint256 limit1 = limits.payoutLimitOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN, 1);
51
- assertEq(limit1, 1000, "First limit should be 1000");
52
-
53
- // Second call with SAME rulesetId — BUG: this APPENDS, not replaces.
54
- limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
55
-
56
- // Query all limits — should have 2 entries now (both with currency=1, amount=1000).
57
- JBCurrencyAmount[] memory allLimits = limits.payoutLimitsOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN);
58
-
59
- // Two entries instead of one.
60
- assertEq(allLimits.length, 2, "BUG: Limits accumulated instead of being replaced");
61
- assertEq(allLimits[0].amount, 1000, "First accumulated limit");
62
- assertEq(allLimits[1].amount, 1000, "Second accumulated limit");
63
-
64
- // The payoutLimitOf function returns the FIRST match, so it still returns 1000.
65
- // But the surplus calculation iterates ALL limits, effectively doubling the payout limit.
66
- uint256 limitQuery = limits.payoutLimitOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN, 1);
67
- assertEq(limitQuery, 1000, "Query returns first match only");
68
- }
69
-
70
- // ───────────────────── Zero amount skipped
71
- // ─────────────────────
72
-
73
- /// @notice Zero-amount limits are not stored (filtered by amount > 0 check).
74
- function test_zeroAmount_skipped() external {
75
- JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](2);
76
- payoutLimits[0] = JBCurrencyAmount({amount: 0, currency: 1}); // Should be skipped.
77
- payoutLimits[1] = JBCurrencyAmount({amount: 500, currency: 2});
78
-
79
- JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
80
- groups[0] = JBFundAccessLimitGroup({
81
- terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
82
- });
83
-
84
- limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
85
-
86
- // Only the non-zero limit should be stored.
87
- JBCurrencyAmount[] memory allLimits = limits.payoutLimitsOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN);
88
- assertEq(allLimits.length, 1, "Zero-amount limit should not be stored");
89
- assertEq(allLimits[0].amount, 500, "Only non-zero limit stored");
90
- assertEq(allLimits[0].currency, 2, "Correct currency stored");
91
- }
92
-
93
- // ───────────────────── Currency ordering validation
94
- // ─────────────────────
95
-
96
- /// @notice Duplicate currencies in payout limits should revert.
97
- function test_currencyOrdering_rejectsEqual() external {
98
- JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](2);
99
- payoutLimits[0] = JBCurrencyAmount({amount: 100, currency: 1});
100
- payoutLimits[1] = JBCurrencyAmount({amount: 200, currency: 1}); // Same currency!
101
-
102
- JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
103
- groups[0] = JBFundAccessLimitGroup({
104
- terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
105
- });
106
-
107
- vm.expectRevert(JBFundAccessLimits.JBFundAccessLimits_InvalidPayoutLimitCurrencyOrdering.selector);
108
- limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
109
- }
110
-
111
- /// @notice Descending currency order should revert.
112
- function test_currencyOrdering_rejectsDescending() external {
113
- JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](2);
114
- payoutLimits[0] = JBCurrencyAmount({amount: 100, currency: 2});
115
- payoutLimits[1] = JBCurrencyAmount({amount: 200, currency: 1}); // Descending!
116
-
117
- JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
118
- groups[0] = JBFundAccessLimitGroup({
119
- terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
120
- });
121
-
122
- vm.expectRevert(JBFundAccessLimits.JBFundAccessLimits_InvalidPayoutLimitCurrencyOrdering.selector);
123
- limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
124
- }
125
-
126
- // ───────────────────── Packing round-trip
127
- // ─────────────────────
128
-
129
- /// @notice Fuzz: packed amount + currency unpack correctly for all inputs.
130
- function testFuzz_packingRoundTrip(uint224 amount, uint32 currency) external {
131
- // Skip zero amounts (they're filtered out).
132
- vm.assume(amount > 0);
133
- // Skip currency 0 since ordering requires > 0 for the first element.
134
- vm.assume(currency > 0);
135
-
136
- JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](1);
137
- payoutLimits[0] = JBCurrencyAmount({amount: amount, currency: currency});
138
-
139
- JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
140
- groups[0] = JBFundAccessLimitGroup({
141
- terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
142
- });
143
-
144
- // Use a unique rulesetId for each fuzz run to avoid accumulation bug.
145
- uint256 rulesetId = uint256(keccak256(abi.encode(amount, currency)));
146
- limits.setFundAccessLimitsFor(PROJECT_ID, rulesetId, groups);
147
-
148
- // Verify round-trip.
149
- JBCurrencyAmount[] memory result = limits.payoutLimitsOf(PROJECT_ID, rulesetId, TERMINAL, TOKEN);
150
- assertEq(result.length, 1, "Should have exactly one limit");
151
- assertEq(result[0].amount, amount, "Amount should round-trip correctly");
152
- assertEq(result[0].currency, currency, "Currency should round-trip correctly");
153
- }
154
-
155
- // ───────────────────── Query nonexistent returns zero
156
- // ─────────────────────
157
-
158
- /// @notice Querying a currency with no limit returns 0 (implicit default).
159
- function test_queryNonexistentCurrency_returnsZero() external view {
160
- uint256 limit = limits.payoutLimitOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN, 999);
161
- assertEq(limit, 0, "Nonexistent currency should return 0");
162
- }
163
- }
@@ -1,59 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
5
- import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
6
- import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
7
- import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
8
- import {JBFundAccessSetup} from "./JBFundAccessSetup.sol";
9
-
10
- contract TestPayoutLimitOf_Local is JBFundAccessSetup {
11
- uint256 _projectId = 1;
12
- uint256 _ruleset = block.timestamp;
13
- uint224 _payoutLimit = 1e18;
14
- uint32 _currency = uint32(uint160(JBConstants.NATIVE_TOKEN));
15
- address _terminal = address(1);
16
- address _token = JBConstants.NATIVE_TOKEN;
17
-
18
- function setUp() public {
19
- super.fundAccessSetup();
20
-
21
- // Fund Access config
22
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](1);
23
- {
24
- // Specify a payout limit.
25
- JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](1);
26
- _payoutLimits[0] =
27
- JBCurrencyAmount({amount: _payoutLimit, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
28
-
29
- // Specify a surplus allowance.
30
- JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](0);
31
-
32
- _fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
33
- terminal: address(_terminal),
34
- token: JBConstants.NATIVE_TOKEN,
35
- payoutLimits: _payoutLimits,
36
- surplusAllowances: _surplusAllowances
37
- });
38
- }
39
-
40
- bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
41
- bytes memory _return = abi.encode(address(this));
42
-
43
- mockExpect(address(directory), _controllerCall, _return);
44
-
45
- _fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
46
- }
47
-
48
- function test_WhenTheProjectHasTheSpecificPayoutLimit() external view {
49
- // it will return the uint256 payoutLimit
50
- uint256 _returnedLimit = _fundAccess.payoutLimitOf(_projectId, _ruleset, _terminal, _token, _currency);
51
- assertEq(_returnedLimit, _payoutLimit);
52
- }
53
-
54
- function test_WhenTheProjectDoesntHaveTheSpecificPayoutLimit() external view {
55
- // it will return 0
56
- uint256 empty = _fundAccess.payoutLimitOf(1, 1, address(1), address(2), 1);
57
- assertEq(empty, 0);
58
- }
59
- }
@@ -1,101 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
5
- import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
6
- import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
7
- import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
8
- import {JBFundAccessSetup} from "./JBFundAccessSetup.sol";
9
-
10
- contract TestPayoutLimitsOf_Local is JBFundAccessSetup {
11
- uint256 _projectId = 1;
12
- uint256 _ruleset = block.timestamp;
13
- uint224 _payoutLimit = 1e18;
14
- uint224 _payoutLimit2 = 1e6;
15
- uint32 _currency = uint32(uint160(JBConstants.NATIVE_TOKEN));
16
- address _terminal = address(1);
17
- address _terminal2 = address(2);
18
- address _someToken = makeAddr("sometoken");
19
-
20
- function setUp() public {
21
- super.fundAccessSetup();
22
- }
23
-
24
- modifier whenAProjectHasPayoutLimits() {
25
- // Fund Access config
26
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
27
- {
28
- // Specify a payout limit.
29
- JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](2);
30
- _payoutLimits[0] =
31
- JBCurrencyAmount({amount: _payoutLimit, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
32
-
33
- // Specify a second payout limit.
34
- // forge-lint: disable-next-line(unsafe-typecast)
35
- _payoutLimits[1] = JBCurrencyAmount({amount: _payoutLimit2, currency: uint32(uint160(_someToken))});
36
-
37
- // Specify a surplus allowance.
38
- JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](0);
39
-
40
- _fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
41
- terminal: address(_terminal),
42
- token: JBConstants.NATIVE_TOKEN,
43
- payoutLimits: _payoutLimits,
44
- surplusAllowances: _surplusAllowances
45
- });
46
-
47
- _fundAccessLimitGroup[1] = JBFundAccessLimitGroup({
48
- terminal: address(_terminal2),
49
- token: JBConstants.NATIVE_TOKEN,
50
- payoutLimits: _payoutLimits,
51
- surplusAllowances: _surplusAllowances
52
- });
53
- }
54
-
55
- bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
56
- bytes memory _return = abi.encode(address(this));
57
-
58
- mockExpect(address(directory), _controllerCall, _return);
59
-
60
- _fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
61
- _fundAccess.setFundAccessLimitsFor(_projectId, _ruleset + 1, _fundAccessLimitGroup);
62
- _;
63
- }
64
-
65
- function test_GivenTheyAreConfiguredForASpecificToken() external whenAProjectHasPayoutLimits {
66
- // it will return them
67
-
68
- JBCurrencyAmount[] memory payoutLimits =
69
- _fundAccess.payoutLimitsOf(_projectId, _ruleset, _terminal, JBConstants.NATIVE_TOKEN);
70
-
71
- assertEq(payoutLimits[0].currency, uint32(uint160(JBConstants.NATIVE_TOKEN)));
72
- assertEq(payoutLimits[0].amount, _payoutLimit);
73
- // forge-lint: disable-next-line(unsafe-typecast)
74
- assertEq(payoutLimits[1].currency, uint32(uint160(_someToken)));
75
- assertEq(payoutLimits[1].amount, _payoutLimit2);
76
- }
77
-
78
- function test_GivenTheyAreConfiguredForASpecificTerminal() external whenAProjectHasPayoutLimits {
79
- // it will return them
80
- JBCurrencyAmount[] memory payoutLimits =
81
- _fundAccess.payoutLimitsOf(_projectId, _ruleset, _terminal2, JBConstants.NATIVE_TOKEN);
82
-
83
- assertEq(payoutLimits[0].currency, uint32(uint160(JBConstants.NATIVE_TOKEN)));
84
- assertEq(payoutLimits[0].amount, _payoutLimit);
85
- // forge-lint: disable-next-line(unsafe-typecast)
86
- assertEq(payoutLimits[1].currency, uint32(uint160(_someToken)));
87
- assertEq(payoutLimits[1].amount, _payoutLimit2);
88
- }
89
-
90
- function test_GivenTheyAreConfiguredForASpecificRulesetId() external whenAProjectHasPayoutLimits {
91
- // it will return them
92
- JBCurrencyAmount[] memory payoutLimits =
93
- _fundAccess.payoutLimitsOf(_projectId, _ruleset + 1, _terminal2, JBConstants.NATIVE_TOKEN);
94
-
95
- assertEq(payoutLimits[0].currency, uint32(uint160(JBConstants.NATIVE_TOKEN)));
96
- assertEq(payoutLimits[0].amount, _payoutLimit);
97
- // forge-lint: disable-next-line(unsafe-typecast)
98
- assertEq(payoutLimits[1].currency, uint32(uint160(_someToken)));
99
- assertEq(payoutLimits[1].amount, _payoutLimit2);
100
- }
101
- }
@@ -1,189 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {JBFundAccessLimits} from "../../../../src/JBFundAccessLimits.sol";
5
- import {JBControlled} from "../../../../src/abstract/JBControlled.sol";
6
- import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
7
- import {IJBFundAccessLimits} from "../../../../src/interfaces/IJBFundAccessLimits.sol";
8
- import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
9
- import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
10
- import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
11
- import {JBFundAccessSetup} from "./JBFundAccessSetup.sol";
12
-
13
- contract TestSetFundAccessLimitsFor_Local is JBFundAccessSetup {
14
- uint256 _projectId = 1;
15
- uint256 _ruleset = block.timestamp;
16
- uint32 _validCurrency = uint32(uint160(JBConstants.NATIVE_TOKEN));
17
- address _terminal = address(1);
18
- address _terminal2 = address(2);
19
- address _someToken = makeAddr("sometoken");
20
- uint224 _validLimit = 1e18;
21
-
22
- function setUp() public {
23
- super.fundAccessSetup();
24
- }
25
-
26
- function test_WhenCallerIsNotController() external {
27
- // it will revert
28
-
29
- bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
30
- bytes memory _return = abi.encode(address(makeAddr("notThisContract")));
31
-
32
- mockExpect(address(directory), _controllerCall, _return);
33
-
34
- // Fund Access config
35
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
36
-
37
- vm.expectRevert(
38
- abi.encodeWithSelector(
39
- JBControlled.JBControlled_ControllerUnauthorized.selector, address(makeAddr("notThisContract"))
40
- )
41
- );
42
- _fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
43
- }
44
-
45
- modifier whenCallerIsControllerOfProject() {
46
- bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
47
- bytes memory _return = abi.encode(address(this));
48
-
49
- mockExpect(address(directory), _controllerCall, _return);
50
- _;
51
- }
52
-
53
- function test_GivenPayoutLimitCurrencyIsNotGivenInAscendingOrder() external whenCallerIsControllerOfProject {
54
- // it will revert INVALID_PAYOUT_LIMIT_CURRENCY_ORDERING
55
-
56
- // Fund Access config
57
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
58
- {
59
- // Specify a payout limit.
60
- JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](2);
61
- _payoutLimits[0] = JBCurrencyAmount({amount: _validLimit, currency: type(uint32).max});
62
-
63
- // Specify a second payout limit.
64
- _payoutLimits[1] =
65
- JBCurrencyAmount({amount: _validLimit, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
66
-
67
- // Specify a surplus allowance.
68
- JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](0);
69
-
70
- _fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
71
- terminal: address(_terminal),
72
- token: JBConstants.NATIVE_TOKEN,
73
- payoutLimits: _payoutLimits,
74
- surplusAllowances: _surplusAllowances
75
- });
76
- }
77
-
78
- vm.expectRevert(JBFundAccessLimits.JBFundAccessLimits_InvalidPayoutLimitCurrencyOrdering.selector);
79
- _fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
80
- }
81
-
82
- function test_GivenSurplusAllowanceCurrenciesAreNotAscendingOrder() external whenCallerIsControllerOfProject {
83
- // it will revert INVALID_SURPLUS_ALLOWANCE_CURRENCY_ORDERING
84
-
85
- // Fund Access config
86
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
87
- {
88
- // Specify a payout limit.
89
- JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](1);
90
- _payoutLimits[0] = JBCurrencyAmount({amount: _validLimit, currency: _validCurrency});
91
-
92
- // Specify a surplus allowance.
93
- JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](2);
94
- _surplusAllowances[0] = JBCurrencyAmount({amount: _validLimit, currency: type(uint32).max});
95
-
96
- _surplusAllowances[1] = JBCurrencyAmount({amount: _validLimit, currency: _validCurrency});
97
-
98
- _fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
99
- terminal: address(_terminal),
100
- token: JBConstants.NATIVE_TOKEN,
101
- payoutLimits: _payoutLimits,
102
- surplusAllowances: _surplusAllowances
103
- });
104
- }
105
-
106
- vm.expectRevert(JBFundAccessLimits.JBFundAccessLimits_InvalidSurplusAllowanceCurrencyOrdering.selector);
107
- _fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
108
- }
109
-
110
- function test_GivenValidConfig() external whenCallerIsControllerOfProject {
111
- // it will set packed properties and emit SetFundAccessLimits
112
-
113
- // Fund Access config
114
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
115
- {
116
- // Specify a payout limit.
117
- JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](2);
118
- _payoutLimits[0] =
119
- JBCurrencyAmount({amount: _validLimit, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
120
-
121
- // Specify a second payout limit.
122
- // forge-lint: disable-next-line(unsafe-typecast)
123
- _payoutLimits[1] = JBCurrencyAmount({amount: _validLimit, currency: uint32(uint160(_someToken))});
124
-
125
- // Specify a surplus allowance.
126
- JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](0);
127
-
128
- _fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
129
- terminal: address(_terminal),
130
- token: JBConstants.NATIVE_TOKEN,
131
- payoutLimits: _payoutLimits,
132
- surplusAllowances: _surplusAllowances
133
- });
134
-
135
- _fundAccessLimitGroup[1] = JBFundAccessLimitGroup({
136
- terminal: address(_terminal2),
137
- token: JBConstants.NATIVE_TOKEN,
138
- payoutLimits: _payoutLimits,
139
- surplusAllowances: _surplusAllowances
140
- });
141
- }
142
-
143
- vm.expectEmit();
144
- emit IJBFundAccessLimits.SetFundAccessLimits(_ruleset, _projectId, _fundAccessLimitGroup[0], address(this));
145
-
146
- vm.expectEmit();
147
- emit IJBFundAccessLimits.SetFundAccessLimits(_ruleset, _projectId, _fundAccessLimitGroup[1], address(this));
148
-
149
- _fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
150
- }
151
-
152
- function test_GivenValidConfigWithLimitsZero() external whenCallerIsControllerOfProject {
153
- // it will set packed properties and emit SetFundAccessLimits
154
-
155
- // Fund Access config
156
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
157
- {
158
- // Specify a payout limit.
159
- JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](1);
160
- _payoutLimits[0] = JBCurrencyAmount({amount: 0, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
161
-
162
- // Specify a surplus allowance.
163
- JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](1);
164
- _surplusAllowances[0] = JBCurrencyAmount({amount: 0, currency: type(uint32).max});
165
-
166
- _fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
167
- terminal: address(_terminal),
168
- token: JBConstants.NATIVE_TOKEN,
169
- payoutLimits: _payoutLimits,
170
- surplusAllowances: _surplusAllowances
171
- });
172
-
173
- _fundAccessLimitGroup[1] = JBFundAccessLimitGroup({
174
- terminal: address(_terminal2),
175
- token: JBConstants.NATIVE_TOKEN,
176
- payoutLimits: _payoutLimits,
177
- surplusAllowances: _surplusAllowances
178
- });
179
- }
180
-
181
- vm.expectEmit();
182
- emit IJBFundAccessLimits.SetFundAccessLimits(_ruleset, _projectId, _fundAccessLimitGroup[0], address(this));
183
-
184
- vm.expectEmit();
185
- emit IJBFundAccessLimits.SetFundAccessLimits(_ruleset, _projectId, _fundAccessLimitGroup[1], address(this));
186
-
187
- _fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
188
- }
189
- }
@@ -1,64 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
5
- import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
6
- import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
7
- import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
8
- import {JBFundAccessSetup} from "./JBFundAccessSetup.sol";
9
-
10
- contract TestSurplusAllowanceOf_Local is JBFundAccessSetup {
11
- uint256 _projectId = 1;
12
- address _terminal = address(1);
13
-
14
- function setUp() public {
15
- super.fundAccessSetup();
16
- }
17
-
18
- modifier whenCallerIsControllerOfProject() {
19
- bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
20
- bytes memory _return = abi.encode(address(this));
21
-
22
- mockExpect(address(directory), _controllerCall, _return);
23
- _;
24
- }
25
-
26
- function test_WhenAProjectHasTheSpecificSurplusConfigured() external whenCallerIsControllerOfProject {
27
- // it will return uint256 surplusAllowance
28
-
29
- // Fund Access config
30
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
31
- {
32
- // Specify a payout limit.
33
- JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](0);
34
-
35
- // Specify a surplus allowance.
36
- JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](1);
37
- _surplusAllowances[0] =
38
- JBCurrencyAmount({amount: 1e18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
39
-
40
- _fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
41
- terminal: _terminal,
42
- token: JBConstants.NATIVE_TOKEN,
43
- payoutLimits: _payoutLimits,
44
- surplusAllowances: _surplusAllowances
45
- });
46
- }
47
-
48
- _fundAccess.setFundAccessLimitsFor(_projectId, block.timestamp, _fundAccessLimitGroup);
49
-
50
- uint256 _returned = _fundAccess.surplusAllowanceOf(
51
- _projectId, block.timestamp, _terminal, JBConstants.NATIVE_TOKEN, uint32(uint160(JBConstants.NATIVE_TOKEN))
52
- );
53
- assertEq(_returned, 1e18);
54
- }
55
-
56
- function test_WhenItDoesntHaveTheSpecificSurplusConfigured() external view {
57
- // it will return 0
58
-
59
- uint256 _returned = _fundAccess.surplusAllowanceOf(
60
- _projectId, block.timestamp, _terminal, JBConstants.NATIVE_TOKEN, uint32(uint160(JBConstants.NATIVE_TOKEN))
61
- );
62
- assertEq(_returned, 0);
63
- }
64
- }