how to use analyse_trade_by_hash()?
Closed this issue · 1 comments
LittleTerry commented
Below are my codes., but I don't know how to set uniswap_v2 = UniswapV2Deployment(pancakeV2ContractAddress, pancakeV2ContractAbi). How should I set? It gives me error:
TypeError: UniswapV2Deployment.init() missing 4 required positional arguments: 'weth', 'router', 'init_code_hash', and 'PairContract'
import json
from web3 import Web3
from eth_defi.uniswap_v2.analysis import analyse_trade_by_hash
from eth_defi.uniswap_v2.deployment import UniswapV2Deployment
BSC_RPC = "https://bsc-dataseed.binance.org:443"
web3 = Web3(Web3.HTTPProvider(BSC_RPC))
# Initialize contract ABI
with open("pancakeV2ContractAbi.json") as file:
pancakeV2ContractAbi = json.load(file)
with open("pancakeV3ContractAbi.json") as file:
pancakeV3ContractAbi = json.load(file)
# pancake contract
# Initialize contract addresses
pancakeV2ContractAddress = "0x10ed43c718714eb63d5aa57b78b54704e256024e"
pancakeV3ContractAddress = '0x13f4ea83d0bd40e75c8222255bc855a974568dd4'
tx_hash = '0x4c95f90c0d5faace72da410d7602271bd1f503373627e65cafc88a6c18cf095c'
uniswap_v2 = UniswapV2Deployment(pancakeV2ContractAddress, pancakeV2ContractAbi)
analysis = analyse_trade_by_hash(web3, uniswap_v2, tx_hash)
print("Swapped in", analysis.amount_in)
print("Swapped out", analysis.amount_out)
miohtama commented
Answered per Discord discussion here
https://discord.com/channels/888448459168948284/929840173733269504/1158932969684209695