agent0.core.hyperdrive.utilities.predict
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
Attributes
Classes
Functions
|
Predict the outcome of a long trade. |
|
Predict the outcome of a short trade. |
Module Contents
- agent0.core.hyperdrive.utilities.predict.YEAR_IN_SECONDS = 31536000
- agent0.core.hyperdrive.utilities.predict.YEAR_IN_BLOCKS = 2628000.0
- class agent0.core.hyperdrive.utilities.predict.TradeDeltas
Bases:
tuple- user
- pool
- fee
- governance
- agent0.core.hyperdrive.utilities.predict.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.
- Parameters:
hyperdrive_interface (HyperdriveReadInterface) – Hyperdrive interface.
pool_state (PoolState, optional) – The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state.
base (FixedPoint, optional) – The size of the long to open, in base. If not given, converted from bonds.
bonds (FixedPoint, optional) – The size of the long to open, in bonds.
for_pool (bool) – Whether the base or bonds specified is for the pool.
- Returns:
The predicted deltas of base, bonds, and shares.
- Return type:
- agent0.core.hyperdrive.utilities.predict.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.
- Parameters:
hyperdrive_interface (HyperdriveReadInterface) – Hyperdrive interface.
pool_state (PoolState, optional) – The state of the pool, which includes block details, pool config, and pool info. If not given, use the current pool state.
base (FixedPoint, optional) – The size of the short to open, in base.
bonds (FixedPoint, optional) – The size of the short to open, in bonds. If not given, bonds is calculated from base.
for_pool (bool) – Whether the base or bonds specified is for the pool.
- Returns:
The predicted deltas of base, bonds, and shares.
- Return type: