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:
106
frontend/scripts/check-withdraw-transactions.js
Normal file
106
frontend/scripts/check-withdraw-transactions.js
Normal file
@@ -0,0 +1,106 @@
|
||||
import { createPublicClient, http, getAddress, keccak256, toBytes } 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 withdrawSelector = keccak256(toBytes('withdraw(uint256)')).slice(0, 10)
|
||||
const supplyCollateralSelector = keccak256(toBytes('supplyCollateral(address,uint256)')).slice(0, 10)
|
||||
|
||||
console.log('\n=== 查找用户的交易记录 ===\n')
|
||||
console.log('用户地址:', USER)
|
||||
console.log('Lending 合约:', LENDING_PROXY)
|
||||
console.log('\n函数选择器:')
|
||||
console.log(' withdraw:', withdrawSelector)
|
||||
console.log(' supplyCollateral:', supplyCollateralSelector)
|
||||
console.log()
|
||||
|
||||
async function main() {
|
||||
const latestBlock = await client.getBlockNumber()
|
||||
console.log('最新区块:', latestBlock)
|
||||
console.log('查询范围: 最近 10000 个区块\n')
|
||||
|
||||
// 获取用户发送到 Lending 合约的所有交易
|
||||
const fromBlock = latestBlock - 10000n
|
||||
const toBlock = latestBlock
|
||||
|
||||
console.log('=== 查找所有用户 → Lending 的交易 ===\n')
|
||||
|
||||
let blockNum = fromBlock
|
||||
const transactions = []
|
||||
|
||||
while (blockNum <= toBlock) {
|
||||
const endBlock = blockNum + 1000n > toBlock ? toBlock : blockNum + 1000n
|
||||
|
||||
try {
|
||||
const block = await client.getBlock({
|
||||
blockNumber: blockNum,
|
||||
includeTransactions: true
|
||||
})
|
||||
|
||||
for (const tx of block.transactions) {
|
||||
if (typeof tx === 'object' &&
|
||||
tx.from.toLowerCase() === USER.toLowerCase() &&
|
||||
tx.to?.toLowerCase() === LENDING_PROXY.toLowerCase()) {
|
||||
transactions.push({
|
||||
hash: tx.hash,
|
||||
blockNumber: block.number,
|
||||
input: tx.input
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// Skip blocks without transactions
|
||||
}
|
||||
|
||||
blockNum += 1000n
|
||||
}
|
||||
|
||||
console.log(`找到 ${transactions.length} 笔交易\n`)
|
||||
|
||||
if (transactions.length === 0) {
|
||||
console.log('没有找到任何交易')
|
||||
return
|
||||
}
|
||||
|
||||
// 分析每笔交易
|
||||
for (const tx of transactions) {
|
||||
console.log('---')
|
||||
console.log('交易哈希:', tx.hash)
|
||||
console.log('区块:', tx.blockNumber.toString())
|
||||
|
||||
const selector = tx.input.slice(0, 10)
|
||||
console.log('函数选择器:', selector)
|
||||
|
||||
let functionName = '未知'
|
||||
if (selector === withdrawSelector) {
|
||||
functionName = 'withdraw (借款/提取)'
|
||||
// 解析参数 (uint256)
|
||||
const amountHex = '0x' + tx.input.slice(10)
|
||||
const amount = BigInt(amountHex)
|
||||
console.log('调用函数:', functionName)
|
||||
console.log('金额:', Number(amount) / 1e6, 'USDC')
|
||||
} else if (selector === supplyCollateralSelector) {
|
||||
functionName = 'supplyCollateral (存入抵押品)'
|
||||
// 解析参数 (address, uint256)
|
||||
const assetAddress = '0x' + tx.input.slice(34, 74)
|
||||
const amountHex = '0x' + tx.input.slice(74)
|
||||
const amount = BigInt(amountHex)
|
||||
console.log('调用函数:', functionName)
|
||||
console.log('资产:', getAddress(assetAddress))
|
||||
console.log('金额:', Number(amount) / 1e18)
|
||||
} else {
|
||||
console.log('调用函数:', functionName, '-', selector)
|
||||
}
|
||||
|
||||
console.log()
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
Reference in New Issue
Block a user