[#470] Fix USDC zap mint: restore _encodeAsStruct for V4 multi-hop#65
Merged
realproject7 merged 1 commit intomainfrom Mar 23, 2026
Merged
[#470] Fix USDC zap mint: restore _encodeAsStruct for V4 multi-hop#65realproject7 merged 1 commit intomainfrom
realproject7 merged 1 commit intomainfrom
Conversation
Root cause: V4 Router's CalldataDecoder.decodeSwapExactInParams/Out reads the first word of action params as an offset pointer (assembly: swapParams := add(params.offset, calldataload(params.offset))). abi.encode(field1, field2, ...) produces a flat tuple starting with the first field value, but the decoder expects a struct-style encoding with an outer 0x20 offset word. Previous fix attempts (PR #469) correctly identified the need for _encodeAsStruct but also added a noPriceChecks (uint256[]) field matching the v4-periphery lib's new minHopPriceX36 struct field. The deployed Universal Router (Jan 2025) predates that field (added Nov 2025), so the extra array corrupted the ABI layout. Fix: restore _encodeAsStruct (adds 0x20 prefix) without noPriceChecks. Verified: successful USDC mint tx on Base mainnet: 0x417378c881237fbbd9bbfd59225c643ebc26851d9151af58b2a1047d5cc70ac5 New ZapPlotLinkV2: 0xAe50C9444DA2Ac80B209dC8B416d1B4A7D3939B0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
approved these changes
Mar 23, 2026
Collaborator
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The contract change is narrowly scoped to the V4 multi-hop ABI layout regression and the deployment/docs updates are consistent with the new address. I did not find correctness, security, or scope issues in this diff.
Findings
- None.
Decision
Approve. The fix restores the struct-style encoding expected by the deployed Universal Router without reintroducing the incompatible extra field from PR #469.
project7-interns
approved these changes
Mar 23, 2026
Collaborator
project7-interns
left a comment
There was a problem hiding this comment.
T2b APPROVE
Fix is minimal, correct, and validated on mainnet.
_encodeAsStructcorrectly prepends 0x20 offset word for V4 Router's CalldataDecodernoPriceChecksfield properly removed — incompatible with deployed Jan 2025 Universal Router- Both swap directions (exact-in and exact-out) are fixed
- Helper is
private pure, no security concerns - No regression to ETH single-hop paths
Note (non-blocking): exact-in path uses uint128(0) as amountOutMinimum — slippage protection relies on downstream bonding curve check. Pre-existing, not introduced here.
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.
Summary
CalldataDecoder.decodeSwapExactInParams/decodeSwapExactOutParamsreads the first word of action params as an offset pointer (swapParams := add(params.offset, calldataload(params.offset))). Ourabi.encode(field1, field2, ...)produced a flat tuple (first word = address), but the decoder expectsabi.encode(struct)format (first word = 0x20 offset)._encodeAsStructbut also includednoPriceChecks(uint256[]) matching the v4-periphery lib's newminHopPriceX36field. The deployed Universal Router (Jan 2025) predates that field (added Nov 2025), corrupting the ABI layout._encodeAsStruct(adds 0x20 prefix) WITHOUTnoPriceChecks0xAe50C9444DA2Ac80B209dC8B416d1B4A7D3939B00x417378c8...Test plan
Fixes realproject7/plotlink#470
🤖 Generated with Claude Code