dojo.dataloaders package

Dataloaders load protocol events data for dojo environments.

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() List[Event]

Load events for an environment in a date range.

Raises:

ValueError – If the environment is not supported.

class dojo.dataloaders.S3Loader(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.

Submodules

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() List[Event]

Load events for an environment in a date range.

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)

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)

action: str
block: int
date: datetime
log_index: int
class dojo.dataloaders.formats.UniV3Burn(date: datetime, block: int, log_index: int, action: str, 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)

action: str
block: int
date: datetime
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, 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)

action: str
block: int
date: datetime
log_index: int
pool: str
quantities: list
tick_range: list
class dojo.dataloaders.formats.UniV3Initialize(date: datetime, block: int, log_index: int, action: str, 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)

action: str
block: int
date: datetime
log_index: int
pool: str
sqrt_priceX96: int
tick: int
class dojo.dataloaders.formats.UniV3Mint(date: datetime, block: int, log_index: int, action: str, 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)

action: str
block: int
date: datetime
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, 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)

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

Load protocol events data from AWS S3.

class dojo.dataloaders.s3_loader.S3Loader(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.