agent0.core.hyperdrive.agent ============================ .. py:module:: agent0.core.hyperdrive.agent .. autoapi-nested-parse:: Account and wallet with Hyperdrive specific parts .. !! processed by numpydoc !! Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/agent0/core/hyperdrive/agent/hyperdrive_actions/index /autoapi/agent0/core/hyperdrive/agent/hyperdrive_wallet/index /autoapi/agent0/core/hyperdrive/agent/trade_result/index Classes ------- .. autoapisummary:: agent0.core.hyperdrive.agent.HyperdriveActionType agent0.core.hyperdrive.agent.HyperdriveMarketAction agent0.core.hyperdrive.agent.HyperdriveWallet agent0.core.hyperdrive.agent.Long agent0.core.hyperdrive.agent.Short agent0.core.hyperdrive.agent.TradeResult Functions --------- .. autoapisummary:: agent0.core.hyperdrive.agent.add_liquidity_trade agent0.core.hyperdrive.agent.close_long_trade agent0.core.hyperdrive.agent.close_short_trade agent0.core.hyperdrive.agent.open_long_trade agent0.core.hyperdrive.agent.open_short_trade agent0.core.hyperdrive.agent.redeem_withdraw_shares_trade agent0.core.hyperdrive.agent.remove_liquidity_trade Package Contents ---------------- .. py:class:: HyperdriveActionType Bases: :py:obj:`enum.Enum` The descriptor of an action in a market. .. !! processed by numpydoc !! .. py:attribute:: INITIALIZE_MARKET :value: 'initialize_market' .. py:attribute:: OPEN_LONG :value: 'open_long' .. py:attribute:: CLOSE_LONG :value: 'close_long' .. py:attribute:: OPEN_SHORT :value: 'open_short' .. py:attribute:: CLOSE_SHORT :value: 'close_short' .. py:attribute:: ADD_LIQUIDITY :value: 'add_liquidity' .. py:attribute:: REMOVE_LIQUIDITY :value: 'remove_liquidity' .. py:attribute:: REDEEM_WITHDRAW_SHARE :value: 'redeem_withdraw_share' .. py:class:: HyperdriveMarketAction Bases: :py:obj:`agent0.core.base.BaseMarketAction`\ [\ :py:obj:`HyperdriveActionType`\ ] Market action specification. .. !! processed by numpydoc !! .. py:attribute:: action_type :type: HyperdriveActionType .. py:attribute:: trade_amount :type: fixedpointmath.FixedPoint .. py:attribute:: maturity_time :type: int | None :value: None .. py:attribute:: slippage_tolerance :type: fixedpointmath.FixedPoint | None :value: None .. py:attribute:: gas_limit :type: int | None :value: None .. py:attribute:: base_fee_multiple :type: float | None :value: None .. py:attribute:: priority_fee_multiple :type: float | None :value: None .. py:attribute:: min_apr :type: fixedpointmath.FixedPoint .. py:attribute:: max_apr :type: fixedpointmath.FixedPoint .. py:function:: add_liquidity_trade(trade_amount: fixedpointmath.FixedPoint, base_fee_multiple: float | None = None, priority_fee_multiple: float | None = None, gas_limit: int | None = None, min_apr: fixedpointmath.FixedPoint | None = None, max_apr: fixedpointmath.FixedPoint | None = None) -> agent0.core.base.Trade[HyperdriveMarketAction] Return a trade object for adding liquidity. :param trade_amount: The amount of liquidity you wish to add to the pool. :type trade_amount: FixedPoint :param base_fee_multiple: The base fee multiple for the transaction. :type base_fee_multiple: float | None, optional :param priority_fee_multiple: The priority fee multiple for the transaction. :type priority_fee_multiple: float | None, 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 min_apr: Minimum allowable APR after liquidity is added. If this is not met, the trade will not execute. Defaults to the minimum solidity FixedPoint (1e-18) :type min_apr: FixedPoint, optional :param max_apr: Maximum allowable APR after liquidity is added. If this is not met, the trade will not execute. Defaults to the maximum solidity FixedPoint (2**256-1) :type max_apr: FixedPoint, optional :returns: The trade object for adding liquidity to a Hyperdrive pool. :rtype: Trade[HyperdriveMarketAction] .. !! processed by numpydoc !! .. py:function:: close_long_trade(trade_amount: fixedpointmath.FixedPoint, maturity_time: int, slippage_tolerance: fixedpointmath.FixedPoint | None = None, base_fee_multiple: float | None = None, priority_fee_multiple: float | None = None, gas_limit: int | None = None) -> agent0.core.base.Trade[HyperdriveMarketAction] Return a trade object for closing a long. :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 base_fee_multiple: The base fee multiple for the transaction. :type base_fee_multiple: float | None, optional :param priority_fee_multiple: The priority fee multiple for the transaction. :type priority_fee_multiple: float | None, 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 :returns: The trade object for closing a long in a Hyperdrive pool. :rtype: Trade[HyperdriveMarketAction] .. !! processed by numpydoc !! .. py:function:: close_short_trade(trade_amount: fixedpointmath.FixedPoint, maturity_time: int, slippage_tolerance: fixedpointmath.FixedPoint | None = None, base_fee_multiple: float | None = None, priority_fee_multiple: float | None = None, gas_limit: int | None = None) -> agent0.core.base.Trade[HyperdriveMarketAction] Return a trade object for closing a short. :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 base_fee_multiple: The base fee multiple for the transaction. :type base_fee_multiple: float | None, optional :param priority_fee_multiple: The priority fee multiple for the transaction. :type priority_fee_multiple: float | None, 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 :returns: The trade object for closing a short in a Hyperdrive pool. :rtype: Trade[HyperdriveMarketAction] .. !! processed by numpydoc !! .. py:function:: open_long_trade(trade_amount: fixedpointmath.FixedPoint, slippage_tolerance: fixedpointmath.FixedPoint | None = None, base_fee_multiple: float | None = None, priority_fee_multiple: float | None = None, gas_limit: int | None = None) -> agent0.core.base.Trade[HyperdriveMarketAction] Return a trade object for opening a long. :param trade_amount: The amount of base you wish to use to open a long. :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 base_fee_multiple: The base fee multiple for the transaction. :type base_fee_multiple: float | None, optional :param priority_fee_multiple: The priority fee multiple for the transaction. :type priority_fee_multiple: float | None, 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 :returns: The trade object for opening a long in a Hyperdrive pool. :rtype: Trade[HyperdriveMarketAction] .. !! processed by numpydoc !! .. py:function:: open_short_trade(trade_amount: fixedpointmath.FixedPoint, slippage_tolerance: fixedpointmath.FixedPoint | None = None, base_fee_multiple: float | None = None, priority_fee_multiple: float | None = None, gas_limit: int | None = None) -> agent0.core.base.Trade[HyperdriveMarketAction] Return a trade object for opening a short. :param trade_amount: The amount of bonds you wish to short. :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 base_fee_multiple: The base fee multiple for the transaction. :type base_fee_multiple: float | None, optional :param priority_fee_multiple: The priority fee multiple for the transaction. :type priority_fee_multiple: float | None, 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 :returns: The trade object for opening a short in a Hyperdrive pool. :rtype: Trade[HyperdriveMarketAction] .. !! processed by numpydoc !! .. py:function:: redeem_withdraw_shares_trade(trade_amount: fixedpointmath.FixedPoint, base_fee_multiple: float | None = None, priority_fee_multiple: float | None = None, gas_limit: int | None = None) -> agent0.core.base.Trade[HyperdriveMarketAction] Return a trade object for redeeming withdraw shares. :param trade_amount: The amount of withdraw shares you wish to redeem from the pool. :type trade_amount: FixedPoint :param base_fee_multiple: The base fee multiple for the transaction. :type base_fee_multiple: float | None, optional :param priority_fee_multiple: The priority fee multiple for the transaction. :type priority_fee_multiple: float | None, 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 :returns: The trade object for redeeming withdraw shares from a Hyperdrive pool. :rtype: Trade[HyperdriveMarketAction] .. !! processed by numpydoc !! .. py:function:: remove_liquidity_trade(trade_amount: fixedpointmath.FixedPoint, slippage_tolerance: fixedpointmath.FixedPoint | None = None, base_fee_multiple: float | None = None, priority_fee_multiple: float | None = None, gas_limit: int | None = None) -> agent0.core.base.Trade[HyperdriveMarketAction] Return a trade object for removing liquidity. :param trade_amount: The amount of liquidity you wish to remove from the pool. :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 base_fee_multiple: The base fee multiple for the transaction. :type base_fee_multiple: float | None, optional :param priority_fee_multiple: The priority fee multiple for the transaction. :type priority_fee_multiple: float | None, 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 :returns: * *Trade[HyperdriveMarketAction]* -- The trade object for removing liquidity from a Hyperdrive pool. * *.. warning::* -- Slippage tolerance is not implemented for remove liquidity trades, field will be ignored. .. !! processed by numpydoc !! .. py:class:: HyperdriveWallet Bases: :py:obj:`agent0.core.base.EthWallet` Stateful variable for storing what is in the agent's wallet. .. !! processed by numpydoc !! .. py:attribute:: lp_tokens :type: fixedpointmath.FixedPoint The LP tokens held by the trader. .. !! processed by numpydoc !! .. py:attribute:: withdraw_shares :type: fixedpointmath.FixedPoint The amount of unclaimed withdraw shares held by the agent. .. !! processed by numpydoc !! .. py:attribute:: longs :type: dict[int, Long] The long positions held by the trader. The dictionary is keyed by the maturity time in seconds. .. !! processed by numpydoc !! .. py:attribute:: shorts :type: dict[int, Short] The short positions held by the trader. The dictionary is keyed by the maturity time in seconds. .. !! processed by numpydoc !! .. py:method:: copy() -> HyperdriveWallet Return a new copy of self. :returns: A deep copy of the wallet. :rtype: HyperdriveWallet .. !! processed by numpydoc !! .. py:class:: Long An open long position. .. todo:: make balance a Quantity to enforce units .. !! processed by numpydoc !! .. py:attribute:: balance :type: fixedpointmath.FixedPoint The amount of bonds that the position is long. .. !! processed by numpydoc !! .. py:attribute:: maturity_time :type: int The maturity time of the long. .. !! processed by numpydoc !! .. py:class:: Short An open short position. .. !! processed by numpydoc !! .. py:attribute:: balance :type: fixedpointmath.FixedPoint The amount of bonds that the position is short. .. !! processed by numpydoc !! .. py:attribute:: maturity_time :type: int The maturity time of the short. .. !! processed by numpydoc !! .. py:class:: TradeResult A data object that stores all information of an executed trade. .. !! processed by numpydoc !! .. py:attribute:: trade_successful :type: bool The status of the trade. .. !! processed by numpydoc !! .. py:attribute:: account :type: eth_account.signers.local.LocalAccount | None :value: None The agent that was executing the trade. .. !! processed by numpydoc !! .. py:attribute:: wallet :type: agent0.core.hyperdrive.agent.hyperdrive_wallet.HyperdriveWallet | None :value: None The wallet of the agent that was executing the trade. .. !! processed by numpydoc !! .. py:attribute:: policy :type: agent0.core.hyperdrive.policies.HyperdriveBasePolicy | None :value: None The policy that was executing the trade. .. !! processed by numpydoc !! .. py:attribute:: trade_object :type: agent0.core.base.Trade[agent0.core.hyperdrive.agent.hyperdrive_actions.HyperdriveMarketAction] | None :value: None The trade object for the trade. .. !! processed by numpydoc !! .. py:attribute:: hyperdrive_event :type: pypechain.core.BaseEvent | None :value: None The transaction receipt of the trade. .. !! processed by numpydoc !! .. py:attribute:: contract_call :type: dict[str, Any] | None :value: None A dictionary detailing the underlying contract call. .. !! processed by numpydoc !! .. py:attribute:: is_slippage :type: bool :value: False If the trade failed due to slippage. .. !! processed by numpydoc !! .. py:attribute:: is_invalid_balance :type: bool :value: False If the trade failed due to invalid balance. .. !! processed by numpydoc !! .. py:attribute:: is_insufficient_allowance :type: bool :value: False If the trade failed due to insufficient approval. .. !! processed by numpydoc !! .. py:attribute:: is_min_txn_amount :type: bool :value: False If the trade failed due to minimum transaction amount. .. !! processed by numpydoc !! .. py:attribute:: is_long_proceeds_less_than_fees :type: bool :value: False If the trade failed due long proceeds less than fees. .. !! processed by numpydoc !! .. py:attribute:: block_number :type: int | None :value: None The block number of the transaction. .. !! processed by numpydoc !! .. py:attribute:: block_timestamp :type: int | None :value: None The block timestamp of the transaction. .. !! processed by numpydoc !! .. py:attribute:: exception :type: Exception | None :value: None The exception that was thrown. .. !! processed by numpydoc !! .. py:attribute:: orig_exception :type: Exception | list[Exception] | BaseException | None :value: None If exception was wrapped, the original exception that was thrown. .. !! processed by numpydoc !! .. py:attribute:: pool_config :type: dict[str, Any] | None :value: None The pool config information. .. !! processed by numpydoc !! .. py:attribute:: pool_info :type: dict[str, Any] | None :value: None The pool info information. .. !! processed by numpydoc !! .. py:attribute:: checkpoint_info :type: dict[str, Any] | None :value: None The checkpoint info information. .. !! processed by numpydoc !! .. py:attribute:: contract_addresses :type: dict[str, Any] | None :value: None The contract addresses. .. !! processed by numpydoc !! .. py:attribute:: additional_info :type: dict[str, Any] | None :value: None Additional information used for crash reporting. .. !! processed by numpydoc !! .. py:attribute:: raw_transaction :type: dict[str, Any] | None :value: None The raw transaction sent to the chain. .. !! processed by numpydoc !! .. py:attribute:: raw_pool_config :type: dict[str, Any] | None :value: None The raw pool config. .. !! processed by numpydoc !! .. py:attribute:: raw_pool_info :type: dict[str, Any] | None :value: None The raw pool info. .. !! processed by numpydoc !! .. py:attribute:: raw_checkpoint :type: dict[str, Any] | None :value: None The raw checkpoint info. .. !! processed by numpydoc !! .. py:attribute:: anvil_state :type: str | None :value: None The dumped anvil state. .. !! processed by numpydoc !!