Files
Heyue_test/frontend/scripts/debug-events.js

61 lines
2.1 KiB
JavaScript
Raw Normal View History

import { createPublicClient, http, getAddress, parseAbiItem } from 'viem'
import { arbitrumSepolia } from 'viem/chains'
const client = createPublicClient({
chain: arbitrumSepolia,
transport: http('https://sepolia-rollup.arbitrum.io/rpc')
})
const LENDING_PROXY = getAddress('0xCb4E7B1069F6C26A1c27523ce4c8dfD884552d1D')
async function main() {
const latestBlock = await client.getBlockNumber()
console.log('Latest Block:', latestBlock)
const fromBlock = latestBlock - 10000n
console.log(`Checking events from block ${fromBlock} to ${latestBlock}..\n`)
// Check SupplyCollateral
const supplyEvent = parseAbiItem('event SupplyCollateral(address indexed from, address indexed dst, address indexed asset, uint256 amount)')
const supplyLogs = await client.getLogs({
address: LENDING_PROXY,
event: supplyEvent,
fromBlock,
toBlock: latestBlock
})
console.log(`SupplyCollateral Events found: ${supplyLogs.length}`)
// Check Deposit
const depositEvent = parseAbiItem('event Deposit(address indexed user, address indexed collateralAsset, uint256 amount)')
const depositLogs = await client.getLogs({
address: LENDING_PROXY,
event: depositEvent,
fromBlock,
toBlock: latestBlock
})
console.log(`Deposit Events found: ${depositLogs.length}`)
// Check WithdrawCollateral
const withdrawColEvent = parseAbiItem('event WithdrawCollateral(address indexed src, address indexed to, address indexed asset, uint256 amount)')
const withdrawColLogs = await client.getLogs({
address: LENDING_PROXY,
event: withdrawColEvent,
fromBlock,
toBlock: latestBlock
})
console.log(`WithdrawCollateral Events found: ${withdrawColLogs.length}`)
// Check Withdraw
const withdrawEvent = parseAbiItem('event Withdraw(address indexed user, address indexed collateralAsset, uint256 amount)')
const withdrawLogs = await client.getLogs({
address: LENDING_PROXY,
event: withdrawEvent,
fromBlock,
toBlock: latestBlock
})
console.log(`Withdraw Events (custom) found: ${withdrawLogs.length}`)
}
main().catch(console.error)