The Trade Data Collector is a Rust-based application designed to collect and export trade order events from a specified Ethereum-based decentralized exchange (DEX) contract which has IOrderBookV4.json as it's abi. It connects to the blockchain using a WebSocket RPC connection and listens for contract events, such as TakeOrderV2
and ClearV2
, that collects all orders actions on a DEX. The collected events are then written to a CSV file for further analysis.
- Connects to Ethereum networks using WebSocket RPC.
- Collects order-related events from smart contracts.
- Supports filtering events by type (
TakeOrderV2
,ClearV2
, etc.). - Exports collected events to a CSV file.
- Configurable network and contract address via command-line arguments.
- Supports multiple Ethereum networks (Mainnet, Arbitrum, Optimism, etc.).
- Rust 1.58 or higher.
- WebSocket RPC URL for the Ethereum network you want to connect to.
- Etherscan API key for fetching contract creation blocks (optional).
- ABI JSON file for the contract you want to track events from(README.md).
-
Clone the repository:
git clone git@github.com:blueogin/trade-data-collector.git cd trade-data-collector
-
Set up environment variables:
-
Create a
.env
file in the project root directory by referencing.env.example
file. -
Replace
YOUR_INFURA_PROJECT_ID
with your Infura or Alchemy WebSocket RPC URL.
-
-
Install dependencies:
cargo build --release
Run the application with the desired options using the following command format:
cargo run -- --network <NETWORK> --contract <CONTRACT_ADDRESS> --event <EVENT_TYPE>
You can find result in order_events.csv.