Files
explorer-monorepo/docs/WETH9_WETH10_ISSUES_AND_FIXES.md

178 lines
4.2 KiB
Markdown
Raw Permalink Normal View History

# WETH9 and WETH10 Issues and Fixes
**Date**: $(date)
**Status**: ✅ **All Issues Documented and Fixes Provided**
---
## Issues Identified
### WETH9 Issues
1. **decimals() returns 0** ⚠️
- **Impact**: Display issues in wallets (MetaMask shows incorrect format)
- **Severity**: Low (display only, doesn't affect functionality)
- **Status**: Known WETH9 limitation
2. **Function signature search limitation** ⚠️
- **Impact**: None (functions work correctly)
- **Severity**: None (heuristic limitation only)
- **Status**: Not a real issue
### WETH10 Issues
1. **No tokens minted yet**
- **Impact**: Contract is empty (0 supply, 0 balance)
- **Severity**: None (normal for unused contract)
- **Status**: Expected behavior
2. **decimals() returns 18**
- **Status**: Correct! No issue here
---
## Solutions and Fixes
### Fix 1: Token Metadata Files
Since WETH9 and WETH10 are pre-deployed contracts that cannot be modified, we create token metadata files for wallets to use correct decimals.
#### WETH9 Token Metadata
**File**: `docs/WETH9_TOKEN_METADATA.json`
```json
{
"chainId": 138,
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"name": "Wrapped Ether",
"symbol": "WETH",
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png"
}
```
#### WETH10 Token Metadata
**File**: `docs/WETH10_TOKEN_METADATA.json`
```json
{
"chainId": 138,
"address": "0xf4BB2e28688e89fCcE3c0580D37d36A7672E8A9f",
"name": "Wrapped Ether v10",
"symbol": "WETH10",
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png"
}
```
### Fix 2: Updated Token List
**File**: `docs/METAMASK_TOKEN_LIST_FIXED.json`
Includes both WETH9 and WETH10 with correct decimals (18).
### Fix 3: Helper Scripts
#### Script: `scripts/get-token-info.sh`
Provides correct token information including decimals override.
#### Script: `scripts/fix-wallet-display.sh`
Instructions and commands to fix wallet display issues.
### Fix 4: Documentation Updates
All documentation updated to include:
- How to manually set decimals in wallets
- Token metadata files
- Workaround instructions
---
## Implementation
### Step 1: Create Token Metadata Files
Token metadata files have been created with correct decimals.
### Step 2: Update Token Lists
Token lists have been updated to include correct decimals.
### Step 3: Create Helper Scripts
Helper scripts have been created to work around the decimals issue.
### Step 4: Update Documentation
All documentation has been updated with fixes and workarounds.
---
## Usage Instructions
### For MetaMask Users
1. **Import Token Manually**:
- Go to MetaMask → Import Tokens
- Enter contract address
- **Important**: Set decimals to **18** (not 0)
- Add token
2. **Use Token List**:
- Add token list URL (if hosted)
- Tokens will appear with correct decimals
### For Developers
1. **Use Token Metadata Files**:
- Load metadata from `docs/WETH9_TOKEN_METADATA.json`
- Use decimals: 18 (not from contract)
2. **In Code**:
```javascript
// Always use 18 decimals for WETH9/WETH10
const decimals = 18; // Don't read from contract
const balance = await contract.balanceOf(address);
const formatted = ethers.utils.formatUnits(balance, 18);
```
---
## Verification
### WETH9 Status
- ✅ Contract exists and functional
- ✅ 1:1 backing maintained (8 ETH = 8 WETH9)
- ⚠️ decimals() returns 0 (fixed with metadata)
- ✅ All functions work correctly
### WETH10 Status
- ✅ Contract exists and functional
- ✅ decimals() returns 18 (correct!)
- No tokens minted yet (normal)
- ✅ All functions work correctly
---
## Summary
**All issues have been addressed:**
1. ✅ WETH9 decimals issue: Fixed with metadata files and documentation
2. ✅ WETH10: No issues (decimals correct)
3. ✅ Token lists updated
4. ✅ Helper scripts created
5. ✅ Documentation complete
**The contracts are functional. The only issue is a display problem with WETH9 decimals, which is fixed with proper metadata.**
---
**Last Updated**: $(date)