agent0.ethpy.hyperdrive ======================= .. py:module:: agent0.ethpy.hyperdrive .. autoapi-nested-parse:: Interfaces for bots and hyperdrive smart contracts. .. !! processed by numpydoc !! Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/agent0/ethpy/hyperdrive/addresses/index /autoapi/agent0/ethpy/hyperdrive/assets/index /autoapi/agent0/ethpy/hyperdrive/deploy/index /autoapi/agent0/ethpy/hyperdrive/get_expected_hyperdrive_version/index /autoapi/agent0/ethpy/hyperdrive/interface/index /autoapi/agent0/ethpy/hyperdrive/state/index /autoapi/agent0/ethpy/hyperdrive/transactions/index Attributes ---------- .. autoapisummary:: agent0.ethpy.hyperdrive.BASE_TOKEN_SYMBOL Classes ------- .. autoapisummary:: agent0.ethpy.hyperdrive.AssetIdPrefix agent0.ethpy.hyperdrive.DeployedHyperdriveFactory agent0.ethpy.hyperdrive.DeployedHyperdrivePool agent0.ethpy.hyperdrive.HyperdriveDeployType agent0.ethpy.hyperdrive.HyperdriveReadInterface agent0.ethpy.hyperdrive.HyperdriveReadWriteInterface Functions --------- .. autoapisummary:: agent0.ethpy.hyperdrive.get_hyperdrive_addresses_from_registry agent0.ethpy.hyperdrive.get_hyperdrive_name agent0.ethpy.hyperdrive.get_hyperdrive_registry_from_artifacts agent0.ethpy.hyperdrive.decode_asset_id agent0.ethpy.hyperdrive.encode_asset_id agent0.ethpy.hyperdrive.deploy_base_and_vault agent0.ethpy.hyperdrive.deploy_hyperdrive_factory agent0.ethpy.hyperdrive.deploy_hyperdrive_from_factory agent0.ethpy.hyperdrive.check_hyperdrive_version agent0.ethpy.hyperdrive.get_minimum_hyperdrive_version agent0.ethpy.hyperdrive.get_hyperdrive_checkpoint agent0.ethpy.hyperdrive.get_hyperdrive_checkpoint_exposure agent0.ethpy.hyperdrive.get_hyperdrive_pool_config agent0.ethpy.hyperdrive.get_hyperdrive_pool_info Package Contents ---------------- .. py:function:: get_hyperdrive_addresses_from_registry(hyperdrive_registry_addr: str, web3: web3.Web3) -> dict[str, eth_typing.ChecksumAddress] Fetch addresses for deployed contracts in the Hyperdrive system. :param hyperdrive_registry_addr: The address of the Hyperdrive registry contract. :type hyperdrive_registry_addr: str :param web3: The instantiated Web3 instance that's connect to a chain to use. :type web3: Web3 :returns: A dictionary keyed by the pool name (e.g., `StETHHyperdrive_14day`) with a value of the address of the deployed hyperdrive pool. :rtype: dict[str, ChecksumAddress] .. !! processed by numpydoc !! .. py:function:: get_hyperdrive_name(hyperdrive_address: eth_typing.ChecksumAddress, web3: web3.Web3) -> str Generates a name for a given hyperdrive address. The address generated is of the form __day. :param hyperdrive_address: The address of a hyperdrive pool. :type hyperdrive_address: ChecksumAddress :param web3: The instantiated Web3 instance that's connect to a chain to use. :type web3: Web3 :returns: The generated name of the hyperdrive pool. :rtype: str .. !! processed by numpydoc !! .. py:function:: get_hyperdrive_registry_from_artifacts(artifacts_uri: str) -> str Fetch addresses for deployed contracts in the Hyperdrive system. :param artifacts_uri: The URI for the artifacts endpoint. :type artifacts_uri: str :returns: A dictionary that mirrors the artifacts json structure. :rtype: dict[str, ChecksumAddress] .. !! processed by numpydoc !! .. py:data:: BASE_TOKEN_SYMBOL :value: 'WETH' .. py:class:: AssetIdPrefix Bases: :py:obj:`enum.IntEnum` The asset ID is used to encode the trade type in a transaction receipt .. !! processed by numpydoc !! .. py:attribute:: LP :value: 0 .. py:attribute:: LONG :value: 1 .. py:attribute:: SHORT :value: 2 .. py:attribute:: WITHDRAWAL_SHARE :value: 3 .. py:function:: decode_asset_id(asset_id: int) -> tuple[int, int] Decodes a transaction asset ID into its constituent parts of an identifier, data, and a timestamp. First calculate the prefix mask by left-shifting 1 by 248 bits and subtracting 1 from the result. This gives us a bit-mask with 248 bits set to 1 and the rest set to 0. Then apply this mask to the input ID using the bitwise-and operator `&` to extract the lower 248 bits as the timestamp. :param asset_id: Encoded ID from a transaction. It is a concatenation, [identifier: 8 bits][timestamp: 248 bits] :type asset_id: int :returns: identifier, timestamp :rtype: tuple[int, int] .. !! processed by numpydoc !! .. py:function:: encode_asset_id(prefix: int, timestamp: int) -> int Encodes a prefix and a timestamp into an asset ID. Asset IDs are used so that LP, long, and short tokens can all be represented in a single MultiToken instance. The zero asset ID indicates the LP token. Encode the asset ID by left-shifting the prefix by 248 bits, then bitwise-or-ing the result with the timestamp. :param prefix: A one byte prefix that specifies the asset type. :type prefix: int :param timestamp: A timestamp associated with the asset. :type timestamp: int :returns: The asset ID. :rtype: int .. !! processed by numpydoc !! .. py:class:: DeployedHyperdriveFactory Bases: :py:obj:`NamedTuple` Collection of attributes associated with a locally deployed Hyperdrive factory. .. !! processed by numpydoc !! .. py:attribute:: deployer_account :type: eth_account.signers.local.LocalAccount .. py:attribute:: factory_contract :type: hyperdrivetypes.types.HyperdriveFactoryContract .. py:attribute:: deployer_coordinator_contract :type: hyperdrivetypes.types.ERC4626HyperdriveDeployerCoordinatorContract | hyperdrivetypes.types.StETHHyperdriveDeployerCoordinatorContract .. py:attribute:: factory_deploy_config :type: hyperdrivetypes.types.HyperdriveFactory.FactoryConfig .. py:class:: DeployedHyperdrivePool Bases: :py:obj:`NamedTuple` Collection of attributes associated with a locally deployed chain with a Hyperdrive pool. .. !! processed by numpydoc !! .. py:attribute:: deployer_account :type: eth_account.signers.local.LocalAccount .. py:attribute:: hyperdrive_contract :type: hyperdrivetypes.types.IHyperdriveContract .. py:attribute:: base_token_contract :type: hyperdrivetypes.types.ERC20MintableContract | web3.contract.contract.Contract .. py:attribute:: vault_shares_token_contract :type: hyperdrivetypes.types.MockERC4626Contract | hyperdrivetypes.types.MockLidoContract .. py:attribute:: deploy_block_number :type: int .. py:attribute:: pool_deploy_config :type: hyperdrivetypes.types.IHyperdrive.PoolDeployConfig .. py:class:: HyperdriveDeployType Bases: :py:obj:`enum.Enum` The deploy type for the hyperdrive pool. .. !! processed by numpydoc !! .. py:attribute:: ERC4626 :value: 0 .. py:attribute:: STETH :value: 1 .. py:function:: deploy_base_and_vault(web3: web3.Web3, deploy_type: HyperdriveDeployType, deploy_account: eth_account.signers.local.LocalAccount, initial_variable_rate: fixedpointmath.FixedPoint) -> DeployedBaseAndVault Deploys the underlying base and vault contracts :param web3: Web3 provider object. :type web3: Web3 :param deploy_type: The deploy type for the hyperdrive pool. :type deploy_type: HyperdriveDeployType :param deploy_account: The account that's deploying the contract. :type deploy_account: LocalAccount :param initial_variable_rate: The starting variable rate for an underlying vault. :type initial_variable_rate: FixedPoint :returns: Containing the deployed base and vault contracts. :rtype: DeployedBaseAndVault .. !! processed by numpydoc !! .. py:function:: deploy_hyperdrive_factory(web3: web3.Web3, deployer_account: eth_account.signers.local.LocalAccount, deployed_base_and_vault: DeployedBaseAndVault, deploy_type: HyperdriveDeployType, factory_deploy_config: hyperdrivetypes.types.HyperdriveFactory.FactoryConfig) -> DeployedHyperdriveFactory Deploys the hyperdrive factory and supporting contracts on the rpc_uri chain. :param web3: Web3 provider object. :type web3: Web3 :param deployer_account: The account that's deploying the contract. :type deployer_account: LocalAccount :param deployed_base_and_vault: The base and vault contracts that were deployed on the local chain. :type deployed_base_and_vault: DeployedBaseAndVault :param deploy_type: The deploy type for the hyperdrive pool. :type deploy_type: HyperdriveDeployType :param factory_deploy_config: The factory configuration for initializing the hyperdrive factory. The type is generated from the Hyperdrive ABI using Pypechain. :type factory_deploy_config: FactoryConfig :returns: Containing the deployed factory, the deploy coordinator contracts, the updated factory config, and the hyperdrive registry contract. :rtype: DeployedHyperdriveFactory .. !! processed by numpydoc !! .. py:function:: deploy_hyperdrive_from_factory(web3: web3.Web3, deployer_account: eth_account.signers.local.LocalAccount, deployed_base_and_vault: DeployedBaseAndVault, deployed_factory: DeployedHyperdriveFactory, deploy_type: HyperdriveDeployType, initial_liquidity: fixedpointmath.FixedPoint, initial_fixed_apr: fixedpointmath.FixedPoint, initial_time_stretch_apr: fixedpointmath.FixedPoint, pool_deploy_config: hyperdrivetypes.types.IHyperdrive.PoolDeployConfig) -> DeployedHyperdrivePool Initializes a Hyperdrive pool and supporting contracts on an existing chain. :param web3: Web3 provider object. :type web3: Web3 :param deployer_account: The local account deploying Hyperdrive. :type deployer_account: LocalAccount :param deployed_base_and_vault: The base and vault contracts that were deployed on the local chain. :type deployed_base_and_vault: DeployedBaseAndVault :param deployed_factory: The factory and supporting contracts that were deployed on the local chain. :type deployed_factory: DeployedHyperdriveFactory :param deploy_type: The deploy type for the hyperdrive pool. :type deploy_type: HyperdriveDeployType :param initial_liquidity: The amount of money to be provided by the `deployer_account` for initial pool liquidity. :type initial_liquidity: FixedPoint :param initial_fixed_apr: The fixed rate of the pool on initialization. :type initial_fixed_apr: FixedPoint :param initial_time_stretch_apr: The apr to target for the time stretch calculation. :type initial_time_stretch_apr: FixedPoint :param pool_deploy_config: The configuration for initializing hyperdrive pool. The type is generated from the Hyperdrive ABI using Pypechain. :type pool_deploy_config: PoolDeployConfig :returns: A named tuple with the following fields: deploy_account: LocalAccount The local account that deploys and initializes hyperdrive. hyperdrive_contract: IHyperdriveContract Web3 contract instance for the hyperdrive contract. base_token_contract: Contract Web3 contract instance for the base token contract. vault_shares_token_contract: Contract Web3 contract instance for the vault shares token contract. deploy_block_number: int The block number hyperdrive was deployed at. :rtype: DeployedHyperdrivePool .. !! processed by numpydoc !! .. py:function:: check_hyperdrive_version(in_version: str) -> bool Checks that the version meets the minimum hyperdrive version. :param in_version: The version string to check. :type in_version: str :returns: True if the version meets the minimum hyperdrive version. :rtype: bool .. !! processed by numpydoc !! .. py:function:: get_minimum_hyperdrive_version() -> str Get the minimum hyperdrive version from the `min-hyperdrive.version` file. :returns: The minimum hyperdrive version. :rtype: str .. !! processed by numpydoc !! .. py:class:: HyperdriveReadInterface(hyperdrive_address: eth_typing.ChecksumAddress, rpc_uri: str | None = None, web3: web3.Web3 | None = None, txn_receipt_timeout: float | None = None, txn_signature: bytes | None = None) Read-only end-point API for interfacing with a deployed Hyperdrive pool. .. !! processed by numpydoc !! .. py:class:: HyperdriveKind Bases: :py:obj:`enum.Enum` Hyperdrive contract kind. NOTE the values of these enums match the output of the `kind()` function from the hyperdrive contract. .. !! processed by numpydoc !! .. py:attribute:: ERC4626 :value: 'ERC4626Hyperdrive' .. py:attribute:: STETH :value: 'StETHHyperdrive' .. py:attribute:: MORPHO :value: 'MorphoBlueHyperdrive' .. py:attribute:: EZETH :value: 'EzETHHyperdrive' .. py:attribute:: RETH :value: 'RETHHyperdrive' .. py:attribute:: STKWELL :value: 'StkWellHyperdrive' .. py:attribute:: EETH :value: 'EETHHyperdrive' .. py:attribute:: hyperdrive_address .. py:attribute:: web3 :value: None .. py:attribute:: hyperdrive_contract .. py:attribute:: hyperdrive_version .. py:attribute:: pool_config .. py:attribute:: hyperdrive_name .. py:attribute:: morpho_contract :value: None .. py:attribute:: morpho_market_id :value: None .. py:attribute:: base_token_contract :type: hyperdrivetypes.types.ERC20MintableContract .. py:attribute:: txn_receipt_timeout :value: None .. py:attribute:: last_state_block_number :value: -1 .. py:method:: get_deploy_block_number() -> eth_typing.BlockNumber | None Get the block number that the Hyperdrive contract was deployed on. NOTE: The deploy event may get lost on e.g., anvil, so we ensure we only check once :returns: The block number that the Hyperdrive contract was deployed on. Returns None if it can't be found. :rtype: BlockNumber | None .. !! processed by numpydoc !! .. py:property:: current_pool_state :type: agent0.ethpy.hyperdrive.state.PoolState The current state of the pool. Each time this is accessed we use an RPC to check that the pool state is synced with the current block. .. !! processed by numpydoc !! .. py:method:: get_current_block() -> web3.types.BlockData Use an RPC to get the current block. :returns: A web3py dataclass containing information about the latest mined block. :rtype: BlockData .. !! processed by numpydoc !! .. py:method:: get_block(block_identifier: web3.types.BlockIdentifier) -> web3.types.BlockData Use an RPC to get the block for the provided identifier. Delegates to eth_getBlockByNumber if block_identifier is an integer or one of the predefined block parameters 'latest', 'earliest', 'pending', 'safe', 'finalized'. Otherwise delegates to eth_getBlockByHash. Throws BlockNotFound error if the block is not found. :param block_identifier: Any one of the web3py types: [BlockParams, BlockNumber, Hash32, HexStr, HexBytes, int]. :type block_identifier: BlockIdentifier :returns: A web3py dataclass containing block information. :rtype: BlockData .. !! processed by numpydoc !! .. py:method:: get_block_number(block: web3.types.BlockData) -> eth_typing.BlockNumber Use an RPC to get the number for the provided block. :param block: A web3py dataclass for storing block information. :type block: BlockData :returns: The number for the corresponding block. :rtype: BlockNumber .. !! processed by numpydoc !! .. py:method:: get_block_timestamp(block: web3.types.BlockData) -> web3.types.Timestamp Use an RPC to get the time for the provided block. :param block: A web3py dataclass for storing block information. :type block: BlockData :returns: The integer timestamp, in seconds, for the corresponding block. :rtype: Timestamp .. !! processed by numpydoc !! .. py:method:: get_hyperdrive_state(block_identifier: web3.types.BlockIdentifier | None = None, block_data: web3.types.BlockData | None = None) -> agent0.ethpy.hyperdrive.state.PoolState Use RPCs and contract calls to get the Hyperdrive pool and block state, given a block identifier. :param block_identifier: The block identifier to get hyperdrive state on. :type block_identifier: BlockIdentifier, optional :param block_data: The block data to use to get hyperdrive state. This parameter is useful for reusing a previously retrieved block data. Can't provide both block_identifier and block_data at the same time. :type block_data: BlockData, optional :returns: A dataclass containing PoolInfo, PoolConfig, Checkpoint, and Block information that is synced to a given block number. :rtype: PoolState .. !! processed by numpydoc !! .. py:method:: get_checkpoint(checkpoint_time: web3.types.Timestamp, block_identifier: web3.types.BlockIdentifier | None = None) -> hyperdrivetypes.CheckpointFP Use an RPC to get the checkpoint info for the Hyperdrive contract for a given checkpoint_time index. :param checkpoint_time: The block timestamp that indexes the checkpoint to get. :type checkpoint_time: Timestamp :param block_identifier: The identifier for a block. If not given, the latest block is used. :type block_identifier: BlockIdentifier, optional :returns: The dataclass containing the checkpoint info in fixed point :rtype: CheckpointFP .. !! processed by numpydoc !! .. py:method:: get_minimum_transaction_amount_shares(block_identifier: web3.types.BlockIdentifier | None = None) -> fixedpointmath.FixedPoint Use an RPC to get the minimum transaction amount in units of shares at the given block. :param block_identifier: The identifier for a block. If not given, the latest block number is used. :type block_identifier: BlockIdentifier, optional :returns: The quantity of withdrawal shares available in the Hyperdrive pool. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_total_supply_withdrawal_shares(block_identifier: web3.types.BlockIdentifier | None = None) -> fixedpointmath.FixedPoint Use an RPC to get the total supply of withdrawal shares in the pool at the given block. :param block_identifier: The identifier for a block. If not given, the latest block number is used. :type block_identifier: BlockIdentifier, optional :returns: The quantity of withdrawal shares available in the Hyperdrive pool. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_vault_shares(block_identifier: web3.types.BlockIdentifier | None = None) -> fixedpointmath.FixedPoint Use an RPC to get the balance of shares that the Hyperdrive pool has in the underlying yield source. :param block_identifier: The identifier for a block. Defaults to the current block number. :type block_identifier: BlockNumber, optional :returns: The quantity of vault shares for the yield source at the provided block. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_idle_shares(pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Get the balance of idle shares that the Hyperdrive pool has. :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The quantity of vault shares for the yield source at the provided block. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_variable_rate(block_identifier: web3.types.BlockIdentifier | None = None) -> fixedpointmath.FixedPoint | None Use an RPC to get the yield source variable rate. .. note:: This function assumes there exists an underlying `getRate` function in the contract. This call will return None if the deployed yield contract doesn't have a `getRate` function. In this case, use `get_standardized_variable_rate` instead. :param block_identifier: The identifier for a block. Defaults to the current block number. :type block_identifier: BlockIdentifier, optional :returns: The variable rate for the yield source at the provided block, or None if the yield source doesn't have a `getRate` function. :rtype: FixedPoint | None .. !! processed by numpydoc !! .. py:method:: get_standardized_variable_rate(time_range: int = 604800) -> fixedpointmath.FixedPoint Get a standardized variable rate using vault share prices from checkpoints in the last `time_range` seconds. .. note:: This function will throw an error if the pool was deployed within the last `time_range` seconds. :param time_range: The time range (in seconds) to use to calculate the variable rate to look for checkpoints. :type time_range: int :returns: The standardized variable rate. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_eth_base_balances(agent: eth_account.signers.local.LocalAccount) -> tuple[fixedpointmath.FixedPoint, fixedpointmath.FixedPoint] Use an RPC to get the agent's balance on the Base & Hyperdrive contracts. :param agent: The account for the agent that is executing and signing the trade transaction. :type agent: LocalAccount :returns: A tuple containing the [agent_eth_balance, agent_base_balance]. :rtype: tuple[FixedPoint] .. !! processed by numpydoc !! .. py:method:: get_hyperdrive_eth_balance() -> fixedpointmath.FixedPoint Get the current Hyperdrive eth balance from an RPC. :returns: The eth on the chain. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_hyperdrive_base_balance(block_identifier: web3.types.BlockIdentifier | None = None) -> fixedpointmath.FixedPoint Get the current Hyperdrive balance in the base contract. :param block_identifier: The identifier for a block. Defaults to the current block number. :type block_identifier: BlockIdentifier, optional :returns: The result of base_token_contract.balanceOf(hyperdrive_address). :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_gov_fees_accrued(block_identifier: web3.types.BlockIdentifier | None = None) -> fixedpointmath.FixedPoint Get the current amount of Uncollected Governance Fees in the Hyperdrive contract. :param block_identifier: The identifier for a block. Defaults to the current block number. :type block_identifier: BlockIdentifier, optional :returns: The result of hyperdrive_contract.functions.getUncollectedGovernanceFees :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_long_total_supply(maturity_time: int, block_identifier: web3.types.BlockIdentifier | None = None) -> fixedpointmath.FixedPoint Get the total supply of long tokens with the given maturity time. :param maturity_time: The maturity time in seconds. :type maturity_time: int :param block_identifier: The identifier for a block. Defaults to the current block number. :type block_identifier: BlockIdentifier, optional :returns: The result of the total supply of long tokens with the given maturity time. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_short_total_supply(maturity_time: int, block_identifier: web3.types.BlockIdentifier | None = None) -> fixedpointmath.FixedPoint Get the total supply of short tokens with the given maturity time. :param maturity_time: The maturity time in seconds. :type maturity_time: int :param block_identifier: The identifier for a block. Defaults to the current block number. :type block_identifier: BlockIdentifier, optional :returns: The result of the total supply of short tokens with the given maturity time. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: get_pool_is_paused() -> bool Get whether or not the pool is paused from events. :returns: Whether or not the pool is paused. :rtype: bool .. !! processed by numpydoc !! .. py:method:: calc_position_duration_in_years(pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Return the pool config position duration as a fraction of a year. This "annualized" time value is used in some calculations, such as the Fixed APR. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The annualized position duration :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_time_stretch(target_rate: fixedpointmath.FixedPoint, target_position_duration: fixedpointmath.FixedPoint) -> fixedpointmath.FixedPoint Return the time stretch parameter given a target fixed rate and position duration. :param target_rate: The fixed rate that the Hyperdrive pool will be initialized with. :type target_rate: FixedPoint :param target_position_duration: The position duration that the Hyperdrive pool will be initialized with. :type target_position_duration: FixedPoint :returns: The time stretch constant. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_checkpoint_timestamp(time: int | web3.types.Timestamp, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> web3.types.Timestamp Converts a timestamp to the checkpoint timestamp that it corresponds to. :param time: Any timestamp (in seconds) before or at the present. :type time: int | Timestamp :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The checkpoint timestamp. :rtype: Timestamp .. !! processed by numpydoc !! .. py:method:: calc_checkpoint_id(checkpoint_duration: int | None = None, block_timestamp: web3.types.Timestamp | None = None) -> web3.types.Timestamp Calculate the Checkpoint ID for a given timestamp. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param checkpoint_duration: The time, in seconds, between checkpoints. Defaults to the current pool's checkpoint duration. :type checkpoint_duration: int, optional :param block_timestamp: A timestamp for any block. Use the latest block to get the current checkpoint id, or a specific timestamp of a transaction's block if getting the checkpoint id for that transaction. Defaults to the current block timestamp. :type block_timestamp: Timestamp, optional :returns: The checkpoint id, in units of seconds, which represents the time of the last checkpoint. :rtype: int .. !! processed by numpydoc !! .. py:method:: calc_spot_rate(pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the spot fixed rate for a given pool state. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. The simulation follows the formula: .. math:: r = ((1 / p) - 1) / t = (1 - p) / (p * t) :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The fixed rate apr for the Hyperdrive pool state. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_rate_given_fixed_price(price: fixedpointmath.FixedPoint, position_duration: fixedpointmath.FixedPoint) -> fixedpointmath.FixedPoint Calculate the rate assuming a given price is constant for some annualized duration. We calculate the rate for a fixed length of time as: ..math:: r = (1 - p) / (p t) where $p$ is the price and $t$ is the length of time that this price is assumed to be constant, in units of years. For example, if the price is constant for 6 months, then $t=0.5$. In our case, $t = \text{position_duration} / (60*60*24*365)$. :param price: The spot price of bonds fora given pool. :type price: FixedPoint :param position_duration: The pool bond position duration, over which the price is assumed to be constant. :type position_duration: FixedPoint :returns: The fixed rate apr for a given fixed price and position duration. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_spot_price(pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the spot price for a given Hyperdrive pool. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The spot price for the Hyperdrive pool state. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_max_spot_price(pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Get the pool's max spot price. :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The pool's maximum achievable spot price. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_effective_share_reserves(pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the adjusted share reserves for a given Hyperdrive pool. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The effective (aka zeta-adjusted) share reserves. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_idle_share_reserves_in_base(pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculates the idle share reserves in base of the pool. :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The pool's idle share reserves in base. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_bonds_given_shares_and_rate(target_rate: fixedpointmath.FixedPoint, target_shares: fixedpointmath.FixedPoint | None = None, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Return the bond reserves for the market share reserves and a given fixed rate. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. The calculation is based on the formula: .. math:: \mu * (z - \zeta) * (1 + \text{apr} * t)^{1 / \tau} .. todo:: This function name matches the Rust implementation, but is not preferred because "given_shares_and_rate" is in the wrong order (should be rate_and_shares) according to arguments and really "given_*" could be removed because it can be inferred from arguments. Need to fix it from the bottom up. :param target_rate: The target apr for which to calculate the bond reserves given the pools current share reserves. :type target_rate: FixedPoint :param target_shares: The target share reserves for the pool :type target_shares: FixedPoint, optional :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The output bonds. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_open_long(base_amount: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the long amount that will be opened for a given base amount after fees. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param base_amount: The amount to spend, in base. :type base_amount: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of bonds purchased. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_pool_deltas_after_open_long(base_amount: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> tuple[fixedpointmath.FixedPoint, fixedpointmath.FixedPoint] Calculate the bond deltas to be applied to the pool after opening a long. :param base_amount: The amount of base used to open a long. :type base_amount: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of (shares, bonds) to remove from the pool reserves. :rtype: tuple[FixedPoint, FixedPoint] .. !! processed by numpydoc !! .. py:method:: calc_spot_price_after_long(base_amount: fixedpointmath.FixedPoint, bond_amount: fixedpointmath.FixedPoint | None = None, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the spot price for a given Hyperdrive pool after a long is opened for `base_amount`. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param base_amount: The amount of base provided for the long. :type base_amount: FixedPoint :param bond_amount: The amount of bonds that would be purchased by the long. The default is to use whatever is returned by `calc_open_long(base_amount)`. :type bond_amount: FixedPoint | None, optional :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The spot price for the Hyperdrive pool state. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_spot_rate_after_long(base_amount: fixedpointmath.FixedPoint, bond_amount: fixedpointmath.FixedPoint | None = None, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the spot rate for a given Hyperdrive pool after a long is opened for `base_amount`. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param base_amount: The amount of base provided for the long. :type base_amount: FixedPoint :param bond_amount: The amount of bonds that would be purchased by the long. The default is to use whatever is returned by `calc_open_long(base_amount)`. :type bond_amount: FixedPoint | None, optional :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The spot rate for the Hyperdrive pool state. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_max_long(budget: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the maximum allowable long for the given Hyperdrive pool and agent budget. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param budget: How much money the agent is able to spend, in base. :type budget: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The maximum long, in units of base. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_close_long(bond_amount: fixedpointmath.FixedPoint, maturity_time: int, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the amount of shares that will be returned after fees for closing a long. :param bond_amount: The amount of bonds to sell. :type bond_amount: FixedPoint :param maturity_time: The maturity time of the bond. :type maturity_time: int :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of shares returned. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_market_value_long(bond_amount: fixedpointmath.FixedPoint, maturity_time: int, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the amount of shares that will be returned after fees for closing a long. :param bond_amount: The amount of bonds to sell. :type bond_amount: FixedPoint :param maturity_time: The maturity time of the bond. :type maturity_time: int :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: An estimate of the amount of shares returned upon closing the long. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_targeted_long(budget: fixedpointmath.FixedPoint, target_rate: fixedpointmath.FixedPoint, max_iterations: int | None = None, allowable_error: fixedpointmath.FixedPoint | None = None, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the amount of bonds that can be purchased for the given budget. :param budget: The account budget in base for making a long. :type budget: FixedPont :param target_rate: The target fixed rate. :type target_rate: FixedPoint :param max_iterations: The number of iterations to use for the Newtonian method. Defaults to 7. :type max_iterations: int | None, optional :param allowable_error: The amount of error supported for reaching the target rate. Defaults to 1e-4. :type allowable_error: FixedPoint | None, optional :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of shares returned. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_open_short(bond_amount: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the amount of base the trader will need to deposit for a short of a given size, after fees. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param bond_amount: The amount to of bonds to short. :type bond_amount: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of base required to short the bonds (aka the "max loss"). :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_pool_share_delta_after_open_short(bond_amount: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the amount of shares the pool will add after opening a short. :param bond_amount: The amount to of bonds to short. :type bond_amount: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of shares to add to the pool reserves. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_spot_price_after_short(bond_amount: fixedpointmath.FixedPoint, base_amount: fixedpointmath.FixedPoint | None = None, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the spot price for a given Hyperdrive pool after a short is opened for `base_amount`. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param bond_amount: The amount that woud be used to open a short. :type bond_amount: FixedPoint :param base_amount: The amount of base provided for the short. The default is to use whatever is returned by `calc_open_short(bond_amount)`. :type base_amount: FixedPoint | None, optional :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The spot price for the Hyperdrive pool state. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_max_short(budget: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the maximum allowable short for the given Hyperdrive pool and agent budget. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param budget: How much money the agent is able to spend, in base. :type budget: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The maximum short, in units of bonds. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_close_short(bond_amount: fixedpointmath.FixedPoint, open_vault_share_price: fixedpointmath.FixedPoint, close_vault_share_price: fixedpointmath.FixedPoint, maturity_time: int, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Get the amount of shares the trader will receive from closing a short. :param bond_amount: The amount to of bonds provided. :type bond_amount: FixedPoint :param open_vault_share_price: The checkpoint share price when the short was opened. :type open_vault_share_price: FixedPoint :param close_vault_share_price: The share price when the short was closed. If the short isn't mature, this is the current share price. If the short is mature, this is the share price of the maturity checkpoint. :type close_vault_share_price: FixedPoint :param maturity_time: The maturity time of the short. :type maturity_time: int :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of shares the trader will receive for closing the short. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_market_value_short(bond_amount: fixedpointmath.FixedPoint, open_vault_share_price: fixedpointmath.FixedPoint, close_vault_share_price: fixedpointmath.FixedPoint, maturity_time: int, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Estimates the current market value of an open short position. :param bond_amount: The amount to of bonds provided. :type bond_amount: FixedPoint :param open_vault_share_price: The checkpoint share price when the short was opened. :type open_vault_share_price: FixedPoint :param close_vault_share_price: The share price when the short was closed. If the short isn't mature, this is the current share price. If the short is mature, this is the share price of the maturity checkpoint. :type close_vault_share_price: FixedPoint :param maturity_time: The maturity time of the short. :type maturity_time: int :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: An estimate of the amount of shares returned upon closing the short. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_present_value(pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the present value of LPs capital in the pool. :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The present value of all LP capital in the pool. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_solvency(pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the pool's solvency. :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: solvency = share_reserves - long_exposure / vault_share_price - minimum_share_reserves :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_bonds_out_given_shares_in_down(amount_in: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the amount of bonds a user will receive from the pool by providing a specified amount of shares. We underestimate the amount of bonds. The amount returned is before fees are applied. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param amount_in: The amount of shares going into the pool. :type amount_in: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of bonds out. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_shares_in_given_bonds_out_up(amount_in: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the amount of shares a user must provide the pool to receive a specified amount of bonds. We overestimate the amount of shares in. The amount returned is before fees are applied. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param amount_in: The amount of bonds to target. :type amount_in: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of shares in to reach the target. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_shares_in_given_bonds_out_down(amount_in: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the amount of shares a user must provide the pool to receive a specified amount of bonds. We underestimate the amount of shares in. The amount returned is before fees are applied. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param amount_in: The amount of bonds to target. :type amount_in: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not provided, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of shares in to reach the target. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:method:: calc_shares_out_given_bonds_in_down(amount_in: fixedpointmath.FixedPoint, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) -> fixedpointmath.FixedPoint Calculate the amount of shares a user will receive from the pool by providing a specified amount of bonds. We underestimate the amount of shares out. The amount returned is before fees are applied. The function does not perform contract calls, but instead relies on the Hyperdrive-rust api to simulate the contract outputs. :param amount_in: The amount of bonds in. :type amount_in: FixedPoint :param pool_state: The state of the pool, which includes block details, pool config, and pool info. If not provided, use the current pool state. :type pool_state: PoolState | None, optional :returns: The amount of shares out. :rtype: FixedPoint .. !! processed by numpydoc !! .. py:class:: HyperdriveReadWriteInterface(hyperdrive_address: eth_typing.ChecksumAddress, rpc_uri: str | None = None, web3: web3.Web3 | None = None, txn_receipt_timeout: float | None = None, txn_signature: bytes | None = None) Bases: :py:obj:`agent0.ethpy.hyperdrive.interface.read_interface.HyperdriveReadInterface` Read-write end-point API for interfacing with a deployed Hyperdrive pool. .. !! processed by numpydoc !! .. py:method:: get_read_interface() -> agent0.ethpy.hyperdrive.interface.read_interface.HyperdriveReadInterface Return the current instance as an instance of the parent (HyperdriveReadInterface) class. :returns: This instantiated object, but as a ReadInterface. :rtype: HyperdriveReadInterface .. !! processed by numpydoc !! .. py:method:: create_checkpoint(sender: eth_account.signers.local.LocalAccount, checkpoint_time: int | None = None, preview: bool = False, gas_limit: int | None = None, nonce_func: Callable[[], web3.types.Nonce] | None = None) -> hyperdrivetypes.CreateCheckpointEventFP Create a Hyperdrive checkpoint. :param sender: The sender account that is executing and signing the trade transaction. :type sender: LocalAccount :param checkpoint_time: The checkpoint time to use. Defaults to the corresponding checkpoint for the provided block_number :type checkpoint_time: int, optional :param preview: Whether to preview the transaction first for error catching. :type preview: bool, optional :param gas_limit: The maximum amount of gas used by the transaction. :type gas_limit: int | None, optional :param nonce_func: A callable function to use to get a nonce. This function is useful for e.g., passing in a safe nonce getter tied to an agent. :type nonce_func: Callable[[], Nonce] | None :returns: A dataclass containing the output event of the contract call. :rtype: CreateCheckpoint .. !! processed by numpydoc !! .. py:method:: set_variable_rate(sender: eth_account.signers.local.LocalAccount, new_rate: fixedpointmath.FixedPoint) -> None Set the variable rate for the yield source. .. note:: This function assumes there's an underlying `setRate` function in the contract. This call will fail if the deployed yield contract doesn't have a `setRate` function. :param sender: The sender account that is executing and signing the trade transaction. :type sender: LocalAccount :param new_rate: The new variable rate for the yield source. :type new_rate: FixedPoint .. !! processed by numpydoc !! .. py:method:: async_open_long(sender: eth_account.signers.local.LocalAccount, trade_amount: fixedpointmath.FixedPoint, slippage_tolerance: fixedpointmath.FixedPoint | None = None, gas_limit: int | None = None, txn_options_base_fee_multiple: float | None = None, txn_options_priority_fee_multiple: float | None = None, nonce_func: Callable[[], web3.types.Nonce] | None = None, preview_before_trade: bool = False) -> hyperdrivetypes.OpenLongEventFP :async: Contract call to open a long position. :param sender: The account that is executing and signing the trade transaction. :type sender: LocalAccount :param trade_amount: The size of the position, in base. :type trade_amount: FixedPoint :param slippage_tolerance: Amount of slippage allowed from the trade. If given, then the trade will not execute unless the slippage is below this value. If not given, then execute the trade regardless of the slippage. :type slippage_tolerance: FixedPoint, optional :param gas_limit: The maximum amount of gas used by the transaction. Defaults to `eth_estimateGas` RPC output. :type gas_limit: int | None, optional :param txn_options_base_fee_multiple: The multiple applied to the base fee for the transaction. Defaults to 1. :type txn_options_base_fee_multiple: float | None, optional :param txn_options_priority_fee_multiple: The multiple applied to the priority fee for the transaction. Defaults to 1. :type txn_options_priority_fee_multiple: float | None, optional :param nonce_func: A callable function to use to get a nonce. This function is useful for e.g., passing in a safe nonce getter tied to an agent. Defaults to setting it to the result of `get_transaction_count`. :type nonce_func: Callable[[], Nonce] | None :param preview_before_trade: Whether to preview the trade before executing. Defaults to False. :type preview_before_trade: bool, optional :returns: A dataclass containing the output event of the contract call. :rtype: OpenLong .. !! processed by numpydoc !! .. py:method:: async_close_long(sender: eth_account.signers.local.LocalAccount, trade_amount: fixedpointmath.FixedPoint, maturity_time: int, slippage_tolerance: fixedpointmath.FixedPoint | None = None, gas_limit: int | None = None, txn_options_base_fee_multiple: float | None = None, txn_options_priority_fee_multiple: float | None = None, nonce_func: Callable[[], web3.types.Nonce] | None = None, preview_before_trade: bool = False) -> hyperdrivetypes.CloseLongEventFP :async: Contract call to close a long position. :param sender: The account that is executing and signing the trade transaction. :type sender: LocalAccount :param trade_amount: The amount of bonds you wish to close. :type trade_amount: FixedPoint :param maturity_time: The token maturity time in seconds. :type maturity_time: int :param slippage_tolerance: Amount of slippage allowed from the trade. If given, then the trade will not execute unless the slippage is below this value. If not given, then execute the trade regardless of the slippage. :type slippage_tolerance: FixedPoint, optional :param gas_limit: The maximum amount of gas used by the transaction. Defaults to `eth_estimateGas` RPC output. :type gas_limit: int | None, optional :param txn_options_base_fee_multiple: The multiple applied to the base fee for the transaction. Defaults to 1. :type txn_options_base_fee_multiple: float | None, optional :param txn_options_priority_fee_multiple: The multiple applied to the priority fee for the transaction. Defaults to 1. :type txn_options_priority_fee_multiple: float | None, optional :param nonce_func: A callable function to use to get a nonce. This function is useful for e.g., passing in a safe nonce getter tied to an agent. Defaults to setting it to the result of `get_transaction_count`. :type nonce_func: Callable[[], Nonce] | None :param preview_before_trade: Whether to preview the trade before executing. Defaults to False. :type preview_before_trade: bool, optional :returns: A dataclass containing the output event of the contract call. :rtype: CloseLong .. !! processed by numpydoc !! .. py:method:: async_open_short(sender: eth_account.signers.local.LocalAccount, trade_amount: fixedpointmath.FixedPoint, slippage_tolerance: fixedpointmath.FixedPoint | None = None, gas_limit: int | None = None, txn_options_base_fee_multiple: float | None = None, txn_options_priority_fee_multiple: float | None = None, nonce_func: Callable[[], web3.types.Nonce] | None = None, preview_before_trade: bool = False) -> hyperdrivetypes.OpenShortEventFP :async: Contract call to open a short position. :param sender: The account that is executing and signing the trade transaction. :type sender: LocalAccount :param trade_amount: The size of the position, in base. :type trade_amount: FixedPoint :param slippage_tolerance: Amount of slippage allowed from the trade. If given, then the trade will not execute unless the slippage is below this value. If not given, then execute the trade regardless of the slippage. :type slippage_tolerance: FixedPoint, optional :param gas_limit: The maximum amount of gas used by the transaction. Defaults to `eth_estimateGas` RPC output. :type gas_limit: int | None, optional :param txn_options_base_fee_multiple: The multiple applied to the base fee for the transaction. Defaults to 1. :type txn_options_base_fee_multiple: float | None, optional :param txn_options_priority_fee_multiple: The multiple applied to the priority fee for the transaction. Defaults to 1. :type txn_options_priority_fee_multiple: float | None, optional :param nonce_func: A callable function to use to get a nonce. This function is useful for e.g., passing in a safe nonce getter tied to an agent. Defaults to setting it to the result of `get_transaction_count`. :type nonce_func: Callable[[], Nonce] | None :param preview_before_trade: Whether to preview the trade before executing. Defaults to False. :type preview_before_trade: bool, optional :returns: A dataclass containing the output event of the contract call. :rtype: OpenShort .. !! processed by numpydoc !! .. py:method:: async_close_short(sender: eth_account.signers.local.LocalAccount, trade_amount: fixedpointmath.FixedPoint, maturity_time: int, slippage_tolerance: fixedpointmath.FixedPoint | None = None, gas_limit: int | None = None, txn_options_base_fee_multiple: float | None = None, txn_options_priority_fee_multiple: float | None = None, nonce_func: Callable[[], web3.types.Nonce] | None = None, preview_before_trade: bool = False) -> hyperdrivetypes.CloseShortEventFP :async: Contract call to close a short position. :param sender: The account that is executing and signing the trade transaction. :type sender: LocalAccount :param trade_amount: The size of the position, in base. :type trade_amount: FixedPoint :param maturity_time: The token maturity time in seconds. :type maturity_time: int :param slippage_tolerance: Amount of slippage allowed from the trade. If given, then the trade will not execute unless the slippage is below this value. If not given, then execute the trade regardless of the slippage. :type slippage_tolerance: FixedPoint, optional :param gas_limit: The maximum amount of gas used by the transaction. Defaults to `eth_estimateGas` RPC output. :type gas_limit: int | None, optional :param txn_options_base_fee_multiple: The multiple applied to the base fee for the transaction. Defaults to 1. :type txn_options_base_fee_multiple: float | None, optional :param txn_options_priority_fee_multiple: The multiple applied to the priority fee for the transaction. Defaults to 1. :type txn_options_priority_fee_multiple: float | None, optional :param nonce_func: A callable function to use to get a nonce. This function is useful for e.g., passing in a safe nonce getter tied to an agent. Defaults to setting it to the result of `get_transaction_count`. :type nonce_func: Callable[[], Nonce] | None :param preview_before_trade: Whether to preview the trade before executing. Defaults to False. :type preview_before_trade: bool, optional :returns: A dataclass containing the output event of the contract call. :rtype: CloseShort .. !! processed by numpydoc !! .. py:method:: async_add_liquidity(sender: eth_account.signers.local.LocalAccount, trade_amount: fixedpointmath.FixedPoint, min_apr: fixedpointmath.FixedPoint, max_apr: fixedpointmath.FixedPoint, slippage_tolerance: fixedpointmath.FixedPoint | None = None, gas_limit: int | None = None, txn_options_base_fee_multiple: float | None = None, txn_options_priority_fee_multiple: float | None = None, nonce_func: Callable[[], web3.types.Nonce] | None = None, preview_before_trade: bool = False) -> hyperdrivetypes.AddLiquidityEventFP :async: Contract call to add liquidity to the Hyperdrive pool. :param sender: The account that is executing and signing the trade transaction. :type sender: LocalAccount :param trade_amount: The size of the position, in base. :type trade_amount: FixedPoint :param min_apr: The minimum allowable APR after liquidity is added. :type min_apr: FixedPoint :param max_apr: The maximum allowable APR after liquidity is added. :type max_apr: FixedPoint :param slippage_tolerance: Amount of slippage allowed from the trade. If given, then the trade will not execute unless the slippage is below this value. If not given, then execute the trade regardless of the slippage. :type slippage_tolerance: FixedPoint, optional :param gas_limit: The maximum amount of gas used by the transaction. Defaults to `eth_estimateGas` RPC output. :type gas_limit: int | None, optional :param txn_options_base_fee_multiple: The multiple applied to the base fee for the transaction. Defaults to 1. :type txn_options_base_fee_multiple: float | None, optional :param txn_options_priority_fee_multiple: The multiple applied to the priority fee for the transaction. Defaults to 1. :type txn_options_priority_fee_multiple: float | None, optional :param nonce_func: A callable function to use to get a nonce. This function is useful for e.g., passing in a safe nonce getter tied to an agent. Defaults to setting it to the result of `get_transaction_count`. :type nonce_func: Callable[[], Nonce] | None :param preview_before_trade: Whether to preview the trade before executing. Defaults to False. :type preview_before_trade: bool, optional :returns: A dataclass containing the output event of the contract call. :rtype: AddLiquidity .. !! processed by numpydoc !! .. py:method:: async_remove_liquidity(sender: eth_account.signers.local.LocalAccount, trade_amount: fixedpointmath.FixedPoint, gas_limit: int | None = None, txn_options_base_fee_multiple: float | None = None, txn_options_priority_fee_multiple: float | None = None, nonce_func: Callable[[], web3.types.Nonce] | None = None, preview_before_trade: bool = False) -> hyperdrivetypes.RemoveLiquidityEventFP :async: Contract call to remove liquidity from the Hyperdrive pool. :param sender: The account that is executing and signing the trade transaction. :type sender: LocalAccount :param trade_amount: The size of the position, in base. :type trade_amount: FixedPoint :param gas_limit: The maximum amount of gas used by the transaction. Defaults to `eth_estimateGas` RPC output. :type gas_limit: int | None, optional :param txn_options_base_fee_multiple: The multiple applied to the base fee for the transaction. Defaults to 1. :type txn_options_base_fee_multiple: float | None, optional :param txn_options_priority_fee_multiple: The multiple applied to the priority fee for the transaction. Defaults to 1. :type txn_options_priority_fee_multiple: float | None, optional :param nonce_func: A callable function to use to get a nonce. This function is useful for e.g., passing in a safe nonce getter tied to an agent. Defaults to setting it to the result of `get_transaction_count`. :type nonce_func: Callable[[], Nonce] | None :param preview_before_trade: Whether to preview the trade before executing. Defaults to False. :type preview_before_trade: bool, optional :returns: A dataclass containing the output event of the contract call. :rtype: RemoveLiquidity .. !! processed by numpydoc !! .. py:method:: async_redeem_withdraw_shares(sender: eth_account.signers.local.LocalAccount, trade_amount: fixedpointmath.FixedPoint, gas_limit: int | None = None, txn_options_base_fee_multiple: float | None = None, txn_options_priority_fee_multiple: float | None = None, nonce_func: Callable[[], web3.types.Nonce] | None = None, preview_before_trade: bool = False) -> hyperdrivetypes.RedeemWithdrawalSharesEventFP :async: Contract call to redeem withdraw shares from Hyperdrive pool. This should be done after closing liquidity. .. note:: This is not guaranteed to redeem all shares. The pool will try to redeem as many as possible, up to the withdrawPool.readyToRedeem limit, without reverting. This will revert if the min_output is too high or the user is trying to withdraw more shares than they have. :param sender: The account that is executing and signing the trade transaction. :type sender: LocalAccount :param trade_amount: The size of the position, in base. :type trade_amount: FixedPoint :param gas_limit: The maximum amount of gas used by the transaction. Defaults to `eth_estimateGas` RPC output. :type gas_limit: int | None, optional :param txn_options_base_fee_multiple: The multiple applied to the base fee for the transaction. Defaults to 1. :type txn_options_base_fee_multiple: float | None, optional :param txn_options_priority_fee_multiple: The multiple applied to the priority fee for the transaction. Defaults to 1. :type txn_options_priority_fee_multiple: float | None, optional :param nonce_func: A callable function to use to get a nonce. This function is useful for e.g., passing in a safe nonce getter tied to an agent. Defaults to setting it to the result of `get_transaction_count`. :type nonce_func: Callable[[], Nonce] | None :param preview_before_trade: Whether to preview the trade before executing. Defaults to False. :type preview_before_trade: bool, optional :returns: A dataclass containing the output event of the contract call. :rtype: RedeemWithdrawalShares .. !! processed by numpydoc !! .. py:function:: get_hyperdrive_checkpoint(hyperdrive_contract: hyperdrivetypes.types.IHyperdriveContract, checkpoint_time: web3.types.Timestamp, block_identifier: web3.types.BlockIdentifier) -> hyperdrivetypes.fixedpoint_types.CheckpointFP Get the checkpoint info for the Hyperdrive contract at a given block. :param hyperdrive_contract: The contract to query the pool info from. :type hyperdrive_contract: IHyperdriveContract :param checkpoint_time: The block timestamp that indexes the checkpoint to get. :type checkpoint_time: Timestamp :param block_identifier: The block number to query from the chain. :type block_identifier: BlockIdentifier :returns: The dataclass containing the checkpoint info in fixed point :rtype: CheckpointFP .. !! processed by numpydoc !! .. py:function:: get_hyperdrive_checkpoint_exposure(hyperdrive_contract: hyperdrivetypes.types.IHyperdriveContract, checkpoint_time: web3.types.Timestamp, block_identifier: web3.types.BlockIdentifier) -> fixedpointmath.FixedPoint Get the checkpoint exposure for the Hyperdrive contract at a given block. :param hyperdrive_contract: The contract to query the pool info from. :type hyperdrive_contract: IHyperdriveContract :param checkpoint_time: The block timestamp that indexes the checkpoint to get. This must be an exact checkpoint time for the deployed pool. :type checkpoint_time: Timestamp :param block_identifier: The block number to query from the chain. :type block_identifier: BlockIdentifier :returns: The dataclass containing the checkpoint info in fixed point. :rtype: CheckpointFP .. !! processed by numpydoc !! .. py:function:: get_hyperdrive_pool_config(hyperdrive_contract: hyperdrivetypes.types.IHyperdriveContract) -> hyperdrivetypes.fixedpoint_types.PoolConfigFP Get the hyperdrive config from a deployed hyperdrive contract. :param hyperdrive_contract: The deployed hyperdrive contract instance. :type hyperdrive_contract: Contract :returns: The hyperdrive pool config. :rtype: dict[str, Any] .. !! processed by numpydoc !! .. py:function:: get_hyperdrive_pool_info(hyperdrive_contract: hyperdrivetypes.types.IHyperdriveContract, block_identifier: web3.types.BlockIdentifier) -> hyperdrivetypes.fixedpoint_types.PoolInfoFP Get the block pool info from the Hyperdrive contract. :param hyperdrive_contract: The contract to query the pool info from. :type hyperdrive_contract: Contract :param block_identifier: The block identifier to query from the chain. :type block_identifier: BlockIdentifier :returns: A dictionary containing the Hyperdrive pool info returned from the smart contract. :rtype: dict[str, Any] .. !! processed by numpydoc !!