dojo.environments
Environments package contains environment classes and logic.
The UniswapV3Env environment models the UniswapV3 system dynamics.
It is responsible for updating both the protocol and agent states through time.
Instantiate a UniswapV3Env object.
Parameters
- chain: blockchain to use in the environment
- agents: list of agents to use in the environment.
- block_range: block range of the environment simulation.
- pools: list of pool names to use in the environment.
- market_impact: market impact model to use, one of: ['replay', 'no_market']. Defaults to 'replay'.
- backend_type: type of backend to use, one of: ['forked', 'local', 'live']. Defaults to 'forked'.
- 'forked': forks a live network to initialize the environment state at the given date range. This mode requires more communication with an archive node and is more unpredictable when funding agents with tokens, but it is faster to intialize state, especially at later start dates.
- 'local': deploys contracts locally to initialize the environment state at the given date range. This mode requires less communication with an archive node and is guaranteed stable when funding agents with tokens, but it can be slower to initialize state, especially at later start dates.
- dataloader: optional dataloader instance to use for loading events data. You'll need to provide this if you want to run a simulation with pools that are not listed in the docs https://compasslabs.github.io/docs/tutorial/environments/UniswapV3#supported-pools.
- port: port to connect to the local chain. Defaults to find a free port.
token_data: optional dict containing token price data to pass to each agent, needed if you want to call the agent
wealth
methods. The dictionary has format:{ "token_symbol": { datetime0: price0, datetime1: price1, ... }, ... }
Raises
- ValueError: if the market impact param is not one given by the
UniswapV3MarketModelType
enum. - ValueError: if the list of pools is empty.
- Exception: if the simulation is being run without a license and not on a free example see (example_backtest.py)
The AAVEv3Env environment models the AAVEv3Env system dynamics.
It is responsible for updating both the protocol and agent states through time.
Instantiate a AAVEv3Env object.
Parameters
- chain: chain to use for the environment.
- agents: list of agents to use in the environment.
- block_range: block range of the environment simulation.
- backend_type: type of backend to use, one of: ['forked', 'local', 'live']. Defaults to 'forked'.
- 'forked': forks a live network to initialize the environment state at the given date range. This mode requires more communication with an archive node and is more unpredictable when funding agents with tokens, but it is faster to intialize state, especially at later start dates.
- 'local': deploys contracts locally to initialize the environment state at the given date range. This mode requires less communication with an archive node and is guaranteed stable when funding agents with tokens, but it can be slower to initialize state, especially at later start dates.
- port: port to connect to the local chain. Defaults to find a free port.
token_data: optional dict containing token price data to pass to each agent, needed if you want to call the agent
wealth
methods. The dictionary has format:{ "token_symbol": { datetime0: price0, datetime1: price1, ... }, ... }
Raises
- ValueError: If backend_type is unsupported.
- ValueError: If the market impact model is unsupported.
The GmxV2Env models the gmx v2 system dynamics.
Instantiate a GmxV2Env object.
Parameters
- chain: blockchain to use in the environment
- agents: list of agents to use in the environment.
- block_range: block range of the environment simulation.
- market_venues: list of market venues to trade on.
- market_impact: market impact model to use, one of: ['replay', 'no_market']. Defaults to 'replay'.
- backend_type: type of backend to use, one of: ['forked', 'local', 'live']. Defaults to 'forked'.
- 'forked': forks a live network to initialize the environment state at the given date range. This mode requires more communication with an archive node and is more unpredictable when funding agents with tokens, but it is faster to intialize state, especially at later start dates.
- 'local': deploys contracts locally to initialize the environment state at the given date range. This mode requires less communication with an archive node and is guaranteed stable when funding agents with tokens, but it can be slower to initialize state, especially at later start dates.
- port: port to connect to the local chain. Defaults to find a free port.
- token_data: optional dict containing token price data to pass to each agent.
- execution_delay: delay in blocks to wait before executing actions. Defaults to 10.