@bananapus/core-v6 0.0.37 → 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 (287) 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 +19 -1
  5. package/src/JBMultiTerminal.sol +68 -34
  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/CodexMigrationFeeFailure.t.sol +0 -163
  74. package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
  75. package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
  76. package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
  77. package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
  78. package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
  79. package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
  80. package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
  81. package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
  82. package/test/formal/BondingCurveProperties.t.sol +0 -420
  83. package/test/formal/FeeProperties.t.sol +0 -252
  84. package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
  85. package/test/invariants/RulesetsInvariant.t.sol +0 -125
  86. package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
  87. package/test/invariants/TokensInvariant.t.sol +0 -195
  88. package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
  89. package/test/invariants/handlers/EconomicHandler.sol +0 -377
  90. package/test/invariants/handlers/Phase3Handler.sol +0 -443
  91. package/test/invariants/handlers/RulesetsHandler.sol +0 -115
  92. package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
  93. package/test/invariants/handlers/TokensHandler.sol +0 -126
  94. package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
  95. package/test/regression/WeightCacheBoundary.t.sol +0 -291
  96. package/test/trees/JBController/burnTokensOf.tree +0 -9
  97. package/test/trees/JBController/claimTokensFor.tree +0 -5
  98. package/test/trees/JBController/deployERC20For.tree +0 -5
  99. package/test/trees/JBController/getRulesetOf.tree +0 -5
  100. package/test/trees/JBController/launchProjectFor.tree +0 -12
  101. package/test/trees/JBController/launchRulesetsFor.tree +0 -8
  102. package/test/trees/JBController/migrateController.tree +0 -12
  103. package/test/trees/JBController/mintTokensOf.tree +0 -12
  104. package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
  105. package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
  106. package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
  107. package/test/trees/JBController/setMetadataOf.tree +0 -5
  108. package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
  109. package/test/trees/JBController/setTokenFor.tree +0 -5
  110. package/test/trees/JBController/transferCreditsFrom.tree +0 -8
  111. package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
  112. package/test/trees/JBDirectory/setControllerOf.tree +0 -11
  113. package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
  114. package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
  115. package/test/trees/JBERC20/initialize.tree +0 -7
  116. package/test/trees/JBERC20/name.tree +0 -5
  117. package/test/trees/JBERC20/nonces.tree +0 -5
  118. package/test/trees/JBERC20/symbol.tree +0 -5
  119. package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
  120. package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
  121. package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
  122. package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
  123. package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
  124. package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
  125. package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
  126. package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
  127. package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
  128. package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
  129. package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
  130. package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
  131. package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
  132. package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
  133. package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
  134. package/test/trees/JBMultiTerminal/pay.tree +0 -23
  135. package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
  136. package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
  137. package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
  138. package/test/trees/JBPermissions/hasPermission.tree +0 -8
  139. package/test/trees/JBPermissions/hasPermissions.tree +0 -8
  140. package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
  141. package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
  142. package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
  143. package/test/trees/JBProjects/createFor.tree +0 -11
  144. package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
  145. package/test/trees/JBProjects/supportsInterface.tree +0 -9
  146. package/test/trees/JBProjects/tokenURI.tree +0 -5
  147. package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
  148. package/test/trees/JBRulesets/currentOf.tree +0 -12
  149. package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
  150. package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
  151. package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
  152. package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
  153. package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
  154. package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
  155. package/test/trees/JBSplits/splitsOf.tree +0 -5
  156. package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
  157. package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
  158. package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
  159. package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
  160. package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
  161. package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
  162. package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
  163. package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
  164. package/test/trees/JBTokens/burnFrom.tree +0 -10
  165. package/test/trees/JBTokens/claimTokensFor.tree +0 -10
  166. package/test/trees/JBTokens/deployERC20For.tree +0 -12
  167. package/test/trees/JBTokens/mintFor.tree +0 -10
  168. package/test/trees/JBTokens/setTokenFor.tree +0 -11
  169. package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
  170. package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
  171. package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
  172. package/test/trees/mintTokensOf.tree +0 -12
  173. package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
  174. package/test/units/static/JBController/JBControllerSetup.sol +0 -50
  175. package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
  176. package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
  177. package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
  178. package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
  179. package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
  180. package/test/units/static/JBController/TestMigrateController.sol +0 -157
  181. package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
  182. package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
  183. package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
  184. package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
  185. package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
  186. package/test/units/static/JBController/TestRulesetViews.sol +0 -225
  187. package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
  188. package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
  189. package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
  190. package/test/units/static/JBController/TestSetUriOf.sol +0 -57
  191. package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
  192. package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
  193. package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
  194. package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
  195. package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
  196. package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
  197. package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
  198. package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
  199. package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
  200. package/test/units/static/JBERC20/SigUtils.sol +0 -36
  201. package/test/units/static/JBERC20/TestInitialize.sol +0 -60
  202. package/test/units/static/JBERC20/TestName.sol +0 -30
  203. package/test/units/static/JBERC20/TestNonces.sol +0 -62
  204. package/test/units/static/JBERC20/TestSymbol.sol +0 -31
  205. package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
  206. package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
  207. package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
  208. package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
  209. package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
  210. package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
  211. package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
  212. package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
  213. package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
  214. package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
  215. package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
  216. package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
  217. package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
  218. package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
  219. package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
  220. package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
  221. package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
  222. package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
  223. package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
  224. package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
  225. package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
  226. package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
  227. package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
  228. package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
  229. package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
  230. package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
  231. package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
  232. package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
  233. package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
  234. package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
  235. package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
  236. package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
  237. package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
  238. package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
  239. package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
  240. package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
  241. package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
  242. package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
  243. package/test/units/static/JBPrices/TestPrices.sol +0 -265
  244. package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
  245. package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
  246. package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
  247. package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
  248. package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
  249. package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
  250. package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
  251. package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
  252. package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
  253. package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
  254. package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
  255. package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
  256. package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
  257. package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
  258. package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
  259. package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
  260. package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
  261. package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
  262. package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
  263. package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
  264. package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
  265. package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
  266. package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
  267. package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
  268. package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
  269. package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
  270. package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
  271. package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
  272. package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
  273. package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
  274. package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
  275. package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
  276. package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
  277. package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
  278. package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
  279. package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
  280. package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
  281. package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
  282. package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
  283. package/test/units/static/JBTokens/TestMintFor.sol +0 -100
  284. package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
  285. package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
  286. package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
  287. 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.37",
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.19",
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.
@@ -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
@@ -1180,16 +1190,22 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1180
1190
  if (cashOutTaxRate != 0) {
1181
1191
  // Non-zero tax: fees apply to the full reclaim amount.
1182
1192
  amountEligibleForFees += reclaimAmount;
1183
- reclaimAmount -= JBFees.feeAmountFrom({amountBeforeFee: reclaimAmount, feePercent: FEE});
1193
+ unchecked {
1194
+ reclaimAmount -= _feeAmountFrom(reclaimAmount);
1195
+ }
1184
1196
  } else {
1185
1197
  // Zero tax: fees apply only up to the fee-free surplus (round-trip prevention).
1186
1198
  uint256 feeFreeSurplus = _feeFreeSurplusOf[projectId][tokenToReclaim];
1187
1199
  if (feeFreeSurplus != 0) {
1188
1200
  uint256 feeableAmount = reclaimAmount < feeFreeSurplus ? reclaimAmount : feeFreeSurplus;
1189
1201
  // slither-disable-next-line reentrancy-no-eth,reentrancy-eth,reentrancy-benign
1190
- _feeFreeSurplusOf[projectId][tokenToReclaim] = feeFreeSurplus - feeableAmount;
1202
+ unchecked {
1203
+ _feeFreeSurplusOf[projectId][tokenToReclaim] = feeFreeSurplus - feeableAmount;
1204
+ }
1191
1205
  amountEligibleForFees += feeableAmount;
1192
- reclaimAmount -= JBFees.feeAmountFrom({amountBeforeFee: feeableAmount, feePercent: FEE});
1206
+ unchecked {
1207
+ reclaimAmount -= _feeAmountFrom(feeableAmount);
1208
+ }
1193
1209
  }
1194
1210
  }
