feat: encode Uniswap v3 multihop paths - #477
Conversation
|
Closing this companion PR: the original #221 is stale WIP and should be closed rather than revived as a one-function fragment. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #477 +/- ##
==========================================
- Coverage 73.26% 73.07% -0.19%
==========================================
Files 12 12
Lines 2319 2325 +6
==========================================
Hits 1699 1699
- Misses 620 626 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryThe PR implements tightly packed Uniswap V3 multihop path encoding in
Confidence Score: 4/5The PR appears safe to merge, with one non-blocking validation gap for empty routes in the new encoder. Normal multihop routes are packed in the expected token-fee-token order with bounded uint24 fees, while an empty route returns a 20-byte value that cannot be decoded as a valid V3 path. Files Needing Attention: uniswap/util.py Important Files Changed
Reviews (1): Last reviewed commit: "feat: started working on multihop swaps ..." | Re-trigger Greptile |
| """ | ||
| raise NotImplementedError | ||
| """Encode a Uniswap V3 route as tightly packed token and fee values.""" | ||
| path = bytearray(_str_to_addr(token_in)) |
There was a problem hiding this comment.
Empty routes produce invalid paths
An empty route skips the loop and returns only the 20-byte input-token address, while a valid Uniswap V3 path requires at least one fee-and-token hop. Rejecting this input locally prevents callers from passing malformed path bytes to a router or quoter and receiving an opaque contract revert.
| path = bytearray(_str_to_addr(token_in)) | |
| if not route: | |
| raise ValueError("route must contain at least one hop") | |
| path = bytearray(_str_to_addr(token_in)) |
Knowledge Base Used: Token Registry, Fee Tiers, Constants, and Shared Utilities
Supersedes #221 with its surviving, conflict-resolved slice.