agent0.ethpy.hyperdrive.interface.read_write_interface ====================================================== .. py:module:: agent0.ethpy.hyperdrive.interface.read_write_interface .. autoapi-nested-parse:: High-level interface for writing to Hyperdrive smart contracts. .. !! processed by numpydoc !! Classes ------- .. autoapisummary:: agent0.ethpy.hyperdrive.interface.read_write_interface.HyperdriveReadWriteInterface Module Contents --------------- .. 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 !!