@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
package/foundry.lock CHANGED
@@ -1,11 +1,5 @@
1
1
  {
2
2
  "lib/forge-std": {
3
3
  "rev": "726a6ee5fc8427a0013d6f624e486c9130c0e336"
4
- },
5
- "lib/sphinx": {
6
- "branch": {
7
- "name": "v0.23.0",
8
- "rev": "5fb24a825f46bd6ae0b5359fe0da1d2346126b09"
9
- }
10
4
  }
11
- }
5
+ }
package/foundry.toml CHANGED
@@ -17,7 +17,7 @@ fail_on_revert = false
17
17
  ethereum = "${RPC_ETHEREUM_MAINNET}"
18
18
 
19
19
  [lint]
20
- exclude_lints = ["pascal-case-struct", "mixed-case-variable"]
20
+ exclude_lints = ["block-timestamp", "mixed-case-variable", "pascal-case-struct"]
21
21
  [fmt]
22
22
  number_underscore = "thousands"
23
23
  multiline_func_header = "all"
package/package.json CHANGED
@@ -1,11 +1,23 @@
1
1
  {
2
2
  "name": "@bananapus/core-v6",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/Bananapus/nana-core-v6"
8
8
  },
9
+ "files": [
10
+ "CHANGELOG.md",
11
+ "foundry.lock",
12
+ "foundry.toml",
13
+ "references/",
14
+ "remappings.txt",
15
+ "script/helpers/",
16
+ "sphinx.lock",
17
+ "src/",
18
+ "test/helpers/",
19
+ "test/mock/"
20
+ ],
9
21
  "engines": {
10
22
  "node": ">=20.0.0"
11
23
  },
@@ -26,13 +38,13 @@
26
38
  "artifacts": "source ./.env && npx sphinx artifacts --org-id 'ea165b21-7cdc-4d7b-be59-ecdd4c26bee4' --project-name 'nana-core-v6'"
27
39
  },
28
40
  "dependencies": {
29
- "@bananapus/permission-ids-v6": "^0.0.17",
30
- "@chainlink/contracts": "^1.5.0",
31
- "@openzeppelin/contracts": "^5.6.1",
32
- "@prb/math": "^4.1.1",
33
- "@uniswap/permit2": "github:Uniswap/permit2"
41
+ "@bananapus/permission-ids-v6": "0.0.22",
42
+ "@chainlink/contracts": "1.5.0",
43
+ "@openzeppelin/contracts": "5.6.1",
44
+ "@prb/math": "4.1.1",
45
+ "@uniswap/permit2": "github:Uniswap/permit2#cc56ad0f3439c502c246fc5cfcc3db92bb8b7219"
34
46
  },
35
47
  "devDependencies": {
36
- "@sphinx-labs/plugins": "^0.33.3"
48
+ "@sphinx-labs/plugins": "0.33.3"
37
49
  }
38
50
  }
@@ -419,12 +419,14 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
419
419
  /// @dev Each operation within this transaction can be done in sequence separately.
420
420
  /// @dev Can only be called by the project's owner or an address with the owner's permission to `LAUNCH_RULESETS`.
421
421
  /// @param projectId The ID of the project to launch rulesets for.
422
+ /// @param projectUri The project's metadata URI. Pass an empty string to leave it unchanged.
422
423
  /// @param rulesetConfigurations The rulesets to queue.
423
424
  /// @param terminalConfigurations The terminals to set up.
424
425
  /// @param memo A memo to pass along to the emitted event.
425
426
  /// @return rulesetId The ID of the last successfully queued ruleset.
426
427
  function launchRulesetsFor(
427
428
  uint256 projectId,
429
+ string calldata projectUri,
428
430
  JBRulesetConfig[] calldata rulesetConfigurations,
429
431
  JBTerminalConfig[] calldata terminalConfigurations,
430
432
  string calldata memo
@@ -455,11 +457,25 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
455
457
  alsoGrantAccessIf: sender == OMNICHAIN_RULESET_OPERATOR
456
458
  });
457
459
 
