@bananapus/core-v6 0.0.37 → 0.0.39

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 (324) hide show
  1. package/foundry.lock +1 -7
  2. package/foundry.toml +1 -1
  3. package/package.json +19 -7
  4. package/src/JBChainlinkV3PriceFeed.sol +4 -1
  5. package/src/JBChainlinkV3SequencerPriceFeed.sol +4 -2
  6. package/src/JBController.sol +71 -44
  7. package/src/JBDeadline.sol +4 -4
  8. package/src/JBDirectory.sol +34 -32
  9. package/src/JBERC20.sol +5 -4
  10. package/src/JBFeelessAddresses.sol +6 -3
  11. package/src/JBFundAccessLimits.sol +25 -21
  12. package/src/JBMultiTerminal.sol +121 -84
  13. package/src/JBPermissions.sol +34 -37
  14. package/src/JBPrices.sol +23 -18
  15. package/src/JBProjects.sol +6 -3
  16. package/src/JBRulesets.sol +44 -41
  17. package/src/JBSplits.sol +18 -16
  18. package/src/JBTerminalStore.sol +32 -25
  19. package/src/JBTokens.sol +36 -26
  20. package/src/abstract/JBControlled.sol +3 -1
  21. package/src/abstract/JBPermissioned.sol +3 -1
  22. package/src/enums/JBApprovalStatus.sol +7 -1
  23. package/src/interfaces/IJBController.sol +7 -3
  24. package/src/interfaces/IJBDirectory.sol +3 -1
  25. package/src/interfaces/IJBMultiTerminal.sol +3 -2
  26. package/src/interfaces/IJBPermissions.sol +2 -1
  27. package/src/interfaces/IJBPrices.sol +3 -1
  28. package/src/interfaces/IJBRulesets.sol +2 -1
  29. package/src/interfaces/IJBSplits.sol +2 -1
  30. package/src/interfaces/IJBTerminal.sol +3 -1
  31. package/src/interfaces/IJBTerminalStore.sol +3 -1
  32. package/src/interfaces/IJBTokens.sol +2 -1
  33. package/src/libraries/JBCashOuts.sol +6 -1
  34. package/src/libraries/JBConstants.sol +12 -3
  35. package/src/libraries/JBCurrencyIds.sol +2 -0
  36. package/src/libraries/JBFees.sol +52 -10
  37. package/src/libraries/JBFixedPointNumber.sol +2 -0
  38. package/src/libraries/JBPayoutSplitGroupLib.sol +7 -4
  39. package/src/libraries/JBRulesetMetadataResolver.sol +4 -0
  40. package/src/libraries/JBSplitGroupIds.sol +2 -1
  41. package/src/libraries/JBSurplus.sol +3 -1
  42. package/src/periphery/JBMatchingPriceFeed.sol +3 -1
  43. package/src/structs/JBAccountingContext.sol +7 -4
  44. package/src/structs/JBFundAccessLimitGroup.sol +10 -17
  45. package/src/structs/JBRuleset.sol +18 -26
  46. package/src/structs/JBRulesetConfig.sol +13 -25
  47. package/src/structs/JBRulesetMetadata.sol +25 -32
  48. package/test/mock/MockMaliciousBeneficiary.sol +15 -15
  49. package/ADMINISTRATION.md +0 -103
  50. package/ARCHITECTURE.md +0 -133
  51. package/AUDIT_INSTRUCTIONS.md +0 -139
  52. package/RISKS.md +0 -215
  53. package/SKILLS.md +0 -55
  54. package/STYLE_GUIDE.md +0 -610
  55. package/USER_JOURNEYS.md +0 -215
  56. package/script/Deploy.s.sol +0 -124
  57. package/script/DeployPeriphery.s.sol +0 -354
  58. package/slither-ci.config.json +0 -10
  59. package/test/AuditFixes.t.sol +0 -808
  60. package/test/ComprehensiveInvariant.t.sol +0 -306
  61. package/test/CoreExploitTests.t.sol +0 -2741
  62. package/test/EconomicSimulation.t.sol +0 -348
  63. package/test/EntryPointPermutations.t.sol +0 -684
  64. package/test/FlashLoanAttacks.t.sol +0 -797
  65. package/test/PermissionEscalation.t.sol +0 -711
  66. package/test/PermissionsInvariant.t.sol +0 -403
  67. package/test/RulesetTransitions.t.sol +0 -713
  68. package/test/SplitLoopTests.t.sol +0 -752
  69. package/test/TestAccessToFunds.sol +0 -2683
  70. package/test/TestAuditResponseDesignProofs.sol +0 -434
  71. package/test/TestCashOut.sol +0 -198
  72. package/test/TestCashOutCountFor.sol +0 -271
  73. package/test/TestCashOutHooks.sol +0 -351
  74. package/test/TestCashOutTimingEdge.sol +0 -241
  75. package/test/TestDataHookFuzzing.sol +0 -524
  76. package/test/TestDurationUnderflow.sol +0 -233
  77. package/test/TestFeeFreeCashOutBypass.sol +0 -949
  78. package/test/TestFeeProcessingFailure.sol +0 -218
  79. package/test/TestFees.sol +0 -619
  80. package/test/TestForwardedTokenConsumption.sol +0 -425
  81. package/test/TestInterfaceSupport.sol +0 -81
  82. package/test/TestJBERC20Inheritance.sol +0 -103
  83. package/test/TestL2SequencerPriceFeed.sol +0 -292
  84. package/test/TestLaunchProject.sol +0 -188
  85. package/test/TestMetaTx.sol +0 -217
  86. package/test/TestMetadataOffsetOverflow.sol +0 -179
  87. package/test/TestMetadataParserLib.sol +0 -471
  88. package/test/TestMigrationHeldFees.sol +0 -255
  89. package/test/TestMintTokensOf.sol +0 -185
  90. package/test/TestMultiTerminalSurplus.sol +0 -348
  91. package/test/TestMultiTokenSurplus.sol +0 -202
  92. package/test/TestMultipleAccessLimits.sol +0 -664
  93. package/test/TestPayBurnRedeemFlow.sol +0 -195
  94. package/test/TestPayHooks.sol +0 -209
  95. package/test/TestPermissions.sol +0 -324
  96. package/test/TestPermissionsEdge.sol +0 -290
  97. package/test/TestPermit2DataHook.t.sol +0 -360
  98. package/test/TestPermit2Terminal.sol +0 -372
  99. package/test/TestRulesetQueueing.sol +0 -1025
  100. package/test/TestRulesetQueuingStress.sol +0 -806
  101. package/test/TestRulesetWeightCaching.sol +0 -178
  102. package/test/TestSplits.sol +0 -391
  103. package/test/TestTerminalMigration.sol +0 -274
  104. package/test/TestTerminalPreviewParity.sol +0 -208
  105. package/test/TestTokenFlow.sol +0 -191
  106. package/test/TestWeightCacheStaleAfterRejection.sol +0 -303
  107. package/test/WeirdTokenTests.t.sol +0 -817
  108. package/test/audit/CashOutReenterPay.t.sol +0 -501
  109. package/test/audit/CodexHeldFeeRounding.t.sol +0 -159
  110. package/test/audit/CodexMigrationFeeFailure.t.sol +0 -163
  111. package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
  112. package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
  113. package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
  114. package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
  115. package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
  116. package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
  117. package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
  118. package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
  119. package/test/formal/BondingCurveProperties.t.sol +0 -420
  120. package/test/formal/FeeProperties.t.sol +0 -252
  121. package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
  122. package/test/invariants/RulesetsInvariant.t.sol +0 -125
  123. package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
  124. package/test/invariants/TokensInvariant.t.sol +0 -195
  125. package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
  126. package/test/invariants/handlers/EconomicHandler.sol +0 -377
  127. package/test/invariants/handlers/Phase3Handler.sol +0 -443
  128. package/test/invariants/handlers/RulesetsHandler.sol +0 -115
  129. package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
  130. package/test/invariants/handlers/TokensHandler.sol +0 -126
  131. package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
  132. package/test/regression/WeightCacheBoundary.t.sol +0 -291
  133. package/test/trees/JBController/burnTokensOf.tree +0 -9
  134. package/test/trees/JBController/claimTokensFor.tree +0 -5
  135. package/test/trees/JBController/deployERC20For.tree +0 -5
  136. package/test/trees/JBController/getRulesetOf.tree +0 -5
  137. package/test/trees/JBController/launchProjectFor.tree +0 -12
  138. package/test/trees/JBController/launchRulesetsFor.tree +0 -8
  139. package/test/trees/JBController/migrateController.tree +0 -12
  140. package/test/trees/JBController/mintTokensOf.tree +0 -12
  141. package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
  142. package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
  143. package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
  144. package/test/trees/JBController/setMetadataOf.tree +0 -5
  145. package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
  146. package/test/trees/JBController/setTokenFor.tree +0 -5
  147. package/test/trees/JBController/transferCreditsFrom.tree +0 -8
  148. package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
  149. package/test/trees/JBDirectory/setControllerOf.tree +0 -11
  150. package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
  151. package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
  152. package/test/trees/JBERC20/initialize.tree +0 -7
  153. package/test/trees/JBERC20/name.tree +0 -5
  154. package/test/trees/JBERC20/nonces.tree +0 -5
  155. package/test/trees/JBERC20/symbol.tree +0 -5
  156. package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
  157. package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
  158. package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
  159. package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
  160. package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
  161. package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
  162. package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
  163. package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
  164. package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
  165. package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
  166. package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
  167. package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
  168. package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
  169. package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
  170. package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
  171. package/test/trees/JBMultiTerminal/pay.tree +0 -23
  172. package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
  173. package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
  174. package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
  175. package/test/trees/JBPermissions/hasPermission.tree +0 -8
  176. package/test/trees/JBPermissions/hasPermissions.tree +0 -8
  177. package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
  178. package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
  179. package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
  180. package/test/trees/JBProjects/createFor.tree +0 -11
  181. package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
  182. package/test/trees/JBProjects/supportsInterface.tree +0 -9
  183. package/test/trees/JBProjects/tokenURI.tree +0 -5
  184. package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
  185. package/test/trees/JBRulesets/currentOf.tree +0 -12
  186. package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
  187. package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
  188. package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
  189. package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
  190. package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
  191. package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
  192. package/test/trees/JBSplits/splitsOf.tree +0 -5
  193. package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
  194. package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
  195. package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
  196. package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
  197. package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
  198. package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
  199. package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
  200. package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
  201. package/test/trees/JBTokens/burnFrom.tree +0 -10
  202. package/test/trees/JBTokens/claimTokensFor.tree +0 -10
  203. package/test/trees/JBTokens/deployERC20For.tree +0 -12
  204. package/test/trees/JBTokens/mintFor.tree +0 -10
  205. package/test/trees/JBTokens/setTokenFor.tree +0 -11
  206. package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
  207. package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
  208. package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
  209. package/test/trees/mintTokensOf.tree +0 -12
  210. package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
  211. package/test/units/static/JBController/JBControllerSetup.sol +0 -50
  212. package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
  213. package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
  214. package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
  215. package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
  216. package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
  217. package/test/units/static/JBController/TestMigrateController.sol +0 -157
  218. package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
  219. package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
  220. package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
  221. package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
  222. package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
  223. package/test/units/static/JBController/TestRulesetViews.sol +0 -225
  224. package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
  225. package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
  226. package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
  227. package/test/units/static/JBController/TestSetUriOf.sol +0 -57
  228. package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
  229. package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
  230. package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
  231. package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
  232. package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
  233. package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
  234. package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
  235. package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
  236. package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
  237. package/test/units/static/JBERC20/SigUtils.sol +0 -36
  238. package/test/units/static/JBERC20/TestInitialize.sol +0 -60
  239. package/test/units/static/JBERC20/TestName.sol +0 -30
  240. package/test/units/static/JBERC20/TestNonces.sol +0 -62
  241. package/test/units/static/JBERC20/TestSymbol.sol +0 -31
  242. package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
  243. package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
  244. package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
  245. package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
  246. package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
  247. package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
  248. package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
  249. package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
  250. package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
  251. package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
  252. package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
  253. package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
  254. package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
  255. package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
  256. package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
  257. package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
  258. package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
  259. package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
  260. package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
  261. package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
  262. package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
  263. package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
  264. package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
  265. package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
  266. package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
  267. package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
  268. package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
  269. package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
  270. package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
  271. package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
  272. package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
  273. package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
  274. package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
  275. package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
  276. package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
  277. package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
  278. package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
  279. package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
  280. package/test/units/static/JBPrices/TestPrices.sol +0 -265
  281. package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
  282. package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
  283. package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
  284. package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
  285. package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
  286. package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
  287. package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
  288. package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
  289. package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
  290. package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
  291. package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
  292. package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
  293. package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
  294. package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
  295. package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
  296. package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
  297. package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
  298. package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
  299. package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
  300. package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
  301. package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
  302. package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
  303. package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
  304. package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
  305. package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
  306. package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
  307. package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
  308. package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
  309. package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
  310. package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
  311. package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
  312. package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
  313. package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
  314. package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
  315. package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
  316. package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
  317. package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
  318. package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
  319. package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
  320. package/test/units/static/JBTokens/TestMintFor.sol +0 -100
  321. package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
  322. package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
  323. package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
  324. 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
- }