@bananapus/core-v6 0.0.1
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/LICENSE +21 -0
- package/README.md +112 -0
- package/SKILLS.md +151 -0
- package/docs/book.css +13 -0
- package/docs/book.toml +12 -0
- package/docs/solidity.min.js +74 -0
- package/docs/src/README.md +703 -0
- package/docs/src/SUMMARY.md +94 -0
- package/docs/src/src/JBChainlinkV3PriceFeed.sol/contract.JBChainlinkV3PriceFeed.md +83 -0
- package/docs/src/src/JBChainlinkV3SequencerPriceFeed.sol/contract.JBChainlinkV3SequencerPriceFeed.md +88 -0
- package/docs/src/src/JBController.sol/contract.JBController.md +1121 -0
- package/docs/src/src/JBDeadline.sol/contract.JBDeadline.md +84 -0
- package/docs/src/src/JBDirectory.sol/contract.JBDirectory.md +294 -0
- package/docs/src/src/JBERC20.sol/contract.JBERC20.md +190 -0
- package/docs/src/src/JBFeelessAddresses.sol/contract.JBFeelessAddresses.md +80 -0
- package/docs/src/src/JBFundAccessLimits.sol/contract.JBFundAccessLimits.md +253 -0
- package/docs/src/src/JBMultiTerminal.sol/contract.JBMultiTerminal.md +1472 -0
- package/docs/src/src/JBPermissions.sol/contract.JBPermissions.md +199 -0
- package/docs/src/src/JBPrices.sol/contract.JBPrices.md +154 -0
- package/docs/src/src/JBProjects.sol/contract.JBProjects.md +131 -0
- package/docs/src/src/JBRulesets.sol/contract.JBRulesets.md +677 -0
- package/docs/src/src/JBSplits.sol/contract.JBSplits.md +237 -0
- package/docs/src/src/JBTerminalStore.sol/contract.JBTerminalStore.md +591 -0
- package/docs/src/src/JBTokens.sol/contract.JBTokens.md +353 -0
- package/docs/src/src/README.md +25 -0
- package/docs/src/src/abstract/JBControlled.sol/abstract.JBControlled.md +64 -0
- package/docs/src/src/abstract/JBPermissioned.sol/abstract.JBPermissioned.md +84 -0
- package/docs/src/src/abstract/README.md +5 -0
- package/docs/src/src/enums/JBApprovalStatus.sol/enum.JBApprovalStatus.md +17 -0
- package/docs/src/src/enums/README.md +4 -0
- package/docs/src/src/interfaces/IJBCashOutHook.sol/interface.IJBCashOutHook.md +29 -0
- package/docs/src/src/interfaces/IJBCashOutTerminal.sol/interface.IJBCashOutTerminal.md +57 -0
- package/docs/src/src/interfaces/IJBControlled.sol/interface.IJBControlled.md +12 -0
- package/docs/src/src/interfaces/IJBController.sol/interface.IJBController.md +334 -0
- package/docs/src/src/interfaces/IJBDirectory.sol/interface.IJBDirectory.md +108 -0
- package/docs/src/src/interfaces/IJBDirectoryAccessControl.sol/interface.IJBDirectoryAccessControl.md +19 -0
- package/docs/src/src/interfaces/IJBFeeTerminal.sol/interface.IJBFeeTerminal.md +91 -0
- package/docs/src/src/interfaces/IJBFeelessAddresses.sol/interface.IJBFeelessAddresses.md +26 -0
- package/docs/src/src/interfaces/IJBFundAccessLimits.sol/interface.IJBFundAccessLimits.md +88 -0
- package/docs/src/src/interfaces/IJBMigratable.sol/interface.IJBMigratable.md +29 -0
- package/docs/src/src/interfaces/IJBMultiTerminal.sol/interface.IJBMultiTerminal.md +50 -0
- package/docs/src/src/interfaces/IJBPayHook.sol/interface.IJBPayHook.md +28 -0
- package/docs/src/src/interfaces/IJBPayoutTerminal.sol/interface.IJBPayoutTerminal.md +105 -0
- package/docs/src/src/interfaces/IJBPermissioned.sol/interface.IJBPermissioned.md +12 -0
- package/docs/src/src/interfaces/IJBPermissions.sol/interface.IJBPermissions.md +74 -0
- package/docs/src/src/interfaces/IJBPermitTerminal.sol/interface.IJBPermitTerminal.md +15 -0
- package/docs/src/src/interfaces/IJBPriceFeed.sol/interface.IJBPriceFeed.md +12 -0
- package/docs/src/src/interfaces/IJBPrices.sol/interface.IJBPrices.md +74 -0
- package/docs/src/src/interfaces/IJBProjectUriRegistry.sol/interface.IJBProjectUriRegistry.md +19 -0
- package/docs/src/src/interfaces/IJBProjects.sol/interface.IJBProjects.md +49 -0
- package/docs/src/src/interfaces/IJBRulesetApprovalHook.sol/interface.IJBRulesetApprovalHook.md +35 -0
- package/docs/src/src/interfaces/IJBRulesetDataHook.sol/interface.IJBRulesetDataHook.md +97 -0
- package/docs/src/src/interfaces/IJBRulesets.sol/interface.IJBRulesets.md +165 -0
- package/docs/src/src/interfaces/IJBSplitHook.sol/interface.IJBSplitHook.md +31 -0
- package/docs/src/src/interfaces/IJBSplits.sol/interface.IJBSplits.md +35 -0
- package/docs/src/src/interfaces/IJBTerminal.sol/interface.IJBTerminal.md +141 -0
- package/docs/src/src/interfaces/IJBTerminalStore.sol/interface.IJBTerminalStore.md +198 -0
- package/docs/src/src/interfaces/IJBToken.sol/interface.IJBToken.md +54 -0
- package/docs/src/src/interfaces/IJBTokenUriResolver.sol/interface.IJBTokenUriResolver.md +12 -0
- package/docs/src/src/interfaces/IJBTokens.sol/interface.IJBTokens.md +151 -0
- package/docs/src/src/interfaces/README.md +33 -0
- package/docs/src/src/libraries/JBCashOuts.sol/library.JBCashOuts.md +40 -0
- package/docs/src/src/libraries/JBConstants.sol/library.JBConstants.md +52 -0
- package/docs/src/src/libraries/JBCurrencyIds.sol/library.JBCurrencyIds.md +19 -0
- package/docs/src/src/libraries/JBFees.sol/library.JBFees.md +52 -0
- package/docs/src/src/libraries/JBFixedPointNumber.sol/library.JBFixedPointNumber.md +12 -0
- package/docs/src/src/libraries/JBMetadataResolver.sol/library.JBMetadataResolver.md +242 -0
- package/docs/src/src/libraries/JBRulesetMetadataResolver.sol/library.JBRulesetMetadataResolver.md +180 -0
- package/docs/src/src/libraries/JBSplitGroupIds.sol/library.JBSplitGroupIds.md +14 -0
- package/docs/src/src/libraries/JBSurplus.sol/library.JBSurplus.md +44 -0
- package/docs/src/src/libraries/README.md +12 -0
- package/docs/src/src/periphery/JBDeadline1Day.sol/contract.JBDeadline1Day.md +15 -0
- package/docs/src/src/periphery/JBDeadline3Days.sol/contract.JBDeadline3Days.md +15 -0
- package/docs/src/src/periphery/JBDeadline3Hours.sol/contract.JBDeadline3Hours.md +15 -0
- package/docs/src/src/periphery/JBDeadline7Days.sol/contract.JBDeadline7Days.md +15 -0
- package/docs/src/src/periphery/JBMatchingPriceFeed.sol/contract.JBMatchingPriceFeed.md +22 -0
- package/docs/src/src/periphery/README.md +8 -0
- package/docs/src/src/structs/JBAccountingContext.sol/struct.JBAccountingContext.md +20 -0
- package/docs/src/src/structs/JBAfterCashOutRecordedContext.sol/struct.JBAfterCashOutRecordedContext.md +43 -0
- package/docs/src/src/structs/JBAfterPayRecordedContext.sol/struct.JBAfterPayRecordedContext.md +42 -0
- package/docs/src/src/structs/JBBeforeCashOutRecordedContext.sol/struct.JBBeforeCashOutRecordedContext.md +45 -0
- package/docs/src/src/structs/JBBeforePayRecordedContext.sol/struct.JBBeforePayRecordedContext.md +41 -0
- package/docs/src/src/structs/JBCashOutHookSpecification.sol/struct.JBCashOutHookSpecification.md +22 -0
- package/docs/src/src/structs/JBCurrencyAmount.sol/struct.JBCurrencyAmount.md +17 -0
- package/docs/src/src/structs/JBFee.sol/struct.JBFee.md +20 -0
- package/docs/src/src/structs/JBFundAccessLimitGroup.sol/struct.JBFundAccessLimitGroup.md +39 -0
- package/docs/src/src/structs/JBPayHookSpecification.sol/struct.JBPayHookSpecification.md +22 -0
- package/docs/src/src/structs/JBPermissionsData.sol/struct.JBPermissionsData.md +21 -0
- package/docs/src/src/structs/JBRuleset.sol/struct.JBRuleset.md +55 -0
- package/docs/src/src/structs/JBRulesetConfig.sol/struct.JBRulesetConfig.md +51 -0
- package/docs/src/src/structs/JBRulesetMetadata.sol/struct.JBRulesetMetadata.md +79 -0
- package/docs/src/src/structs/JBRulesetWeightCache.sol/struct.JBRulesetWeightCache.md +16 -0
- package/docs/src/src/structs/JBRulesetWithMetadata.sol/struct.JBRulesetWithMetadata.md +16 -0
- package/docs/src/src/structs/JBSingleAllowance.sol/struct.JBSingleAllowance.md +26 -0
- package/docs/src/src/structs/JBSplit.sol/struct.JBSplit.md +49 -0
- package/docs/src/src/structs/JBSplitGroup.sol/struct.JBSplitGroup.md +17 -0
- package/docs/src/src/structs/JBSplitHookContext.sol/struct.JBSplitHookContext.md +29 -0
- package/docs/src/src/structs/JBTerminalConfig.sol/struct.JBTerminalConfig.md +16 -0
- package/docs/src/src/structs/JBTokenAmount.sol/struct.JBTokenAmount.md +23 -0
- package/docs/src/src/structs/README.md +25 -0
- package/foundry.lock +11 -0
- package/foundry.toml +41 -0
- package/package.json +38 -0
- package/remappings.txt +1 -0
- package/script/Deploy.s.sol +111 -0
- package/script/DeployPeriphery.s.sol +287 -0
- package/script/helpers/CoreDeploymentLib.sol +121 -0
- package/slither-ci.config.json +10 -0
- package/sphinx.lock +507 -0
- package/src/JBChainlinkV3PriceFeed.sol +77 -0
- package/src/JBChainlinkV3SequencerPriceFeed.sol +75 -0
- package/src/JBController.sol +1186 -0
- package/src/JBDeadline.sol +73 -0
- package/src/JBDirectory.sol +343 -0
- package/src/JBERC20.sol +131 -0
- package/src/JBFeelessAddresses.sol +54 -0
- package/src/JBFundAccessLimits.sol +308 -0
- package/src/JBMultiTerminal.sol +2024 -0
- package/src/JBPermissions.sol +252 -0
- package/src/JBPrices.sol +227 -0
- package/src/JBProjects.sol +126 -0
- package/src/JBRulesets.sol +1093 -0
- package/src/JBSplits.sol +324 -0
- package/src/JBTerminalStore.sol +908 -0
- package/src/JBTokens.sol +376 -0
- package/src/abstract/JBControlled.sol +48 -0
- package/src/abstract/JBPermissioned.sol +77 -0
- package/src/enums/JBApprovalStatus.sol +12 -0
- package/src/interfaces/IJBCashOutHook.sol +15 -0
- package/src/interfaces/IJBCashOutTerminal.sol +51 -0
- package/src/interfaces/IJBControlled.sol +10 -0
- package/src/interfaces/IJBController.sol +280 -0
- package/src/interfaces/IJBDirectory.sol +69 -0
- package/src/interfaces/IJBDirectoryAccessControl.sol +15 -0
- package/src/interfaces/IJBFeeTerminal.sol +61 -0
- package/src/interfaces/IJBFeelessAddresses.sol +17 -0
- package/src/interfaces/IJBFundAccessLimits.sol +94 -0
- package/src/interfaces/IJBMigratable.sol +24 -0
- package/src/interfaces/IJBMultiTerminal.sol +36 -0
- package/src/interfaces/IJBPayHook.sol +14 -0
- package/src/interfaces/IJBPayoutTerminal.sol +92 -0
- package/src/interfaces/IJBPermissioned.sol +10 -0
- package/src/interfaces/IJBPermissions.sol +71 -0
- package/src/interfaces/IJBPermitTerminal.sol +14 -0
- package/src/interfaces/IJBPriceFeed.sol +10 -0
- package/src/interfaces/IJBPrices.sol +65 -0
- package/src/interfaces/IJBProjectUriRegistry.sol +15 -0
- package/src/interfaces/IJBProjects.sol +27 -0
- package/src/interfaces/IJBRulesetApprovalHook.sol +21 -0
- package/src/interfaces/IJBRulesetDataHook.sol +56 -0
- package/src/interfaces/IJBRulesets.sol +151 -0
- package/src/interfaces/IJBSplitHook.sol +16 -0
- package/src/interfaces/IJBSplits.sol +28 -0
- package/src/interfaces/IJBTerminal.sol +120 -0
- package/src/interfaces/IJBTerminalStore.sol +225 -0
- package/src/interfaces/IJBToken.sol +39 -0
- package/src/interfaces/IJBTokenUriResolver.sol +10 -0
- package/src/interfaces/IJBTokens.sol +113 -0
- package/src/libraries/JBCashOuts.sol +120 -0
- package/src/libraries/JBConstants.sol +14 -0
- package/src/libraries/JBCurrencyIds.sol +7 -0
- package/src/libraries/JBFees.sol +28 -0
- package/src/libraries/JBFixedPointNumber.sol +12 -0
- package/src/libraries/JBMetadataResolver.sol +306 -0
- package/src/libraries/JBRulesetMetadataResolver.sol +160 -0
- package/src/libraries/JBSplitGroupIds.sol +7 -0
- package/src/libraries/JBSurplus.sol +40 -0
- package/src/periphery/JBDeadline1Day.sol +8 -0
- package/src/periphery/JBDeadline3Days.sol +8 -0
- package/src/periphery/JBDeadline3Hours.sol +8 -0
- package/src/periphery/JBDeadline7Days.sol +8 -0
- package/src/periphery/JBMatchingPriceFeed.sol +13 -0
- package/src/structs/JBAccountingContext.sol +12 -0
- package/src/structs/JBAfterCashOutRecordedContext.sol +30 -0
- package/src/structs/JBAfterPayRecordedContext.sol +29 -0
- package/src/structs/JBBeforeCashOutRecordedContext.sol +31 -0
- package/src/structs/JBBeforePayRecordedContext.sol +28 -0
- package/src/structs/JBCashOutHookSpecification.sol +15 -0
- package/src/structs/JBCurrencyAmount.sol +10 -0
- package/src/structs/JBFee.sol +12 -0
- package/src/structs/JBFundAccessLimitGroup.sol +28 -0
- package/src/structs/JBPayHookSpecification.sol +15 -0
- package/src/structs/JBPermissionsData.sol +13 -0
- package/src/structs/JBRuleset.sol +42 -0
- package/src/structs/JBRulesetConfig.sol +43 -0
- package/src/structs/JBRulesetMetadata.sol +56 -0
- package/src/structs/JBRulesetWeightCache.sol +9 -0
- package/src/structs/JBRulesetWithMetadata.sol +12 -0
- package/src/structs/JBSingleAllowance.sol +16 -0
- package/src/structs/JBSplit.sol +37 -0
- package/src/structs/JBSplitGroup.sol +12 -0
- package/src/structs/JBSplitHookContext.sol +20 -0
- package/src/structs/JBTerminalConfig.sol +12 -0
- package/src/structs/JBTokenAmount.sol +14 -0
- package/test/AuditExploits.t.sol +2710 -0
- package/test/ComprehensiveInvariant.t.sol +298 -0
- package/test/EconomicSimulation.t.sol +340 -0
- package/test/EntryPointPermutations.t.sol +671 -0
- package/test/FlashLoanAttacks.t.sol +792 -0
- package/test/PermissionEscalation.t.sol +679 -0
- package/test/RulesetTransitions.t.sol +699 -0
- package/test/SplitLoopTests.t.sol +731 -0
- package/test/TestAccessToFunds.sol +2644 -0
- package/test/TestCashOut.sol +185 -0
- package/test/TestCashOutCountFor.sol +272 -0
- package/test/TestCashOutHooks.sol +317 -0
- package/test/TestCashOutTimingEdge.sol +229 -0
- package/test/TestDurationUnderflow.sol +220 -0
- package/test/TestFeeProcessingFailure.sol +208 -0
- package/test/TestFees.sol +604 -0
- package/test/TestInterfaceSupport.sol +62 -0
- package/test/TestJBERC20Inheritance.sol +91 -0
- package/test/TestLaunchProject.sol +176 -0
- package/test/TestMetaTx.sol +203 -0
- package/test/TestMetadataParserLib.sol +438 -0
- package/test/TestMigrationHeldFees.sol +249 -0
- package/test/TestMintTokensOf.sol +172 -0
- package/test/TestMultiTokenSurplus.sol +206 -0
- package/test/TestMultipleAccessLimits.sol +642 -0
- package/test/TestPayBurnRedeemFlow.sol +180 -0
- package/test/TestPayHooks.sol +190 -0
- package/test/TestPermissions.sol +305 -0
- package/test/TestPermissionsEdge.sol +286 -0
- package/test/TestPermit2Terminal.sol +339 -0
- package/test/TestRulesetQueueing.sol +1001 -0
- package/test/TestRulesetQueuingStress.sol +778 -0
- package/test/TestRulesetWeightCaching.sol +177 -0
- package/test/TestSplits.sol +369 -0
- package/test/TestTerminalMigration.sol +167 -0
- package/test/TestTokenFlow.sol +174 -0
- package/test/WeirdTokenTests.t.sol +764 -0
- package/test/formal/BondingCurveProperties.t.sol +411 -0
- package/test/formal/FeeProperties.t.sol +246 -0
- package/test/helpers/JBTest.sol +129 -0
- package/test/helpers/MetadataResolverHelper.sol +116 -0
- package/test/helpers/TestBaseWorkflow.sol +317 -0
- package/test/invariants/Phase3DeepInvariant.t.sol +404 -0
- package/test/invariants/RulesetsInvariant.t.sol +115 -0
- package/test/invariants/TerminalStoreInvariant.t.sol +220 -0
- package/test/invariants/TokensInvariant.t.sol +184 -0
- package/test/invariants/handlers/ComprehensiveHandler.sol +285 -0
- package/test/invariants/handlers/EconomicHandler.sol +347 -0
- package/test/invariants/handlers/Phase3Handler.sol +414 -0
- package/test/invariants/handlers/RulesetsHandler.sol +111 -0
- package/test/invariants/handlers/TerminalStoreHandler.sol +146 -0
- package/test/invariants/handlers/TokensHandler.sol +127 -0
- package/test/mock/ERC2771ForwarderMock.sol +37 -0
- package/test/mock/MockERC20.sol +18 -0
- package/test/mock/MockMaliciousBeneficiary.sol +67 -0
- package/test/mock/MockMaliciousSplitHook.sol +42 -0
- package/test/mock/MockPriceFeed.sol +20 -0
- package/test/trees/JBController/burnTokensOf.tree +9 -0
- package/test/trees/JBController/claimTokensFor.tree +5 -0
- package/test/trees/JBController/deployERC20For.tree +5 -0
- package/test/trees/JBController/getRulesetOf.tree +5 -0
- package/test/trees/JBController/launchProjectFor.tree +12 -0
- package/test/trees/JBController/launchRulesetsFor.tree +8 -0
- package/test/trees/JBController/migrateController.tree +12 -0
- package/test/trees/JBController/mintTokensOf.tree +12 -0
- package/test/trees/JBController/payReservedTokenToTerminal.tree +8 -0
- package/test/trees/JBController/receiveMigrationFrom.tree +4 -0
- package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +12 -0
- package/test/trees/JBController/setMetadataOf.tree +5 -0
- package/test/trees/JBController/setSplitGroupsOf.tree +5 -0
- package/test/trees/JBController/setTokenFor.tree +5 -0
- package/test/trees/JBController/transferCreditsFrom.tree +8 -0
- package/test/trees/JBDirectory/primaryTerminalOf.tree +8 -0
- package/test/trees/JBDirectory/setControllerOf.tree +11 -0
- package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +15 -0
- package/test/trees/JBDirectory/setTerminalsOf.tree +11 -0
- package/test/trees/JBERC20/initialize.tree +7 -0
- package/test/trees/JBERC20/name.tree +5 -0
- package/test/trees/JBERC20/nonces.tree +5 -0
- package/test/trees/JBERC20/symbol.tree +5 -0
- package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +5 -0
- package/test/trees/JBFeelessAddresses/supportsInterface.tree +5 -0
- package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +5 -0
- package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +8 -0
- package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +18 -0
- package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +5 -0
- package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +8 -0
- package/test/trees/JBMetadataResolver/getDataFor.tree +8 -0
- package/test/trees/JBMultiTerminal/accountingContextsOf.tree +5 -0
- package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +10 -0
- package/test/trees/JBMultiTerminal/addToBalanceOf.tree +23 -0
- package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +23 -0
- package/test/trees/JBMultiTerminal/executePayout.tree +32 -0
- package/test/trees/JBMultiTerminal/executeProcessFee.tree +14 -0
- package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +12 -0
- package/test/trees/JBMultiTerminal/pay.tree +23 -0
- package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +8 -0
- package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +34 -0
- package/test/trees/JBMultiTerminal/useAllowanceOf.tree +16 -0
- package/test/trees/JBPermissions/hasPermission.tree +8 -0
- package/test/trees/JBPermissions/hasPermissions.tree +8 -0
- package/test/trees/JBPermissions/setPermissionsFor.tree +5 -0
- package/test/trees/JBPrices/addPriceFeedFor.tree +14 -0
- package/test/trees/JBPrices/pricePerUnitOf.tree +11 -0
- package/test/trees/JBProjects/createFor.tree +11 -0
- package/test/trees/JBProjects/setTokenUriResolver.tree +5 -0
- package/test/trees/JBProjects/supportsInterface.tree +9 -0
- package/test/trees/JBProjects/tokenURI.tree +5 -0
- package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +8 -0
- package/test/trees/JBRulesets/currentOf.tree +12 -0
- package/test/trees/JBRulesets/getRulesetOf.tree +5 -0
- package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +10 -0
- package/test/trees/JBRulesets/rulesetsOf.tree +11 -0
- package/test/trees/JBRulesets/upcomingRulesetOf.tree +20 -0
- package/test/trees/JBRulesets/updateRulesetWeightCache.tree +5 -0
- package/test/trees/JBSplits/setSplitGroupsOf.tree +17 -0
- package/test/trees/JBSplits/splitsOf.tree +5 -0
- package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +16 -0
- package/test/trees/JBTerminalStore/currentSurplusOf.tree +25 -0
- package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +5 -0
- package/test/trees/JBTerminalStore/recordCashOutsFor.tree +16 -0
- package/test/trees/JBTerminalStore/recordPaymentFrom.tree +14 -0
- package/test/trees/JBTerminalStore/recordPayoutFor.tree +10 -0
- package/test/trees/JBTerminalStore/recordTerminalMigration.tree +5 -0
- package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +10 -0
- package/test/trees/JBTokens/burnFrom.tree +10 -0
- package/test/trees/JBTokens/claimTokensFor.tree +10 -0
- package/test/trees/JBTokens/deployERC20For.tree +12 -0
- package/test/trees/JBTokens/mintFor.tree +10 -0
- package/test/trees/JBTokens/setTokenFor.tree +11 -0
- package/test/trees/JBTokens/totalBalanceOf.tree +5 -0
- package/test/trees/JBTokens/totalSupplyOf.tree +5 -0
- package/test/trees/JBTokens/transferCreditsFrom.tree +8 -0
- package/test/trees/mintTokensOf.tree +12 -0
- package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +220 -0
- package/test/units/static/JBController/JBControllerSetup.sol +40 -0
- package/test/units/static/JBController/TestBurnTokensOf.sol +107 -0
- package/test/units/static/JBController/TestClaimTokensFor.sol +60 -0
- package/test/units/static/JBController/TestDeployErc20For.sol +80 -0
- package/test/units/static/JBController/TestLaunchProjectFor.sol +282 -0
- package/test/units/static/JBController/TestLaunchRulesetsFor.sol +322 -0
- package/test/units/static/JBController/TestMigrateController.sol +148 -0
- package/test/units/static/JBController/TestMintTokensOfUnits.sol +102 -0
- package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +71 -0
- package/test/units/static/JBController/TestReceiveMigrationFrom.sol +95 -0
- package/test/units/static/JBController/TestRulesetViews.sol +219 -0
- package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +595 -0
- package/test/units/static/JBController/TestSetSplitGroupsOf.sol +63 -0
- package/test/units/static/JBController/TestSetTokenFor.sol +227 -0
- package/test/units/static/JBController/TestSetUriOf.sol +53 -0
- package/test/units/static/JBController/TestTransferCreditsFrom.sol +159 -0
- package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +194 -0
- package/test/units/static/JBDirectory/JBDirectorySetup.sol +22 -0
- package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +122 -0
- package/test/units/static/JBDirectory/TestSetControllerOf.sol +173 -0
- package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +98 -0
- package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +169 -0
- package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +128 -0
- package/test/units/static/JBERC20/JBERC20Setup.sol +20 -0
- package/test/units/static/JBERC20/SigUtils.sol +34 -0
- package/test/units/static/JBERC20/TestInitialize.sol +54 -0
- package/test/units/static/JBERC20/TestName.sol +30 -0
- package/test/units/static/JBERC20/TestNonces.sol +59 -0
- package/test/units/static/JBERC20/TestSymbol.sol +31 -0
- package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +20 -0
- package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +29 -0
- package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +35 -0
- package/test/units/static/JBFees/TestFeesFuzz.sol +78 -0
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +16 -0
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +71 -0
- package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +21 -0
- package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +159 -0
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +56 -0
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +94 -0
- package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +182 -0
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +61 -0
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +96 -0
- package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +89 -0
- package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +227 -0
- package/test/units/static/JBMetadataResolver/TestMetadataResolverM20M21.sol +245 -0
- package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +39 -0
- package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +65 -0
- package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +313 -0
- package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +432 -0
- package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +478 -0
- package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +577 -0
- package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +176 -0
- package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +190 -0
- package/test/units/static/JBMultiTerminal/TestPay.sol +514 -0
- package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +29 -0
- package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +243 -0
- package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +310 -0
- package/test/units/static/JBPermissions/JBPermissionsSetup.sol +18 -0
- package/test/units/static/JBPermissions/TestHasPermission.sol +50 -0
- package/test/units/static/JBPermissions/TestHasPermissions.sol +93 -0
- package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +62 -0
- package/test/units/static/JBPrices/JBPricesSetup.sol +26 -0
- package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +102 -0
- package/test/units/static/JBPrices/TestPricePerUnitOf.sol +129 -0
- package/test/units/static/JBPrices/TestPrices.sol +262 -0
- package/test/units/static/JBProjects/JBProjectsSetup.sol +20 -0
- package/test/units/static/JBProjects/TestCreateFor.sol +69 -0
- package/test/units/static/JBProjects/TestInitialProject.sol +19 -0
- package/test/units/static/JBProjects/TestInterfaces.sol +27 -0
- package/test/units/static/JBProjects/TestSetResolver.sol +36 -0
- package/test/units/static/JBProjects/TestTokenUri.sol +38 -0
- package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +99 -0
- package/test/units/static/JBRulesets/JBRulesetsSetup.sol +21 -0
- package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +257 -0
- package/test/units/static/JBRulesets/TestCurrentOf.sol +231 -0
- package/test/units/static/JBRulesets/TestGetRulesetOf.sol +94 -0
- package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +252 -0
- package/test/units/static/JBRulesets/TestRulesets.sol +617 -0
- package/test/units/static/JBRulesets/TestRulesetsOf.sol +37 -0
- package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +526 -0
- package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +91 -0
- package/test/units/static/JBSplits/JBSplitsSetup.sol +23 -0
- package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +502 -0
- package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +370 -0
- package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +262 -0
- package/test/units/static/JBSplits/TestSplitsOf.sol +24 -0
- package/test/units/static/JBSplits/TestSplitsPacking.sol +33 -0
- package/test/units/static/JBSurplus/TestSurplusFuzz.sol +125 -0
- package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +23 -0
- package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +434 -0
- package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +428 -0
- package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +65 -0
- package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +479 -0
- package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +508 -0
- package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +257 -0
- package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +131 -0
- package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +390 -0
- package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +187 -0
- package/test/units/static/JBTokens/JBTokensSetup.sol +23 -0
- package/test/units/static/JBTokens/TestBurnFrom.sol +104 -0
- package/test/units/static/JBTokens/TestClaimTokensFor.sol +107 -0
- package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +89 -0
- package/test/units/static/JBTokens/TestMintFor.sol +97 -0
- package/test/units/static/JBTokens/TestSetTokenFor.sol +95 -0
- package/test/units/static/JBTokens/TestTotalBalanceOf.sol +65 -0
- package/test/units/static/JBTokens/TestTotalSupplyOf.sol +56 -0
- package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +54 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
5
|
+
|
|
6
|
+
import {IJBPayHook} from "./IJBPayHook.sol";
|
|
7
|
+
import {JBAccountingContext} from "../structs/JBAccountingContext.sol";
|
|
8
|
+
import {JBAfterPayRecordedContext} from "../structs/JBAfterPayRecordedContext.sol";
|
|
9
|
+
|
|
10
|
+
/// @notice A terminal that accepts payments and can be migrated.
|
|
11
|
+
interface IJBTerminal is IERC165 {
|
|
12
|
+
event AddToBalance(
|
|
13
|
+
uint256 indexed projectId, uint256 amount, uint256 returnedFees, string memo, bytes metadata, address caller
|
|
14
|
+
);
|
|
15
|
+
event HookAfterRecordPay(
|
|
16
|
+
IJBPayHook indexed hook, JBAfterPayRecordedContext context, uint256 specificationAmount, address caller
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
event MigrateTerminal(
|
|
20
|
+
uint256 indexed projectId, address indexed token, IJBTerminal indexed to, uint256 amount, address caller
|
|
21
|
+
);
|
|
22
|
+
event Pay(
|
|
23
|
+
uint256 indexed rulesetId,
|
|
24
|
+
uint256 indexed rulesetCycleNumber,
|
|
25
|
+
uint256 indexed projectId,
|
|
26
|
+
address payer,
|
|
27
|
+
address beneficiary,
|
|
28
|
+
uint256 amount,
|
|
29
|
+
uint256 newlyIssuedTokenCount,
|
|
30
|
+
string memo,
|
|
31
|
+
bytes metadata,
|
|
32
|
+
address caller
|
|
33
|
+
);
|
|
34
|
+
event SetAccountingContext(uint256 indexed projectId, JBAccountingContext context, address caller);
|
|
35
|
+
|
|
36
|
+
/// @notice Returns the accounting context for a project's token.
|
|
37
|
+
/// @param projectId The ID of the project to get the accounting context of.
|
|
38
|
+
/// @param token The token to get the accounting context for.
|
|
39
|
+
/// @return The accounting context for the project's token.
|
|
40
|
+
function accountingContextForTokenOf(
|
|
41
|
+
uint256 projectId,
|
|
42
|
+
address token
|
|
43
|
+
)
|
|
44
|
+
external
|
|
45
|
+
view
|
|
46
|
+
returns (JBAccountingContext memory);
|
|
47
|
+
|
|
48
|
+
/// @notice Returns all accounting contexts for a project.
|
|
49
|
+
/// @param projectId The ID of the project to get the accounting contexts of.
|
|
50
|
+
/// @return The accounting contexts for the project.
|
|
51
|
+
function accountingContextsOf(uint256 projectId) external view returns (JBAccountingContext[] memory);
|
|
52
|
+
|
|
53
|
+
/// @notice Returns a project's current surplus for a set of accounting contexts.
|
|
54
|
+
/// @param projectId The ID of the project to get the surplus of.
|
|
55
|
+
/// @param accountingContexts The accounting contexts to include in the surplus calculation.
|
|
56
|
+
/// @param decimals The number of decimals to express the surplus with.
|
|
57
|
+
/// @param currency The currency to express the surplus in.
|
|
58
|
+
/// @return The project's current surplus.
|
|
59
|
+
function currentSurplusOf(
|
|
60
|
+
uint256 projectId,
|
|
61
|
+
JBAccountingContext[] memory accountingContexts,
|
|
62
|
+
uint256 decimals,
|
|
63
|
+
uint256 currency
|
|
64
|
+
)
|
|
65
|
+
external
|
|
66
|
+
view
|
|
67
|
+
returns (uint256);
|
|
68
|
+
|
|
69
|
+
/// @notice Adds accounting contexts for a project's tokens.
|
|
70
|
+
/// @param projectId The ID of the project to add accounting contexts for.
|
|
71
|
+
/// @param accountingContexts The accounting contexts to add.
|
|
72
|
+
function addAccountingContextsFor(uint256 projectId, JBAccountingContext[] calldata accountingContexts) external;
|
|
73
|
+
|
|
74
|
+
/// @notice Adds funds to a project's balance.
|
|
75
|
+
/// @param projectId The ID of the project to add funds to.
|
|
76
|
+
/// @param token The token being added.
|
|
77
|
+
/// @param amount The amount of tokens being added.
|
|
78
|
+
/// @param shouldReturnHeldFees Whether held fees should be returned based on the amount added.
|
|
79
|
+
/// @param memo A memo to pass along to the emitted event.
|
|
80
|
+
/// @param metadata Extra data to pass along to the emitted event.
|
|
81
|
+
function addToBalanceOf(
|
|
82
|
+
uint256 projectId,
|
|
83
|
+
address token,
|
|
84
|
+
uint256 amount,
|
|
85
|
+
bool shouldReturnHeldFees,
|
|
86
|
+
string calldata memo,
|
|
87
|
+
bytes calldata metadata
|
|
88
|
+
)
|
|
89
|
+
external
|
|
90
|
+
payable;
|
|
91
|
+
|
|
92
|
+
/// @notice Migrates a project's funds from this terminal to another.
|
|
93
|
+
/// @param projectId The ID of the project being migrated.
|
|
94
|
+
/// @param token The address of the token being migrated.
|
|
95
|
+
/// @param to The terminal to migrate to.
|
|
96
|
+
/// @return balance The amount of funds that were migrated.
|
|
97
|
+
function migrateBalanceOf(uint256 projectId, address token, IJBTerminal to) external returns (uint256 balance);
|
|
98
|
+
|
|
99
|
+
/// @notice Pays a project in a specified token.
|
|
100
|
+
/// @param projectId The ID of the project being paid.
|
|
101
|
+
/// @param token The token being paid in.
|
|
102
|
+
/// @param amount The amount of tokens being paid.
|
|
103
|
+
/// @param beneficiary The address to mint project tokens to.
|
|
104
|
+
/// @param minReturnedTokens The minimum number of project tokens expected in return.
|
|
105
|
+
/// @param memo A memo to pass along to the emitted event.
|
|
106
|
+
/// @param metadata Extra data to pass along to the pay hooks.
|
|
107
|
+
/// @return beneficiaryTokenCount The number of tokens minted for the beneficiary.
|
|
108
|
+
function pay(
|
|
109
|
+
uint256 projectId,
|
|
110
|
+
address token,
|
|
111
|
+
uint256 amount,
|
|
112
|
+
address beneficiary,
|
|
113
|
+
uint256 minReturnedTokens,
|
|
114
|
+
string calldata memo,
|
|
115
|
+
bytes calldata metadata
|
|
116
|
+
)
|
|
117
|
+
external
|
|
118
|
+
payable
|
|
119
|
+
returns (uint256 beneficiaryTokenCount);
|
|
120
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {IJBDirectory} from "./IJBDirectory.sol";
|
|
5
|
+
import {IJBPrices} from "./IJBPrices.sol";
|
|
6
|
+
import {IJBRulesets} from "./IJBRulesets.sol";
|
|
7
|
+
import {IJBTerminal} from "./IJBTerminal.sol";
|
|
8
|
+
import {JBAccountingContext} from "./../structs/JBAccountingContext.sol";
|
|
9
|
+
import {JBCashOutHookSpecification} from "./../structs/JBCashOutHookSpecification.sol";
|
|
10
|
+
import {JBPayHookSpecification} from "./../structs/JBPayHookSpecification.sol";
|
|
11
|
+
import {JBRuleset} from "./../structs/JBRuleset.sol";
|
|
12
|
+
import {JBTokenAmount} from "./../structs/JBTokenAmount.sol";
|
|
13
|
+
|
|
14
|
+
/// @notice Manages the bookkeeping for payments, cash outs, payouts, and surplus allowance usage for terminals.
|
|
15
|
+
interface IJBTerminalStore {
|
|
16
|
+
/// @notice The directory of terminals and controllers for projects.
|
|
17
|
+
function DIRECTORY() external view returns (IJBDirectory);
|
|
18
|
+
|
|
19
|
+
/// @notice The contract that stores prices for each project.
|
|
20
|
+
function PRICES() external view returns (IJBPrices);
|
|
21
|
+
|
|
22
|
+
/// @notice The contract storing and managing project rulesets.
|
|
23
|
+
function RULESETS() external view returns (IJBRulesets);
|
|
24
|
+
|
|
25
|
+
/// @notice Returns the balance of a terminal for a project and token.
|
|
26
|
+
/// @param terminal The terminal to get the balance of.
|
|
27
|
+
/// @param projectId The ID of the project to get the balance for.
|
|
28
|
+
/// @param token The token to get the balance of.
|
|
29
|
+
/// @return The balance.
|
|
30
|
+
function balanceOf(address terminal, uint256 projectId, address token) external view returns (uint256);
|
|
31
|
+
|
|
32
|
+
/// @notice Returns the amount of payout limit used by a terminal for a project in a given cycle.
|
|
33
|
+
/// @param terminal The terminal to get the used payout limit of.
|
|
34
|
+
/// @param projectId The ID of the project.
|
|
35
|
+
/// @param token The token the payout limit is denominated in.
|
|
36
|
+
/// @param rulesetCycleNumber The cycle number to get the used payout limit for.
|
|
37
|
+
/// @param currency The currency the payout limit is denominated in.
|
|
38
|
+
/// @return The amount of payout limit used.
|
|
39
|
+
function usedPayoutLimitOf(
|
|
40
|
+
address terminal,
|
|
41
|
+
uint256 projectId,
|
|
42
|
+
address token,
|
|
43
|
+
uint256 rulesetCycleNumber,
|
|
44
|
+
uint256 currency
|
|
45
|
+
)
|
|
46
|
+
external
|
|
47
|
+
view
|
|
48
|
+
returns (uint256);
|
|
49
|
+
|
|
50
|
+
/// @notice Returns the amount of surplus allowance used by a terminal for a project in a given ruleset.
|
|
51
|
+
/// @param terminal The terminal to get the used surplus allowance of.
|
|
52
|
+
/// @param projectId The ID of the project.
|
|
53
|
+
/// @param token The token the surplus allowance is denominated in.
|
|
54
|
+
/// @param rulesetId The ID of the ruleset to get the used surplus allowance for.
|
|
55
|
+
/// @param currency The currency the surplus allowance is denominated in.
|
|
56
|
+
/// @return The amount of surplus allowance used.
|
|
57
|
+
function usedSurplusAllowanceOf(
|
|
58
|
+
address terminal,
|
|
59
|
+
uint256 projectId,
|
|
60
|
+
address token,
|
|
61
|
+
uint256 rulesetId,
|
|
62
|
+
uint256 currency
|
|
63
|
+
)
|
|
64
|
+
external
|
|
65
|
+
view
|
|
66
|
+
returns (uint256);
|
|
67
|
+
|
|
68
|
+
/// @notice Returns the reclaimable surplus for a project given a cash-out count, total supply, and surplus.
|
|
69
|
+
/// @param projectId The ID of the project.
|
|
70
|
+
/// @param cashOutCount The number of tokens being cashed out.
|
|
71
|
+
/// @param totalSupply The total token supply.
|
|
72
|
+
/// @param surplus The project's surplus.
|
|
73
|
+
/// @return The reclaimable surplus amount.
|
|
74
|
+
function currentReclaimableSurplusOf(
|
|
75
|
+
uint256 projectId,
|
|
76
|
+
uint256 cashOutCount,
|
|
77
|
+
uint256 totalSupply,
|
|
78
|
+
uint256 surplus
|
|
79
|
+
)
|
|
80
|
+
external
|
|
81
|
+
view
|
|
82
|
+
returns (uint256);
|
|
83
|
+
|
|
84
|
+
/// @notice Returns the reclaimable surplus for a project across multiple terminals.
|
|
85
|
+
/// @param projectId The ID of the project.
|
|
86
|
+
/// @param cashOutCount The number of tokens being cashed out.
|
|
87
|
+
/// @param terminals The terminals to include in the surplus calculation.
|
|
88
|
+
/// @param accountingContexts The accounting contexts to include.
|
|
89
|
+
/// @param decimals The number of decimals to express the result with.
|
|
90
|
+
/// @param currency The currency to express the result in.
|
|
91
|
+
/// @return The reclaimable surplus amount.
|
|
92
|
+
function currentReclaimableSurplusOf(
|
|
93
|
+
uint256 projectId,
|
|
94
|
+
uint256 cashOutCount,
|
|
95
|
+
IJBTerminal[] calldata terminals,
|
|
96
|
+
JBAccountingContext[] calldata accountingContexts,
|
|
97
|
+
uint256 decimals,
|
|
98
|
+
uint256 currency
|
|
99
|
+
)
|
|
100
|
+
external
|
|
101
|
+
view
|
|
102
|
+
returns (uint256);
|
|
103
|
+
|
|
104
|
+
/// @notice Returns the current surplus for a terminal and project.
|
|
105
|
+
/// @param terminal The terminal to get the surplus of.
|
|
106
|
+
/// @param projectId The ID of the project.
|
|
107
|
+
/// @param accountingContexts The accounting contexts to include.
|
|
108
|
+
/// @param decimals The number of decimals to express the result with.
|
|
109
|
+
/// @param currency The currency to express the result in.
|
|
110
|
+
/// @return The current surplus.
|
|
111
|
+
function currentSurplusOf(
|
|
112
|
+
address terminal,
|
|
113
|
+
uint256 projectId,
|
|
114
|
+
JBAccountingContext[] calldata accountingContexts,
|
|
115
|
+
uint256 decimals,
|
|
116
|
+
uint256 currency
|
|
117
|
+
)
|
|
118
|
+
external
|
|
119
|
+
view
|
|
120
|
+
returns (uint256);
|
|
121
|
+
|
|
122
|
+
/// @notice Returns the current total surplus for a project across all terminals.
|
|
123
|
+
/// @param projectId The ID of the project.
|
|
124
|
+
/// @param decimals The number of decimals to express the result with.
|
|
125
|
+
/// @param currency The currency to express the result in.
|
|
126
|
+
/// @return The current total surplus.
|
|
127
|
+
function currentTotalSurplusOf(
|
|
128
|
+
uint256 projectId,
|
|
129
|
+
uint256 decimals,
|
|
130
|
+
uint256 currency
|
|
131
|
+
)
|
|
132
|
+
external
|
|
133
|
+
view
|
|
134
|
+
returns (uint256);
|
|
135
|
+
|
|
136
|
+
/// @notice Records a balance addition for a project.
|
|
137
|
+
/// @param projectId The ID of the project.
|
|
138
|
+
/// @param token The token being added.
|
|
139
|
+
/// @param amount The amount being added.
|
|
140
|
+
function recordAddedBalanceFor(uint256 projectId, address token, uint256 amount) external;
|
|
141
|
+
|
|
142
|
+
/// @notice Records a payment to a project.
|
|
143
|
+
/// @param payer The address of the payer.
|
|
144
|
+
/// @param amount The amount being paid.
|
|
145
|
+
/// @param projectId The ID of the project being paid.
|
|
146
|
+
/// @param beneficiary The address to mint project tokens to.
|
|
147
|
+
/// @param metadata Extra data to pass along to the data hook.
|
|
148
|
+
/// @return ruleset The project's current ruleset.
|
|
149
|
+
/// @return tokenCount The number of project tokens minted.
|
|
150
|
+
/// @return hookSpecifications Any pay hook specifications from the data hook.
|
|
151
|
+
function recordPaymentFrom(
|
|
152
|
+
address payer,
|
|
153
|
+
JBTokenAmount memory amount,
|
|
154
|
+
uint256 projectId,
|
|
155
|
+
address beneficiary,
|
|
156
|
+
bytes calldata metadata
|
|
157
|
+
)
|
|
158
|
+
external
|
|
159
|
+
returns (JBRuleset memory ruleset, uint256 tokenCount, JBPayHookSpecification[] memory hookSpecifications);
|
|
160
|
+
|
|
161
|
+
/// @notice Records a payout from a project.
|
|
162
|
+
/// @param projectId The ID of the project paying out.
|
|
163
|
+
/// @param accountingContext The accounting context of the token being paid out.
|
|
164
|
+
/// @param amount The amount being paid out.
|
|
165
|
+
/// @param currency The currency the amount is denominated in.
|
|
166
|
+
/// @return ruleset The project's current ruleset.
|
|
167
|
+
/// @return amountPaidOut The amount paid out in the token's native decimals.
|
|
168
|
+
function recordPayoutFor(
|
|
169
|
+
uint256 projectId,
|
|
170
|
+
JBAccountingContext calldata accountingContext,
|
|
171
|
+
uint256 amount,
|
|
172
|
+
uint256 currency
|
|
173
|
+
)
|
|
174
|
+
external
|
|
175
|
+
returns (JBRuleset memory ruleset, uint256 amountPaidOut);
|
|
176
|
+
|
|
177
|
+
/// @notice Records a cash out from a project.
|
|
178
|
+
/// @param holder The address cashing out.
|
|
179
|
+
/// @param projectId The ID of the project being cashed out from.
|
|
180
|
+
/// @param cashOutCount The number of project tokens being cashed out.
|
|
181
|
+
/// @param accountingContext The accounting context of the token being reclaimed.
|
|
182
|
+
/// @param balanceAccountingContexts The accounting contexts to include in the balance calculation.
|
|
183
|
+
/// @param metadata Extra data to pass along to the data hook.
|
|
184
|
+
/// @return ruleset The project's current ruleset.
|
|
185
|
+
/// @return reclaimAmount The amount reclaimed.
|
|
186
|
+
/// @return cashOutTaxRate The cash out tax rate applied.
|
|
187
|
+
/// @return hookSpecifications Any cash out hook specifications from the data hook.
|
|
188
|
+
function recordCashOutFor(
|
|
189
|
+
address holder,
|
|
190
|
+
uint256 projectId,
|
|
191
|
+
uint256 cashOutCount,
|
|
192
|
+
JBAccountingContext calldata accountingContext,
|
|
193
|
+
JBAccountingContext[] calldata balanceAccountingContexts,
|
|
194
|
+
bytes calldata metadata
|
|
195
|
+
)
|
|
196
|
+
external
|
|
197
|
+
returns (
|
|
198
|
+
JBRuleset memory ruleset,
|
|
199
|
+
uint256 reclaimAmount,
|
|
200
|
+
uint256 cashOutTaxRate,
|
|
201
|
+
JBCashOutHookSpecification[] memory hookSpecifications
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
/// @notice Records a terminal migration for a project.
|
|
205
|
+
/// @param projectId The ID of the project being migrated.
|
|
206
|
+
/// @param token The token being migrated.
|
|
207
|
+
/// @return balance The balance that was migrated.
|
|
208
|
+
function recordTerminalMigration(uint256 projectId, address token) external returns (uint256 balance);
|
|
209
|
+
|
|
210
|
+
/// @notice Records surplus allowance usage for a project.
|
|
211
|
+
/// @param projectId The ID of the project using surplus allowance.
|
|
212
|
+
/// @param accountingContext The accounting context of the token being used.
|
|
213
|
+
/// @param amount The amount of surplus allowance to use.
|
|
214
|
+
/// @param currency The currency the amount is denominated in.
|
|
215
|
+
/// @return ruleset The project's current ruleset.
|
|
216
|
+
/// @return usedAmount The amount used in the token's native decimals.
|
|
217
|
+
function recordUsedAllowanceOf(
|
|
218
|
+
uint256 projectId,
|
|
219
|
+
JBAccountingContext calldata accountingContext,
|
|
220
|
+
uint256 amount,
|
|
221
|
+
uint256 currency
|
|
222
|
+
)
|
|
223
|
+
external
|
|
224
|
+
returns (JBRuleset memory ruleset, uint256 usedAmount);
|
|
225
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/// @notice A token that can be used by a project in the Juicebox ecosystem.
|
|
5
|
+
interface IJBToken {
|
|
6
|
+
/// @notice Returns the balance of an account.
|
|
7
|
+
/// @param account The account to get the balance of.
|
|
8
|
+
/// @return The number of tokens owned by the account.
|
|
9
|
+
function balanceOf(address account) external view returns (uint256);
|
|
10
|
+
|
|
11
|
+
/// @notice Returns whether this token can be added to a given project.
|
|
12
|
+
/// @param projectId The ID of the project to check.
|
|
13
|
+
/// @return A flag indicating whether the token can be added.
|
|
14
|
+
function canBeAddedTo(uint256 projectId) external view returns (bool);
|
|
15
|
+
|
|
16
|
+
/// @notice Returns the number of decimals used by the token.
|
|
17
|
+
/// @return The number of decimals.
|
|
18
|
+
function decimals() external view returns (uint8);
|
|
19
|
+
|
|
20
|
+
/// @notice Returns the total supply of the token.
|
|
21
|
+
/// @return The total supply.
|
|
22
|
+
function totalSupply() external view returns (uint256);
|
|
23
|
+
|
|
24
|
+
/// @notice Initializes the token with a name, symbol, and owner.
|
|
25
|
+
/// @param name The token's name.
|
|
26
|
+
/// @param symbol The token's symbol.
|
|
27
|
+
/// @param owner The token contract's owner.
|
|
28
|
+
function initialize(string memory name, string memory symbol, address owner) external;
|
|
29
|
+
|
|
30
|
+
/// @notice Burns tokens from an account.
|
|
31
|
+
/// @param account The address to burn tokens from.
|
|
32
|
+
/// @param amount The amount of tokens to burn.
|
|
33
|
+
function burn(address account, uint256 amount) external;
|
|
34
|
+
|
|
35
|
+
/// @notice Mints tokens to an account.
|
|
36
|
+
/// @param account The address to mint tokens to.
|
|
37
|
+
/// @param amount The amount of tokens to mint.
|
|
38
|
+
function mint(address account, uint256 amount) external;
|
|
39
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/// @notice Resolves token URIs for project NFTs.
|
|
5
|
+
interface IJBTokenUriResolver {
|
|
6
|
+
/// @notice Returns the token URI for a project.
|
|
7
|
+
/// @param projectId The ID of the project to get the token URI of.
|
|
8
|
+
/// @return tokenUri The token URI.
|
|
9
|
+
function getUri(uint256 projectId) external view returns (string memory tokenUri);
|
|
10
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {IJBToken} from "./IJBToken.sol";
|
|
5
|
+
|
|
6
|
+
/// @notice Manages minting, burning, and balances of projects' tokens and token credits.
|
|
7
|
+
interface IJBTokens {
|
|
8
|
+
event DeployERC20(
|
|
9
|
+
uint256 indexed projectId, IJBToken indexed token, string name, string symbol, bytes32 salt, address caller
|
|
10
|
+
);
|
|
11
|
+
event Burn(
|
|
12
|
+
address indexed holder,
|
|
13
|
+
uint256 indexed projectId,
|
|
14
|
+
uint256 count,
|
|
15
|
+
uint256 creditBalance,
|
|
16
|
+
uint256 tokenBalance,
|
|
17
|
+
address caller
|
|
18
|
+
);
|
|
19
|
+
event ClaimTokens(
|
|
20
|
+
address indexed holder,
|
|
21
|
+
uint256 indexed projectId,
|
|
22
|
+
uint256 creditBalance,
|
|
23
|
+
uint256 count,
|
|
24
|
+
address beneficiary,
|
|
25
|
+
address caller
|
|
26
|
+
);
|
|
27
|
+
event Mint(
|
|
28
|
+
address indexed holder, uint256 indexed projectId, uint256 count, bool tokensWereClaimed, address caller
|
|
29
|
+
);
|
|
30
|
+
event SetToken(uint256 indexed projectId, IJBToken indexed token, address caller);
|
|
31
|
+
event TransferCredits(
|
|
32
|
+
address indexed holder, uint256 indexed projectId, address indexed recipient, uint256 count, address caller
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
/// @notice Returns the credit balance for a holder and project.
|
|
36
|
+
/// @param holder The address to get the credit balance of.
|
|
37
|
+
/// @param projectId The ID of the project to get the credit balance for.
|
|
38
|
+
/// @return The credit balance.
|
|
39
|
+
function creditBalanceOf(address holder, uint256 projectId) external view returns (uint256);
|
|
40
|
+
|
|
41
|
+
/// @notice Returns the project ID associated with a token.
|
|
42
|
+
/// @param token The token to get the project ID of.
|
|
43
|
+
/// @return The project ID.
|
|
44
|
+
function projectIdOf(IJBToken token) external view returns (uint256);
|
|
45
|
+
|
|
46
|
+
/// @notice Returns the token for a project.
|
|
47
|
+
/// @param projectId The ID of the project to get the token of.
|
|
48
|
+
/// @return The project's token.
|
|
49
|
+
function tokenOf(uint256 projectId) external view returns (IJBToken);
|
|
50
|
+
|
|
51
|
+
/// @notice Returns the total credit supply for a project.
|
|
52
|
+
/// @param projectId The ID of the project to get the total credit supply of.
|
|
53
|
+
/// @return The total credit supply.
|
|
54
|
+
function totalCreditSupplyOf(uint256 projectId) external view returns (uint256);
|
|
55
|
+
|
|
56
|
+
/// @notice Returns the total balance (tokens + credits) for a holder and project.
|
|
57
|
+
/// @param holder The address to get the total balance of.
|
|
58
|
+
/// @param projectId The ID of the project to get the total balance for.
|
|
59
|
+
/// @return balance The combined token and credit balance.
|
|
60
|
+
function totalBalanceOf(address holder, uint256 projectId) external view returns (uint256 balance);
|
|
61
|
+
|
|
62
|
+
/// @notice Returns the total supply (tokens + credits) for a project.
|
|
63
|
+
/// @param projectId The ID of the project to get the total supply of.
|
|
64
|
+
/// @return The total supply.
|
|
65
|
+
function totalSupplyOf(uint256 projectId) external view returns (uint256);
|
|
66
|
+
|
|
67
|
+
/// @notice Burns tokens and/or credits from a holder's balance.
|
|
68
|
+
/// @param holder The address to burn tokens from.
|
|
69
|
+
/// @param projectId The ID of the project whose tokens are being burned.
|
|
70
|
+
/// @param count The number of tokens to burn.
|
|
71
|
+
function burnFrom(address holder, uint256 projectId, uint256 count) external;
|
|
72
|
+
|
|
73
|
+
/// @notice Claims tokens from a holder's credits into a beneficiary's account.
|
|
74
|
+
/// @param holder The address to claim credits from.
|
|
75
|
+
/// @param projectId The ID of the project whose tokens are being claimed.
|
|
76
|
+
/// @param count The number of tokens to claim.
|
|
77
|
+
/// @param beneficiary The address to send the claimed tokens to.
|
|
78
|
+
function claimTokensFor(address holder, uint256 projectId, uint256 count, address beneficiary) external;
|
|
79
|
+
|
|
80
|
+
/// @notice Deploys an ERC-20 token for a project.
|
|
81
|
+
/// @param projectId The ID of the project to deploy the ERC-20 for.
|
|
82
|
+
/// @param name The ERC-20's name.
|
|
83
|
+
/// @param symbol The ERC-20's symbol.
|
|
84
|
+
/// @param salt The salt used for deterministic clone deployment.
|
|
85
|
+
/// @return token The deployed token.
|
|
86
|
+
function deployERC20For(
|
|
87
|
+
uint256 projectId,
|
|
88
|
+
string calldata name,
|
|
89
|
+
string calldata symbol,
|
|
90
|
+
bytes32 salt
|
|
91
|
+
)
|
|
92
|
+
external
|
|
93
|
+
returns (IJBToken token);
|
|
94
|
+
|
|
95
|
+
/// @notice Mints tokens or credits for a holder.
|
|
96
|
+
/// @param holder The address to mint tokens for.
|
|
97
|
+
/// @param projectId The ID of the project whose tokens are being minted.
|
|
98
|
+
/// @param count The number of tokens to mint.
|
|
99
|
+
/// @return token The project's token, if one exists.
|
|
100
|
+
function mintFor(address holder, uint256 projectId, uint256 count) external returns (IJBToken token);
|
|
101
|
+
|
|
102
|
+
/// @notice Sets a project's token.
|
|
103
|
+
/// @param projectId The ID of the project to set the token of.
|
|
104
|
+
/// @param token The token to set.
|
|
105
|
+
function setTokenFor(uint256 projectId, IJBToken token) external;
|
|
106
|
+
|
|
107
|
+
/// @notice Transfers credits from one holder to another.
|
|
108
|
+
/// @param holder The address to transfer credits from.
|
|
109
|
+
/// @param projectId The ID of the project whose credits are being transferred.
|
|
110
|
+
/// @param recipient The address to transfer credits to.
|
|
111
|
+
/// @param count The number of credits to transfer.
|
|
112
|
+
function transferCreditsFrom(address holder, uint256 projectId, address recipient, uint256 count) external;
|
|
113
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import {mulDiv} from "@prb/math/src/Common.sol";
|
|
5
|
+
|
|
6
|
+
import {JBConstants} from "./JBConstants.sol";
|
|
7
|
+
|
|
8
|
+
/// @notice Cash out calculations.
|
|
9
|
+
library JBCashOuts {
|
|
10
|
+
/// @notice Thrown when the desired output cannot be achieved (e.g., cash out tax rate is 100%).
|
|
11
|
+
error JBCashOuts_DesiredOutputNotAchievable();
|
|
12
|
+
|
|
13
|
+
/// @notice Returns the amount of surplus terminal tokens which can be reclaimed based on the total surplus, the
|
|
14
|
+
/// number of tokens being cashed out, the total token supply, and the ruleset's cash out tax rate.
|
|
15
|
+
/// @param surplus The total amount of surplus terminal tokens.
|
|
16
|
+
/// @param cashOutCount The number of tokens being cashed out, as a fixed point number with 18 decimals.
|
|
17
|
+
/// @param totalSupply The total token supply, as a fixed point number with 18 decimals.
|
|
18
|
+
/// @param cashOutTaxRate The current ruleset's cash out tax rate.
|
|
19
|
+
/// @return reclaimableSurplus The amount of surplus tokens that can be reclaimed.
|
|
20
|
+
function cashOutFrom(
|
|
21
|
+
uint256 surplus,
|
|
22
|
+
uint256 cashOutCount,
|
|
23
|
+
uint256 totalSupply,
|
|
24
|
+
uint256 cashOutTaxRate
|
|
25
|
+
)
|
|
26
|
+
internal
|
|
27
|
+
pure
|
|
28
|
+
returns (uint256)
|
|
29
|
+
{
|
|
30
|
+
// If nothing is being cashed out, nothing can be reclaimed.
|
|
31
|
+
if (cashOutCount == 0) return 0;
|
|
32
|
+
|
|
33
|
+
// If the cash out tax rate is the max, no surplus can be reclaimed.
|
|
34
|
+
if (cashOutTaxRate == JBConstants.MAX_CASH_OUT_TAX_RATE) return 0;
|
|
35
|
+
|
|
36
|
+
// If the total supply is being cashed out, return the entire surplus.
|
|
37
|
+
if (cashOutCount >= totalSupply) return surplus;
|
|
38
|
+
|
|
39
|
+
// Get a reference to the linear proportion.
|
|
40
|
+
uint256 base = mulDiv(surplus, cashOutCount, totalSupply);
|
|
41
|
+
|
|
42
|
+
// These conditions are all part of the same curve.
|
|
43
|
+
// Edge conditions are separated to minimize the operations performed in those cases.
|
|
44
|
+
if (cashOutTaxRate == 0) {
|
|
45
|
+
return base;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return mulDiv(
|
|
49
|
+
base,
|
|
50
|
+
(JBConstants.MAX_CASH_OUT_TAX_RATE - cashOutTaxRate) + mulDiv(cashOutTaxRate, cashOutCount, totalSupply),
|
|
51
|
+
JBConstants.MAX_CASH_OUT_TAX_RATE
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// @notice Returns the minimum number of tokens that must be cashed out to receive at least `desiredOutput` of
|
|
56
|
+
/// surplus terminal tokens. This is the inverse of `cashOutFrom`.
|
|
57
|
+
/// @dev Due to integer rounding in `cashOutFrom`, the returned count may yield slightly more than `desiredOutput`.
|
|
58
|
+
/// When `desiredOutput >= surplus`, returns `totalSupply` (cashing out everything yields the full surplus).
|
|
59
|
+
/// @param surplus The total amount of surplus terminal tokens.
|
|
60
|
+
/// @param desiredOutput The minimum amount of surplus tokens the caller wants to receive.
|
|
61
|
+
/// @param totalSupply The total token supply, as a fixed point number with 18 decimals.
|
|
62
|
+
/// @param cashOutTaxRate The current ruleset's cash out tax rate.
|
|
63
|
+
/// @return count The minimum number of tokens to cash out.
|
|
64
|
+
function minCashOutCountFor(
|
|
65
|
+
uint256 surplus,
|
|
66
|
+
uint256 desiredOutput,
|
|
67
|
+
uint256 totalSupply,
|
|
68
|
+
uint256 cashOutTaxRate
|
|
69
|
+
)
|
|
70
|
+
internal
|
|
71
|
+
pure
|
|
72
|
+
returns (uint256)
|
|
73
|
+
{
|
|
74
|
+
// If no output is desired, no tokens need to be cashed out.
|
|
75
|
+
if (desiredOutput == 0) return 0;
|
|
76
|
+
|
|
77
|
+
// If the cash out tax rate is at maximum, no output is achievable.
|
|
78
|
+
if (cashOutTaxRate == JBConstants.MAX_CASH_OUT_TAX_RATE) {
|
|
79
|
+
revert JBCashOuts_DesiredOutputNotAchievable();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// If the desired output meets or exceeds the surplus, the entire supply must be cashed out.
|
|
83
|
+
if (desiredOutput >= surplus) return totalSupply;
|
|
84
|
+
|
|
85
|
+
// Linear case (no tax): out = surplus * c / totalSupply, so c = ceil(out * totalSupply / surplus).
|
|
86
|
+
if (cashOutTaxRate == 0) {
|
|
87
|
+
uint256 count = mulDiv(desiredOutput, totalSupply, surplus);
|
|
88
|
+
// Round up if the floor division undershoots.
|
|
89
|
+
if (mulDiv(surplus, count, totalSupply) < desiredOutput) count++;
|
|
90
|
+
return count;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// General case: binary search for the minimum c such that
|
|
94
|
+
// cashOutFrom(surplus, c, totalSupply, cashOutTaxRate) >= desiredOutput.
|
|
95
|
+
//
|
|
96
|
+
// The forward formula out = (S*c/T) * [(m-r) + r*c/T] / m is monotonically non-decreasing in c,
|
|
97
|
+
// so binary search is valid. We know:
|
|
98
|
+
// - cashOutFrom(surplus, 0, totalSupply, r) = 0 < desiredOutput
|
|
99
|
+
// - cashOutFrom(surplus, totalSupply, totalSupply, r) = surplus > desiredOutput
|
|
100
|
+
// so a valid answer always exists in [1, totalSupply].
|
|
101
|
+
|
|
102
|
+
uint256 lo = 1;
|
|
103
|
+
uint256 hi = totalSupply;
|
|
104
|
+
|
|
105
|
+
while (lo < hi) {
|
|
106
|
+
uint256 mid = lo + (hi - lo) / 2;
|
|
107
|
+
if (
|
|
108
|
+
cashOutFrom({
|
|
109
|
+
surplus: surplus, cashOutCount: mid, totalSupply: totalSupply, cashOutTaxRate: cashOutTaxRate
|
|
110
|
+
}) >= desiredOutput
|
|
111
|
+
) {
|
|
112
|
+
hi = mid;
|
|
113
|
+
} else {
|
|
114
|
+
lo = mid + 1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return lo;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/// @notice Global constants used across Juicebox contracts.
|
|
5
|
+
library JBConstants {
|
|
6
|
+
/// @notice Each chain's native token address in Juicebox is represented by
|
|
7
|
+
/// 0x000000000000000000000000000000000000EEEe.
|
|
8
|
+
address public constant NATIVE_TOKEN = address(0x000000000000000000000000000000000000EEEe);
|
|
9
|
+
uint16 public constant MAX_RESERVED_PERCENT = 10_000;
|
|
10
|
+
uint16 public constant MAX_CASH_OUT_TAX_RATE = 10_000;
|
|
11
|
+
uint32 public constant MAX_WEIGHT_CUT_PERCENT = 1_000_000_000;
|
|
12
|
+
uint32 public constant SPLITS_TOTAL_PERCENT = 1_000_000_000;
|
|
13
|
+
uint16 public constant MAX_FEE = 1000;
|
|
14
|
+
}
|