// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.24; import {Test, console} from "forge-std/Test.sol"; import {UniV3TwapReader} from "../src/oracle/UniV3TwapReader.sol"; /// @notice Fork test against Arbitrum One: prices ARB via the canonical /// ARB/USDC Uniswap v3 pool and sanity-checks the WAD output. /// Run: forge test --mc TwapForkTest --fork-url https://arb1.arbitrum.io/rpc contract TwapForkTest is Test { // Uniswap v3 ARB/USDC 0.05% pool on Arbitrum One address constant ARB_USDC_POOL = 0xb0f6cA40411360c03d41C5fFc5F179b8403CdcF8; address constant ARB = 0x912CE59144191C1204E64559FE8253a0e49E6548; function test_fork_arbTwap_sane() public { if (block.chainid != 42161) { vm.skip(true); // only meaningful on an Arbitrum fork } UniV3TwapReader reader = new UniV3TwapReader(ARB_USDC_POOL, ARB, 30 minutes, 1); uint256 p = reader.twapPrice(); console.log("ARB 30m TWAP (WAD):", p); // sanity: ARB trades somewhere between $0.05 and $50 assertGt(p, 0.05e18); assertLt(p, 50e18); } }