findDex.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from web3Tools import *
  2. initBolck = w3.eth.blockNumber - 10000
  3. #topDexRouter
  4. #topFactory
  5. info = []
  6. while initBolck < w3.eth.blockNumber :
  7. try:
  8. initBolck = initBolck +1
  9. result = w3.new.getBlock(initBolck, True)
  10. transactions = result['transactions']
  11. for transactionsI in transactions:
  12. function = transactionsI['input'][:10]
  13. if function in swapFunction:
  14. toAddress = transactionsI['to'].lower()
  15. if toAddress not in topDexRouter:
  16. topDexRouter.append(toAddress)
  17. try:
  18. factoryAddress = w3.dex.getFactory(toAddress).lower()
  19. if factoryAddress in topFactory:
  20. continue
  21. printTime('toAddress', toAddress)
  22. printTime('factoryAddress', factoryAddress)
  23. topFactory.append(factoryAddress)
  24. totalPair = w3.dex.getTotalPairV2(toAddress)
  25. printTime('totalPair', totalPair)
  26. data = {}
  27. data['router'] = toAddress
  28. data['factory'] = factoryAddress
  29. data['totalPair'] = totalPair
  30. info.append(data)
  31. except:
  32. continue
  33. except BaseException as err:
  34. time.sleep(20)
  35. printTime(info)