1195
1211
  }
@@ -1437,9 +1453,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1437
1453
  }
1438
1454
 
1439
1455
  // Get the fee for the specified amount.
1440
- uint256 specificationAmountFee = _isFeeless(address(specification.hook))
1441
- ? 0
1442
- : JBFees.feeAmountFrom({amountBeforeFee: specification.amount, feePercent: FEE});
1456
+ uint256 specificationAmountFee =
1457
+ _isFeeless(address(specification.hook)) ? 0 : _feeAmountFrom(specification.amount);
1443
1458
 
1444
1459
  // Add the specification's amount to the amount eligible for fees.
1445
1460
  if (specificationAmountFee != 0) {
@@ -1615,12 +1630,12 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1615
1630
  // slither-disable-next-line reentrancy-events
1616
1631
  newlyIssuedTokenCount = _controllerOf(projectId)
1617
1632
  .mintTokensOf({
1618
- projectId: projectId,
1619
- tokenCount: tokenCount,
1620
- beneficiary: beneficiary,
1621
- memo: "",
1622
- useReservedPercent: true
1623
- });
1633
+ projectId: projectId,
1634
+ tokenCount: tokenCount,
1635
+ beneficiary: beneficiary,
1636
+ memo: "",
1637
+ useReservedPercent: true
1638
+ });
1624
1639
  }
1625
1640
 
