agent0.ethpy.hyperdrive.interface.read_interface ================================================ .. py:module:: agent0.ethpy.hyperdrive.interface.read_interface .. autoapi-nested-parse:: High-level interface for a Hyperdrive pool. .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: agent0.ethpy.hyperdrive.interface.read_interface.AGENT0_SIGNATURE Classes ------- .. autoapisummary:: agent0.ethpy.hyperdrive.interface.read_interface.HyperdriveReadInterface Module Contents --------------- .. py:data:: AGENT0_SIGNATURE .. 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 !!