Repository navigation
Conversation
[Medium impact] The latest changes appear safe to merge and fix the remaining wrap-amount mismatch. SummaryThe PR adds native-ETH routes across V2 and V3 and legacy swap methods to the V4 clients.
Reviews (8) · Last reviewed commit: "review fix" · Reviewed by Greptile |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #496 +/- ##
==========================================
+ Coverage 71.03% 74.59% +3.56%
==========================================
Files 14 14
Lines 4302 4909 +607
==========================================
+ Hits 3056 3662 +606
- Misses 1246 1247 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@greptileai review |
|
@greptileai review |
…yncUniswap4; update UniversalRouter commands ABIs; Misc: Uniswap and AsyncUniswap default version set to 3; version 1 removed from supported; encode_v3_path() methods moved to util.py
|
@greptileai review |
|
@greptileai review |
|
@greptileai review |
…v3 trades via universal router when input token is native token
|
@greptileai review |
|
@greptileai review |
…ap4; update UniversalRouter commands ABIs
|
@TimeToBuildBob
Yes, that's intended. We only need to test quoting for the legacy classes. Moreover, I think using markers is overkill. In fact, we test against the same contract as on mainnet. It's enough to set custom IDs, like Actually, I think this approach should fit the v4 workflow too. We can pick crucial tests, like approvals/quoting/swaps, and skip heavy or non-critical ones for the very same reasons. In both cases, we have the full test results (and that's really meticulous) on the PR as proof and reference. Thoughts? |
|
@liquid-8 A smaller cross-chain set: agreed. But "if one succeeds, all succeed" doesn't hold, because each case depends on that chain's pool liquidity. I replayed the currently marked quote cases as read-only
So all four legs would fail today. Some v2 pools are tiny (Optimism WETH/UNI holds about 0.0005 UNI). On Optimism, DAI/USDC has no v2 pair, and its v3 0.3% pool has no in-range liquidity. This set passed 5/5 in both directions on all four:
That multihop is token-to-token. The ETH-anchored Selecting the cases
v4 The same approach makes sense, with two conditions:
|
|
@TimeToBuildBob, thanks for the research; that will help to explain. First, I don't consider the state PR to be final. Sure, there are networks to add. Regarding failed tests on previous runs: most were caused by an overly optimistic
I still need it to merge. You don't have any concerns regarding the codebase, do you? I will add the missing networks and configure tests in the next PR, which will be the final one for this delivery. That merge would also unlock the possibility of building an agent skill for Uniswap v4, similar to #497, which is part of D3. Sepolia addresses have been added. They miss the PositionDescriptor contract deployment on that network, but it is non-crucial, and the constructor can handle that case.
Totally makes sense. Regarding tokens, pool liquidity, etc. The only thing guaranteed on a random EVM network is a native token and its wrapped version, nothing more. Some networks we need to test have no proper pools for multi-hops. Just a bunch of (native token/some ERC20) and a couple of (ERC20 A/ERC20 B) not connected to other pools. You're right that we must test contracts. So, we must pick a bare minimum of parameters for certain methods. E.g., we need to test |
|
@liquid-8 Yes, I do. Please don't merge I ran the sync
The same code is in Fixes, in all four helpers, sync and async (
With those four applied to a scratch copy of the sync file, all the swaps above succeeded: ETH arrived as ETH, no WETH approval was needed, and v3 exact-out bought exactly 100 USDC. CI stays green because these tests check only Two smaller things in
Also worth a release note: the default I haven't verified the rest of the new address maps on-chain. On your testing plan: agreed. A (WETH, one ERC20) pool passed as a one-hop |
@TimeToBuildBob Should be addressed in 6422f17 Please verify |
|
@liquid-8 The four swap fixes are correct at All 16 swaps passed: v2/v3 × exact-input/exact-output × ETH→USDC/USDC→ETH × sync/async. I checked ETH balances after accounting for gas, USDC balances, and WETH balances—not just transaction status:
The Polygon address typo, The regression-test part of my last request is still outstanding. This commit changes no tests: For clarity, I am withdrawing the previously reproduced swap-code blockers, not claiming the whole deployment matrix is verified. At this check, the current-head Test workflow is queued (run); only the Docs build has completed. I have not reproduced a current-head v3 CI failure, and broader cross-chain coverage can remain in your planned follow-up. |
|
@liquid-8 Checked The new cases still only assert Current-head Test is red (run 47454886736):
v4/arbitrum is the clean signal: 8 errors + 8 failures, all on these new cases. v4/mainnet stopped at Please keep the four swap fixes, fix the fixture names/decorators and the WETH quote routes, and add the balance assertions: ETH net of gas, WETH stays 0, token delta, plus a fresh-account ETH-input case with no WETH approval. I can re-run the fork checks once those are in. Please don't merge this head. |
@TimeToBuildBob
I have no idea why we should check anything on that. This type of swap behaves like any other, like, what's the point |
|
@liquid-8 The point is not to test gas pricing. It's to distinguish “the wallet received native ETH” from the old bug where the transaction succeeded but delivered WETH instead. A receipt with For example, for token→ETH, using raw wei balances immediately before and after the swap: fee = receipt["gasUsed"] * receipt["effectiveGasPrice"]
eth_received = eth_after - eth_before + feeAssert Checked
Current-head CI confirms the test problems: v4/Arbitrum has 20 failures in these new cases, rather than the previous missing-fixture/invalid-route errors. The other red legs are still v4/mainnet's The previously verified swap-code fixes remain unchanged; I'm not reopening those or asking for a broader deployment sweep in this PR. The remaining work is to make these regression tests measure the intended transfers correctly and get CI green. I can't call this head merge-ready yet. |
|
@liquid-8 Checked the new head Two of the previous test corrections remain:
For exact-output native ETH, use Current CI: v4/Arbitrum has 18 failures, all in these legacy/fresh balance tests, with 307 passes. v4/mainnet stops at 20 failures, including reverted transactions in the older v4 tests; unlike the previous run, this is not just the base-fee rejection, so I have not established their cause. v3/mainnet still has the nine example-fixture connection-refused errors (234 passes). Build, typecheck and v2/mainnet pass. I'm keeping this review scoped to the outstanding regressions, not reopening the verified swap fixes or the broader deployment sweep. This head is not merge-ready while those assertions and CI remain red. |
|
@liquid-8 Checked 1. Sync assert input_token_balance_delta >= int((1 - client.max_slippage) * qtycap)
assert output_token_balance_delta == qtyArbitrum CI: ETH→USDC asserts assert input_token_balance_delta == qty
assert output_token_balance_delta >= int((1 - client.max_slippage) * qtycap)2. Token→ETH still shows zero native ETH after the fee correction. On Arbitrum, every USDC→ETH legacy case (v2/v3 × exact-in/exact-out × sync/async) failed with v4/mainnet and v3/mainnet are still running, so I have not used them. Please don't merge this head. |
Elaborate on this, please |
|
@liquid-8 I meant that CI measured There is a concrete fixture problem I should have checked first: both test accounts have EIP-7702 delegation code on both mainnet and Arbitrum. I just queried
All four responses were My earlier Next test change: generate a genuinely new account with Verified with an isolated Arbitrum fork: I sent The sync exact-input v2 assertion mismatch from my previous comment is independently visible in the test source and still needs fixing. But please do not change the already-fixed swap/unwrap code based on my WETH hypothesis. I have not rerun the current-head swap matrix with clean accounts, so this is a confirmed fixture defect, not a claim that the full suite now passes. |
|
@liquid-8 Checked The legacy quote-only clients still use the Anvil addresses, but that does not reintroduce the ETH-recipient problem: the regression swaps and balance measurements use the new v4 client accounts. At this check, current-head CI has passed build, typecheck and v2/mainnet; v3/mainnet and both v4 legs are still running. I have not rerun the swap matrix locally at this head, so this is confirmation of the fixture/assertion fixes, not an all-green or merge-ready verdict. The next verification is the balance regression results from those v4 jobs; there is no basis to change the swap code on the earlier WETH hypothesis. |
|
@TimeToBuildBob Looks good innit. As far as I can see, there are no concerns anymore, right? |
|
@liquid-8 Yes, no blocking concerns from me at CI at this head is all green: build, typecheck, v2/mainnet, v3/mainnet (the earlier connection-refused errors are gone), v4/mainnet (337 passed) and v4/arbitrum (325 passed). In both v4 legs, all 18 regression cases ran and passed rather than being skipped. They cover v2/v3 × exact-in/exact-out × sync/async in both directions, plus the fresh-account no-WETH-approval case. That includes USDC→ETH, so with clean empty-code accounts, the gas-corrected native-ETH delta and the WETH-stays-zero assertion both hold. The earlier zero-ETH result came from the delegated fixture accounts, not the swap code. One optional nit, not a blocker: the last commit changed the exact-output check to The merge decision is the maintainers'; from the review side, I consider my findings addressed. |
|
Checked the follow-up This change only rewires the fixtures in the two v4 test files; it does not change the swap implementation or assertions. No new blocking concern from that diff. Current-head CI is still running (Test run); the all-green result in my previous comment applies to |
|
@liquid-8 Checked PR CI at this head is all green: build, typecheck, v2/v3/v4 mainnet, v4/arbitrum. The swap/unwrap implementation and the empty-code regression accounts are unchanged.
Smaller, not blocking the library:
The merge click is still the maintainers'. From the review side, I would not hold the library on the dispatch YAML, and I would not treat a post-merge dispatch as coverage until the network names match. |
Added: V2 and V3 custom routes for quoting and swaps in Uniswap/AsyncUniswap
Added: Single- and multi-hop V2 and V3 swaps via UnivesalRouter in Uniswap4/AsyncUniswap4
Added: UniversalRouter v2.1.2; supports the full set of commands and actions
Added: all-chain testing workflows for Uniswap/AsyncUniswap and Uniswap4/AsyncUniswap4