Skip to main content

2. Define events

In events.sol, define any events that you want to handle in your indexer.

events.sol
interface Events {
event PairCreated(address indexed token0, address indexed token1, address pair, uint256 extra_);
event Sync(uint112 reserve0, uint112 reserve1);
event Swap(address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to);
}

Event Fetcher

info

Use the event fetcher tool to input a contract address and extract events for your events.sol file.

Alternatively, if you don't want to define your events manually, you can use the Event Fetcher to fetch the ABI

Fetch events

Click on any events you want to import into your events.sol file

Add events

Full Example

events.sol
interface Events {
event Swap(address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to);
event PairCreated(address indexed token0, address indexed token1, address pair, uint256 extra_) ;
event Sync(uint112 reserve0, uint112 reserve1);
}