1626
1641
  emit Pay({
@@ -1710,8 +1725,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1710
1725
  }
1711
1726
 
1712
1727
  /// @notice Returns held fees to the project who paid them based on the specified amount.
1713
- /// @dev Fee rounding during partial replenishment can zero out dust-level fee entries (< 40 wei at 2.5% fee).
1714
- /// 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.
1715
1730
  /// @param projectId The project held fees are being returned to.
1716
1731
  /// @param token The token that the held fees are in.
1717
1732
  /// @param amount The amount to base the calculation on, as a fixed point number with the same number of decimals
@@ -1747,7 +1762,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1747
1762
  break;
1748
1763
  } else {
1749
1764
  // Notice here we take `feeAmountFrom` on the stored `.amount`.
1750
- uint256 feeAmount = JBFees.feeAmountFrom({amountBeforeFee: heldFee.amount, feePercent: FEE});
1765
+ uint256 feeAmount = _feeAmountFrom(heldFee.amount);
1751
1766
 
1752
1767
  // Keep a reference to the amount from which the fee was taken.
1753
1768
  uint256 amountPaidOut = heldFee.amount - feeAmount;
@@ -1761,8 +1776,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1761
1776
  // Move the start index forward to the held fee after the current one.
1762
1777
  newStartIndex = startIndex + i + 1;
1763
1778
  } else {
1764
- // And here we overwrite with `feeAmountResultingIn` the `leftoverAmount`
1765
- 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);
1766
1782
 
1767
1783
  // Get fee from `leftoverAmount`.
1768
1784
  unchecked {
@@ -1817,10 +1833,6 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1817
1833
  (ruleset, amountPaidOut) =
1818
1834
  STORE.recordPayoutFor({projectId: projectId, token: token, amount: amount, currency: currency});
1819
1835
 
1820
- // Cap fee-free surplus at remaining balance. Non-fee-free funds leave first.
1821
- // slither-disable-next-line reentrancy-no-eth,reentrancy-eth,reentrancy-benign
1822
- _capFeeFreeSurplus({projectId: projectId, token: token});
1823
-
1824
1836
  // Get a reference to the project's owner.
1825
1837
  // The owner will receive tokens minted by paying the platform fee and receive any leftover funds not sent to
1826
1838
  // payout splits.
@@ -1849,17 +1861,20 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1849
1861
  // Send any leftover funds to the project owner and update the fee tracking accordingly.
1850
1862
  if (leftoverPayoutAmount != 0) {
1851
1863
  // Keep a reference to the fee for the leftover payout amount.
1852
- uint256 fee = _isFeeless(projectOwner)
1853
- ? 0
1854
- : 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
+ }
1855
1870
 
1856
1871
  // Failed owner transfer consumes the payout limit by design. Same pattern as split payouts:
1857
1872
  // the try-catch prevents revert, failed amount is returned to project balance, and the owner can retry
1858
1873
  // via addToBalanceOf or in the next cycle.
1859
- try this.executeTransferTo({addr: projectOwner, token: token, amount: leftoverPayoutAmount - fee}) {
1874
+ try this.executeTransferTo({addr: projectOwner, token: token, amount: netLeftoverPayoutAmount}) {
1860
1875
  if (fee > 0) {
1861
1876
  amountEligibleForFees += leftoverPayoutAmount;
1862
- leftoverPayoutAmount -= fee;
1877
+ leftoverPayoutAmount = netLeftoverPayoutAmount;
1863
1878
  }
1864
1879
  } catch (bytes memory reason) {
1865
1880
  // slither-disable-next-line reentrancy-events
@@ -1867,7 +1882,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1867
1882
  projectId: projectId,
1868
1883
  addr: projectOwner,
1869
1884
  token: token,
1870
- amount: leftoverPayoutAmount - fee,
1885
+ amount: netLeftoverPayoutAmount,
1871
1886
  fee: fee,
1872
1887
  reason: reason,
1873
1888
  caller: sender
@@ -1878,6 +1893,11 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1878
1893
  }
1879
1894
  }
1880
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
+
1881
1901
  // Take the fee.
1882
1902
  uint256 feeTaken = _takeFeeFrom({
1883
1903
  projectId: projectId,
@@ -1918,7 +1938,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1918
1938
  returns (uint256 feeAmount)
1919
1939
  {
1920
1940
  // Get a reference to the fee amount.
1921
- feeAmount = JBFees.feeAmountFrom({amountBeforeFee: amount, feePercent: FEE});
1941
+ feeAmount = _feeAmountFrom(amount);
1922
1942
 
1923
1943
  if (shouldHoldFees) {
1924
1944
  // Store the held fee.
@@ -2170,4 +2190,18 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
2170
2190
  tokenAmount =
2171
2191
  JBTokenAmount({token: token, decimals: context.decimals, currency: context.currency, value: value});
2172
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
+ }
2173
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 {