Files
hyper/clp_auto_hedger/compare_txs.py

58 lines
1.7 KiB
Python

import os
import sys
import json
from web3 import Web3
# Manually load .env
env_vars = {}
try:
with open(".env", "r") as f:
for line in f:
if "=" in line and not line.startswith("#"):
key, value = line.strip().split("=", 1)
env_vars[key] = value
except FileNotFoundError:
print("Error: .env file not found")
sys.exit(1)
RPC_URL = env_vars.get("MAINNET_RPC_URL")
w3 = Web3(Web3.HTTPProvider(RPC_URL))
tx_hashes = [
"0x4d462075bea5c35ac3c16d101fee91f553a664f30bcbfcb16494966099357d03",
"0xe7c37e1304c85bc4231277570c39056b299ce1db0be6c0da62137f235b70cd5e"
]
# Known Method IDs
METHODS = {
"0xd0e30db0": "deposit() (Wrap ETH -> WETH)",
"0x2e1a7d4d": "withdraw(uint256) (Unwrap WETH -> ETH)",
"0xa9059cbb": "transfer(address,uint256)",
"0x095ea7b3": "approve(address,uint256)",
"0x414bf389": "exactInputSingle(params) (Swap)",
"0x88316456": "mint(params) (Uniswap V3 Mint)",
"0x0c49ccbe": "decreaseLiquidity(params)",
"0xfc6f7865": "collect(params)"
}
print(f"{'TX HASH':<10} | {'STATUS':<8} | {'METHOD':<30} | {'VALUE (ETH)':<10} | {'TO':<42}")
print("-" * 110)
for tx_hash in tx_hashes:
try:
tx = w3.eth.get_transaction(tx_hash)
receipt = w3.eth.get_transaction_receipt(tx_hash)
status = "SUCCESS" if receipt.status == 1 else "FAIL"
value = tx['value'] / 10**18
to_addr = tx['to']
input_data = tx['input'].hex()
method_id = input_data[:10]
method_name = METHODS.get(method_id, f"Unknown ({method_id})")
print(f"{tx_hash[:8]}.. | {status:<8} | {method_name:<30} | {value:<10.4f} | {to_addr}")
except Exception as e:
print(f"{tx_hash[:8]}.. | ERROR: {e}")