@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
package/src/JBTerminalStore.sol
CHANGED
|
@@ -25,8 +25,12 @@ import {JBPayHookSpecification} from "./structs/JBPayHookSpecification.sol";
|
|
|
25
25
|
import {JBRuleset} from "./structs/JBRuleset.sol";
|
|
26
26
|
import {JBTokenAmount} from "./structs/JBTokenAmount.sol";
|
|
27
27
|
|
|
28
|
-
/// @notice
|
|
29
|
-
///
|
|
28
|
+
/// @notice The accounting engine behind every terminal. Records project balances, enforces payout limits and surplus
|
|
29
|
+
/// allowances, calculates how many tokens to mint per payment (based on the ruleset's weight and currency), and
|
|
30
|
+
/// determines how much a token holder receives when cashing out (via the bonding curve in `JBCashOuts`).
|
|
31
|
+
/// @dev Terminals call `recordPaymentFrom`, `recordPayoutFor`, `recordUsedAllowanceFrom`, and `recordCashOutFor` to
|
|
32
|
+
/// update state. This contract also handles data hook integration — if a ruleset specifies a data hook, it is called
|
|
33
|
+
/// before recording to potentially override token counts or specify pay/cash-out hooks.
|
|
30
34
|
contract JBTerminalStore is IJBTerminalStore {
|
|
31
35
|
// A library that parses the packed ruleset metadata into a friendlier format.
|
|
32
36
|
using JBRulesetMetadataResolver for JBRuleset;
|
|
@@ -161,8 +165,9 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
161
165
|
// ---------------------- external transactions ---------------------- //
|
|
162
166
|
//*********************************************************************//
|
|
163
167
|
|
|
164
|
-
/// @notice
|
|
165
|
-
///
|
|
168
|
+
/// @notice Registers which tokens a terminal can accept for a project, along with their decimal precision and
|
|
169
|
+
/// currency. Called by the terminal when `addAccountingContextsFor` is invoked.
|
|
170
|
+
/// @dev Uses `msg.sender` as the terminal address. Reverts if the current ruleset disallows adding contexts.
|
|
166
171
|
/// @param projectId The ID of the project.
|
|
167
172
|
/// @param contexts The accounting contexts to record.
|
|
168
173
|
function recordAccountingContextOf(uint256 projectId, JBAccountingContext[] calldata contexts) external override {
|
|
@@ -232,12 +237,11 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
232
237
|
balanceOf[msg.sender][projectId][token] = balanceOf[msg.sender][projectId][token] + amount;
|
|
233
238
|
}
|
|
234
239
|
|
|
235
|
-
/// @notice Records a cash out
|
|
236
|
-
/// @dev
|
|
237
|
-
///
|
|
238
|
-
/// burned.
|
|
240
|
+
/// @notice Records a cash out — calculates how many terminal tokens a holder receives for burning project tokens.
|
|
241
|
+
/// @dev Uses the data hook if configured, otherwise applies the bonding curve formula based on cash out tax rate,
|
|
242
|
+
/// surplus, and supply. The terminal calls this before actually burning tokens and transferring funds.
|
|
239
243
|
/// @param holder The account that is cashing out tokens.
|
|
240
|
-
/// @param projectId The ID of the project being
|
|
244
|
+
/// @param projectId The ID of the project being cashed out from.
|
|
241
245
|
/// @param cashOutCount The number of project tokens to cash out, as supplied by the caller and later burned by the
|
|
242
246
|
/// terminal, as a fixed point number with 18 decimals.
|
|
243
247
|
/// @param tokenToReclaim The token being reclaimed by the cash out.
|
|
@@ -310,9 +314,9 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
310
314
|
}
|
|
311
315
|
}
|
|
312
316
|
|
|
313
|
-
/// @notice Records a payment to
|
|
314
|
-
///
|
|
315
|
-
///
|
|
317
|
+
/// @notice Records a payment — calculates how many project tokens to mint based on the payment amount and the
|
|
318
|
+
/// current ruleset's weight. Uses the data hook if configured, otherwise mints proportionally.
|
|
319
|
+
/// @dev Called by the terminal after accepting funds. Updates the project's recorded balance.
|
|
316
320
|
/// @param payer The address that made the payment to the terminal.
|
|
317
321
|
/// @param amount The amount of tokens being paid. Includes the token being paid, their value, the number of
|
|
318
322
|
/// decimals included, and the currency of the amount.
|
|
@@ -353,10 +357,10 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
353
357
|
}
|
|
354
358
|
}
|
|
355
359
|
|
|
356
|
-
/// @notice Records a payout
|
|
357
|
-
///
|
|
358
|
-
///
|
|
359
|
-
///
|
|
360
|
+
/// @notice Records a payout — decrements the project's balance and enforces the payout limit. Called by the
|
|
361
|
+
/// terminal during `sendPayoutsOf`.
|
|
362
|
+
/// @dev Reverts if the total payouts for this cycle would exceed the ruleset's payout limit. The balance is
|
|
363
|
+
/// decremented before validation (safe because the entire tx reverts atomically on failure).
|
|
360
364
|
/// @param projectId The ID of the project that is paying out funds.
|
|
361
365
|
/// @param token The token being paid out.
|
|
362
366
|
/// @param amount The amount to pay out (use from the payout limit), as a fixed point number.
|
|
@@ -411,8 +415,8 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
411
415
|
// Validate BEFORE writing to storage to avoid wasting gas on SSTORE when the tx will revert.
|
|
412
416
|
uint256 payoutLimit = IJBController(address(DIRECTORY.controllerOf(projectId))).FUND_ACCESS_LIMITS()
|
|
413
417
|
.payoutLimitOf({
|
|
414
|
-
|
|
415
|
-
|
|
418
|
+
projectId: projectId, rulesetId: ruleset.id, terminal: msg.sender, token: token, currency: currency
|
|
419
|
+
});
|
|
416
420
|
|
|
417
421
|
// Make sure the new used amount is within the payout limit.
|
|
418
422
|
if (newUsedPayoutLimitOf > payoutLimit || payoutLimit == 0) {
|
|
@@ -428,7 +432,8 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
428
432
|
usedPayoutLimitOf[msg.sender][projectId][token][ruleset.cycleNumber][currency] = newUsedPayoutLimitOf;
|
|
429
433
|
}
|
|
430
434
|
|
|
431
|
-
/// @notice Records
|
|
435
|
+
/// @notice Records a terminal migration — zeros out the project's balance and returns the amount being moved to
|
|
436
|
+
/// the new terminal. The current ruleset must allow terminal migration.
|
|
432
437
|
/// @param projectId The ID of the project being migrated.
|
|
433
438
|
/// @param token The token being migrated.
|
|
434
439
|
/// @return balance The project's current balance (which is being migrated), as a fixed point number with the same
|
|
@@ -449,8 +454,10 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
449
454
|
balanceOf[msg.sender][projectId][token] = 0;
|
|
450
455
|
}
|
|
451
456
|
|
|
452
|
-
/// @notice Records a
|
|
453
|
-
///
|
|
457
|
+
/// @notice Records a surplus allowance withdrawal — takes funds from the project's surplus (the balance above
|
|
458
|
+
/// payout limits) and enforces the surplus allowance cap.
|
|
459
|
+
/// @dev Called by the terminal during `useAllowanceOf`. Unlike payouts, surplus withdrawals go directly to a
|
|
460
|
+
/// beneficiary rather than through splits.
|
|
454
461
|
/// @param projectId The ID of the project to use the surplus allowance of.
|
|
455
462
|
/// @param token The token whose balances should contribute to the surplus allowance being reclaimed from.
|
|
456
463
|
/// @param amount The amount to use from the surplus allowance, as a fixed point number.
|
|
@@ -513,8 +520,8 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
513
520
|
// Validate BEFORE writing to storage to avoid wasting gas on SSTORE when the tx will revert.
|
|
514
521
|
uint256 surplusAllowance = IJBController(address(DIRECTORY.controllerOf(projectId))).FUND_ACCESS_LIMITS()
|
|
515
522
|
.surplusAllowanceOf({
|
|
516
|
-
|
|
517
|
-
|
|
523
|
+
projectId: projectId, rulesetId: ruleset.id, terminal: msg.sender, token: token, currency: currency
|
|
524
|
+
});
|
|
518
525
|
|
|
519
526
|
// Make sure the new used amount is within the allowance.
|
|
520
527
|
if (newUsedSurplusAllowanceOf > surplusAllowance || surplusAllowance == 0) {
|
|
@@ -1332,8 +1339,8 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
1332
1339
|
JBCurrencyAmount[] memory payoutLimits = IJBController(address(DIRECTORY.controllerOf(projectId)))
|
|
1333
1340
|
.FUND_ACCESS_LIMITS()
|
|
1334
1341
|
.payoutLimitsOf({
|
|
1335
|
-
|
|
1336
|
-
|
|
1342
|
+
projectId: projectId, rulesetId: ruleset.id, terminal: address(terminal), token: accountingContext.token
|
|
1343
|
+
});
|
|
1337
1344
|
|
|
1338
1345
|
// Keep a reference to the number of payout limits being iterated on.
|
|
1339
1346
|
uint256 numberOfPayoutLimits = payoutLimits.length;
|
package/src/JBTokens.sol
CHANGED
|
@@ -8,12 +8,12 @@ import {IJBDirectory} from "./interfaces/IJBDirectory.sol";
|
|
|
8
8
|
import {IJBToken} from "./interfaces/IJBToken.sol";
|
|
9
9
|
import {IJBTokens} from "./interfaces/IJBTokens.sol";
|
|
10
10
|
|
|
11
|
-
/// @notice Manages
|
|
12
|
-
///
|
|
13
|
-
///
|
|
14
|
-
/// @dev The total supply
|
|
15
|
-
///
|
|
16
|
-
///
|
|
11
|
+
/// @notice Manages the dual-token system for every Juicebox project. When someone pays a project, the controller mints
|
|
12
|
+
/// tokens here — initially as internal "credits" tracked by this contract. Once a project deploys or attaches an
|
|
13
|
+
/// ERC-20, holders can claim their credits into transferable ERC-20 tokens. Burns always consume credits first.
|
|
14
|
+
/// @dev The total supply reported by `totalSupplyOf` is credits + ERC-20 supply combined, and is used by the terminal
|
|
15
|
+
/// to calculate cash-out values. Projects can deploy a new ERC-20 via `deployERC20For` or bring their own via
|
|
16
|
+
/// `setTokenFor` (must be 18 decimals).
|
|
17
17
|
contract JBTokens is JBControlled, IJBTokens {
|
|
18
18
|
//*********************************************************************//
|
|
19
19
|
// --------------------------- custom errors ------------------------- //
|
|
@@ -74,11 +74,11 @@ contract JBTokens is JBControlled, IJBTokens {
|
|
|
74
74
|
// ---------------------- external transactions ---------------------- //
|
|
75
75
|
//*********************************************************************//
|
|
76
76
|
|
|
77
|
-
/// @notice
|
|
78
|
-
///
|
|
79
|
-
/// @dev Only a project's current controller can burn its tokens.
|
|
77
|
+
/// @notice Destroy a holder's tokens for a project. Credits (internal balance) are burned first; if more tokens
|
|
78
|
+
/// need burning, the remaining amount is burned from the holder's ERC-20 balance.
|
|
79
|
+
/// @dev Only a project's current controller can burn its tokens. Called during cash outs and manual burns.
|
|
80
80
|
/// @param holder The address that owns the tokens which are being burned.
|
|
81
|
-
/// @param projectId The ID of the project
|
|
81
|
+
/// @param projectId The ID of the project the burned tokens belong to.
|
|
82
82
|
/// @param count The number of tokens to burn.
|
|
83
83
|
function burnFrom(address holder, uint256 projectId, uint256 count) external override onlyControllerOf(projectId) {
|
|
84
84
|
// Get a reference to the project's current token.
|
|
@@ -131,7 +131,9 @@ contract JBTokens is JBControlled, IJBTokens {
|
|
|
131
131
|
if (tokensToBurn > 0) token.burn({account: holder, amount: tokensToBurn});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
/// @notice
|
|
134
|
+
/// @notice Convert internal credits into transferable ERC-20 tokens. The credits are subtracted from the holder's
|
|
135
|
+
/// balance and the equivalent ERC-20 tokens are minted to the beneficiary. The project must have an ERC-20
|
|
136
|
+
/// deployed or attached.
|
|
135
137
|
/// @dev Only a project's controller can claim that project's tokens.
|
|
136
138
|
/// @param holder The owner of the credits being redeemed.
|
|
137
139
|
/// @param projectId The ID of the project whose tokens are being claimed.
|
|
@@ -180,8 +182,9 @@ contract JBTokens is JBControlled, IJBTokens {
|
|
|
180
182
|
token.mint({account: beneficiary, amount: count});
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
/// @notice
|
|
184
|
-
///
|
|
185
|
+
/// @notice Deploy a new ERC-20 token for a project (cloned from the `TOKEN` implementation). Once deployed, holders
|
|
186
|
+
/// can claim their credits into this transferable token. A project can only have one token — this reverts if one
|
|
187
|
+
/// already exists.
|
|
185
188
|
/// @dev Only a project's controller can deploy its token.
|
|
186
189
|
/// @param projectId The ID of the project to deploy an ERC-20 token for.
|
|
187
190
|
/// @param name The ERC-20's name.
|
|
@@ -231,8 +234,10 @@ contract JBTokens is JBControlled, IJBTokens {
|
|
|
231
234
|
token.initialize({name: name, symbol: symbol, tokens: address(this)});
|
|
232
235
|
}
|
|
233
236
|
|
|
234
|
-
/// @notice
|
|
235
|
-
///
|
|
237
|
+
/// @notice Create new tokens for a holder. If the project has an ERC-20 deployed, tokens are minted directly to
|
|
238
|
+
/// the holder's wallet. Otherwise, they're tracked as internal credits that can be claimed later.
|
|
239
|
+
/// @dev Only a project's current controller can mint its tokens. Called during payments and reserved token
|
|
240
|
+
/// distribution.
|
|
236
241
|
/// @param holder The address receiving the new tokens.
|
|
237
242
|
/// @param projectId The ID of the project to which the tokens belong.
|
|
238
243
|
/// @param count The number of tokens to mint.
|
|
@@ -276,11 +281,12 @@ contract JBTokens is JBControlled, IJBTokens {
|
|
|
276
281
|
});
|
|
277
282
|
}
|
|
278
283
|
|
|
279
|
-
/// @notice
|
|
284
|
+
/// @notice Attach an existing ERC-20 token to a project (instead of deploying a new one). The token must use 18
|
|
285
|
+
/// decimals and must not already be attached to another project. A project can only have one token.
|
|
280
286
|
/// @dev Only a project's controller can set its token.
|
|
281
|
-
/// @dev If the
|
|
282
|
-
///
|
|
283
|
-
///
|
|
287
|
+
/// @dev WARNING: If the ERC-20 has supply minted outside this contract, that supply will be included in
|
|
288
|
+
/// `totalSupplyOf` and dilute cash-out values for all holders. Ensure the token's supply is appropriate before
|
|
289
|
+
/// calling.
|
|
284
290
|
/// @param projectId The ID of the project to set the token of.
|
|
285
291
|
/// @param token The new token's address.
|
|
286
292
|
function setTokenFor(uint256 projectId, IJBToken token) external override onlyControllerOf(projectId) {
|
|
@@ -308,7 +314,8 @@ contract JBTokens is JBControlled, IJBTokens {
|
|
|
308
314
|
emit SetToken({projectId: projectId, token: token, caller: msg.sender});
|
|
309
315
|
}
|
|
310
316
|
|
|
311
|
-
/// @notice
|
|
317
|
+
/// @notice Update the name and symbol of a project's ERC-20 token. The project must already have a token deployed
|
|
318
|
+
/// or attached.
|
|
312
319
|
/// @dev Only a project's controller can set the token's name and symbol.
|
|
313
320
|
/// @param projectId The ID of the project whose token is being updated.
|
|
314
321
|
/// @param name The new name.
|
|
@@ -340,7 +347,8 @@ contract JBTokens is JBControlled, IJBTokens {
|
|
|
340
347
|
token.setMetadata({name: name, symbol: symbol});
|
|
341
348
|
}
|
|
342
349
|
|
|
343
|
-
/// @notice
|
|
350
|
+
/// @notice Move internal credits from one account to another. Credits are non-transferable on their own (they're
|
|
351
|
+
/// just a balance in this contract), so this function enables transfers via the controller.
|
|
344
352
|
/// @dev Only a project's controller can transfer credits for that project.
|
|
345
353
|
/// @param holder The address to transfer credits from.
|
|
346
354
|
/// @param projectId The ID of the project whose credits are being transferred.
|
|
@@ -379,7 +387,8 @@ contract JBTokens is JBControlled, IJBTokens {
|
|
|
379
387
|
// ------------------------- external views -------------------------- //
|
|
380
388
|
//*********************************************************************//
|
|
381
389
|
|
|
382
|
-
/// @notice
|
|
390
|
+
/// @notice Get a holder's complete balance for a project — both their internal credits and their ERC-20 token
|
|
391
|
+
/// balance combined.
|
|
383
392
|
/// @param holder The holder to get a balance for.
|
|
384
393
|
/// @param projectId The project to get the `holder`'s balance for.
|
|
385
394
|
/// @return balance The combined token and token credit balance of the `holder`.
|
|
@@ -400,11 +409,12 @@ contract JBTokens is JBControlled, IJBTokens {
|
|
|
400
409
|
// --------------------------- public views -------------------------- //
|
|
401
410
|
//*********************************************************************//
|
|
402
411
|
|
|
403
|
-
/// @notice
|
|
404
|
-
///
|
|
412
|
+
/// @notice Get the total token supply for a project — internal credits plus the ERC-20's `totalSupply()`. This is
|
|
413
|
+
/// the denominator used in cash-out bonding curve calculations.
|
|
414
|
+
/// @dev WARNING: Projects using `setTokenFor` with an external ERC-20 inherit that token's supply manipulation
|
|
405
415
|
/// surface. If the external token has a separate minting authority, `totalSupply()` can be inflated outside of
|
|
406
|
-
/// this contract,
|
|
407
|
-
///
|
|
416
|
+
/// this contract, diluting cash-out values for all holders. Projects using `deployERC20For` are safe because the
|
|
417
|
+
/// resulting `JBERC20` is exclusively owned by this `JBTokens` contract.
|
|
408
418
|
/// @param projectId The ID of the project to get the total supply of.
|
|
409
419
|
/// @return totalSupply The total supply of the project's tokens and token credits.
|
|
410
420
|
function totalSupplyOf(uint256 projectId) public view override returns (uint256 totalSupply) {
|
|
@@ -4,7 +4,9 @@ pragma solidity 0.8.28;
|
|
|
4
4
|
import {IJBControlled} from "./../interfaces/IJBControlled.sol";
|
|
5
5
|
import {IJBDirectory} from "./../interfaces/IJBDirectory.sol";
|
|
6
6
|
|
|
7
|
-
/// @notice
|
|
7
|
+
/// @notice Base contract that restricts certain functions to the project's current controller (as registered in
|
|
8
|
+
/// `JBDirectory`). Used by `JBTokens`, `JBSplits`, `JBFundAccessLimits`, `JBRulesets`, and `JBPrices` to ensure only
|
|
9
|
+
/// the controller can update project state.
|
|
8
10
|
abstract contract JBControlled is IJBControlled {
|
|
9
11
|
//*********************************************************************//
|
|
10
12
|
// --------------------------- custom errors -------------------------- //
|
|
@@ -6,7 +6,9 @@ import {Context} from "@openzeppelin/contracts/utils/Context.sol";
|
|
|
6
6
|
import {IJBPermissioned} from "./../interfaces/IJBPermissioned.sol";
|
|
7
7
|
import {IJBPermissions} from "./../interfaces/IJBPermissions.sol";
|
|
8
8
|
|
|
9
|
-
/// @notice
|
|
9
|
+
/// @notice Base contract that provides permission-checking helpers. Contracts that inherit this can require that the
|
|
10
|
+
/// caller either *is* the account or has been granted a specific permission by that account (via `JBPermissions`).
|
|
11
|
+
/// @dev Used by `JBController`, `JBMultiTerminal`, `JBDirectory`, and others to enforce operator authorization.
|
|
10
12
|
abstract contract JBPermissioned is Context, IJBPermissioned {
|
|
11
13
|
//*********************************************************************//
|
|
12
14
|
// --------------------------- custom errors -------------------------- //
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
/// @notice
|
|
4
|
+
/// @notice The lifecycle states a queued ruleset can be in relative to its approval hook.
|
|
5
|
+
/// @dev `Empty` — no ruleset exists. `Upcoming` — queued but not yet eligible for approval check. `Active` —
|
|
6
|
+
/// currently
|
|
7
|
+
/// governing the project. `ApprovalExpected` — the deadline hasn't passed yet, expected to be approved.
|
|
8
|
+
/// `Approved` — passed the approval hook and will take effect. `Failed` — rejected by the approval hook; the
|
|
9
|
+
/// previous
|
|
10
|
+
/// ruleset continues.
|
|
5
11
|
enum JBApprovalStatus {
|
|
6
12
|
Empty,
|
|
7
13
|
Upcoming,
|
|
@@ -23,8 +23,9 @@ import {JBSplit} from "./../structs/JBSplit.sol";
|
|
|
23
23
|
import {JBSplitGroup} from "./../structs/JBSplitGroup.sol";
|
|
24
24
|
import {JBTerminalConfig} from "./../structs/JBTerminalConfig.sol";
|
|
25
25
|
|
|
26
|
-
/// @notice
|
|
27
|
-
/// project
|
|
26
|
+
/// @notice The interface for the protocol's project controller — launch projects, queue rulesets, mint/burn tokens,
|
|
27
|
+
/// deploy ERC-20s, distribute reserved tokens, and manage all project configuration. This is the primary contract
|
|
28
|
+
/// project owners and frontends interact with.
|
|
28
29
|
interface IJBController is IERC165, IJBProjectUriRegistry, IJBDirectoryAccessControl {
|
|
29
30
|
/// @notice Tokens were burned from a holder's balance.
|
|
30
31
|
/// @param holder The address whose tokens were burned.
|
|
@@ -57,9 +58,10 @@ interface IJBController is IERC165, IJBProjectUriRegistry, IJBDirectoryAccessCon
|
|
|
57
58
|
/// @notice Rulesets were launched for an existing project.
|
|
58
59
|
/// @param rulesetId The ID of the first queued ruleset.
|
|
59
60
|
/// @param projectId The ID of the project.
|
|
61
|
+
/// @param projectUri The metadata URI of the project.
|
|
60
62
|
/// @param memo A memo associated with the launch.
|
|
61
63
|
/// @param caller The address that called the launch function.
|
|
62
|
-
event LaunchRulesets(uint256 rulesetId, uint256 projectId, string memo, address caller);
|
|
64
|
+
event LaunchRulesets(uint256 rulesetId, uint256 projectId, string projectUri, string memo, address caller);
|
|
63
65
|
|
|
64
66
|
/// @notice Tokens were minted for a beneficiary.
|
|
65
67
|
/// @param beneficiary The address that received the minted tokens.
|
|
@@ -313,12 +315,14 @@ interface IJBController is IERC165, IJBProjectUriRegistry, IJBDirectoryAccessCon
|
|
|
313
315
|
|
|
314
316
|
/// @notice Queues a project's initial rulesets and sets up terminals for it.
|
|
315
317
|
/// @param projectId The ID of the project to launch rulesets for.
|
|
318
|
+
/// @param projectUri The project's metadata URI. Pass an empty string to leave it unchanged.
|
|
316
319
|
/// @param rulesetConfigurations The rulesets to queue.
|
|
317
320
|
/// @param terminalConfigurations The terminals to set up.
|
|
318
321
|
/// @param memo A memo to pass along to the emitted event.
|
|
319
322
|
/// @return rulesetId The ID of the last successfully queued ruleset.
|
|
320
323
|
function launchRulesetsFor(
|
|
321
324
|
uint256 projectId,
|
|
325
|
+
string calldata projectUri,
|
|
322
326
|
JBRulesetConfig[] calldata rulesetConfigurations,
|
|
323
327
|
JBTerminalConfig[] calldata terminalConfigurations,
|
|
324
328
|
string calldata memo
|
|
@@ -6,7 +6,9 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
|
6
6
|
import {IJBProjects} from "./IJBProjects.sol";
|
|
7
7
|
import {IJBTerminal} from "./IJBTerminal.sol";
|
|
8
8
|
|
|
9
|
-
/// @notice
|
|
9
|
+
/// @notice Interface for the protocol's routing table. Tracks which terminals accept payments for each project and
|
|
10
|
+
/// which controller manages each project's rulesets and tokens. Used by frontends and contracts to discover where to
|
|
11
|
+
/// send funds.
|
|
10
12
|
interface IJBDirectory {
|
|
11
13
|
/// @notice A terminal was added to a project.
|
|
12
14
|
/// @param projectId The ID of the project the terminal was added to.
|
|
@@ -12,8 +12,9 @@ import {IJBTerminal} from "./IJBTerminal.sol";
|
|
|
12
12
|
import {IJBTerminalStore} from "./IJBTerminalStore.sol";
|
|
13
13
|
import {IJBTokens} from "./IJBTokens.sol";
|
|
14
14
|
|
|
15
|
-
/// @notice
|
|
16
|
-
///
|
|
15
|
+
/// @notice The interface for the protocol's multi-token payment terminal. Accepts ETH and ERC-20 payments, processes
|
|
16
|
+
/// cash outs (token redemptions), distributes payouts to splits, manages surplus allowance withdrawals, and handles
|
|
17
|
+
/// the 2.5% protocol fee lifecycle. The primary entry point for all fund movement in Juicebox.
|
|
17
18
|
interface IJBMultiTerminal is IJBTerminal, IJBFeeTerminal, IJBCashOutTerminal, IJBPayoutTerminal, IJBPermitTerminal {
|
|
18
19
|
/// @notice The directory of terminals and controllers for projects.
|
|
19
20
|
function DIRECTORY() external view returns (IJBDirectory);
|
|
@@ -3,7 +3,8 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {JBPermissionsData} from "./../structs/JBPermissionsData.sol";
|
|
5
5
|
|
|
6
|
-
/// @notice
|
|
6
|
+
/// @notice Interface for the protocol's permission system. Allows any address to authorize operators to perform
|
|
7
|
+
/// specific actions on its behalf, scoped to individual projects or globally (wildcard project ID 0).
|
|
7
8
|
interface IJBPermissions {
|
|
8
9
|
/// @notice Permissions were set for an operator on behalf of an account.
|
|
9
10
|
/// @param operator The operator whose permissions were set.
|
|
@@ -4,7 +4,9 @@ pragma solidity ^0.8.0;
|
|
|
4
4
|
import {IJBPriceFeed} from "./IJBPriceFeed.sol";
|
|
5
5
|
import {IJBProjects} from "./IJBProjects.sol";
|
|
6
6
|
|
|
7
|
-
/// @notice
|
|
7
|
+
/// @notice Interface for the price feed registry. Resolves exchange rates between currencies via immutable price feeds
|
|
8
|
+
/// (typically Chainlink). Used when payout limits or surplus allowances are denominated in a different currency than
|
|
9
|
+
/// the token held in the terminal.
|
|
8
10
|
interface IJBPrices {
|
|
9
11
|
/// @notice A price feed was added for a project's currency pair.
|
|
10
12
|
/// @param projectId The ID of the project the price feed was added for.
|
|
@@ -5,7 +5,8 @@ import {IJBRulesetApprovalHook} from "./IJBRulesetApprovalHook.sol";
|
|
|
5
5
|
import {JBApprovalStatus} from "./../enums/JBApprovalStatus.sol";
|
|
6
6
|
import {JBRuleset} from "./../structs/JBRuleset.sol";
|
|
7
7
|
|
|
8
|
-
/// @notice
|
|
8
|
+
/// @notice Interface for the ruleset storage and lifecycle contract. Rulesets define a project's economic parameters
|
|
9
|
+
/// (weight, duration, cash-out rate, etc.) and are queued as a linked list with approval hooks gating transitions.
|
|
9
10
|
interface IJBRulesets {
|
|
10
11
|
/// @notice A ruleset was initialized from a base ruleset.
|
|
11
12
|
/// @param rulesetId The ID of the initialized ruleset.
|
|
@@ -4,7 +4,8 @@ pragma solidity ^0.8.0;
|
|
|
4
4
|
import {JBSplit} from "./../structs/JBSplit.sol";
|
|
5
5
|
import {JBSplitGroup} from "./../structs/JBSplitGroup.sol";
|
|
6
6
|
|
|
7
|
-
/// @notice
|
|
7
|
+
/// @notice Interface for the split storage contract. Splits define how payouts and reserved tokens are distributed —
|
|
8
|
+
/// each split specifies a recipient and their percentage share. Splits can be locked until a timestamp.
|
|
8
9
|
interface IJBSplits {
|
|
9
10
|
/// @notice A split was set for a project.
|
|
10
11
|
/// @param projectId The ID of the project the split was set for.
|
|
@@ -9,7 +9,9 @@ import {JBAfterPayRecordedContext} from "../structs/JBAfterPayRecordedContext.so
|
|
|
9
9
|
import {JBPayHookSpecification} from "../structs/JBPayHookSpecification.sol";
|
|
10
10
|
import {JBRuleset} from "../structs/JBRuleset.sol";
|
|
11
11
|
|
|
12
|
-
/// @notice A terminal
|
|
12
|
+
/// @notice Base interface for all Juicebox terminals. A terminal accepts payments for projects, reports surplus, and
|
|
13
|
+
/// supports balance migration. Projects register their terminals in `JBDirectory`; the primary terminal for a token
|
|
14
|
+
/// receives payments routed by frontends.
|
|
13
15
|
interface IJBTerminal is IERC165 {
|
|
14
16
|
/// @notice Funds were added to a project's balance.
|
|
15
17
|
/// @param projectId The ID of the project that received the funds.
|
|
@@ -11,7 +11,9 @@ import {JBPayHookSpecification} from "../structs/JBPayHookSpecification.sol";
|
|
|
11
11
|
import {JBRuleset} from "../structs/JBRuleset.sol";
|
|
12
12
|
import {JBTokenAmount} from "../structs/JBTokenAmount.sol";
|
|
13
13
|
|
|
14
|
-
/// @notice
|
|
14
|
+
/// @notice Interface for the terminal's accounting engine. Records balances, enforces payout limits and surplus
|
|
15
|
+
/// allowances, calculates token issuance per payment, and determines cash-out reclaim amounts via the bonding curve.
|
|
16
|
+
/// Terminals delegate all state-changing accounting to this contract.
|
|
15
17
|
interface IJBTerminalStore {
|
|
16
18
|
/// @notice The directory of terminals and controllers for projects.
|
|
17
19
|
function DIRECTORY() external view returns (IJBDirectory);
|
|
@@ -3,7 +3,8 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {IJBToken} from "./IJBToken.sol";
|
|
5
5
|
|
|
6
|
-
/// @notice Manages
|
|
6
|
+
/// @notice Interface for the dual-token system. Manages credits (internal balances) and ERC-20 tokens for every
|
|
7
|
+
/// project. Credits are minted first and can later be claimed as transferable ERC-20 tokens.
|
|
7
8
|
interface IJBTokens {
|
|
8
9
|
/// @notice Tokens or credits were burned from a holder's balance.
|
|
9
10
|
/// @param holder The address whose tokens were burned.
|
|
@@ -5,7 +5,12 @@ import {mulDiv} from "@prb/math/src/Common.sol";
|
|
|
5
5
|
|
|
6
6
|
import {JBConstants} from "./JBConstants.sol";
|
|
7
7
|
|
|
8
|
-
/// @notice
|
|
8
|
+
/// @notice Implements the bonding curve math for cash outs. When a token holder cashes out, this library calculates
|
|
9
|
+
/// how much of the project's surplus they can reclaim based on their share of the total supply and the current
|
|
10
|
+
/// cash-out tax rate. A 0% tax rate gives a proportional share; a 100% tax rate returns nothing (all surplus stays).
|
|
11
|
+
/// @dev Formula: `surplus * count * [(MAX - taxRate) + taxRate * (count / supply)] / (supply * MAX)`.
|
|
12
|
+
/// Also provides an inverse function (`cashOutCountFrom`) for determining how many tokens to burn for a desired
|
|
13
|
+
/// reclaim amount.
|
|
9
14
|
library JBCashOuts {
|
|
10
15
|
/// @notice Thrown when the desired output cannot be achieved (e.g., cash out tax rate is 100%).
|
|
11
16
|
error JBCashOuts_DesiredOutputNotAchievable();
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.28;
|
|
3
3
|
|
|
4
|
-
/// @notice
|
|
4
|
+
/// @notice Protocol-wide constants. These define the boundaries for economic parameters throughout Juicebox.
|
|
5
5
|
library JBConstants {
|
|
6
|
-
/// @notice
|
|
7
|
-
/// 0x000000000000000000000000000000000000EEEe.
|
|
6
|
+
/// @notice The sentinel address used to represent each chain's native token (ETH on mainnet, etc.).
|
|
8
7
|
address public constant NATIVE_TOKEN = address(0x000000000000000000000000000000000000EEEe);
|
|
8
|
+
|
|
9
|
+
/// @notice The maximum reserved token percentage (basis points). 10,000 = 100% of minted tokens go to reserves.
|
|
9
10
|
uint16 public constant MAX_RESERVED_PERCENT = 10_000;
|
|
11
|
+
|
|
12
|
+
/// @notice The maximum cash-out tax rate (basis points). 10,000 = 100% tax, meaning token holders reclaim nothing.
|
|
10
13
|
uint16 public constant MAX_CASH_OUT_TAX_RATE = 10_000;
|
|
14
|
+
|
|
15
|
+
/// @notice The maximum weight cut percent (9-decimal precision). 1,000,000,000 = 100% cut per cycle (no issuance).
|
|
11
16
|
uint32 public constant MAX_WEIGHT_CUT_PERCENT = 1_000_000_000;
|
|
17
|
+
|
|
18
|
+
/// @notice The denominator for split percentages (9-decimal precision). A split of 1,000,000,000 = 100%.
|
|
12
19
|
uint32 public constant SPLITS_TOTAL_PERCENT = 1_000_000_000;
|
|
20
|
+
|
|
21
|
+
/// @notice The fee denominator. The protocol fee is `FEE / MAX_FEE` (currently 25/1000 = 2.5%).
|
|
13
22
|
uint16 public constant MAX_FEE = 1000;
|
|
14
23
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.28;
|
|
3
3
|
|
|
4
|
+
/// @notice Well-known currency IDs used as the `baseCurrency` in ruleset metadata. These are distinct from accounting
|
|
5
|
+
/// context currencies (which use `uint32(uint160(tokenAddress))`). Only used for price feed lookups in `JBPrices`.
|
|
4
6
|
library JBCurrencyIds {
|
|
5
7
|
uint32 public constant ETH = 1;
|
|
6
8
|
uint32 public constant USD = 2;
|
package/src/libraries/JBFees.sol
CHANGED
|
@@ -5,26 +5,68 @@ import {mulDiv} from "@prb/math/src/Common.sol";
|
|
|
5
5
|
|
|
6
6
|
import {JBConstants} from "./../libraries/JBConstants.sol";
|
|
7
7
|
|
|
8
|
-
/// @notice
|
|
8
|
+
/// @notice Utility functions for calculating the protocol fee (2.5%) in both directions: forward (fee from a pre-fee
|
|
9
|
+
/// amount) and backward (the pre-fee amount that would yield a given post-fee amount). Used by `JBMultiTerminal`
|
|
10
|
+
/// during payouts, surplus allowance usage, and cash outs.
|
|
11
|
+
/// @dev Fee dust protection: if a nonzero amount with a nonzero fee would otherwise round to 0, returns 1 wei to
|
|
12
|
+
/// prevent fee bypass via many tiny transfers.
|
|
9
13
|
library JBFees {
|
|
14
|
+
/// @notice Returns the fee that would be taken from `amountBeforeFee`.
|
|
15
|
+
/// @dev Use this to forward-calculate the fee from a known pre-fee amount.
|
|
16
|
+
/// @dev If a nonzero amount and nonzero fee would otherwise produce a zero fee, returns 1 so feeable dust payouts
|
|
17
|
+
/// cannot bypass protocol fees by splitting across tiny transfers.
|
|
18
|
+
/// @param amountBeforeFee The amount before the fee is applied, as a fixed point number.
|
|
19
|
+
/// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
|
|
20
|
+
/// @return The fee amount, as a fixed point number with the same number of decimals as the provided `amount`.
|
|
21
|
+
function feeAmountFrom(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {
|
|
22
|
+
uint256 feeAmount = feeAmountFromFloor({amountBeforeFee: amountBeforeFee, feePercent: feePercent});
|
|
23
|
+
|
|
24
|
+
return feeAmount == 0 && amountBeforeFee != 0 && feePercent != 0 ? 1 : feeAmount;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// @notice Returns the floor-rounded fee that would be taken from `amountBeforeFee`.
|
|
28
|
+
/// @dev Fee rounding error is bounded by N-1 wei (N = number of splits). Economically insignificant. Rounds down
|
|
29
|
+
/// (mulDiv floors), so the fee beneficiary may receive up to 1 wei less per split.
|
|
30
|
+
/// @param amountBeforeFee The amount before the fee is applied, as a fixed point number.
|
|
31
|
+
/// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
|
|
32
|
+
/// @return The floor-rounded fee amount, as a fixed point number with the same number of decimals as the provided
|
|
33
|
+
/// `amount`.
|
|
34
|
+
function feeAmountFromFloor(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {
|
|
35
|
+
return mulDiv(amountBeforeFee, feePercent, JBConstants.MAX_FEE);
|
|
36
|
+
}
|
|
37
|
+
|
|
10
38
|
/// @notice Returns the fee amount that, when added to `amountAfterFee`, produces the gross amount needed to yield
|
|
11
39
|
/// `amountAfterFee` after the fee is deducted.
|
|
12
40
|
/// @dev Use this to back-calculate the fee from a desired post-fee payout.
|
|
41
|
+
/// @dev If a nonzero amount and nonzero fee would otherwise produce a zero fee, returns 1 so feeable dust payouts
|
|
42
|
+
/// cannot bypass protocol fees by splitting across tiny transfers.
|
|
13
43
|
/// @param amountAfterFee The desired post-fee amount, as a fixed point number.
|
|
14
44
|
/// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
|
|
15
45
|
/// @return The fee amount, as a fixed point number with the same number of decimals as the provided `amount`.
|
|
16
46
|
function feeAmountResultingIn(uint256 amountAfterFee, uint256 feePercent) internal pure returns (uint256) {
|
|
17
|
-
|
|
47
|
+
uint256 feeAmount = feeAmountResultingInFloor({amountAfterFee: amountAfterFee, feePercent: feePercent});
|
|
48
|
+
|
|
49
|
+
return feeAmount == 0 && amountAfterFee != 0 && feePercent != 0 ? 1 : feeAmount;
|
|
18
50
|
}
|
|
19
51
|
|
|
20
|
-
/// @notice Returns the fee that
|
|
21
|
-
///
|
|
22
|
-
/// @dev
|
|
23
|
-
///
|
|
24
|
-
/// @param
|
|
52
|
+
/// @notice Returns the floor-rounded fee amount that, when added to `amountAfterFee`, produces the gross amount
|
|
53
|
+
/// needed to yield `amountAfterFee` after the fee is deducted.
|
|
54
|
+
/// @dev Use this when adjusting an existing held-fee entry, where applying the 1-unit minimum again would double
|
|
55
|
+
/// charge dust.
|
|
56
|
+
/// @param amountAfterFee The desired post-fee amount, as a fixed point number.
|
|
25
57
|
/// @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
|
|
27
|
-
|
|
28
|
-
|
|
58
|
+
/// @return The floor-rounded fee amount, as a fixed point number with the same number of decimals as the provided
|
|
59
|
+
/// `amount`.
|
|
60
|
+
function feeAmountResultingInFloor(uint256 amountAfterFee, uint256 feePercent) internal pure returns (uint256) {
|
|
61
|
+
return mulDiv(amountAfterFee, JBConstants.MAX_FEE, JBConstants.MAX_FEE - feePercent) - amountAfterFee;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// @notice Returns the floor-rounded fee amount resulting in `amountAfterFee` for a 2.5% fee.
|
|
65
|
+
/// @dev Equivalent to `feeAmountResultingInFloor(amountAfterFee, 25)`, but avoids the generic `mulDiv` path.
|
|
66
|
+
/// @param amountAfterFee The desired post-fee amount, as a fixed point number.
|
|
67
|
+
/// @return The floor-rounded fee amount.
|
|
68
|
+
function feeAmountResultingInFloorForFee25(uint256 amountAfterFee) internal pure returns (uint256) {
|
|
69
|
+
// The specialized denominator is `(JBConstants.MAX_FEE - 25) / 25`.
|
|
70
|
+
return amountAfterFee / 39;
|
|
29
71
|
}
|
|
30
72
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.28;
|
|
3
3
|
|
|
4
|
+
/// @notice Utility for converting between fixed-point numbers with different decimal precisions (e.g. 6-decimal USDC
|
|
5
|
+
/// amounts to 18-decimal internal accounting).
|
|
4
6
|
library JBFixedPointNumber {
|
|
5
7
|
function adjustDecimals(uint256 value, uint256 decimals, uint256 targetDecimals) internal pure returns (uint256) {
|
|
6
8
|
// If decimals need adjusting, multiply or divide the price by the decimal adjuster to get the normalized
|