dojo.actions package

This module contains all actions that can be executed by environments.

class dojo.actions.BaseAction(agent: BaseAgent)

Bases: object

Base action class for all environments.

Parameters:

agent – The agent executing the action.

agent: BaseAgent
encode(obs: BaseObs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

Raises:

NotImplementedError – Must be implemented by subclass.

Submodules

Actions for UniswapV3.

class dojo.actions.aaveV3.AAVEv3Borrow(agent: BaseAgent, token_name: str, amount: Decimal, mode: Literal['stable', 'variable'], gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Borrow tokens from AAVEv3 pool.

Parameters:
  • token_name – Name of the token you want to supply.

  • amount – Amount to borrow, in human-readable format. (e.g. Decimal(‘1.5’) ETH).

  • mode – Borrowing mode. Can be stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – gas price in wei.

amount: Decimal
encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

gas: int | None = None
gas_price: int | None = None
mode: Literal['stable', 'variable']
token_name: str
class dojo.actions.aaveV3.AAVEv3BorrowToHealthFactor(agent: BaseAgent, token_name: str, factor: float, mode: Literal['stable', 'variable'], gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Borrow tokens from AAVEv3 pool to a specific health factor.

Parameters:
  • token_name – Name of the token you want to supply.

  • factor – Health factor to borrow to.

  • mode – Borrowing mode. Can be stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – gas price in wei.

encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

factor: float
gas: int | None = None
gas_price: int | None = None
mode: Literal['stable', 'variable']
token_name: str
class dojo.actions.aaveV3.AAVEv3FlashLoanSimple(agent: BaseAgent, token_name: str, amount: Decimal, reciever_address: str, params: bytes, referral_code: int | None = 0, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Take a flash loan.

Parameters:
  • token_name – Name of the token you want to supply.

  • amount – Amount to borrow, in human-readable format. (e.g. Decimal(‘1.5’) ETH).

  • reciever_address – Address of the contract recieving the flash loan.

  • params – bytes array being passed to the reciever contracts executeOperation() function.

  • gas – Gas to pay in wei.

  • gas_price – gas price in wei.

amount: Decimal
encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

gas: int | None = None
gas_price: int | None = None
params: bytes
reciever_address: str
referral_code: int | None = 0
token_name: str
class dojo.actions.aaveV3.AAVEv3FullLiquidation(agent: BaseAgent, collateral: str, debt: str, user: str)

Bases: BaseAction

Liquidate a users collateral.

If their health factor has dropped below 1.0, this action will liquidate the maximum amount possible. :param collateral: address of the collateral reserve. :param debt: address of the debt reserve. :param user: address of the borrower.

collateral: str
debt: str
encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

gas: int | None = None
gas_price: int | None = None
user: str
class dojo.actions.aaveV3.AAVEv3Liquidation(agent: BaseAgent, token_name: str, factor: float, mode: Literal['stable', 'variable'], gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Liquidate a users collateral, if their health factor has dropped below 1.0.

Parameters:
  • collateral – address of the collateral reserve.

  • debt – address of the debt reserve.

  • user – address of the borrower.

  • deptToCover – amount of asset debt that the liquidator will repay.

encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

factor: float
gas: int | None = None
gas_price: int | None = None
mode: Literal['stable', 'variable']
token_name: str
class dojo.actions.aaveV3.AAVEv3Repay(agent: BaseAgent, token_name: str, amount: Decimal, mode: Literal['stable', 'variable'], gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Repay borrowed tokens.

Parameters:
  • token_name – Name of the token you want to supply.

  • amount – Amount to borrow, in human-readable format. (e.g. Decimal(‘1.5’) ETH).

  • mode – Borrowing mode. Can be stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – gas price in wei.

amount: Decimal
encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

gas: int | None = None
gas_price: int | None = None
mode: Literal['stable', 'variable']
token_name: str
class dojo.actions.aaveV3.AAVEv3RepayAll(agent: BaseAgent, token_name: str, mode: Literal['stable', 'variable'], gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Repay all borrowed tokens.

Parameters:
  • token_name – Name of the token you want to supply.

  • mode – Borrowing mode. Can be stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – gas price in wei.

encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

gas: int | None = None
gas_price: int | None = None
mode: Literal['stable', 'variable']
token_name: str
class dojo.actions.aaveV3.AAVEv3RepayToHealthFactor(agent: BaseAgent, token_name: str, factor: float, mode: Literal['stable', 'variable'], gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Repay tokens to a specific health factor.

Parameters:
  • token_name – Name of the token you want to supply.

  • factor – Health factor to repay to.

  • mode – Borrowing mode. Can be stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – gas price in wei.

encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

factor: float
gas: int | None = None
gas_price: int | None = None
mode: Literal['stable', 'variable']
token_name: str
class dojo.actions.aaveV3.AAVEv3Supply(agent: BaseAgent, token_name: str, amount: Decimal, gas: int | None = None)

Bases: BaseAction

Supply funds to AAVEv3 Pool. You can earn interest for supplying funds.

Parameters:
  • token_name – Name of the token you want to supply.

  • amount – Amount to borrow, in human-readable format. (e.g. Decimal(‘1.5’) ETH).

  • gas – Gas to pay in wei.

  • gas_price – gas price in wei.

amount: Decimal
encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

gas: int | None = None
gas_price: int | None = None
token_name: str
class dojo.actions.aaveV3.AAVEv3Withdraw(agent: BaseAgent, token_name: str, amount: Decimal, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Witdraw funds from AAVEv3Pool.

Parameters:
  • token_name – Name of the token you want to supply.

  • amount – Amount to borrow, in human-readable format. (e.g. Decimal(‘1.5’) ETH).

  • gas – Gas to pay in wei.

  • gas_price – gas price in wei.

  • gas_price – Maximum fee to pay per gas in wei.

amount: Decimal
encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

gas: int | None = None
gas_price: int | None = None
token_name: str
class dojo.actions.aaveV3.AAVEv3WithdrawAll(agent: BaseAgent, token_name: str, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Witdraw funds from AAVEv3Pool.

Parameters:
  • token_name – Name of the token you want to supply.

  • gas – Gas to pay in wei.

  • gas_price – gas price in wei.

encode(obs: AAVEv3Obs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

gas: int | None = None
gas_price: int | None = None
token_name: str

Base action classes for all environments.

class dojo.actions.base_action.BaseAction(agent: BaseAgent)

Bases: object

Base action class for all environments.

Parameters:

agent – The agent executing the action.

agent: BaseAgent
encode(obs: BaseObs) Dict[str, Any]

Encode the action in a purely numerical dictionary format.

Parameters:

obs – The observation from the environment.

Raises:

NotImplementedError – Must be implemented by subclass.

Actions for UniswapV3.

class dojo.actions.uniswapV3.UniV3Collect(agent: BaseAgent, pool: str, quantities: Tuple[Decimal, Decimal], tick_range: Tuple[int, int], gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Collect action for UniswapV3.

Parameters:
  • agent – The agent executing the action.

  • pool – The pool name to trade on.

  • quantities – The quantities to trade.

  • tick_range – The tick range to quote.

  • gas – The gas for the transaction.

  • gas_price – The gas price for the transaction.

agent: BaseAgent
gas: int | None = None
gas_price: int | None = None
pool: str
quantities: Tuple[Decimal, Decimal]
tick_range: Tuple[int, int]
class dojo.actions.uniswapV3.UniV3Quote(agent: BaseAgent, pool: str, quantities: Tuple[Decimal, Decimal], tick_range: Tuple[int, int], gas: int | None = None, gas_price: int | None = None, liquidity: int = -1, owner: str = '0x0000000000000000000000000000000000000000')

Bases: BaseAction

Quote action for UniswapV3.

Parameters:
  • agent – The agent executing the action.

  • pool – The pool name to trade on.

  • quantities – The quantities to trade.

  • tick_range – The tick range to quote.

  • gas – The gas for the transaction.

  • gas_price – The gas price for the transaction.

  • liquidity – Optional liquidity to use for the quote, needed for MarketAgent burns.

  • owner – Optional owner to use for the quote, needed for MarketAgent burns.

agent: BaseAgent
gas: int | None = None
gas_price: int | None = None
liquidity: int = -1
owner: str = '0x0000000000000000000000000000000000000000'
pool: str
quantities: Tuple[Decimal, Decimal]
tick_range: Tuple[int, int]
class dojo.actions.uniswapV3.UniV3SetFeeProtocol(agent: BaseAgent, pool: str, quantities: Tuple[Decimal, Decimal], gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

SetFeeProtocol action for UniswapV3.

Parameters:
  • agent – The agent executing the action.

  • pool – The pool name to trade on.

  • quantities – The quantities to trade.

  • gas – The gas for the transaction.

  • gas_price – The gas price for the transaction.

agent: BaseAgent
gas: int | None = None
gas_price: int | None = None
pool: str
quantities: Tuple[Decimal, Decimal]
class dojo.actions.uniswapV3.UniV3Trade(agent: BaseAgent, pool: str, quantities: Tuple[Decimal, Decimal], gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction

Trade action for UniswapV3.

Parameters:
  • agent – The agent executing the action.

  • pool – The pool name to trade on.

  • quantities – The quantities to trade.

  • price_limit – The price limit for the trade (slippage).

  • gas – The gas for the transaction.

  • gas_price – The gas price for the transaction.

agent: BaseAgent
gas: int | None = None
gas_price: int | None = None
pool: str
price_limit: Decimal | None = None
quantities: Tuple[Decimal, Decimal]