fetch_events_to_csv

Documentation for eth_defi.uniswap_v3.events.fetch_events_to_csv function.

fetch_events_to_csv(json_rpc_url, state, start_block=12369621, end_block=12370621, output_folder='/tmp', max_workers=16, log_info=<built-in function print>, max_blocks_once=2000, max_threads=10)[source]

Fetch all tracked Uniswap v3 events to CSV files for notebook analysis.

Creates couple of CSV files with the event data:

  • /tmp/uniswap-v3-swap.csv

  • /tmp/uniswap-v3-poolcreated.csv

  • /tmp/uniswap-v3-mint.csv

  • /tmp/uniswap-v3-burn.csv

A progress bar and estimation on the completion is rendered for console / Jupyter notebook using tqdm.

The scan be resumed using state storage to retrieve the last scanned block number from the previous round. However, the mechanism here is no perfect and only good for notebook use - for advanced persistent usage like database backed scans, please write your own scan loop using proper transaction management.

Note

Any Ethereum address is lowercased in the resulting dataset and is not checksummed.

Parameters
  • json_rpc_url (str) – JSON-RPC URL

  • start_block (int) – First block to process (inclusive), default is block 12369621 (when Uniswap v3 factory was created on mainnet)

  • end_block (int) – Last block to process (inclusive), default is block 12370621 (1000 block after default start block)

  • state (eth_defi.event_reader.state.ScanState) – Store the current scan state, so we can resume

  • output_folder (str) – Folder to contain output CSV files, default is /tmp folder

  • max_workers (int) – How many threads to allocate for JSON-RPC IO. You can increase your EVM node output a bit by making a lot of parallel requests, until you exhaust your nodes IO capacity. Experiement with different values and see how your node performs.

  • max_blocks_once – How many blocks your JSON-RPC provider allows for eth_getLogs call

  • log_info – Which function to use to output info messages about the progress

Returns

Our web3 instance we constructed for reading events

Return type

eth_defi.provider.multi_provider.MultiProviderWeb3