agent0.core.hyperdrive.agent.hyperdrive_actions
Hyperdrive AMM action specification.
Classes
The descriptor of an action in a market. |
|
Market action specification. |
Functions
|
Return a trade object for opening a long. |
|
Return a trade object for closing a long. |
|
Return a trade object for opening a short. |
|
Return a trade object for closing a short. |
|
Return a trade object for adding liquidity. |
Return a trade object for removing liquidity. |
|
Return a trade object for redeeming withdraw shares. |
Module Contents
- class agent0.core.hyperdrive.agent.hyperdrive_actions.HyperdriveActionType
Bases:
enum.EnumThe descriptor of an action in a market.
- INITIALIZE_MARKET = 'initialize_market'
- OPEN_LONG = 'open_long'
- CLOSE_LONG = 'close_long'
- OPEN_SHORT = 'open_short'
- CLOSE_SHORT = 'close_short'
- ADD_LIQUIDITY = 'add_liquidity'
- REMOVE_LIQUIDITY = 'remove_liquidity'
- REDEEM_WITHDRAW_SHARE = 'redeem_withdraw_share'
- class agent0.core.hyperdrive.agent.hyperdrive_actions.HyperdriveMarketAction
Bases:
agent0.core.base.BaseMarketAction[HyperdriveActionType]Market action specification.
- action_type: HyperdriveActionType
- trade_amount: fixedpointmath.FixedPoint
- maturity_time: int | None = None
- slippage_tolerance: fixedpointmath.FixedPoint | None = None
- gas_limit: int | None = None
- base_fee_multiple: float | None = None
- priority_fee_multiple: float | None = None
- min_apr: fixedpointmath.FixedPoint
- max_apr: fixedpointmath.FixedPoint
- agent0.core.hyperdrive.agent.hyperdrive_actions.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.
- Parameters:
trade_amount (FixedPoint) – The amount of base you wish to use to open a long.
slippage_tolerance (FixedPoint, optional) – 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.
base_fee_multiple (float | None, optional) – The base fee multiple for the transaction.
priority_fee_multiple (float | None, optional) – The priority fee multiple for the transaction.
gas_limit (int | None, optional) – The maximum amount of gas used by the transaction. Defaults to eth_estimateGas RPC output.
- Returns:
The trade object for opening a long in a Hyperdrive pool.
- Return type:
- agent0.core.hyperdrive.agent.hyperdrive_actions.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.
- Parameters:
trade_amount (FixedPoint) – The amount of bonds you wish to close.
maturity_time (int) – The token maturity time in seconds.
slippage_tolerance (FixedPoint, optional) – 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.
base_fee_multiple (float | None, optional) – The base fee multiple for the transaction.
priority_fee_multiple (float | None, optional) – The priority fee multiple for the transaction.
gas_limit (int | None, optional) – The maximum amount of gas used by the transaction. Defaults to eth_estimateGas RPC output.
- Returns:
The trade object for closing a long in a Hyperdrive pool.
- Return type:
- agent0.core.hyperdrive.agent.hyperdrive_actions.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.
- Parameters:
trade_amount (FixedPoint) – The amount of bonds you wish to short.
slippage_tolerance (FixedPoint, optional) – 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.
base_fee_multiple (float | None, optional) – The base fee multiple for the transaction.
priority_fee_multiple (float | None, optional) – The priority fee multiple for the transaction.
gas_limit (int | None, optional) – The maximum amount of gas used by the transaction. Defaults to eth_estimateGas RPC output.
- Returns:
The trade object for opening a short in a Hyperdrive pool.
- Return type:
- agent0.core.hyperdrive.agent.hyperdrive_actions.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.
- Parameters:
trade_amount (FixedPoint) – The amount of bonds you wish to close.
maturity_time (int) – The token maturity time in seconds.
slippage_tolerance (FixedPoint, optional) – 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.
base_fee_multiple (float | None, optional) – The base fee multiple for the transaction.
priority_fee_multiple (float | None, optional) – The priority fee multiple for the transaction.
gas_limit (int | None, optional) – The maximum amount of gas used by the transaction. Defaults to eth_estimateGas RPC output.
- Returns:
The trade object for closing a short in a Hyperdrive pool.
- Return type:
- agent0.core.hyperdrive.agent.hyperdrive_actions.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.
- Parameters:
trade_amount (FixedPoint) – The amount of liquidity you wish to add to the pool.
base_fee_multiple (float | None, optional) – The base fee multiple for the transaction.
priority_fee_multiple (float | None, optional) – The priority fee multiple for the transaction.
gas_limit (int | None, optional) – The maximum amount of gas used by the transaction. Defaults to eth_estimateGas RPC output.
min_apr (FixedPoint, optional) – 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)
max_apr (FixedPoint, optional) – 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)
- Returns:
The trade object for adding liquidity to a Hyperdrive pool.
- Return type:
- agent0.core.hyperdrive.agent.hyperdrive_actions.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.
- Parameters:
trade_amount (FixedPoint) – The amount of liquidity you wish to remove from the pool.
slippage_tolerance (FixedPoint, optional) – 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.
base_fee_multiple (float | None, optional) – The base fee multiple for the transaction.
priority_fee_multiple (float | None, optional) – The priority fee multiple for the transaction.
gas_limit (int | None, optional) – The maximum amount of gas used by the transaction. Defaults to eth_estimateGas RPC output.
- 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.
Return a trade object for redeeming withdraw shares.
- Parameters:
trade_amount (FixedPoint) – The amount of withdraw shares you wish to redeem from the pool.
base_fee_multiple (float | None, optional) – The base fee multiple for the transaction.
priority_fee_multiple (float | None, optional) – The priority fee multiple for the transaction.
gas_limit (int | None, optional) – The maximum amount of gas used by the transaction. Defaults to eth_estimateGas RPC output.
- Returns:
The trade object for redeeming withdraw shares from a Hyperdrive pool.
- Return type: