agent0.core.hyperdrive.utilities.predict ======================================== .. py:module:: agent0.core.hyperdrive.utilities.predict .. autoapi-nested-parse:: Predict the outcome of trades. A trade results in changes to 4 entities, measured in 3 units. accounts: pool, user, fee, governance units: base, bonds, shares (base and shares refer to the same account) Applications where this is useful: LP and Arb bot uses this logic to hit a target rate. Trade by specifying the output units (base for open long, bonds otherwise). For example: +------------+--------------+---------------+--------------+ | Entity | Base | Bonds | Shares | +============+==============+===============+==============+ | user | 100 | 104.95 | 100 | +------------+--------------+---------------+--------------+ | pool | 99.9952 | -104.955 | 99.9952 | +------------+--------------+---------------+--------------+ | fee | 0.0428367 | 0.0449786 | 0.0428367 | +------------+--------------+---------------+--------------+ | governance | 0.00475964 | 0.00499762 | 0.00475964 | +------------+--------------+---------------+--------------+ .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: agent0.core.hyperdrive.utilities.predict.YEAR_IN_SECONDS agent0.core.hyperdrive.utilities.predict.YEAR_IN_BLOCKS Classes ------- .. autoapisummary:: agent0.core.hyperdrive.utilities.predict.Deltas agent0.core.hyperdrive.utilities.predict.TradeDeltas Functions --------- .. autoapisummary:: agent0.core.hyperdrive.utilities.predict.predict_long agent0.core.hyperdrive.utilities.predict.predict_short Module Contents --------------- .. py:data:: YEAR_IN_SECONDS :value: 31536000 .. py:data:: YEAR_IN_BLOCKS :value: 2628000.0 .. py:class:: Deltas Bases: :py:obj:`tuple` .. py:attribute:: base .. py:attribute:: bonds .. py:attribute:: shares .. py:class:: TradeDeltas Bases: :py:obj:`tuple` .. py:attribute:: user .. py:attribute:: pool .. py:attribute:: fee .. py:attribute:: governance .. py:function:: predict_long(hyperdrive_interface: agent0.ethpy.hyperdrive.interface.read_interface.HyperdriveReadInterface, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None, base: fixedpointmath.FixedPoint | None = None, bonds: fixedpointmath.FixedPoint | None = None, for_pool: bool = False) -> TradeDeltas Predict the outcome of a long trade. :param hyperdrive_interface: Hyperdrive interface. :type hyperdrive_interface: HyperdriveReadInterface :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, optional :param base: The size of the long to open, in base. If not given, converted from bonds. :type base: FixedPoint, optional :param bonds: The size of the long to open, in bonds. :type bonds: FixedPoint, optional :param for_pool: Whether the base or bonds specified is for the pool. :type for_pool: bool :returns: The predicted deltas of base, bonds, and shares. :rtype: TradeDeltas .. !! processed by numpydoc !! .. py:function:: predict_short(hyperdrive_interface: agent0.ethpy.hyperdrive.interface.read_interface.HyperdriveReadInterface, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None, base: fixedpointmath.FixedPoint | None = None, bonds: fixedpointmath.FixedPoint | None = None, for_pool: bool = False) -> TradeDeltas Predict the outcome of a short trade. :param hyperdrive_interface: Hyperdrive interface. :type hyperdrive_interface: HyperdriveReadInterface :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, optional :param base: The size of the short to open, in base. :type base: FixedPoint, optional :param bonds: The size of the short to open, in bonds. If not given, bonds is calculated from base. :type bonds: FixedPoint, optional :param for_pool: Whether the base or bonds specified is for the pool. :type for_pool: bool :returns: The predicted deltas of base, bonds, and shares. :rtype: TradeDeltas .. !! processed by numpydoc !!