dojo.agents
This module contains the agents that can be used in the Dojo environment.
The BaseAgent class is the base class for AAVEv3 agents.
Agents in UniswapV3 environments can inherit from BaseAgent instead. This is a placeholder for future helper functions to go into.
The BaseAgent class is the base class for all agents.
The agents can be viewed as part of the environment in that they are only responsible for handling their own state given new data, and do not make any decisions on how to act in the environment. They are effectively a data wrapper around the on-chain brownie accounts. You should override the reward() method to define the reward generating function for your agent.
Initialize the agent.
Parameters
- initial_portfolio: initial asset portfolio to load at reset. e.g.
{"ETH": Decimal(10), "USDC": Decimal(1000)}
- name: optional name for the agent, if not set will use the class name.
Cache token price data.
Need to keep track of which NFTs the agent has.
Get the agent quantity of a token.
:token: The token symbol or address.
Get the agent wealth of ERC20 tokens in $.
Transfer quantity
ERC20 tokens from the source
address to the agent.
Transfer token_id
NFT from the source
address to the agent.
Setup the agent on-chain account and initialize the token portfolio.
Raises
- NotImplementedError: if backend type is not recognized.
Approve a grantee to spend ERC20 tokens on the agent's behalf.
Parameters
- grantee: the grantee contract name.
- token: the token symbol.
Get the agent reward.
Parameters
- obs: The observation from the environment.
There are many inbuilt methods and data structures that can be used to calculate
the reward:
- self.wealth()
: agent wealth.
- self.portfolio()
: agent portfolio.
- self.erc20_portfolio()
: agent ERC20 portfolio.
- self.erc721_portfolio()
: agent ERC721 portfolio.
- self.erc20_wealth()
: agent ERC20 wealth.
This agent executes the actions given by the market impact model.
A placeholder agent that does nothing.
The BaseAgent class is the base class for UniswapV3 agents.
Agents in UniswapV3 environments can inherit from BaseAgent instead, but will be missing certain helper methods.