460
+ if (bytes(projectUri).length > 0) {
461
+ _requirePermissionAllowingOverrideFrom({
462
+ account: PROJECTS.ownerOf(projectId),
463
+ projectId: projectId,
464
+ permissionId: JBPermissionIds.SET_PROJECT_URI,
465
+ alsoGrantAccessIf: sender == OMNICHAIN_RULESET_OPERATOR
466
+ });
467
+ }
468
+
458
469
  // If the project has already had rulesets, use `queueRulesetsOf(...)` instead.
459
470
  if (RULESETS.latestRulesetIdOf(projectId) > 0) {
460
471
  revert JBController_RulesetsAlreadyLaunched(projectId);
461
472
  }
462
473
 
474
+ // If provided, set the project's metadata URI.
475
+ if (bytes(projectUri).length > 0) {
476
+ uriOf[projectId] = projectUri;
477
+ }
478
+
463
479
  // Set this contract as the project's controller in the directory.
464
480
  DIRECTORY.setControllerOf({projectId: projectId, controller: IERC165(this)});
465
481
 
@@ -470,7 +486,9 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
470
486
  // slither-disable-next-line reentrancy-events
471
487
  rulesetId = _queueRulesets({projectId: projectId, rulesetConfigurations: rulesetConfigurations});
472
488
 
473
- emit LaunchRulesets({rulesetId: rulesetId, projectId: projectId, memo: memo, caller: _msgSender()});
489
+ emit LaunchRulesets({
490
+ rulesetId: rulesetId, projectId: projectId, projectUri: projectUri, memo: memo, caller: _msgSender()
491
+ });
474
492
  }
475
493
 
476
494
  /// @notice Migrate a project from this controller to another one.
@@ -525,6 +543,10 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
525
543
  // Cache common values used in both permission checks.
526
544
  address sender = _msgSender();
527
545
  bool senderIsTerminal = _isTerminalOf(projectId, sender);
546
+ bool senderIsTerminalOrDataHook = senderIsTerminal || sender == ruleset.dataHook();
547
+ // Only query the data hook if the sender isn't already a terminal or the data hook itself.
548
+ bool senderHasDataHookMintPermission =
549
+ !senderIsTerminalOrDataHook && _hasDataHookMintPermissionFor(projectId, ruleset, sender);
528
550
 
529
551
  // Minting is restricted to: the project's owner, addresses with permission to `MINT_TOKENS`, the project's
530
552
  // terminals, and the project's data hook.
@@ -532,15 +554,14 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
532
554
  account: PROJECTS.ownerOf(projectId),
533
555
  projectId: projectId,
534
556
  permissionId: JBPermissionIds.MINT_TOKENS,
535
- alsoGrantAccessIf: senderIsTerminal || sender == ruleset.dataHook()
536
- || _hasDataHookMintPermissionFor(projectId, ruleset, sender)
557
+ alsoGrantAccessIf: senderIsTerminalOrDataHook || senderHasDataHookMintPermission
537
558
  });
538
559
 
539
560
  // If the message sender is not the project's terminal or data hook, the ruleset must have `allowOwnerMinting`
540
561
  // set to `true`.
541
562
  if (
542
- ruleset.id != 0 && !ruleset.allowOwnerMinting() && !senderIsTerminal && sender != ruleset.dataHook()
543
- && !_hasDataHookMintPermissionFor(projectId, ruleset, sender)
563
+ ruleset.id != 0 && !ruleset.allowOwnerMinting() && !senderIsTerminalOrDataHook
564
+ && !senderHasDataHookMintPermission
544
565
  ) {
545
566
  revert JBController_MintNotAllowedAndNotTerminalOrHook(sender);
546
567
  }
@@ -83,6 +83,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
83
83
  // ------------------------ internal constants ----------------------- //
84
84
  //*********************************************************************//
85
85
 
86
+ /// @notice Denominator for forward-calculating this terminal's fee from a pre-fee amount.
87
+ uint256 internal constant _FEE_AMOUNT_FROM_DENOMINATOR = JBConstants.MAX_FEE / FEE;
88
+
86
89
  /// @notice Project ID #1 receives fees. It should be the first project launched during the deployment process.
87
90
  uint256 internal constant _FEE_BENEFICIARY_PROJECT_ID = 1;
88
91
 
@@ -330,15 +333,18 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
330
333
  // This payout is eligible for a fee since the funds are leaving this contract and the split hook isn't a
