@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,731 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.6;
|
|
3
|
+
|
|
4
|
+
import /* {*} from */ "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
6
|
+
import {ERC165, IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
7
|
+
|
|
8
|
+
/// @notice Tests for split loop edge cases: circular splits, reentrancy, gas consumption, rounding.
|
|
9
|
+
contract SplitLoopTests_Local is TestBaseWorkflow {
|
|
10
|
+
using JBRulesetMetadataResolver for JBRuleset;
|
|
11
|
+
|
|
12
|
+
uint256 public projectA;
|
|
13
|
+
uint256 public projectB;
|
|
14
|
+
address public projectOwner;
|
|
15
|
+
|
|
16
|
+
function setUp() public override {
|
|
17
|
+
super.setUp();
|
|
18
|
+
projectOwner = multisig();
|
|
19
|
+
|
|
20
|
+
// Launch fee collector project (#1)
|
|
21
|
+
_launchFeeProject();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
25
|
+
// Helpers
|
|
26
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
27
|
+
|
|
28
|
+
function _launchFeeProject() internal {
|
|
29
|
+
JBRulesetConfig[] memory feeRulesetConfig = new JBRulesetConfig[](1);
|
|
30
|
+
feeRulesetConfig[0].mustStartAtOrAfter = 0;
|
|
31
|
+
feeRulesetConfig[0].duration = 0;
|
|
32
|
+
feeRulesetConfig[0].weight = 1000e18;
|
|
33
|
+
feeRulesetConfig[0].weightCutPercent = 0;
|
|
34
|
+
feeRulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
35
|
+
feeRulesetConfig[0].metadata = JBRulesetMetadata({
|
|
36
|
+
reservedPercent: 0,
|
|
37
|
+
cashOutTaxRate: 0,
|
|
38
|
+
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
39
|
+
pausePay: false,
|
|
40
|
+
pauseCreditTransfers: false,
|
|
41
|
+
allowOwnerMinting: false,
|
|
42
|
+
allowSetCustomToken: false,
|
|
43
|
+
allowTerminalMigration: false,
|
|
44
|
+
allowSetTerminals: false,
|
|
45
|
+
ownerMustSendPayouts: false,
|
|
46
|
+
allowSetController: false,
|
|
47
|
+
allowAddAccountingContext: true,
|
|
48
|
+
allowAddPriceFeed: false,
|
|
49
|
+
holdFees: false,
|
|
50
|
+
useTotalSurplusForCashOuts: false,
|
|
51
|
+
useDataHookForPay: false,
|
|
52
|
+
useDataHookForCashOut: false,
|
|
53
|
+
dataHook: address(0),
|
|
54
|
+
metadata: 0
|
|
55
|
+
});
|
|
56
|
+
feeRulesetConfig[0].splitGroups = new JBSplitGroup[](0);
|
|
57
|
+
feeRulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
|
|
58
|
+
|
|
59
|
+
JBTerminalConfig[] memory terminalConfigurations = _defaultTerminalConfig();
|
|
60
|
+
|
|
61
|
+
jbController()
|
|
62
|
+
.launchProjectFor({
|
|
63
|
+
owner: address(420),
|
|
64
|
+
projectUri: "feeCollector",
|
|
65
|
+
rulesetConfigurations: feeRulesetConfig,
|
|
66
|
+
terminalConfigurations: terminalConfigurations,
|
|
67
|
+
memo: ""
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _defaultTerminalConfig() internal view returns (JBTerminalConfig[] memory) {
|
|
72
|
+
JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
|
|
73
|
+
JBAccountingContext[] memory tokensToAccept = new JBAccountingContext[](1);
|
|
74
|
+
tokensToAccept[0] = JBAccountingContext({
|
|
75
|
+
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
76
|
+
});
|
|
77
|
+
terminalConfigurations[0] =
|
|
78
|
+
JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: tokensToAccept});
|
|
79
|
+
return terminalConfigurations;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function _launchProjectWithSplitsAndPayoutLimit(
|
|
83
|
+
JBSplit[] memory splits,
|
|
84
|
+
uint256 payoutLimit
|
|
85
|
+
)
|
|
86
|
+
internal
|
|
87
|
+
returns (uint256)
|
|
88
|
+
{
|
|
89
|
+
JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
|
|
90
|
+
rulesetConfig[0].mustStartAtOrAfter = 0;
|
|
91
|
+
rulesetConfig[0].duration = 0;
|
|
92
|
+
rulesetConfig[0].weight = 1000e18;
|
|
93
|
+
rulesetConfig[0].weightCutPercent = 0;
|
|
94
|
+
rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
95
|
+
rulesetConfig[0].metadata = JBRulesetMetadata({
|
|
96
|
+
reservedPercent: 0,
|
|
97
|
+
cashOutTaxRate: 0,
|
|
98
|
+
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
99
|
+
pausePay: false,
|
|
100
|
+
pauseCreditTransfers: false,
|
|
101
|
+
allowOwnerMinting: true,
|
|
102
|
+
allowSetCustomToken: true,
|
|
103
|
+
allowTerminalMigration: false,
|
|
104
|
+
allowSetTerminals: false,
|
|
105
|
+
ownerMustSendPayouts: false,
|
|
106
|
+
allowSetController: false,
|
|
107
|
+
allowAddAccountingContext: true,
|
|
108
|
+
allowAddPriceFeed: false,
|
|
109
|
+
holdFees: false,
|
|
110
|
+
useTotalSurplusForCashOuts: false,
|
|
111
|
+
useDataHookForPay: false,
|
|
112
|
+
useDataHookForCashOut: false,
|
|
113
|
+
dataHook: address(0),
|
|
114
|
+
metadata: 0
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
JBSplitGroup[] memory splitGroups = new JBSplitGroup[](1);
|
|
118
|
+
splitGroups[0] = JBSplitGroup({groupId: uint256(uint160(JBConstants.NATIVE_TOKEN)), splits: splits});
|
|
119
|
+
rulesetConfig[0].splitGroups = splitGroups;
|
|
120
|
+
|
|
121
|
+
JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](1);
|
|
122
|
+
payoutLimits[0] =
|
|
123
|
+
JBCurrencyAmount({amount: uint224(payoutLimit), currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
|
|
124
|
+
JBFundAccessLimitGroup[] memory fundAccessLimitGroups = new JBFundAccessLimitGroup[](1);
|
|
125
|
+
fundAccessLimitGroups[0] = JBFundAccessLimitGroup({
|
|
126
|
+
terminal: address(jbMultiTerminal()),
|
|
127
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
128
|
+
payoutLimits: payoutLimits,
|
|
129
|
+
surplusAllowances: new JBCurrencyAmount[](0)
|
|
130
|
+
});
|
|
131
|
+
rulesetConfig[0].fundAccessLimitGroups = fundAccessLimitGroups;
|
|
132
|
+
|
|
133
|
+
return jbController()
|
|
134
|
+
.launchProjectFor({
|
|
135
|
+
owner: projectOwner,
|
|
136
|
+
projectUri: "splitTestProject",
|
|
137
|
+
rulesetConfigurations: rulesetConfig,
|
|
138
|
+
terminalConfigurations: _defaultTerminalConfig(),
|
|
139
|
+
memo: ""
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function _payProject(uint256 pid, address payer, uint256 amount) internal {
|
|
144
|
+
vm.deal(payer, amount);
|
|
145
|
+
vm.prank(payer);
|
|
146
|
+
jbMultiTerminal().pay{value: amount}({
|
|
147
|
+
projectId: pid,
|
|
148
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
149
|
+
amount: amount,
|
|
150
|
+
beneficiary: payer,
|
|
151
|
+
minReturnedTokens: 0,
|
|
152
|
+
memo: "",
|
|
153
|
+
metadata: new bytes(0)
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
158
|
+
// Test 1: Circular splits A→B, B→A via addToBalance — no loop
|
|
159
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
160
|
+
|
|
161
|
+
function test_circularSplits_AtoB_addToBalance_noLoop() public {
|
|
162
|
+
// Project A splits to project B (preferAddToBalance=true)
|
|
163
|
+
JBSplit[] memory splitsA = new JBSplit[](1);
|
|
164
|
+
splitsA[0] = JBSplit({
|
|
165
|
+
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
|
|
166
|
+
projectId: 0, // Will set after B is created
|
|
167
|
+
beneficiary: payable(address(0)),
|
|
168
|
+
preferAddToBalance: true,
|
|
169
|
+
lockedUntil: 0,
|
|
170
|
+
hook: IJBSplitHook(address(0))
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Project B splits to project A (preferAddToBalance=true)
|
|
174
|
+
JBSplit[] memory splitsB = new JBSplit[](1);
|
|
175
|
+
splitsB[0] = JBSplit({
|
|
176
|
+
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
|
|
177
|
+
projectId: 0, // Will set after A is created
|
|
178
|
+
beneficiary: payable(address(0)),
|
|
179
|
+
preferAddToBalance: true,
|
|
180
|
+
lockedUntil: 0,
|
|
181
|
+
hook: IJBSplitHook(address(0))
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Launch A first (with dummy splits, we'll update later)
|
|
185
|
+
JBSplit[] memory dummySplits = new JBSplit[](0);
|
|
186
|
+
projectA = _launchProjectWithSplitsAndPayoutLimit(dummySplits, 10 ether);
|
|
187
|
+
|
|
188
|
+
// Now create B with split to A
|
|
189
|
+
splitsB[0].projectId = uint64(projectA);
|
|
190
|
+
projectB = _launchProjectWithSplitsAndPayoutLimit(splitsB, 10 ether);
|
|
191
|
+
|
|
192
|
+
// Update A's splits to point to B
|
|
193
|
+
(JBRuleset memory rulesetA,) = jbController().currentRulesetOf(projectA);
|
|
194
|
+
JBSplitGroup[] memory newSplitGroupsA = new JBSplitGroup[](1);
|
|
195
|
+
splitsA[0].projectId = uint64(projectB);
|
|
196
|
+
newSplitGroupsA[0] = JBSplitGroup({groupId: uint256(uint160(JBConstants.NATIVE_TOKEN)), splits: splitsA});
|
|
197
|
+
vm.prank(projectOwner);
|
|
198
|
+
jbController().setSplitGroupsOf(projectA, rulesetA.id, newSplitGroupsA);
|
|
199
|
+
|
|
200
|
+
// Fund project A
|
|
201
|
+
_payProject(projectA, address(0xBA1E), 10 ether);
|
|
202
|
+
|
|
203
|
+
// Send payouts from A → should send to B via addToBalance (hook-free, no loop)
|
|
204
|
+
vm.prank(projectOwner);
|
|
205
|
+
jbMultiTerminal()
|
|
206
|
+
.sendPayoutsOf({
|
|
207
|
+
projectId: projectA,
|
|
208
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
209
|
+
amount: 5 ether,
|
|
210
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
211
|
+
minTokensPaidOut: 0
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// B should have received funds
|
|
215
|
+
uint256 balanceB = jbTerminalStore().balanceOf(address(jbMultiTerminal()), projectB, JBConstants.NATIVE_TOKEN);
|
|
216
|
+
assertTrue(balanceB > 0, "Project B should have received funds from A's payout split");
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
220
|
+
// Test 2: Circular splits A→B via pay — no loop
|
|
221
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
222
|
+
|
|
223
|
+
function test_circularSplits_AtoB_pay_noLoop() public {
|
|
224
|
+
// Project A splits to project B via pay (preferAddToBalance=false)
|
|
225
|
+
JBSplit[] memory splitsA = new JBSplit[](1);
|
|
226
|
+
splitsA[0] = JBSplit({
|
|
227
|
+
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
|
|
228
|
+
projectId: 0,
|
|
229
|
+
beneficiary: payable(projectOwner),
|
|
230
|
+
preferAddToBalance: false,
|
|
231
|
+
lockedUntil: 0,
|
|
232
|
+
hook: IJBSplitHook(address(0))
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
projectA = _launchProjectWithSplitsAndPayoutLimit(new JBSplit[](0), 10 ether);
|
|
236
|
+
|
|
237
|
+
splitsA[0].projectId = 1; // Fee project, for simplicity
|
|
238
|
+
projectB = projectA; // Reuse
|
|
239
|
+
|
|
240
|
+
// Update A to split to fee project via pay
|
|
241
|
+
(JBRuleset memory rulesetA,) = jbController().currentRulesetOf(projectA);
|
|
242
|
+
JBSplitGroup[] memory newSplitGroups = new JBSplitGroup[](1);
|
|
243
|
+
splitsA[0].projectId = 1;
|
|
244
|
+
newSplitGroups[0] = JBSplitGroup({groupId: uint256(uint160(JBConstants.NATIVE_TOKEN)), splits: splitsA});
|
|
245
|
+
vm.prank(projectOwner);
|
|
246
|
+
jbController().setSplitGroupsOf(projectA, rulesetA.id, newSplitGroups);
|
|
247
|
+
|
|
248
|
+
// Fund and send payouts
|
|
249
|
+
_payProject(projectA, address(0xBA1E), 10 ether);
|
|
250
|
+
|
|
251
|
+
vm.prank(projectOwner);
|
|
252
|
+
jbMultiTerminal()
|
|
253
|
+
.sendPayoutsOf({
|
|
254
|
+
projectId: projectA,
|
|
255
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
256
|
+
amount: 5 ether,
|
|
257
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
258
|
+
minTokensPaidOut: 0
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// Should complete without infinite recursion
|
|
262
|
+
assertTrue(true, "Pay-based split should not cause infinite recursion");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
266
|
+
// Test 3: Split hook reentrancy — pay during split
|
|
267
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
268
|
+
|
|
269
|
+
function test_splitHookReentrancy_payDuringSplit() public {
|
|
270
|
+
ReentrantSplitHookPay reentrantHook = new ReentrantSplitHookPay(jbMultiTerminal());
|
|
271
|
+
|
|
272
|
+
JBSplit[] memory splits = new JBSplit[](1);
|
|
273
|
+
splits[0] = JBSplit({
|
|
274
|
+
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
|
|
275
|
+
projectId: 0,
|
|
276
|
+
beneficiary: payable(address(reentrantHook)),
|
|
277
|
+
preferAddToBalance: false,
|
|
278
|
+
lockedUntil: 0,
|
|
279
|
+
hook: IJBSplitHook(address(reentrantHook))
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
uint256 pid = _launchProjectWithSplitsAndPayoutLimit(splits, 10 ether);
|
|
283
|
+
reentrantHook.setTargetProject(pid);
|
|
284
|
+
|
|
285
|
+
// Fund
|
|
286
|
+
_payProject(pid, address(0xBA1E), 10 ether);
|
|
287
|
+
|
|
288
|
+
// Send payouts — hook tries to re-enter via pay
|
|
289
|
+
// This should either revert or complete safely (hook is try/caught)
|
|
290
|
+
vm.prank(projectOwner);
|
|
291
|
+
jbMultiTerminal()
|
|
292
|
+
.sendPayoutsOf({
|
|
293
|
+
projectId: pid,
|
|
294
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
295
|
+
amount: 5 ether,
|
|
296
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
297
|
+
minTokensPaidOut: 0
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// If we got here, the system handled reentrancy safely
|
|
301
|
+
assertTrue(true, "System handled split hook reentrancy via pay");
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
305
|
+
// Test 4: Split hook reentrancy — cashOut during split
|
|
306
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
307
|
+
|
|
308
|
+
function test_splitHookReentrancy_cashOutDuringSplit() public {
|
|
309
|
+
ReentrantSplitHookCashOut reentrantHook = new ReentrantSplitHookCashOut(jbMultiTerminal());
|
|
310
|
+
|
|
311
|
+
JBSplit[] memory splits = new JBSplit[](1);
|
|
312
|
+
splits[0] = JBSplit({
|
|
313
|
+
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
|
|
314
|
+
projectId: 0,
|
|
315
|
+
beneficiary: payable(address(reentrantHook)),
|
|
316
|
+
preferAddToBalance: false,
|
|
317
|
+
lockedUntil: 0,
|
|
318
|
+
hook: IJBSplitHook(address(reentrantHook))
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
uint256 pid = _launchProjectWithSplitsAndPayoutLimit(splits, 10 ether);
|
|
322
|
+
reentrantHook.setTargetProject(pid);
|
|
323
|
+
|
|
324
|
+
// Fund — reentrant hook needs tokens to cash out
|
|
325
|
+
// Seed the fee project so it has funds (not needed for this test)
|
|
326
|
+
_payProject(pid, address(0xBA1E), 10 ether);
|
|
327
|
+
|
|
328
|
+
// Setup: give hook tokens for the target project
|
|
329
|
+
vm.deal(address(reentrantHook), 5 ether);
|
|
330
|
+
vm.prank(address(reentrantHook));
|
|
331
|
+
jbMultiTerminal().pay{value: 5 ether}({
|
|
332
|
+
projectId: pid,
|
|
333
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
334
|
+
amount: 5 ether,
|
|
335
|
+
beneficiary: address(reentrantHook),
|
|
336
|
+
minReturnedTokens: 0,
|
|
337
|
+
memo: "",
|
|
338
|
+
metadata: new bytes(0)
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// Send payouts — hook tries to re-enter via cashOut
|
|
342
|
+
vm.prank(projectOwner);
|
|
343
|
+
jbMultiTerminal()
|
|
344
|
+
.sendPayoutsOf({
|
|
345
|
+
projectId: pid,
|
|
346
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
347
|
+
amount: 5 ether,
|
|
348
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
349
|
+
minTokensPaidOut: 0
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// If we got here, the system handled cashOut reentrancy safely
|
|
353
|
+
assertTrue(true, "System handled split hook reentrancy via cashOut");
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
357
|
+
// Test 5: Split to self — no infinite recursion
|
|
358
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
359
|
+
|
|
360
|
+
function test_splitToSelf_noInfiniteRecursion() public {
|
|
361
|
+
// Project splits to itself via addToBalance
|
|
362
|
+
JBSplit[] memory splits = new JBSplit[](1);
|
|
363
|
+
splits[0] = JBSplit({
|
|
364
|
+
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
|
|
365
|
+
projectId: 0, // Will set to self
|
|
366
|
+
beneficiary: payable(address(0)),
|
|
367
|
+
preferAddToBalance: true,
|
|
368
|
+
lockedUntil: 0,
|
|
369
|
+
hook: IJBSplitHook(address(0))
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
uint256 pid = _launchProjectWithSplitsAndPayoutLimit(new JBSplit[](0), 10 ether);
|
|
373
|
+
|
|
374
|
+
// Update splits to point to self
|
|
375
|
+
splits[0].projectId = uint64(pid);
|
|
376
|
+
(JBRuleset memory ruleset,) = jbController().currentRulesetOf(pid);
|
|
377
|
+
JBSplitGroup[] memory newSplitGroups = new JBSplitGroup[](1);
|
|
378
|
+
newSplitGroups[0] = JBSplitGroup({groupId: uint256(uint160(JBConstants.NATIVE_TOKEN)), splits: splits});
|
|
379
|
+
vm.prank(projectOwner);
|
|
380
|
+
jbController().setSplitGroupsOf(pid, ruleset.id, newSplitGroups);
|
|
381
|
+
|
|
382
|
+
// Fund
|
|
383
|
+
_payProject(pid, address(0xBA1E), 10 ether);
|
|
384
|
+
|
|
385
|
+
// Send payouts — self-split via addToBalance is hook-free, should complete
|
|
386
|
+
vm.prank(projectOwner);
|
|
387
|
+
jbMultiTerminal()
|
|
388
|
+
.sendPayoutsOf({
|
|
389
|
+
projectId: pid,
|
|
390
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
391
|
+
amount: 5 ether,
|
|
392
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
393
|
+
minTokensPaidOut: 0
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
assertTrue(true, "Self-split via addToBalance completes without infinite loop");
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
400
|
+
// Test 6: Many small splits — gas consumption
|
|
401
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
402
|
+
|
|
403
|
+
function test_manySmallSplits_gasConsumption() public {
|
|
404
|
+
uint256 numSplits = 200;
|
|
405
|
+
JBSplit[] memory splits = new JBSplit[](numSplits);
|
|
406
|
+
|
|
407
|
+
uint32 perSplitPercent = uint32(JBConstants.SPLITS_TOTAL_PERCENT / numSplits);
|
|
408
|
+
|
|
409
|
+
for (uint256 i = 0; i < numSplits; i++) {
|
|
410
|
+
splits[i] = JBSplit({
|
|
411
|
+
percent: perSplitPercent,
|
|
412
|
+
projectId: 0,
|
|
413
|
+
beneficiary: payable(address(uint160(0x3000 + i))),
|
|
414
|
+
preferAddToBalance: false,
|
|
415
|
+
lockedUntil: 0,
|
|
416
|
+
hook: IJBSplitHook(address(0))
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
uint256 pid = _launchProjectWithSplitsAndPayoutLimit(splits, 10 ether);
|
|
421
|
+
|
|
422
|
+
// Fund
|
|
423
|
+
_payProject(pid, address(0xBA1E), 10 ether);
|
|
424
|
+
|
|
425
|
+
// Measure gas
|
|
426
|
+
uint256 gasStart = gasleft();
|
|
427
|
+
vm.prank(projectOwner);
|
|
428
|
+
jbMultiTerminal()
|
|
429
|
+
.sendPayoutsOf({
|
|
430
|
+
projectId: pid,
|
|
431
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
432
|
+
amount: 5 ether,
|
|
433
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
434
|
+
minTokensPaidOut: 0
|
|
435
|
+
});
|
|
436
|
+
uint256 gasUsed = gasStart - gasleft();
|
|
437
|
+
|
|
438
|
+
// Should complete within block gas limit (~30M)
|
|
439
|
+
assertLt(gasUsed, 30_000_000, "200 splits should complete within block gas limit");
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
443
|
+
// Test 7: Split percentages rounding favor
|
|
444
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
445
|
+
|
|
446
|
+
function test_splitPercentages_roundingFavor() public {
|
|
447
|
+
// 3 splits at ~33.33% each
|
|
448
|
+
uint32 oneThird = uint32(JBConstants.SPLITS_TOTAL_PERCENT / 3);
|
|
449
|
+
|
|
450
|
+
JBSplit[] memory splits = new JBSplit[](3);
|
|
451
|
+
for (uint256 i = 0; i < 3; i++) {
|
|
452
|
+
splits[i] = JBSplit({
|
|
453
|
+
percent: oneThird,
|
|
454
|
+
projectId: 0,
|
|
455
|
+
beneficiary: payable(address(uint160(0x4000 + i))),
|
|
456
|
+
preferAddToBalance: false,
|
|
457
|
+
lockedUntil: 0,
|
|
458
|
+
hook: IJBSplitHook(address(0))
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
uint256 pid = _launchProjectWithSplitsAndPayoutLimit(splits, 10 ether);
|
|
463
|
+
|
|
464
|
+
_payProject(pid, address(0xBA1E), 10 ether);
|
|
465
|
+
|
|
466
|
+
uint256 totalBefore = address(jbMultiTerminal()).balance;
|
|
467
|
+
|
|
468
|
+
vm.prank(projectOwner);
|
|
469
|
+
uint256 netLeftover = jbMultiTerminal()
|
|
470
|
+
.sendPayoutsOf({
|
|
471
|
+
projectId: pid,
|
|
472
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
473
|
+
amount: 3 ether,
|
|
474
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
475
|
+
minTokensPaidOut: 0
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// Check no rounding loss greater than 3 wei (one per split)
|
|
479
|
+
uint256 totalPaidToSplits = 0;
|
|
480
|
+
for (uint256 i = 0; i < 3; i++) {
|
|
481
|
+
totalPaidToSplits += address(uint160(0x4000 + i)).balance;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// The difference between what was deducted and what splits received should be minimal
|
|
485
|
+
// (just fees and rounding)
|
|
486
|
+
assertTrue(totalPaidToSplits > 0, "Splits should have received something");
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
490
|
+
// Test 8: Split percentage overflow rejected
|
|
491
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
492
|
+
|
|
493
|
+
function test_splitPercentageOverflow_rejected() public {
|
|
494
|
+
// Two splits totaling > 100%
|
|
495
|
+
JBSplit[] memory splits = new JBSplit[](2);
|
|
496
|
+
splits[0] = JBSplit({
|
|
497
|
+
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
|
|
498
|
+
projectId: 0,
|
|
499
|
+
beneficiary: payable(address(0x5000)),
|
|
500
|
+
preferAddToBalance: false,
|
|
501
|
+
lockedUntil: 0,
|
|
502
|
+
hook: IJBSplitHook(address(0))
|
|
503
|
+
});
|
|
504
|
+
splits[1] = JBSplit({
|
|
505
|
+
percent: 1,
|
|
506
|
+
projectId: 0,
|
|
507
|
+
beneficiary: payable(address(0x5001)),
|
|
508
|
+
preferAddToBalance: false,
|
|
509
|
+
lockedUntil: 0,
|
|
510
|
+
hook: IJBSplitHook(address(0))
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
JBRulesetConfig[] memory rulesetConfig = new JBRulesetConfig[](1);
|
|
514
|
+
rulesetConfig[0].mustStartAtOrAfter = 0;
|
|
515
|
+
rulesetConfig[0].duration = 0;
|
|
516
|
+
rulesetConfig[0].weight = 1000e18;
|
|
517
|
+
rulesetConfig[0].weightCutPercent = 0;
|
|
518
|
+
rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
519
|
+
rulesetConfig[0].metadata = JBRulesetMetadata({
|
|
520
|
+
reservedPercent: 0,
|
|
521
|
+
cashOutTaxRate: 0,
|
|
522
|
+
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
523
|
+
pausePay: false,
|
|
524
|
+
pauseCreditTransfers: false,
|
|
525
|
+
allowOwnerMinting: true,
|
|
526
|
+
allowSetCustomToken: true,
|
|
527
|
+
allowTerminalMigration: false,
|
|
528
|
+
allowSetTerminals: false,
|
|
529
|
+
ownerMustSendPayouts: false,
|
|
530
|
+
allowSetController: false,
|
|
531
|
+
allowAddAccountingContext: true,
|
|
532
|
+
allowAddPriceFeed: false,
|
|
533
|
+
holdFees: false,
|
|
534
|
+
useTotalSurplusForCashOuts: false,
|
|
535
|
+
useDataHookForPay: false,
|
|
536
|
+
useDataHookForCashOut: false,
|
|
537
|
+
dataHook: address(0),
|
|
538
|
+
metadata: 0
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
JBSplitGroup[] memory splitGroups = new JBSplitGroup[](1);
|
|
542
|
+
splitGroups[0] = JBSplitGroup({groupId: uint256(uint160(JBConstants.NATIVE_TOKEN)), splits: splits});
|
|
543
|
+
rulesetConfig[0].splitGroups = splitGroups;
|
|
544
|
+
rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
|
|
545
|
+
|
|
546
|
+
// Should revert because splits total > 100%
|
|
547
|
+
vm.expectRevert();
|
|
548
|
+
jbController()
|
|
549
|
+
.launchProjectFor({
|
|
550
|
+
owner: projectOwner,
|
|
551
|
+
projectUri: "overflowSplitTest",
|
|
552
|
+
rulesetConfigurations: rulesetConfig,
|
|
553
|
+
terminalConfigurations: _defaultTerminalConfig(),
|
|
554
|
+
memo: ""
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
559
|
+
// Test 9: Gas guzzling split hook — fallback
|
|
560
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
561
|
+
|
|
562
|
+
function test_gasGuzzlingSplitHook_fallback() public {
|
|
563
|
+
GasGuzzlingSplitHook gasHook = new GasGuzzlingSplitHook();
|
|
564
|
+
|
|
565
|
+
JBSplit[] memory splits = new JBSplit[](1);
|
|
566
|
+
splits[0] = JBSplit({
|
|
567
|
+
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
|
|
568
|
+
projectId: 0,
|
|
569
|
+
beneficiary: payable(address(gasHook)),
|
|
570
|
+
preferAddToBalance: false,
|
|
571
|
+
lockedUntil: 0,
|
|
572
|
+
hook: IJBSplitHook(address(gasHook))
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
uint256 pid = _launchProjectWithSplitsAndPayoutLimit(splits, 10 ether);
|
|
576
|
+
|
|
577
|
+
_payProject(pid, address(0xBA1E), 10 ether);
|
|
578
|
+
|
|
579
|
+
// Send payouts — gas guzzling hook should be caught by try/catch
|
|
580
|
+
vm.prank(projectOwner);
|
|
581
|
+
jbMultiTerminal()
|
|
582
|
+
.sendPayoutsOf({
|
|
583
|
+
projectId: pid,
|
|
584
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
585
|
+
amount: 5 ether,
|
|
586
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
587
|
+
minTokensPaidOut: 0
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// If we get here, the try/catch fallback worked
|
|
591
|
+
assertTrue(true, "Gas guzzling split hook handled via try/catch");
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
595
|
+
// Test 10: ETH to non-payable recipient — fallback
|
|
596
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
597
|
+
|
|
598
|
+
function test_splitHook_ETH_nonPayableRecipient() public {
|
|
599
|
+
NonPayableContract nonPayable = new NonPayableContract();
|
|
600
|
+
|
|
601
|
+
JBSplit[] memory splits = new JBSplit[](1);
|
|
602
|
+
splits[0] = JBSplit({
|
|
603
|
+
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
|
|
604
|
+
projectId: 0,
|
|
605
|
+
beneficiary: payable(address(nonPayable)),
|
|
606
|
+
preferAddToBalance: false,
|
|
607
|
+
lockedUntil: 0,
|
|
608
|
+
hook: IJBSplitHook(address(0))
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
uint256 pid = _launchProjectWithSplitsAndPayoutLimit(splits, 10 ether);
|
|
612
|
+
|
|
613
|
+
_payProject(pid, address(0xBA1E), 10 ether);
|
|
614
|
+
|
|
615
|
+
// Send payouts to non-payable — should be caught by try/catch
|
|
616
|
+
vm.prank(projectOwner);
|
|
617
|
+
jbMultiTerminal()
|
|
618
|
+
.sendPayoutsOf({
|
|
619
|
+
projectId: pid,
|
|
620
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
621
|
+
amount: 5 ether,
|
|
622
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
623
|
+
minTokensPaidOut: 0
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
// Funds should be retained in the project or sent to owner fallback
|
|
627
|
+
assertTrue(true, "Non-payable recipient handled via try/catch fallback");
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
receive() external payable {}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
634
|
+
// Mock Contracts
|
|
635
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
636
|
+
|
|
637
|
+
/// @notice Split hook that re-enters terminal via pay during processSplitWith.
|
|
638
|
+
contract ReentrantSplitHookPay is ERC165, IJBSplitHook {
|
|
639
|
+
IJBMultiTerminal public terminal;
|
|
640
|
+
uint256 public targetProjectId;
|
|
641
|
+
|
|
642
|
+
constructor(IJBMultiTerminal _terminal) {
|
|
643
|
+
terminal = _terminal;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
function setTargetProject(uint256 pid) external {
|
|
647
|
+
targetProjectId = pid;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function processSplitWith(JBSplitHookContext calldata) external payable override {
|
|
651
|
+
// Try to re-enter via pay
|
|
652
|
+
if (msg.value > 0 && targetProjectId > 0) {
|
|
653
|
+
try terminal.pay{value: msg.value}({
|
|
654
|
+
projectId: targetProjectId,
|
|
655
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
656
|
+
amount: msg.value,
|
|
657
|
+
beneficiary: address(this),
|
|
658
|
+
minReturnedTokens: 0,
|
|
659
|
+
memo: "reentrant",
|
|
660
|
+
metadata: new bytes(0)
|
|
661
|
+
}) {}
|
|
662
|
+
catch {}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function supportsInterface(bytes4 _interfaceId) public view override(IERC165, ERC165) returns (bool) {
|
|
667
|
+
return _interfaceId == type(IJBSplitHook).interfaceId || super.supportsInterface(_interfaceId);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
receive() external payable {}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/// @notice Split hook that re-enters terminal via cashOut during processSplitWith.
|
|
674
|
+
contract ReentrantSplitHookCashOut is ERC165, IJBSplitHook {
|
|
675
|
+
IJBMultiTerminal public terminal;
|
|
676
|
+
uint256 public targetProjectId;
|
|
677
|
+
|
|
678
|
+
constructor(IJBMultiTerminal _terminal) {
|
|
679
|
+
terminal = _terminal;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function setTargetProject(uint256 pid) external {
|
|
683
|
+
targetProjectId = pid;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function processSplitWith(JBSplitHookContext calldata) external payable override {
|
|
687
|
+
// Try to re-enter via cashOut
|
|
688
|
+
if (targetProjectId > 0) {
|
|
689
|
+
IJBTokens tokens = terminal.TOKENS();
|
|
690
|
+
uint256 balance = tokens.totalBalanceOf(address(this), targetProjectId);
|
|
691
|
+
if (balance > 0) {
|
|
692
|
+
try terminal.cashOutTokensOf({
|
|
693
|
+
holder: address(this),
|
|
694
|
+
projectId: targetProjectId,
|
|
695
|
+
cashOutCount: balance,
|
|
696
|
+
tokenToReclaim: JBConstants.NATIVE_TOKEN,
|
|
697
|
+
minTokensReclaimed: 0,
|
|
698
|
+
beneficiary: payable(address(this)),
|
|
699
|
+
metadata: new bytes(0)
|
|
700
|
+
}) {}
|
|
701
|
+
catch {}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
function supportsInterface(bytes4 _interfaceId) public view override(IERC165, ERC165) returns (bool) {
|
|
707
|
+
return _interfaceId == type(IJBSplitHook).interfaceId || super.supportsInterface(_interfaceId);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
receive() external payable {}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/// @notice Split hook that consumes all gas.
|
|
714
|
+
contract GasGuzzlingSplitHook is ERC165, IJBSplitHook {
|
|
715
|
+
function processSplitWith(JBSplitHookContext calldata) external payable override {
|
|
716
|
+
// Infinite loop to consume all gas
|
|
717
|
+
while (true) {}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function supportsInterface(bytes4 _interfaceId) public view override(IERC165, ERC165) returns (bool) {
|
|
721
|
+
return _interfaceId == type(IJBSplitHook).interfaceId || super.supportsInterface(_interfaceId);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
receive() external payable {}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/// @notice Contract that cannot receive ETH.
|
|
728
|
+
contract NonPayableContract {
|
|
729
|
+
// No receive() or fallback() — ETH transfers revert
|
|
730
|
+
|
|
731
|
+
}
|