Add complete token lists for Ethereum Mainnet, ChainID 138, and ALL Mainnet

- Added Ethereum Mainnet token list (1 token: USDT)
- Updated ChainID 138 token list (6 tokens: added cUSDT and cUSDC)
- Added ALL Mainnet token list (9 tokens including AUSDT)
- Discovered ALL Mainnet tokens via Transfer event scanning
- Updated validation scripts for multi-chain support
- Created comprehensive documentation and guides
- Updated master documentation indexes
- All token lists validated and ready for submission
This commit is contained in:
defiQUG
2026-01-26 13:52:05 -08:00
parent f5f519a643
commit f0ab0eadc2
32 changed files with 4185 additions and 26 deletions

View File

@@ -3,7 +3,7 @@
* Enhanced Token List Validator
* Validates token lists against the Uniswap Token Lists JSON schema
* Based on: https://github.com/Uniswap/token-lists
* Schema: https://uniswap.org/tokenlist.schema.json
* Uses: @uniswap/token-lists package for schema and types
*
* Enhanced with:
* - EIP-55 checksum validation
@@ -21,14 +21,29 @@ import { ethers } from 'ethers';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Required chain ID
const REQUIRED_CHAIN_ID = 138;
// Required chain ID (optional - if not set, will validate all tokens have same chainId)
// Can be overridden via --chain-id flag
let REQUIRED_CHAIN_ID = null;
// Fetch schema from Uniswap
const SCHEMA_URL = 'https://uniswap.org/tokenlist.schema.json';
async function fetchSchema() {
/**
* Get schema from @uniswap/token-lists package
* Falls back to fetching from URL if package not available
*/
async function getSchema() {
try {
// Try to import schema from @uniswap/token-lists package
const tokenLists = await import('@uniswap/token-lists');
if (tokenLists.schema) {
console.log('✅ Using schema from @uniswap/token-lists package\n');
return tokenLists.schema;
}
} catch (error) {
console.log('⚠️ @uniswap/token-lists package not available, fetching schema from URL...\n');
}
// Fallback: fetch schema from Uniswap
try {
const SCHEMA_URL = 'https://uniswap.org/tokenlist.schema.json';
const response = await fetch(SCHEMA_URL);
if (!response.ok) {
throw new Error(`Failed to fetch schema: ${response.statusText}`);
@@ -56,6 +71,7 @@ function enhancedValidation(tokenList) {
const warnings = [];
const seenAddresses = new Set();
const seenSymbols = new Map(); // chainId -> Set of symbols
let detectedChainId = null;
// Required fields
if (!tokenList.name || typeof tokenList.name !== 'string') {
@@ -81,6 +97,11 @@ function enhancedValidation(tokenList) {
return { errors, warnings, valid: false };
}
// Detect chain ID from first token if not specified
if (tokenList.tokens.length > 0 && tokenList.tokens[0].chainId) {
detectedChainId = tokenList.tokens[0].chainId;
}
// Validate each token
tokenList.tokens.forEach((token, index) => {
const prefix = `Token[${index}]`;
@@ -89,8 +110,15 @@ function enhancedValidation(tokenList) {
if (typeof token.chainId !== 'number') {
errors.push(`${prefix}: Missing or invalid "chainId"`);
} else {
// Strict chain ID validation
if (token.chainId !== REQUIRED_CHAIN_ID) {
// Chain ID consistency check
if (detectedChainId === null) {
detectedChainId = token.chainId;
} else if (token.chainId !== detectedChainId) {
errors.push(`${prefix}: chainId mismatch - expected ${detectedChainId}, got ${token.chainId}`);
}
// Strict chain ID validation (if REQUIRED_CHAIN_ID is set)
if (REQUIRED_CHAIN_ID !== null && token.chainId !== REQUIRED_CHAIN_ID) {
errors.push(`${prefix}: chainId must be ${REQUIRED_CHAIN_ID}, got ${token.chainId}`);
}
}
@@ -170,8 +198,8 @@ async function validateTokenList(filePath) {
process.exit(1);
}
// Try to fetch and use Uniswap schema
const schema = await fetchSchema();
// Get schema from @uniswap/token-lists package or fetch from URL
const schema = await getSchema();
let validationResult;
if (schema) {
@@ -273,10 +301,16 @@ async function validateTokenList(filePath) {
}
// Main
const filePath = process.argv[2] || resolve(__dirname, '../lists/dbis-138.tokenlist.json');
const args = process.argv.slice(2);
const filePath = args.find(arg => !arg.startsWith('--')) || resolve(__dirname, '../lists/dbis-138.tokenlist.json');
const chainIdArg = args.find(arg => arg.startsWith('--chain-id='));
if (chainIdArg) {
REQUIRED_CHAIN_ID = parseInt(chainIdArg.split('=')[1], 10);
}
if (!filePath) {
console.error('Usage: node validate-token-list.js [path/to/token-list.json]');
console.error('Usage: node validate-token-list.js [path/to/token-list.json] [--chain-id=138]');
process.exit(1);
}