test(v2-agg): complete V2 aggregator hook test suite - #485
Draft
SocksNFlops wants to merge 14 commits into
Draft
Conversation
🤖 Claude PR Metadata GenerationStatus: ❌ Error
|
…creasing, no residuals)
…cceptance criteria for flash-swap redesign
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracks PROTO-1373 — PR 1 of the V2-on-V4 migration. Branched from `main` per Option B (independent of `socksnflops/eco-206-inherit-permissioned-router`).
What this commit lays down
Why precompile + assembly create2 (not submodule)
`UniswapV2Aggregator` is pinned to `pragma solidity 0.8.29`; UR is pinned to `0.8.26`. The precompile + assembly create2 pattern (already used by v4-hooks-public itself for V2 factory) sidesteps the cross-version compilation problem and avoids the heavy `v4-hooks-public` + `protocol-fees` submodule tree.
Local verification
```
forge build --skip "test/integration-tests/" # compiles clean
forge test --match-path "test/foundry-tests/aggregators/"
27 passed; 0 failed; 0 skipped — onlyForked modifier no-ops cleanly without FORK_URL
```
What's NOT here yet (follow-up commits on this branch, before merge)
Reviewer notes
AI-Generated Description
Summary
End-to-end test suite proving Universal Router can route V2 swaps through V4's
V4_SWAPcommand against aUniswapV2Aggregatorhook — the prerequisite for deleting the V2-specific swap module (~1.5 KB bytecode recovery toward the EIP-170 limit).Tracks PROTO-1373 — branched from
main(independent ofsocksnflops/eco-206-inherit-permissioned-router).Changes
Test framework (
_AggregatorBase.t.sol)UniswapV2AggregatorMockdeployed via CREATE2 with inline HookMiner for correct permission-flag address24-cell matrix (
V2AggregatorMatrix.t.sol)PoolNotInitializedrevertAdditional test suites
V2AggregatorMultiHop.t.sol— differential quote-vs-execution check, bounded fuzz on single-hopamountInV2AggregatorFeeOnTransfer.t.sol— exact-in FoT success, exact-out FoT revert (K-invariant violation), invariant fuzz (K non-decreasing, no residual tokens)V2AggregatorNative.t.sol— WRAP_ETH / UNWRAP_WETH composition; native currency initialize revertV2AggregatorIntermediateLimitation.t.sol— documents exact-out V2-only-intermediate limitation as acceptance criteria for flash-swap hook redesignGas snapshots (
gas/V2AggregatorGas.t.sol)snapshots/V2AggregatorGas.jsonInvariant suite (
invariants/)V2AggregatorHandler.sol+V2AggregatorInvariant.t.sol— K non-decreasing and no-residual-tokens invariants under fuzzed swap sequencesMocks
UniswapV2AggregatorMock.sol— in-tree mock mirroring production hook behavior (same permission flags,_swapOnPairflow,BeforeSwapDeltashape) under^0.8.24pragma to avoid cross-version compilation issuesMockFoTToken.sol— configurable fee-on-transfer ERC20 for FoT test pathsWhy in-tree mock (not submodule)
UniswapV2Aggregatorin v4-hooks-public is pinned topragma 0.8.29; UR is on0.8.26. The mock avoids dragging 5+ transitive submodules and lets tests override hook behavior for edge-case fuzzing.Notes
FORK_URLenv var; without it, tests no-op cleanly viaonlyForkedmodifierfoundry.tomlfs_permissionsextended to read the test directory