@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
@@ -23,8 +23,11 @@ interface IJBPayoutSplitGroupExecutor {
23
23
  returns (uint256 netPayoutAmount);
24
24
  }
25
25
 
26
- /// @notice External library for payout split-group distribution extracted to reduce terminal bytecode.
27
- /// @dev Called via DELEGATECALL from the terminal, so events are emitted from the terminal's address.
26
+ /// @notice Handles distributing payouts to a project's split recipients. Iterates through each split, sends the
27
+ /// proportional amount, and gracefully handles failures if a split payout reverts (e.g. a hook is broken), the
28
+ /// amount is returned to the project's balance rather than blocking all other splits.
29
+ /// @dev Extracted as an external library to reduce `JBMultiTerminal` bytecode size. Called via DELEGATECALL, so events
30
+ /// are emitted from the terminal's address.
28
31
  library JBPayoutSplitGroupLib {
29
32
  event PayoutReverted(uint256 indexed projectId, JBSplit split, uint256 amount, bytes reason, address caller);
30
33
  event SendPayoutToSplit(
@@ -140,8 +143,8 @@ library JBPayoutSplitGroupLib {
140
143
  // slither-disable-next-line reentrancy-events,calls-loop
141
144
  try IJBPayoutSplitGroupExecutor(address(this))
142
145
  .executePayout({
143
- split: split, projectId: projectId, token: token, amount: amount, originalMessageSender: caller
144
- }) returns (
146
+ split: split, projectId: projectId, token: token, amount: amount, originalMessageSender: caller
147
+ }) returns (
145
148
  uint256 payoutAmount
146
149
  ) {
147
150
  return payoutAmount;
@@ -4,6 +4,10 @@ pragma solidity 0.8.28;
4
4
  import {JBRuleset} from "./../structs/JBRuleset.sol";
5
5
  import {JBRulesetMetadata} from "./../structs/JBRulesetMetadata.sol";
6
6
 
7
+ /// @notice Unpacks the 256-bit packed `metadata` field from a `JBRuleset` into individual parameters. The metadata
8
+ /// encodes: reservedPercent, cashOutTaxRate, baseCurrency, 14 boolean flags (pausePay, allowOwnerMinting, etc.),
9
+ /// a data hook address, and 14 bits of custom metadata. Used throughout the protocol to read ruleset configuration
10
+ /// without storing each field separately.
7
11
  library JBRulesetMetadataResolver {
8
12
  function reservedPercent(JBRuleset memory ruleset) internal pure returns (uint16) {
9
13
  return uint16(ruleset.metadata >> 4);
@@ -1,7 +1,8 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity 0.8.28;
3
3
 
4
- /// @notice Group IDs that categorize splits.
4
+ /// @notice Well-known split group IDs. The reserved tokens group (ID 1) defines how a project's reserved tokens are
5
+ /// distributed. Payout split groups use the token address cast to `uint256(uint160(token))` as their group ID.
5
6
  library JBSplitGroupIds {
6
7
  uint256 public constant RESERVED_TOKENS = 1;
7
8
  }
@@ -3,7 +3,9 @@ pragma solidity 0.8.28;
3
3
 
4
4
  import {IJBTerminal} from "../interfaces/IJBTerminal.sol";
5
5
 
6
- /// @notice Surplus calculations.
6
+ /// @notice Calculates a project's total surplus across all its terminals. Surplus is the amount held beyond what's
7
+ /// needed to cover the project's payout limits — it represents the pool available for cash outs and surplus allowance
8
+ /// usage. Aggregates across multiple terminals and tokens, converting to a common currency via `JBPrices`.
7
9
  library JBSurplus {
8
10
  /// @notice Gets the total current surplus amount across all of a project's terminals.
9
11
  /// @dev This amount changes as the value of the balances changes in relation to the currency being used to measure
@@ -1,8 +1,10 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity 0.8.28;
3
3
 
4
- import {IJBPriceFeed} from "src/interfaces/IJBPriceFeed.sol";
4
+ import {IJBPriceFeed} from "../interfaces/IJBPriceFeed.sol";
5
5
 
6
+ /// @notice A trivial price feed that always returns 1:1 (one unit = one unit). Used when a payout limit is
7
+ /// denominated in the same currency as the terminal's token, so no actual conversion is needed.
6
8
  contract JBMatchingPriceFeed is IJBPriceFeed {
7
9
  constructor() {}
8
10
 
@@ -1,10 +1,13 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- /// @custom:member token The address of the token that accounting is being done with.
5
- /// @custom:member decimals The number of decimals expected in that token's fixed point accounting.
6
- /// @custom:member currency The currency that the token is priced in terms of. By convention, this is
7
- /// `uint32(uint160(tokenAddress))` for tokens, or a constant ID from e.g. `JBCurrencyIds` for other currencies.
4
+ /// @notice Describes how a terminal accounts for a specific token its address, decimal precision, and which
5
+ /// currency
6
+ /// it's priced in. Used when recording payments, payouts, and cash outs to ensure correct fixed-point arithmetic.
7
+ /// @custom:member token The token address (use `JBConstants.NATIVE_TOKEN` for ETH).
8
+ /// @custom:member decimals The number of decimals for this token's fixed-point amounts (e.g. 18 for ETH, 6 for USDC).
9
+ /// @custom:member currency The currency ID for price feed lookups. Convention: `uint32(uint160(tokenAddress))` for
10
+ /// tokens, or `JBCurrencyIds.ETH`/`JBCurrencyIds.USD` for well-known currencies.
8
11
  struct JBAccountingContext {
9
12
  address token;
10
13
  uint8 decimals;
@@ -3,23 +3,16 @@ pragma solidity ^0.8.0;
3
3
 
4
4
  import {JBCurrencyAmount} from "./JBCurrencyAmount.sol";
5
5
 
6
- /// @dev Payout limit example: if the `amount` is 5, the `currency` is 1 (USD), and the terminal's token is ETH, then
7
- /// the project can pay out 5 USD worth of ETH during a ruleset.
8
- /// @dev Surplus allowance example: if the `amount` is 5, the `currency` is 1 (USD), and the terminal's token is ETH,
9
- /// then the project can pay out 5 USD worth of ETH from its surplus during a ruleset. A project's surplus is its
10
- /// balance minus its current combined payout limit.
11
- /// @dev If a project has multiple payout limits or surplus allowances, they are all available. They can all be used
12
- /// during a single ruleset.
13
- /// @dev The payout limits' and surplus allowances' fixed point amounts have the same number of decimals as the
14
- /// terminal.
15
- /// @custom:member terminal The terminal that the payout limits and surplus allowances apply to.
16
- /// @custom:member token The token that the payout limits and surplus allowances apply to within the `terminal`.
17
- /// @custom:member payoutLimits An array of payout limits. The payout limits cumulatively dictate the maximum value of
18
- /// `token`s a project can pay out from its balance in a terminal during a ruleset. Each payout limit can have a unique
19
- /// currency and amount.
20
- /// @custom:member surplusAllowances An array of surplus allowances. The surplus allowances cumulatively dictates the
21
- /// maximum value of `token`s a project can pay out from its surplus (balance less payouts) in a terminal during a
22
- /// ruleset. Each surplus allowance can have a unique currency and amount.
6
+ /// @notice Defines how much a project can withdraw from a specific terminal and token each funding cycle.
7
+ /// @dev Example — payout limit of 5 USD in an ETH terminal: the project can distribute up to 5 USD worth of ETH to
8
+ /// its splits per cycle. Example surplus allowance of 5 USD: the project owner can pull up to 5 USD worth of ETH
9
+ /// from the surplus (balance above payout limits).
10
+ /// @dev Multiple limits in different currencies are additive — each can be used independently within one cycle.
11
+ /// @dev Amounts use the same decimal precision as the terminal token (e.g. 18 for ETH, 6 for USDC).
12
+ /// @custom:member terminal The terminal address these limits apply to.
13
+ /// @custom:member token The token address within that terminal these limits apply to.
14
+ /// @custom:member payoutLimits Maximum amounts distributable to splits per cycle, each in a specific currency.
15
+ /// @custom:member surplusAllowances Maximum amounts withdrawable from surplus per cycle, each in a specific currency.
23
16
  struct JBFundAccessLimitGroup {
24
17
  address terminal;
25
18
  address token;
@@ -3,32 +3,24 @@ pragma solidity ^0.8.0;
3
3
 
4
4
  import {IJBRulesetApprovalHook} from "./../interfaces/IJBRulesetApprovalHook.sol";
5
5
 
6
- /// @dev `JBRuleset` timestamps are unix timestamps (seconds since 00:00 January 1st, 1970 UTC).
7
- /// @custom:member cycleNumber The ruleset's cycle number. Each ruleset's `cycleNumber` is the previous ruleset's
8
- /// `cycleNumber` plus one. Each project's first ruleset has a `cycleNumber` of 1.
9
- /// @custom:member id The ruleset's ID, which is a timestamp of when this ruleset's rules were initialized. The
10
- /// `rulesetId` stays the same for rulesets that automatically cycle over from a manually queued ruleset.
11
- /// @custom:member basedOnId The `rulesetId` of the ruleset which was active when this ruleset was created.
12
- /// @custom:member start The timestamp from which this ruleset is considered active.
13
- /// @custom:member duration The number of seconds the ruleset lasts for. After this duration, a new ruleset will start.
14
- /// The project owner can queue new rulesets at any time, which will take effect once the current ruleset's duration is
15
- /// over. If the `duration` is 0, newly queued rulesets will take effect immediately. If a ruleset ends and there are no
16
- /// new rulesets queued, the current ruleset cycles over to another one with the same properties but a new `start`
17
- /// timestamp and a `weight` reduced by the ruleset's `weightCutPercent`.
18
- /// @custom:member weight A fixed point number with 18 decimals which is typically used by payment terminals to
19
- /// determine how many tokens should be minted when a payment is received. This can be used by other contracts for
20
- /// arbitrary calculations.
21
- /// @custom:member weightCutPercent The percentage by which to reduce the `weight` each time a new ruleset starts.
22
- /// `weight`
23
- /// is
24
- /// a percentage out of `JBConstants.MAX_WEIGHT_CUT_PERCENT`. If it's 0, the next ruleset will have the same `weight` by
25
- /// default. If it's 90%, the next ruleset's `weight` will be 10% smaller. If a ruleset explicitly sets a new `weight`,
26
- /// the `weightCutPercent` doesn't apply.
27
- /// @custom:member approvalHook An address of a contract that says whether a queued ruleset should be approved or
28
- /// rejected. If a
29
- /// ruleset is rejected, it won't go into effect. An approval hook can be used to create rules which dictate how a
30
- /// project owner can change their ruleset over time.
31
- /// @custom:member metadata Extra data associated with a ruleset which can be used by other contracts.
6
+ /// @notice A ruleset defines how a project behaves during a period of time — token issuance rate, cash-out terms,
7
+ /// payout rules, and permissions. Rulesets cycle automatically: when one expires, the next queued (and approved) one
8
+ /// takes effect. If nothing is queued, the current ruleset auto-cycles with decayed weight.
9
+ /// @dev Timestamps are unix timestamps (seconds since epoch).
10
+ /// @custom:member cycleNumber Which cycle this is (starts at 1, increments each cycle).
11
+ /// @custom:member id The ruleset's ID the unix timestamp when it was first stored. Stays the same across
12
+ /// auto-cycles.
13
+ /// @custom:member basedOnId The ID of the ruleset that was active when this one was created (forms a linked list).
14
+ /// @custom:member start When this ruleset became/becomes active.
15
+ /// @custom:member duration How many seconds the ruleset lasts. 0 = no auto-cycling (must be explicitly replaced).
16
+ /// @custom:member weight Tokens minted per unit paid (18 decimals). The terminal divides payment amount by weight to
17
+ /// determine token issuance. Higher weight = more tokens per unit of payment.
18
+ /// @custom:member weightCutPercent How much to reduce weight each cycle (out of 1,000,000,000). 100,000,000 = 10% cut
19
+ /// per cycle. 0 = no decay. Only applies when a cycle auto-rolls without an explicitly queued replacement.
20
+ /// @custom:member approvalHook A contract that gates whether queued rulesets can take effect (e.g. `JBDeadline` for
21
+ /// minimum notice periods). If the hook rejects a queued ruleset, the current one continues.
22
+ /// @custom:member metadata Packed 256-bit field containing reservedPercent, cashOutTaxRate, baseCurrency, boolean
23
+ /// flags, data hook address, and custom metadata. Decoded by `JBRulesetMetadataResolver`.
32
24
  struct JBRuleset {
33
25
  uint48 cycleNumber;
34
26
  uint48 id;
@@ -6,31 +6,19 @@ import {JBFundAccessLimitGroup} from "./JBFundAccessLimitGroup.sol";
6
6
  import {JBRulesetMetadata} from "./JBRulesetMetadata.sol";
7
7
  import {JBSplitGroup} from "./JBSplitGroup.sol";
8
8
 
9
- /// @custom:member mustStartAtOrAfter The earliest time the ruleset can start.
10
- /// @custom:member duration The number of seconds the ruleset lasts for, after which a new ruleset will start. A
11
- /// duration of 0 means that the ruleset will stay active until the project owner explicitly issues a reconfiguration,
12
- /// at which point a new ruleset will immediately start with the updated properties. If the duration is greater than 0,
13
- /// a project owner cannot make changes to a ruleset's parameters while it is active – any proposed changes will apply
14
- /// to the subsequent ruleset. If no changes are proposed, a ruleset rolls over to another one with the same properties
15
- /// but new `start` timestamp and a cut `weight`.
16
- /// @custom:member weight A fixed point number with 18 decimals that contracts can use to base arbitrary calculations
17
- /// on. For example, payment terminals can use this to determine how many tokens should be minted when a payment is
18
- /// received.
19
- /// @custom:member weightCutPercent A percent by how much the `weight` of the subsequent ruleset should be reduced, if
20
- /// the
21
- /// project owner hasn't queued the subsequent ruleset with an explicit `weight`. If it's 0, each ruleset will have
22
- /// equal weight. If the number is 90%, the next ruleset will have a 10% smaller weight. This weight is out of
23
- /// `JBConstants.MAX_WEIGHT_CUT_PERCENT`.
24
- /// @custom:member approvalHook An address of a contract that says whether a proposed ruleset should be accepted or
25
- /// rejected. It
26
- /// can be used to create rules around how a project owner can change ruleset parameters over time.
27
- /// @custom:member metadata Metadata specifying the controller-specific parameters that a ruleset can have. These
28
- /// properties cannot change until the next ruleset starts.
29
- /// @custom:member splitGroups An array of splits to use for any number of groups while the ruleset is active.
30
- /// @custom:member fundAccessLimitGroups An array of structs which dictate the amount of funds a project can access from
31
- /// its balance in each payment terminal while the ruleset is active. Amounts are fixed point numbers using the same
32
- /// number of decimals as the corresponding terminal. The `_payoutLimit` and `_surplusAllowance` parameters must fit in
33
- /// a `uint232`.
9
+ /// @notice The configuration passed to `JBController.launchRulesetsFor` or `queueRulesetsOf` to define a new ruleset.
10
+ /// Includes the economic parameters (weight, duration, decay), the metadata (permissions and hooks), the split
11
+ /// recipients, and the fund access limits.
12
+ /// @custom:member mustStartAtOrAfter The earliest timestamp the ruleset can begin. Pass 0 to start immediately after
13
+ /// the previous ruleset ends.
14
+ /// @custom:member duration How long the ruleset lasts in seconds. 0 = stays active until explicitly replaced.
15
+ /// @custom:member weight Tokens minted per unit of payment (18 decimals). Pass 1 to inherit decayed weight from the
16
+ /// previous ruleset. Pass 0 for no token issuance.
17
+ /// @custom:member weightCutPercent Decay rate per cycle (out of 1,000,000,000). 100,000,000 = 10% cut. 0 = no decay.
18
+ /// @custom:member approvalHook Contract that must approve the *next* queued ruleset for it to take effect.
19
+ /// @custom:member metadata The ruleset's behavioral flags and parameters (see `JBRulesetMetadata`).
20
+ /// @custom:member splitGroups How payouts and reserved tokens are distributed during this ruleset.
21
+ /// @custom:member fundAccessLimitGroups How much the project can withdraw from each terminal per cycle.
34
22
  struct JBRulesetConfig {
35
23
  uint48 mustStartAtOrAfter;
36
24
  uint32 duration;
@@ -1,38 +1,31 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- /// @custom:member reservedPercent The reserved percent of the ruleset. This number is a percentage calculated out of
5
- /// `JBConstants.MAX_RESERVED_PERCENT`.
6
- /// @custom:member cashOutTaxRate The cash out tax rate of the ruleset. This number is a percentage calculated out of
7
- /// `JBConstants.MAX_CASH_OUT_TAX_RATE`.
8
- /// @custom:member baseCurrency The currency on which to base the ruleset's weight. By convention, this is
9
- /// `uint32(uint160(tokenAddress))` for tokens, or a constant ID from e.g. `JBCurrencyIds` for other currencies.
10
- /// @custom:member pausePay A flag indicating if the pay functionality should be paused during the ruleset.
11
- /// @custom:member pauseCreditTransfers A flag indicating if the project token transfer functionality should be paused
12
- /// during the funding cycle.
13
- /// @custom:member allowOwnerMinting A flag indicating if the project owner or an operator with the `MINT_TOKENS`
14
- /// permission from the owner should be allowed to mint project tokens on demand during this ruleset.
15
- /// @custom:member allowTerminalMigration A flag indicating if migrating terminals should be allowed during this
16
- /// ruleset.
17
- /// @custom:member allowSetTerminals A flag indicating if a project's terminals can be added or removed.
18
- /// @custom:member allowSetController A flag indicating if a project's controller can be changed.
19
- /// @custom:member allowAddAccountingContext A flag indicating if a project can add new accounting contexts for its
20
- /// terminals to use.
21
- /// @custom:member allowAddPriceFeed A flag indicating if a project can add new price feeds to calculate exchange rates
22
- /// between its tokens.
23
- /// @custom:member ownerMustSendPayouts A flag indicating if privileged payout distribution should be
24
- /// enforced, otherwise payouts can be distributed by anyone.
25
- /// @custom:member holdFees A flag indicating if fees should be held during this ruleset.
26
- /// @custom:member useTotalSurplusForCashOuts A flag indicating if cash outs should use the project's balance held
27
- /// in all terminals instead of the project's local terminal balance from which the cash out is being fulfilled.
28
- /// @custom:member useDataHookForPay A flag indicating if the data hook should be used for pay transactions during this
29
- /// ruleset.
30
- /// @custom:member useDataHookForCashOut A flag indicating if the data hook should be used for cash out transactions
31
- /// during
32
- /// this ruleset.
33
- /// @custom:member dataHook The data hook to use during this ruleset.
34
- /// @custom:member metadata Metadata of the metadata, only the 14 least significant bits can be used, the 2 most
35
- /// significant bits are disregarded.
4
+ /// @notice Human-readable configuration for a ruleset's behavioral flags and parameters. This struct is packed into
5
+ /// 256 bits for on-chain storage (see `JBRulesetMetadataResolver` for the packing layout).
6
+ /// @custom:member reservedPercent Percentage of newly minted tokens set aside for the reserved token split group
7
+ /// (0–10,000 basis points). 5,000 = 50% reserved.
8
+ /// @custom:member cashOutTaxRate Tax applied when holders cash out tokens (0–10,000 basis points). Higher rate = less
9
+ /// reclaim per token. 0 = proportional, 10,000 = no reclaim (100% tax).
10
+ /// @custom:member baseCurrency The currency used to interpret the ruleset's weight for token issuance. Convention:
11
+ /// `uint32(uint160(tokenAddress))` for tokens, or `JBCurrencyIds.ETH`/`JBCurrencyIds.USD` for well-known currencies.
12
+ /// @custom:member pausePay If `true`, the project cannot receive payments during this ruleset.
13
+ /// @custom:member pauseCreditTransfers If `true`, token credit transfers are disabled during this ruleset.
14
+ /// @custom:member allowOwnerMinting If `true`, the project owner (or MINT_TOKENS operator) can mint tokens on demand.
15
+ /// @custom:member allowSetCustomToken If `true`, the project can set a custom ERC-20 token via `setTokenFor`.
16
+ /// @custom:member allowTerminalMigration If `true`, terminals can be migrated to new implementations.
17
+ /// @custom:member allowSetTerminals If `true`, the project's terminal list can be modified.
18
+ /// @custom:member allowSetController If `true`, the project's controller can be changed.
19
+ /// @custom:member allowAddAccountingContext If `true`, new token accounting contexts can be added to terminals.
20
+ /// @custom:member allowAddPriceFeed If `true`, the project can register new price feeds in `JBPrices`.
21
+ /// @custom:member ownerMustSendPayouts If `true`, only the project owner can trigger payout distribution.
22
+ /// @custom:member holdFees If `true`, fees are accumulated but not processed until a future ruleset (or manually).
23
+ /// @custom:member useTotalSurplusForCashOuts If `true`, cash-out calculations use surplus across all terminals (not
24
+ /// just the one being cashed out from).
25
+ /// @custom:member useDataHookForPay If `true`, the data hook is called before recording payments.
26
+ /// @custom:member useDataHookForCashOut If `true`, the data hook is called before recording cash outs.
27
+ /// @custom:member dataHook Contract called before pay/cash-out to potentially override token counts or add hooks.
28
+ /// @custom:member metadata 14 bits of application-specific metadata (upper 2 bits are ignored).
36
29
  struct JBRulesetMetadata {
37
30
  uint16 reservedPercent;
38
31
  uint16 cashOutTaxRate;
@@ -19,12 +19,12 @@ contract MaliciousPayoutBeneficiary is IERC721Receiver, Test {
19
19
 
20
20
  IJBMultiTerminal(_terminal)
21
21
  .sendPayoutsOf({
22
- projectId: 2,
23
- amount: 5 * 10 ** 18,
24
- currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
25
- token: JBConstants.NATIVE_TOKEN,
26
- minTokensPaidOut: 0
27
- });
22
+ projectId: 2,
23
+ amount: 5 * 10 ** 18,
24
+ currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
25
+ token: JBConstants.NATIVE_TOKEN,
26
+ minTokensPaidOut: 0
27
+ });
28
28
  }
29
29
 
30
30
  receive() external payable {
@@ -46,15 +46,15 @@ contract MaliciousAllowanceBeneficiary is IERC721Receiver, Test {
46
46
 
47
47
  IJBMultiTerminal(_terminal)
48
48
  .useAllowanceOf({
49
- projectId: 2,
50
- amount: 5 * 10 ** 18,
51
- currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
52
- token: JBConstants.NATIVE_TOKEN,
53
- minTokensPaidOut: 0,
54
- beneficiary: payable(address(this)),
55
- feeBeneficiary: payable(0x000000000000000000000000000000000000007B),
56
- memo: "MEMO"
57
- });
49
+ projectId: 2,
50
+ amount: 5 * 10 ** 18,
51
+ currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
52
+ token: JBConstants.NATIVE_TOKEN,
53
+ minTokensPaidOut: 0,
54
+ beneficiary: payable(address(this)),
55
+ feeBeneficiary: payable(0x000000000000000000000000000000000000007B),
56
+ memo: "MEMO"
57
+ });
58
58
  }
59
59
 
60
60
  receive() external payable {
package/ADMINISTRATION.md DELETED
@@ -1,103 +0,0 @@
1
- # Administration
2
-
3
- ## At A Glance
4
-
5
- | Item | Details |
6
- | --- | --- |
7
- | Scope | Core Juicebox V6 control plane: directory, controller, terminals, permissions, prices, and global protocol switches |
8
- | Control posture | Mixed protocol-owner, project-owner, delegated-operator, controller, and terminal control |
9
- | Highest-risk actions | Controller migration, terminal migration, token binding, price-feed installation, and broad permission grants |
10
- | Recovery posture | Project-local mistakes may be fixable if rulesets allow it; immutable infra mistakes usually require replacement and migration |
11
-
12
- ## Purpose
13
-
14
- `nana-core-v6` is the main control plane in the stack. It mixes protocol-owned contracts, project-local ownership, delegated operators through `JBPermissions`, and ruleset flags that allow or block changes. This file explains who can still change project behavior after core is live.
15
-
16
- ## Control Model
17
-
18
- - Protocol-wide `Ownable` surfaces exist on `JBDirectory`, `JBProjects`, `JBPrices`, and `JBFeelessAddresses`.
19
- - Project-local control comes from the project NFT owner in `JBProjects`.
20
- - Fine-grained operator delegation comes from `JBPermissions`.
21
- - Controllers and terminals become privileged system callers once the directory points to them.
22
- - The current ruleset can further allow or deny owner or operator actions.
23
-
24
- ## Roles
25
-
26
- | Role | How Assigned | Scope | Notes |
27
- | --- | --- | --- | --- |
28
- | Project owner | `JBProjects.ownerOf(projectId)` | Per project | Main human control surface |
29
- | Project operator | `JBPermissions` grant | Per project or wildcard | Can be narrow or dangerously broad |
30
- | Controller | `JBDirectory.controllerOf(projectId)` | Per project | Manages rulesets, token setup, splits, and fund-access config |
31
- | Terminal | `JBDirectory` terminal set | Per project | Moves funds through `JBTerminalStore` and terminal entrypoints |
32
- | Protocol owner | `Ownable(owner)` on protocol-wide contracts | Global | Different contracts can have different owners |
33
- | Omnichain ruleset operator | `JBController` constructor immutable | Global or broad | Bypasses some owner checks for synchronized ruleset flows |
34
-
35
- ## Privileged Surfaces
36
-
37
- High-value admin functions include:
38
-
39
- - `JBDirectory.setControllerOf(...)`, `setTerminalsOf(...)`, `setPrimaryTerminalOf(...)`
40
- - `JBController.queueRulesetsOf(...)`, `launchRulesetsFor(...)`, `setSplitGroupsOf(...)`, `deployERC20For(...)`, `setTokenFor(...)`, `setUriOf(...)`, `addPriceFeedFor(...)`
41
- - `JBMultiTerminal.useAllowanceOf(...)`, `migrateBalanceOf(...)`, `cashOutTokensOf(...)` when permission-gated by the holder or delegated authority
42
- - `JBPermissions.setPermissionsFor(...)`
43
- - `JBPrices.addPriceFeedFor(...)` for protocol defaults or project-local feeds
44
- - `JBFeelessAddresses.setFeelessAddress(...)`
45
- - `JBProjects.setTokenUriResolver(...)`
46
-
47
- The practical split is simple:
48
-
49
- - protocol owners change global infrastructure or defaults
50
- - project owners and operators change project configuration
51
- - controllers and terminals act with the authority core gives them
52
-
53
- ## Immutable And One-Way Decisions
54
-
55
- - Default or project-specific price feeds are write-once for a given pair.
56
- - ERC-20 token binding for a project is effectively one-time.
57
- - The fee beneficiary project ID inside `JBMultiTerminal` is hardcoded.
58
- - Constructor immutables on controller, directory, terminal, store, prices, and tokens cannot be patched.
59
-
60
- ## Operational Notes
61
-
62
- - Use narrow project-scoped permissions instead of wildcard or ROOT permissions when possible.
63
- - Check whether the active ruleset allows the change before assuming the owner or operator can make it.
64
- - Treat controller migration, terminal migration, token deployment, and price-feed installation as high-blast-radius control-plane changes.
65
- - Read both the permission check and the current ruleset flags before concluding an action is allowed.
66
- - Keep fee-route and payout-path failure semantics in mind. Some failures restore project balance instead of trapping funds.
67
-
68
- ## Machine Notes
69
-
70
- - Do not infer authority from project ownership alone. Many paths also depend on the active ruleset and permission bitmap.
71
- - Treat `JBDirectory`, `JBController`, `JBMultiTerminal`, `JBPermissions`, `JBPrices`, `JBFeelessAddresses`, and `JBProjects` as the minimum control-plane source set.
72
- - If a controller, terminal, or price-feed action is not backed by the exact current directory entry, stop and resolve the mismatch first.
73
- - If a permission is not named explicitly in the call path, inspect the contract check before assuming delegated authority exists.
74
- - If a fee route or split payout failed, check whether core restored balance or left a retry path before calling it a permanent loss.
75
-
76
- ## Recovery
77
-
78
- - Wrong immutable infrastructure usually means deploying a new controller, terminal, store, or price layer and then migrating.
79
- - Wrong project-local config can often be corrected if the current ruleset still allows it.
80
- - Wrong wildcard permissions are fixed by updating the permission bitmap, but they are dangerous because of what can happen before revocation.
81
- - Some fee-route and payout-route failures are recoverable in place because core prefers liveness over trapped funds.
82
-
83
- ## Admin Boundaries
84
-
85
- - Protocol owners cannot directly rewrite project economics without going through the contracts and ruleset constraints that enforce those changes.
86
- - Project owners cannot bypass immutable constructor references or rewrite existing price-feed entries.
87
- - Controllers and terminals only have the authority given by the directory and core contracts.
88
- - Nobody can change the hardcoded fee beneficiary or patch immutable deployment mistakes in place.
89
-
90
- ## Source Map
91
-
92
- - `src/JBDirectory.sol`
93
- - `src/JBController.sol`
94
- - `src/JBMultiTerminal.sol`
95
- - `src/JBPermissions.sol`
96
- - `src/JBPrices.sol`
97
- - `src/JBFeelessAddresses.sol`
98
- - `src/JBProjects.sol`
99
- - `test/units/static/JBController/`
100
- - `test/units/static/JBDirectory/`
101
- - `test/units/static/JBMultiTerminal/`
102
- - `test/units/static/JBPermissions/`
103
- - `test/units/static/JBPrices/`
package/ARCHITECTURE.md DELETED
@@ -1,133 +0,0 @@
1
- # Architecture
2
-
3
- ## Purpose
4
-
5
- `nana-core-v6` is the root of the V6 stack. It owns project identity, rulesets, permissions, treasury balances, token issuance, fee behavior, payout limits, and the hook interfaces that extension repos use.
6
-
7
- If a change affects accounting, token supply, fees, terminal routing, or permission semantics, this repo is the source of truth.
8
-
9
- ## System Overview
10
-
11
- `JBController`, `JBMultiTerminal`, and `JBTerminalStore` form the main execution and accounting path. `JBDirectory`, `JBRulesets`, `JBProjects`, `JBTokens`, `JBPermissions`, `JBSplits`, and related contracts provide routing, identity, and shared state for downstream repos.
12
-
13
- `JBTerminalStore` is terminal-scoped through `msg.sender`, so each terminal tracks its own balances and usage while sharing the same ruleset and price surfaces. Hooks can change economics or add side effects, but they should not create a second ledger.
14
-
15
- ## Core Invariants
16
-
17
- - Preview functions should stay aligned with the state-changing functions they mirror.
18
- - Data hooks run before settlement and may change economics. Pay and cash-out hooks run after settlement.
19
- - Reserved tokens and other pending supply affect supply-sensitive math before distribution.
20
- - Terminal balances, fee accounting, reclaim math, and surplus calculations must agree.
21
- - Fee logic taxes value leaving the system, not every internal rebalance.
22
- - Rulesets are time-ordered and approval-aware, and downstream deployers depend on predictable ID progression.
23
- - Permission checks are protocol safety checks, not just UI hints.
24
-
25
- ## Modules
26
-
27
- | Module | Responsibility | Notes |
28
- | --- | --- | --- |
29
- | `JBMultiTerminal` | Payment, cash-out, payout, allowance, and fee entrypoints | Execution surface |
30
- | `JBTerminalStore` | Shared accounting and preview math | Economic source of truth |
31
- | `JBController` | Launch, queue rulesets, mint, burn, and update split groups | Supply and configuration |
32
- | `JBDirectory`, `JBRulesets` | Project routing and time-based ruleset lifecycle | Coordination layer |
33
- | `JBProjects`, `JBTokens`, `JBERC20` | Identity and token surfaces | Ownership and tokenization |
34
- | `JBPermissions`, `JBSplits`, `JBFundAccessLimits`, `JBPrices` | Shared authorization and configuration state | Cross-repo dependencies |
35
-
36
- ## Trust Boundaries
37
-
38
- - This repo owns the canonical balance and supply transitions.
39
- - Hook repos may change inputs and post-settlement behavior, but they should not replace the core ledger.
40
- - External price feeds, Permit2, and ERC-20 behavior matter, but accounting truth still lives here.
41
-
42
- ## Critical Flows
43
-
44
- ### Payment
45
-
46
- ```text
47
- terminal receives funds
48
- -> terminal store reads the active ruleset and optional data hooks
49
- -> before-pay data hook can change weight and return pay-hook specs
50
- -> terminal store records the payment in the terminal-scoped ledger
51
- -> controller mints beneficiary tokens and accrues reserved tokens
52
- -> pay hooks run after settlement
53
- ```
54
-
55
- ### Cash Out
56
-
57
- ```text
58
- holder requests redemption
59
- -> terminal store reads the current ruleset, balances, and supply inputs
60
- -> before-cash-out data hook can change reclaim inputs and hook specs
61
- -> terminal store records the cash out in the terminal-scoped ledger
62
- -> controller burns tokens
63
- -> terminal pays reclaim value and routes protocol fees
64
- -> cash-out hooks run after settlement
65
- ```
66
-
67
- ### Launch And Queue Rulesets
68
-
69
- ```text
70
- owner, operator, or omnichain ruleset operator
71
- -> controller launches or queues rulesets
72
- -> launch also sets the controller in the directory and configures terminals
73
- -> rulesets become the source of truth for later pay, cash-out, and admin constraints
74
- ```
75
-
76
- ### Payouts And Allowances
77
-
78
- ```text
79
- authorized caller
80
- -> consumes payout limits or surplus allowances
81
- -> funds move to splits, projects, hooks, or direct recipients
82
- -> same-terminal project payouts stay inside terminal accounting and may add fee-free surplus
83
- ```
84
-
85
- ## Accounting Model
86
-
87
- This repo owns the canonical ledger for balances, fees, supply-sensitive reclaim math, payout limits, allowances, reserved tokens, and preview calculations. Other repos may wrap or influence these values, but they should not duplicate them.
88
-
89
- `JBTerminalStore` keeps terminal balances, payout-limit usage, and surplus-allowance usage. Those reset boundaries are not the same:
90
-
91
- - payout-limit usage is tracked by ruleset cycle number
92
- - surplus-allowance usage is tracked by `ruleset.id`
93
-
94
- If a duration-based ruleset auto-cycles without a new ruleset ID, payout-limit usage resets but allowance usage does not.
95
-
96
- ## Security Model
97
-
98
- - Review `JBMultiTerminal`, `JBTerminalStore`, and `JBController` as one pipeline.
99
- - `JBTerminalStore` uses shared logic with terminal-scoped state. Misreading that split leads to bad accounting assumptions.
100
- - Small changes in fee or surplus logic can affect every downstream repo.
101
- - Same-terminal project payouts, fee-free surplus capping, and migration cleanup are coupled.
102
- - `allowOwnerMinting` is not a universal mint kill switch. Other allowed paths can still mint.
103
- - Hook ordering and preview-execution alignment are ongoing maintenance requirements.
104
-
105
- ## Safe Change Guide
106
-
107
- - Trace both the preview path and the state-changing path for any nontrivial change.
108
- - Read downstream hook repos before changing hook metadata or interface expectations.
109
- - Keep fee logic, balance logic, reclaim math, and surplus math in sync.
110
- - If you change same-terminal payouts between projects, re-check self-pay reverts, fee-free surplus accumulation, and post-pay caps.
111
- - If you change ruleset rollover semantics, re-check which counters reset on cycle progression versus new ruleset IDs.
112
- - If permissions change, update shared docs and downstream assumptions at the same time.
113
-
114
- ## Canonical Checks
115
-
116
- - fee-free surplus and same-terminal payout behavior:
117
- `test/TestFeeFreeCashOutBypass.sol`
118
- - migration and terminal-accounting continuity:
119
- `test/TestTerminalMigration.sol`
120
- - ruleset ordering and transition behavior:
121
- `test/RulesetTransitions.t.sol`
122
-
123
- ## Source Map
124
-
125
- - `src/JBController.sol`
126
- - `src/JBMultiTerminal.sol`
127
- - `src/JBTerminalStore.sol`
128
- - `src/JBDirectory.sol`
129
- - `src/JBRulesets.sol`
130
- - `src/JBPermissions.sol`
131
- - `test/TestFeeFreeCashOutBypass.sol`
132
- - `test/TestTerminalMigration.sol`
133
- - `test/RulesetTransitions.t.sol`