@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,713 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.6;
3
-
4
- import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
5
- import {JBApprovalStatus} from "../src/enums/JBApprovalStatus.sol";
6
- import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
7
- import {JBConstants} from "../src/libraries/JBConstants.sol";
8
- import {JBRulesetMetadataResolver} from "../src/libraries/JBRulesetMetadataResolver.sol";
9
- import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
10
- import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
11
- import {JBRuleset} from "../src/structs/JBRuleset.sol";
12
- import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
13
- import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
14
- import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
15
- import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
16
- import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
17
- import {ERC165, IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
18
-
19
- /// @notice Tests for ruleset transition edge cases: boundary timing, weight decay, approval hooks, limit resets.
20
- contract RulesetTransitions_Local is TestBaseWorkflow {
21
- using JBRulesetMetadataResolver for JBRuleset;
22
-
23
- address public projectOwner;
24
-
25
- function setUp() public override {
26
- super.setUp();
27
- projectOwner = multisig();
28
-
29
- // Launch fee collector project (#1)
30
- _launchFeeProject();
31
- }
32
-
33
- // ═══════════════════════════════════════════════════════════════════
34
- // Helpers
35
- // ═══════════════════════════════════════════════════════════════════
36
-
37
- function _launchFeeProject() internal {
38
- JBRulesetConfig[] memory feeRulesetConfig = new JBRulesetConfig[](1);
39
- feeRulesetConfig[0].mustStartAtOrAfter = 0;
40
- feeRulesetConfig[0].duration = 0;
41
- feeRulesetConfig[0].weight = 1000e18;
42
- feeRulesetConfig[0].weightCutPercent = 0;
43
- feeRulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
44
- feeRulesetConfig[0].metadata = JBRulesetMetadata({
45
- reservedPercent: 0,
46
- cashOutTaxRate: 0,
47
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
48
- pausePay: false,
49
- pauseCreditTransfers: false,
50
- allowOwnerMinting: false,
51
- allowSetCustomToken: false,
52
- allowTerminalMigration: false,
53
- allowSetTerminals: false,
54
- ownerMustSendPayouts: false,
55
- allowSetController: false,
56
- allowAddAccountingContext: true,
57
- allowAddPriceFeed: false,
58
- holdFees: false,
59
- useTotalSurplusForCashOuts: false,
60
- useDataHookForPay: false,
61
- useDataHookForCashOut: false,
62
- dataHook: address(0),
63
- metadata: 0
64
- });
65
- feeRulesetConfig[0].splitGroups = new JBSplitGroup[](0);
66
- feeRulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
67
-
68
- JBTerminalConfig[] memory terminalConfigurations = _defaultTerminalConfig();
69
-
70
- jbController()
71
- .launchProjectFor({
72
- owner: address(420),
73
- projectUri: "feeCollector",
74
- rulesetConfigurations: feeRulesetConfig,
75
- terminalConfigurations: terminalConfigurations,
76
- memo: ""
77
- });
78
- }
79
-
80
- function _defaultTerminalConfig() internal view returns (JBTerminalConfig[] memory) {
81
- JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
82
- JBAccountingContext[] memory tokensToAccept = new JBAccountingContext[](1);
83
- tokensToAccept[0] = JBAccountingContext({
84
- token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
85
- });
86
- terminalConfigurations[0] =
87
- JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: tokensToAccept});
88
- return terminalConfigurations;
89
- }
90
-
91
- function _defaultMetadata() internal pure returns (JBRulesetMetadata memory) {
92
- return JBRulesetMetadata({
93
- reservedPercent: 0,
94
- cashOutTaxRate: 0,
95
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
96
- pausePay: false,
97
- pauseCreditTransfers: false,
98
- allowOwnerMinting: true,
99
- allowSetCustomToken: true,
100
- allowTerminalMigration: false,
101
- allowSetTerminals: false,
102
- ownerMustSendPayouts: false,
103
- allowSetController: false,
104
- allowAddAccountingContext: true,
105
- allowAddPriceFeed: false,
106
- holdFees: false,
107
- useTotalSurplusForCashOuts: false,
108
- useDataHookForPay: false,
109
- useDataHookForCashOut: false,
110
- dataHook: address(0),
111
- metadata: 0
112
- });
113
- }
114
-
115
- function _payProject(uint256 pid, address payer, uint256 amount) internal returns (uint256) {
116
- vm.deal(payer, amount);
117
- vm.prank(payer);
118
- return jbMultiTerminal().pay{value: amount}({
119
- projectId: pid,
120
- token: JBConstants.NATIVE_TOKEN,
121
- amount: amount,
122
- beneficiary: payer,
123
- minReturnedTokens: 0,
124
- memo: "",
125
- metadata: new bytes(0)
126
- });
127
- }
128
-
129
- // ═══════════════════════════════════════════════════════════════════
130
- // Test 1: Pay at cycle boundary — different weights
131
- // ═══════════════════════════════════════════════════════════════════
132
-
133
- function test_rulesetTransition_payAtBoundary() public {
134
- // Launch with 7-day duration, 50% weight cut
135
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
136
- rulesetConfig[0].mustStartAtOrAfter = 0;
137
- rulesetConfig[0].duration = 7 days;
138
- rulesetConfig[0].weight = 1000e18;
139
- rulesetConfig[0].weightCutPercent = uint32(JBConstants.MAX_WEIGHT_CUT_PERCENT / 2); // 50%
140
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
141
- rulesetConfig[0].metadata = _defaultMetadata();
142
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
143
- rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
144
-
145
- uint256 pid = jbController()
146
- .launchProjectFor({
147
- owner: projectOwner,
148
- projectUri: "boundaryTest",
149
- rulesetConfigurations: rulesetConfig,
150
- terminalConfigurations: _defaultTerminalConfig(),
151
- memo: ""
152
- });
153
-
154
- // Pay at last second of cycle 1
155
- vm.warp(block.timestamp + 7 days - 1);
156
- uint256 tokensCycle1 = _payProject(pid, address(0xA11CE), 1 ether);
157
-
158
- // Pay at first second of cycle 2
159
- vm.warp(block.timestamp + 2); // crosses boundary
160
- uint256 tokensCycle2 = _payProject(pid, address(0xB0B), 1 ether);
161
-
162
- // Cycle 2 has 50% of cycle 1's weight → should mint half the tokens
163
- assertGt(tokensCycle1, tokensCycle2, "Cycle 2 should mint fewer tokens due to weight cut");
164
- // With 50% cut: cycle2 tokens should be ~half of cycle1
165
- assertApproxEqRel(tokensCycle2, tokensCycle1 / 2, 0.01e18, "Cycle 2 tokens should be ~50% of cycle 1");
166
- }
167
-
168
- // ═══════════════════════════════════════════════════════════════════
169
- // Test 2: Cash out across cycles — uses current tax rate
170
- // ═══════════════════════════════════════════════════════════════════
171
-
172
- function test_rulesetTransition_cashOutAcrossCycles() public {
173
- // Cycle 1: 0% tax. Queue cycle 2: 90% tax
174
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
175
- rulesetConfig[0].mustStartAtOrAfter = 0;
176
- rulesetConfig[0].duration = 7 days;
177
- rulesetConfig[0].weight = 1000e18;
178
- rulesetConfig[0].weightCutPercent = 0;
179
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
180
- rulesetConfig[0].metadata = _defaultMetadata();
181
- rulesetConfig[0].metadata.cashOutTaxRate = 0;
182
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
183
- rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
184
-
185
- uint256 pid = jbController()
186
- .launchProjectFor({
187
- owner: projectOwner,
188
- projectUri: "cashOutCycleTest",
189
- rulesetConfigurations: rulesetConfig,
190
- terminalConfigurations: _defaultTerminalConfig(),
191
- memo: ""
192
- });
193
-
194
- // Pay in cycle 1
195
- address alice = address(0xA11CE);
196
- uint256 aliceTokens = _payProject(pid, alice, 10 ether);
197
-
198
- // Queue new ruleset with 90% cashOutTaxRate
199
- JBRulesetConfig[] memory newConfig = new JBRulesetConfig[](1);
200
- newConfig[0].mustStartAtOrAfter = 0;
201
- newConfig[0].duration = 7 days;
202
- newConfig[0].weight = 1000e18;
203
- newConfig[0].weightCutPercent = 0;
204
- newConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
205
- newConfig[0].metadata = _defaultMetadata();
206
- newConfig[0].metadata.cashOutTaxRate = 9000; // 90%
207
- newConfig[0].splitGroups = new JBSplitGroup[](0);
208
- newConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
209
-
210
- vm.prank(projectOwner);
211
- jbController().queueRulesetsOf(pid, newConfig, "");
212
-
213
- // Advance to cycle 2
214
- vm.warp(block.timestamp + 7 days + 1);
215
-
216
- // Pay in second payer so Alice isn't the sole holder (tax has no effect on 100% cashout)
217
- address bob = address(0xB0B);
218
- _payProject(pid, bob, 10 ether);
219
-
220
- // Cash out Alice in cycle 2 — should use the new 90% tax rate
221
- vm.prank(alice);
222
- uint256 reclaimAmount = jbMultiTerminal()
223
- .cashOutTokensOf({
224
- holder: alice,
225
- projectId: pid,
226
- cashOutCount: aliceTokens,
227
- tokenToReclaim: JBConstants.NATIVE_TOKEN,
228
- minTokensReclaimed: 0,
229
- beneficiary: payable(alice),
230
- metadata: new bytes(0)
231
- });
232
-
233
- // With 90% tax on partial cashout (50% of supply), reclaim is significantly reduced
234
- // The bonding curve formula penalizes partial cashouts with high tax
235
- assertLt(reclaimAmount, 10 ether, "90% tax should reduce reclaim below payment amount");
236
- }
237
-
238
- // ═══════════════════════════════════════════════════════════════════
239
- // Test 3: Weight decay — 10 cycles accuracy
240
- // ═══════════════════════════════════════════════════════════════════
241
-
242
- function test_weightDecay_multiCycle_accuracy() public {
243
- // 10% weight cut per cycle
244
- uint32 tenPercentCut = uint32(JBConstants.MAX_WEIGHT_CUT_PERCENT / 10);
245
-
246
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
247
- rulesetConfig[0].mustStartAtOrAfter = 0;
248
- rulesetConfig[0].duration = 1 days;
249
- rulesetConfig[0].weight = 1000e18;
250
- rulesetConfig[0].weightCutPercent = tenPercentCut;
251
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
252
- rulesetConfig[0].metadata = _defaultMetadata();
253
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
254
- rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
255
-
256
- uint256 pid = jbController()
257
- .launchProjectFor({
258
- owner: projectOwner,
259
- projectUri: "decayTest",
260
- rulesetConfigurations: rulesetConfig,
261
- terminalConfigurations: _defaultTerminalConfig(),
262
- memo: ""
263
- });
264
-
265
- // Record tokens minted per cycle
266
- uint256[] memory tokensPerCycle = new uint256[](10);
267
- for (uint256 i = 0; i < 10; i++) {
268
- if (i > 0) vm.warp(block.timestamp + 1 days + 1);
269
- // forge-lint: disable-next-line(unsafe-typecast)
270
- tokensPerCycle[i] = _payProject(pid, address(uint160(0x6000 + i)), 1 ether);
271
- }
272
-
273
- // Each cycle should mint ~90% of previous
274
- for (uint256 i = 1; i < 10; i++) {
275
- assertLt(tokensPerCycle[i], tokensPerCycle[i - 1], "Each cycle should mint fewer tokens");
276
- // Within 1% tolerance of 90% ratio
277
- uint256 expectedRatio = 900; // 90%
278
- uint256 actualRatio = (tokensPerCycle[i] * 1000) / tokensPerCycle[i - 1];
279
- assertApproxEqAbs(actualRatio, expectedRatio, 5, "Weight decay ratio should be ~90%");
280
- }
281
-
282
- // After 10 cycles (9 weight transitions): weight ≈ 1000 * 0.9^9 ≈ 387.42
283
- // Cycle 10 tokens should be roughly 38.74% of cycle 1
284
- uint256 ratio = (tokensPerCycle[9] * 10_000) / tokensPerCycle[0];
285
- assertApproxEqAbs(ratio, 3874, 50, "After 9 weight transitions, weight should be ~38.74% of original");
286
- }
287
-
288
- // ═══════════════════════════════════════════════════════════════════
289
- // Test 4: 100% weight cut kills weight
290
- // ═══════════════════════════════════════════════════════════════════
291
-
292
- function test_weightDecay_100percent_killsWeight() public {
293
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
294
- rulesetConfig[0].mustStartAtOrAfter = 0;
295
- rulesetConfig[0].duration = 1 days;
296
- rulesetConfig[0].weight = 1000e18;
297
- rulesetConfig[0].weightCutPercent = uint32(JBConstants.MAX_WEIGHT_CUT_PERCENT); // 100%
298
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
299
- rulesetConfig[0].metadata = _defaultMetadata();
300
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
301
- rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
302
-
303
- uint256 pid = jbController()
304
- .launchProjectFor({
305
- owner: projectOwner,
306
- projectUri: "killWeightTest",
307
- rulesetConfigurations: rulesetConfig,
308
- terminalConfigurations: _defaultTerminalConfig(),
309
- memo: ""
310
- });
311
-
312
- // Cycle 1: normal minting
313
- uint256 cycle1Tokens = _payProject(pid, address(0xA11CE), 1 ether);
314
- assertGt(cycle1Tokens, 0, "Cycle 1 should mint tokens");
315
-
316
- // Advance to cycle 2
317
- vm.warp(block.timestamp + 1 days + 1);
318
-
319
- // Cycle 2: weight should be 0 → mint 0 tokens
320
- uint256 cycle2Tokens = _payProject(pid, address(0xB0B), 1 ether);
321
- assertEq(cycle2Tokens, 0, "100% weight cut should mint 0 tokens in cycle 2");
322
- }
323
-
324
- // ═══════════════════════════════════════════════════════════════════
325
- // Test 5: Queued ruleset overrides auto-cycle
326
- // ═══════════════════════════════════════════════════════════════════
327
-
328
- function test_queuedRuleset_overridesAutoCycle() public {
329
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
330
- rulesetConfig[0].mustStartAtOrAfter = 0;
331
- rulesetConfig[0].duration = 7 days;
332
- rulesetConfig[0].weight = 1000e18;
333
- rulesetConfig[0].weightCutPercent = uint32(JBConstants.MAX_WEIGHT_CUT_PERCENT / 2); // 50%
334
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
335
- rulesetConfig[0].metadata = _defaultMetadata();
336
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
337
- rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
338
-
339
- uint256 pid = jbController()
340
- .launchProjectFor({
341
- owner: projectOwner,
342
- projectUri: "queueOverrideTest",
343
- rulesetConfigurations: rulesetConfig,
344
- terminalConfigurations: _defaultTerminalConfig(),
345
- memo: ""
346
- });
347
-
348
- // Queue a new ruleset with different weight (2000e18 instead of auto-decayed 500e18)
349
- JBRulesetConfig[] memory newConfig = new JBRulesetConfig[](1);
350
- newConfig[0].mustStartAtOrAfter = 0;
351
- newConfig[0].duration = 7 days;
352
- newConfig[0].weight = 2000e18;
353
- newConfig[0].weightCutPercent = 0;
354
- newConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
355
- newConfig[0].metadata = _defaultMetadata();
356
- newConfig[0].splitGroups = new JBSplitGroup[](0);
357
- newConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
358
-
359
- vm.prank(projectOwner);
360
- jbController().queueRulesetsOf(pid, newConfig, "");
361
-
362
- // Advance to cycle 2
363
- vm.warp(block.timestamp + 7 days + 1);
364
-
365
- // Pay — should use queued weight (2000e18), not auto-decayed (500e18)
366
- uint256 tokens = _payProject(pid, address(0xA11CE), 1 ether);
367
-
368
- // With weight 2000e18 and 1 ETH, should get 2000 tokens
369
- assertEq(tokens, 2000e18, "Queued ruleset weight should override auto-cycle decay");
370
- }
371
-
372
- // ═══════════════════════════════════════════════════════════════════
373
- // Test 6: Approval hook — pending to approved
374
- // ═══════════════════════════════════════════════════════════════════
375
-
376
- function test_approvalHook_pendingToApproved() public {
377
- DelayedApprovalHook approvalHook = new DelayedApprovalHook(3 days);
378
-
379
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
380
- rulesetConfig[0].mustStartAtOrAfter = 0;
381
- rulesetConfig[0].duration = 7 days;
382
- rulesetConfig[0].weight = 1000e18;
383
- rulesetConfig[0].weightCutPercent = 0;
384
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(approvalHook));
385
- rulesetConfig[0].metadata = _defaultMetadata();
386
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
387
- rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
388
-
389
- uint256 pid = jbController()
390
- .launchProjectFor({
391
- owner: projectOwner,
392
- projectUri: "approvalTest",
393
- rulesetConfigurations: rulesetConfig,
394
- terminalConfigurations: _defaultTerminalConfig(),
395
- memo: ""
396
- });
397
-
398
- // Queue a new ruleset
399
- JBRulesetConfig[] memory newConfig = new JBRulesetConfig[](1);
400
- newConfig[0].mustStartAtOrAfter = 0;
401
- newConfig[0].duration = 7 days;
402
- newConfig[0].weight = 2000e18;
403
- newConfig[0].weightCutPercent = 0;
404
- newConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
405
- newConfig[0].metadata = _defaultMetadata();
406
- newConfig[0].splitGroups = new JBSplitGroup[](0);
407
- newConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
408
-
409
- vm.prank(projectOwner);
410
- jbController().queueRulesetsOf(pid, newConfig, "");
411
-
412
- // Check status before approval period
413
- (,, JBApprovalStatus statusBefore) = jbController().latestQueuedRulesetOf(pid);
414
- // Status should be ApprovalExpected (pending)
415
- assertTrue(
416
- statusBefore == JBApprovalStatus.ApprovalExpected || statusBefore == JBApprovalStatus.Approved,
417
- "Status should be ApprovalExpected or Approved initially"
418
- );
419
-
420
- // Advance past approval delay (3 days)
421
- vm.warp(block.timestamp + 4 days);
422
-
423
- // Status should now be Approved
424
- (,, JBApprovalStatus statusAfter) = jbController().latestQueuedRulesetOf(pid);
425
- assertEq(uint256(statusAfter), uint256(JBApprovalStatus.Approved), "Status should be Approved after delay");
426
- }
427
-
428
- // ═══════════════════════════════════════════════════════════════════
429
- // Test 7: Approval hook — rejected falls back
430
- // ═══════════════════════════════════════════════════════════════════
431
-
432
- function test_approvalHook_rejected_fallsBack() public {
433
- AlwaysRejectingHook rejectHook = new AlwaysRejectingHook();
434
-
435
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
436
- rulesetConfig[0].mustStartAtOrAfter = 0;
437
- rulesetConfig[0].duration = 7 days;
438
- rulesetConfig[0].weight = 1000e18;
439
- rulesetConfig[0].weightCutPercent = 0;
440
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(rejectHook));
441
- rulesetConfig[0].metadata = _defaultMetadata();
442
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
443
- rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
444
-
445
- uint256 pid = jbController()
446
- .launchProjectFor({
447
- owner: projectOwner,
448
- projectUri: "rejectTest",
449
- rulesetConfigurations: rulesetConfig,
450
- terminalConfigurations: _defaultTerminalConfig(),
451
- memo: ""
452
- });
453
-
454
- // Queue a new ruleset with different weight
455
- JBRulesetConfig[] memory newConfig = new JBRulesetConfig[](1);
456
- newConfig[0].mustStartAtOrAfter = 0;
457
- newConfig[0].duration = 7 days;
458
- newConfig[0].weight = 5000e18;
459
- newConfig[0].weightCutPercent = 0;
460
- newConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
461
- newConfig[0].metadata = _defaultMetadata();
462
- newConfig[0].splitGroups = new JBSplitGroup[](0);
463
- newConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
464
-
465
- vm.prank(projectOwner);
466
- jbController().queueRulesetsOf(pid, newConfig, "");
467
-
468
- // Advance to cycle 2
469
- vm.warp(block.timestamp + 7 days + 1);
470
-
471
- // Pay — should use the fallback (cycle 1 auto-repeated), not the rejected queued ruleset
472
- uint256 tokens = _payProject(pid, address(0xA11CE), 1 ether);
473
-
474
- // Should still get 1000 tokens (cycle 1 weight, not 5000)
475
- assertEq(tokens, 1000e18, "Rejected ruleset should fall back to repeating previous cycle");
476
- }
477
-
478
- // ═══════════════════════════════════════════════════════════════════
479
- // Test 8: Payout limit resets at cycle boundary
480
- // ═══════════════════════════════════════════════════════════════════
481
-
482
- function test_rulesetTransition_payoutLimitReset() public {
483
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
484
- rulesetConfig[0].mustStartAtOrAfter = 0;
485
- rulesetConfig[0].duration = 7 days;
486
- rulesetConfig[0].weight = 1000e18;
487
- rulesetConfig[0].weightCutPercent = 0;
488
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
489
- rulesetConfig[0].metadata = _defaultMetadata();
490
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
491
-
492
- JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](1);
493
- payoutLimits[0] = JBCurrencyAmount({amount: 5 ether, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
494
- JBFundAccessLimitGroup[] memory fundAccessLimitGroups = new JBFundAccessLimitGroup[](1);
495
- fundAccessLimitGroups[0] = JBFundAccessLimitGroup({
496
- terminal: address(jbMultiTerminal()),
497
- token: JBConstants.NATIVE_TOKEN,
498
- payoutLimits: payoutLimits,
499
- surplusAllowances: new JBCurrencyAmount[](0)
500
- });
501
- rulesetConfig[0].fundAccessLimitGroups = fundAccessLimitGroups;
502
-
503
- uint256 pid = jbController()
504
- .launchProjectFor({
505
- owner: projectOwner,
506
- projectUri: "payoutLimitResetTest",
507
- rulesetConfigurations: rulesetConfig,
508
- terminalConfigurations: _defaultTerminalConfig(),
509
- memo: ""
510
- });
511
-
512
- // Fund generously
513
- _payProject(pid, address(0xBA1E), 100 ether);
514
-
515
- // Use full payout limit in cycle 1
516
- vm.prank(projectOwner);
517
- jbMultiTerminal()
518
- .sendPayoutsOf({
519
- projectId: pid,
520
- token: JBConstants.NATIVE_TOKEN,
521
- amount: 5 ether,
522
- currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
523
- minTokensPaidOut: 0
524
- });
525
-
526
- // Try to send more — should fail (limit exhausted)
527
- vm.prank(projectOwner);
528
- vm.expectRevert();
529
- jbMultiTerminal()
530
- .sendPayoutsOf({
531
- projectId: pid,
532
- token: JBConstants.NATIVE_TOKEN,
533
- amount: 1 ether,
534
- currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
535
- minTokensPaidOut: 0
536
- });
537
-
538
- // Advance to cycle 2
539
- vm.warp(block.timestamp + 7 days + 1);
540
-
541
- // Payout limit should be reset — can send again
542
- vm.prank(projectOwner);
543
- jbMultiTerminal()
544
- .sendPayoutsOf({
545
- projectId: pid,
546
- token: JBConstants.NATIVE_TOKEN,
547
- amount: 5 ether,
548
- currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
549
- minTokensPaidOut: 0
550
- });
551
-
552
- // If we got here, limit was successfully reset
553
- assertTrue(true, "Payout limit reset at cycle boundary");
554
- }
555
-
556
- // ═══════════════════════════════════════════════════════════════════
557
- // Test 9: Tax rate change across cycles
558
- // ═══════════════════════════════════════════════════════════════════
559
-
560
- function test_rulesetTransition_changeTaxRate() public {
561
- // Cycle 1: 0% tax
562
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
563
- rulesetConfig[0].mustStartAtOrAfter = 0;
564
- rulesetConfig[0].duration = 7 days;
565
- rulesetConfig[0].weight = 1000e18;
566
- rulesetConfig[0].weightCutPercent = 0;
567
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
568
- rulesetConfig[0].metadata = _defaultMetadata();
569
- rulesetConfig[0].metadata.cashOutTaxRate = 0;
570
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
571
- rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
572
-
573
- uint256 pid = jbController()
574
- .launchProjectFor({
575
- owner: projectOwner,
576
- projectUri: "taxRateChangeTest",
577
- rulesetConfigurations: rulesetConfig,
578
- terminalConfigurations: _defaultTerminalConfig(),
579
- memo: ""
580
- });
581
-
582
- // Pay in cycle 1
583
- address alice = address(0xA11CE);
584
- uint256 aliceTokens = _payProject(pid, alice, 10 ether);
585
-
586
- // Queue cycle 2: 90% tax
587
- JBRulesetConfig[] memory newConfig = new JBRulesetConfig[](1);
588
- newConfig[0].mustStartAtOrAfter = 0;
589
- newConfig[0].duration = 7 days;
590
- newConfig[0].weight = 1000e18;
591
- newConfig[0].weightCutPercent = 0;
592
- newConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
593
- newConfig[0].metadata = _defaultMetadata();
594
- newConfig[0].metadata.cashOutTaxRate = 9000; // 90%
595
- newConfig[0].splitGroups = new JBSplitGroup[](0);
596
- newConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
597
-
598
- vm.prank(projectOwner);
599
- jbController().queueRulesetsOf(pid, newConfig, "");
600
-
601
- // Advance to cycle 2
602
- vm.warp(block.timestamp + 7 days + 1);
603
-
604
- // Add a second payer so Alice isn't the sole holder (tax has no effect on 100% cashout)
605
- address bob = address(0xB0B);
606
- _payProject(pid, bob, 10 ether);
607
-
608
- // Cash out Alice's cycle-1 tokens in cycle 2 with 90% tax
609
- vm.prank(alice);
610
- uint256 reclaimAmount = jbMultiTerminal()
611
- .cashOutTokensOf({
612
- holder: alice,
613
- projectId: pid,
614
- cashOutCount: aliceTokens,
615
- tokenToReclaim: JBConstants.NATIVE_TOKEN,
616
- minTokensReclaimed: 0,
617
- beneficiary: payable(alice),
618
- metadata: new bytes(0)
619
- });
620
-
621
- // With 90% tax on partial cashout, reclaim is reduced below payment
622
- assertLt(reclaimAmount, 10 ether, "Tokens minted in cycle 1 should get reduced reclaim under cycle 2's 90% tax");
623
- }
624
-
625
- // ═══════════════════════════════════════════════════════════════════
626
- // Test 10: duration=0 means same ruleset forever
627
- // ═══════════════════════════════════════════════════════════════════
628
-
629
- function test_rulesetTransition_durationZero_neverCycles() public {
630
- JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
631
- rulesetConfig[0].mustStartAtOrAfter = 0;
632
- rulesetConfig[0].duration = 0; // Never cycles
633
- rulesetConfig[0].weight = 1000e18;
634
- rulesetConfig[0].weightCutPercent = uint32(JBConstants.MAX_WEIGHT_CUT_PERCENT / 2); // 50% cut would apply if it
635
- // cycled
636
- rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
637
- rulesetConfig[0].metadata = _defaultMetadata();
638
- rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
639
- rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
640
-
641
- uint256 pid = jbController()
642
- .launchProjectFor({
643
- owner: projectOwner,
644
- projectUri: "noCycleTest",
645
- rulesetConfigurations: rulesetConfig,
646
- terminalConfigurations: _defaultTerminalConfig(),
647
- memo: ""
648
- });
649
-
650
- // Pay now
651
- uint256 tokensNow = _payProject(pid, address(0xA11CE), 1 ether);
652
-
653
- // Advance far into the future
654
- vm.warp(block.timestamp + 365 days);
655
-
656
- // Pay again — should still use same weight (no cycling)
657
- uint256 tokensLater = _payProject(pid, address(0xB0B), 1 ether);
658
-
659
- assertEq(tokensNow, tokensLater, "duration=0 should mean weight never decays");
660
-
661
- // Verify still cycle 1
662
- (JBRuleset memory ruleset,) = jbController().currentRulesetOf(pid);
663
- assertEq(ruleset.cycleNumber, 1, "Should still be cycle 1 with duration=0");
664
- }
665
-
666
- receive() external payable {}
667
- }
668
-
669
- // ═══════════════════════════════════════════════════════════════════════
670
- // Mock Contracts
671
- // ═══════════════════════════════════════════════════════════════════════
672
-
673
- /// @notice Approval hook that approves after a configurable delay.
674
- contract DelayedApprovalHook is ERC165, IJBRulesetApprovalHook {
675
- // forge-lint: disable-next-line(screaming-snake-case-immutable)
676
- uint256 public immutable approvalDelay;
677
-
678
- constructor(uint256 _approvalDelay) {
679
- approvalDelay = _approvalDelay;
680
- }
681
-
682
- function DURATION() external view override returns (uint256) {
683
- return approvalDelay;
684
- }
685
-
686
- function approvalStatusOf(uint256, JBRuleset calldata ruleset) external view override returns (JBApprovalStatus) {
687
- // If enough time has passed since the ruleset was queued, approve it
688
- if (block.timestamp >= ruleset.start - approvalDelay) {
689
- return JBApprovalStatus.Approved;
690
- }
691
- return JBApprovalStatus.ApprovalExpected;
692
- }
693
-
694
- function supportsInterface(bytes4 _interfaceId) public view override(IERC165, ERC165) returns (bool) {
695
- return _interfaceId == type(IJBRulesetApprovalHook).interfaceId || super.supportsInterface(_interfaceId);
696
- }
697
- }
698
-
699
- /// @notice Approval hook that always rejects.
700
- contract AlwaysRejectingHook is ERC165, IJBRulesetApprovalHook {
701
- // forge-lint: disable-next-line(mixed-case-function)
702
- function DURATION() external pure override returns (uint256) {
703
- return 0;
704
- }
705
-
706
- function approvalStatusOf(uint256, JBRuleset calldata) external pure override returns (JBApprovalStatus) {
707
- return JBApprovalStatus.Failed;
708
- }
709
-
710
- function supportsInterface(bytes4 _interfaceId) public view override(IERC165, ERC165) returns (bool) {
711
- return _interfaceId == type(IJBRulesetApprovalHook).interfaceId || super.supportsInterface(_interfaceId);
712
- }
713
- }