Files
Heyue_test/frontend/scripts/test-config-read.js
Sofio 5cb64f881e 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>
2026-01-26 23:32:29 +08:00

95 lines
3.9 KiB
JavaScript

import { createPublicClient, http } from 'viem'
import { arbitrumSepolia } from 'viem/chains'
const client = createPublicClient({
chain: arbitrumSepolia,
transport: http('https://api.zan.top/node/v1/arb/sepolia/baf84c429d284bb5b676cb8c9ca21c07')
})
const CONFIGURATOR = '0x488409CE9A3Fcd8EbD373dCb7e025cF8AB96fcdc'
const LENDING_PROXY = '0xCb4E7B1069F6C26A1c27523ce4c8dfD884552d1D'
const YT_A = '0x97204190B35D9895a7a47aa7BaC61ac08De3cF05'
const CONFIGURATOR_ABI = [
{
inputs: [
{ internalType: 'address', name: 'lendingProxy', type: 'address' }
],
name: 'getConfiguration',
outputs: [
{
components: [
{ internalType: 'address', name: 'baseToken', type: 'address' },
{ internalType: 'address', name: 'lendingPriceSource', type: 'address' },
{ internalType: 'uint64', name: 'supplyKink', type: 'uint64' },
{ internalType: 'uint64', name: 'supplyPerYearInterestRateSlopeLow', type: 'uint64' },
{ internalType: 'uint64', name: 'supplyPerYearInterestRateSlopeHigh', type: 'uint64' },
{ internalType: 'uint64', name: 'supplyPerYearInterestRateBase', type: 'uint64' },
{ internalType: 'uint64', name: 'borrowKink', type: 'uint64' },
{ internalType: 'uint64', name: 'borrowPerYearInterestRateSlopeLow', type: 'uint64' },
{ internalType: 'uint64', name: 'borrowPerYearInterestRateSlopeHigh', type: 'uint64' },
{ internalType: 'uint64', name: 'borrowPerYearInterestRateBase', type: 'uint64' },
{ internalType: 'uint64', name: 'storeFrontPriceFactor', type: 'uint64' },
{ internalType: 'uint64', name: 'trackingIndexScale', type: 'uint64' },
{ internalType: 'uint104', name: 'baseBorrowMin', type: 'uint104' },
{ internalType: 'uint104', name: 'targetReserves', type: 'uint104' },
{
components: [
{ internalType: 'address', name: 'asset', type: 'address' },
{ internalType: 'uint8', name: 'decimals', type: 'uint8' },
{ internalType: 'uint64', name: 'borrowCollateralFactor', type: 'uint64' },
{ internalType: 'uint64', name: 'liquidateCollateralFactor', type: 'uint64' },
{ internalType: 'uint64', name: 'liquidationFactor', type: 'uint64' },
{ internalType: 'uint128', name: 'supplyCap', type: 'uint128' }
],
internalType: 'struct LendingConfiguration.AssetConfig[]',
name: 'assetConfigs',
type: 'tuple[]'
}
],
internalType: 'struct LendingConfiguration.Configuration',
name: '',
type: 'tuple'
}
],
stateMutability: 'view',
type: 'function'
}
]
async function main() {
console.log('🔍 测试从 Configurator 读取配置...\n')
try {
const config = await client.readContract({
address: CONFIGURATOR,
abi: CONFIGURATOR_ABI,
functionName: 'getConfiguration',
args: [LENDING_PROXY]
})
console.log('✅ 成功读取配置!\n')
console.log('基础代币 (USDC):', config.baseToken)
console.log('价格源:', config.lendingPriceSource)
console.log('\n抵押品配置数量:', config.assetConfigs.length)
config.assetConfigs.forEach((asset, index) => {
console.log(`\n${index + 1}. 抵押品:`, asset.asset)
console.log(' 精度:', asset.decimals)
console.log(' 借款抵押率:', Number(asset.borrowCollateralFactor) / 1e16, '%')
console.log(' 清算抵押率:', Number(asset.liquidateCollateralFactor) / 1e16, '%')
console.log(' 清算奖励:', Number(asset.liquidationFactor) / 1e16, '%')
console.log(' 供应上限:', Number(asset.supplyCap) / 1e18)
if (asset.asset.toLowerCase() === YT_A.toLowerCase()) {
console.log(' ✅ 这是 YT-A')
}
})
} catch (error) {
console.error('❌ 读取配置失败:', error.message)
}
}
main()