- 新增 ARB Sepolia + BNB Testnet 多链支持 - 添加 LendingPanel 借贷系统组件 - 添加 LendingAdminPanel 管理面板 - 添加 USDCPanel USDC 操作组件 - 添加 HoldersPanel 持有人信息组件 - 添加 AutoTestPanel 自动化测试组件 - 重构 LP 组件为模块化结构 (LP/) - 添加多个调试和测试脚本 - 修复 USDC 精度动态配置 - 优化合约配置支持多链切换 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
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 YT_A = getAddress('0x97204190B35D9895a7a47aa7BaC61ac08De3cF05')
|
||
const USER = getAddress('0xa013422A5918CD099C63c8CC35283EACa99a705d')
|
||
|
||
const LENDING_ABI = [
|
||
{
|
||
inputs: [
|
||
{ internalType: 'address', name: '_user', type: 'address' },
|
||
{ internalType: 'address', name: '_collateralAsset', type: 'address' }
|
||
],
|
||
name: 'getUserCollateral',
|
||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
||
stateMutability: 'view',
|
||
type: 'function'
|
||
}
|
||
]
|
||
|
||
async function main() {
|
||
console.log('\n检查抵押品余额...\n')
|
||
console.log('用户:', USER)
|
||
console.log('抵押品:', YT_A)
|
||
|
||
try {
|
||
const collateralBalance = await client.readContract({
|
||
address: LENDING_PROXY,
|
||
abi: LENDING_ABI,
|
||
functionName: 'getUserCollateral',
|
||
args: [USER, YT_A]
|
||
})
|
||
|
||
console.log('\n✓ 抵押品余额:', Number(collateralBalance) / 1e18, 'YT-A')
|
||
|
||
if (collateralBalance > 0n) {
|
||
console.log('\n成功!代币已存入合约作为抵押品。')
|
||
} else {
|
||
console.log('\n警告:抵押品余额为 0,但钱包代币已被扣除。')
|
||
console.log('可能原因:')
|
||
console.log('1. 交易失败但代币被锁在某处')
|
||
console.log('2. 函数调用错误,需要检查交易哈希')
|
||
}
|
||
|
||
} catch (error) {
|
||
console.error('\n✗ 读取失败:', error.message)
|
||
}
|
||
}
|
||
|
||
main()
|