agent0.core.hyperdrive.interactive.hyperdrive

Defines the interactive hyperdrive class that encapsulates a hyperdrive pool.

Classes

Hyperdrive

Interactive Hyperdrive class that supports connecting to an existing hyperdrive deployment.

Module Contents

class agent0.core.hyperdrive.interactive.hyperdrive.Hyperdrive(chain: agent0.core.hyperdrive.interactive.chain.Chain, hyperdrive_address: eth_typing.ChecksumAddress, config: Config | None = None, name: str | None = None)

Interactive Hyperdrive class that supports connecting to an existing hyperdrive deployment.

class Config

The configuration for the interactive hyperdrive class.

classmethod get_hyperdrive_addresses_from_registry(chain: agent0.core.hyperdrive.interactive.chain.Chain, registry_address: str) dict[str, eth_typing.ChecksumAddress]

Gather deployed Hyperdrive pool addresses.

Parameters:
  • chain (Chain) – The Chain object connected to a chain.

  • registry_address (str) – The address of the Hyperdrive factory contract.

Returns:

A dictionary keyed by the pool’s name, valued by the pool’s address

Return type:

dict[str, ChecksumAddress]

classmethod get_hyperdrive_pools_from_registry(chain: agent0.core.hyperdrive.interactive.chain.Chain, registry_address: str) Sequence[Hyperdrive]

Gather deployed Hyperdrive pool addresses.

Parameters:
  • chain (Chain) – The Chain object connected to a chain.

  • registry_address (str) – The address of the Hyperdrive registry contract.

Returns:

The hyperdrive objects for all registered pools

Return type:

Sequence[Hyperdrive]

abstract get_positions(show_closed_positions: bool = False, calc_pnl: bool = False, coerce_float: bool = False) pandas.DataFrame

Gets all current positions of this pool and their corresponding pnl and returns as a pandas dataframe.

This function is not implemented for remote hyperdrive, as gathering this data is expensive. In the future, we can explicitly make this call gather data from the remote chain.

Parameters:
  • coerce_float (bool) – If True, will coerce underlying Decimals to floats.

  • calc_pnl (bool, optional) – If the chain config’s calc_pnl flag is False, passing in calc_pnl=True to this function allows for a one-off pnl calculation for the current positions. Ignored if the chain’s calc_pnl flag is set to True, as every position snapshot will return pnl information.

  • show_closed_positions (bool) – Whether to show positions closed positions (i.e., positions with zero balance). Defaults to False. When False, will only return currently open positions. Useful for gathering currently open positions. When True, will also return any closed positions. Useful for calculating overall pnl of all positions.

Returns:

A dataframe consisting of currently open positions and their corresponding pnl.

Return type:

pd.Dataframe

get_trade_events(all_token_deltas: bool = False, coerce_float: bool = False) pandas.DataFrame

Gets the ticker history of all trades and the corresponding token deltas for each trade.

Parameters:
  • all_token_deltas (bool) – When removing liquidity that results in withdrawal shares, the events table returns two entries for this transaction to keep track of token deltas (one for lp tokens and one for withdrawal shares). If this flag is true, will return all entries in the table, which is useful for calculating token positions. If false, will drop the duplicate withdrawal share entry (useful for returning a ticker).

  • coerce_float (bool) – If True, will coerce underlying Decimals to floats.

Returns:

A dataframe of trade events.

Return type:

pd.Dataframe

abstract get_historical_positions(coerce_float: bool = False) pandas.DataFrame

Gets the history of all positions over time and their corresponding pnl and returns as a pandas dataframe.

This function is not implemented for remote hyperdrive, as gathering this data is expensive. In the future, we can explicitly make this call gather data from the remote chain.

Parameters:

coerce_float (bool) – If True, will coerce underlying Decimals to floats.

Returns:

A dataframe consisting of positions over time and their corresponding pnl.

Return type:

pd.Dataframe

abstract get_historical_pnl(coerce_float: bool = False) pandas.DataFrame

Gets total pnl for each wallet for each block, aggregated across all open positions.

This function is not implemented for remote hyperdrive, as gathering this data is expensive. In the future, we can explicitly make this call gather data from the remote chain.

Parameters:

coerce_float (bool) – If True, will coerce underlying Decimals to floats.

Returns:

A dataframe of aggregated wallet pnl per block

Return type:

pd.Dataframe

property hyperdrive_address: eth_typing.ChecksumAddress

Returns the hyperdrive addresses for this pool.

Returns:

The hyperdrive addresses for this pool

Return type:

ChecksumAddress