@bananapus/core-v6 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/foundry.lock +1 -7
- package/foundry.toml +1 -1
- package/package.json +19 -7
- package/src/JBChainlinkV3PriceFeed.sol +4 -1
- package/src/JBChainlinkV3SequencerPriceFeed.sol +4 -2
- package/src/JBController.sol +71 -44
- package/src/JBDeadline.sol +4 -4
- package/src/JBDirectory.sol +34 -32
- package/src/JBERC20.sol +5 -4
- package/src/JBFeelessAddresses.sol +6 -3
- package/src/JBFundAccessLimits.sol +25 -21
- package/src/JBMultiTerminal.sol +121 -84
- package/src/JBPermissions.sol +34 -37
- package/src/JBPrices.sol +23 -18
- package/src/JBProjects.sol +6 -3
- package/src/JBRulesets.sol +44 -41
- package/src/JBSplits.sol +18 -16
- package/src/JBTerminalStore.sol +32 -25
- package/src/JBTokens.sol +36 -26
- package/src/abstract/JBControlled.sol +3 -1
- package/src/abstract/JBPermissioned.sol +3 -1
- package/src/enums/JBApprovalStatus.sol +7 -1
- package/src/interfaces/IJBController.sol +7 -3
- package/src/interfaces/IJBDirectory.sol +3 -1
- package/src/interfaces/IJBMultiTerminal.sol +3 -2
- package/src/interfaces/IJBPermissions.sol +2 -1
- package/src/interfaces/IJBPrices.sol +3 -1
- package/src/interfaces/IJBRulesets.sol +2 -1
- package/src/interfaces/IJBSplits.sol +2 -1
- package/src/interfaces/IJBTerminal.sol +3 -1
- package/src/interfaces/IJBTerminalStore.sol +3 -1
- package/src/interfaces/IJBTokens.sol +2 -1
- package/src/libraries/JBCashOuts.sol +6 -1
- package/src/libraries/JBConstants.sol +12 -3
- package/src/libraries/JBCurrencyIds.sol +2 -0
- package/src/libraries/JBFees.sol +52 -10
- package/src/libraries/JBFixedPointNumber.sol +2 -0
- package/src/libraries/JBPayoutSplitGroupLib.sol +7 -4
- package/src/libraries/JBRulesetMetadataResolver.sol +4 -0
- package/src/libraries/JBSplitGroupIds.sol +2 -1
- package/src/libraries/JBSurplus.sol +3 -1
- package/src/periphery/JBMatchingPriceFeed.sol +3 -1
- package/src/structs/JBAccountingContext.sol +7 -4
- package/src/structs/JBFundAccessLimitGroup.sol +10 -17
- package/src/structs/JBRuleset.sol +18 -26
- package/src/structs/JBRulesetConfig.sol +13 -25
- package/src/structs/JBRulesetMetadata.sol +25 -32
- package/test/mock/MockMaliciousBeneficiary.sol +15 -15
- package/ADMINISTRATION.md +0 -103
- package/ARCHITECTURE.md +0 -133
- package/AUDIT_INSTRUCTIONS.md +0 -139
- package/RISKS.md +0 -215
- package/SKILLS.md +0 -55
- package/STYLE_GUIDE.md +0 -610
- package/USER_JOURNEYS.md +0 -215
- package/script/Deploy.s.sol +0 -124
- package/script/DeployPeriphery.s.sol +0 -354
- package/slither-ci.config.json +0 -10
- package/test/AuditFixes.t.sol +0 -808
- package/test/ComprehensiveInvariant.t.sol +0 -306
- package/test/CoreExploitTests.t.sol +0 -2741
- package/test/EconomicSimulation.t.sol +0 -348
- package/test/EntryPointPermutations.t.sol +0 -684
- package/test/FlashLoanAttacks.t.sol +0 -797
- package/test/PermissionEscalation.t.sol +0 -711
- package/test/PermissionsInvariant.t.sol +0 -403
- package/test/RulesetTransitions.t.sol +0 -713
- package/test/SplitLoopTests.t.sol +0 -752
- package/test/TestAccessToFunds.sol +0 -2683
- package/test/TestAuditResponseDesignProofs.sol +0 -434
- package/test/TestCashOut.sol +0 -198
- package/test/TestCashOutCountFor.sol +0 -271
- package/test/TestCashOutHooks.sol +0 -351
- package/test/TestCashOutTimingEdge.sol +0 -241
- package/test/TestDataHookFuzzing.sol +0 -524
- package/test/TestDurationUnderflow.sol +0 -233
- package/test/TestFeeFreeCashOutBypass.sol +0 -949
- package/test/TestFeeProcessingFailure.sol +0 -218
- package/test/TestFees.sol +0 -619
- package/test/TestForwardedTokenConsumption.sol +0 -425
- package/test/TestInterfaceSupport.sol +0 -81
- package/test/TestJBERC20Inheritance.sol +0 -103
- package/test/TestL2SequencerPriceFeed.sol +0 -292
- package/test/TestLaunchProject.sol +0 -188
- package/test/TestMetaTx.sol +0 -217
- package/test/TestMetadataOffsetOverflow.sol +0 -179
- package/test/TestMetadataParserLib.sol +0 -471
- package/test/TestMigrationHeldFees.sol +0 -255
- package/test/TestMintTokensOf.sol +0 -185
- package/test/TestMultiTerminalSurplus.sol +0 -348
- package/test/TestMultiTokenSurplus.sol +0 -202
- package/test/TestMultipleAccessLimits.sol +0 -664
- package/test/TestPayBurnRedeemFlow.sol +0 -195
- package/test/TestPayHooks.sol +0 -209
- package/test/TestPermissions.sol +0 -324
- package/test/TestPermissionsEdge.sol +0 -290
- package/test/TestPermit2DataHook.t.sol +0 -360
- package/test/TestPermit2Terminal.sol +0 -372
- package/test/TestRulesetQueueing.sol +0 -1025
- package/test/TestRulesetQueuingStress.sol +0 -806
- package/test/TestRulesetWeightCaching.sol +0 -178
- package/test/TestSplits.sol +0 -391
- package/test/TestTerminalMigration.sol +0 -274
- package/test/TestTerminalPreviewParity.sol +0 -208
- package/test/TestTokenFlow.sol +0 -191
- package/test/TestWeightCacheStaleAfterRejection.sol +0 -303
- package/test/WeirdTokenTests.t.sol +0 -817
- package/test/audit/CashOutReenterPay.t.sol +0 -501
- package/test/audit/CodexHeldFeeRounding.t.sol +0 -159
- package/test/audit/CodexMigrationFeeFailure.t.sol +0 -163
- package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
- package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
- package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
- package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
- package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
- package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
- package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
- package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
- package/test/formal/BondingCurveProperties.t.sol +0 -420
- package/test/formal/FeeProperties.t.sol +0 -252
- package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
- package/test/invariants/RulesetsInvariant.t.sol +0 -125
- package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
- package/test/invariants/TokensInvariant.t.sol +0 -195
- package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
- package/test/invariants/handlers/EconomicHandler.sol +0 -377
- package/test/invariants/handlers/Phase3Handler.sol +0 -443
- package/test/invariants/handlers/RulesetsHandler.sol +0 -115
- package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
- package/test/invariants/handlers/TokensHandler.sol +0 -126
- package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
- package/test/regression/WeightCacheBoundary.t.sol +0 -291
- package/test/trees/JBController/burnTokensOf.tree +0 -9
- package/test/trees/JBController/claimTokensFor.tree +0 -5
- package/test/trees/JBController/deployERC20For.tree +0 -5
- package/test/trees/JBController/getRulesetOf.tree +0 -5
- package/test/trees/JBController/launchProjectFor.tree +0 -12
- package/test/trees/JBController/launchRulesetsFor.tree +0 -8
- package/test/trees/JBController/migrateController.tree +0 -12
- package/test/trees/JBController/mintTokensOf.tree +0 -12
- package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
- package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
- package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
- package/test/trees/JBController/setMetadataOf.tree +0 -5
- package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
- package/test/trees/JBController/setTokenFor.tree +0 -5
- package/test/trees/JBController/transferCreditsFrom.tree +0 -8
- package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
- package/test/trees/JBDirectory/setControllerOf.tree +0 -11
- package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
- package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
- package/test/trees/JBERC20/initialize.tree +0 -7
- package/test/trees/JBERC20/name.tree +0 -5
- package/test/trees/JBERC20/nonces.tree +0 -5
- package/test/trees/JBERC20/symbol.tree +0 -5
- package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
- package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
- package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
- package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
- package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
- package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
- package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
- package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
- package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
- package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
- package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
- package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
- package/test/trees/JBMultiTerminal/pay.tree +0 -23
- package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
- package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
- package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
- package/test/trees/JBPermissions/hasPermission.tree +0 -8
- package/test/trees/JBPermissions/hasPermissions.tree +0 -8
- package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
- package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
- package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
- package/test/trees/JBProjects/createFor.tree +0 -11
- package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
- package/test/trees/JBProjects/supportsInterface.tree +0 -9
- package/test/trees/JBProjects/tokenURI.tree +0 -5
- package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
- package/test/trees/JBRulesets/currentOf.tree +0 -12
- package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
- package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
- package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
- package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
- package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
- package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
- package/test/trees/JBSplits/splitsOf.tree +0 -5
- package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
- package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
- package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
- package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
- package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
- package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
- package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
- package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
- package/test/trees/JBTokens/burnFrom.tree +0 -10
- package/test/trees/JBTokens/claimTokensFor.tree +0 -10
- package/test/trees/JBTokens/deployERC20For.tree +0 -12
- package/test/trees/JBTokens/mintFor.tree +0 -10
- package/test/trees/JBTokens/setTokenFor.tree +0 -11
- package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
- package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
- package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
- package/test/trees/mintTokensOf.tree +0 -12
- package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
- package/test/units/static/JBController/JBControllerSetup.sol +0 -50
- package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
- package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
- package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
- package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
- package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
- package/test/units/static/JBController/TestMigrateController.sol +0 -157
- package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
- package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
- package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
- package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
- package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
- package/test/units/static/JBController/TestRulesetViews.sol +0 -225
- package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
- package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
- package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
- package/test/units/static/JBController/TestSetUriOf.sol +0 -57
- package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
- package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
- package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
- package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
- package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
- package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
- package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
- package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
- package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
- package/test/units/static/JBERC20/SigUtils.sol +0 -36
- package/test/units/static/JBERC20/TestInitialize.sol +0 -60
- package/test/units/static/JBERC20/TestName.sol +0 -30
- package/test/units/static/JBERC20/TestNonces.sol +0 -62
- package/test/units/static/JBERC20/TestSymbol.sol +0 -31
- package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
- package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
- package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
- package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
- package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
- package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
- package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
- package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
- package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
- package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
- package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
- package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
- package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
- package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
- package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
- package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
- package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
- package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
- package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
- package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
- package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
- package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
- package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
- package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
- package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
- package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
- package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
- package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
- package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
- package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
- package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
- package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
- package/test/units/static/JBPrices/TestPrices.sol +0 -265
- package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
- package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
- package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
- package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
- package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
- package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
- package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
- package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
- package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
- package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
- package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
- package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
- package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
- package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
- package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
- package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
- package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
- package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
- package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
- package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
- package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
- package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
- package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
- package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
- package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
- package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
- package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
- package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
- package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
- package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
- package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
- package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
- package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
- package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
- package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
- package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
- package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
- package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
- package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
- package/test/units/static/JBTokens/TestMintFor.sol +0 -100
- package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
- package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
- package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
- package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +0 -56
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity >=0.8.6;
|
|
3
|
-
|
|
4
|
-
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
5
|
-
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
|
-
|
|
7
|
-
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
8
|
-
import {JBMultiTerminal} from "../src/JBMultiTerminal.sol";
|
|
9
|
-
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
10
|
-
import {IJBCashOutHook} from "../src/interfaces/IJBCashOutHook.sol";
|
|
11
|
-
import {IJBMultiTerminal} from "../src/interfaces/IJBMultiTerminal.sol";
|
|
12
|
-
import {IJBPayHook} from "../src/interfaces/IJBPayHook.sol";
|
|
13
|
-
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
14
|
-
import {IJBRulesetDataHook} from "../src/interfaces/IJBRulesetDataHook.sol";
|
|
15
|
-
import {IJBSplitHook} from "../src/interfaces/IJBSplitHook.sol";
|
|
16
|
-
import {IJBTokens} from "../src/interfaces/IJBTokens.sol";
|
|
17
|
-
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
18
|
-
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
19
|
-
import {JBAfterCashOutRecordedContext} from "../src/structs/JBAfterCashOutRecordedContext.sol";
|
|
20
|
-
import {JBAfterPayRecordedContext} from "../src/structs/JBAfterPayRecordedContext.sol";
|
|
21
|
-
import {JBCashOutHookSpecification} from "../src/structs/JBCashOutHookSpecification.sol";
|
|
22
|
-
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
23
|
-
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
24
|
-
import {JBPayHookSpecification} from "../src/structs/JBPayHookSpecification.sol";
|
|
25
|
-
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
26
|
-
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
27
|
-
import {JBSplit} from "../src/structs/JBSplit.sol";
|
|
28
|
-
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
29
|
-
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
30
|
-
|
|
31
|
-
contract TestForwardedTokenConsumption_Local is TestBaseWorkflow {
|
|
32
|
-
uint112 private constant _WEIGHT = 1000 * 10 ** 18;
|
|
33
|
-
uint256 private constant _PAY_AMOUNT = 10 * 10 ** 6;
|
|
34
|
-
uint256 private constant _HOOK_FORWARD_AMOUNT = 1 * 10 ** 6;
|
|
35
|
-
uint256 private constant _PAYOUT_AMOUNT = 4 * 10 ** 6;
|
|
36
|
-
address private constant _DATA_HOOK = address(bytes20(keccak256("datahook")));
|
|
37
|
-
|
|
38
|
-
IJBController private _controller;
|
|
39
|
-
IJBMultiTerminal private _terminal;
|
|
40
|
-
IJBMultiTerminal private _terminal2;
|
|
41
|
-
IJBTokens private _tokens;
|
|
42
|
-
address private _projectOwner;
|
|
43
|
-
|
|
44
|
-
uint64 private _projectId;
|
|
45
|
-
|
|
46
|
-
function setUp() public override {
|
|
47
|
-
super.setUp();
|
|
48
|
-
|
|
49
|
-
_controller = jbController();
|
|
50
|
-
_terminal = jbMultiTerminal();
|
|
51
|
-
_terminal2 = jbMultiTerminal2();
|
|
52
|
-
_tokens = jbTokens();
|
|
53
|
-
_projectOwner = multisig();
|
|
54
|
-
|
|
55
|
-
// Launch the fee beneficiary project first so project ID 1 has a terminal and accounting context.
|
|
56
|
-
_launchProject({
|
|
57
|
-
terminal: _terminal,
|
|
58
|
-
projectUri: "fee-project",
|
|
59
|
-
metadata: _metadataWithHooks({useDataHookForPay: true, useDataHookForCashOut: true, dataHook: _DATA_HOOK}),
|
|
60
|
-
splitGroups: new JBSplitGroup[](0),
|
|
61
|
-
fundAccessLimitGroups: new JBFundAccessLimitGroup[](0)
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
_projectId = uint64(
|
|
65
|
-
_launchProject({
|
|
66
|
-
terminal: _terminal,
|
|
67
|
-
projectUri: "hook-project",
|
|
68
|
-
metadata: _metadataWithHooks({
|
|
69
|
-
useDataHookForPay: true, useDataHookForCashOut: true, dataHook: _DATA_HOOK
|
|
70
|
-
}),
|
|
71
|
-
splitGroups: new JBSplitGroup[](0),
|
|
72
|
-
fundAccessLimitGroups: new JBFundAccessLimitGroup[](0)
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function test_RevertIfERC20PayHookDoesNotConsumeForwardedTokens() external {
|
|
78
|
-
NonConsumingPayHook hook = new NonConsumingPayHook();
|
|
79
|
-
JBPayHookSpecification[] memory specifications = new JBPayHookSpecification[](1);
|
|
80
|
-
specifications[0] =
|
|
81
|
-
JBPayHookSpecification({hook: hook, noop: false, amount: _HOOK_FORWARD_AMOUNT, metadata: ""});
|
|
82
|
-
|
|
83
|
-
vm.mockCall(
|
|
84
|
-
_DATA_HOOK,
|
|
85
|
-
abi.encodeWithSelector(IJBRulesetDataHook.beforePayRecordedWith.selector),
|
|
86
|
-
abi.encode(_WEIGHT, specifications)
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
vm.prank(multisig());
|
|
90
|
-
jbFeelessAddresses().setFeelessAddress(address(hook), true);
|
|
91
|
-
|
|
92
|
-
address payer = makeAddr("payer");
|
|
93
|
-
usdcToken().mint(payer, _PAY_AMOUNT);
|
|
94
|
-
vm.prank(payer);
|
|
95
|
-
usdcToken().approve(address(_terminal), _PAY_AMOUNT);
|
|
96
|
-
|
|
97
|
-
vm.expectRevert(
|
|
98
|
-
abi.encodeWithSelector(
|
|
99
|
-
JBMultiTerminal.JBMultiTerminal_TemporaryAllowanceNotConsumed.selector,
|
|
100
|
-
address(usdcToken()),
|
|
101
|
-
address(hook),
|
|
102
|
-
_HOOK_FORWARD_AMOUNT
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
vm.prank(payer);
|
|
106
|
-
_terminal.pay({
|
|
107
|
-
projectId: _projectId,
|
|
108
|
-
token: address(usdcToken()),
|
|
109
|
-
amount: _PAY_AMOUNT,
|
|
110
|
-
beneficiary: payer,
|
|
111
|
-
minReturnedTokens: 0,
|
|
112
|
-
memo: "",
|
|
113
|
-
metadata: ""
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function test_RevertIfERC20CashOutHookDoesNotConsumeForwardedTokens() external {
|
|
118
|
-
JBPayHookSpecification[] memory emptyPaySpecifications = new JBPayHookSpecification[](0);
|
|
119
|
-
vm.mockCall(
|
|
120
|
-
_DATA_HOOK,
|
|
121
|
-
abi.encodeWithSelector(IJBRulesetDataHook.beforePayRecordedWith.selector),
|
|
122
|
-
abi.encode(_WEIGHT, emptyPaySpecifications)
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
usdcToken().mint(address(this), _PAY_AMOUNT);
|
|
126
|
-
usdcToken().approve(address(_terminal), _PAY_AMOUNT);
|
|
127
|
-
|
|
128
|
-
_terminal.pay({
|
|
129
|
-
projectId: _projectId,
|
|
130
|
-
token: address(usdcToken()),
|
|
131
|
-
amount: _PAY_AMOUNT,
|
|
132
|
-
beneficiary: address(this),
|
|
133
|
-
minReturnedTokens: 0,
|
|
134
|
-
memo: "",
|
|
135
|
-
metadata: ""
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
uint256 cashOutCount = _tokens.totalBalanceOf(address(this), _projectId) / 2;
|
|
139
|
-
|
|
140
|
-
NonConsumingCashOutHook hook = new NonConsumingCashOutHook();
|
|
141
|
-
JBCashOutHookSpecification[] memory specifications = new JBCashOutHookSpecification[](1);
|
|
142
|
-
specifications[0] =
|
|
143
|
-
JBCashOutHookSpecification({hook: hook, noop: false, amount: _HOOK_FORWARD_AMOUNT, metadata: ""});
|
|
144
|
-
|
|
145
|
-
vm.mockCall(
|
|
146
|
-
_DATA_HOOK,
|
|
147
|
-
abi.encodeWithSelector(IJBRulesetDataHook.beforeCashOutRecordedWith.selector),
|
|
148
|
-
abi.encode(
|
|
149
|
-
0,
|
|
150
|
-
cashOutCount,
|
|
151
|
-
_controller.totalTokenSupplyWithReservedTokensOf(_projectId),
|
|
152
|
-
_PAY_AMOUNT,
|
|
153
|
-
specifications
|
|
154
|
-
)
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
vm.prank(multisig());
|
|
158
|
-
jbFeelessAddresses().setFeelessAddress(address(hook), true);
|
|
159
|
-
|
|
160
|
-
vm.expectRevert(
|
|
161
|
-
abi.encodeWithSelector(
|
|
162
|
-
JBMultiTerminal.JBMultiTerminal_TemporaryAllowanceNotConsumed.selector,
|
|
163
|
-
address(usdcToken()),
|
|
164
|
-
address(hook),
|
|
165
|
-
_HOOK_FORWARD_AMOUNT
|
|
166
|
-
)
|
|
167
|
-
);
|
|
168
|
-
_terminal.cashOutTokensOf({
|
|
169
|
-
holder: address(this),
|
|
170
|
-
projectId: _projectId,
|
|
171
|
-
cashOutCount: cashOutCount,
|
|
172
|
-
tokenToReclaim: address(usdcToken()),
|
|
173
|
-
minTokensReclaimed: 0,
|
|
174
|
-
beneficiary: payable(address(this)),
|
|
175
|
-
metadata: ""
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function test_SendPayoutsToMultiTerminalAddToBalanceConsumesForwardedAllowance() external {
|
|
180
|
-
uint256 recipientProjectId = _launchProject({
|
|
181
|
-
terminal: _terminal2,
|
|
182
|
-
projectUri: "recipient-add-to-balance",
|
|
183
|
-
metadata: _metadataWithHooks({
|
|
184
|
-
useDataHookForPay: false, useDataHookForCashOut: false, dataHook: address(0)
|
|
185
|
-
}),
|
|
186
|
-
splitGroups: new JBSplitGroup[](0),
|
|
187
|
-
fundAccessLimitGroups: new JBFundAccessLimitGroup[](0)
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
uint256 sourceProjectId = _launchProject({
|
|
191
|
-
terminal: _terminal,
|
|
192
|
-
projectUri: "source-add-to-balance",
|
|
193
|
-
metadata: _metadataWithHooks({
|
|
194
|
-
useDataHookForPay: false, useDataHookForCashOut: false, dataHook: address(0)
|
|
195
|
-
}),
|
|
196
|
-
splitGroups: _splitGroupsToProject({targetProjectId: recipientProjectId, preferAddToBalance: true}),
|
|
197
|
-
fundAccessLimitGroups: _usdcPayoutLimitGroups({terminal: _terminal, payoutAmount: _PAYOUT_AMOUNT})
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
usdcToken().mint(address(this), _PAYOUT_AMOUNT);
|
|
201
|
-
usdcToken().approve(address(_terminal), _PAYOUT_AMOUNT);
|
|
202
|
-
|
|
203
|
-
_terminal.pay({
|
|
204
|
-
projectId: sourceProjectId,
|
|
205
|
-
token: address(usdcToken()),
|
|
206
|
-
amount: _PAYOUT_AMOUNT,
|
|
207
|
-
beneficiary: address(this),
|
|
208
|
-
minReturnedTokens: 0,
|
|
209
|
-
memo: "",
|
|
210
|
-
metadata: ""
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
uint256 fee = _PAYOUT_AMOUNT * _terminal.FEE() / JBConstants.MAX_FEE;
|
|
214
|
-
uint256 expectedNetPayout = _PAYOUT_AMOUNT - fee;
|
|
215
|
-
|
|
216
|
-
_terminal.sendPayoutsOf({
|
|
217
|
-
projectId: sourceProjectId,
|
|
218
|
-
amount: _PAYOUT_AMOUNT,
|
|
219
|
-
currency: uint32(uint160(address(usdcToken()))),
|
|
220
|
-
token: address(usdcToken()),
|
|
221
|
-
minTokensPaidOut: 0
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
assertEq(usdcToken().allowance(address(_terminal), address(_terminal2)), 0);
|
|
225
|
-
assertEq(jbTerminalStore().balanceOf(address(_terminal), sourceProjectId, address(usdcToken())), fee);
|
|
226
|
-
assertEq(
|
|
227
|
-
jbTerminalStore().balanceOf(address(_terminal2), recipientProjectId, address(usdcToken())),
|
|
228
|
-
expectedNetPayout
|
|
229
|
-
);
|
|
230
|
-
assertEq(usdcToken().balanceOf(address(_terminal2)), expectedNetPayout);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function test_SendPayoutsToMultiTerminalPayConsumesForwardedAllowance() external {
|
|
234
|
-
uint256 recipientProjectId = _launchProject({
|
|
235
|
-
terminal: _terminal2,
|
|
236
|
-
projectUri: "recipient-pay",
|
|
237
|
-
metadata: _metadataWithHooks({
|
|
238
|
-
useDataHookForPay: false, useDataHookForCashOut: false, dataHook: address(0)
|
|
239
|
-
}),
|
|
240
|
-
splitGroups: new JBSplitGroup[](0),
|
|
241
|
-
fundAccessLimitGroups: new JBFundAccessLimitGroup[](0)
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
uint256 sourceProjectId = _launchProject({
|
|
245
|
-
terminal: _terminal,
|
|
246
|
-
projectUri: "source-pay",
|
|
247
|
-
metadata: _metadataWithHooks({
|
|
248
|
-
useDataHookForPay: false, useDataHookForCashOut: false, dataHook: address(0)
|
|
249
|
-
}),
|
|
250
|
-
splitGroups: _splitGroupsToProject({targetProjectId: recipientProjectId, preferAddToBalance: false}),
|
|
251
|
-
fundAccessLimitGroups: _usdcPayoutLimitGroups({terminal: _terminal, payoutAmount: _PAYOUT_AMOUNT})
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
usdcToken().mint(address(this), _PAYOUT_AMOUNT);
|
|
255
|
-
usdcToken().approve(address(_terminal), _PAYOUT_AMOUNT);
|
|
256
|
-
|
|
257
|
-
_terminal.pay({
|
|
258
|
-
projectId: sourceProjectId,
|
|
259
|
-
token: address(usdcToken()),
|
|
260
|
-
amount: _PAYOUT_AMOUNT,
|
|
261
|
-
beneficiary: address(this),
|
|
262
|
-
minReturnedTokens: 0,
|
|
263
|
-
memo: "",
|
|
264
|
-
metadata: ""
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
uint256 fee = _PAYOUT_AMOUNT * _terminal.FEE() / JBConstants.MAX_FEE;
|
|
268
|
-
uint256 expectedNetPayout = _PAYOUT_AMOUNT - fee;
|
|
269
|
-
|
|
270
|
-
_terminal.sendPayoutsOf({
|
|
271
|
-
projectId: sourceProjectId,
|
|
272
|
-
amount: _PAYOUT_AMOUNT,
|
|
273
|
-
currency: uint32(uint160(address(usdcToken()))),
|
|
274
|
-
token: address(usdcToken()),
|
|
275
|
-
minTokensPaidOut: 0
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
assertEq(usdcToken().allowance(address(_terminal), address(_terminal2)), 0);
|
|
279
|
-
assertEq(jbTerminalStore().balanceOf(address(_terminal), sourceProjectId, address(usdcToken())), fee);
|
|
280
|
-
assertEq(
|
|
281
|
-
jbTerminalStore().balanceOf(address(_terminal2), recipientProjectId, address(usdcToken())),
|
|
282
|
-
expectedNetPayout
|
|
283
|
-
);
|
|
284
|
-
assertEq(usdcToken().balanceOf(address(_terminal2)), expectedNetPayout);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function _launchProject(
|
|
288
|
-
IJBMultiTerminal terminal,
|
|
289
|
-
string memory projectUri,
|
|
290
|
-
JBRulesetMetadata memory metadata,
|
|
291
|
-
JBSplitGroup[] memory splitGroups,
|
|
292
|
-
JBFundAccessLimitGroup[] memory fundAccessLimitGroups
|
|
293
|
-
)
|
|
294
|
-
internal
|
|
295
|
-
returns (uint256)
|
|
296
|
-
{
|
|
297
|
-
JBRulesetConfig[] memory rulesetConfigurations = new JBRulesetConfig[](1);
|
|
298
|
-
rulesetConfigurations[0].mustStartAtOrAfter = 0;
|
|
299
|
-
rulesetConfigurations[0].duration = 0;
|
|
300
|
-
rulesetConfigurations[0].weight = _WEIGHT;
|
|
301
|
-
rulesetConfigurations[0].weightCutPercent = 0;
|
|
302
|
-
rulesetConfigurations[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
303
|
-
rulesetConfigurations[0].metadata = metadata;
|
|
304
|
-
rulesetConfigurations[0].splitGroups = splitGroups;
|
|
305
|
-
rulesetConfigurations[0].fundAccessLimitGroups = fundAccessLimitGroups;
|
|
306
|
-
|
|
307
|
-
JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
|
|
308
|
-
terminalConfigurations[0] =
|
|
309
|
-
JBTerminalConfig({terminal: terminal, accountingContextsToAccept: _usdcAccountingContexts()});
|
|
310
|
-
|
|
311
|
-
return _controller.launchProjectFor({
|
|
312
|
-
owner: _projectOwner,
|
|
313
|
-
projectUri: projectUri,
|
|
314
|
-
rulesetConfigurations: rulesetConfigurations,
|
|
315
|
-
terminalConfigurations: terminalConfigurations,
|
|
316
|
-
memo: ""
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function _metadataWithHooks(
|
|
321
|
-
bool useDataHookForPay,
|
|
322
|
-
bool useDataHookForCashOut,
|
|
323
|
-
address dataHook
|
|
324
|
-
)
|
|
325
|
-
internal
|
|
326
|
-
view
|
|
327
|
-
returns (JBRulesetMetadata memory)
|
|
328
|
-
{
|
|
329
|
-
return JBRulesetMetadata({
|
|
330
|
-
reservedPercent: 0,
|
|
331
|
-
cashOutTaxRate: 0,
|
|
332
|
-
baseCurrency: uint32(uint160(address(usdcToken()))),
|
|
333
|
-
pausePay: false,
|
|
334
|
-
pauseCreditTransfers: false,
|
|
335
|
-
allowOwnerMinting: false,
|
|
336
|
-
allowSetCustomToken: false,
|
|
337
|
-
allowTerminalMigration: false,
|
|
338
|
-
allowSetTerminals: false,
|
|
339
|
-
ownerMustSendPayouts: false,
|
|
340
|
-
allowSetController: false,
|
|
341
|
-
allowAddAccountingContext: true,
|
|
342
|
-
allowAddPriceFeed: false,
|
|
343
|
-
holdFees: false,
|
|
344
|
-
useTotalSurplusForCashOuts: false,
|
|
345
|
-
useDataHookForPay: useDataHookForPay,
|
|
346
|
-
useDataHookForCashOut: useDataHookForCashOut,
|
|
347
|
-
dataHook: dataHook,
|
|
348
|
-
metadata: 0
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
function _splitGroupsToProject(
|
|
353
|
-
uint256 targetProjectId,
|
|
354
|
-
bool preferAddToBalance
|
|
355
|
-
)
|
|
356
|
-
internal
|
|
357
|
-
view
|
|
358
|
-
returns (JBSplitGroup[] memory)
|
|
359
|
-
{
|
|
360
|
-
JBSplit[] memory splits = new JBSplit[](1);
|
|
361
|
-
splits[0].percent = uint32(JBConstants.SPLITS_TOTAL_PERCENT);
|
|
362
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
363
|
-
splits[0].projectId = uint64(targetProjectId);
|
|
364
|
-
splits[0].beneficiary = payable(address(0));
|
|
365
|
-
splits[0].preferAddToBalance = preferAddToBalance;
|
|
366
|
-
splits[0].lockedUntil = 0;
|
|
367
|
-
splits[0].hook = IJBSplitHook(address(0));
|
|
368
|
-
|
|
369
|
-
JBSplitGroup[] memory splitGroups = new JBSplitGroup[](1);
|
|
370
|
-
splitGroups[0] = JBSplitGroup({groupId: uint256(uint160(address(usdcToken()))), splits: splits});
|
|
371
|
-
|
|
372
|
-
return splitGroups;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
function _usdcAccountingContexts() internal view returns (JBAccountingContext[] memory) {
|
|
376
|
-
JBAccountingContext[] memory accountingContexts = new JBAccountingContext[](1);
|
|
377
|
-
accountingContexts[0] = JBAccountingContext({
|
|
378
|
-
token: address(usdcToken()),
|
|
379
|
-
decimals: usdcToken().decimals(),
|
|
380
|
-
currency: uint32(uint160(address(usdcToken())))
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
return accountingContexts;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function _usdcPayoutLimitGroups(
|
|
387
|
-
IJBMultiTerminal terminal,
|
|
388
|
-
uint256 payoutAmount
|
|
389
|
-
)
|
|
390
|
-
internal
|
|
391
|
-
view
|
|
392
|
-
returns (JBFundAccessLimitGroup[] memory)
|
|
393
|
-
{
|
|
394
|
-
JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](1);
|
|
395
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
396
|
-
payoutLimits[0] =
|
|
397
|
-
JBCurrencyAmount({amount: uint224(payoutAmount), currency: uint32(uint160(address(usdcToken())))});
|
|
398
|
-
|
|
399
|
-
JBFundAccessLimitGroup[] memory fundAccessLimitGroups = new JBFundAccessLimitGroup[](1);
|
|
400
|
-
fundAccessLimitGroups[0] = JBFundAccessLimitGroup({
|
|
401
|
-
terminal: address(terminal),
|
|
402
|
-
token: address(usdcToken()),
|
|
403
|
-
payoutLimits: payoutLimits,
|
|
404
|
-
surplusAllowances: new JBCurrencyAmount[](0)
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
return fundAccessLimitGroups;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
contract NonConsumingPayHook is ERC165, IJBPayHook {
|
|
412
|
-
function afterPayRecordedWith(JBAfterPayRecordedContext calldata) external payable override {}
|
|
413
|
-
|
|
414
|
-
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
|
|
415
|
-
return interfaceId == type(IJBPayHook).interfaceId || super.supportsInterface(interfaceId);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
contract NonConsumingCashOutHook is ERC165, IJBCashOutHook {
|
|
420
|
-
function afterCashOutRecordedWith(JBAfterCashOutRecordedContext calldata) external payable override {}
|
|
421
|
-
|
|
422
|
-
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
|
|
423
|
-
return interfaceId == type(IJBCashOutHook).interfaceId || super.supportsInterface(interfaceId);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.6;
|
|
3
|
-
|
|
4
|
-
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
-
import {JBController} from "../src/JBController.sol";
|
|
6
|
-
import {JBDeadline} from "../src/JBDeadline.sol";
|
|
7
|
-
import {JBMultiTerminal} from "../src/JBMultiTerminal.sol";
|
|
8
|
-
import {JBProjects} from "../src/JBProjects.sol";
|
|
9
|
-
import {IJBCashOutTerminal} from "../src/interfaces/IJBCashOutTerminal.sol";
|
|
10
|
-
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
11
|
-
import {IJBFeeTerminal} from "../src/interfaces/IJBFeeTerminal.sol";
|
|
12
|
-
import {IJBMigratable} from "../src/interfaces/IJBMigratable.sol";
|
|
13
|
-
import {IJBMultiTerminal} from "../src/interfaces/IJBMultiTerminal.sol";
|
|
14
|
-
import {IJBPayoutTerminal} from "../src/interfaces/IJBPayoutTerminal.sol";
|
|
15
|
-
import {IJBPermissioned} from "../src/interfaces/IJBPermissioned.sol";
|
|
16
|
-
import {IJBPermitTerminal} from "../src/interfaces/IJBPermitTerminal.sol";
|
|
17
|
-
import {IJBProjects} from "../src/interfaces/IJBProjects.sol";
|
|
18
|
-
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
19
|
-
import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
|
|
20
|
-
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
|
21
|
-
import {IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
|
|
22
|
-
import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
23
|
-
|
|
24
|
-
/// Contracts are introspective about the interfaces they adhere to.
|
|
25
|
-
contract TestEIP165_Local is TestBaseWorkflow {
|
|
26
|
-
// forge-lint: disable-next-line(screaming-snake-case-const)
|
|
27
|
-
bytes4 private constant _notSupportedInterface = 0xffffffff;
|
|
28
|
-
|
|
29
|
-
function testJBController() public view {
|
|
30
|
-
JBController _controller = jbController();
|
|
31
|
-
|
|
32
|
-
// Should support these interfaces.
|
|
33
|
-
assertTrue(_controller.supportsInterface(type(IERC165).interfaceId));
|
|
34
|
-
assertTrue(_controller.supportsInterface(type(IJBMigratable).interfaceId));
|
|
35
|
-
assertTrue(_controller.supportsInterface(type(IJBPermissioned).interfaceId));
|
|
36
|
-
assertTrue(_controller.supportsInterface(type(IJBController).interfaceId));
|
|
37
|
-
|
|
38
|
-
// Make sure it doesn't always return true.
|
|
39
|
-
assertTrue(!_controller.supportsInterface(_notSupportedInterface));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function testJBMultiTerminal() public view {
|
|
43
|
-
JBMultiTerminal _terminal = jbMultiTerminal();
|
|
44
|
-
|
|
45
|
-
// Should support these interfaces.
|
|
46
|
-
assertTrue(_terminal.supportsInterface(type(IJBMultiTerminal).interfaceId));
|
|
47
|
-
assertTrue(_terminal.supportsInterface(type(IJBTerminal).interfaceId));
|
|
48
|
-
assertTrue(_terminal.supportsInterface(type(IJBCashOutTerminal).interfaceId));
|
|
49
|
-
assertTrue(_terminal.supportsInterface(type(IJBPayoutTerminal).interfaceId));
|
|
50
|
-
assertTrue(_terminal.supportsInterface(type(IJBPermitTerminal).interfaceId));
|
|
51
|
-
assertTrue(_terminal.supportsInterface(type(IJBFeeTerminal).interfaceId));
|
|
52
|
-
assertTrue(_terminal.supportsInterface(type(IERC165).interfaceId));
|
|
53
|
-
|
|
54
|
-
// Make sure it doesn't always return true.
|
|
55
|
-
assertTrue(!_terminal.supportsInterface(_notSupportedInterface));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function testJBProjects() public view {
|
|
59
|
-
JBProjects _projects = jbProjects();
|
|
60
|
-
|
|
61
|
-
// Should support these interfaces.
|
|
62
|
-
assertTrue(_projects.supportsInterface(type(IERC165).interfaceId));
|
|
63
|
-
assertTrue(_projects.supportsInterface(type(IERC721).interfaceId));
|
|
64
|
-
assertTrue(_projects.supportsInterface(type(IERC721Metadata).interfaceId));
|
|
65
|
-
assertTrue(_projects.supportsInterface(type(IJBProjects).interfaceId));
|
|
66
|
-
|
|
67
|
-
// Make sure it doesn't always return true.
|
|
68
|
-
assertTrue(!_projects.supportsInterface(_notSupportedInterface));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function testJBDeadline() public {
|
|
72
|
-
JBDeadline _approvalHook = new JBDeadline(3000);
|
|
73
|
-
|
|
74
|
-
// Should support these interfaces.
|
|
75
|
-
assertTrue(_approvalHook.supportsInterface(type(IERC165).interfaceId));
|
|
76
|
-
assertTrue(_approvalHook.supportsInterface(type(IJBRulesetApprovalHook).interfaceId));
|
|
77
|
-
|
|
78
|
-
// Make sure it doesn't always return true.
|
|
79
|
-
assertTrue(!_approvalHook.supportsInterface(_notSupportedInterface));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
-
import {JBERC20} from "../src/JBERC20.sol";
|
|
6
|
-
import {IJBPermissions} from "../src/interfaces/IJBPermissions.sol";
|
|
7
|
-
import {IJBProjects} from "../src/interfaces/IJBProjects.sol";
|
|
8
|
-
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
9
|
-
import {IJBToken} from "../src/interfaces/IJBToken.sol";
|
|
10
|
-
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
11
|
-
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
12
|
-
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
13
|
-
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
14
|
-
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
15
|
-
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
16
|
-
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
17
|
-
|
|
18
|
-
import {ERC20Votes} from "../src/JBERC20.sol";
|
|
19
|
-
|
|
20
|
-
contract JBERC20Inheritance_Local is JBERC20(IJBPermissions(address(1)), IJBProjects(address(2))), TestBaseWorkflow {
|
|
21
|
-
/// This test is to verify that the inheritance order of JBERC20 is correct and that it calls the
|
|
22
|
-
/// `ERC20Votes._update()`
|
|
23
|
-
/// forge-config: default.allow_internal_expect_revert = true
|
|
24
|
-
function test_votesUpdate() public {
|
|
25
|
-
uint256 _max = _maxSupply();
|
|
26
|
-
vm.expectRevert(abi.encodeWithSelector(ERC20Votes.ERC20ExceededSafeSupply.selector, _max + 1, _max));
|
|
27
|
-
|
|
28
|
-
_update(address(0), address(100), _max + 1);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// This test checks that voting power gets accounted for.
|
|
32
|
-
function test_votesUpdateOnTransfer() public {
|
|
33
|
-
JBRulesetMetadata memory _metadata = JBRulesetMetadata({
|
|
34
|
-
reservedPercent: 0,
|
|
35
|
-
cashOutTaxRate: 0,
|
|
36
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
37
|
-
pausePay: false,
|
|
38
|
-
pauseCreditTransfers: false,
|
|
39
|
-
allowOwnerMinting: true,
|
|
40
|
-
allowSetCustomToken: false,
|
|
41
|
-
allowTerminalMigration: false,
|
|
42
|
-
allowSetTerminals: false,
|
|
43
|
-
ownerMustSendPayouts: false,
|
|
44
|
-
allowSetController: false,
|
|
45
|
-
allowAddAccountingContext: true,
|
|
46
|
-
allowAddPriceFeed: false,
|
|
47
|
-
holdFees: false,
|
|
48
|
-
useTotalSurplusForCashOuts: false,
|
|
49
|
-
useDataHookForPay: true,
|
|
50
|
-
useDataHookForCashOut: true,
|
|
51
|
-
dataHook: address(0),
|
|
52
|
-
metadata: 0
|
|
53
|
-
});
|
|
54
|
-
address _projectOwner = multisig();
|
|
55
|
-
address _recipient = address(200);
|
|
56
|
-
uint256 _amount = 10 ether;
|
|
57
|
-
|
|
58
|
-
// Package up ruleset configuration.
|
|
59
|
-
JBRulesetConfig[] memory _rulesetConfig = new JBRulesetConfig[](1);
|
|
60
|
-
_rulesetConfig[0].mustStartAtOrAfter = 0;
|
|
61
|
-
_rulesetConfig[0].duration = 0;
|
|
62
|
-
_rulesetConfig[0].weight = 0;
|
|
63
|
-
_rulesetConfig[0].weightCutPercent = 0;
|
|
64
|
-
_rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
65
|
-
_rulesetConfig[0].metadata = _metadata;
|
|
66
|
-
_rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
|
|
67
|
-
_rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
|
|
68
|
-
|
|
69
|
-
// Package up terminal configuration.
|
|
70
|
-
JBTerminalConfig[] memory _terminalConfigurations = new JBTerminalConfig[](1);
|
|
71
|
-
JBAccountingContext[] memory _tokensToAccept = new JBAccountingContext[](1);
|
|
72
|
-
_tokensToAccept[0] = JBAccountingContext({
|
|
73
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
74
|
-
});
|
|
75
|
-
_terminalConfigurations[0] =
|
|
76
|
-
JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: _tokensToAccept});
|
|
77
|
-
|
|
78
|
-
uint256 projectId = jbController()
|
|
79
|
-
.launchProjectFor({
|
|
80
|
-
owner: _projectOwner,
|
|
81
|
-
projectUri: "myIPFSHash",
|
|
82
|
-
rulesetConfigurations: _rulesetConfig,
|
|
83
|
-
terminalConfigurations: _terminalConfigurations,
|
|
84
|
-
memo: ""
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Configure a token.
|
|
88
|
-
vm.prank(_projectOwner);
|
|
89
|
-
IJBToken _token = jbController().deployERC20For(projectId, "TestToken", "TEST", bytes32(0));
|
|
90
|
-
|
|
91
|
-
// Have the user delegate to themselves.
|
|
92
|
-
vm.prank(_recipient);
|
|
93
|
-
ERC20Votes(address(_token)).delegate(_recipient);
|
|
94
|
-
|
|
95
|
-
// Mint tokens to the user, check that the balance is correct.
|
|
96
|
-
vm.startPrank(_projectOwner);
|
|
97
|
-
jbController().mintTokensOf(projectId, _amount, _recipient, "", false);
|
|
98
|
-
assertEq(_token.balanceOf(_recipient), _amount);
|
|
99
|
-
|
|
100
|
-
// Assert that the user received the voting power as expected.
|
|
101
|
-
assertEq(ERC20Votes(address(_token)).getVotes(_recipient), _amount);
|
|
102
|
-
}
|
|
103
|
-
}
|