@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,24 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {JBFundAccessLimits} from "../../../../src/JBFundAccessLimits.sol";
|
|
5
|
-
import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
|
|
6
|
-
import {IJBFundAccessLimits} from "../../../../src/interfaces/IJBFundAccessLimits.sol";
|
|
7
|
-
import {JBTest} from "../../../helpers/JBTest.sol";
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
Contract that deploys a target contract with other mock contracts to satisfy the constructor.
|
|
11
|
-
Tests relative to this contract will be dependent on mock calls/emits and stdStorage.
|
|
12
|
-
*/
|
|
13
|
-
contract JBFundAccessSetup is JBTest {
|
|
14
|
-
// Target Contract
|
|
15
|
-
IJBFundAccessLimits public _fundAccess;
|
|
16
|
-
|
|
17
|
-
// Mocks
|
|
18
|
-
IJBDirectory public directory = IJBDirectory(makeAddr("directory"));
|
|
19
|
-
|
|
20
|
-
function fundAccessSetup() public virtual {
|
|
21
|
-
// Instantiate the contract being tested
|
|
22
|
-
_fundAccess = new JBFundAccessLimits(directory);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {JBFundAccessLimits} from "../../../../src/JBFundAccessLimits.sol";
|
|
5
|
-
import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
|
|
6
|
-
import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
|
|
7
|
-
import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
|
|
8
|
-
import {JBTest} from "../../../helpers/JBTest.sol";
|
|
9
|
-
|
|
10
|
-
/// @notice Edge case tests for JBFundAccessLimits append behavior and packing.
|
|
11
|
-
/// The key finding is that setFundAccessLimitsFor uses .push() (append), not replace.
|
|
12
|
-
/// If called twice for the same rulesetId, limits accumulate rather than being replaced.
|
|
13
|
-
contract TestFundAccessLimitsEdge_Local is JBTest {
|
|
14
|
-
IJBDirectory public directory = IJBDirectory(makeAddr("directory"));
|
|
15
|
-
JBFundAccessLimits public limits;
|
|
16
|
-
|
|
17
|
-
uint256 constant PROJECT_ID = 1;
|
|
18
|
-
uint256 constant RULESET_ID = 100;
|
|
19
|
-
address constant TERMINAL = address(0xBEEF);
|
|
20
|
-
address constant TOKEN = address(0xCAFE);
|
|
21
|
-
|
|
22
|
-
function setUp() public {
|
|
23
|
-
limits = new JBFundAccessLimits(directory);
|
|
24
|
-
|
|
25
|
-
// Mock controllerOf to return this contract (so we can call setFundAccessLimitsFor).
|
|
26
|
-
vm.mockCall(
|
|
27
|
-
address(directory), abi.encodeCall(IJBDirectory.controllerOf, (PROJECT_ID)), abi.encode(address(this))
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// ───────────────────── Append-not-replace bug
|
|
32
|
-
// ─────────────────────
|
|
33
|
-
|
|
34
|
-
/// @notice BUG: Calling setFundAccessLimitsFor twice accumulates limits instead of replacing.
|
|
35
|
-
/// If a controller ever calls this twice for the same rulesetId (e.g., custom controller,
|
|
36
|
-
/// reentrancy, or migration bug), limits double.
|
|
37
|
-
function test_doubleSetting_accumulatesLimits() external {
|
|
38
|
-
JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](1);
|
|
39
|
-
payoutLimits[0] = JBCurrencyAmount({amount: 1000, currency: 1});
|
|
40
|
-
|
|
41
|
-
JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
|
|
42
|
-
groups[0] = JBFundAccessLimitGroup({
|
|
43
|
-
terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// First call — sets limit to 1000.
|
|
47
|
-
limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
|
|
48
|
-
|
|
49
|
-
// Verify first limit.
|
|
50
|
-
uint256 limit1 = limits.payoutLimitOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN, 1);
|
|
51
|
-
assertEq(limit1, 1000, "First limit should be 1000");
|
|
52
|
-
|
|
53
|
-
// Second call with SAME rulesetId — BUG: this APPENDS, not replaces.
|
|
54
|
-
limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
|
|
55
|
-
|
|
56
|
-
// Query all limits — should have 2 entries now (both with currency=1, amount=1000).
|
|
57
|
-
JBCurrencyAmount[] memory allLimits = limits.payoutLimitsOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN);
|
|
58
|
-
|
|
59
|
-
// Two entries instead of one.
|
|
60
|
-
assertEq(allLimits.length, 2, "BUG: Limits accumulated instead of being replaced");
|
|
61
|
-
assertEq(allLimits[0].amount, 1000, "First accumulated limit");
|
|
62
|
-
assertEq(allLimits[1].amount, 1000, "Second accumulated limit");
|
|
63
|
-
|
|
64
|
-
// The payoutLimitOf function returns the FIRST match, so it still returns 1000.
|
|
65
|
-
// But the surplus calculation iterates ALL limits, effectively doubling the payout limit.
|
|
66
|
-
uint256 limitQuery = limits.payoutLimitOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN, 1);
|
|
67
|
-
assertEq(limitQuery, 1000, "Query returns first match only");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// ───────────────────── Zero amount skipped
|
|
71
|
-
// ─────────────────────
|
|
72
|
-
|
|
73
|
-
/// @notice Zero-amount limits are not stored (filtered by amount > 0 check).
|
|
74
|
-
function test_zeroAmount_skipped() external {
|
|
75
|
-
JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](2);
|
|
76
|
-
payoutLimits[0] = JBCurrencyAmount({amount: 0, currency: 1}); // Should be skipped.
|
|
77
|
-
payoutLimits[1] = JBCurrencyAmount({amount: 500, currency: 2});
|
|
78
|
-
|
|
79
|
-
JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
|
|
80
|
-
groups[0] = JBFundAccessLimitGroup({
|
|
81
|
-
terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
|
|
85
|
-
|
|
86
|
-
// Only the non-zero limit should be stored.
|
|
87
|
-
JBCurrencyAmount[] memory allLimits = limits.payoutLimitsOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN);
|
|
88
|
-
assertEq(allLimits.length, 1, "Zero-amount limit should not be stored");
|
|
89
|
-
assertEq(allLimits[0].amount, 500, "Only non-zero limit stored");
|
|
90
|
-
assertEq(allLimits[0].currency, 2, "Correct currency stored");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ───────────────────── Currency ordering validation
|
|
94
|
-
// ─────────────────────
|
|
95
|
-
|
|
96
|
-
/// @notice Duplicate currencies in payout limits should revert.
|
|
97
|
-
function test_currencyOrdering_rejectsEqual() external {
|
|
98
|
-
JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](2);
|
|
99
|
-
payoutLimits[0] = JBCurrencyAmount({amount: 100, currency: 1});
|
|
100
|
-
payoutLimits[1] = JBCurrencyAmount({amount: 200, currency: 1}); // Same currency!
|
|
101
|
-
|
|
102
|
-
JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
|
|
103
|
-
groups[0] = JBFundAccessLimitGroup({
|
|
104
|
-
terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
vm.expectRevert(JBFundAccessLimits.JBFundAccessLimits_InvalidPayoutLimitCurrencyOrdering.selector);
|
|
108
|
-
limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/// @notice Descending currency order should revert.
|
|
112
|
-
function test_currencyOrdering_rejectsDescending() external {
|
|
113
|
-
JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](2);
|
|
114
|
-
payoutLimits[0] = JBCurrencyAmount({amount: 100, currency: 2});
|
|
115
|
-
payoutLimits[1] = JBCurrencyAmount({amount: 200, currency: 1}); // Descending!
|
|
116
|
-
|
|
117
|
-
JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
|
|
118
|
-
groups[0] = JBFundAccessLimitGroup({
|
|
119
|
-
terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
vm.expectRevert(JBFundAccessLimits.JBFundAccessLimits_InvalidPayoutLimitCurrencyOrdering.selector);
|
|
123
|
-
limits.setFundAccessLimitsFor(PROJECT_ID, RULESET_ID, groups);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// ───────────────────── Packing round-trip
|
|
127
|
-
// ─────────────────────
|
|
128
|
-
|
|
129
|
-
/// @notice Fuzz: packed amount + currency unpack correctly for all inputs.
|
|
130
|
-
function testFuzz_packingRoundTrip(uint224 amount, uint32 currency) external {
|
|
131
|
-
// Skip zero amounts (they're filtered out).
|
|
132
|
-
vm.assume(amount > 0);
|
|
133
|
-
// Skip currency 0 since ordering requires > 0 for the first element.
|
|
134
|
-
vm.assume(currency > 0);
|
|
135
|
-
|
|
136
|
-
JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](1);
|
|
137
|
-
payoutLimits[0] = JBCurrencyAmount({amount: amount, currency: currency});
|
|
138
|
-
|
|
139
|
-
JBFundAccessLimitGroup[] memory groups = new JBFundAccessLimitGroup[](1);
|
|
140
|
-
groups[0] = JBFundAccessLimitGroup({
|
|
141
|
-
terminal: TERMINAL, token: TOKEN, payoutLimits: payoutLimits, surplusAllowances: new JBCurrencyAmount[](0)
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// Use a unique rulesetId for each fuzz run to avoid accumulation bug.
|
|
145
|
-
uint256 rulesetId = uint256(keccak256(abi.encode(amount, currency)));
|
|
146
|
-
limits.setFundAccessLimitsFor(PROJECT_ID, rulesetId, groups);
|
|
147
|
-
|
|
148
|
-
// Verify round-trip.
|
|
149
|
-
JBCurrencyAmount[] memory result = limits.payoutLimitsOf(PROJECT_ID, rulesetId, TERMINAL, TOKEN);
|
|
150
|
-
assertEq(result.length, 1, "Should have exactly one limit");
|
|
151
|
-
assertEq(result[0].amount, amount, "Amount should round-trip correctly");
|
|
152
|
-
assertEq(result[0].currency, currency, "Currency should round-trip correctly");
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// ───────────────────── Query nonexistent returns zero
|
|
156
|
-
// ─────────────────────
|
|
157
|
-
|
|
158
|
-
/// @notice Querying a currency with no limit returns 0 (implicit default).
|
|
159
|
-
function test_queryNonexistentCurrency_returnsZero() external view {
|
|
160
|
-
uint256 limit = limits.payoutLimitOf(PROJECT_ID, RULESET_ID, TERMINAL, TOKEN, 999);
|
|
161
|
-
assertEq(limit, 0, "Nonexistent currency should return 0");
|
|
162
|
-
}
|
|
163
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
|
|
5
|
-
import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
|
|
6
|
-
import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
|
|
7
|
-
import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
|
|
8
|
-
import {JBFundAccessSetup} from "./JBFundAccessSetup.sol";
|
|
9
|
-
|
|
10
|
-
contract TestPayoutLimitOf_Local is JBFundAccessSetup {
|
|
11
|
-
uint256 _projectId = 1;
|
|
12
|
-
uint256 _ruleset = block.timestamp;
|
|
13
|
-
uint224 _payoutLimit = 1e18;
|
|
14
|
-
uint32 _currency = uint32(uint160(JBConstants.NATIVE_TOKEN));
|
|
15
|
-
address _terminal = address(1);
|
|
16
|
-
address _token = JBConstants.NATIVE_TOKEN;
|
|
17
|
-
|
|
18
|
-
function setUp() public {
|
|
19
|
-
super.fundAccessSetup();
|
|
20
|
-
|
|
21
|
-
// Fund Access config
|
|
22
|
-
JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](1);
|
|
23
|
-
{
|
|
24
|
-
// Specify a payout limit.
|
|
25
|
-
JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](1);
|
|
26
|
-
_payoutLimits[0] =
|
|
27
|
-
JBCurrencyAmount({amount: _payoutLimit, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
|
|
28
|
-
|
|
29
|
-
// Specify a surplus allowance.
|
|
30
|
-
JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](0);
|
|
31
|
-
|
|
32
|
-
_fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
|
|
33
|
-
terminal: address(_terminal),
|
|
34
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
35
|
-
payoutLimits: _payoutLimits,
|
|
36
|
-
surplusAllowances: _surplusAllowances
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
|
|
41
|
-
bytes memory _return = abi.encode(address(this));
|
|
42
|
-
|
|
43
|
-
mockExpect(address(directory), _controllerCall, _return);
|
|
44
|
-
|
|
45
|
-
_fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function test_WhenTheProjectHasTheSpecificPayoutLimit() external view {
|
|
49
|
-
// it will return the uint256 payoutLimit
|
|
50
|
-
uint256 _returnedLimit = _fundAccess.payoutLimitOf(_projectId, _ruleset, _terminal, _token, _currency);
|
|
51
|
-
assertEq(_returnedLimit, _payoutLimit);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function test_WhenTheProjectDoesntHaveTheSpecificPayoutLimit() external view {
|
|
55
|
-
// it will return 0
|
|
56
|
-
uint256 empty = _fundAccess.payoutLimitOf(1, 1, address(1), address(2), 1);
|
|
57
|
-
assertEq(empty, 0);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
|
|
5
|
-
import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
|
|
6
|
-
import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
|
|
7
|
-
import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
|
|
8
|
-
import {JBFundAccessSetup} from "./JBFundAccessSetup.sol";
|
|
9
|
-
|
|
10
|
-
contract TestPayoutLimitsOf_Local is JBFundAccessSetup {
|
|
11
|
-
uint256 _projectId = 1;
|
|
12
|
-
uint256 _ruleset = block.timestamp;
|
|
13
|
-
uint224 _payoutLimit = 1e18;
|
|
14
|
-
uint224 _payoutLimit2 = 1e6;
|
|
15
|
-
uint32 _currency = uint32(uint160(JBConstants.NATIVE_TOKEN));
|
|
16
|
-
address _terminal = address(1);
|
|
17
|
-
address _terminal2 = address(2);
|
|
18
|
-
address _someToken = makeAddr("sometoken");
|
|
19
|
-
|
|
20
|
-
function setUp() public {
|
|
21
|
-
super.fundAccessSetup();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
modifier whenAProjectHasPayoutLimits() {
|
|
25
|
-
// Fund Access config
|
|
26
|
-
JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
|
|
27
|
-
{
|
|
28
|
-
// Specify a payout limit.
|
|
29
|
-
JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](2);
|
|
30
|
-
_payoutLimits[0] =
|
|
31
|
-
JBCurrencyAmount({amount: _payoutLimit, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
|
|
32
|
-
|
|
33
|
-
// Specify a second payout limit.
|
|
34
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
35
|
-
_payoutLimits[1] = JBCurrencyAmount({amount: _payoutLimit2, currency: uint32(uint160(_someToken))});
|
|
36
|
-
|
|
37
|
-
// Specify a surplus allowance.
|
|
38
|
-
JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](0);
|
|
39
|
-
|
|
40
|
-
_fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
|
|
41
|
-
terminal: address(_terminal),
|
|
42
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
43
|
-
payoutLimits: _payoutLimits,
|
|
44
|
-
surplusAllowances: _surplusAllowances
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
_fundAccessLimitGroup[1] = JBFundAccessLimitGroup({
|
|
48
|
-
terminal: address(_terminal2),
|
|
49
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
50
|
-
payoutLimits: _payoutLimits,
|
|
51
|
-
surplusAllowances: _surplusAllowances
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
|
|
56
|
-
bytes memory _return = abi.encode(address(this));
|
|
57
|
-
|
|
58
|
-
mockExpect(address(directory), _controllerCall, _return);
|
|
59
|
-
|
|
60
|
-
_fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
|
|
61
|
-
_fundAccess.setFundAccessLimitsFor(_projectId, _ruleset + 1, _fundAccessLimitGroup);
|
|
62
|
-
_;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function test_GivenTheyAreConfiguredForASpecificToken() external whenAProjectHasPayoutLimits {
|
|
66
|
-
// it will return them
|
|
67
|
-
|
|
68
|
-
JBCurrencyAmount[] memory payoutLimits =
|
|
69
|
-
_fundAccess.payoutLimitsOf(_projectId, _ruleset, _terminal, JBConstants.NATIVE_TOKEN);
|
|
70
|
-
|
|
71
|
-
assertEq(payoutLimits[0].currency, uint32(uint160(JBConstants.NATIVE_TOKEN)));
|
|
72
|
-
assertEq(payoutLimits[0].amount, _payoutLimit);
|
|
73
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
74
|
-
assertEq(payoutLimits[1].currency, uint32(uint160(_someToken)));
|
|
75
|
-
assertEq(payoutLimits[1].amount, _payoutLimit2);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function test_GivenTheyAreConfiguredForASpecificTerminal() external whenAProjectHasPayoutLimits {
|
|
79
|
-
// it will return them
|
|
80
|
-
JBCurrencyAmount[] memory payoutLimits =
|
|
81
|
-
_fundAccess.payoutLimitsOf(_projectId, _ruleset, _terminal2, JBConstants.NATIVE_TOKEN);
|
|
82
|
-
|
|
83
|
-
assertEq(payoutLimits[0].currency, uint32(uint160(JBConstants.NATIVE_TOKEN)));
|
|
84
|
-
assertEq(payoutLimits[0].amount, _payoutLimit);
|
|
85
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
86
|
-
assertEq(payoutLimits[1].currency, uint32(uint160(_someToken)));
|
|
87
|
-
assertEq(payoutLimits[1].amount, _payoutLimit2);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function test_GivenTheyAreConfiguredForASpecificRulesetId() external whenAProjectHasPayoutLimits {
|
|
91
|
-
// it will return them
|
|
92
|
-
JBCurrencyAmount[] memory payoutLimits =
|
|
93
|
-
_fundAccess.payoutLimitsOf(_projectId, _ruleset + 1, _terminal2, JBConstants.NATIVE_TOKEN);
|
|
94
|
-
|
|
95
|
-
assertEq(payoutLimits[0].currency, uint32(uint160(JBConstants.NATIVE_TOKEN)));
|
|
96
|
-
assertEq(payoutLimits[0].amount, _payoutLimit);
|
|
97
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
98
|
-
assertEq(payoutLimits[1].currency, uint32(uint160(_someToken)));
|
|
99
|
-
assertEq(payoutLimits[1].amount, _payoutLimit2);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {JBFundAccessLimits} from "../../../../src/JBFundAccessLimits.sol";
|
|
5
|
-
import {JBControlled} from "../../../../src/abstract/JBControlled.sol";
|
|
6
|
-
import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
|
|
7
|
-
import {IJBFundAccessLimits} from "../../../../src/interfaces/IJBFundAccessLimits.sol";
|
|
8
|
-
import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
|
|
9
|
-
import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
|
|
10
|
-
import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
|
|
11
|
-
import {JBFundAccessSetup} from "./JBFundAccessSetup.sol";
|
|
12
|
-
|
|
13
|
-
contract TestSetFundAccessLimitsFor_Local is JBFundAccessSetup {
|
|
14
|
-
uint256 _projectId = 1;
|
|
15
|
-
uint256 _ruleset = block.timestamp;
|
|
16
|
-
uint32 _validCurrency = uint32(uint160(JBConstants.NATIVE_TOKEN));
|
|
17
|
-
address _terminal = address(1);
|
|
18
|
-
address _terminal2 = address(2);
|
|
19
|
-
address _someToken = makeAddr("sometoken");
|
|
20
|
-
uint224 _validLimit = 1e18;
|
|
21
|
-
|
|
22
|
-
function setUp() public {
|
|
23
|
-
super.fundAccessSetup();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function test_WhenCallerIsNotController() external {
|
|
27
|
-
// it will revert
|
|
28
|
-
|
|
29
|
-
bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
|
|
30
|
-
bytes memory _return = abi.encode(address(makeAddr("notThisContract")));
|
|
31
|
-
|
|
32
|
-
mockExpect(address(directory), _controllerCall, _return);
|
|
33
|
-
|
|
34
|
-
// Fund Access config
|
|
35
|
-
JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
|
|
36
|
-
|
|
37
|
-
vm.expectRevert(
|
|
38
|
-
abi.encodeWithSelector(
|
|
39
|
-
JBControlled.JBControlled_ControllerUnauthorized.selector, address(makeAddr("notThisContract"))
|
|
40
|
-
)
|
|
41
|
-
);
|
|
42
|
-
_fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
modifier whenCallerIsControllerOfProject() {
|
|
46
|
-
bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
|
|
47
|
-
bytes memory _return = abi.encode(address(this));
|
|
48
|
-
|
|
49
|
-
mockExpect(address(directory), _controllerCall, _return);
|
|
50
|
-
_;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function test_GivenPayoutLimitCurrencyIsNotGivenInAscendingOrder() external whenCallerIsControllerOfProject {
|
|
54
|
-
// it will revert INVALID_PAYOUT_LIMIT_CURRENCY_ORDERING
|
|
55
|
-
|
|
56
|
-
// Fund Access config
|
|
57
|
-
JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
|
|
58
|
-
{
|
|
59
|
-
// Specify a payout limit.
|
|
60
|
-
JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](2);
|
|
61
|
-
_payoutLimits[0] = JBCurrencyAmount({amount: _validLimit, currency: type(uint32).max});
|
|
62
|
-
|
|
63
|
-
// Specify a second payout limit.
|
|
64
|
-
_payoutLimits[1] =
|
|
65
|
-
JBCurrencyAmount({amount: _validLimit, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
|
|
66
|
-
|
|
67
|
-
// Specify a surplus allowance.
|
|
68
|
-
JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](0);
|
|
69
|
-
|
|
70
|
-
_fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
|
|
71
|
-
terminal: address(_terminal),
|
|
72
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
73
|
-
payoutLimits: _payoutLimits,
|
|
74
|
-
surplusAllowances: _surplusAllowances
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
vm.expectRevert(JBFundAccessLimits.JBFundAccessLimits_InvalidPayoutLimitCurrencyOrdering.selector);
|
|
79
|
-
_fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function test_GivenSurplusAllowanceCurrenciesAreNotAscendingOrder() external whenCallerIsControllerOfProject {
|
|
83
|
-
// it will revert INVALID_SURPLUS_ALLOWANCE_CURRENCY_ORDERING
|
|
84
|
-
|
|
85
|
-
// Fund Access config
|
|
86
|
-
JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
|
|
87
|
-
{
|
|
88
|
-
// Specify a payout limit.
|
|
89
|
-
JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](1);
|
|
90
|
-
_payoutLimits[0] = JBCurrencyAmount({amount: _validLimit, currency: _validCurrency});
|
|
91
|
-
|
|
92
|
-
// Specify a surplus allowance.
|
|
93
|
-
JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](2);
|
|
94
|
-
_surplusAllowances[0] = JBCurrencyAmount({amount: _validLimit, currency: type(uint32).max});
|
|
95
|
-
|
|
96
|
-
_surplusAllowances[1] = JBCurrencyAmount({amount: _validLimit, currency: _validCurrency});
|
|
97
|
-
|
|
98
|
-
_fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
|
|
99
|
-
terminal: address(_terminal),
|
|
100
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
101
|
-
payoutLimits: _payoutLimits,
|
|
102
|
-
surplusAllowances: _surplusAllowances
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
vm.expectRevert(JBFundAccessLimits.JBFundAccessLimits_InvalidSurplusAllowanceCurrencyOrdering.selector);
|
|
107
|
-
_fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function test_GivenValidConfig() external whenCallerIsControllerOfProject {
|
|
111
|
-
// it will set packed properties and emit SetFundAccessLimits
|
|
112
|
-
|
|
113
|
-
// Fund Access config
|
|
114
|
-
JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
|
|
115
|
-
{
|
|
116
|
-
// Specify a payout limit.
|
|
117
|
-
JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](2);
|
|
118
|
-
_payoutLimits[0] =
|
|
119
|
-
JBCurrencyAmount({amount: _validLimit, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
|
|
120
|
-
|
|
121
|
-
// Specify a second payout limit.
|
|
122
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
123
|
-
_payoutLimits[1] = JBCurrencyAmount({amount: _validLimit, currency: uint32(uint160(_someToken))});
|
|
124
|
-
|
|
125
|
-
// Specify a surplus allowance.
|
|
126
|
-
JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](0);
|
|
127
|
-
|
|
128
|
-
_fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
|
|
129
|
-
terminal: address(_terminal),
|
|
130
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
131
|
-
payoutLimits: _payoutLimits,
|
|
132
|
-
surplusAllowances: _surplusAllowances
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
_fundAccessLimitGroup[1] = JBFundAccessLimitGroup({
|
|
136
|
-
terminal: address(_terminal2),
|
|
137
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
138
|
-
payoutLimits: _payoutLimits,
|
|
139
|
-
surplusAllowances: _surplusAllowances
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
vm.expectEmit();
|
|
144
|
-
emit IJBFundAccessLimits.SetFundAccessLimits(_ruleset, _projectId, _fundAccessLimitGroup[0], address(this));
|
|
145
|
-
|
|
146
|
-
vm.expectEmit();
|
|
147
|
-
emit IJBFundAccessLimits.SetFundAccessLimits(_ruleset, _projectId, _fundAccessLimitGroup[1], address(this));
|
|
148
|
-
|
|
149
|
-
_fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function test_GivenValidConfigWithLimitsZero() external whenCallerIsControllerOfProject {
|
|
153
|
-
// it will set packed properties and emit SetFundAccessLimits
|
|
154
|
-
|
|
155
|
-
// Fund Access config
|
|
156
|
-
JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
|
|
157
|
-
{
|
|
158
|
-
// Specify a payout limit.
|
|
159
|
-
JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](1);
|
|
160
|
-
_payoutLimits[0] = JBCurrencyAmount({amount: 0, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
|
|
161
|
-
|
|
162
|
-
// Specify a surplus allowance.
|
|
163
|
-
JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](1);
|
|
164
|
-
_surplusAllowances[0] = JBCurrencyAmount({amount: 0, currency: type(uint32).max});
|
|
165
|
-
|
|
166
|
-
_fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
|
|
167
|
-
terminal: address(_terminal),
|
|
168
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
169
|
-
payoutLimits: _payoutLimits,
|
|
170
|
-
surplusAllowances: _surplusAllowances
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
_fundAccessLimitGroup[1] = JBFundAccessLimitGroup({
|
|
174
|
-
terminal: address(_terminal2),
|
|
175
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
176
|
-
payoutLimits: _payoutLimits,
|
|
177
|
-
surplusAllowances: _surplusAllowances
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
vm.expectEmit();
|
|
182
|
-
emit IJBFundAccessLimits.SetFundAccessLimits(_ruleset, _projectId, _fundAccessLimitGroup[0], address(this));
|
|
183
|
-
|
|
184
|
-
vm.expectEmit();
|
|
185
|
-
emit IJBFundAccessLimits.SetFundAccessLimits(_ruleset, _projectId, _fundAccessLimitGroup[1], address(this));
|
|
186
|
-
|
|
187
|
-
_fundAccess.setFundAccessLimitsFor(_projectId, _ruleset, _fundAccessLimitGroup);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
|
|
5
|
-
import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
|
|
6
|
-
import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
|
|
7
|
-
import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
|
|
8
|
-
import {JBFundAccessSetup} from "./JBFundAccessSetup.sol";
|
|
9
|
-
|
|
10
|
-
contract TestSurplusAllowanceOf_Local is JBFundAccessSetup {
|
|
11
|
-
uint256 _projectId = 1;
|
|
12
|
-
address _terminal = address(1);
|
|
13
|
-
|
|
14
|
-
function setUp() public {
|
|
15
|
-
super.fundAccessSetup();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
modifier whenCallerIsControllerOfProject() {
|
|
19
|
-
bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
|
|
20
|
-
bytes memory _return = abi.encode(address(this));
|
|
21
|
-
|
|
22
|
-
mockExpect(address(directory), _controllerCall, _return);
|
|
23
|
-
_;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function test_WhenAProjectHasTheSpecificSurplusConfigured() external whenCallerIsControllerOfProject {
|
|
27
|
-
// it will return uint256 surplusAllowance
|
|
28
|
-
|
|
29
|
-
// Fund Access config
|
|
30
|
-
JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](2);
|
|
31
|
-
{
|
|
32
|
-
// Specify a payout limit.
|
|
33
|
-
JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](0);
|
|
34
|
-
|
|
35
|
-
// Specify a surplus allowance.
|
|
36
|
-
JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](1);
|
|
37
|
-
_surplusAllowances[0] =
|
|
38
|
-
JBCurrencyAmount({amount: 1e18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
|
|
39
|
-
|
|
40
|
-
_fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
|
|
41
|
-
terminal: _terminal,
|
|
42
|
-
token: JBConstants.NATIVE_TOKEN,
|
|
43
|
-
payoutLimits: _payoutLimits,
|
|
44
|
-
surplusAllowances: _surplusAllowances
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
_fundAccess.setFundAccessLimitsFor(_projectId, block.timestamp, _fundAccessLimitGroup);
|
|
49
|
-
|
|
50
|
-
uint256 _returned = _fundAccess.surplusAllowanceOf(
|
|
51
|
-
_projectId, block.timestamp, _terminal, JBConstants.NATIVE_TOKEN, uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
52
|
-
);
|
|
53
|
-
assertEq(_returned, 1e18);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function test_WhenItDoesntHaveTheSpecificSurplusConfigured() external view {
|
|
57
|
-
// it will return 0
|
|
58
|
-
|
|
59
|
-
uint256 _returned = _fundAccess.surplusAllowanceOf(
|
|
60
|
-
_projectId, block.timestamp, _terminal, JBConstants.NATIVE_TOKEN, uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
61
|
-
);
|
|
62
|
-
assertEq(_returned, 0);
|
|
63
|
-
}
|
|
64
|
-
}
|