@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
package/test/TestPayHooks.sol
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
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 {IJBController} from "../src/interfaces/IJBController.sol";
|
|
6
|
+
import {IJBPayHook} from "../src/interfaces/IJBPayHook.sol";
|
|
7
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
8
|
+
import {IJBRulesetDataHook} from "../src/interfaces/IJBRulesetDataHook.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 {JBAfterPayRecordedContext} from "../src/structs/JBAfterPayRecordedContext.sol";
|
|
13
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
14
|
+
import {JBPayHookSpecification} from "../src/structs/JBPayHookSpecification.sol";
|
|
15
|
+
import {JBRuleset} from "../src/structs/JBRuleset.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 {JBTokenAmount} from "../src/structs/JBTokenAmount.sol";
|
|
21
|
+
import {mulDiv} from "@prb/math/src/Common.sol";
|
|
5
22
|
|
|
6
23
|
contract TestPayHooks_Local is TestBaseWorkflow {
|
|
7
24
|
uint8 private constant _WEIGHT_DECIMALS = 18;
|
|
@@ -118,25 +135,27 @@ contract TestPayHooks_Local is TestBaseWorkflow {
|
|
|
118
135
|
bytes memory _hookMetadata = bytes("Some data hook metadata");
|
|
119
136
|
|
|
120
137
|
// Package up the specification struct.
|
|
121
|
-
_specifications[i] = JBPayHookSpecification(
|
|
138
|
+
_specifications[i] = JBPayHookSpecification({
|
|
139
|
+
hook: IJBPayHook(_hookAddress), amount: _payHookAmounts[i], metadata: _hookMetadata
|
|
140
|
+
});
|
|
122
141
|
|
|
123
142
|
// Keep a reference to the data that'll be received by the hook.
|
|
124
143
|
JBAfterPayRecordedContext memory _postRecordPayContext = JBAfterPayRecordedContext({
|
|
125
144
|
payer: _payer,
|
|
126
145
|
projectId: _projectId,
|
|
127
146
|
rulesetId: _ruleset.id,
|
|
128
|
-
amount: JBTokenAmount(
|
|
129
|
-
JBConstants.NATIVE_TOKEN,
|
|
130
|
-
_terminal.accountingContextForTokenOf(_projectId, JBConstants.NATIVE_TOKEN).decimals,
|
|
131
|
-
_terminal.accountingContextForTokenOf(_projectId, JBConstants.NATIVE_TOKEN).currency,
|
|
132
|
-
_nativePayAmount
|
|
133
|
-
),
|
|
134
|
-
forwardedAmount: JBTokenAmount(
|
|
135
|
-
JBConstants.NATIVE_TOKEN,
|
|
136
|
-
_terminal.accountingContextForTokenOf(_projectId, JBConstants.NATIVE_TOKEN).decimals,
|
|
137
|
-
_terminal.accountingContextForTokenOf(_projectId, JBConstants.NATIVE_TOKEN).currency,
|
|
138
|
-
_payHookAmounts[i]
|
|
139
|
-
),
|
|
147
|
+
amount: JBTokenAmount({
|
|
148
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
149
|
+
decimals: _terminal.accountingContextForTokenOf(_projectId, JBConstants.NATIVE_TOKEN).decimals,
|
|
150
|
+
currency: _terminal.accountingContextForTokenOf(_projectId, JBConstants.NATIVE_TOKEN).currency,
|
|
151
|
+
value: _nativePayAmount
|
|
152
|
+
}),
|
|
153
|
+
forwardedAmount: JBTokenAmount({
|
|
154
|
+
token: JBConstants.NATIVE_TOKEN,
|
|
155
|
+
decimals: _terminal.accountingContextForTokenOf(_projectId, JBConstants.NATIVE_TOKEN).decimals,
|
|
156
|
+
currency: _terminal.accountingContextForTokenOf(_projectId, JBConstants.NATIVE_TOKEN).currency,
|
|
157
|
+
value: _payHookAmounts[i]
|
|
158
|
+
}),
|
|
140
159
|
weight: _WEIGHT,
|
|
141
160
|
newlyIssuedTokenCount: mulDiv(_nativePayAmount, _DATA_HOOK_WEIGHT, 10 ** _NATIVE_TOKEN_DECIMALS),
|
|
142
161
|
beneficiary: _beneficiary,
|
package/test/TestPermissions.sol
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
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 {MockERC20} from "./mock/MockERC20.sol";
|
|
6
|
+
import {JBPermissions} from "../src/JBPermissions.sol";
|
|
7
|
+
import {JBPermissioned} from "../src/abstract/JBPermissioned.sol";
|
|
8
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
9
|
+
import {IJBPermissions} from "../src/interfaces/IJBPermissions.sol";
|
|
10
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
11
|
+
import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
|
|
12
|
+
import {IJBToken} from "../src/interfaces/IJBToken.sol";
|
|
13
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
14
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
15
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
16
|
+
import {JBPermissionsData} from "../src/structs/JBPermissionsData.sol";
|
|
17
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
18
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
19
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
20
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
21
|
+
import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
|
|
5
22
|
|
|
6
23
|
contract TestPermissions_Local is TestBaseWorkflow {
|
|
7
24
|
IJBController private _controller;
|
|
@@ -135,6 +152,7 @@ contract TestPermissions_Local is TestBaseWorkflow {
|
|
|
135
152
|
address _op,
|
|
136
153
|
uint56 _projectId,
|
|
137
154
|
uint8 _checkedId,
|
|
155
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
138
156
|
uint8[] memory _set_permissions
|
|
139
157
|
)
|
|
140
158
|
public
|
|
@@ -143,6 +161,7 @@ contract TestPermissions_Local is TestBaseWorkflow {
|
|
|
143
161
|
vm.assume(_set_permissions.length != 0);
|
|
144
162
|
vm.assume(_account != trustedForwarder());
|
|
145
163
|
|
|
164
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
146
165
|
uint256[] memory _check_permissions = new uint256[](1);
|
|
147
166
|
_check_permissions[0] = _checkedId;
|
|
148
167
|
|
|
@@ -1,7 +1,10 @@
|
|
|
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 {JBPermissionsData} from "../src/structs/JBPermissionsData.sol";
|
|
7
|
+
import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
|
|
5
8
|
|
|
6
9
|
/// @notice Defense-in-depth validation of JBPermissions ROOT escalation prevention.
|
|
7
10
|
/// Verifies that ROOT operators cannot forward ROOT, cannot set wildcard permissions,
|
|
@@ -231,6 +234,7 @@ contract TestPermissionsEdge_Local is TestBaseWorkflow {
|
|
|
231
234
|
uint256 idx;
|
|
232
235
|
for (uint256 i = 1; i < 256; i++) {
|
|
233
236
|
if ((bitmap >> i) & 1 == 1) {
|
|
237
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
234
238
|
ids[idx] = uint8(i);
|
|
235
239
|
idx++;
|
|
236
240
|
}
|
|
@@ -1,7 +1,23 @@
|
|
|
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 {JBMultiTerminal} from "../src/JBMultiTerminal.sol";
|
|
7
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
8
|
+
import {IJBPrices} from "../src/interfaces/IJBPrices.sol";
|
|
9
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
10
|
+
import {IJBTerminal} from "../src/interfaces/IJBTerminal.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 {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
15
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
16
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
17
|
+
import {JBSingleAllowance} from "../src/structs/JBSingleAllowance.sol";
|
|
18
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
19
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
20
|
+
import {IAllowanceTransfer, IPermit2} from "@uniswap/permit2/src/interfaces/IPermit2.sol";
|
|
5
21
|
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
6
22
|
import {MockPriceFeed} from "./mock/MockPriceFeed.sol";
|
|
7
23
|
|
|
@@ -20,6 +36,7 @@ contract TestPermit2Terminal_Local is TestBaseWorkflow {
|
|
|
20
36
|
uint256 _projectId;
|
|
21
37
|
|
|
22
38
|
// Permit2 params.
|
|
39
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
23
40
|
bytes32 DOMAIN_SEPARATOR;
|
|
24
41
|
address from;
|
|
25
42
|
uint256 fromPrivateKey;
|
|
@@ -126,7 +143,13 @@ contract TestPermit2Terminal_Local is TestBaseWorkflow {
|
|
|
126
143
|
|
|
127
144
|
// Setup: prepare permit details for signing.
|
|
128
145
|
IAllowanceTransfer.PermitDetails memory details = IAllowanceTransfer.PermitDetails({
|
|
129
|
-
|
|
146
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
147
|
+
token: address(_usdc),
|
|
148
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
149
|
+
amount: uint160(_coins),
|
|
150
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
151
|
+
expiration: uint48(_expiration),
|
|
152
|
+
nonce: 0
|
|
130
153
|
});
|
|
131
154
|
|
|
132
155
|
IAllowanceTransfer.PermitSingle memory permit =
|
|
@@ -137,7 +160,9 @@ contract TestPermit2Terminal_Local is TestBaseWorkflow {
|
|
|
137
160
|
|
|
138
161
|
JBSingleAllowance memory permitData = JBSingleAllowance({
|
|
139
162
|
sigDeadline: _deadline,
|
|
163
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
140
164
|
amount: uint160(_coins),
|
|
165
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
141
166
|
expiration: uint48(_expiration),
|
|
142
167
|
nonce: uint48(0),
|
|
143
168
|
signature: sig
|
|
@@ -191,7 +216,13 @@ contract TestPermit2Terminal_Local is TestBaseWorkflow {
|
|
|
191
216
|
|
|
192
217
|
// Setup: prepare permit details for signing.
|
|
193
218
|
IAllowanceTransfer.PermitDetails memory details = IAllowanceTransfer.PermitDetails({
|
|
194
|
-
|
|
219
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
220
|
+
token: address(_usdc),
|
|
221
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
222
|
+
amount: uint160(_coins),
|
|
223
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
224
|
+
expiration: uint48(_expiration),
|
|
225
|
+
nonce: 0
|
|
195
226
|
});
|
|
196
227
|
|
|
197
228
|
IAllowanceTransfer.PermitSingle memory permit =
|
|
@@ -202,7 +233,9 @@ contract TestPermit2Terminal_Local is TestBaseWorkflow {
|
|
|
202
233
|
|
|
203
234
|
JBSingleAllowance memory permitData = JBSingleAllowance({
|
|
204
235
|
sigDeadline: _deadline,
|
|
236
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
205
237
|
amount: uint160(_coins),
|
|
238
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
206
239
|
expiration: uint48(_expiration),
|
|
207
240
|
nonce: uint48(0),
|
|
208
241
|
signature: sig
|
|
@@ -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 {JBController} from "../src/JBController.sol";
|
|
6
|
+
import {JBDeadline} from "../src/JBDeadline.sol";
|
|
7
|
+
import {JBRulesets} from "../src/JBRulesets.sol";
|
|
8
|
+
import {JBApprovalStatus} from "../src/enums/JBApprovalStatus.sol";
|
|
9
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
10
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
11
|
+
import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
|
|
12
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
13
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
14
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
15
|
+
import {JBRuleset} from "../src/structs/JBRuleset.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";
|
|
5
20
|
|
|
6
21
|
// A project's rulesets can be queued, and re-queued as long as the current ruleset approval hook approves.
|
|
7
22
|
contract TestRulesetQueuing_Local is TestBaseWorkflow {
|
|
@@ -13,8 +28,12 @@ contract TestRulesetQueuing_Local is TestBaseWorkflow {
|
|
|
13
28
|
IJBTerminal private _terminal;
|
|
14
29
|
uint112 private _weight;
|
|
15
30
|
|
|
31
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
16
32
|
uint256 private _DEADLINE_DURATION = 3 days;
|
|
33
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
17
34
|
uint256 private _RULESET_DURATION_DAYS = 6;
|
|
35
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
36
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
18
37
|
uint32 private _RULESET_DURATION = uint32(_RULESET_DURATION_DAYS * 1 days);
|
|
19
38
|
|
|
20
39
|
function setUp() public override {
|
|
@@ -779,6 +798,7 @@ contract TestRulesetQueuing_Local is TestBaseWorkflow {
|
|
|
779
798
|
// Package up another config to overwrite.
|
|
780
799
|
JBRulesetConfig[] memory _secondQueued = new JBRulesetConfig[](1);
|
|
781
800
|
|
|
801
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
782
802
|
_secondQueued[0].mustStartAtOrAfter = uint48(block.timestamp + _DEADLINE_DURATION);
|
|
783
803
|
_secondQueued[0].duration = _RULESET_DURATION;
|
|
784
804
|
_secondQueued[0].weight = _weightSecondQueued;
|
|
@@ -805,10 +825,13 @@ contract TestRulesetQueuing_Local is TestBaseWorkflow {
|
|
|
805
825
|
_duration = bound(_duration, 1, block.timestamp);
|
|
806
826
|
|
|
807
827
|
JBRuleset memory _ruleset = JBRuleset({
|
|
828
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
808
829
|
id: uint48(_rulesetId),
|
|
809
830
|
basedOnId: 0,
|
|
810
831
|
cycleNumber: 1,
|
|
832
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
811
833
|
start: uint48(_start),
|
|
834
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
812
835
|
duration: uint32(_duration),
|
|
813
836
|
weight: 1,
|
|
814
837
|
weightCutPercent: 0,
|
|
@@ -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 {JBDeadline} from "../src/JBDeadline.sol";
|
|
6
|
+
import {JBApprovalStatus} from "../src/enums/JBApprovalStatus.sol";
|
|
7
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
8
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
9
|
+
import {IJBRulesets} from "../src/interfaces/IJBRulesets.sol";
|
|
10
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
11
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.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 {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
5
18
|
|
|
6
19
|
/// @notice Mock approval hook that always returns a configurable status.
|
|
7
20
|
contract MockApprovalHookConfigurable is IJBRulesetApprovalHook {
|
|
@@ -350,6 +363,7 @@ contract MockApprovalHookConfigurable is IJBRulesetApprovalHook {
|
|
|
350
363
|
pid,
|
|
351
364
|
0,
|
|
352
365
|
FOURTEEN_DAYS,
|
|
366
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
353
367
|
uint112(INITIAL_WEIGHT + uint112(i) * 100e18),
|
|
354
368
|
0,
|
|
355
369
|
IJBRulesetApprovalHook(address(0))
|
|
@@ -544,6 +558,7 @@ contract MockApprovalHookConfigurable is IJBRulesetApprovalHook {
|
|
|
544
558
|
|
|
545
559
|
_queueRuleset(
|
|
546
560
|
pid,
|
|
561
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
547
562
|
uint48(originalStart + SEVEN_DAYS),
|
|
548
563
|
SEVEN_DAYS,
|
|
549
564
|
INITIAL_WEIGHT * 2,
|
|
@@ -563,6 +578,7 @@ contract MockApprovalHookConfigurable is IJBRulesetApprovalHook {
|
|
|
563
578
|
// 1 second after first boundary -> should snap to second boundary.
|
|
564
579
|
_queueRuleset(
|
|
565
580
|
pid,
|
|
581
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
566
582
|
uint48(originalStart + SEVEN_DAYS + 1),
|
|
567
583
|
SEVEN_DAYS,
|
|
568
584
|
INITIAL_WEIGHT * 2,
|
|
@@ -599,6 +615,7 @@ contract MockApprovalHookConfigurable is IJBRulesetApprovalHook {
|
|
|
599
615
|
pid,
|
|
600
616
|
0,
|
|
601
617
|
SEVEN_DAYS,
|
|
618
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
602
619
|
uint112(INITIAL_WEIGHT + uint112(i) * 100e18),
|
|
603
620
|
0,
|
|
604
621
|
IJBRulesetApprovalHook(address(0))
|
|
@@ -608,6 +625,7 @@ contract MockApprovalHookConfigurable is IJBRulesetApprovalHook {
|
|
|
608
625
|
JBRuleset memory current = _rulesets.currentOf(pid);
|
|
609
626
|
assertEq(
|
|
610
627
|
current.weight,
|
|
628
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
611
629
|
INITIAL_WEIGHT + uint112(i) * 100e18,
|
|
612
630
|
string.concat("Cycle ", vm.toString(i + 1), " weight mismatch")
|
|
613
631
|
);
|
|
@@ -765,6 +783,7 @@ contract MockApprovalHookConfigurable is IJBRulesetApprovalHook {
|
|
|
765
783
|
pid,
|
|
766
784
|
0,
|
|
767
785
|
SEVEN_DAYS,
|
|
786
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
768
787
|
uint112(INITIAL_WEIGHT + uint112(i) * 100e18),
|
|
769
788
|
0,
|
|
770
789
|
IJBRulesetApprovalHook(address(0))
|
|
@@ -1,7 +1,11 @@
|
|
|
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 {IJBController} from "../src/interfaces/IJBController.sol";
|
|
6
|
+
import {IJBRulesets} from "../src/interfaces/IJBRulesets.sol";
|
|
7
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
8
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
5
9
|
|
|
6
10
|
// A ruleset's weight can be cached to make larger intervals calculable while staying within the gas limit.
|
|
7
11
|
contract TestRulesetWeightCaching_Local is TestBaseWorkflow {
|
package/test/TestSplits.sol
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
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 {JBTerminalStore} from "../src/JBTerminalStore.sol";
|
|
6
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
7
|
+
import {IJBDirectory} from "../src/interfaces/IJBDirectory.sol";
|
|
8
|
+
import {IJBMultiTerminal} from "../src/interfaces/IJBMultiTerminal.sol";
|
|
9
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
10
|
+
import {IJBSplitHook} from "../src/interfaces/IJBSplitHook.sol";
|
|
11
|
+
import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
|
|
12
|
+
import {IJBTokens} from "../src/interfaces/IJBTokens.sol";
|
|
13
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
14
|
+
import {JBSplitGroupIds} from "../src/libraries/JBSplitGroupIds.sol";
|
|
15
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
16
|
+
import {JBCurrencyAmount} from "../src/structs/JBCurrencyAmount.sol";
|
|
17
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
18
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
19
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
20
|
+
import {JBSplit} from "../src/structs/JBSplit.sol";
|
|
21
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
22
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
23
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
|
24
|
+
import {mulDiv} from "@prb/math/src/Common.sol";
|
|
5
25
|
|
|
6
26
|
contract TestSplits_Local is TestBaseWorkflow {
|
|
7
27
|
IJBController private _controller;
|
|
@@ -304,6 +324,7 @@ contract TestSplits_Local is TestBaseWorkflow {
|
|
|
304
324
|
// Set up a payout split recipient.
|
|
305
325
|
_splits[0] = JBSplit({
|
|
306
326
|
preferAddToBalance: false,
|
|
327
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
307
328
|
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT / _multiplier),
|
|
308
329
|
projectId: 0,
|
|
309
330
|
beneficiary: _splitsGuy,
|
|
@@ -314,6 +335,7 @@ contract TestSplits_Local is TestBaseWorkflow {
|
|
|
314
335
|
// A dummy used to check that splits groups of "0" don't bypass payout limits.
|
|
315
336
|
_splits[1] = JBSplit({
|
|
316
337
|
preferAddToBalance: false,
|
|
338
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
317
339
|
percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT / _multiplier),
|
|
318
340
|
projectId: 0,
|
|
319
341
|
beneficiary: _splitsGuy,
|
|
@@ -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 {JBMultiTerminal} from "../src/JBMultiTerminal.sol";
|
|
6
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
7
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
8
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
9
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
10
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.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
|
|
|
6
16
|
/// @notice E2E test: Pay into terminal A -> migrate to terminal B -> verify balances, surplus, cash outs.
|
|
7
17
|
contract TestTerminalMigration_Local is TestBaseWorkflow {
|
package/test/TestTokenFlow.sol
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
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 {JBController} from "../src/JBController.sol";
|
|
6
|
+
import {JBERC20} from "../src/JBERC20.sol";
|
|
7
|
+
import {JBTokens} from "../src/JBTokens.sol";
|
|
8
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
9
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
10
|
+
import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
|
|
11
|
+
import {IJBToken} from "../src/interfaces/IJBToken.sol";
|
|
12
|
+
import {IJBTokens} from "../src/interfaces/IJBTokens.sol";
|
|
13
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
14
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.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 {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
|
21
|
+
import {mulDiv} from "@prb/math/src/Common.sol";
|
|
5
22
|
|
|
6
23
|
// Launch project, issue token or set the token, mint token, burn token.
|
|
7
24
|
contract TestTokenFlow_Local is TestBaseWorkflow {
|
|
@@ -1,10 +1,24 @@
|
|
|
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 {IJBController} from "../src/interfaces/IJBController.sol";
|
|
7
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
8
|
+
import {IJBRulesets} from "../src/interfaces/IJBRulesets.sol";
|
|
9
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
10
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
11
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.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 {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
5
18
|
|
|
6
19
|
/// @notice Mock approval hook that ALWAYS rejects queued rulesets.
|
|
7
20
|
contract AlwaysRejectApprovalHook is IJBRulesetApprovalHook {
|
|
21
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
8
22
|
function DURATION() external pure override returns (uint256) {
|
|
9
23
|
return 0;
|
|
10
24
|
}
|
|
@@ -1,7 +1,19 @@
|
|
|
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 {IJBSplitHook} from "../src/interfaces/IJBSplitHook.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 {JBSplit} from "../src/structs/JBSplit.sol";
|
|
15
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
16
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
5
17
|
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
6
18
|
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
7
19
|
|
|
@@ -92,6 +104,7 @@ contract WeirdTokenTests_Local is TestBaseWorkflow {
|
|
|
92
104
|
rulesetConfig[0].metadata = JBRulesetMetadata({
|
|
93
105
|
reservedPercent: 0,
|
|
94
106
|
cashOutTaxRate: 0,
|
|
107
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
95
108
|
baseCurrency: uint32(uint160(token)),
|
|
96
109
|
pausePay: false,
|
|
97
110
|
pauseCreditTransfers: false,
|
|
@@ -115,6 +128,7 @@ contract WeirdTokenTests_Local is TestBaseWorkflow {
|
|
|
115
128
|
|
|
116
129
|
JBTerminalConfig[] memory terminalConfigurations = new JBTerminalConfig[](1);
|
|
117
130
|
JBAccountingContext[] memory tokensToAccept = new JBAccountingContext[](1);
|
|
131
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
118
132
|
tokensToAccept[0] = JBAccountingContext({token: token, decimals: decimals, currency: uint32(uint160(token))});
|
|
119
133
|
terminalConfigurations[0] =
|
|
120
134
|
JBTerminalConfig({terminal: jbMultiTerminal(), accountingContextsToAccept: tokensToAccept});
|
|
@@ -676,9 +690,11 @@ contract RebasingToken is ERC20 {
|
|
|
676
690
|
function rebaseHolder(address target, int256 percent) external {
|
|
677
691
|
uint256 balance = balanceOf(target);
|
|
678
692
|
if (percent > 0) {
|
|
693
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
679
694
|
uint256 increase = (balance * uint256(percent)) / 100;
|
|
680
695
|
_mint(target, increase);
|
|
681
696
|
} else if (percent < 0) {
|
|
697
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
682
698
|
uint256 decrease = (balance * uint256(-percent)) / 100;
|
|
683
699
|
if (decrease > 0 && decrease <= balance) {
|
|
684
700
|
_burn(target, decrease);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.26;
|
|
3
3
|
|
|
4
|
-
import "forge-std/Test.sol";
|
|
4
|
+
import {Test} from "forge-std/Test.sol";
|
|
5
5
|
|
|
6
6
|
import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
|
|
7
7
|
|
|
@@ -68,6 +68,7 @@ contract TestChainlinkPriceFeedFork is Test {
|
|
|
68
68
|
// Cross-check against raw latestRoundData.
|
|
69
69
|
(, int256 rawPrice,,,) = AggregatorV3Interface(ETH_USD_FEED).latestRoundData();
|
|
70
70
|
uint256 feedDecimals = AggregatorV3Interface(ETH_USD_FEED).decimals();
|
|
71
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
71
72
|
uint256 expected18 = uint256(rawPrice) * 10 ** (18 - feedDecimals);
|
|
72
73
|
assertEq(price18, expected18, "Price mismatch vs raw feed");
|
|
73
74
|
}
|
|
@@ -85,15 +86,19 @@ contract TestChainlinkPriceFeedFork is Test {
|
|
|
85
86
|
|
|
86
87
|
// Raw feed is 8 decimals — price8 should match it exactly.
|
|
87
88
|
(, int256 rawPrice,,,) = AggregatorV3Interface(ETH_USD_FEED).latestRoundData();
|
|
89
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
88
90
|
assertEq(price8, uint256(rawPrice), "8-decimal mismatch");
|
|
89
91
|
|
|
90
92
|
// 6 decimals = raw / 100 (truncated).
|
|
93
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
91
94
|
assertEq(price6, uint256(rawPrice) / 1e2, "6-decimal mismatch");
|
|
92
95
|
|
|
93
96
|
// 18 decimals = raw * 1e10.
|
|
97
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
94
98
|
assertEq(price18, uint256(rawPrice) * 1e10, "18-decimal mismatch");
|
|
95
99
|
|
|
96
100
|
// 27 decimals = raw * 1e19.
|
|
101
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
97
102
|
assertEq(price27, uint256(rawPrice) * 1e19, "27-decimal mismatch");
|
|
98
103
|
}
|
|
99
104
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
|
-
import "forge-std/Test.sol";
|
|
4
|
+
import {Test} from "forge-std/Test.sol";
|
|
5
5
|
import {JBCashOuts} from "../../src/libraries/JBCashOuts.sol";
|
|
6
6
|
import {JBFees} from "../../src/libraries/JBFees.sol";
|
|
7
7
|
import {JBConstants} from "../../src/libraries/JBConstants.sol";
|
|
@@ -21,6 +21,7 @@ contract BondingCurveProperties is Test {
|
|
|
21
21
|
// Property 1: Boundedness — cashOutFrom never exceeds surplus
|
|
22
22
|
// =========================================================================
|
|
23
23
|
/// @notice cashOutFrom(S, c, T, r) <= S for all valid inputs.
|
|
24
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
24
25
|
function check_cashOut_boundedness(
|
|
25
26
|
uint256 surplus,
|
|
26
27
|
uint256 cashOutCount,
|
|
@@ -62,6 +63,7 @@ contract BondingCurveProperties is Test {
|
|
|
62
63
|
// Property 2: Monotonicity — more tokens → more reclaim
|
|
63
64
|
// =========================================================================
|
|
64
65
|
/// @notice cashOutFrom(S, c1, T, r) <= cashOutFrom(S, c2, T, r) when c1 <= c2.
|
|
66
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
65
67
|
function check_cashOut_monotonicity(
|
|
66
68
|
uint256 surplus,
|
|
67
69
|
uint256 c1,
|
|
@@ -112,6 +114,7 @@ contract BondingCurveProperties is Test {
|
|
|
112
114
|
// Property 3: Full redemption — when c >= T, result is S (full surplus)
|
|
113
115
|
// =========================================================================
|
|
114
116
|
/// @notice When cashOutCount >= totalSupply, the full surplus is returned.
|
|
117
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
115
118
|
function check_cashOut_fullRedemption(uint256 surplus, uint256 totalSupply, uint256 cashOutTaxRate) public pure {
|
|
116
119
|
vm.assume(surplus > 0 && surplus <= type(uint128).max);
|
|
117
120
|
vm.assume(totalSupply > 0 && totalSupply <= type(uint128).max);
|
|
@@ -136,6 +139,7 @@ contract BondingCurveProperties is Test {
|
|
|
136
139
|
// Property 4: Max tax → zero reclaim
|
|
137
140
|
// =========================================================================
|
|
138
141
|
/// @notice When cashOutTaxRate == MAX_CASH_OUT_TAX_RATE, result is 0.
|
|
142
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
139
143
|
function check_cashOut_maxTaxIsZero(uint256 surplus, uint256 cashOutCount, uint256 totalSupply) public pure {
|
|
140
144
|
vm.assume(surplus > 0 && surplus <= type(uint128).max);
|
|
141
145
|
vm.assume(totalSupply > 0 && totalSupply <= type(uint128).max);
|
|
@@ -160,6 +164,7 @@ contract BondingCurveProperties is Test {
|
|
|
160
164
|
/// @notice Splitting a cash out into two parts should never yield more than a single cash out.
|
|
161
165
|
/// cashOutFrom(S, a, T, r) + cashOutFrom(S', b, T', r) <= cashOutFrom(S, a+b, T, r)
|
|
162
166
|
/// where S' = S - cashOutFrom(S, a, T, r) and T' = T - a
|
|
167
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
163
168
|
function check_cashOut_noArbitrage(
|
|
164
169
|
uint256 surplus,
|
|
165
170
|
uint256 a,
|
|
@@ -244,6 +249,7 @@ contract BondingCurveProperties is Test {
|
|
|
244
249
|
/// @notice The forward and reverse fee functions should be consistent:
|
|
245
250
|
/// amount - feeAmountFrom(amount, fee) + feeAmountResultingIn(net, fee) >= feeAmountFrom(amount, fee)
|
|
246
251
|
/// where net = amount - feeAmountFrom(amount, fee)
|
|
252
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
247
253
|
function check_fee_roundTrip(uint256 amount, uint256 feePercent) public pure {
|
|
248
254
|
vm.assume(amount > 0 && amount <= type(uint128).max);
|
|
249
255
|
vm.assume(feePercent > 0 && feePercent < MAX_FEE);
|
|
@@ -275,6 +281,7 @@ contract BondingCurveProperties is Test {
|
|
|
275
281
|
// Property 7: Metadata packing round-trip
|
|
276
282
|
// =========================================================================
|
|
277
283
|
/// @notice packRulesetMetadata(m) → expandMetadata should return the original metadata.
|
|
284
|
+
// forge-lint: disable-next-line(mixed-case-function)
|
|
278
285
|
function check_metadataPacking_roundTrip(
|
|
279
286
|
uint16 reservedPercent,
|
|
280
287
|
uint16 cashOutTaxRate,
|