Skip to content

feat: wallet-sdk + Uniswap V4 fuel swap + witness-bound Permit2 (rebased onto main)#10

Open
alejoamiras wants to merge 7 commits into
holonym-foundation:mainfrom
alejoamiras:feat/fuel-swap-rebased
Open

feat: wallet-sdk + Uniswap V4 fuel swap + witness-bound Permit2 (rebased onto main)#10
alejoamiras wants to merge 7 commits into
holonym-foundation:mainfrom
alejoamiras:feat/fuel-swap-rebased

Conversation

@alejoamiras

@alejoamiras alejoamiras commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Full bridge upgrade rebased onto current main (post feat/passport-integration merge): wallet-sdk migration, Uniswap V4 fuel swap for automatic L2 gas, and witness-bound Permit2 for secure bridge parameter binding.

Note: This is a companion to PR #6. PR #6 has the same features but is based pre-passport-integration merge. This PR is rebased onto current main and has been tested end-to-end on v4-devnet-2.

What's included

Wallet-SDK Migration

  • Replace @azguardwallet/client with @aztec/wallet-sdk for wallet discovery, connection, and emoji verification
  • BridgedFPC private fuel payment — users can pay L2 gas fees using bridged tokens
  • L2→L1 private withdrawal auth witness fix

Uniswap V4 Fuel Swap (Contracts + Frontend)

  • UniswapFuelSwap.sol — swaps a portion of bridged tokens for ETH via Uniswap V4, wraps to WETH, and bridges to L2 as fee juice
  • SwapBridgeRouter.sol — single-tx entry point: Permit2 transfer → optional fuel swap → TokenPortal deposit
  • SeedUniswapPools.s.sol — standalone Forge script to seed V4 pools with liquidity
  • FuelToggle component with real-time price quotes (CoinGecko + Uniswap V4 Quoter)
  • Deploy scripts for all contracts + SetTrustedForwarderAllPortals admin script

Witness-Bound Permit2

  • Bridge parameters (portal, recipient, secret hash, etc.) are bound into the Permit2 witness
  • Prevents parameter tampering between signature and execution
  • routeHash + fuelRecipient encoding fix for the simple (non-fuel) bridge path

Permit2 is completely optional. There is a commit before the Permit2 work that uses the standard ERC20 approval method and doesn't change the TokenPortal contract at all. The router is layered on top — you can use the simpler path if preferred.

Tested on devnet ✅

Flow Status Notes
Public bridge (L1→L2) ✅ Working Via SwapBridgeRouter with Permit2
L1→L2 + public fuel swap ✅ Working USDC → WETH → ETH → FeeJuice via Uniswap V4
L1→L2 + private fuel (BridgedFPC) ✅ Working
L2→L1 withdrawal Ready Both public and private paths
Wallet-SDK connection ✅ Working Discovery + emoji verification flow
Multi-token support ✅ Working USDC, WETH, and others tested
Faucet (mint test tokens) ✅ Working Fresh compliant deployment with our key

What you'll need for production

  1. Deploy contracts: UniswapFuelSwap, SwapBridgeRouter (Forge scripts provided)
  2. Seed Uniswap V4 pools: SeedUniswapPools.s.sol for ETH/FeeJuice and ERC20/WETH pools
  3. Trusted forwarder: Run SetTrustedForwarderAllPortals to authorize the router on each TokenPortal
  4. Update deployments.json: Point to your deployed contract addresses
  5. BridgedFPC address: Deterministic from artifact + salt=0 (already configured)

Deployment notes

  • Fresh compliant deployment included (4.0.0-devnet.2-patch.3_2026-03-20)
  • Stale PXE LMDB data stores (pxe_data_*, wallet_data_*) must be cleaned before running bridge-script deployments
  • saveFuelInfraToDeployment added to save_contracts.ts for the compliant script
  • Bridge-script codegen artifacts included for custom TokenBridge + TokenMinterProxy

Also vibe coded 🤖

A good chunk of this was built with Claude, so definitely give the contracts a proper review. The logic is solid from our testing but fresh eyes on the Solidity would be great.

🤖 Generated with Claude Code

alejoamiras and others added 7 commits March 17, 2026 17:33
- Add trusted forwarder pattern to TokenPortal for delegated deposits
- SwapBridgeRouter: witness-bound Permit2 bridge with optional fuel swap
- UniswapFuelSwap: Uniswap V4 integration for automatic L2 gas funding
- Deploy scripts and comprehensive test suites for all contracts
- Remove deprecated BridgeAndFuel and MockFuelSwap contracts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…mit2

Frontend integration for the full bridge upgrade:
- Migrate from @azguardwallet/client to @aztec/wallet-sdk
- BridgedFPC private fuel payment with automatic fee juice claims
- FuelToggle component with real-time Uniswap V4 price quotes
- Witness-bound Permit2 flow for secure bridge parameter binding
- Withdrawal auth witness for private L2-to-L1 exits
- CoinGecko + V4 Quoter dual pricing for fuel estimates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update bridge-script for SwapBridgeRouter and UniswapFuelSwap
- Add redeploy-permit2 utility script
- Update deployment registry and README with new contract details

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Deploy all 7 tokens with custom TokenPortal (compliant script)
- Deploy SwapBridgeRouter at 0x9E21891e2a3a7A366C1bbAB18a2B88Fd72C5D6D7
- Set trusted forwarder on all portals
- Add BridgedFPC deterministic address (salt=0)
- Add saveFuelInfraToDeployment to save_contracts utility
- Fix duplicate fee juice display in BridgeSection
- Generate L2 codegen artifacts for compliant bridge

Public L1→L2 bridge tested and working.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Standalone Forge script to seed ETH/FeeJuice and ERC20/WETH pools
without redeploying UniswapFuelSwap. Supports configurable amounts,
skip flags, and transfers deployer's existing FJ balance to the seeder.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…uel claim

- Replace hardcoded "USDC" with selected token symbol on progress page
- Show fuel amount in USD (from CoinGecko prices) instead of token units
- Smart decimal formatting: shows meaningful digits for small amounts (0.003 WETH not 0.00)
- Private fuel (BridgedFPC) now correctly triggers claim_private on L2
  and isPrivate on L1 deposit — the whole chain is private when private fuel is selected

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ate deposit)

Private fuel (BridgedFPC) flow:
- L1: depositToAztecPublic for both token and FeeJuice (no attestation needed)
- L2: claim_public for token + BridgedMintAndPayFeePaymentMethod handles
  FeeJuice.claim (private) + mint_and_pay_fee (private) as fee setup calls

Reverts the isPrivate || !!privateFuel change — private deposit requires
attestation signatures which aren't available for the fuel-only flow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant