Skip to content

Fix USDC multi-hop encoding, redeploy Zap, re-enable USDC#469

Merged
realproject7 merged 1 commit intomainfrom
task/468-usdc-multihop-fix
Mar 23, 2026
Merged

Fix USDC multi-hop encoding, redeploy Zap, re-enable USDC#469
realproject7 merged 1 commit intomainfrom
task/468-usdc-multihop-fix

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

Fixes #468

Root Cause

abi.encode(field1, field2, ...) produces flat tuple encoding, but the V4 Router's CalldataDecoder.decodeSwapExactInParams() expects struct-style encoding with an outer 0x20 offset word. The single-hop ExactInputSingleParams worked because Forge's abi.encode(struct) naturally includes this offset, while our manual multi-hop encoding did not.

Contract Fix (in plotlink-contracts)

Added _encodeAsStruct() helper that prepends 0x20 offset to flat-encoded multi-hop params, matching what the Router expects. Applied to both _executeV4MultiHopSwapExactIn and _executeV4MultiHopSwapExactOut.

Successful USDC Trade (Base Mainnet)

TX: 0x22298421d03be8f4459c03141b10148b1b0c28e34e78e943e0a4b1995c43ea7f

  • 1 USDC → storyline tokens via USDC→ETH→PLOT multi-hop
  • Gas used: ~2M (V4 multi-hop is gas-intensive)

Test plan

  • Verify TradingWidget shows ETH, USDC, and HUNT options
  • Verify USDC zap quote works (estimateMint)
  • Verify ETH zap still works with new contract
  • Build passes

🤖 Generated with Claude Code

- ZAP_PLOTLINK: 0x04f557... → 0x952606df750C01e0a12458C3F814598B94AD5C5f
- Re-enable USDC in SUPPORTED_ZAP_TOKENS (was disabled in PR #466)

Root cause: abi.encode(field1, field2, ...) produces flat tuple encoding,
but the V4 Router's CalldataDecoder.decodeSwapExactInParams() expects
struct-style encoding (with an outer 0x20 offset word). Added
_encodeAsStruct() helper in the contract.

New contract verified on Sourcify. Successful USDC trade:
https://basescan.org/tx/0x22298421d03be8f4459c03141b10148b1b0c28e34e78e943e0a4b1995c43ea7f

Fixes #468

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The repo-side changes match issue #468: the new zap contract address is wired in, USDC is re-enabled, and the PR documents a successful mainnet USDC trade after redeployment.

Findings

  • None.

Decision

Approving because the acceptance criteria relevant to this repo are satisfied and CI is green.

@realproject7 realproject7 merged commit ee54d11 into main Mar 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Contract] Fix USDC multi-hop ABI encoding in ZapPlotLinkV2

2 participants