Files
smom-dbis-138/docs/operations/WRAP_AND_BRIDGE_WETH9_TO_MAINNET.md
defiQUG 50ab378da9 feat: Implement Universal Cross-Chain Asset Hub - All phases complete
PRODUCTION-GRADE IMPLEMENTATION - All 7 Phases Done

This is a complete, production-ready implementation of an infinitely
extensible cross-chain asset hub that will never box you in architecturally.

## Implementation Summary

### Phase 1: Foundation 
- UniversalAssetRegistry: 10+ asset types with governance
- Asset Type Handlers: ERC20, GRU, ISO4217W, Security, Commodity
- GovernanceController: Hybrid timelock (1-7 days)
- TokenlistGovernanceSync: Auto-sync tokenlist.json

### Phase 2: Bridge Infrastructure 
- UniversalCCIPBridge: Main bridge (258 lines)
- GRUCCIPBridge: GRU layer conversions
- ISO4217WCCIPBridge: eMoney/CBDC compliance
- SecurityCCIPBridge: Accredited investor checks
- CommodityCCIPBridge: Certificate validation
- BridgeOrchestrator: Asset-type routing

### Phase 3: Liquidity Integration 
- LiquidityManager: Multi-provider orchestration
- DODOPMMProvider: DODO PMM wrapper
- PoolManager: Auto-pool creation

### Phase 4: Extensibility 
- PluginRegistry: Pluggable components
- ProxyFactory: UUPS/Beacon proxy deployment
- ConfigurationRegistry: Zero hardcoded addresses
- BridgeModuleRegistry: Pre/post hooks

### Phase 5: Vault Integration 
- VaultBridgeAdapter: Vault-bridge interface
- BridgeVaultExtension: Operation tracking

### Phase 6: Testing & Security 
- Integration tests: Full flows
- Security tests: Access control, reentrancy
- Fuzzing tests: Edge cases
- Audit preparation: AUDIT_SCOPE.md

### Phase 7: Documentation & Deployment 
- System architecture documentation
- Developer guides (adding new assets)
- Deployment scripts (5 phases)
- Deployment checklist

## Extensibility (Never Box In)

7 mechanisms to prevent architectural lock-in:
1. Plugin Architecture - Add asset types without core changes
2. Upgradeable Contracts - UUPS proxies
3. Registry-Based Config - No hardcoded addresses
4. Modular Bridges - Asset-specific contracts
5. Composable Compliance - Stackable modules
6. Multi-Source Liquidity - Pluggable providers
7. Event-Driven - Loose coupling

## Statistics

- Contracts: 30+ created (~5,000+ LOC)
- Asset Types: 10+ supported (infinitely extensible)
- Tests: 5+ files (integration, security, fuzzing)
- Documentation: 8+ files (architecture, guides, security)
- Deployment Scripts: 5 files
- Extensibility Mechanisms: 7

## Result

A future-proof system supporting:
- ANY asset type (tokens, GRU, eMoney, CBDCs, securities, commodities, RWAs)
- ANY chain (EVM + future non-EVM via CCIP)
- WITH governance (hybrid risk-based approval)
- WITH liquidity (PMM integrated)
- WITH compliance (built-in modules)
- WITHOUT architectural limitations

Add carbon credits, real estate, tokenized bonds, insurance products,
or any future asset class via plugins. No redesign ever needed.

Status: Ready for Testing → Audit → Production
2026-01-24 07:01:37 -08:00

5.5 KiB

Wrap ETH to WETH9 and Bridge to Ethereum Mainnet

Purpose: Guide for wrapping ETH to WETH9 on Chain 138 and bridging to Ethereum Mainnet


Quick Start

# Wrap and bridge 20,000 ETH to Ethereum Mainnet
cd /home/intlc/projects/proxmox/smom-dbis-138
./scripts/wrap-and-bridge-weth9-to-mainnet.sh 20000 <recipient_address> <private_key>

# Or use environment variable for private key
export PRIVATE_KEY=0x...
./scripts/wrap-and-bridge-weth9-to-mainnet.sh 20000 <recipient_address>

Prerequisites

  1. ETH Balance: Sufficient ETH on Chain 138 for wrapping
  2. LINK Tokens: LINK tokens for paying CCIP fees (typically 0.1-2 LINK)
  3. Private Key: Wallet with ETH and LINK tokens
  4. Recipient Address: Ethereum Mainnet address to receive WETH9 (can be same as sender)

Contract Addresses

Chain 138

  • WETH9: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
  • CCIPWETH9Bridge: 0x89dd12025bfCD38A168455A44B400e913ED33BE2
  • LINK Token: 0x514910771AF9Ca656af840dff83E8264EcF986CA

