dojo.dataloaders package

Dataloaders load protocol events data for dojo environments.

class dojo.dataloaders.AaveV3Loader(env_name: str, date_range: Tuple[datetime, datetime], file_paths: List[str])

Bases: BaseLoader

Class for loading events data from pickle or JSON files in AWS S3.

class dojo.dataloaders.BaseLoader(env_name: str, date_range: Tuple[datetime, datetime], **kwargs)

Bases: ABC

Abstract base class for dataloaders.

This class automatically checks that the events data loaded is in the correct format. It also converts addresses to checksum format and dates to UTC timezone.

You can implement your own dataloader by inheriting from this class and overriding the _load_data method. This method should return a list of dictionaries in the formats specified under dojo/dataloaders/formats.py.

load(do_checks: bool = True) List[Event] | List[dict]

Load events for an environment in a date range.

Parameters:

do_checks – Whether to check that the events are in the correct format. - If True, returns a list of Event dataclasses. - If False, returns the raw list of dictionaries.

Raises:

ValueError – If the environment is not supported.

class dojo.dataloaders.UniV3Loader(env_name: str, date_range: Tuple[datetime, datetime], pools: List[str])

Bases: BaseLoader

Class for loading events data from pickle or JSON files in AWS S3.

Submodules

Load protocol events data from AWS S3.

class dojo.dataloaders.aavev3_loader.AaveV3Loader(env_name: str, date_range: Tuple[datetime, datetime], file_paths: List[str])

Bases: BaseLoader

Class for loading events data from pickle or JSON files in AWS S3.

The base dataloader class.

class dojo.dataloaders.base_loader.BaseLoader(env_name: str, date_range: Tuple[datetime, datetime], **kwargs)

Bases: ABC

Abstract base class for dataloaders.

This class automatically checks that the events data loaded is in the correct format. It also converts addresses to checksum format and dates to UTC timezone.

You can implement your own dataloader by inheriting from this class and overriding the _load_data method. This method should return a list of dictionaries in the formats specified under dojo/dataloaders/formats.py.

load(do_checks: bool = True) List[Event] | List[dict]

Load events for an environment in a date range.

Parameters:

do_checks – Whether to check that the events are in the correct format. - If True, returns a list of Event dataclasses. - If False, returns the raw list of dictionaries.

Raises:

ValueError – If the environment is not supported.

dojo.dataloaders.base_loader.address_to_name(protocol: str, address: str) str

Convert contract address to name.

Event format specifications.

This module specifies the format of events data that is compatible with dojo environments. The data passed to the dataloader should have these formats.

class dojo.dataloaders.formats.Event(date: datetime, block: int, log_index: int, action: str, gas: int, gas_price: int)

Bases: object

Base class for events.

Parameters:
  • date – date of event (datetime)

  • block – block number of event (int)

  • log_index – log index of event (int)

  • action – action type of event (str)

  • gas – gas used for the event (int)

  • gas_price – gas price used for the event (int)

action: str
block: int
date: datetime
gas: int
gas_price: int
log_index: int
class dojo.dataloaders.formats.UniV3Burn(date: datetime, block: int, log_index: int, action: str, gas: int, gas_price: int, pool: str, quantities: list, tick_range: list, liquidity: int, owner: str)

Bases: Event

Event class for UniswapV3 burns.

Parameters:
  • date – date of event (datetime)

  • block – block number of event (int)

  • log_index – log index of event (int)

  • action – action type of event (str)

  • pool – pool address (str)

  • quantities – token quantities of the burn (list)

  • tick_range – tick range of the burn (list)

  • liquidity – liquidity of the burn (int)

  • owner – owner address of the burn (str)

  • gas – gas used for the event (int)

  • gas_price – gas price used for the event (int)

action: str
block: int
date: datetime
gas: int
gas_price: int
liquidity: int
log_index: int
owner: str
pool: str
quantities: list
tick_range: list
class dojo.dataloaders.formats.UniV3Collect(date: datetime, block: int, log_index: int, action: str, gas: int, gas_price: int, pool: str, quantities: list, tick_range: list)

Bases: Event

Event class for UniswapV3 collects.

Parameters:
  • date – date of event (datetime)

  • block – block number of event (int)

  • log_index – log index of event (int)

  • action – action type of event (str)

  • pool – pool address (str)

  • quantities – token quantities of the collect (list)

  • tick_range – tick range of the collect (list)

  • gas – gas used for the event (int)

  • gas_price – gas price used for the event (int)

action: str
block: int
date: datetime
gas: int
gas_price: int
log_index: int
pool: str
quantities: list
tick_range: list
class dojo.dataloaders.formats.UniV3Initialize(date: datetime, block: int, log_index: int, action: str, gas: int, gas_price: int, pool: str, sqrt_priceX96: int, tick: int)

Bases: Event

Event class for UniswapV3 pool initializations.

Parameters:
  • date – date of event (datetime)

  • block – block number of event (int)

  • log_index – log index of event (int)

  • action – action type of event (str)

  • pool – pool address (str)

  • sqrt_priceX96 – initial sqrt_priceX96 set in the pool by event (int)

  • tick – initial tick set in the pool by event (int)

  • gas – gas used for the event (int)

  • gas_price – gas price used for the event (int)

action: str
block: int
date: datetime
gas: int
gas_price: int
log_index: int
pool: str
sqrt_priceX96: int
tick: int
class dojo.dataloaders.formats.UniV3Mint(date: datetime, block: int, log_index: int, action: str, gas: int, gas_price: int, pool: str, quantities: list, tick_range: list, liquidity: int, owner: str)

Bases: Event

Event class for UniswapV3 mints.

Parameters:
  • date – date of event (datetime)

  • block – block number of event (int)

  • log_index – log index of event (int)

  • action – action type of event (str)

  • pool – pool address (str)

  • quantities – token quantities of the mint (list)

  • tick_range – tick range of the mint (list)

  • liquidity – liquidity of the mint (int)

  • owner – owner address of the mint (str)

  • gas – gas used for the event (int)

  • gas_price – gas price used for the event (int)

action: str
block: int
date: datetime
gas: int
gas_price: int
liquidity: int
log_index: int
owner: str
pool: str
quantities: list
tick_range: list
class dojo.dataloaders.formats.UniV3Swap(date: datetime, block: int, log_index: int, action: str, gas: int, gas_price: int, pool: str, quantities: list)

Bases: Event

Event class for UniswapV3 swaps.

Parameters:
  • date – date of event (datetime)

  • block – block number of event (int)

  • log_index – log index of event (int)

  • action – action type of event (str)

  • pool – pool address (str)

  • quantities – token quantities of the swap (list)

  • gas – gas used for the event (int)

  • gas_price – gas price used for the event (int)

action: str
block: int
date: datetime
gas: int
gas_price: int
log_index: int
pool: str
quantities: list

Load protocol events data from AWS S3.

class dojo.dataloaders.univ3_loader.UniV3Loader(env_name: str, date_range: Tuple[datetime, datetime], pools: List[str])

Bases: BaseLoader

Class for loading events data from pickle or JSON files in AWS S3.