verbs_examples.agents.borrow_agent.BorrowAgent#
- class BorrowAgent[source]#
Borrower agent who supplies and borrows tokens from an Aave pool
- __init__(env, i: int, pool_implementation_abi: type, oracle_abi: type, mintable_erc20_abi: type, pool_address: bytes, oracle_address: bytes, token_a_address: bytes, token_b_address: bytes, activation_rate: float)[source]#
Initialise the Borrower agent and create the corresponding account in the EVM.
The agent stores the ABIs of the Aave contracts and the token contracts that they will be interacting with. ABIs are loaded using the function
verbs.abi.load_abi()
.- Parameters:
env (
verbs.types.Env
) – Simulation environmenti (
int
) – Agent index in the simulationpool_implementation_abi (
type
) – abi of the Aave v3 pool contractoracle_abi (
type
) – abi of the Aave oracle contract for collateral and debt tokensmintable_erc20_abi (
type
) – abi of ERC20 contractpool_address (
bytes
) – Addres of Aave v3 pool contractoracle_address (
bytes
) – Address of Aave oracle contract for collateral and debt tokenstoken_a_address (
bytes
) – Address of collateral token (usually the risky token)token_b_address (
bytes
) – Address of debt token (usually the less risky token)activation_rate (
float
) – Probability of taking an action (either provide collateral or borrow) at each step
- record(env) Tuple[int, float, float, float] [source]#
Record the state of the agent
This method is called at the end of each step for all agents. It should return any data to be recorded over the course of the simulation.
- Parameters:
env (
verbs.types.Env
) – Network/EVM that the simulation interacts with.- Returns:
tuple[int
,float
,float
,float]
– Tuple containing:Step of the simulation.
Health factor of the borrower’s position at the current step.
Collateral value of the borrower’s position in the base currency In Aave the base currency is USD and it has 8 decimal places
Debt asset value of the borrower’s position in the base currency
- update(rng: Generator, env) List[Tuple[bytes, bytes, bytes, bool, int | None, int | None, int | None]] [source]#
Update the state of the agent and returns list of transactions according to their policy.
Borrower agent can either supply collateral to the Aave pool or borrow debt assets.
- Parameters:
rng (
numpy.random.Generator
) – Numpy random generator, used for any random sampling to ensure determinism of the simulation.env (
verbs.types.Env
) – Network/EVM that the simulation interacts with.
- Returns:
list
– List of transactions to be processed in the next block of the simulation. This can be an empty list if the agent is not submitting any transactions.