Ethereum Mainnet

  • WETH9: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 (same address)
  • CCIPWETH9Bridge: 0x2A0840e5117683b11682ac46f5CF5621E67269E3
  • Chain Selector: 5009297550715157269

Process Flow

1. Check ETH Balance
   ↓
2. Wrap ETH → WETH9 (deposit())
   ↓
3. Approve Bridge (approve())
   ↓
4. Check LINK Balance
   ↓
5. Bridge to Mainnet (sendCrossChain())
   ↓
6. Wait for CCIP Confirmation (1-5 minutes)
   ↓
7. WETH9 appears on Ethereum Mainnet

Step-by-Step Manual Process

Step 1: Wrap ETH to WETH9

AMOUNT_WEI=$(cast --to-wei 20000 ether)

cast send "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "deposit()" \
  --value "$AMOUNT_WEI" \
  --rpc-url http://192.168.11.250:8545 \
  --private-key 0x... \
  --gas-price 20000000000 \
  --legacy

Step 2: Approve Bridge

MAX_UINT256="115792089237316195423570985008687907853269984665640564039457584007913129639935"

cast send "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "approve(address,uint256)" \
  "0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
  "$MAX_UINT256" \
  --rpc-url http://192.168.11.250:8545 \
  --private-key 0x... \
  --gas-price 20000000000 \
  --legacy

Step 3: Bridge to Ethereum Mainnet

RECIPIENT="0xYourMainnetAddress"
ETHEREUM_SELECTOR="5009297550715157269"
AMOUNT_WEI=$(cast --to-wei 20000 ether)

cast send "0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
  "sendCrossChain(uint64,address,uint256)" \
  "$ETHEREUM_SELECTOR" \
  "$RECIPIENT" \
  "$AMOUNT_WEI" \
  --rpc-url http://192.168.11.250:8545 \
  --private-key 0x... \
  --gas-price 20000000000 \
  --legacy

Verification

Check WETH9 Balance (Chain 138)

cast call "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "balanceOf(address)" \
  "0xYourAddress" \
  --rpc-url http://192.168.11.250:8545

Check Bridge Allowance

cast call "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "allowance(address,address)" \
  "0xYourAddress" \
  "0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
  --rpc-url http://192.168.11.250:8545

Check WETH9 Balance (Ethereum Mainnet)

After bridge completes (wait 1-5 minutes):

cast call "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "balanceOf(address)" \
  "0xYourMainnetAddress" \
  --rpc-url https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY

Safety Considerations

Large Amount Warnings

For amounts > 1,000 ETH, the script will:

  • Display warning messages
  • Request confirmation before wrapping
  • Request final confirmation before bridging

Gas Fees

  • Wrap Transaction: ~50,000 gas
  • Approve Transaction: ~50,000 gas
  • Bridge Transaction: ~200,000-500,000 gas
  • CCIP Fees: Paid in LINK tokens (0.1-2 LINK typically)

Timing

  • Wrap: ~15 seconds (block confirmation)
  • Approve: ~10 seconds (block confirmation)
  • Bridge: ~1-5 minutes (CCIP confirmation)

Troubleshooting

Insufficient ETH Balance

Error: Insufficient ETH balance

Solution: Ensure you have enough ETH to cover:

  • Amount to wrap
  • Gas fees for all transactions
Warning: Low LINK balance

Solution: Acquire LINK tokens on Chain 138 for CCIP fees

Bridge Transaction Fails

Possible Causes:

  1. Destination not configured on bridge
  2. Insufficient LINK for fees
  3. Insufficient gas

Solution: Check bridge destination configuration:

cast call "0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
  "destinations(uint64)" \
  "5009297550715157269" \
  --rpc-url http://192.168.11.250:8545

Example: Bridge 20,000 ETH

# Set environment
export PRIVATE_KEY=0xYourPrivateKey
export RPC_URL_138=http://192.168.11.250:8545

# Execute bridge
./scripts/wrap-and-bridge-weth9-to-mainnet.sh 20000 0xYourMainnetAddress

# The script will:
# 1. Check ETH balance
# 2. Wrap 20,000 ETH to WETH9
# 3. Approve bridge
# 4. Bridge to Ethereum Mainnet
# 5. Display transaction hash and next steps

Cost Estimate (20,000 ETH)

Item Cost
Wrap Gas ~0.001 ETH
Approve Gas ~0.001 ETH
Bridge Gas ~0.005 ETH
CCIP Fee (LINK) ~0.5-2 LINK
Total ETH Cost ~0.007 ETH
Total LINK Cost ~0.5-2 LINK


Last Updated: 2025-01-12