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 USDC = '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d' 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' } ] const LENDING_ABI = [ { inputs: [], name: 'paused', outputs: [{ internalType: 'bool', name: '', type: 'bool' }], stateMutability: 'view', type: 'function' } ] async function main() { console.log('\n检查 Lending 合约配置状态...\n') try { // 读取配置 const config = await client.readContract({ address: CONFIGURATOR, abi: CONFIGURATOR_ABI, functionName: 'getConfiguration', args: [LENDING_PROXY] }) // 检查暂停状态 const isPaused = await client.readContract({ address: LENDING_PROXY, abi: LENDING_ABI, functionName: 'paused' }) console.log('=== 基础配置 ===') console.log('baseToken:', config.baseToken) console.log('是否为 USDC:', config.baseToken.toLowerCase() === USDC.toLowerCase() ? '✓ 是' : '✗ 否') console.log('lendingPriceSource:', config.lendingPriceSource) console.log('是否为零地址:', config.lendingPriceSource === '0x0000000000000000000000000000000000000000' ? '✗ 是(错误)' : '✓ 否') console.log('\n=== 利率参数 ===') console.log('supplyKink:', config.supplyKink.toString()) console.log('borrowKink:', config.borrowKink.toString()) console.log('baseBorrowMin:', config.baseBorrowMin.toString()) console.log('targetReserves:', config.targetReserves.toString()) console.log('\n=== 系统状态 ===') console.log('是否暂停:', isPaused ? '✗ 是(无法操作)' : '✓ 否') console.log('\n=== 抵押品配置 ===') console.log('配置的抵押品数量:', config.assetConfigs.length) const ytAConfig = config.assetConfigs.find( cfg => cfg.asset.toLowerCase() === YT_A.toLowerCase() ) if (ytAConfig) { console.log('\nYT-A 配置:') console.log(' 地址:', ytAConfig.asset) console.log(' 精度:', ytAConfig.decimals) console.log(' 借款抵押率:', Number(ytAConfig.borrowCollateralFactor) / 1e16, '%') console.log(' 清算抵押率:', Number(ytAConfig.liquidateCollateralFactor) / 1e16, '%') console.log(' 清算奖励:', Number(ytAConfig.liquidationFactor) / 1e16, '%') console.log(' 供应上限:', Number(ytAConfig.supplyCap) / 1e18, 'tokens') } else { console.log('\n✗ YT-A 未配置!') } // 诊断 console.log('\n=== 诊断结果 ===') const issues = [] if (config.baseToken === '0x0000000000000000000000000000000000000000') { issues.push('✗ baseToken 未设置(零地址)') } if (config.lendingPriceSource === '0x0000000000000000000000000000000000000000') { issues.push('✗ lendingPriceSource 未设置(零地址)') } if (isPaused) { issues.push('✗ 系统已暂停') } if (!ytAConfig) { issues.push('✗ YT-A 未配置') } if (issues.length > 0) { console.log('发现问题:') issues.forEach(issue => console.log(' ' + issue)) } else { console.log('✓ 所有配置正常') } } catch (error) { console.error('✗ 读取配置失败:', error.message) } } main()