feat: 添加多链支持和 Lending 借贷系统

- 新增 ARB Sepolia + BNB Testnet 多链支持
- 添加 LendingPanel 借贷系统组件
- 添加 LendingAdminPanel 管理面板
- 添加 USDCPanel USDC 操作组件
- 添加 HoldersPanel 持有人信息组件
- 添加 AutoTestPanel 自动化测试组件
- 重构 LP 组件为模块化结构 (LP/)
- 添加多个调试和测试脚本
- 修复 USDC 精度动态配置
- 优化合约配置支持多链切换

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-26 23:32:29 +08:00
parent c8427caa01
commit 5cb64f881e
80 changed files with 18342 additions and 1117 deletions

View File

@@ -0,0 +1,104 @@
import { createPublicClient, http, formatUnits } from 'viem';
import { arbitrumSepolia } from 'viem/chains';
const RPC_URL = 'https://sepolia-rollup.arbitrum.io/rpc';
const LENDING_PROXY = '0xCb4E7B1069F6C26A1c27523ce4c8dfD884552d1D';
const client = createPublicClient({
chain: arbitrumSepolia,
transport: http(RPC_URL)
});
async function testBothFunctions() {
console.log('\n=== 测试 getTotalSupply vs getTotalLiquidity ===\n');
// 测试 getTotalSupply
console.log('1⃣ 测试 getTotalSupply():');
try {
const totalSupply = await client.readContract({
address: LENDING_PROXY,
abi: [{
inputs: [],
name: 'getTotalSupply',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
}],
functionName: 'getTotalSupply'
});
console.log(' ✅ 调用成功!');
console.log(' 值:', totalSupply.toString());
console.log(' 格式化:', formatUnits(totalSupply, 6), 'USDC');
} catch (error) {
console.log(' ❌ 调用失败!');
console.log(' 错误:', error.message.split('\n')[0]);
}
console.log('\n2⃣ 测试 getTotalLiquidity():');
try {
const totalLiquidity = await client.readContract({
address: LENDING_PROXY,
abi: [{
inputs: [],
name: 'getTotalLiquidity',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
}],
functionName: 'getTotalLiquidity'
});
console.log(' ✅ 调用成功!');
console.log(' 值:', totalLiquidity.toString());
console.log(' 格式化:', formatUnits(totalLiquidity, 6), 'USDC');
} catch (error) {
console.log(' ❌ 调用失败!');
console.log(' 错误:', error.message.split('\n')[0]);
}
// 测试其他可能的函数名
console.log('\n3⃣ 测试 totalSupply() (Compound V3 标准):');
try {
const totalSupply = await client.readContract({
address: LENDING_PROXY,
abi: [{
inputs: [],
name: 'totalSupply',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
}],
functionName: 'totalSupply'
});
console.log(' ✅ 调用成功!');
console.log(' 值:', totalSupply.toString());
console.log(' 格式化:', formatUnits(totalSupply, 6), 'USDC');
} catch (error) {
console.log(' ❌ 调用失败!');
console.log(' 错误:', error.message.split('\n')[0]);
}
console.log('\n4⃣ 测试 totalBorrow():');
try {
const totalBorrow = await client.readContract({
address: LENDING_PROXY,
abi: [{
inputs: [],
name: 'totalBorrow',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
}],
functionName: 'totalBorrow'
});
console.log(' ✅ 调用成功!');
console.log(' 值:', totalBorrow.toString());
console.log(' 格式化:', formatUnits(totalBorrow, 6), 'USDC');
} catch (error) {
console.log(' ❌ 调用失败!');
console.log(' 错误:', error.message.split('\n')[0]);
}
console.log('\n');
}
testBothFunctions().catch(console.error);