dojo.actions package

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

class dojo.actions.BaseAction(*, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: Generic[Observation]

Base action class for all environments.

Parameters:

agent – The agent executing the action.

agent: BaseAgent

Submodules

Actions for AaveV3.

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

Bases: BaseAaveAction

Borrow tokens from AAVEv3 pool.

Parameters:
  • token – Symbol of the token you want to borrow.

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

  • mode – Type of borrow debt - stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

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

Bases: BaseAaveAction

Borrow tokens from AAVEv3 pool to a specific health factor.

Parameters:
  • token – Symbol of the token you want to borrow.

  • factor – Health factor to borrow to.

  • mode – Type of borrow debt - stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

factor: float
mode: Literal['stable', 'variable']
token: str
class dojo.actions.aaveV3.AAVEv3FlashLoan(tokens: list[str], amounts: list[Decimal], modes: list[Literal['none', 'stable', 'variable']], receiver: str, params: bytes, *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAaveAction

Take a flash loan - access the liquidity of multiple reserves.

Parameters:
  • tokens – List of symbols of the token you want to flash borrow.

  • amounts – List of amounts to flash borrow, in human-readable format. (e.g. Decimal(‘1.5’) ETH).

  • modes – List of borrow debt types - none, stable, or variable.

  • receiver – Address of the contract receiving the flash loan.

  • params – Arbitrary bytes-encoded params that will be passed to executeOperation() method of the receiver contract.

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

amounts: list[Decimal]
modes: list[Literal['none', 'stable', 'variable']]
params: bytes
receiver: str
tokens: list[str]
class dojo.actions.aaveV3.AAVEv3FlashLoanSimple(token: str, amount: Decimal, receiver: str, params: bytes, *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAaveAction

Take a simple flash loan - access the liquidity of one reserve.

Parameters:
  • token – Symbol of the token you want to flash borrow.

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

  • receiver – Address of the contract receiving the flash loan.

  • params – Arbitrary bytes-encoded params that will be passed to executeOperation() method of the receiver contract.

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

amount: Decimal
params: bytes
receiver: str
token: str
class dojo.actions.aaveV3.AAVEv3FullLiquidation(collateral: str, debt: str, user: str, receiveAToken: bool = False, *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAaveAction

Liquidate the maximum amount of a user’s collateral.

Parameters:
  • collateral – Symbol of the token used as collateral.

  • debt – Symbol of the token used as debt.

  • user – Address of the borrower.

  • receiveAToken – Whether to receive the liquidated asset as aTokens. Default is False.

collateral: str
debt: str
receiveAToken: bool = False
user: str
class dojo.actions.aaveV3.AAVEv3Liquidation(collateral: str, debt: str, user: str, debtToCover: int, receiveAToken: bool = False, *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAaveAction

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

Parameters:
  • collateral – Symbol of the token used as collateral.

  • debt – Symbol of the token used as debt.

  • user – Address of the borrower.

  • debtToCover – Amount of asset debt that the liquidator will repay in human- readable format.

  • receiveAToken – Whether to receive the liquidated asset as aTokens. Default is False.

collateral: str
debt: str
debtToCover: int
receiveAToken: bool = False
user: str
class dojo.actions.aaveV3.AAVEv3Repay(token: str, amount: Decimal, mode: Literal['stable', 'variable'], *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAaveAction

Repay borrowed tokens.

Parameters:
  • token – Symbol of the token you want to repay.

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

  • mode – Type of borrow debt - stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

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

Bases: BaseAaveAction

Repay all borrowed tokens.

Parameters:
  • token – Symbol of the token you want to repay.

  • mode – Type of borrow debt - stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

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

Bases: BaseAaveAction

Repay tokens to a specific health factor.

Parameters:
  • token – Symbol of the token you want to repay.

  • factor – Health factor to repay to.

  • mode – Type of borrow debt - stable or variable.

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

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

Bases: BaseAaveAction

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

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

  • amount – Amount of tokens being supplied, in human-readable format. (e.g. Decimal(‘1.5’) ETH).

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

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

Bases: BaseAaveAction

Witdraw funds from AAVEv3 pool.

Parameters:
  • token – Symbol of the token you want to withdraw.

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

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

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

Bases: BaseAaveAction

Witdraw all funds from AAVEv3 pool.

Parameters:
  • token – Symbol of the token you want to withdraw.

  • gas – Gas to pay in wei.

  • gas_price – Gas price in wei.

token: str
class dojo.actions.aaveV3.BaseAaveAction(*, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction[AAVEv3Observation]

Base Action for Aave.

Base action classes for all environments.

class dojo.actions.base_action.BaseAction(*, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: Generic[Observation]

Base action class for all environments.

Parameters:

agent – The agent executing the action.

agent: BaseAgent

Actions for UniswapV3.

class dojo.actions.uniswapV3.UniswapV3Action(*, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: BaseAction[UniswapV3Observation]

Base Action for Aave.

class dojo.actions.uniswapV3.UniswapV3BurnNew(position_id: str, *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: UniswapV3Action

Burn a position.

The position needs to be empty, or an error will be thrown

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

Bases: UniswapV3Action

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.

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

Bases: UniswapV3Action

Collect all tokesn from a position.

Parameters:

agent – TODO

pool: str
position_id: str
class dojo.actions.uniswapV3.UniswapV3IncreaseLiquidity(pool: str, position_id: int, liquidity: int, owner: str = '0x0000000000000000000000000000000000000000', *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: UniswapV3Action

Increase Liquidity of an existing position.

Not yet supported.

Parameters:

agent – Amount of token 0.

liquidity: int
owner: str = '0x0000000000000000000000000000000000000000'
pool: str
position_id: int
class dojo.actions.uniswapV3.UniswapV3LiquidatePosition(position_id: int, *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: UniswapV3Action

Liquidating a Position.

This will withdraw all liquidity from the postion, send it to the liquidation agent and destroy the LP token. Not yet supported.

Parameters:

id – ID of the position to liquidate.

position_id: int
class dojo.actions.uniswapV3.UniswapV3ProvideLiquidity(pool: str, tick_range: tuple[int, int], liquidity: int, *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: UniswapV3Action

Quote action for UniswapV3.

Parameters:
  • agent – The agent executing the action.

  • pool – The pool name to trade on.

  • tick_range – The tick range to quote.

  • liquidity – The amount of liquidity that should be provided.

liquidity: int
pool: str
tick_range: tuple[int, int]
class dojo.actions.uniswapV3.UniswapV3ProvideQuantities(pool: str, tick_range: tuple[int, int], amount0: Decimal, amount1: Decimal, owner: str = '0x0000000000000000000000000000000000000000', auto_trade: bool = False, *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: UniswapV3Action

Provide a specific amount of quantities.

Will throw errors if the quantities are incompatible with the tick range.

Parameters:
  • agent – The agent executing the action.

  • pool – The pool name to trade on.

  • tick_range – The tick range to quote.

  • amount0 – Amount of token 0.

  • amount1 – Amount of token 1.

amount0: Decimal
amount1: Decimal
auto_trade: bool = False
owner: str = '0x0000000000000000000000000000000000000000'
pool: str
tick_range: tuple[int, int]
class dojo.actions.uniswapV3.UniswapV3Quote(pool: str, quantities: tuple[Decimal, Decimal], tick_range: tuple[int, int], liquidity: int = -1, owner: str = '0x0000000000000000000000000000000000000000', *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: UniswapV3Action

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.

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

Bases: UniswapV3Action

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
pool: str
quantities: tuple[Decimal, Decimal]
class dojo.actions.uniswapV3.UniswapV3Trade(pool: str, quantities: tuple[Decimal, Decimal], price_limit: Decimal | None = None, *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: UniswapV3Action

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.

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

Bases: UniswapV3Action

Trade tokens for perfect ration to then provide in a tick range.

At the moment, it just trades to 50/50 in value, if the active tick is covered.

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.

pool: str
quantities: tuple[Decimal, Decimal]
tick_range: tuple[int, int]
class dojo.actions.uniswapV3.UniswapV3WithdrawLiquidity(position_id: int, liquidity: int, owner: str = '0x0000000000000000000000000000000000000000', *, agent: BaseAgent, gas: int | None = None, gas_price: int | None = None)

Bases: UniswapV3Action

Withdraw Liquidity from an existing position.

Tokens can then be collected from the position, or re-provided.

Parameters:
  • position_id – ID fo the position to withdraw from.

  • liquidity – Amount of liquidity to withdraw (in wei).

  • owner – The owner of the position to withdraw from.

liquidity: int
owner: str = '0x0000000000000000000000000000000000000000'
position_id: int