@bananapus/core-v6 0.0.36 → 0.0.38

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