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:
108
frontend/scripts/check-token-transfers.js
Normal file
108
frontend/scripts/check-token-transfers.js
Normal file
@@ -0,0 +1,108 @@
|
||||
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 YT_A = getAddress('0x97204190B35D9895a7a47aa7BaC61ac08De3cF05')
|
||||
const LENDING_PROXY = getAddress('0xCb4E7B1069F6C26A1c27523ce4c8dfD884552d1D')
|
||||
const USER = getAddress('0xa013422A5918CD099C63c8CC35283EACa99a705d')
|
||||
|
||||
const TRANSFER_EVENT = {
|
||||
type: 'event',
|
||||
name: 'Transfer',
|
||||
inputs: [
|
||||
{ indexed: true, name: 'from', type: 'address' },
|
||||
{ indexed: true, name: 'to', type: 'address' },
|
||||
{ indexed: false, name: 'value', type: 'uint256' }
|
||||
]
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log('\n检查 YT-A 代币转账... \n')
|
||||
|
||||
const latestBlock = await client.getBlockNumber()
|
||||
console.log('最新区块:', latestBlock)
|
||||
console.log('查询范围: 最近 1000 个区块\n')
|
||||
|
||||
try {
|
||||
// 检查转入 Lending 合约的 Transfer
|
||||
console.log('--- 1. 查找转入 Lending 合约的转账 ---')
|
||||
const logsTo = await client.getLogs({
|
||||
address: YT_A,
|
||||
event: TRANSFER_EVENT,
|
||||
args: {
|
||||
to: LENDING_PROXY
|
||||
},
|
||||
fromBlock: latestBlock - 1000n,
|
||||
toBlock: latestBlock
|
||||
})
|
||||
|
||||
if (logsTo.length === 0) {
|
||||
console.log('✗ 未找到任何转入 Lending 合约的转账\n')
|
||||
} else {
|
||||
console.log('✓ 找到', logsTo.length, '笔转入记录:\n')
|
||||
logsTo.forEach((log, i) => {
|
||||
const { from, to, value } = log.args
|
||||
const isFromUser = from.toLowerCase() === USER.toLowerCase()
|
||||
console.log((i + 1) + '. 区块', log.blockNumber)
|
||||
console.log(' 交易:', log.transactionHash)
|
||||
console.log(' From:', from, isFromUser ? '<- 你的地址' : '')
|
||||
console.log(' To:', to)
|
||||
console.log(' Amount:', Number(value) / 1e18, 'YT-A')
|
||||
console.log()
|
||||
})
|
||||
}
|
||||
|
||||
// 检查从用户发出的 Transfer
|
||||
console.log('--- 2. 查找从你的地址发出的转账 ---')
|
||||
const logsFrom = await client.getLogs({
|
||||
address: YT_A,
|
||||
event: TRANSFER_EVENT,
|
||||
args: {
|
||||
from: USER
|
||||
},
|
||||
fromBlock: latestBlock - 1000n,
|
||||
toBlock: latestBlock
|
||||
})
|
||||
|
||||
if (logsFrom.length === 0) {
|
||||
console.log('✗ 未找到任何从你地址发出的转账\n')
|
||||
} else {
|
||||
console.log('✓ 找到', logsFrom.length, '笔转出记录:\n')
|
||||
logsFrom.forEach((log, i) => {
|
||||
const { from, to, value } = log.args
|
||||
const isToLending = to.toLowerCase() === LENDING_PROXY.toLowerCase()
|
||||
console.log((i + 1) + '. 区块', log.blockNumber)
|
||||
console.log(' 交易:', log.transactionHash)
|
||||
console.log(' From:', from)
|
||||
console.log(' To:', to, isToLending ? '<- Lending 合约' : '')
|
||||
console.log(' Amount:', Number(value) / 1e18, 'YT-A')
|
||||
console.log()
|
||||
})
|
||||
}
|
||||
|
||||
// 检查用户的 YT-A 余额
|
||||
console.log('--- 3. 检查当前 YT-A 余额 ---')
|
||||
const balance = await client.readContract({
|
||||
address: YT_A,
|
||||
abi: [{
|
||||
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
||||
name: 'balanceOf',
|
||||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
||||
stateMutability: 'view',
|
||||
type: 'function'
|
||||
}],
|
||||
functionName: 'balanceOf',
|
||||
args: [USER]
|
||||
})
|
||||
console.log('你的 YT-A 余额:', Number(balance) / 1e18, '\n')
|
||||
|
||||
} catch (error) {
|
||||
console.error('查询失败:', error.message)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user