@bananapus/core-v6 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/foundry.lock +1 -7
- package/foundry.toml +1 -1
- package/package.json +19 -7
- package/src/JBChainlinkV3PriceFeed.sol +4 -1
- package/src/JBChainlinkV3SequencerPriceFeed.sol +4 -2
- package/src/JBController.sol +71 -44
- package/src/JBDeadline.sol +4 -4
- package/src/JBDirectory.sol +34 -32
- package/src/JBERC20.sol +5 -4
- package/src/JBFeelessAddresses.sol +6 -3
- package/src/JBFundAccessLimits.sol +25 -21
- package/src/JBMultiTerminal.sol +121 -84
- package/src/JBPermissions.sol +34 -37
- package/src/JBPrices.sol +23 -18
- package/src/JBProjects.sol +6 -3
- package/src/JBRulesets.sol +44 -41
- package/src/JBSplits.sol +18 -16
- package/src/JBTerminalStore.sol +32 -25
- package/src/JBTokens.sol +36 -26
- package/src/abstract/JBControlled.sol +3 -1
- package/src/abstract/JBPermissioned.sol +3 -1
- package/src/enums/JBApprovalStatus.sol +7 -1
- package/src/interfaces/IJBController.sol +7 -3
- package/src/interfaces/IJBDirectory.sol +3 -1
- package/src/interfaces/IJBMultiTerminal.sol +3 -2
- package/src/interfaces/IJBPermissions.sol +2 -1
- package/src/interfaces/IJBPrices.sol +3 -1
- package/src/interfaces/IJBRulesets.sol +2 -1
- package/src/interfaces/IJBSplits.sol +2 -1
- package/src/interfaces/IJBTerminal.sol +3 -1
- package/src/interfaces/IJBTerminalStore.sol +3 -1
- package/src/interfaces/IJBTokens.sol +2 -1
- package/src/libraries/JBCashOuts.sol +6 -1
- package/src/libraries/JBConstants.sol +12 -3
- package/src/libraries/JBCurrencyIds.sol +2 -0
- package/src/libraries/JBFees.sol +52 -10
- package/src/libraries/JBFixedPointNumber.sol +2 -0
- package/src/libraries/JBPayoutSplitGroupLib.sol +7 -4
- package/src/libraries/JBRulesetMetadataResolver.sol +4 -0
- package/src/libraries/JBSplitGroupIds.sol +2 -1
- package/src/libraries/JBSurplus.sol +3 -1
- package/src/periphery/JBMatchingPriceFeed.sol +3 -1
- package/src/structs/JBAccountingContext.sol +7 -4
- package/src/structs/JBFundAccessLimitGroup.sol +10 -17
- package/src/structs/JBRuleset.sol +18 -26
- package/src/structs/JBRulesetConfig.sol +13 -25
- package/src/structs/JBRulesetMetadata.sol +25 -32
- package/test/mock/MockMaliciousBeneficiary.sol +15 -15
- package/ADMINISTRATION.md +0 -103
- package/ARCHITECTURE.md +0 -133
- package/AUDIT_INSTRUCTIONS.md +0 -139
- package/RISKS.md +0 -215
- package/SKILLS.md +0 -55
- package/STYLE_GUIDE.md +0 -610
- package/USER_JOURNEYS.md +0 -215
- package/script/Deploy.s.sol +0 -124
- package/script/DeployPeriphery.s.sol +0 -354
- package/slither-ci.config.json +0 -10
- package/test/AuditFixes.t.sol +0 -808
- package/test/ComprehensiveInvariant.t.sol +0 -306
- package/test/CoreExploitTests.t.sol +0 -2741
- package/test/EconomicSimulation.t.sol +0 -348
- package/test/EntryPointPermutations.t.sol +0 -684
- package/test/FlashLoanAttacks.t.sol +0 -797
- package/test/PermissionEscalation.t.sol +0 -711
- package/test/PermissionsInvariant.t.sol +0 -403
- package/test/RulesetTransitions.t.sol +0 -713
- package/test/SplitLoopTests.t.sol +0 -752
- package/test/TestAccessToFunds.sol +0 -2683
- package/test/TestAuditResponseDesignProofs.sol +0 -434
- package/test/TestCashOut.sol +0 -198
- package/test/TestCashOutCountFor.sol +0 -271
- package/test/TestCashOutHooks.sol +0 -351
- package/test/TestCashOutTimingEdge.sol +0 -241
- package/test/TestDataHookFuzzing.sol +0 -524
- package/test/TestDurationUnderflow.sol +0 -233
- package/test/TestFeeFreeCashOutBypass.sol +0 -949
- package/test/TestFeeProcessingFailure.sol +0 -218
- package/test/TestFees.sol +0 -619
- package/test/TestForwardedTokenConsumption.sol +0 -425
- package/test/TestInterfaceSupport.sol +0 -81
- package/test/TestJBERC20Inheritance.sol +0 -103
- package/test/TestL2SequencerPriceFeed.sol +0 -292
- package/test/TestLaunchProject.sol +0 -188
- package/test/TestMetaTx.sol +0 -217
- package/test/TestMetadataOffsetOverflow.sol +0 -179
- package/test/TestMetadataParserLib.sol +0 -471
- package/test/TestMigrationHeldFees.sol +0 -255
- package/test/TestMintTokensOf.sol +0 -185
- package/test/TestMultiTerminalSurplus.sol +0 -348
- package/test/TestMultiTokenSurplus.sol +0 -202
- package/test/TestMultipleAccessLimits.sol +0 -664
- package/test/TestPayBurnRedeemFlow.sol +0 -195
- package/test/TestPayHooks.sol +0 -209
- package/test/TestPermissions.sol +0 -324
- package/test/TestPermissionsEdge.sol +0 -290
- package/test/TestPermit2DataHook.t.sol +0 -360
- package/test/TestPermit2Terminal.sol +0 -372
- package/test/TestRulesetQueueing.sol +0 -1025
- package/test/TestRulesetQueuingStress.sol +0 -806
- package/test/TestRulesetWeightCaching.sol +0 -178
- package/test/TestSplits.sol +0 -391
- package/test/TestTerminalMigration.sol +0 -274
- package/test/TestTerminalPreviewParity.sol +0 -208
- package/test/TestTokenFlow.sol +0 -191
- package/test/TestWeightCacheStaleAfterRejection.sol +0 -303
- package/test/WeirdTokenTests.t.sol +0 -817
- package/test/audit/CashOutReenterPay.t.sol +0 -501
- package/test/audit/CodexHeldFeeRounding.t.sol +0 -159
- package/test/audit/CodexMigrationFeeFailure.t.sol +0 -163
- package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
- package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
- package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
- package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
- package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
- package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
- package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
- package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
- package/test/formal/BondingCurveProperties.t.sol +0 -420
- package/test/formal/FeeProperties.t.sol +0 -252
- package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
- package/test/invariants/RulesetsInvariant.t.sol +0 -125
- package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
- package/test/invariants/TokensInvariant.t.sol +0 -195
- package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
- package/test/invariants/handlers/EconomicHandler.sol +0 -377
- package/test/invariants/handlers/Phase3Handler.sol +0 -443
- package/test/invariants/handlers/RulesetsHandler.sol +0 -115
- package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
- package/test/invariants/handlers/TokensHandler.sol +0 -126
- package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
- package/test/regression/WeightCacheBoundary.t.sol +0 -291
- package/test/trees/JBController/burnTokensOf.tree +0 -9
- package/test/trees/JBController/claimTokensFor.tree +0 -5
- package/test/trees/JBController/deployERC20For.tree +0 -5
- package/test/trees/JBController/getRulesetOf.tree +0 -5
- package/test/trees/JBController/launchProjectFor.tree +0 -12
- package/test/trees/JBController/launchRulesetsFor.tree +0 -8
- package/test/trees/JBController/migrateController.tree +0 -12
- package/test/trees/JBController/mintTokensOf.tree +0 -12
- package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
- package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
- package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
- package/test/trees/JBController/setMetadataOf.tree +0 -5
- package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
- package/test/trees/JBController/setTokenFor.tree +0 -5
- package/test/trees/JBController/transferCreditsFrom.tree +0 -8
- package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
- package/test/trees/JBDirectory/setControllerOf.tree +0 -11
- package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
- package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
- package/test/trees/JBERC20/initialize.tree +0 -7
- package/test/trees/JBERC20/name.tree +0 -5
- package/test/trees/JBERC20/nonces.tree +0 -5
- package/test/trees/JBERC20/symbol.tree +0 -5
- package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
- package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
- package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
- package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
- package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
- package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
- package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
- package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
- package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
- package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
- package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
- package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
- package/test/trees/JBMultiTerminal/pay.tree +0 -23
- package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
- package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
- package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
- package/test/trees/JBPermissions/hasPermission.tree +0 -8
- package/test/trees/JBPermissions/hasPermissions.tree +0 -8
- package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
- package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
- package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
- package/test/trees/JBProjects/createFor.tree +0 -11
- package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
- package/test/trees/JBProjects/supportsInterface.tree +0 -9
- package/test/trees/JBProjects/tokenURI.tree +0 -5
- package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
- package/test/trees/JBRulesets/currentOf.tree +0 -12
- package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
- package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
- package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
- package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
- package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
- package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
- package/test/trees/JBSplits/splitsOf.tree +0 -5
- package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
- package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
- package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
- package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
- package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
- package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
- package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
- package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
- package/test/trees/JBTokens/burnFrom.tree +0 -10
- package/test/trees/JBTokens/claimTokensFor.tree +0 -10
- package/test/trees/JBTokens/deployERC20For.tree +0 -12
- package/test/trees/JBTokens/mintFor.tree +0 -10
- package/test/trees/JBTokens/setTokenFor.tree +0 -11
- package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
- package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
- package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
- package/test/trees/mintTokensOf.tree +0 -12
- package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
- package/test/units/static/JBController/JBControllerSetup.sol +0 -50
- package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
- package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
- package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
- package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
- package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
- package/test/units/static/JBController/TestMigrateController.sol +0 -157
- package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
- package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
- package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
- package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
- package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
- package/test/units/static/JBController/TestRulesetViews.sol +0 -225
- package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
- package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
- package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
- package/test/units/static/JBController/TestSetUriOf.sol +0 -57
- package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
- package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
- package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
- package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
- package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
- package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
- package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
- package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
- package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
- package/test/units/static/JBERC20/SigUtils.sol +0 -36
- package/test/units/static/JBERC20/TestInitialize.sol +0 -60
- package/test/units/static/JBERC20/TestName.sol +0 -30
- package/test/units/static/JBERC20/TestNonces.sol +0 -62
- package/test/units/static/JBERC20/TestSymbol.sol +0 -31
- package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
- package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
- package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
- package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
- package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
- package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
- package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
- package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
- package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
- package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
- package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
- package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
- package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
- package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
- package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
- package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
- package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
- package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
- package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
- package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
- package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
- package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
- package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
- package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
- package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
- package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
- package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
- package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
- package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
- package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
- package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
- package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
- package/test/units/static/JBPrices/TestPrices.sol +0 -265
- package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
- package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
- package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
- package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
- package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
- package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
- package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
- package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
- package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
- package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
- package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
- package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
- package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
- package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
- package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
- package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
- package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
- package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
- package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
- package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
- package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
- package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
- package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
- package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
- package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
- package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
- package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
- package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
- package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
- package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
- package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
- package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
- package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
- package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
- package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
- package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
- package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
- package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
- package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
- package/test/units/static/JBTokens/TestMintFor.sol +0 -100
- package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
- package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
- package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
- package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +0 -56
|
@@ -23,8 +23,11 @@ interface IJBPayoutSplitGroupExecutor {
|
|
|
23
23
|
returns (uint256 netPayoutAmount);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/// @notice
|
|
27
|
-
///
|
|
26
|
+
/// @notice Handles distributing payouts to a project's split recipients. Iterates through each split, sends the
|
|
27
|
+
/// proportional amount, and gracefully handles failures — if a split payout reverts (e.g. a hook is broken), the
|
|
28
|
+
/// amount is returned to the project's balance rather than blocking all other splits.
|
|
29
|
+
/// @dev Extracted as an external library to reduce `JBMultiTerminal` bytecode size. Called via DELEGATECALL, so events
|
|
30
|
+
/// are emitted from the terminal's address.
|
|
28
31
|
library JBPayoutSplitGroupLib {
|
|
29
32
|
event PayoutReverted(uint256 indexed projectId, JBSplit split, uint256 amount, bytes reason, address caller);
|
|
30
33
|
event SendPayoutToSplit(
|
|
@@ -140,8 +143,8 @@ library JBPayoutSplitGroupLib {
|
|
|
140
143
|
// slither-disable-next-line reentrancy-events,calls-loop
|
|
141
144
|
try IJBPayoutSplitGroupExecutor(address(this))
|
|
142
145
|
.executePayout({
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
split: split, projectId: projectId, token: token, amount: amount, originalMessageSender: caller
|
|
147
|
+
}) returns (
|
|
145
148
|
uint256 payoutAmount
|
|
146
149
|
) {
|
|
147
150
|
return payoutAmount;
|
|
@@ -4,6 +4,10 @@ pragma solidity 0.8.28;
|
|
|
4
4
|
import {JBRuleset} from "./../structs/JBRuleset.sol";
|
|
5
5
|
import {JBRulesetMetadata} from "./../structs/JBRulesetMetadata.sol";
|
|
6
6
|
|
|
7
|
+
/// @notice Unpacks the 256-bit packed `metadata` field from a `JBRuleset` into individual parameters. The metadata
|
|
8
|
+
/// encodes: reservedPercent, cashOutTaxRate, baseCurrency, 14 boolean flags (pausePay, allowOwnerMinting, etc.),
|
|
9
|
+
/// a data hook address, and 14 bits of custom metadata. Used throughout the protocol to read ruleset configuration
|
|
10
|
+
/// without storing each field separately.
|
|
7
11
|
library JBRulesetMetadataResolver {
|
|
8
12
|
function reservedPercent(JBRuleset memory ruleset) internal pure returns (uint16) {
|
|
9
13
|
return uint16(ruleset.metadata >> 4);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.28;
|
|
3
3
|
|
|
4
|
-
/// @notice
|
|
4
|
+
/// @notice Well-known split group IDs. The reserved tokens group (ID 1) defines how a project's reserved tokens are
|
|
5
|
+
/// distributed. Payout split groups use the token address cast to `uint256(uint160(token))` as their group ID.
|
|
5
6
|
library JBSplitGroupIds {
|
|
6
7
|
uint256 public constant RESERVED_TOKENS = 1;
|
|
7
8
|
}
|
|
@@ -3,7 +3,9 @@ pragma solidity 0.8.28;
|
|
|
3
3
|
|
|
4
4
|
import {IJBTerminal} from "../interfaces/IJBTerminal.sol";
|
|
5
5
|
|
|
6
|
-
/// @notice Surplus
|
|
6
|
+
/// @notice Calculates a project's total surplus across all its terminals. Surplus is the amount held beyond what's
|
|
7
|
+
/// needed to cover the project's payout limits — it represents the pool available for cash outs and surplus allowance
|
|
8
|
+
/// usage. Aggregates across multiple terminals and tokens, converting to a common currency via `JBPrices`.
|
|
7
9
|
library JBSurplus {
|
|
8
10
|
/// @notice Gets the total current surplus amount across all of a project's terminals.
|
|
9
11
|
/// @dev This amount changes as the value of the balances changes in relation to the currency being used to measure
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.28;
|
|
3
3
|
|
|
4
|
-
import {IJBPriceFeed} from "
|
|
4
|
+
import {IJBPriceFeed} from "../interfaces/IJBPriceFeed.sol";
|
|
5
5
|
|
|
6
|
+
/// @notice A trivial price feed that always returns 1:1 (one unit = one unit). Used when a payout limit is
|
|
7
|
+
/// denominated in the same currency as the terminal's token, so no actual conversion is needed.
|
|
6
8
|
contract JBMatchingPriceFeed is IJBPriceFeed {
|
|
7
9
|
constructor() {}
|
|
8
10
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
/// @
|
|
5
|
-
///
|
|
6
|
-
///
|
|
7
|
-
///
|
|
4
|
+
/// @notice Describes how a terminal accounts for a specific token — its address, decimal precision, and which
|
|
5
|
+
/// currency
|
|
6
|
+
/// it's priced in. Used when recording payments, payouts, and cash outs to ensure correct fixed-point arithmetic.
|
|
7
|
+
/// @custom:member token The token address (use `JBConstants.NATIVE_TOKEN` for ETH).
|
|
8
|
+
/// @custom:member decimals The number of decimals for this token's fixed-point amounts (e.g. 18 for ETH, 6 for USDC).
|
|
9
|
+
/// @custom:member currency The currency ID for price feed lookups. Convention: `uint32(uint160(tokenAddress))` for
|
|
10
|
+
/// tokens, or `JBCurrencyIds.ETH`/`JBCurrencyIds.USD` for well-known currencies.
|
|
8
11
|
struct JBAccountingContext {
|
|
9
12
|
address token;
|
|
10
13
|
uint8 decimals;
|
|
@@ -3,23 +3,16 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {JBCurrencyAmount} from "./JBCurrencyAmount.sol";
|
|
5
5
|
|
|
6
|
-
/// @
|
|
7
|
-
/// the project can
|
|
8
|
-
///
|
|
9
|
-
///
|
|
10
|
-
///
|
|
11
|
-
/// @dev
|
|
12
|
-
///
|
|
13
|
-
/// @
|
|
14
|
-
///
|
|
15
|
-
/// @custom:member
|
|
16
|
-
/// @custom:member token The token that the payout limits and surplus allowances apply to within the `terminal`.
|
|
17
|
-
/// @custom:member payoutLimits An array of payout limits. The payout limits cumulatively dictate the maximum value of
|
|
18
|
-
/// `token`s a project can pay out from its balance in a terminal during a ruleset. Each payout limit can have a unique
|
|
19
|
-
/// currency and amount.
|
|
20
|
-
/// @custom:member surplusAllowances An array of surplus allowances. The surplus allowances cumulatively dictates the
|
|
21
|
-
/// maximum value of `token`s a project can pay out from its surplus (balance less payouts) in a terminal during a
|
|
22
|
-
/// ruleset. Each surplus allowance can have a unique currency and amount.
|
|
6
|
+
/// @notice Defines how much a project can withdraw from a specific terminal and token each funding cycle.
|
|
7
|
+
/// @dev Example — payout limit of 5 USD in an ETH terminal: the project can distribute up to 5 USD worth of ETH to
|
|
8
|
+
/// its splits per cycle. Example — surplus allowance of 5 USD: the project owner can pull up to 5 USD worth of ETH
|
|
9
|
+
/// from the surplus (balance above payout limits).
|
|
10
|
+
/// @dev Multiple limits in different currencies are additive — each can be used independently within one cycle.
|
|
11
|
+
/// @dev Amounts use the same decimal precision as the terminal token (e.g. 18 for ETH, 6 for USDC).
|
|
12
|
+
/// @custom:member terminal The terminal address these limits apply to.
|
|
13
|
+
/// @custom:member token The token address within that terminal these limits apply to.
|
|
14
|
+
/// @custom:member payoutLimits Maximum amounts distributable to splits per cycle, each in a specific currency.
|
|
15
|
+
/// @custom:member surplusAllowances Maximum amounts withdrawable from surplus per cycle, each in a specific currency.
|
|
23
16
|
struct JBFundAccessLimitGroup {
|
|
24
17
|
address terminal;
|
|
25
18
|
address token;
|
|
@@ -3,32 +3,24 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {IJBRulesetApprovalHook} from "./../interfaces/IJBRulesetApprovalHook.sol";
|
|
5
5
|
|
|
6
|
-
/// @
|
|
7
|
-
///
|
|
8
|
-
///
|
|
9
|
-
/// @
|
|
10
|
-
///
|
|
11
|
-
/// @custom:member
|
|
12
|
-
///
|
|
13
|
-
/// @custom:member
|
|
14
|
-
///
|
|
15
|
-
///
|
|
16
|
-
///
|
|
17
|
-
///
|
|
18
|
-
/// @custom:member
|
|
19
|
-
///
|
|
20
|
-
///
|
|
21
|
-
///
|
|
22
|
-
///
|
|
23
|
-
///
|
|
24
|
-
/// a percentage out of `JBConstants.MAX_WEIGHT_CUT_PERCENT`. If it's 0, the next ruleset will have the same `weight` by
|
|
25
|
-
/// default. If it's 90%, the next ruleset's `weight` will be 10% smaller. If a ruleset explicitly sets a new `weight`,
|
|
26
|
-
/// the `weightCutPercent` doesn't apply.
|
|
27
|
-
/// @custom:member approvalHook An address of a contract that says whether a queued ruleset should be approved or
|
|
28
|
-
/// rejected. If a
|
|
29
|
-
/// ruleset is rejected, it won't go into effect. An approval hook can be used to create rules which dictate how a
|
|
30
|
-
/// project owner can change their ruleset over time.
|
|
31
|
-
/// @custom:member metadata Extra data associated with a ruleset which can be used by other contracts.
|
|
6
|
+
/// @notice A ruleset defines how a project behaves during a period of time — token issuance rate, cash-out terms,
|
|
7
|
+
/// payout rules, and permissions. Rulesets cycle automatically: when one expires, the next queued (and approved) one
|
|
8
|
+
/// takes effect. If nothing is queued, the current ruleset auto-cycles with decayed weight.
|
|
9
|
+
/// @dev Timestamps are unix timestamps (seconds since epoch).
|
|
10
|
+
/// @custom:member cycleNumber Which cycle this is (starts at 1, increments each cycle).
|
|
11
|
+
/// @custom:member id The ruleset's ID — the unix timestamp when it was first stored. Stays the same across
|
|
12
|
+
/// auto-cycles.
|
|
13
|
+
/// @custom:member basedOnId The ID of the ruleset that was active when this one was created (forms a linked list).
|
|
14
|
+
/// @custom:member start When this ruleset became/becomes active.
|
|
15
|
+
/// @custom:member duration How many seconds the ruleset lasts. 0 = no auto-cycling (must be explicitly replaced).
|
|
16
|
+
/// @custom:member weight Tokens minted per unit paid (18 decimals). The terminal divides payment amount by weight to
|
|
17
|
+
/// determine token issuance. Higher weight = more tokens per unit of payment.
|
|
18
|
+
/// @custom:member weightCutPercent How much to reduce weight each cycle (out of 1,000,000,000). 100,000,000 = 10% cut
|
|
19
|
+
/// per cycle. 0 = no decay. Only applies when a cycle auto-rolls without an explicitly queued replacement.
|
|
20
|
+
/// @custom:member approvalHook A contract that gates whether queued rulesets can take effect (e.g. `JBDeadline` for
|
|
21
|
+
/// minimum notice periods). If the hook rejects a queued ruleset, the current one continues.
|
|
22
|
+
/// @custom:member metadata Packed 256-bit field containing reservedPercent, cashOutTaxRate, baseCurrency, boolean
|
|
23
|
+
/// flags, data hook address, and custom metadata. Decoded by `JBRulesetMetadataResolver`.
|
|
32
24
|
struct JBRuleset {
|
|
33
25
|
uint48 cycleNumber;
|
|
34
26
|
uint48 id;
|
|
@@ -6,31 +6,19 @@ import {JBFundAccessLimitGroup} from "./JBFundAccessLimitGroup.sol";
|
|
|
6
6
|
import {JBRulesetMetadata} from "./JBRulesetMetadata.sol";
|
|
7
7
|
import {JBSplitGroup} from "./JBSplitGroup.sol";
|
|
8
8
|
|
|
9
|
-
/// @
|
|
10
|
-
///
|
|
11
|
-
///
|
|
12
|
-
///
|
|
13
|
-
///
|
|
14
|
-
///
|
|
15
|
-
///
|
|
16
|
-
///
|
|
17
|
-
///
|
|
18
|
-
///
|
|
19
|
-
/// @custom:member
|
|
20
|
-
///
|
|
21
|
-
///
|
|
22
|
-
/// equal weight. If the number is 90%, the next ruleset will have a 10% smaller weight. This weight is out of
|
|
23
|
-
/// `JBConstants.MAX_WEIGHT_CUT_PERCENT`.
|
|
24
|
-
/// @custom:member approvalHook An address of a contract that says whether a proposed ruleset should be accepted or
|
|
25
|
-
/// rejected. It
|
|
26
|
-
/// can be used to create rules around how a project owner can change ruleset parameters over time.
|
|
27
|
-
/// @custom:member metadata Metadata specifying the controller-specific parameters that a ruleset can have. These
|
|
28
|
-
/// properties cannot change until the next ruleset starts.
|
|
29
|
-
/// @custom:member splitGroups An array of splits to use for any number of groups while the ruleset is active.
|
|
30
|
-
/// @custom:member fundAccessLimitGroups An array of structs which dictate the amount of funds a project can access from
|
|
31
|
-
/// its balance in each payment terminal while the ruleset is active. Amounts are fixed point numbers using the same
|
|
32
|
-
/// number of decimals as the corresponding terminal. The `_payoutLimit` and `_surplusAllowance` parameters must fit in
|
|
33
|
-
/// a `uint232`.
|
|
9
|
+
/// @notice The configuration passed to `JBController.launchRulesetsFor` or `queueRulesetsOf` to define a new ruleset.
|
|
10
|
+
/// Includes the economic parameters (weight, duration, decay), the metadata (permissions and hooks), the split
|
|
11
|
+
/// recipients, and the fund access limits.
|
|
12
|
+
/// @custom:member mustStartAtOrAfter The earliest timestamp the ruleset can begin. Pass 0 to start immediately after
|
|
13
|
+
/// the previous ruleset ends.
|
|
14
|
+
/// @custom:member duration How long the ruleset lasts in seconds. 0 = stays active until explicitly replaced.
|
|
15
|
+
/// @custom:member weight Tokens minted per unit of payment (18 decimals). Pass 1 to inherit decayed weight from the
|
|
16
|
+
/// previous ruleset. Pass 0 for no token issuance.
|
|
17
|
+
/// @custom:member weightCutPercent Decay rate per cycle (out of 1,000,000,000). 100,000,000 = 10% cut. 0 = no decay.
|
|
18
|
+
/// @custom:member approvalHook Contract that must approve the *next* queued ruleset for it to take effect.
|
|
19
|
+
/// @custom:member metadata The ruleset's behavioral flags and parameters (see `JBRulesetMetadata`).
|
|
20
|
+
/// @custom:member splitGroups How payouts and reserved tokens are distributed during this ruleset.
|
|
21
|
+
/// @custom:member fundAccessLimitGroups How much the project can withdraw from each terminal per cycle.
|
|
34
22
|
struct JBRulesetConfig {
|
|
35
23
|
uint48 mustStartAtOrAfter;
|
|
36
24
|
uint32 duration;
|
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
/// @
|
|
5
|
-
/// `
|
|
6
|
-
/// @custom:member
|
|
7
|
-
///
|
|
8
|
-
/// @custom:member
|
|
9
|
-
///
|
|
10
|
-
/// @custom:member
|
|
11
|
-
///
|
|
12
|
-
///
|
|
13
|
-
/// @custom:member
|
|
14
|
-
///
|
|
15
|
-
/// @custom:member
|
|
16
|
-
///
|
|
17
|
-
/// @custom:member allowSetTerminals
|
|
18
|
-
/// @custom:member allowSetController
|
|
19
|
-
/// @custom:member allowAddAccountingContext
|
|
20
|
-
///
|
|
21
|
-
/// @custom:member
|
|
22
|
-
///
|
|
23
|
-
/// @custom:member
|
|
24
|
-
///
|
|
25
|
-
/// @custom:member
|
|
26
|
-
/// @custom:member
|
|
27
|
-
///
|
|
28
|
-
/// @custom:member
|
|
29
|
-
/// ruleset.
|
|
30
|
-
/// @custom:member useDataHookForCashOut A flag indicating if the data hook should be used for cash out transactions
|
|
31
|
-
/// during
|
|
32
|
-
/// this ruleset.
|
|
33
|
-
/// @custom:member dataHook The data hook to use during this ruleset.
|
|
34
|
-
/// @custom:member metadata Metadata of the metadata, only the 14 least significant bits can be used, the 2 most
|
|
35
|
-
/// significant bits are disregarded.
|
|
4
|
+
/// @notice Human-readable configuration for a ruleset's behavioral flags and parameters. This struct is packed into
|
|
5
|
+
/// 256 bits for on-chain storage (see `JBRulesetMetadataResolver` for the packing layout).
|
|
6
|
+
/// @custom:member reservedPercent Percentage of newly minted tokens set aside for the reserved token split group
|
|
7
|
+
/// (0–10,000 basis points). 5,000 = 50% reserved.
|
|
8
|
+
/// @custom:member cashOutTaxRate Tax applied when holders cash out tokens (0–10,000 basis points). Higher rate = less
|
|
9
|
+
/// reclaim per token. 0 = proportional, 10,000 = no reclaim (100% tax).
|
|
10
|
+
/// @custom:member baseCurrency The currency used to interpret the ruleset's weight for token issuance. Convention:
|
|
11
|
+
/// `uint32(uint160(tokenAddress))` for tokens, or `JBCurrencyIds.ETH`/`JBCurrencyIds.USD` for well-known currencies.
|
|
12
|
+
/// @custom:member pausePay If `true`, the project cannot receive payments during this ruleset.
|
|
13
|
+
/// @custom:member pauseCreditTransfers If `true`, token credit transfers are disabled during this ruleset.
|
|
14
|
+
/// @custom:member allowOwnerMinting If `true`, the project owner (or MINT_TOKENS operator) can mint tokens on demand.
|
|
15
|
+
/// @custom:member allowSetCustomToken If `true`, the project can set a custom ERC-20 token via `setTokenFor`.
|
|
16
|
+
/// @custom:member allowTerminalMigration If `true`, terminals can be migrated to new implementations.
|
|
17
|
+
/// @custom:member allowSetTerminals If `true`, the project's terminal list can be modified.
|
|
18
|
+
/// @custom:member allowSetController If `true`, the project's controller can be changed.
|
|
19
|
+
/// @custom:member allowAddAccountingContext If `true`, new token accounting contexts can be added to terminals.
|
|
20
|
+
/// @custom:member allowAddPriceFeed If `true`, the project can register new price feeds in `JBPrices`.
|
|
21
|
+
/// @custom:member ownerMustSendPayouts If `true`, only the project owner can trigger payout distribution.
|
|
22
|
+
/// @custom:member holdFees If `true`, fees are accumulated but not processed until a future ruleset (or manually).
|
|
23
|
+
/// @custom:member useTotalSurplusForCashOuts If `true`, cash-out calculations use surplus across all terminals (not
|
|
24
|
+
/// just the one being cashed out from).
|
|
25
|
+
/// @custom:member useDataHookForPay If `true`, the data hook is called before recording payments.
|
|
26
|
+
/// @custom:member useDataHookForCashOut If `true`, the data hook is called before recording cash outs.
|
|
27
|
+
/// @custom:member dataHook Contract called before pay/cash-out to potentially override token counts or add hooks.
|
|
28
|
+
/// @custom:member metadata 14 bits of application-specific metadata (upper 2 bits are ignored).
|
|
36
29
|
struct JBRulesetMetadata {
|
|
37
30
|
uint16 reservedPercent;
|
|
38
31
|
uint16 cashOutTaxRate;
|
|
@@ -19,12 +19,12 @@ contract MaliciousPayoutBeneficiary is IERC721Receiver, Test {
|
|
|
19
19
|
|
|
20
20
|
IJBMultiTerminal(_terminal)
|
|
21
21
|
.sendPayoutsOf({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
projectId: 2,
|
|
50
|
+
amount: 5 * 10 ** 18,
|
|
51
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
52
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
53
|
+
minTokensPaidOut: 0,
|
|
54
|
+
beneficiary: payable(address(this)),
|
|
55
|
+
feeBeneficiary: payable(0x000000000000000000000000000000000000007B),
|
|
56
|
+
memo: "MEMO"
|
|
57
|
+
});
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
receive() external payable {
|
package/ADMINISTRATION.md
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# Administration
|
|
2
|
-
|
|
3
|
-
## At A Glance
|
|
4
|
-
|
|
5
|
-
| Item | Details |
|
|
6
|
-
| --- | --- |
|
|
7
|
-
| Scope | Core Juicebox V6 control plane: directory, controller, terminals, permissions, prices, and global protocol switches |
|
|
8
|
-
| Control posture | Mixed protocol-owner, project-owner, delegated-operator, controller, and terminal control |
|
|
9
|
-
| Highest-risk actions | Controller migration, terminal migration, token binding, price-feed installation, and broad permission grants |
|
|
10
|
-
| Recovery posture | Project-local mistakes may be fixable if rulesets allow it; immutable infra mistakes usually require replacement and migration |
|
|
11
|
-
|
|
12
|
-
## Purpose
|
|
13
|
-
|
|
14
|
-
`nana-core-v6` is the main control plane in the stack. It mixes protocol-owned contracts, project-local ownership, delegated operators through `JBPermissions`, and ruleset flags that allow or block changes. This file explains who can still change project behavior after core is live.
|
|
15
|
-
|
|
16
|
-
## Control Model
|
|
17
|
-
|
|
18
|
-
- Protocol-wide `Ownable` surfaces exist on `JBDirectory`, `JBProjects`, `JBPrices`, and `JBFeelessAddresses`.
|
|
19
|
-
- Project-local control comes from the project NFT owner in `JBProjects`.
|
|
20
|
-
- Fine-grained operator delegation comes from `JBPermissions`.
|
|
21
|
-
- Controllers and terminals become privileged system callers once the directory points to them.
|
|
22
|
-
- The current ruleset can further allow or deny owner or operator actions.
|
|
23
|
-
|
|
24
|
-
## Roles
|
|
25
|
-
|
|
26
|
-
| Role | How Assigned | Scope | Notes |
|
|
27
|
-
| --- | --- | --- | --- |
|
|
28
|
-
| Project owner | `JBProjects.ownerOf(projectId)` | Per project | Main human control surface |
|
|
29
|
-
| Project operator | `JBPermissions` grant | Per project or wildcard | Can be narrow or dangerously broad |
|
|
30
|
-
| Controller | `JBDirectory.controllerOf(projectId)` | Per project | Manages rulesets, token setup, splits, and fund-access config |
|
|
31
|
-
| Terminal | `JBDirectory` terminal set | Per project | Moves funds through `JBTerminalStore` and terminal entrypoints |
|
|
32
|
-
| Protocol owner | `Ownable(owner)` on protocol-wide contracts | Global | Different contracts can have different owners |
|
|
33
|
-
| Omnichain ruleset operator | `JBController` constructor immutable | Global or broad | Bypasses some owner checks for synchronized ruleset flows |
|
|
34
|
-
|
|
35
|
-
## Privileged Surfaces
|
|
36
|
-
|
|
37
|
-
High-value admin functions include:
|
|
38
|
-
|
|
39
|
-
- `JBDirectory.setControllerOf(...)`, `setTerminalsOf(...)`, `setPrimaryTerminalOf(...)`
|
|
40
|
-
- `JBController.queueRulesetsOf(...)`, `launchRulesetsFor(...)`, `setSplitGroupsOf(...)`, `deployERC20For(...)`, `setTokenFor(...)`, `setUriOf(...)`, `addPriceFeedFor(...)`
|
|
41
|
-
- `JBMultiTerminal.useAllowanceOf(...)`, `migrateBalanceOf(...)`, `cashOutTokensOf(...)` when permission-gated by the holder or delegated authority
|
|
42
|
-
- `JBPermissions.setPermissionsFor(...)`
|
|
43
|
-
- `JBPrices.addPriceFeedFor(...)` for protocol defaults or project-local feeds
|
|
44
|
-
- `JBFeelessAddresses.setFeelessAddress(...)`
|
|
45
|
-
- `JBProjects.setTokenUriResolver(...)`
|
|
46
|
-
|
|
47
|
-
The practical split is simple:
|
|
48
|
-
|
|
49
|
-
- protocol owners change global infrastructure or defaults
|
|
50
|
-
- project owners and operators change project configuration
|
|
51
|
-
- controllers and terminals act with the authority core gives them
|
|
52
|
-
|
|
53
|
-
## Immutable And One-Way Decisions
|
|
54
|
-
|
|
55
|
-
- Default or project-specific price feeds are write-once for a given pair.
|
|
56
|
-
- ERC-20 token binding for a project is effectively one-time.
|
|
57
|
-
- The fee beneficiary project ID inside `JBMultiTerminal` is hardcoded.
|
|
58
|
-
- Constructor immutables on controller, directory, terminal, store, prices, and tokens cannot be patched.
|
|
59
|
-
|
|
60
|
-
## Operational Notes
|
|
61
|
-
|
|
62
|
-
- Use narrow project-scoped permissions instead of wildcard or ROOT permissions when possible.
|
|
63
|
-
- Check whether the active ruleset allows the change before assuming the owner or operator can make it.
|
|
64
|
-
- Treat controller migration, terminal migration, token deployment, and price-feed installation as high-blast-radius control-plane changes.
|
|
65
|
-
- Read both the permission check and the current ruleset flags before concluding an action is allowed.
|
|
66
|
-
- Keep fee-route and payout-path failure semantics in mind. Some failures restore project balance instead of trapping funds.
|
|
67
|
-
|
|
68
|
-
## Machine Notes
|
|
69
|
-
|
|
70
|
-
- Do not infer authority from project ownership alone. Many paths also depend on the active ruleset and permission bitmap.
|
|
71
|
-
- Treat `JBDirectory`, `JBController`, `JBMultiTerminal`, `JBPermissions`, `JBPrices`, `JBFeelessAddresses`, and `JBProjects` as the minimum control-plane source set.
|
|
72
|
-
- If a controller, terminal, or price-feed action is not backed by the exact current directory entry, stop and resolve the mismatch first.
|
|
73
|
-
- If a permission is not named explicitly in the call path, inspect the contract check before assuming delegated authority exists.
|
|
74
|
-
- If a fee route or split payout failed, check whether core restored balance or left a retry path before calling it a permanent loss.
|
|
75
|
-
|
|
76
|
-
## Recovery
|
|
77
|
-
|
|
78
|
-
- Wrong immutable infrastructure usually means deploying a new controller, terminal, store, or price layer and then migrating.
|
|
79
|
-
- Wrong project-local config can often be corrected if the current ruleset still allows it.
|
|
80
|
-
- Wrong wildcard permissions are fixed by updating the permission bitmap, but they are dangerous because of what can happen before revocation.
|
|
81
|
-
- Some fee-route and payout-route failures are recoverable in place because core prefers liveness over trapped funds.
|
|
82
|
-
|
|
83
|
-
## Admin Boundaries
|
|
84
|
-
|
|
85
|
-
- Protocol owners cannot directly rewrite project economics without going through the contracts and ruleset constraints that enforce those changes.
|
|
86
|
-
- Project owners cannot bypass immutable constructor references or rewrite existing price-feed entries.
|
|
87
|
-
- Controllers and terminals only have the authority given by the directory and core contracts.
|
|
88
|
-
- Nobody can change the hardcoded fee beneficiary or patch immutable deployment mistakes in place.
|
|
89
|
-
|
|
90
|
-
## Source Map
|
|
91
|
-
|
|
92
|
-
- `src/JBDirectory.sol`
|
|
93
|
-
- `src/JBController.sol`
|
|
94
|
-
- `src/JBMultiTerminal.sol`
|
|
95
|
-
- `src/JBPermissions.sol`
|
|
96
|
-
- `src/JBPrices.sol`
|
|
97
|
-
- `src/JBFeelessAddresses.sol`
|
|
98
|
-
- `src/JBProjects.sol`
|
|
99
|
-
- `test/units/static/JBController/`
|
|
100
|
-
- `test/units/static/JBDirectory/`
|
|
101
|
-
- `test/units/static/JBMultiTerminal/`
|
|
102
|
-
- `test/units/static/JBPermissions/`
|
|
103
|
-
- `test/units/static/JBPrices/`
|
package/ARCHITECTURE.md
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
# Architecture
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
|
|
5
|
-
`nana-core-v6` is the root of the V6 stack. It owns project identity, rulesets, permissions, treasury balances, token issuance, fee behavior, payout limits, and the hook interfaces that extension repos use.
|
|
6
|
-
|
|
7
|
-
If a change affects accounting, token supply, fees, terminal routing, or permission semantics, this repo is the source of truth.
|
|
8
|
-
|
|
9
|
-
## System Overview
|
|
10
|
-
|
|
11
|
-
`JBController`, `JBMultiTerminal`, and `JBTerminalStore` form the main execution and accounting path. `JBDirectory`, `JBRulesets`, `JBProjects`, `JBTokens`, `JBPermissions`, `JBSplits`, and related contracts provide routing, identity, and shared state for downstream repos.
|
|
12
|
-
|
|
13
|
-
`JBTerminalStore` is terminal-scoped through `msg.sender`, so each terminal tracks its own balances and usage while sharing the same ruleset and price surfaces. Hooks can change economics or add side effects, but they should not create a second ledger.
|
|
14
|
-
|
|
15
|
-
## Core Invariants
|
|
16
|
-
|
|
17
|
-
- Preview functions should stay aligned with the state-changing functions they mirror.
|
|
18
|
-
- Data hooks run before settlement and may change economics. Pay and cash-out hooks run after settlement.
|
|
19
|
-
- Reserved tokens and other pending supply affect supply-sensitive math before distribution.
|
|
20
|
-
- Terminal balances, fee accounting, reclaim math, and surplus calculations must agree.
|
|
21
|
-
- Fee logic taxes value leaving the system, not every internal rebalance.
|
|
22
|
-
- Rulesets are time-ordered and approval-aware, and downstream deployers depend on predictable ID progression.
|
|
23
|
-
- Permission checks are protocol safety checks, not just UI hints.
|
|
24
|
-
|
|
25
|
-
## Modules
|
|
26
|
-
|
|
27
|
-
| Module | Responsibility | Notes |
|
|
28
|
-
| --- | --- | --- |
|
|
29
|
-
| `JBMultiTerminal` | Payment, cash-out, payout, allowance, and fee entrypoints | Execution surface |
|
|
30
|
-
| `JBTerminalStore` | Shared accounting and preview math | Economic source of truth |
|
|
31
|
-
| `JBController` | Launch, queue rulesets, mint, burn, and update split groups | Supply and configuration |
|
|
32
|
-
| `JBDirectory`, `JBRulesets` | Project routing and time-based ruleset lifecycle | Coordination layer |
|
|
33
|
-
| `JBProjects`, `JBTokens`, `JBERC20` | Identity and token surfaces | Ownership and tokenization |
|
|
34
|
-
| `JBPermissions`, `JBSplits`, `JBFundAccessLimits`, `JBPrices` | Shared authorization and configuration state | Cross-repo dependencies |
|
|
35
|
-
|
|
36
|
-
## Trust Boundaries
|
|
37
|
-
|
|
38
|
-
- This repo owns the canonical balance and supply transitions.
|
|
39
|
-
- Hook repos may change inputs and post-settlement behavior, but they should not replace the core ledger.
|
|
40
|
-
- External price feeds, Permit2, and ERC-20 behavior matter, but accounting truth still lives here.
|
|
41
|
-
|
|
42
|
-
## Critical Flows
|
|
43
|
-
|
|
44
|
-
### Payment
|
|
45
|
-
|
|
46
|
-
```text
|
|
47
|
-
terminal receives funds
|
|
48
|
-
-> terminal store reads the active ruleset and optional data hooks
|
|
49
|
-
-> before-pay data hook can change weight and return pay-hook specs
|
|
50
|
-
-> terminal store records the payment in the terminal-scoped ledger
|
|
51
|
-
-> controller mints beneficiary tokens and accrues reserved tokens
|
|
52
|
-
-> pay hooks run after settlement
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Cash Out
|
|
56
|
-
|
|
57
|
-
```text
|
|
58
|
-
holder requests redemption
|
|
59
|
-
-> terminal store reads the current ruleset, balances, and supply inputs
|
|
60
|
-
-> before-cash-out data hook can change reclaim inputs and hook specs
|
|
61
|
-
-> terminal store records the cash out in the terminal-scoped ledger
|
|
62
|
-
-> controller burns tokens
|
|
63
|
-
-> terminal pays reclaim value and routes protocol fees
|
|
64
|
-
-> cash-out hooks run after settlement
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Launch And Queue Rulesets
|
|
68
|
-
|
|
69
|
-
```text
|
|
70
|
-
owner, operator, or omnichain ruleset operator
|
|
71
|
-
-> controller launches or queues rulesets
|
|
72
|
-
-> launch also sets the controller in the directory and configures terminals
|
|
73
|
-
-> rulesets become the source of truth for later pay, cash-out, and admin constraints
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Payouts And Allowances
|
|
77
|
-
|
|
78
|
-
```text
|
|
79
|
-
authorized caller
|
|
80
|
-
-> consumes payout limits or surplus allowances
|
|
81
|
-
-> funds move to splits, projects, hooks, or direct recipients
|
|
82
|
-
-> same-terminal project payouts stay inside terminal accounting and may add fee-free surplus
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Accounting Model
|
|
86
|
-
|
|
87
|
-
This repo owns the canonical ledger for balances, fees, supply-sensitive reclaim math, payout limits, allowances, reserved tokens, and preview calculations. Other repos may wrap or influence these values, but they should not duplicate them.
|
|
88
|
-
|
|
89
|
-
`JBTerminalStore` keeps terminal balances, payout-limit usage, and surplus-allowance usage. Those reset boundaries are not the same:
|
|
90
|
-
|
|
91
|
-
- payout-limit usage is tracked by ruleset cycle number
|
|
92
|
-
- surplus-allowance usage is tracked by `ruleset.id`
|
|
93
|
-
|
|
94
|
-
If a duration-based ruleset auto-cycles without a new ruleset ID, payout-limit usage resets but allowance usage does not.
|
|
95
|
-
|
|
96
|
-
## Security Model
|
|
97
|
-
|
|
98
|
-
- Review `JBMultiTerminal`, `JBTerminalStore`, and `JBController` as one pipeline.
|
|
99
|
-
- `JBTerminalStore` uses shared logic with terminal-scoped state. Misreading that split leads to bad accounting assumptions.
|
|
100
|
-
- Small changes in fee or surplus logic can affect every downstream repo.
|
|
101
|
-
- Same-terminal project payouts, fee-free surplus capping, and migration cleanup are coupled.
|
|
102
|
-
- `allowOwnerMinting` is not a universal mint kill switch. Other allowed paths can still mint.
|
|
103
|
-
- Hook ordering and preview-execution alignment are ongoing maintenance requirements.
|
|
104
|
-
|
|
105
|
-
## Safe Change Guide
|
|
106
|
-
|
|
107
|
-
- Trace both the preview path and the state-changing path for any nontrivial change.
|
|
108
|
-
- Read downstream hook repos before changing hook metadata or interface expectations.
|
|
109
|
-
- Keep fee logic, balance logic, reclaim math, and surplus math in sync.
|
|
110
|
-
- If you change same-terminal payouts between projects, re-check self-pay reverts, fee-free surplus accumulation, and post-pay caps.
|
|
111
|
-
- If you change ruleset rollover semantics, re-check which counters reset on cycle progression versus new ruleset IDs.
|
|
112
|
-
- If permissions change, update shared docs and downstream assumptions at the same time.
|
|
113
|
-
|
|
114
|
-
## Canonical Checks
|
|
115
|
-
|
|
116
|
-
- fee-free surplus and same-terminal payout behavior:
|
|
117
|
-
`test/TestFeeFreeCashOutBypass.sol`
|
|
118
|
-
- migration and terminal-accounting continuity:
|
|
119
|
-
`test/TestTerminalMigration.sol`
|
|
120
|
-
- ruleset ordering and transition behavior:
|
|
121
|
-
`test/RulesetTransitions.t.sol`
|
|
122
|
-
|
|
123
|
-
## Source Map
|
|
124
|
-
|
|
125
|
-
- `src/JBController.sol`
|
|
126
|
-
- `src/JBMultiTerminal.sol`
|
|
127
|
-
- `src/JBTerminalStore.sol`
|
|
128
|
-
- `src/JBDirectory.sol`
|
|
129
|
-
- `src/JBRulesets.sol`
|
|
130
|
-
- `src/JBPermissions.sol`
|
|
131
|
-
- `test/TestFeeFreeCashOutBypass.sol`
|
|
132
|
-
- `test/TestTerminalMigration.sol`
|
|
133
|
-
- `test/RulesetTransitions.t.sol`
|