agent0.core.hyperdrive

Objects for bots to interface with Hyperdrive contracts and the Rust interface.

Submodules

Classes

HyperdriveActionType

The descriptor of an action in a market.

HyperdriveMarketAction

Market action specification.

HyperdriveWallet

Stateful variable for storing what is in the agent's wallet.

Long

An open long position.

Short

An open short position.

TradeResult

A data object that stores all information of an executed trade.

Package Contents

class agent0.core.hyperdrive.HyperdriveActionType

Bases: enum.Enum

The descriptor of an action in a market.

INITIALIZE_MARKET = 'initialize_market'
OPEN_LONG = 'open_long'
CLOSE_LONG = 'close_long'
OPEN_SHORT = 'open_short'
CLOSE_SHORT = 'close_short'
ADD_LIQUIDITY = 'add_liquidity'
REMOVE_LIQUIDITY = 'remove_liquidity'
REDEEM_WITHDRAW_SHARE = 'redeem_withdraw_share'
class agent0.core.hyperdrive.HyperdriveMarketAction

Bases: agent0.core.base.BaseMarketAction[HyperdriveActionType]

Market action specification.

action_type: HyperdriveActionType
trade_amount: fixedpointmath.FixedPoint
maturity_time: int | None = None
slippage_tolerance: fixedpointmath.FixedPoint | None = None
gas_limit: int | None = None
base_fee_multiple: float | None = None
priority_fee_multiple: float | None = None
min_apr: fixedpointmath.FixedPoint
max_apr: fixedpointmath.FixedPoint
class agent0.core.hyperdrive.HyperdriveWallet

Bases: agent0.core.base.EthWallet

Stateful variable for storing what is in the agent’s wallet.

lp_tokens: fixedpointmath.FixedPoint

The LP tokens held by the trader.

withdraw_shares: fixedpointmath.FixedPoint

The amount of unclaimed withdraw shares held by the agent.

longs: dict[int, Long]

The long positions held by the trader. The dictionary is keyed by the maturity time in seconds.

shorts: dict[int, Short]

The short positions held by the trader. The dictionary is keyed by the maturity time in seconds.

copy() HyperdriveWallet

Return a new copy of self.

Returns:

A deep copy of the wallet.

Return type:

HyperdriveWallet

class agent0.core.hyperdrive.Long

An open long position.

balance: fixedpointmath.FixedPoint

The amount of bonds that the position is long.

maturity_time: int

The maturity time of the long.

class agent0.core.hyperdrive.Short

An open short position.

balance: fixedpointmath.FixedPoint

The amount of bonds that the position is short.

maturity_time: int

The maturity time of the short.

class agent0.core.hyperdrive.TradeResult

A data object that stores all information of an executed trade.

trade_successful: bool

The status of the trade.

account: eth_account.signers.local.LocalAccount | None = None

The agent that was executing the trade.

wallet: agent0.core.hyperdrive.agent.hyperdrive_wallet.HyperdriveWallet | None = None

The wallet of the agent that was executing the trade.

policy: agent0.core.hyperdrive.policies.HyperdriveBasePolicy | None = None

The policy that was executing the trade.

trade_object: agent0.core.base.Trade[agent0.core.hyperdrive.agent.hyperdrive_actions.HyperdriveMarketAction] | None = None

The trade object for the trade.

hyperdrive_event: pypechain.core.BaseEvent | None = None

The transaction receipt of the trade.

contract_call: dict[str, Any] | None = None

A dictionary detailing the underlying contract call.

is_slippage: bool = False

If the trade failed due to slippage.

is_invalid_balance: bool = False

If the trade failed due to invalid balance.

is_insufficient_allowance: bool = False

If the trade failed due to insufficient approval.

is_min_txn_amount: bool = False

If the trade failed due to minimum transaction amount.

is_long_proceeds_less_than_fees: bool = False

If the trade failed due long proceeds less than fees.

block_number: int | None = None

The block number of the transaction.

block_timestamp: int | None = None

The block timestamp of the transaction.

exception: Exception | None = None

The exception that was thrown.

orig_exception: Exception | list[Exception] | BaseException | None = None

If exception was wrapped, the original exception that was thrown.

pool_config: dict[str, Any] | None = None

The pool config information.

pool_info: dict[str, Any] | None = None

The pool info information.

checkpoint_info: dict[str, Any] | None = None

The checkpoint info information.

contract_addresses: dict[str, Any] | None = None

The contract addresses.

additional_info: dict[str, Any] | None = None

Additional information used for crash reporting.

raw_transaction: dict[str, Any] | None = None

The raw transaction sent to the chain.

raw_pool_config: dict[str, Any] | None = None

The raw pool config.

raw_pool_info: dict[str, Any] | None = None

The raw pool info.

raw_checkpoint: dict[str, Any] | None = None

The raw checkpoint info.

anvil_state: str | None = None

The dumped anvil state.