@bananapus/core-v6 0.0.15 → 0.0.16
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/ADMINISTRATION.md +4 -0
- package/README.md +2 -2
- package/SKILLS.md +2 -0
- package/STYLE_GUIDE.md +16 -2
- package/package.json +2 -2
- package/script/Deploy.s.sol +22 -13
- package/script/DeployPeriphery.s.sol +70 -52
- package/script/helpers/CoreDeploymentLib.sol +83 -35
- package/src/JBChainlinkV3PriceFeed.sol +1 -0
- package/src/JBController.sol +18 -3
- package/src/JBERC20.sol +12 -3
- package/src/JBFundAccessLimits.sol +12 -2
- package/src/JBMultiTerminal.sol +3 -1
- package/src/JBPermissions.sol +1 -0
- package/src/JBProjects.sol +1 -1
- package/src/JBRulesets.sol +11 -0
- package/src/JBSplits.sol +5 -0
- package/src/JBTerminalStore.sol +3 -0
- package/src/JBTokens.sol +40 -4
- package/src/interfaces/IJBController.sol +6 -0
- package/src/interfaces/IJBPermitTerminal.sol +1 -0
- package/src/interfaces/IJBToken.sol +5 -0
- package/src/interfaces/IJBTokens.sol +13 -0
- package/src/libraries/JBMetadataResolver.sol +7 -3
- package/src/libraries/JBRulesetMetadataResolver.sol +21 -21
- package/src/structs/JBAccountingContext.sol +1 -0
- package/src/structs/JBAfterCashOutRecordedContext.sol +1 -0
- package/src/structs/JBAfterPayRecordedContext.sol +1 -0
- package/src/structs/JBBeforeCashOutRecordedContext.sol +1 -0
- package/src/structs/JBBeforePayRecordedContext.sol +1 -0
- package/src/structs/JBCashOutHookSpecification.sol +1 -0
- package/src/structs/JBCurrencyAmount.sol +1 -0
- package/src/structs/JBFee.sol +1 -0
- package/src/structs/JBFundAccessLimitGroup.sol +1 -0
- package/src/structs/JBPayHookSpecification.sol +1 -0
- package/src/structs/JBPermissionsData.sol +1 -0
- package/src/structs/JBRuleset.sol +1 -0
- package/src/structs/JBRulesetConfig.sol +1 -0
- package/src/structs/JBRulesetMetadata.sol +1 -0
- package/src/structs/JBRulesetWeightCache.sol +1 -0
- package/src/structs/JBRulesetWithMetadata.sol +1 -0
- package/src/structs/JBSingleAllowance.sol +1 -0
- package/src/structs/JBSplit.sol +1 -0
- package/src/structs/JBSplitGroup.sol +1 -0
- package/src/structs/JBSplitHookContext.sol +1 -0
- package/src/structs/JBTerminalConfig.sol +1 -0
- package/src/structs/JBTokenAmount.sol +1 -0
- package/test/ComprehensiveInvariant.t.sol +15 -2
- package/test/CoreExploitTests.t.sol +34 -1
- package/test/EconomicSimulation.t.sol +10 -2
- package/test/EntryPointPermutations.t.sol +17 -3
- package/test/FlashLoanAttacks.t.sol +12 -1
- package/test/PermissionEscalation.t.sol +53 -10
- package/test/RulesetTransitions.t.sol +15 -1
- package/test/SplitLoopTests.t.sol +25 -2
- package/test/TestAccessToFunds.sol +17 -2
- package/test/TestCashOut.sol +15 -1
- package/test/TestCashOutCountFor.sol +1 -1
- package/test/TestCashOutHooks.sol +47 -25
- package/test/TestCashOutTimingEdge.sol +13 -1
- package/test/TestDurationUnderflow.sol +13 -1
- package/test/TestFeeProcessingFailure.sol +16 -1
- package/test/TestFees.sol +14 -1
- package/test/TestInterfaceSupport.sol +20 -1
- package/test/TestJBERC20Inheritance.sol +11 -1
- package/test/TestLaunchProject.sol +13 -1
- package/test/TestMetaTx.sol +15 -1
- package/test/TestMetadataParserLib.sol +37 -4
- package/test/TestMigrationHeldFees.sol +16 -1
- package/test/TestMintTokensOf.sol +14 -1
- package/test/TestMultiTokenSurplus.sol +14 -1
- package/test/TestMultipleAccessLimits.sol +23 -1
- package/test/TestPayBurnRedeemFlow.sol +16 -1
- package/test/TestPayHooks.sol +33 -14
- package/test/TestPermissions.sol +20 -1
- package/test/TestPermissionsEdge.sol +5 -1
- package/test/TestPermit2Terminal.sol +36 -3
- package/test/TestRulesetQueueing.sol +24 -1
- package/test/TestRulesetQueuingStress.sol +20 -1
- package/test/TestRulesetWeightCaching.sol +5 -1
- package/test/TestSplits.sol +23 -1
- package/test/TestTerminalMigration.sol +11 -1
- package/test/TestTokenFlow.sol +18 -1
- package/test/TestWeightCacheStaleAfterRejection.sol +15 -1
- package/test/WeirdTokenTests.t.sol +17 -1
- package/test/fork/TestChainlinkPriceFeedFork.sol +6 -1
- package/test/formal/BondingCurveProperties.t.sol +8 -1
- package/test/formal/FeeProperties.t.sol +7 -1
- package/test/helpers/JBTest.sol +1 -1
- package/test/helpers/TestBaseWorkflow.sol +84 -1
- package/test/invariants/Phase3DeepInvariant.t.sol +13 -2
- package/test/invariants/RulesetsInvariant.t.sol +12 -2
- package/test/invariants/TerminalStoreInvariant.t.sol +11 -2
- package/test/invariants/TokensInvariant.t.sol +13 -2
- package/test/invariants/handlers/ComprehensiveHandler.sol +19 -1
- package/test/invariants/handlers/EconomicHandler.sol +31 -1
- package/test/invariants/handlers/Phase3Handler.sol +31 -1
- package/test/invariants/handlers/RulesetsHandler.sol +5 -1
- package/test/invariants/handlers/TerminalStoreHandler.sol +6 -1
- package/test/invariants/handlers/TokensHandler.sol +1 -1
- package/test/mock/MockERC20.sol +0 -2
- package/test/mock/MockMaliciousBeneficiary.sol +2 -1
- package/test/mock/MockMaliciousSplitHook.sol +2 -1
- package/test/mock/MockPriceFeed.sol +1 -1
- package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -1
- package/test/units/static/JBController/JBControllerSetup.sol +10 -1
- package/test/units/static/JBController/TestBurnTokensOf.sol +8 -1
- package/test/units/static/JBController/TestClaimTokensFor.sol +4 -1
- package/test/units/static/JBController/TestDeployErc20For.sol +7 -1
- package/test/units/static/JBController/TestLaunchProjectFor.sol +21 -1
- package/test/units/static/JBController/TestLaunchRulesetsFor.sol +21 -1
- package/test/units/static/JBController/TestMigrateController.sol +10 -1
- package/test/units/static/JBController/TestMintTokensOfUnits.sol +10 -1
- package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +4 -1
- package/test/units/static/JBController/TestReceiveMigrationFrom.sol +5 -1
- package/test/units/static/JBController/TestRulesetViews.sol +7 -1
- package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +21 -1
- package/test/units/static/JBController/TestSetSplitGroupsOf.sol +6 -1
- package/test/units/static/JBController/TestSetTokenFor.sol +13 -1
- package/test/units/static/JBController/TestSetUriOf.sol +5 -1
- package/test/units/static/JBController/TestTransferCreditsFrom.sol +11 -1
- package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +12 -1
- package/test/units/static/JBDirectory/JBDirectorySetup.sol +4 -1
- package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +5 -1
- package/test/units/static/JBDirectory/TestSetControllerOf.sol +11 -1
- package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +7 -1
- package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +11 -1
- package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +10 -1
- package/test/units/static/JBERC20/JBERC20Setup.sol +2 -1
- package/test/units/static/JBERC20/SigUtils.sol +2 -0
- package/test/units/static/JBERC20/TestInitialize.sol +1 -1
- package/test/units/static/JBERC20/TestName.sol +1 -1
- package/test/units/static/JBERC20/TestNonces.sol +3 -1
- package/test/units/static/JBERC20/TestSymbol.sol +1 -1
- package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +2 -1
- package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +2 -1
- package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +1 -1
- package/test/units/static/JBFees/TestFeesFuzz.sol +1 -1
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -1
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -1
- package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +3 -1
- package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +4 -1
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +4 -1
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +8 -1
- package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +8 -1
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +4 -1
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +7 -1
- package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +1 -1
- package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +2 -1
- package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +2 -1
- package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +12 -1
- package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +9 -1
- package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +18 -2
- package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +42 -7
- package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +30 -6
- package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +18 -2
- package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +13 -3
- package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +21 -4
- package/test/units/static/JBMultiTerminal/TestPay.sol +32 -6
- package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -1
- package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +15 -1
- package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +17 -1
- package/test/units/static/JBPermissions/JBPermissionsSetup.sol +2 -1
- package/test/units/static/JBPermissions/TestHasPermission.sol +1 -1
- package/test/units/static/JBPermissions/TestHasPermissions.sol +1 -1
- package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +3 -1
- package/test/units/static/JBPrices/JBPricesSetup.sol +6 -1
- package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +6 -1
- package/test/units/static/JBPrices/TestPricePerUnitOf.sol +4 -1
- package/test/units/static/JBPrices/TestPrices.sol +4 -1
- package/test/units/static/JBProjects/JBProjectsSetup.sol +2 -1
- package/test/units/static/JBProjects/TestCreateFor.sol +3 -1
- package/test/units/static/JBProjects/TestInitialProject.sol +2 -1
- package/test/units/static/JBProjects/TestInterfaces.sol +0 -1
- package/test/units/static/JBProjects/TestSetResolver.sol +2 -1
- package/test/units/static/JBProjects/TestTokenUri.sol +3 -1
- package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +9 -1
- package/test/units/static/JBRulesets/JBRulesetsSetup.sol +3 -1
- package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +9 -1
- package/test/units/static/JBRulesets/TestCurrentOf.sol +10 -1
- package/test/units/static/JBRulesets/TestGetRulesetOf.sol +7 -1
- package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +9 -1
- package/test/units/static/JBRulesets/TestRulesets.sol +12 -1
- package/test/units/static/JBRulesets/TestRulesetsOf.sol +1 -1
- package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +10 -1
- package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +6 -1
- package/test/units/static/JBSplits/JBSplitsSetup.sol +3 -1
- package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +8 -1
- package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +8 -1
- package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +6 -1
- package/test/units/static/JBSplits/TestSplitsOf.sol +1 -1
- package/test/units/static/JBSplits/TestSplitsPacking.sol +5 -2
- package/test/units/static/JBSurplus/TestSurplusFuzz.sol +3 -1
- package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +5 -1
- package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +14 -1
- package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +14 -1
- package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +3 -1
- package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +20 -1
- package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +15 -1
- package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +13 -1
- package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +8 -1
- package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +16 -1
- package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +15 -1
- package/test/units/static/JBTokens/JBTokensSetup.sol +5 -1
- package/test/units/static/JBTokens/TestBurnFrom.sol +4 -1
- package/test/units/static/JBTokens/TestClaimTokensFor.sol +4 -1
- package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +4 -1
- package/test/units/static/JBTokens/TestMintFor.sol +4 -1
- package/test/units/static/JBTokens/TestSetTokenFor.sol +4 -1
- package/test/units/static/JBTokens/TestTotalBalanceOf.sol +1 -1
- package/test/units/static/JBTokens/TestTotalSupplyOf.sol +1 -1
- package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +3 -1
|
@@ -33,6 +33,7 @@ pragma solidity ^0.8.0;
|
|
|
33
33
|
/// @custom:member dataHook The data hook to use during this ruleset.
|
|
34
34
|
/// @custom:member metadata Metadata of the metadata, only the 14 least significant bits can be used, the 2 most
|
|
35
35
|
/// significant bits are disregarded.
|
|
36
|
+
// forge-lint: disable-next-line(pascal-case-struct)
|
|
36
37
|
struct JBRulesetMetadata {
|
|
37
38
|
uint16 reservedPercent;
|
|
38
39
|
uint16 cashOutTaxRate;
|
|
@@ -3,6 +3,7 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
/// @custom:member weight The cached weight value.
|
|
5
5
|
/// @custom:member weightCutMultiple The weight cut multiple that produces the given weight.
|
|
6
|
+
// forge-lint: disable-next-line(pascal-case-struct)
|
|
6
7
|
struct JBRulesetWeightCache {
|
|
7
8
|
uint112 weight;
|
|
8
9
|
uint168 weightCutMultiple;
|
|
@@ -6,6 +6,7 @@ import {JBRulesetMetadata} from "./JBRulesetMetadata.sol";
|
|
|
6
6
|
|
|
7
7
|
/// @custom:member ruleset The ruleset.
|
|
8
8
|
/// @custom:member metadata The ruleset's metadata.
|
|
9
|
+
// forge-lint: disable-next-line(pascal-case-struct)
|
|
9
10
|
struct JBRulesetWithMetadata {
|
|
10
11
|
JBRuleset ruleset;
|
|
11
12
|
JBRulesetMetadata metadata;
|
|
@@ -7,6 +7,7 @@ pragma solidity ^0.8.0;
|
|
|
7
7
|
/// @custom:member nonce An incrementing value indexed per owner,token,and spender for each signature.
|
|
8
8
|
/// @custom:member signature The signature over the permit data. Supports EOA signatures, compact signatures defined by
|
|
9
9
|
/// EIP-2098, and contract signatures defined by EIP-1271.
|
|
10
|
+
// forge-lint: disable-next-line(pascal-case-struct)
|
|
10
11
|
struct JBSingleAllowance {
|
|
11
12
|
uint256 sigDeadline;
|
|
12
13
|
uint160 amount;
|
package/src/structs/JBSplit.sol
CHANGED
|
@@ -27,6 +27,7 @@ import {IJBSplitHook} from "./../interfaces/IJBSplitHook.sol";
|
|
|
27
27
|
/// increased while a split is locked. If `lockedUntil` is zero, this split can be changed at any time.
|
|
28
28
|
/// @custom:member hook A contract which will receive this split's tokens and properties, and can define custom
|
|
29
29
|
/// behavior.
|
|
30
|
+
// forge-lint: disable-next-line(pascal-case-struct)
|
|
30
31
|
struct JBSplit {
|
|
31
32
|
uint32 percent;
|
|
32
33
|
uint64 projectId;
|
|
@@ -6,6 +6,7 @@ import {JBSplit} from "./JBSplit.sol";
|
|
|
6
6
|
/// @custom:member groupId An identifier for the group. By convention, this ID is `uint256(uint160(tokenAddress))` for
|
|
7
7
|
/// payouts and `1` for reserved tokens.
|
|
8
8
|
/// @custom:member splits The splits in the group.
|
|
9
|
+
// forge-lint: disable-next-line(pascal-case-struct)
|
|
9
10
|
struct JBSplitGroup {
|
|
10
11
|
uint256 groupId;
|
|
11
12
|
JBSplit[] splits;
|
|
@@ -10,6 +10,7 @@ import {JBSplit} from "./JBSplit.sol";
|
|
|
10
10
|
/// @custom:member groupId The group the split belongs to. By convention, this ID is `uint256(uint160(tokenAddress))`
|
|
11
11
|
/// for payouts and `1` for reserved tokens.
|
|
12
12
|
/// @custom:member split The split which specified the hook.
|
|
13
|
+
// forge-lint: disable-next-line(pascal-case-struct)
|
|
13
14
|
struct JBSplitHookContext {
|
|
14
15
|
address token;
|
|
15
16
|
uint256 amount;
|
|
@@ -6,6 +6,7 @@ import {IJBTerminal} from "./../interfaces/IJBTerminal.sol";
|
|
|
6
6
|
|
|
7
7
|
/// @custom:member terminal The terminal to configure.
|
|
8
8
|
/// @custom:member accountingContextsToAccept The accounting contexts to accept from the terminal.
|
|
9
|
+
// forge-lint: disable-next-line(pascal-case-struct)
|
|
9
10
|
struct JBTerminalConfig {
|
|
10
11
|
IJBTerminal terminal;
|
|
11
12
|
JBAccountingContext[] accountingContextsToAccept;
|
|
@@ -6,6 +6,7 @@ pragma solidity ^0.8.0;
|
|
|
6
6
|
/// @custom:member currency The currency. By convention, this is `uint32(uint160(tokenAddress))` for tokens, or a
|
|
7
7
|
/// constant ID from e.g. `JBCurrencyIds` for other currencies.
|
|
8
8
|
/// @custom:member value The amount of tokens that was paid, as a fixed point number.
|
|
9
|
+
// forge-lint: disable-next-line(pascal-case-struct)
|
|
9
10
|
struct JBTokenAmount {
|
|
10
11
|
address token;
|
|
11
12
|
uint8 decimals;
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
|
-
import "forge-std/StdInvariant.sol";
|
|
5
|
-
import
|
|
4
|
+
import {StdInvariant} from "forge-std/StdInvariant.sol";
|
|
5
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
6
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
7
|
+
import {IJBSplitHook} from "../src/interfaces/IJBSplitHook.sol";
|
|
8
|
+
import {IJBToken} from "../src/interfaces/IJBToken.sol";
|
|
9
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
10
|
+
import {JBRulesetMetadataResolver} from "../src/libraries/JBRulesetMetadataResolver.sol";
|
|
11
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
12
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
13
|
+
import {JBRuleset} from "../src/structs/JBRuleset.sol";
|
|
14
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
15
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
16
|
+
import {JBSplit} from "../src/structs/JBSplit.sol";
|
|
17
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
18
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
6
19
|
import {ComprehensiveHandler} from "./invariants/handlers/ComprehensiveHandler.sol";
|
|
7
20
|
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
8
21
|
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {MetadataResolverHelper} from "./helpers/MetadataResolverHelper.sol";
|
|
6
|
+
import {MockERC20} from "./mock/MockERC20.sol";
|
|
7
|
+
import {JBMultiTerminal} from "../src/JBMultiTerminal.sol";
|
|
8
|
+
import {JBTokens} from "../src/JBTokens.sol";
|
|
9
|
+
import {JBApprovalStatus} from "../src/enums/JBApprovalStatus.sol";
|
|
10
|
+
import {IJBController} from "../src/interfaces/IJBController.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 {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
|
|
16
|
+
import {IJBToken} from "../src/interfaces/IJBToken.sol";
|
|
17
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
18
|
+
import {JBFees} from "../src/libraries/JBFees.sol";
|
|
19
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
20
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
21
|
+
import {JBFee} from "../src/structs/JBFee.sol";
|
|
22
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
23
|
+
import {JBPayHookSpecification} from "../src/structs/JBPayHookSpecification.sol";
|
|
24
|
+
import {JBRuleset} from "../src/structs/JBRuleset.sol";
|
|
25
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
26
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
27
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
28
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
29
|
+
import {ERC165, IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
5
30
|
import {JBCashOuts} from "../src/libraries/JBCashOuts.sol";
|
|
6
31
|
|
|
7
32
|
/// @notice Tests for edge case scenarios in Juicebox V5.
|
|
@@ -1227,7 +1252,9 @@ contract EdgeCases_Local is TestBaseWorkflow {
|
|
|
1227
1252
|
uint256 hugeBorrow = uint256(type(uint112).max) + 500 ether;
|
|
1228
1253
|
|
|
1229
1254
|
// Silent truncation — Solidity 0.8.x does NOT revert on explicit downcasts!
|
|
1255
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
1230
1256
|
uint112 truncatedCollateral = uint112(hugeCollateral);
|
|
1257
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
1231
1258
|
uint112 truncatedBorrow = uint112(hugeBorrow);
|
|
1232
1259
|
|
|
1233
1260
|
// The truncated values are dramatically smaller.
|
|
@@ -2050,6 +2077,7 @@ contract EdgeCases_Local is TestBaseWorkflow {
|
|
|
2050
2077
|
|
|
2051
2078
|
/// @notice Helper: launches a project with only MockERC20 (6 decimals, simulating USDC on Tempo).
|
|
2052
2079
|
/// No NATIVE_TOKEN accounting context is registered.
|
|
2080
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
2053
2081
|
function _launchProjectERC20(uint16 cashOutTaxRate, uint16 reservedPercent) internal returns (uint256 projectId) {
|
|
2054
2082
|
MockERC20 token = usdcToken();
|
|
2055
2083
|
|
|
@@ -2119,6 +2147,7 @@ contract EdgeCases_Local is TestBaseWorkflow {
|
|
|
2119
2147
|
}
|
|
2120
2148
|
|
|
2121
2149
|
/// @notice Helper: launches an ERC-20-only project with payout limits.
|
|
2150
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
2122
2151
|
function _launchProjectERC20WithPayoutLimit(
|
|
2123
2152
|
uint16 cashOutTaxRate,
|
|
2124
2153
|
uint224 payoutLimit
|
|
@@ -2632,8 +2661,11 @@ contract ReentrancyAttacker {
|
|
|
2632
2661
|
|
|
2633
2662
|
/// @notice Malicious fee terminal that reenters processHeldFeesOf during pay().
|
|
2634
2663
|
contract ReentrantFeeTerminal is ERC165 {
|
|
2664
|
+
// forge-lint: disable-next-line(screaming-snake-case-immutable)
|
|
2635
2665
|
IJBMultiTerminal public immutable victim;
|
|
2666
|
+
// forge-lint: disable-next-line(screaming-snake-case-immutable)
|
|
2636
2667
|
uint256 public immutable targetProjectId;
|
|
2668
|
+
// forge-lint: disable-next-line(screaming-snake-case-immutable)
|
|
2637
2669
|
address public immutable targetToken;
|
|
2638
2670
|
uint256 public payCallCount;
|
|
2639
2671
|
|
|
@@ -2688,6 +2720,7 @@ contract ReentrantFeeTerminal is ERC165 {
|
|
|
2688
2720
|
|
|
2689
2721
|
/// @notice Malicious approval hook that always reverts.
|
|
2690
2722
|
contract MaliciousApprovalHook is ERC165, IJBRulesetApprovalHook {
|
|
2723
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
2691
2724
|
function DURATION() external pure override returns (uint256) {
|
|
2692
2725
|
return 1 days;
|
|
2693
2726
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
|
-
import "forge-std/StdInvariant.sol";
|
|
5
|
-
import
|
|
4
|
+
import {StdInvariant} from "forge-std/StdInvariant.sol";
|
|
5
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
6
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
7
|
+
import {JBRulesetMetadataResolver} from "../src/libraries/JBRulesetMetadataResolver.sol";
|
|
8
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
9
|
+
import {JBRuleset} from "../src/structs/JBRuleset.sol";
|
|
10
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
11
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
12
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
13
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
6
14
|
import {EconomicHandler} from "./invariants/handlers/EconomicHandler.sol";
|
|
7
15
|
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
8
16
|
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
6
|
+
import {JBRulesetMetadataResolver} from "../src/libraries/JBRulesetMetadataResolver.sol";
|
|
7
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
8
|
+
import {JBFee} from "../src/structs/JBFee.sol";
|
|
9
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
10
|
+
import {JBRuleset} from "../src/structs/JBRuleset.sol";
|
|
11
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
12
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
13
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
14
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
5
15
|
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
6
16
|
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
7
17
|
|
|
@@ -592,7 +602,9 @@ contract EntryPointPermutations_Local is TestBaseWorkflow {
|
|
|
592
602
|
if (payoutLimit > 0) {
|
|
593
603
|
payoutLimits = new JBCurrencyAmount[](1);
|
|
594
604
|
payoutLimits[0] = JBCurrencyAmount({
|
|
595
|
-
|
|
605
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
606
|
+
amount: uint224(payoutLimit),
|
|
607
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
596
608
|
});
|
|
597
609
|
} else {
|
|
598
610
|
payoutLimits = new JBCurrencyAmount[](0);
|
|
@@ -601,7 +613,9 @@ contract EntryPointPermutations_Local is TestBaseWorkflow {
|
|
|
601
613
|
if (surplusAllowance > 0) {
|
|
602
614
|
surplusAllowances = new JBCurrencyAmount[](1);
|
|
603
615
|
surplusAllowances[0] = JBCurrencyAmount({
|
|
604
|
-
|
|
616
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
617
|
+
amount: uint224(surplusAllowance),
|
|
618
|
+
currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
605
619
|
});
|
|
606
620
|
} else {
|
|
607
621
|
surplusAllowances = new JBCurrencyAmount[](0);
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
6
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
7
|
+
import {JBRulesetMetadataResolver} from "../src/libraries/JBRulesetMetadataResolver.sol";
|
|
8
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
9
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
10
|
+
import {JBRuleset} from "../src/structs/JBRuleset.sol";
|
|
11
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
12
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
13
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
14
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
5
15
|
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
6
16
|
|
|
7
17
|
/// @notice Tests that flash-loan style atomic pay+cashOut attacks cannot extract profit.
|
|
@@ -548,6 +558,7 @@ contract FlashLoanAttacks_Local is TestBaseWorkflow {
|
|
|
548
558
|
|
|
549
559
|
// Attacker front-runs: pays right before payout
|
|
550
560
|
address attacker = address(0xA77AC0);
|
|
561
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
551
562
|
uint256 attackerInitialETH = 10 ether;
|
|
552
563
|
vm.deal(attacker, attackerInitialETH);
|
|
553
564
|
vm.prank(attacker);
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {JBPermissions} from "../src/JBPermissions.sol";
|
|
6
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
7
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
8
|
+
import {JBRulesetMetadataResolver} from "../src/libraries/JBRulesetMetadataResolver.sol";
|
|
9
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
10
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
11
|
+
import {JBPermissionsData} from "../src/structs/JBPermissionsData.sol";
|
|
12
|
+
import {JBRuleset} from "../src/structs/JBRuleset.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
|
+
import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
|
|
5
18
|
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
6
19
|
|
|
7
20
|
/// @notice Tests for permission system correctness: ROOT restrictions, wildcard, boundary IDs, escalation prevention.
|
|
@@ -38,6 +51,7 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
38
51
|
jbPermissions()
|
|
39
52
|
.setPermissionsFor(
|
|
40
53
|
projectOwner,
|
|
54
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
41
55
|
JBPermissionsData({operator: alice, projectId: uint64(projectId2), permissionIds: rootPerms})
|
|
42
56
|
);
|
|
43
57
|
}
|
|
@@ -175,13 +189,17 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
175
189
|
JBPermissions.JBPermissions_Unauthorized.selector,
|
|
176
190
|
projectOwner,
|
|
177
191
|
alice,
|
|
192
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
178
193
|
uint64(projectId2),
|
|
179
194
|
JBPermissionIds.ROOT
|
|
180
195
|
)
|
|
181
196
|
);
|
|
182
197
|
jbPermissions()
|
|
183
198
|
.setPermissionsFor(
|
|
184
|
-
|
|
199
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
200
|
+
projectOwner,
|
|
201
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
202
|
+
JBPermissionsData({operator: bob, projectId: uint64(projectId2), permissionIds: perms})
|
|
185
203
|
);
|
|
186
204
|
}
|
|
187
205
|
|
|
@@ -197,7 +215,10 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
197
215
|
vm.prank(alice);
|
|
198
216
|
jbPermissions()
|
|
199
217
|
.setPermissionsFor(
|
|
200
|
-
|
|
218
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
219
|
+
projectOwner,
|
|
220
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
221
|
+
JBPermissionsData({operator: bob, projectId: uint64(projectId2), permissionIds: perms})
|
|
201
222
|
);
|
|
202
223
|
|
|
203
224
|
// Verify Bob now has CASH_OUT_TOKENS
|
|
@@ -263,7 +284,10 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
263
284
|
vm.prank(projectOwner);
|
|
264
285
|
jbPermissions()
|
|
265
286
|
.setPermissionsFor(
|
|
266
|
-
|
|
287
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
288
|
+
projectOwner,
|
|
289
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
290
|
+
JBPermissionsData({operator: bob, projectId: uint64(projectId2), permissionIds: perms})
|
|
267
291
|
);
|
|
268
292
|
|
|
269
293
|
// Verify Bob has it
|
|
@@ -287,6 +311,7 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
287
311
|
jbPermissions()
|
|
288
312
|
.setPermissionsFor(
|
|
289
313
|
projectOwner,
|
|
314
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
290
315
|
JBPermissionsData({operator: bob, projectId: uint64(projectId2), permissionIds: emptyPerms})
|
|
291
316
|
);
|
|
292
317
|
|
|
@@ -317,7 +342,10 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
317
342
|
vm.prank(projectOwner);
|
|
318
343
|
jbPermissions()
|
|
319
344
|
.setPermissionsFor(
|
|
320
|
-
|
|
345
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
346
|
+
projectOwner,
|
|
347
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
348
|
+
JBPermissionsData({operator: bob, projectId: uint64(projectId2), permissionIds: perms})
|
|
321
349
|
);
|
|
322
350
|
|
|
323
351
|
bool hasPerm = jbPermissions()
|
|
@@ -357,7 +385,10 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
357
385
|
vm.expectRevert(abi.encodeWithSelector(JBPermissions.JBPermissions_NoZeroPermission.selector));
|
|
358
386
|
jbPermissions()
|
|
359
387
|
.setPermissionsFor(
|
|
360
|
-
|
|
388
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
389
|
+
projectOwner,
|
|
390
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
391
|
+
JBPermissionsData({operator: bob, projectId: uint64(projectId2), permissionIds: perms})
|
|
361
392
|
);
|
|
362
393
|
}
|
|
363
394
|
|
|
@@ -468,7 +499,10 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
468
499
|
vm.prank(projectOwner);
|
|
469
500
|
jbPermissions()
|
|
470
501
|
.setPermissionsFor(
|
|
471
|
-
|
|
502
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
503
|
+
projectOwner,
|
|
504
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
505
|
+
JBPermissionsData({operator: bob, projectId: uint64(pid), permissionIds: perms})
|
|
472
506
|
);
|
|
473
507
|
|
|
474
508
|
// Charlie (no permission) tries to send payouts — should fail because ownerMustSendPayouts
|
|
@@ -539,7 +573,10 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
539
573
|
vm.prank(projectOwner);
|
|
540
574
|
jbPermissions()
|
|
541
575
|
.setPermissionsFor(
|
|
542
|
-
|
|
576
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
577
|
+
projectOwner,
|
|
578
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
579
|
+
JBPermissionsData({operator: bob, projectId: uint64(projectId2), permissionIds: perms1})
|
|
543
580
|
);
|
|
544
581
|
|
|
545
582
|
assertTrue(
|
|
@@ -574,7 +611,10 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
574
611
|
vm.prank(projectOwner);
|
|
575
612
|
jbPermissions()
|
|
576
613
|
.setPermissionsFor(
|
|
577
|
-
|
|
614
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
615
|
+
projectOwner,
|
|
616
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
617
|
+
JBPermissionsData({operator: bob, projectId: uint64(projectId2), permissionIds: perms2})
|
|
578
618
|
);
|
|
579
619
|
|
|
580
620
|
// Bob should only have MINT_TOKENS, not the previous ones
|
|
@@ -628,7 +668,10 @@ contract PermissionEscalation_Local is TestBaseWorkflow {
|
|
|
628
668
|
vm.prank(projectOwner);
|
|
629
669
|
jbPermissions()
|
|
630
670
|
.setPermissionsFor(
|
|
631
|
-
|
|
671
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
672
|
+
projectOwner,
|
|
673
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
674
|
+
JBPermissionsData({operator: bob, projectId: uint64(projectId2), permissionIds: perms})
|
|
632
675
|
);
|
|
633
676
|
|
|
634
677
|
// Call from trusted forwarder with Bob appended as sender
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {JBApprovalStatus} from "../src/enums/JBApprovalStatus.sol";
|
|
6
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
7
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
8
|
+
import {JBRulesetMetadataResolver} from "../src/libraries/JBRulesetMetadataResolver.sol";
|
|
9
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
10
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
11
|
+
import {JBRuleset} from "../src/structs/JBRuleset.sol";
|
|
12
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
13
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
14
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
15
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
5
16
|
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
6
17
|
import {ERC165, IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
7
18
|
|
|
@@ -255,6 +266,7 @@ contract RulesetTransitions_Local is TestBaseWorkflow {
|
|
|
255
266
|
uint256[] memory tokensPerCycle = new uint256[](10);
|
|
256
267
|
for (uint256 i = 0; i < 10; i++) {
|
|
257
268
|
if (i > 0) vm.warp(block.timestamp + 1 days + 1);
|
|
269
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
258
270
|
tokensPerCycle[i] = _payProject(pid, address(uint160(0x6000 + i)), 1 ether);
|
|
259
271
|
}
|
|
260
272
|
|
|
@@ -660,6 +672,7 @@ contract RulesetTransitions_Local is TestBaseWorkflow {
|
|
|
660
672
|
|
|
661
673
|
/// @notice Approval hook that approves after a configurable delay.
|
|
662
674
|
contract DelayedApprovalHook is ERC165, IJBRulesetApprovalHook {
|
|
675
|
+
// forge-lint: disable-next-line(screaming-snake-case-immutable)
|
|
663
676
|
uint256 public immutable approvalDelay;
|
|
664
677
|
|
|
665
678
|
constructor(uint256 _approvalDelay) {
|
|
@@ -685,6 +698,7 @@ contract DelayedApprovalHook is ERC165, IJBRulesetApprovalHook {
|
|
|
685
698
|
|
|
686
699
|
/// @notice Approval hook that always rejects.
|
|
687
700
|
contract AlwaysRejectingHook is ERC165, IJBRulesetApprovalHook {
|
|
701
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
688
702
|
function DURATION() external pure override returns (uint256) {
|
|
689
703
|
return 0;
|
|
690
704
|
}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {IJBMultiTerminal} from "../src/interfaces/IJBMultiTerminal.sol";
|
|
6
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
7
|
+
import {IJBSplitHook} from "../src/interfaces/IJBSplitHook.sol";
|
|
8
|
+
import {IJBTokens} from "../src/interfaces/IJBTokens.sol";
|
|
9
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
10
|
+
import {JBRulesetMetadataResolver} from "../src/libraries/JBRulesetMetadataResolver.sol";
|
|
11
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
12
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
13
|
+
import {JBRuleset} from "../src/structs/JBRuleset.sol";
|
|
14
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
15
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
16
|
+
import {JBSplit} from "../src/structs/JBSplit.sol";
|
|
17
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
18
|
+
import {JBSplitHookContext} from "../src/structs/JBSplitHookContext.sol";
|
|
19
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
5
20
|
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
6
21
|
import {ERC165, IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
7
22
|
|
|
@@ -120,7 +135,8 @@ contract SplitLoopTests_Local is TestBaseWorkflow {
|
|
|
120
135
|
|
|
121
136
|
JBCurrencyAmount[] memory payoutLimits = new JBCurrencyAmount[](1);
|
|
122
137
|
payoutLimits[0] =
|
|
123
|
-
|
|
138
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
139
|
+
JBCurrencyAmount({amount: uint224(payoutLimit), currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
|
|
124
140
|
JBFundAccessLimitGroup[] memory fundAccessLimitGroups = new JBFundAccessLimitGroup[](1);
|
|
125
141
|
fundAccessLimitGroups[0] = JBFundAccessLimitGroup({
|
|
126
142
|
terminal: address(jbMultiTerminal()),
|
|
@@ -186,12 +202,14 @@ contract SplitLoopTests_Local is TestBaseWorkflow {
|
|
|
186
202
|
projectA = _launchProjectWithSplitsAndPayoutLimit(dummySplits, 10 ether);
|
|
187
203
|
|
|
188
204
|
// Now create B with split to A
|
|
205
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
189
206
|
splitsB[0].projectId = uint64(projectA);
|
|
190
207
|
projectB = _launchProjectWithSplitsAndPayoutLimit(splitsB, 10 ether);
|
|
191
208
|
|
|
192
209
|
// Update A's splits to point to B
|
|
193
210
|
(JBRuleset memory rulesetA,) = jbController().currentRulesetOf(projectA);
|
|
194
211
|
JBSplitGroup[] memory newSplitGroupsA = new JBSplitGroup[](1);
|
|
212
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
195
213
|
splitsA[0].projectId = uint64(projectB);
|
|
196
214
|
newSplitGroupsA[0] = JBSplitGroup({groupId: uint256(uint160(JBConstants.NATIVE_TOKEN)), splits: splitsA});
|
|
197
215
|
vm.prank(projectOwner);
|
|
@@ -372,6 +390,7 @@ contract SplitLoopTests_Local is TestBaseWorkflow {
|
|
|
372
390
|
uint256 pid = _launchProjectWithSplitsAndPayoutLimit(new JBSplit[](0), 10 ether);
|
|
373
391
|
|
|
374
392
|
// Update splits to point to self
|
|
393
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
375
394
|
splits[0].projectId = uint64(pid);
|
|
376
395
|
(JBRuleset memory ruleset,) = jbController().currentRulesetOf(pid);
|
|
377
396
|
JBSplitGroup[] memory newSplitGroups = new JBSplitGroup[](1);
|
|
@@ -404,12 +423,14 @@ contract SplitLoopTests_Local is TestBaseWorkflow {
|
|
|
404
423
|
uint256 numSplits = 200;
|
|
405
424
|
JBSplit[] memory splits = new JBSplit[](numSplits);
|
|
406
425
|
|
|
426
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
407
427
|
uint32 perSplitPercent = uint32(JBConstants.SPLITS_TOTAL_PERCENT / numSplits);
|
|
408
428
|
|
|
409
429
|
for (uint256 i = 0; i < numSplits; i++) {
|
|
410
430
|
splits[i] = JBSplit({
|
|
411
431
|
percent: perSplitPercent,
|
|
412
432
|
projectId: 0,
|
|
433
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
413
434
|
beneficiary: payable(address(uint160(0x3000 + i))),
|
|
414
435
|
preferAddToBalance: false,
|
|
415
436
|
lockedUntil: 0,
|
|
@@ -452,6 +473,7 @@ contract SplitLoopTests_Local is TestBaseWorkflow {
|
|
|
452
473
|
splits[i] = JBSplit({
|
|
453
474
|
percent: oneThird,
|
|
454
475
|
projectId: 0,
|
|
476
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
455
477
|
beneficiary: payable(address(uint160(0x4000 + i))),
|
|
456
478
|
preferAddToBalance: false,
|
|
457
479
|
lockedUntil: 0,
|
|
@@ -476,6 +498,7 @@ contract SplitLoopTests_Local is TestBaseWorkflow {
|
|
|
476
498
|
// Check no rounding loss greater than 3 wei (one per split)
|
|
477
499
|
uint256 totalPaidToSplits = 0;
|
|
478
500
|
for (uint256 i = 0; i < 3; i++) {
|
|
501
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
479
502
|
totalPaidToSplits += address(uint160(0x4000 + i)).balance;
|
|
480
503
|
}
|
|
481
504
|
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity >=0.8.6;
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import "
|
|
4
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {MockERC20} from "./mock/MockERC20.sol";
|
|
6
|
+
import {JBTerminalStore} from "../src/JBTerminalStore.sol";
|
|
7
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
8
|
+
import {IJBMultiTerminal} from "../src/interfaces/IJBMultiTerminal.sol";
|
|
9
|
+
import {IJBPrices} from "../src/interfaces/IJBPrices.sol";
|
|
10
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
11
|
+
import {IJBTokens} from "../src/interfaces/IJBTokens.sol";
|
|
12
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
13
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
14
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
15
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
16
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
17
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
18
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
19
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
20
|
+
import {mulDiv} from "@prb/math/src/Common.sol";
|
|
6
21
|
import {MockPriceFeed} from "./mock/MockPriceFeed.sol";
|
|
7
22
|
import {MaliciousAllowanceBeneficiary, MaliciousPayoutBeneficiary} from "./mock/MockMaliciousBeneficiary.sol";
|
|
8
23
|
|
package/test/TestCashOut.sol
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {JBTokens} from "../src/JBTokens.sol";
|
|
6
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
7
|
+
import {IJBMultiTerminal} from "../src/interfaces/IJBMultiTerminal.sol";
|
|
8
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
9
|
+
import {IJBTerminal} from "../src/interfaces/IJBTerminal.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
|
+
import {mulDiv} from "@prb/math/src/Common.sol";
|
|
18
|
+
import {mul as UD60x18mul, unwrap as UD60x18unwrap, wrap as UD60x18wrap} from "@prb/math/src/UD60x18.sol";
|
|
5
19
|
|
|
6
20
|
// Projects can issue a token, be paid to receieve claimed tokens, burn some of the claimed tokens, cash out the rest
|
|
7
21
|
// of
|