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,111 @@
import { createPublicClient, http, getAddress } from 'viem'
import { arbitrumSepolia } from 'viem/chains'
const client = createPublicClient({
chain: arbitrumSepolia,
transport: http('https://api.zan.top/node/v1/arb/sepolia/baf84c429d284bb5b676cb8c9ca21c07')
})
const LENDING_PROXY = getAddress('0xCb4E7B1069F6C26A1c27523ce4c8dfD884552d1D')
const USER = getAddress('0xa013422A5918CD099C63c8CC35283EACa99a705d')
const YT_A = getAddress('0x97204190B35D9895a7a47aa7BaC61ac08De3cF05')
async function testFunction(name, abi, args) {
try {
const result = await client.readContract({
address: LENDING_PROXY,
abi: [abi],
functionName: name,
args: args
})
console.log(`${name} 成功:`, result)
return { success: true, result }
} catch (error) {
console.log(`${name} 失败:`, error.message.split('\n')[0])
return { success: false, error: error.message }
}
}
async function main() {
console.log('\n测试不同的抵押品查询函数...\n')
console.log('合约:', LENDING_PROXY)
console.log('用户:', USER)
console.log('抵押品:', YT_A, '\n')
// 测试 1: userCollateral (Compound V3 标准)
console.log('--- 测试 1: userCollateral(address, address) ---')
await testFunction('userCollateral', {
inputs: [
{ name: 'account', type: 'address' },
{ name: 'asset', type: 'address' }
],
name: 'userCollateral',
outputs: [
{ name: 'balance', type: 'uint128' },
{ name: '_reserved', type: 'uint128' }
],
stateMutability: 'view',
type: 'function'
}, [USER, YT_A])
// 测试 2: getUserCollateral
console.log('\n--- 测试 2: getUserCollateral(address, address) ---')
await testFunction('getUserCollateral', {
inputs: [
{ name: '_user', type: 'address' },
{ name: '_collateralAsset', type: 'address' }
],
name: 'getUserCollateral',
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
}, [USER, YT_A])
// 测试 3: collateralBalanceOf
console.log('\n--- 测试 3: collateralBalanceOf(address, address) ---')
await testFunction('collateralBalanceOf', {
inputs: [
{ name: 'account', type: 'address' },
{ name: 'asset', type: 'address' }
],
name: 'collateralBalanceOf',
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
}, [USER, YT_A])
// 测试 4: getUserAccountData
console.log('\n--- 测试 4: getUserAccountData(address) ---')
const result = await testFunction('getUserAccountData', {
inputs: [{ name: '_user', type: 'address' }],
name: 'getUserAccountData',
outputs: [
{ name: 'totalCollateralValue', type: 'uint256' },
{ name: 'totalBorrowValue', type: 'uint256' },
{ name: 'availableToBorrow', type: 'uint256' },
{ name: 'healthFactor', type: 'uint256' }
],
stateMutability: 'view',
type: 'function'
}, [USER])
if (result.success) {
console.log('\n详细结果:')
console.log(' totalCollateralValue:', result.result[0].toString())
console.log(' totalBorrowValue:', result.result[1].toString())
console.log(' availableToBorrow:', result.result[2].toString())
console.log(' healthFactor:', result.result[3].toString())
}
// 测试 5: borrowBalanceOf (检查借款)
console.log('\n--- 测试 5: borrowBalanceOf(address) ---')
await testFunction('borrowBalanceOf', {
inputs: [{ name: 'account', type: 'address' }],
name: 'borrowBalanceOf',
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
}, [USER])
}
main()