@bananapus/core-v6 0.0.36 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/foundry.lock +1 -7
- package/foundry.toml +1 -1
- package/package.json +19 -7
- package/src/JBController.sol +26 -5
- package/src/JBMultiTerminal.sol +85 -47
- package/src/JBTerminalStore.sol +6 -6
- package/src/interfaces/IJBController.sol +4 -1
- package/src/libraries/JBFees.sol +47 -9
- package/src/libraries/JBPayoutSplitGroupLib.sol +2 -2
- package/src/periphery/JBMatchingPriceFeed.sol +1 -1
- package/test/mock/MockMaliciousBeneficiary.sol +15 -15
- package/ADMINISTRATION.md +0 -103
- package/ARCHITECTURE.md +0 -133
- package/AUDIT_INSTRUCTIONS.md +0 -139
- package/RISKS.md +0 -215
- package/SKILLS.md +0 -55
- package/STYLE_GUIDE.md +0 -610
- package/USER_JOURNEYS.md +0 -215
- package/script/Deploy.s.sol +0 -124
- package/script/DeployPeriphery.s.sol +0 -354
- package/slither-ci.config.json +0 -10
- package/test/AuditFixes.t.sol +0 -808
- package/test/ComprehensiveInvariant.t.sol +0 -306
- package/test/CoreExploitTests.t.sol +0 -2741
- package/test/EconomicSimulation.t.sol +0 -348
- package/test/EntryPointPermutations.t.sol +0 -684
- package/test/FlashLoanAttacks.t.sol +0 -797
- package/test/PermissionEscalation.t.sol +0 -711
- package/test/PermissionsInvariant.t.sol +0 -403
- package/test/RulesetTransitions.t.sol +0 -713
- package/test/SplitLoopTests.t.sol +0 -752
- package/test/TestAccessToFunds.sol +0 -2683
- package/test/TestAuditResponseDesignProofs.sol +0 -434
- package/test/TestCashOut.sol +0 -198
- package/test/TestCashOutCountFor.sol +0 -271
- package/test/TestCashOutHooks.sol +0 -351
- package/test/TestCashOutTimingEdge.sol +0 -241
- package/test/TestDataHookFuzzing.sol +0 -524
- package/test/TestDurationUnderflow.sol +0 -233
- package/test/TestFeeFreeCashOutBypass.sol +0 -949
- package/test/TestFeeProcessingFailure.sol +0 -218
- package/test/TestFees.sol +0 -619
- package/test/TestForwardedTokenConsumption.sol +0 -425
- package/test/TestInterfaceSupport.sol +0 -81
- package/test/TestJBERC20Inheritance.sol +0 -103
- package/test/TestL2SequencerPriceFeed.sol +0 -292
- package/test/TestLaunchProject.sol +0 -188
- package/test/TestMetaTx.sol +0 -217
- package/test/TestMetadataOffsetOverflow.sol +0 -179
- package/test/TestMetadataParserLib.sol +0 -471
- package/test/TestMigrationHeldFees.sol +0 -255
- package/test/TestMintTokensOf.sol +0 -185
- package/test/TestMultiTerminalSurplus.sol +0 -348
- package/test/TestMultiTokenSurplus.sol +0 -202
- package/test/TestMultipleAccessLimits.sol +0 -664
- package/test/TestPayBurnRedeemFlow.sol +0 -195
- package/test/TestPayHooks.sol +0 -209
- package/test/TestPermissions.sol +0 -324
- package/test/TestPermissionsEdge.sol +0 -290
- package/test/TestPermit2DataHook.t.sol +0 -360
- package/test/TestPermit2Terminal.sol +0 -372
- package/test/TestRulesetQueueing.sol +0 -1025
- package/test/TestRulesetQueuingStress.sol +0 -806
- package/test/TestRulesetWeightCaching.sol +0 -178
- package/test/TestSplits.sol +0 -391
- package/test/TestTerminalMigration.sol +0 -274
- package/test/TestTerminalPreviewParity.sol +0 -208
- package/test/TestTokenFlow.sol +0 -191
- package/test/TestWeightCacheStaleAfterRejection.sol +0 -303
- package/test/WeirdTokenTests.t.sol +0 -817
- package/test/audit/CashOutReenterPay.t.sol +0 -501
- package/test/audit/CodexHeldFeeRounding.t.sol +0 -159
- package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
- package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
- package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
- package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
- package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
- package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
- package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
- package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
- package/test/formal/BondingCurveProperties.t.sol +0 -420
- package/test/formal/FeeProperties.t.sol +0 -252
- package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
- package/test/invariants/RulesetsInvariant.t.sol +0 -125
- package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
- package/test/invariants/TokensInvariant.t.sol +0 -195
- package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
- package/test/invariants/handlers/EconomicHandler.sol +0 -377
- package/test/invariants/handlers/Phase3Handler.sol +0 -443
- package/test/invariants/handlers/RulesetsHandler.sol +0 -115
- package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
- package/test/invariants/handlers/TokensHandler.sol +0 -126
- package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
- package/test/regression/WeightCacheBoundary.t.sol +0 -291
- package/test/trees/JBController/burnTokensOf.tree +0 -9
- package/test/trees/JBController/claimTokensFor.tree +0 -5
- package/test/trees/JBController/deployERC20For.tree +0 -5
- package/test/trees/JBController/getRulesetOf.tree +0 -5
- package/test/trees/JBController/launchProjectFor.tree +0 -12
- package/test/trees/JBController/launchRulesetsFor.tree +0 -8
- package/test/trees/JBController/migrateController.tree +0 -12
- package/test/trees/JBController/mintTokensOf.tree +0 -12
- package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
- package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
- package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
- package/test/trees/JBController/setMetadataOf.tree +0 -5
- package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
- package/test/trees/JBController/setTokenFor.tree +0 -5
- package/test/trees/JBController/transferCreditsFrom.tree +0 -8
- package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
- package/test/trees/JBDirectory/setControllerOf.tree +0 -11
- package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
- package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
- package/test/trees/JBERC20/initialize.tree +0 -7
- package/test/trees/JBERC20/name.tree +0 -5
- package/test/trees/JBERC20/nonces.tree +0 -5
- package/test/trees/JBERC20/symbol.tree +0 -5
- package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
- package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
- package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
- package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
- package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
- package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
- package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
- package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
- package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
- package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
- package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
- package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
- package/test/trees/JBMultiTerminal/pay.tree +0 -23
- package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
- package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
- package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
- package/test/trees/JBPermissions/hasPermission.tree +0 -8
- package/test/trees/JBPermissions/hasPermissions.tree +0 -8
- package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
- package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
- package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
- package/test/trees/JBProjects/createFor.tree +0 -11
- package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
- package/test/trees/JBProjects/supportsInterface.tree +0 -9
- package/test/trees/JBProjects/tokenURI.tree +0 -5
- package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
- package/test/trees/JBRulesets/currentOf.tree +0 -12
- package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
- package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
- package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
- package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
- package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
- package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
- package/test/trees/JBSplits/splitsOf.tree +0 -5
- package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
- package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
- package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
- package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
- package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
- package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
- package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
- package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
- package/test/trees/JBTokens/burnFrom.tree +0 -10
- package/test/trees/JBTokens/claimTokensFor.tree +0 -10
- package/test/trees/JBTokens/deployERC20For.tree +0 -12
- package/test/trees/JBTokens/mintFor.tree +0 -10
- package/test/trees/JBTokens/setTokenFor.tree +0 -11
- package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
- package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
- package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
- package/test/trees/mintTokensOf.tree +0 -12
- package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
- package/test/units/static/JBController/JBControllerSetup.sol +0 -50
- package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
- package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
- package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
- package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
- package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
- package/test/units/static/JBController/TestMigrateController.sol +0 -157
- package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
- package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
- package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
- package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
- package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
- package/test/units/static/JBController/TestRulesetViews.sol +0 -225
- package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
- package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
- package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
- package/test/units/static/JBController/TestSetUriOf.sol +0 -57
- package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
- package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
- package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
- package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
- package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
- package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
- package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
- package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
- package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
- package/test/units/static/JBERC20/SigUtils.sol +0 -36
- package/test/units/static/JBERC20/TestInitialize.sol +0 -60
- package/test/units/static/JBERC20/TestName.sol +0 -30
- package/test/units/static/JBERC20/TestNonces.sol +0 -62
- package/test/units/static/JBERC20/TestSymbol.sol +0 -31
- package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
- package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
- package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
- package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
- package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
- package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
- package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
- package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
- package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
- package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
- package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
- package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
- package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
- package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
- package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
- package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
- package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
- package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
- package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
- package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
- package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
- package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
- package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
- package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
- package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
- package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
- package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
- package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
- package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
- package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
- package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
- package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
- package/test/units/static/JBPrices/TestPrices.sol +0 -265
- package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
- package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
- package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
- package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
- package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
- package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
- package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
- package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
- package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
- package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
- package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
- package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
- package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
- package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
- package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
- package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
- package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
- package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
- package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
- package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
- package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
- package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
- package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
- package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
- package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
- package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
- package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
- package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
- package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
- package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
- package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
- package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
- package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
- package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
- package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
- package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
- package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
- package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
- package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
- package/test/units/static/JBTokens/TestMintFor.sol +0 -100
- package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
- package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
- package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
- package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +0 -56
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {Test} from "forge-std/Test.sol";
|
|
5
|
-
|
|
6
|
-
import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
|
|
7
|
-
|
|
8
|
-
import {JBChainlinkV3PriceFeed} from "../../src/JBChainlinkV3PriceFeed.sol";
|
|
9
|
-
import {JBPrices} from "../../src/JBPrices.sol";
|
|
10
|
-
import {IJBDirectory} from "../../src/interfaces/IJBDirectory.sol";
|
|
11
|
-
import {IJBPermissions} from "../../src/interfaces/IJBPermissions.sol";
|
|
12
|
-
import {IJBPriceFeed} from "../../src/interfaces/IJBPriceFeed.sol";
|
|
13
|
-
import {IJBProjects} from "../../src/interfaces/IJBProjects.sol";
|
|
14
|
-
|
|
15
|
-
/// @notice Fork tests for JBChainlinkV3PriceFeed and JBPrices against live Chainlink oracles on Ethereum mainnet.
|
|
16
|
-
contract TestChainlinkPriceFeedFork is Test {
|
|
17
|
-
// Chainlink feed addresses (Ethereum mainnet).
|
|
18
|
-
address constant ETH_USD_FEED = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;
|
|
19
|
-
address constant BTC_USD_FEED = 0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c;
|
|
20
|
-
|
|
21
|
-
// Staleness threshold (1 hour).
|
|
22
|
-
uint256 constant THRESHOLD = 3600;
|
|
23
|
-
|
|
24
|
-
// Currency identifiers (arbitrary nonzero values for JBPrices mapping keys).
|
|
25
|
-
uint256 constant CURRENCY_ETH = 1;
|
|
26
|
-
uint256 constant CURRENCY_USD = 2;
|
|
27
|
-
uint256 constant CURRENCY_BTC = 3;
|
|
28
|
-
|
|
29
|
-
// Pinned block for reproducibility.
|
|
30
|
-
uint256 constant FORK_BLOCK = 22_000_000;
|
|
31
|
-
|
|
32
|
-
JBChainlinkV3PriceFeed ethUsdPriceFeed;
|
|
33
|
-
JBChainlinkV3PriceFeed btcUsdPriceFeed;
|
|
34
|
-
JBPrices prices;
|
|
35
|
-
address owner;
|
|
36
|
-
|
|
37
|
-
function setUp() public {
|
|
38
|
-
vm.createSelectFork("ethereum", FORK_BLOCK);
|
|
39
|
-
|
|
40
|
-
owner = makeAddr("owner");
|
|
41
|
-
|
|
42
|
-
// Deploy price feeds against real Chainlink aggregators.
|
|
43
|
-
ethUsdPriceFeed = new JBChainlinkV3PriceFeed(AggregatorV3Interface(ETH_USD_FEED), THRESHOLD);
|
|
44
|
-
btcUsdPriceFeed = new JBChainlinkV3PriceFeed(AggregatorV3Interface(BTC_USD_FEED), THRESHOLD);
|
|
45
|
-
|
|
46
|
-
// Deploy JBPrices with mock directory/permissions/projects (only price resolution is tested).
|
|
47
|
-
prices = new JBPrices(
|
|
48
|
-
IJBDirectory(makeAddr("directory")),
|
|
49
|
-
IJBPermissions(makeAddr("permissions")),
|
|
50
|
-
IJBProjects(makeAddr("projects")),
|
|
51
|
-
owner,
|
|
52
|
-
address(0)
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ------------------------------------------------------------------
|
|
57
|
-
// Live feed sanity checks
|
|
58
|
-
// ------------------------------------------------------------------
|
|
59
|
-
|
|
60
|
-
/// @notice Verify currentUnitPrice returns a sane ETH/USD price at the pinned block.
|
|
61
|
-
function test_currentUnitPrice_liveEthUsd() public view {
|
|
62
|
-
uint256 price18 = ethUsdPriceFeed.currentUnitPrice(18);
|
|
63
|
-
|
|
64
|
-
// ETH price should be between $500 and $50,000.
|
|
65
|
-
assertGt(price18, 500e18, "ETH price too low");
|
|
66
|
-
assertLt(price18, 50_000e18, "ETH price too high");
|
|
67
|
-
|
|
68
|
-
// Cross-check against raw latestRoundData.
|
|
69
|
-
(, int256 rawPrice,,,) = AggregatorV3Interface(ETH_USD_FEED).latestRoundData();
|
|
70
|
-
uint256 feedDecimals = AggregatorV3Interface(ETH_USD_FEED).decimals();
|
|
71
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
72
|
-
uint256 expected18 = uint256(rawPrice) * 10 ** (18 - feedDecimals);
|
|
73
|
-
assertEq(price18, expected18, "Price mismatch vs raw feed");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ------------------------------------------------------------------
|
|
77
|
-
// Decimal scaling
|
|
78
|
-
// ------------------------------------------------------------------
|
|
79
|
-
|
|
80
|
-
/// @notice Verify correct scaling across 6, 8, 18, and 27 decimals.
|
|
81
|
-
function test_currentUnitPrice_differentDecimals() public view {
|
|
82
|
-
uint256 price6 = ethUsdPriceFeed.currentUnitPrice(6);
|
|
83
|
-
uint256 price8 = ethUsdPriceFeed.currentUnitPrice(8);
|
|
84
|
-
uint256 price18 = ethUsdPriceFeed.currentUnitPrice(18);
|
|
85
|
-
uint256 price27 = ethUsdPriceFeed.currentUnitPrice(27);
|
|
86
|
-
|
|
87
|
-
// Raw feed is 8 decimals — price8 should match it exactly.
|
|
88
|
-
(, int256 rawPrice,,,) = AggregatorV3Interface(ETH_USD_FEED).latestRoundData();
|
|
89
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
90
|
-
assertEq(price8, uint256(rawPrice), "8-decimal mismatch");
|
|
91
|
-
|
|
92
|
-
// 6 decimals = raw / 100 (truncated).
|
|
93
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
94
|
-
assertEq(price6, uint256(rawPrice) / 1e2, "6-decimal mismatch");
|
|
95
|
-
|
|
96
|
-
// 18 decimals = raw * 1e10.
|
|
97
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
98
|
-
assertEq(price18, uint256(rawPrice) * 1e10, "18-decimal mismatch");
|
|
99
|
-
|
|
100
|
-
// 27 decimals = raw * 1e19.
|
|
101
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
102
|
-
assertEq(price27, uint256(rawPrice) * 1e19, "27-decimal mismatch");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ------------------------------------------------------------------
|
|
106
|
-
// JBPrices integration — direct feed
|
|
107
|
-
// ------------------------------------------------------------------
|
|
108
|
-
|
|
109
|
-
/// @notice Register ETH/USD feed and resolve via pricePerUnitOf.
|
|
110
|
-
function test_pricePerUnitOf_directFeed() public {
|
|
111
|
-
vm.prank(owner);
|
|
112
|
-
prices.addPriceFeedFor(0, CURRENCY_USD, CURRENCY_ETH, IJBPriceFeed(address(ethUsdPriceFeed)));
|
|
113
|
-
|
|
114
|
-
uint256 priceFromPrices = prices.pricePerUnitOf(0, CURRENCY_USD, CURRENCY_ETH, 18);
|
|
115
|
-
uint256 priceFromFeed = ethUsdPriceFeed.currentUnitPrice(18);
|
|
116
|
-
|
|
117
|
-
assertEq(priceFromPrices, priceFromFeed, "Direct feed mismatch");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// ------------------------------------------------------------------
|
|
121
|
-
// JBPrices integration — inverse feed
|
|
122
|
-
// ------------------------------------------------------------------
|
|
123
|
-
|
|
124
|
-
/// @notice Register ETH/USD feed but query USD/ETH — verify inverse calculation.
|
|
125
|
-
function test_pricePerUnitOf_inverseFeed() public {
|
|
126
|
-
vm.prank(owner);
|
|
127
|
-
prices.addPriceFeedFor(0, CURRENCY_USD, CURRENCY_ETH, IJBPriceFeed(address(ethUsdPriceFeed)));
|
|
128
|
-
|
|
129
|
-
uint256 inversePrice = prices.pricePerUnitOf(0, CURRENCY_ETH, CURRENCY_USD, 18);
|
|
130
|
-
|
|
131
|
-
// inverse = (1e18 * 1e18) / ethUsdPrice. For ETH ~$2000, inverse ~0.0005e18 = 5e14.
|
|
132
|
-
// Sane range: $500–$50k → inverse 2e13–2e15.
|
|
133
|
-
assertGt(inversePrice, 2e13, "Inverse price too low");
|
|
134
|
-
assertLt(inversePrice, 2e15, "Inverse price too high");
|
|
135
|
-
|
|
136
|
-
// Verify round-trip: price * inverse ≈ 1e18 (within mulDiv rounding).
|
|
137
|
-
uint256 directPrice = ethUsdPriceFeed.currentUnitPrice(18);
|
|
138
|
-
uint256 product = (directPrice * inversePrice) / 1e18;
|
|
139
|
-
// mulDiv truncation can cause up to ~1e4 wei error at these magnitudes.
|
|
140
|
-
assertApproxEqAbs(product, 1e18, 1e4, "Round-trip mismatch");
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// ------------------------------------------------------------------
|
|
144
|
-
// JBPrices — same currency
|
|
145
|
-
// ------------------------------------------------------------------
|
|
146
|
-
|
|
147
|
-
/// @notice pricePerUnitOf(X, X, 18) should return 1e18 without any feed.
|
|
148
|
-
function test_pricePerUnitOf_sameCurrency() public view {
|
|
149
|
-
uint256 price = prices.pricePerUnitOf(0, CURRENCY_ETH, CURRENCY_ETH, 18);
|
|
150
|
-
assertEq(price, 1e18, "Same currency should be 1e18");
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// ------------------------------------------------------------------
|
|
154
|
-
// JBPrices — default fallback
|
|
155
|
-
// ------------------------------------------------------------------
|
|
156
|
-
|
|
157
|
-
/// @notice Feed registered at projectId=0 should be used when querying projectId=99.
|
|
158
|
-
function test_pricePerUnitOf_defaultFallback() public {
|
|
159
|
-
vm.prank(owner);
|
|
160
|
-
prices.addPriceFeedFor(0, CURRENCY_USD, CURRENCY_ETH, IJBPriceFeed(address(ethUsdPriceFeed)));
|
|
161
|
-
|
|
162
|
-
uint256 defaultPrice = prices.pricePerUnitOf(0, CURRENCY_USD, CURRENCY_ETH, 18);
|
|
163
|
-
uint256 fallbackPrice = prices.pricePerUnitOf(99, CURRENCY_USD, CURRENCY_ETH, 18);
|
|
164
|
-
|
|
165
|
-
assertEq(fallbackPrice, defaultPrice, "Fallback should match default");
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// ------------------------------------------------------------------
|
|
169
|
-
// Stale price revert
|
|
170
|
-
// ------------------------------------------------------------------
|
|
171
|
-
|
|
172
|
-
/// @notice Warping past the threshold should cause a StalePrice revert.
|
|
173
|
-
function test_stalePriceReverts() public {
|
|
174
|
-
// Snapshot updatedAt from the feed at this block.
|
|
175
|
-
(,,, uint256 updatedAt,) = AggregatorV3Interface(ETH_USD_FEED).latestRoundData();
|
|
176
|
-
|
|
177
|
-
// Warp far enough that the feed's updatedAt + threshold < block.timestamp.
|
|
178
|
-
uint256 warpTo = block.timestamp + 7200;
|
|
179
|
-
vm.warp(warpTo);
|
|
180
|
-
|
|
181
|
-
vm.expectRevert(
|
|
182
|
-
abi.encodeWithSelector(
|
|
183
|
-
JBChainlinkV3PriceFeed.JBChainlinkV3PriceFeed_StalePrice.selector, warpTo, THRESHOLD, updatedAt
|
|
184
|
-
)
|
|
185
|
-
);
|
|
186
|
-
ethUsdPriceFeed.currentUnitPrice(18);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// ------------------------------------------------------------------
|
|
190
|
-
// Feed immutability
|
|
191
|
-
// ------------------------------------------------------------------
|
|
192
|
-
|
|
193
|
-
/// @notice Registering the same currency pair twice should revert.
|
|
194
|
-
function test_feedImmutability() public {
|
|
195
|
-
vm.prank(owner);
|
|
196
|
-
prices.addPriceFeedFor(0, CURRENCY_USD, CURRENCY_ETH, IJBPriceFeed(address(ethUsdPriceFeed)));
|
|
197
|
-
|
|
198
|
-
vm.prank(owner);
|
|
199
|
-
vm.expectRevert(
|
|
200
|
-
abi.encodeWithSelector(
|
|
201
|
-
JBPrices.JBPrices_PriceFeedAlreadyExists.selector, IJBPriceFeed(address(ethUsdPriceFeed))
|
|
202
|
-
)
|
|
203
|
-
);
|
|
204
|
-
prices.addPriceFeedFor(0, CURRENCY_USD, CURRENCY_ETH, IJBPriceFeed(address(btcUsdPriceFeed)));
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// ------------------------------------------------------------------
|
|
208
|
-
// Multiple feeds
|
|
209
|
-
// ------------------------------------------------------------------
|
|
210
|
-
|
|
211
|
-
/// @notice Register both ETH/USD and BTC/USD and verify independent resolution.
|
|
212
|
-
function test_multipleFeeds_ethUsd_btcUsd() public {
|
|
213
|
-
vm.startPrank(owner);
|
|
214
|
-
prices.addPriceFeedFor(0, CURRENCY_USD, CURRENCY_ETH, IJBPriceFeed(address(ethUsdPriceFeed)));
|
|
215
|
-
prices.addPriceFeedFor(0, CURRENCY_USD, CURRENCY_BTC, IJBPriceFeed(address(btcUsdPriceFeed)));
|
|
216
|
-
vm.stopPrank();
|
|
217
|
-
|
|
218
|
-
uint256 ethUsd = prices.pricePerUnitOf(0, CURRENCY_USD, CURRENCY_ETH, 18);
|
|
219
|
-
uint256 btcUsd = prices.pricePerUnitOf(0, CURRENCY_USD, CURRENCY_BTC, 18);
|
|
220
|
-
|
|
221
|
-
// ETH/USD: $500–$50,000.
|
|
222
|
-
assertGt(ethUsd, 500e18, "ETH/USD too low");
|
|
223
|
-
assertLt(ethUsd, 50_000e18, "ETH/USD too high");
|
|
224
|
-
|
|
225
|
-
// BTC/USD: $10,000–$500,000.
|
|
226
|
-
assertGt(btcUsd, 10_000e18, "BTC/USD too low");
|
|
227
|
-
assertLt(btcUsd, 500_000e18, "BTC/USD too high");
|
|
228
|
-
|
|
229
|
-
// BTC should be more expensive than ETH.
|
|
230
|
-
assertGt(btcUsd, ethUsd, "BTC should cost more than ETH");
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// ------------------------------------------------------------------
|
|
234
|
-
// Cross-price derivation
|
|
235
|
-
// ------------------------------------------------------------------
|
|
236
|
-
|
|
237
|
-
/// @notice Derive ETH/BTC price from ETH/USD and BTC/USD feeds.
|
|
238
|
-
function test_crossPriceDerived() public {
|
|
239
|
-
vm.startPrank(owner);
|
|
240
|
-
prices.addPriceFeedFor(0, CURRENCY_USD, CURRENCY_ETH, IJBPriceFeed(address(ethUsdPriceFeed)));
|
|
241
|
-
prices.addPriceFeedFor(0, CURRENCY_USD, CURRENCY_BTC, IJBPriceFeed(address(btcUsdPriceFeed)));
|
|
242
|
-
vm.stopPrank();
|
|
243
|
-
|
|
244
|
-
uint256 ethUsd = prices.pricePerUnitOf(0, CURRENCY_USD, CURRENCY_ETH, 18);
|
|
245
|
-
uint256 btcUsd = prices.pricePerUnitOf(0, CURRENCY_USD, CURRENCY_BTC, 18);
|
|
246
|
-
|
|
247
|
-
// ETH/BTC = ethUsd / btcUsd (how many BTC per 1 ETH).
|
|
248
|
-
uint256 ethPerBtc = (ethUsd * 1e18) / btcUsd;
|
|
249
|
-
|
|
250
|
-
// Should be between 0.01 and 0.1 (at 18 decimals: 1e16–1e17).
|
|
251
|
-
assertGt(ethPerBtc, 1e16, "ETH/BTC ratio too low");
|
|
252
|
-
assertLt(ethPerBtc, 1e17, "ETH/BTC ratio too high");
|
|
253
|
-
}
|
|
254
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {Test} from "forge-std/Test.sol";
|
|
5
|
-
|
|
6
|
-
import {AggregatorV2V3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV2V3Interface.sol";
|
|
7
|
-
import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
|
|
8
|
-
|
|
9
|
-
import {JBChainlinkV3SequencerPriceFeed} from "../../src/JBChainlinkV3SequencerPriceFeed.sol";
|
|
10
|
-
|
|
11
|
-
/// @notice Fork tests for JBChainlinkV3SequencerPriceFeed against the live Arbitrum sequencer uptime feed and
|
|
12
|
-
/// ETH/USD Chainlink oracle.
|
|
13
|
-
contract TestSequencerPriceFeedFork is Test {
|
|
14
|
-
// Chainlink feed addresses (Arbitrum mainnet).
|
|
15
|
-
address constant ARB_ETH_USD_FEED = 0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612;
|
|
16
|
-
address constant ARB_SEQUENCER_FEED = 0xFdB631F5EE196F0ed6FAa767959853A9F217697D;
|
|
17
|
-
|
|
18
|
-
// Staleness threshold (1 hour).
|
|
19
|
-
uint256 constant THRESHOLD = 3600;
|
|
20
|
-
|
|
21
|
-
// Grace period after sequencer restart (1 hour).
|
|
22
|
-
uint256 constant GRACE_PERIOD = 3600;
|
|
23
|
-
|
|
24
|
-
// Pinned block for reproducibility (sequencer is up at this block).
|
|
25
|
-
uint256 constant FORK_BLOCK = 300_000_000;
|
|
26
|
-
|
|
27
|
-
JBChainlinkV3SequencerPriceFeed feed;
|
|
28
|
-
|
|
29
|
-
function setUp() public {
|
|
30
|
-
string memory rpc = vm.envOr("RPC_ARBITRUM_MAINNET", string(""));
|
|
31
|
-
if (bytes(rpc).length == 0) {
|
|
32
|
-
// Skip all tests if no Arbitrum RPC is configured.
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
vm.createSelectFork(rpc, FORK_BLOCK);
|
|
37
|
-
|
|
38
|
-
feed = new JBChainlinkV3SequencerPriceFeed(
|
|
39
|
-
AggregatorV3Interface(ARB_ETH_USD_FEED),
|
|
40
|
-
THRESHOLD,
|
|
41
|
-
AggregatorV2V3Interface(ARB_SEQUENCER_FEED),
|
|
42
|
-
GRACE_PERIOD
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// ------------------------------------------------------------------
|
|
47
|
-
// Helpers
|
|
48
|
-
// ------------------------------------------------------------------
|
|
49
|
-
|
|
50
|
-
modifier skipIfNoRpc() {
|
|
51
|
-
if (address(feed) == address(0)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
_;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ------------------------------------------------------------------
|
|
58
|
-
// 1. Normal operation — valid price returned
|
|
59
|
-
// ------------------------------------------------------------------
|
|
60
|
-
|
|
61
|
-
/// @notice Under normal conditions (sequencer up, grace period elapsed), currentUnitPrice returns a sane price.
|
|
62
|
-
function test_normalOperation_returnsValidPrice() public view skipIfNoRpc {
|
|
63
|
-
uint256 price18 = feed.currentUnitPrice(18);
|
|
64
|
-
|
|
65
|
-
// ETH price should be between $500 and $50,000.
|
|
66
|
-
assertGt(price18, 500e18, "ETH price too low");
|
|
67
|
-
assertLt(price18, 50_000e18, "ETH price too high");
|
|
68
|
-
|
|
69
|
-
// Cross-check against raw latestRoundData from the price feed.
|
|
70
|
-
(, int256 rawPrice,,,) = AggregatorV3Interface(ARB_ETH_USD_FEED).latestRoundData();
|
|
71
|
-
uint256 feedDecimals = AggregatorV3Interface(ARB_ETH_USD_FEED).decimals();
|
|
72
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
73
|
-
uint256 expected18 = uint256(rawPrice) * 10 ** (18 - feedDecimals);
|
|
74
|
-
assertEq(price18, expected18, "Price mismatch vs raw feed");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// ------------------------------------------------------------------
|
|
78
|
-
// 2. Sequencer down — reverts
|
|
79
|
-
// ------------------------------------------------------------------
|
|
80
|
-
|
|
81
|
-
/// @notice When the sequencer feed reports answer=1 (down), currentUnitPrice reverts.
|
|
82
|
-
function test_sequencerDown_reverts() public skipIfNoRpc {
|
|
83
|
-
// Mock the sequencer feed to report answer=1 (down).
|
|
84
|
-
// latestRoundData() selector = 0xfeaf968c
|
|
85
|
-
vm.mockCall(
|
|
86
|
-
ARB_SEQUENCER_FEED,
|
|
87
|
-
abi.encodeWithSelector(AggregatorV3Interface.latestRoundData.selector),
|
|
88
|
-
abi.encode(
|
|
89
|
-
uint80(1), // roundId
|
|
90
|
-
int256(1), // answer = 1 → sequencer down
|
|
91
|
-
block.timestamp - GRACE_PERIOD - 100, // startedAt (irrelevant when answer=1)
|
|
92
|
-
block.timestamp, // updatedAt
|
|
93
|
-
uint80(1) // answeredInRound
|
|
94
|
-
)
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
vm.expectRevert(
|
|
98
|
-
abi.encodeWithSelector(
|
|
99
|
-
JBChainlinkV3SequencerPriceFeed.JBChainlinkV3SequencerPriceFeed_SequencerDownOrRestarting.selector,
|
|
100
|
-
block.timestamp,
|
|
101
|
-
GRACE_PERIOD,
|
|
102
|
-
block.timestamp - GRACE_PERIOD - 100
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
feed.currentUnitPrice(18);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ------------------------------------------------------------------
|
|
109
|
-
// 3. Grace period active — reverts
|
|
110
|
-
// ------------------------------------------------------------------
|
|
111
|
-
|
|
112
|
-
/// @notice When the sequencer just came back up (within grace period), currentUnitPrice reverts.
|
|
113
|
-
function test_gracePeriodActive_reverts() public skipIfNoRpc {
|
|
114
|
-
// Mock the sequencer feed: answer=0 (up) but startedAt is 1 second ago (within grace period).
|
|
115
|
-
uint256 startedAt = block.timestamp - 1;
|
|
116
|
-
|
|
117
|
-
vm.mockCall(
|
|
118
|
-
ARB_SEQUENCER_FEED,
|
|
119
|
-
abi.encodeWithSelector(AggregatorV3Interface.latestRoundData.selector),
|
|
120
|
-
abi.encode(
|
|
121
|
-
uint80(1), // roundId
|
|
122
|
-
int256(0), // answer = 0 → sequencer up
|
|
123
|
-
startedAt, // startedAt = very recent
|
|
124
|
-
block.timestamp, // updatedAt
|
|
125
|
-
uint80(1) // answeredInRound
|
|
126
|
-
)
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
vm.expectRevert(
|
|
130
|
-
abi.encodeWithSelector(
|
|
131
|
-
JBChainlinkV3SequencerPriceFeed.JBChainlinkV3SequencerPriceFeed_SequencerDownOrRestarting.selector,
|
|
132
|
-
block.timestamp,
|
|
133
|
-
GRACE_PERIOD,
|
|
134
|
-
startedAt
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
feed.currentUnitPrice(18);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// ------------------------------------------------------------------
|
|
141
|
-
// 4. Post-grace recovery — succeeds
|
|
142
|
-
// ------------------------------------------------------------------
|
|
143
|
-
|
|
144
|
-
/// @notice After the grace period has elapsed, currentUnitPrice succeeds again.
|
|
145
|
-
function test_postGraceRecovery_succeeds() public skipIfNoRpc {
|
|
146
|
-
// Mock the sequencer feed: answer=0 (up), startedAt is well before the grace period ended.
|
|
147
|
-
uint256 startedAt = block.timestamp - GRACE_PERIOD - 100;
|
|
148
|
-
|
|
149
|
-
vm.mockCall(
|
|
150
|
-
ARB_SEQUENCER_FEED,
|
|
151
|
-
abi.encodeWithSelector(AggregatorV3Interface.latestRoundData.selector),
|
|
152
|
-
abi.encode(
|
|
153
|
-
uint80(1), // roundId
|
|
154
|
-
int256(0), // answer = 0 → sequencer up
|
|
155
|
-
startedAt, // startedAt = well in the past
|
|
156
|
-
block.timestamp, // updatedAt
|
|
157
|
-
uint80(1) // answeredInRound
|
|
158
|
-
)
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
// The price feed itself is still the real Chainlink feed, so this should succeed.
|
|
162
|
-
uint256 price18 = feed.currentUnitPrice(18);
|
|
163
|
-
|
|
164
|
-
// Same sanity check: ETH price between $500 and $50,000.
|
|
165
|
-
assertGt(price18, 500e18, "ETH price too low after recovery");
|
|
166
|
-
assertLt(price18, 50_000e18, "ETH price too high after recovery");
|
|
167
|
-
}
|
|
168
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {TestTerminalPreviewParity_Local} from "../TestTerminalPreviewParity.sol";
|
|
5
|
-
import {IJBTerminal} from "../../src/interfaces/IJBTerminal.sol";
|
|
6
|
-
import {IJBCashOutTerminal} from "../../src/interfaces/IJBCashOutTerminal.sol";
|
|
7
|
-
import {JBConstants} from "../../src/libraries/JBConstants.sol";
|
|
8
|
-
import {JBCashOutHookSpecification} from "../../src/structs/JBCashOutHookSpecification.sol";
|
|
9
|
-
import {JBPayHookSpecification} from "../../src/structs/JBPayHookSpecification.sol";
|
|
10
|
-
import {JBRuleset} from "../../src/structs/JBRuleset.sol";
|
|
11
|
-
|
|
12
|
-
contract TestTerminalPreviewParityFork is TestTerminalPreviewParity_Local {
|
|
13
|
-
uint256 internal constant FORK_BLOCK = 22_000_000;
|
|
14
|
-
|
|
15
|
-
function setUp() public override {
|
|
16
|
-
vm.createSelectFork("ethereum", FORK_BLOCK);
|
|
17
|
-
super.setUp();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function testForkPreviewPayForMatchesPay() external {
|
|
21
|
-
_launchFeeProject();
|
|
22
|
-
uint256 projectId = _launchProject(2500, 10_000);
|
|
23
|
-
|
|
24
|
-
(
|
|
25
|
-
JBRuleset memory ruleset,
|
|
26
|
-
uint256 previewBeneficiaryTokenCount,
|
|
27
|
-
uint256 previewReservedTokenCount,
|
|
28
|
-
JBPayHookSpecification[] memory hookSpecifications
|
|
29
|
-
) = _terminal.previewPayFor(projectId, JBConstants.NATIVE_TOKEN, 1 ether, _beneficiary, "");
|
|
30
|
-
|
|
31
|
-
assertEq(hookSpecifications.length, 0);
|
|
32
|
-
|
|
33
|
-
uint256 balanceBefore = jbTokens().totalBalanceOf(_beneficiary, projectId);
|
|
34
|
-
uint256 reservedBefore = _controller.pendingReservedTokenBalanceOf(projectId);
|
|
35
|
-
|
|
36
|
-
address payer = makeAddr("forkPayer");
|
|
37
|
-
vm.deal(payer, 1 ether);
|
|
38
|
-
|
|
39
|
-
vm.expectEmit();
|
|
40
|
-
emit IJBTerminal.Pay(
|
|
41
|
-
ruleset.id,
|
|
42
|
-
ruleset.cycleNumber,
|
|
43
|
-
projectId,
|
|
44
|
-
payer,
|
|
45
|
-
_beneficiary,
|
|
46
|
-
1 ether,
|
|
47
|
-
previewBeneficiaryTokenCount,
|
|
48
|
-
"",
|
|
49
|
-
"",
|
|
50
|
-
payer
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
vm.prank(payer);
|
|
54
|
-
uint256 beneficiaryTokenCount =
|
|
55
|
-
_terminal.pay{value: 1 ether}(projectId, JBConstants.NATIVE_TOKEN, 1 ether, _beneficiary, 0, "", "");
|
|
56
|
-
|
|
57
|
-
assertEq(beneficiaryTokenCount, previewBeneficiaryTokenCount);
|
|
58
|
-
assertEq(jbTokens().totalBalanceOf(_beneficiary, projectId) - balanceBefore, previewBeneficiaryTokenCount);
|
|
59
|
-
assertEq(_controller.pendingReservedTokenBalanceOf(projectId) - reservedBefore, previewReservedTokenCount);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function testForkPreviewCashOutFromMatchesCashOut() external {
|
|
63
|
-
_launchFeeProject();
|
|
64
|
-
uint256 projectId = _launchProject(0, 5000);
|
|
65
|
-
|
|
66
|
-
vm.prank(_projectOwner);
|
|
67
|
-
jbFeelessAddresses().setFeelessAddress(_beneficiary, true);
|
|
68
|
-
|
|
69
|
-
vm.deal(_beneficiary, 1 ether);
|
|
70
|
-
vm.prank(_beneficiary);
|
|
71
|
-
uint256 minted =
|
|
72
|
-
_terminal.pay{value: 1 ether}(projectId, JBConstants.NATIVE_TOKEN, 1 ether, _beneficiary, 0, "", "");
|
|
73
|
-
|
|
74
|
-
uint256 cashOutCount = minted / 2;
|
|
75
|
-
|
|
76
|
-
(
|
|
77
|
-
JBRuleset memory ruleset,
|
|
78
|
-
uint256 previewReclaimAmount,
|
|
79
|
-
uint256 previewCashOutTaxRate,
|
|
80
|
-
JBCashOutHookSpecification[] memory hookSpecifications
|
|
81
|
-
) = _terminal.previewCashOutFrom(
|
|
82
|
-
_beneficiary, projectId, cashOutCount, JBConstants.NATIVE_TOKEN, payable(_beneficiary), ""
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
assertEq(hookSpecifications.length, 0);
|
|
86
|
-
|
|
87
|
-
vm.expectEmit();
|
|
88
|
-
emit IJBCashOutTerminal.CashOutTokens(
|
|
89
|
-
ruleset.id,
|
|
90
|
-
ruleset.cycleNumber,
|
|
91
|
-
projectId,
|
|
92
|
-
_beneficiary,
|
|
93
|
-
_beneficiary,
|
|
94
|
-
cashOutCount,
|
|
95
|
-
previewCashOutTaxRate,
|
|
96
|
-
previewReclaimAmount,
|
|
97
|
-
"",
|
|
98
|
-
_beneficiary
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
vm.prank(_beneficiary);
|
|
102
|
-
uint256 reclaimAmount = _terminal.cashOutTokensOf(
|
|
103
|
-
_beneficiary, projectId, cashOutCount, JBConstants.NATIVE_TOKEN, 0, payable(_beneficiary), ""
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
assertEq(reclaimAmount, previewReclaimAmount);
|
|
107
|
-
}
|
|
108
|
-
}
|