331
334
  // feeless address.
332
335
  if (!_isFeeless(address(split.hook))) {
333
- netPayoutAmount -= JBFees.feeAmountFrom({amountBeforeFee: amount, feePercent: FEE});
336
+ unchecked {
337
+ netPayoutAmount -= _feeAmountFrom(amount);
338
+ }
334
339
  }
335
340
 
336
341
  // Create the context to send to the split hook.
337
342
  JBSplitHookContext memory context = JBSplitHookContext({
338
343
  token: token,
339
344
  amount: netPayoutAmount,
340
- decimals: STORE.accountingContextOf({terminal: address(this), projectId: projectId, token: token})
341
- .decimals,
345
+ decimals: STORE.accountingContextOf({
346
+ terminal: address(this), projectId: projectId, token: token
347
+ }).decimals,
342
348
  projectId: projectId,
343
349
  groupId: uint256(uint160(token)),
344
350
  split: split
@@ -370,7 +376,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
370
376
  // This payout is eligible for a fee if the funds are leaving this contract and the receiving terminal isn't
371
377
  // a feeless address.
372
378
  if (terminal != this && !_isFeeless(address(terminal))) {
373
- netPayoutAmount -= JBFees.feeAmountFrom({amountBeforeFee: amount, feePercent: FEE});
379
+ unchecked {
380
+ netPayoutAmount -= _feeAmountFrom(amount);
381
+ }
374
382
  }
375
383
 
376
384
  // Track the fee-free payout amount. During cashout at zero tax rate, fees apply
@@ -430,7 +438,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
430
438
  // This payout is eligible for a fee since the funds are leaving this contract and the recipient isn't a
431
439
  // feeless address.
432
440
  if (!_isFeeless(recipient)) {
433
- netPayoutAmount -= JBFees.feeAmountFrom({amountBeforeFee: amount, feePercent: FEE});
441
+ unchecked {
442
+ netPayoutAmount -= _feeAmountFrom(amount);
443
+ }
434
444
  }
435
445
 
436
446
  // If there's a beneficiary, send the funds directly to the beneficiary. Otherwise send to the
@@ -664,7 +674,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
664
674
  _processFee({
665
675
  projectId: projectId,
666
676
  token: token,
667
- amount: JBFees.feeAmountFrom({amountBeforeFee: heldFee.amount, feePercent: FEE}),
677
+ amount: _feeAmountFrom(heldFee.amount),
668
678
  beneficiary: heldFee.beneficiary,
669
679
  feeTerminal: feeTerminal,
670
680
  wasHeld: true
@@ -1150,20 +1160,24 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1150
1160
  // Cache whether the beneficiary is feeless.
1151
1161
  bool beneficiaryIsFeeless = _isFeeless(beneficiary);
1152
1162
 
1153
- // Record the cash out.
1154
- (ruleset, reclaimAmount, cashOutTaxRate, hookSpecifications) = STORE.recordCashOutFor({
1155
- holder: holder,
1156
- projectId: projectId,
1157
- cashOutCount: cashOutCount,
1158
- tokenToReclaim: tokenToReclaim,
1159
- beneficiaryIsFeeless: beneficiaryIsFeeless,
1160
- metadata: metadata
1161
- });
1163
+ {
1164
+ // Cache the controller to avoid a redundant external call (also used inside STORE.recordCashOutFor).
1165
+ IJBController controller = _controllerOf(projectId);
1166
+
1167
+ // Record the cash out.
1168
+ (ruleset, reclaimAmount, cashOutTaxRate, hookSpecifications) = STORE.recordCashOutFor({
1169
+ holder: holder,
1170
+ projectId: projectId,
1171
+ cashOutCount: cashOutCount,
1172
+ tokenToReclaim: tokenToReclaim,
1173
+ beneficiaryIsFeeless: beneficiaryIsFeeless,
1174
+ metadata: metadata
1175
+ });
1162
1176
 
1163
- // Burn the project tokens.
1164
- if (cashOutCount != 0) {
1165
- _controllerOf(projectId)
1166
- .burnTokensOf({holder: holder, projectId: projectId, tokenCount: cashOutCount, memo: ""});
1177
+ // Burn the project tokens.
1178
+ if (cashOutCount != 0) {
1179
+ controller.burnTokensOf({holder: holder, projectId: projectId, tokenCount: cashOutCount, memo: ""});
1180
+ }
1167
1181
  }
1168
1182
 
1169
1183
  // Keep a reference to the amount being reclaimed that is subject to fees.
@@ -1176,16 +1190,22 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1176
1190
  if (cashOutTaxRate != 0) {
1177
1191
  // Non-zero tax: fees apply to the full reclaim amount.
1178
1192
  amountEligibleForFees += reclaimAmount;
1179
- reclaimAmount -= JBFees.feeAmountFrom({amountBeforeFee: reclaimAmount, feePercent: FEE});
1193
+ unchecked {
1194
+ reclaimAmount -= _feeAmountFrom(reclaimAmount);
1195
+ }
1180
1196
  } else {
1181
1197
  // Zero tax: fees apply only up to the fee-free surplus (round-trip prevention).
1182
1198
  uint256 feeFreeSurplus = _feeFreeSurplusOf[projectId][tokenToReclaim];
1183
1199
  if (feeFreeSurplus != 0) {
1184
1200
  uint256 feeableAmount = reclaimAmount < feeFreeSurplus ? reclaimAmount : feeFreeSurplus;
1185
1201
  // slither-disable-next-line reentrancy-no-eth,reentrancy-eth,reentrancy-benign
1186
- _feeFreeSurplusOf[projectId][tokenToReclaim] = feeFreeSurplus - feeableAmount;
1202
+ unchecked {
1203
+ _feeFreeSurplusOf[projectId][tokenToReclaim] = feeFreeSurplus - feeableAmount;
1204
+ }
1187
1205
  amountEligibleForFees += feeableAmount;
1188
- reclaimAmount -= JBFees.feeAmountFrom({amountBeforeFee: feeableAmount, feePercent: FEE});
1206
+ unchecked {
1207
+ reclaimAmount -= _feeAmountFrom(feeableAmount);
1208
+ }
1189
1209
  }
1190
1210
  }
1191
1211
  }
@@ -1433,9 +1453,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1433
1453
  }
1434
1454
 
1435
1455
  // Get the fee for the specified amount.
1436
- uint256 specificationAmountFee = _isFeeless(address(specification.hook))
1437
- ? 0
1438
- : JBFees.feeAmountFrom({amountBeforeFee: specification.amount, feePercent: FEE});
1456
+ uint256 specificationAmountFee =
1457
+ _isFeeless(address(specification.hook)) ? 0 : _feeAmountFrom(specification.amount);
1439
1458
 
1440
1459
  // Add the specification's amount to the amount eligible for fees.
1441
1460
  if (specificationAmountFee != 0) {
@@ -1611,12 +1630,12 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1611
1630
  // slither-disable-next-line reentrancy-events
1612
1631
  newlyIssuedTokenCount = _controllerOf(projectId)
1613
1632
  .mintTokensOf({
1614
- projectId: projectId,
1615
- tokenCount: tokenCount,
1616
- beneficiary: beneficiary,
1617
- memo: "",
1618
- useReservedPercent: true
1619
- });
1633
+ projectId: projectId,
1634
+ tokenCount: tokenCount,
1635
+ beneficiary: beneficiary,
1636
+ memo: "",
1637
+ useReservedPercent: true
1638
+ });
1620
1639
  }
1621
1640
 
1622
1641
  emit Pay({
@@ -1706,8 +1725,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1706
1725
  }
1707
1726
 
1708
1727
  /// @notice Returns held fees to the project who paid them based on the specified amount.
1709
- /// @dev Fee rounding during partial replenishment can zero out dust-level fee entries (< 40 wei at 2.5% fee).
1710
- /// This is accepted behavior dust fees are economically insignificant.
1728
+ /// @dev Partial replenishments use the raw floor calculation so repaying a dust amount cannot both credit the
1729
+ /// payer project and leave the fee project owed the 1-unit minimum fee.
1711
1730
  /// @param projectId The project held fees are being returned to.
1712
1731
  /// @param token The token that the held fees are in.
1713
1732
  /// @param amount The amount to base the calculation on, as a fixed point number with the same number of decimals
@@ -1743,7 +1762,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1743
1762
  break;
1744
1763
  } else {
1745
1764
  // Notice here we take `feeAmountFrom` on the stored `.amount`.
1746
- uint256 feeAmount = JBFees.feeAmountFrom({amountBeforeFee: heldFee.amount, feePercent: FEE});
1765
+ uint256 feeAmount = _feeAmountFrom(heldFee.amount);
1747
1766
 
1748
1767
  // Keep a reference to the amount from which the fee was taken.
1749
1768
  uint256 amountPaidOut = heldFee.amount - feeAmount;
@@ -1757,8 +1776,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1757
1776
  // Move the start index forward to the held fee after the current one.
1758
1777
  newStartIndex = startIndex + i + 1;
1759
1778
  } else {
1760
- // And here we overwrite with `feeAmountResultingIn` the `leftoverAmount`
1761
- feeAmount = JBFees.feeAmountResultingIn({amountAfterFee: leftoverAmount, feePercent: FEE});
1779
+ // Use the floor variant here. The minimum 1-unit fee applies when a fee is created, not while
1780
+ // splitting an already-held fee entry across repayments.
1781
+ feeAmount = JBFees.feeAmountResultingInFloorForFee25(leftoverAmount);
1762
1782
 
1763
1783
  // Get fee from `leftoverAmount`.
1764
1784
  unchecked {
@@ -1813,10 +1833,6 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1813
1833
  (ruleset, amountPaidOut) =
1814
1834
  STORE.recordPayoutFor({projectId: projectId, token: token, amount: amount, currency: currency});
1815
1835
 
1816
- // Cap fee-free surplus at remaining balance. Non-fee-free funds leave first.
1817
- // slither-disable-next-line reentrancy-no-eth,reentrancy-eth,reentrancy-benign
1818
- _capFeeFreeSurplus({projectId: projectId, token: token});
1819
-
1820
1836
  // Get a reference to the project's owner.
1821
1837
  // The owner will receive tokens minted by paying the platform fee and receive any leftover funds not sent to
1822
1838
  // payout splits.
@@ -1845,17 +1861,20 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1845
1861
  // Send any leftover funds to the project owner and update the fee tracking accordingly.
1846
1862
  if (leftoverPayoutAmount != 0) {
1847
1863
  // Keep a reference to the fee for the leftover payout amount.
1848
- uint256 fee = _isFeeless(projectOwner)
1849
- ? 0
1850
- : JBFees.feeAmountFrom({amountBeforeFee: leftoverPayoutAmount, feePercent: FEE});
1864
+ uint256 fee = _isFeeless(projectOwner) ? 0 : _feeAmountFrom(leftoverPayoutAmount);
1865
+
1866
+ uint256 netLeftoverPayoutAmount;
1867
+ unchecked {
1868
+ netLeftoverPayoutAmount = leftoverPayoutAmount - fee;
1869
+ }
1851
1870
 
1852
1871
  // Failed owner transfer consumes the payout limit by design. Same pattern as split payouts:
1853
1872
  // the try-catch prevents revert, failed amount is returned to project balance, and the owner can retry
1854
1873
  // via addToBalanceOf or in the next cycle.
1855
- try this.executeTransferTo({addr: projectOwner, token: token, amount: leftoverPayoutAmount - fee}) {
1874
+ try this.executeTransferTo({addr: projectOwner, token: token, amount: netLeftoverPayoutAmount}) {
1856
1875
  if (fee > 0) {
1857
1876
  amountEligibleForFees += leftoverPayoutAmount;
1858
- leftoverPayoutAmount -= fee;
1877
+ leftoverPayoutAmount = netLeftoverPayoutAmount;
1859
1878
  }
1860
1879
  } catch (bytes memory reason) {
1861
1880
  // slither-disable-next-line reentrancy-events
@@ -1863,7 +1882,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1863
1882
  projectId: projectId,
1864
1883
  addr: projectOwner,
1865
1884
  token: token,
1866
- amount: leftoverPayoutAmount - fee,
1885
+ amount: netLeftoverPayoutAmount,
1867
1886
  fee: fee,
1868
1887
  reason: reason,
1869
1888
  caller: sender
@@ -1874,6 +1893,11 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1874
1893
  }
1875
1894
  }
1876
1895
 
1896
+ // Cap fee-free surplus at remaining balance. Non-fee-free funds leave first.
1897
+ // Placed after all payouts settle so the cap reflects post-payout state.
1898
+ // slither-disable-next-line reentrancy-no-eth,reentrancy-eth,reentrancy-benign
1899
+ _capFeeFreeSurplus({projectId: projectId, token: token});
1900
+
1877
1901
  // Take the fee.
1878
1902
  uint256 feeTaken = _takeFeeFrom({
1879
1903
  projectId: projectId,
@@ -1914,7 +1938,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1914
1938
  returns (uint256 feeAmount)
1915
1939
  {
1916
1940
  // Get a reference to the fee amount.
1917
- feeAmount = JBFees.feeAmountFrom({amountBeforeFee: amount, feePercent: FEE});
1941
+ feeAmount = _feeAmountFrom(amount);
1918
1942
 
1919
1943
  if (shouldHoldFees) {
1920
1944
  // Store the held fee.
@@ -2166,4 +2190,18 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
2166
2190
  tokenAmount =
2167
2191
  JBTokenAmount({token: token, decimals: context.decimals, currency: context.currency, value: value});
2168
2192
  }
2193
+
2194
+ //*********************************************************************//
2195
+ // -------------------------- private helpers ------------------------ //
2196
+ //*********************************************************************//
2197
+
2198
+ /// @notice The terminal fee charged from a pre-fee `amount`.
2199
+ /// @dev Returns at least 1 for nonzero feeable amounts so dust payouts cannot bypass protocol fees.
2200
+ /// @param amount The amount before the fee is applied.
2201
+ /// @return feeAmount The fee amount.
2202
+ function _feeAmountFrom(uint256 amount) private pure returns (uint256 feeAmount) {
2203
+ feeAmount = amount / _FEE_AMOUNT_FROM_DENOMINATOR;
2204
+
2205
+ return feeAmount == 0 && amount != 0 ? 1 : feeAmount;
2206
+ }
2169
2207
  }
@@ -411,8 +411,8 @@ contract JBTerminalStore is IJBTerminalStore {
411
411
  // Validate BEFORE writing to storage to avoid wasting gas on SSTORE when the tx will revert.
412
412
  uint256 payoutLimit = IJBController(address(DIRECTORY.controllerOf(projectId))).FUND_ACCESS_LIMITS()
413
413
  .payoutLimitOf({
414
- projectId: projectId, rulesetId: ruleset.id, terminal: msg.sender, token: token, currency: currency
415
- });
414
+ projectId: projectId, rulesetId: ruleset.id, terminal: msg.sender, token: token, currency: currency
415
+ });
416
416
 
417
417
  // Make sure the new used amount is within the payout limit.
418
418
  if (newUsedPayoutLimitOf > payoutLimit || payoutLimit == 0) {
@@ -513,8 +513,8 @@ contract JBTerminalStore is IJBTerminalStore {
513
513
  // Validate BEFORE writing to storage to avoid wasting gas on SSTORE when the tx will revert.
514
514
  uint256 surplusAllowance = IJBController(address(DIRECTORY.controllerOf(projectId))).FUND_ACCESS_LIMITS()
515
515
  .surplusAllowanceOf({
516
- projectId: projectId, rulesetId: ruleset.id, terminal: msg.sender, token: token, currency: currency
517
- });
516
+ projectId: projectId, rulesetId: ruleset.id, terminal: msg.sender, token: token, currency: currency
517
+ });
518
518
 
519
519
  // Make sure the new used amount is within the allowance.
520
520
  if (newUsedSurplusAllowanceOf > surplusAllowance || surplusAllowance == 0) {
@@ -1332,8 +1332,8 @@ contract JBTerminalStore is IJBTerminalStore {
1332
1332
  JBCurrencyAmount[] memory payoutLimits = IJBController(address(DIRECTORY.controllerOf(projectId)))
1333
1333
  .FUND_ACCESS_LIMITS()
1334
1334
  .payoutLimitsOf({
1335
- projectId: projectId, rulesetId: ruleset.id, terminal: address(terminal), token: accountingContext.token
1336
- });
1335
+ projectId: projectId, rulesetId: ruleset.id, terminal: address(terminal), token: accountingContext.token
1336
+ });
1337
1337
 
1338
1338
  // Keep a reference to the number of payout limits being iterated on.
1339
1339
  uint256 numberOfPayoutLimits = payoutLimits.length;
@@ -57,9 +57,10 @@ interface IJBController is IERC165, IJBProjectUriRegistry, IJBDirectoryAccessCon
57
57
  /// @notice Rulesets were launched for an existing project.
58
58
  /// @param rulesetId The ID of the first queued ruleset.
59
59
  /// @param projectId The ID of the project.
60
+ /// @param projectUri The metadata URI of the project.
60
61
  /// @param memo A memo associated with the launch.
61
62
  /// @param caller The address that called the launch function.
62
- event LaunchRulesets(uint256 rulesetId, uint256 projectId, string memo, address caller);
63
+ event LaunchRulesets(uint256 rulesetId, uint256 projectId, string projectUri, string memo, address caller);
63
64
 
64
65
  /// @notice Tokens were minted for a beneficiary.
65
66
  /// @param beneficiary The address that received the minted tokens.
@@ -313,12 +314,14 @@ interface IJBController is IERC165, IJBProjectUriRegistry, IJBDirectoryAccessCon
313
314
 
314
315
  /// @notice Queues a project's initial rulesets and sets up terminals for it.
315
316
  /// @param projectId The ID of the project to launch rulesets for.
317
+ /// @param projectUri The project's metadata URI. Pass an empty string to leave it unchanged.
316
318
  /// @param rulesetConfigurations The rulesets to queue.
317
319
  /// @param terminalConfigurations The terminals to set up.
318
320
  /// @param memo A memo to pass along to the emitted event.
319
321
  /// @return rulesetId The ID of the last successfully queued ruleset.
320
322
  function launchRulesetsFor(
321
323
  uint256 projectId,
324
+ string calldata projectUri,
322
325
  JBRulesetConfig[] calldata rulesetConfigurations,
323
326
  JBTerminalConfig[] calldata terminalConfigurations,
324
327
  string calldata memo
@@ -7,24 +7,62 @@ import {JBConstants} from "./../libraries/JBConstants.sol";
7
7
 
8
8
  /// @notice Fee calculations.
9
9
  library JBFees {
10
+ /// @notice Returns the fee that would be taken from `amountBeforeFee`.
11
+ /// @dev Use this to forward-calculate the fee from a known pre-fee amount.
12
+ /// @dev If a nonzero amount and nonzero fee would otherwise produce a zero fee, returns 1 so feeable dust payouts
13
+ /// cannot bypass protocol fees by splitting across tiny transfers.
14
+ /// @param amountBeforeFee The amount before the fee is applied, as a fixed point number.
15
+ /// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
16
+ /// @return The fee amount, as a fixed point number with the same number of decimals as the provided `amount`.
17
+ function feeAmountFrom(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {
18
+ uint256 feeAmount = feeAmountFromFloor({amountBeforeFee: amountBeforeFee, feePercent: feePercent});
19
+
20
+ return feeAmount == 0 && amountBeforeFee != 0 && feePercent != 0 ? 1 : feeAmount;
21
+ }
22
+
23
+ /// @notice Returns the floor-rounded fee that would be taken from `amountBeforeFee`.
24
+ /// @dev Fee rounding error is bounded by N-1 wei (N = number of splits). Economically insignificant. Rounds down
25
+ /// (mulDiv floors), so the fee beneficiary may receive up to 1 wei less per split.
26
+ /// @param amountBeforeFee The amount before the fee is applied, as a fixed point number.
27
+ /// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
28
+ /// @return The floor-rounded fee amount, as a fixed point number with the same number of decimals as the provided
29
+ /// `amount`.
30
+ function feeAmountFromFloor(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {
31
+ return mulDiv(amountBeforeFee, feePercent, JBConstants.MAX_FEE);
32
+ }
33
+
10
34
  /// @notice Returns the fee amount that, when added to `amountAfterFee`, produces the gross amount needed to yield
11
35
  /// `amountAfterFee` after the fee is deducted.
12
36
  /// @dev Use this to back-calculate the fee from a desired post-fee payout.
37
+ /// @dev If a nonzero amount and nonzero fee would otherwise produce a zero fee, returns 1 so feeable dust payouts
38
+ /// cannot bypass protocol fees by splitting across tiny transfers.
13
39
  /// @param amountAfterFee The desired post-fee amount, as a fixed point number.
14
40
  /// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
15
41
  /// @return The fee amount, as a fixed point number with the same number of decimals as the provided `amount`.
16
42
  function feeAmountResultingIn(uint256 amountAfterFee, uint256 feePercent) internal pure returns (uint256) {
17
- return mulDiv(amountAfterFee, JBConstants.MAX_FEE, JBConstants.MAX_FEE - feePercent) - amountAfterFee;
43
+ uint256 feeAmount = feeAmountResultingInFloor({amountAfterFee: amountAfterFee, feePercent: feePercent});
44
+
45
+ return feeAmount == 0 && amountAfterFee != 0 && feePercent != 0 ? 1 : feeAmount;
18
46
  }
19
47
 
20
- /// @notice Returns the fee that would be taken from `amountBeforeFee`.
21
- /// @dev Use this to forward-calculate the fee from a known pre-fee amount.
22
- /// @dev Fee rounding error is bounded by N-1 wei (N = number of splits). Economically
23
- /// insignificant. Rounds down (mulDiv floors), so the fee beneficiary may receive up to 1 wei less per split.
24
- /// @param amountBeforeFee The amount before the fee is applied, as a fixed point number.
48
+ /// @notice Returns the floor-rounded fee amount that, when added to `amountAfterFee`, produces the gross amount
49
+ /// needed to yield `amountAfterFee` after the fee is deducted.
50
+ /// @dev Use this when adjusting an existing held-fee entry, where applying the 1-unit minimum again would double
51
+ /// charge dust.
52
+ /// @param amountAfterFee The desired post-fee amount, as a fixed point number.
25
53
  /// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
26
- /// @return The fee amount, as a fixed point number with the same number of decimals as the provided `amount`.
27
- function feeAmountFrom(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {
28
- return mulDiv(amountBeforeFee, feePercent, JBConstants.MAX_FEE);
54
+ /// @return The floor-rounded fee amount, as a fixed point number with the same number of decimals as the provided
55
+ /// `amount`.
56
+ function feeAmountResultingInFloor(uint256 amountAfterFee, uint256 feePercent) internal pure returns (uint256) {
57
+ return mulDiv(amountAfterFee, JBConstants.MAX_FEE, JBConstants.MAX_FEE - feePercent) - amountAfterFee;
58
+ }
59
+
60
+ /// @notice Returns the floor-rounded fee amount resulting in `amountAfterFee` for a 2.5% fee.
61
+ /// @dev Equivalent to `feeAmountResultingInFloor(amountAfterFee, 25)`, but avoids the generic `mulDiv` path.
62
+ /// @param amountAfterFee The desired post-fee amount, as a fixed point number.
63
+ /// @return The floor-rounded fee amount.
64
+ function feeAmountResultingInFloorForFee25(uint256 amountAfterFee) internal pure returns (uint256) {
65
+ // The specialized denominator is `(JBConstants.MAX_FEE - 25) / 25`.
66
+ return amountAfterFee / 39;
29
67
  }
30
68
  }
@@ -140,8 +140,8 @@ library JBPayoutSplitGroupLib {
140
140
  // slither-disable-next-line reentrancy-events,calls-loop
141
141
  try IJBPayoutSplitGroupExecutor(address(this))
142
142
  .executePayout({
143
- split: split, projectId: projectId, token: token, amount: amount, originalMessageSender: caller
144
- }) returns (
143
+ split: split, projectId: projectId, token: token, amount: amount, originalMessageSender: caller
144
+ }) returns (
145
145
  uint256 payoutAmount
146
146
  ) {
147
147
  return payoutAmount;
@@ -1,7 +1,7 @@
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
6
  contract JBMatchingPriceFeed is IJBPriceFeed {
7
7
  constructor() {}
@@ -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 {