API Reference

Detailed API Reference for Vertex Protocol SDK.

vertex_protocol.client

class vertex_protocol.client.VertexClient(context)[source]

Bases: object

The primary client interface for interacting with Vertex Protocol.

This client consolidates the functionality of various aspects of Vertex such as spot, market, subaccount, and perpetual (perp) operations.

To initialize an instance of this client, use the create_vertex_client utility.

Attributes:
  • context (VertexClientContext): The client context containing configuration for interacting with Vertex.

  • market (MarketAPI): Sub-client for executing and querying market operations.

  • subaccount (SubaccountAPI): Sub-client for executing and querying subaccount operations.

  • spot (SpotAPI): Sub-client for executing and querying spot operations.

  • perp (PerpAPI): Sub-client for executing and querying perpetual operations.

__init__(context)[source]

Initialize a new instance of the VertexClient.

This constructor should not be called directly. Instead, use the create_vertex_client utility to create a new VertexClient. This is because the create_vertex_client utility includes important additional setup steps that aren’t included in this constructor.

Args:

context (VertexClientContext): The client context.

Note:

Use create_vertex_client for creating instances.

context: VertexClientContext
market: MarketAPI
subaccount: SubaccountAPI
spot: SpotAPI
perp: PerpAPI
class vertex_protocol.client.VertexClientMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

VertexClientMode is an enumeration representing the operational modes of the VertexClient.

Attributes:

MAINNET: For operating in Vertex’s mainnet environment deployed on Arbitrum One.

BLAST_MAINNET: For operating in Vertex’s mainnet environment deployed on Blast Mainnet.

SEPOLIA_TESTNET: For operating in Vertex’s testnet environment deployed on Arbitrum Sepolia.

DEVNET: For local development.

TESTING: For running tests.

MAINNET = 'mainnet'
BLAST_MAINNET = 'blast-mainnet'
SEPOLIA_TESTNET = 'sepolia-testnet'
DEVNET = 'devnet'
TESTING = 'testing'
vertex_protocol.client.create_vertex_client(mode, signer=None, context_opts=None)[source]

Create a new VertexClient based on the given mode and signer.

This function will create a new VertexClientContext based on the provided mode, and then initialize a new VertexClient with that context.

If context_opts are provided, they will be used to create the client context. Otherwise, default context options for the given mode will be used.

Return type:

VertexClient

Args:
mode (VertexClientMode): The mode in which to operate the client. Can be one of the following:

VertexClientMode.MAINNET: For operating in Vertex’s mainnet environment deployed on Arbitrum One. VertexClientMode.BLAST_MAINNET: For operating in Vertex’s mainnet environment deployed on Blast Mainnet. VertexClientMode.SEPOLIA_TESTNET: For operating in Vertex’s testnet environment deployed on Arbitrum Sepolia. VertexClientMode.DEVNET: For local development.

signer (Signer, optional): An instance of LocalAccount or a private key string for signing transactions.

context_opts (VertexClientContextOpts, optional): Options for creating the client context.

If not provided, default options for the given mode will be used.

Returns:

VertexClient: The created VertexClient instance.

class vertex_protocol.client.VertexClientContext(signer, engine_client, indexer_client, contracts)[source]

Bases: object

Context required to use the Vertex client.

signer: Optional[LocalAccount]
engine_client: EngineClient
indexer_client: IndexerClient
contracts: VertexContracts
__init__(signer, engine_client, indexer_client, contracts)
class vertex_protocol.client.VertexClientContextOpts(**data)[source]

Bases: BaseModel

contracts_context: Optional[VertexContractsContext]
rpc_node_url: Optional[AnyUrl]
engine_endpoint_url: Optional[AnyUrl]
indexer_endpoint_url: Optional[AnyUrl]
vertex_protocol.client.create_vertex_client_context(opts, signer=None)[source]

Initializes a VertexClientContext instance with the provided signer and options.

Return type:

VertexClientContext

Args:

opts (VertexClientContextOpts): Options including endpoints for the engine and indexer clients.

signer (Signer, optional): An instance of LocalAccount or a private key string for signing transactions.

Returns:

VertexClientContext: The initialized Vertex client context.

Note:

This helper attempts to fully set up the engine client, including the necessary verifying contracts to correctly sign executes. If this step fails, it is skipped and can be set up later, while logging the error.

vertex_protocol.client.apis

class vertex_protocol.client.apis.VertexBaseAPI(context)[source]

Bases: object

The base class for all Vertex API classes, providing the foundation for API-specific classes in the Vertex client.

VertexBaseAPI serves as a foundation for the hierarchical structure of the Vertex API classes. This structure allows for better organization and separation of concerns, with each API-specific subclass handling a different aspect of the Vertex client’s functionality.

Attributes:

context (VertexClientContext): The context in which the API operates, providing access to the client’s state and services.

Note:

This class is not meant to be used directly. It provides base functionality for other API classes in the Vertex client.

__init__(context)[source]

Initialize an instance of VertexBaseAPI.

VertexBaseAPI requires a context during instantiation, which should be an instance of VertexClientContext. This context provides access to the state and services of the Vertex client and allows the API to interact with these.

Args:

context (VertexClientContext): The context in which this API operates. Provides access to the state and services of the Vertex client.

context: VertexClientContext
class vertex_protocol.client.apis.MarketAPI(context)[source]

Bases: MarketExecuteAPI, MarketQueryAPI

A unified interface for market operations in the Vertex Protocol.

This class combines functionalities from both MarketExecuteAPI and MarketQueryAPI into a single interface, providing a simpler and more consistent way to perform market operations. It allows for both query (data retrieval) and execution (transaction) operations for market.

Inheritance:

MarketExecuteAPI: This provides functionalities to execute various operations related to market. These include actions like placing an order, canceling an order, minting and burning LP tokens.

MarketQueryAPI: This provides functionalities to retrieve various kinds of information related to market. These include operations like retrieving order books, historical orders, market matches, and others.

Attributes and Methods: Inherited from MarketExecuteAPI and MarketQueryAPI.

class vertex_protocol.client.apis.MarketExecuteAPI(context)[source]

Bases: VertexBaseAPI

Provides functionality to interact with the Vertex’s market execution APIs. This class contains methods that allow clients to execute operations such as minting LP tokens, burning LP tokens, placing and cancelling orders on the Vertex market.

Attributes:

context (VertexClientContext): The context that provides connectivity configuration for VertexClient.

Note:

This class should not be instantiated directly, it is designed to be used through a VertexClient instance.

mint_lp(params)[source]

Mint LP tokens through the engine.

Return type:

ExecuteResponse

Args:

params (MintLpParams): Parameters required to mint LP tokens.

Returns:

ExecuteResponse: The response from the engine execution.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

burn_lp(params)[source]

Burn LP tokens through the engine.

Return type:

ExecuteResponse

Args:

params (BurnLpParams): Parameters required to burn LP tokens.

Returns:

ExecuteResponse: The response from the engine execution.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

place_order(params)[source]

Places an order through the engine.

Return type:

ExecuteResponse

Args:

params (PlaceOrderParams): Parameters required to place an order.

Returns:

ExecuteResponse: The response from the engine execution.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

place_market_order(params)[source]

Places a market order through the engine.

Return type:

ExecuteResponse

Args:

params (PlaceMarketOrderParams): Parameters required to place a market order.

Returns:

ExecuteResponse: The response from the engine execution.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

cancel_orders(params)[source]

Cancels orders through the engine.

Return type:

ExecuteResponse

Args:

params (CancelOrdersParams): Parameters required to cancel orders.

Returns:

ExecuteResponse: The response from the engine execution containing information about the canceled product orders.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

cancel_product_orders(params)[source]

Cancels all orders for provided products through the engine.

Return type:

ExecuteResponse

Args:

params (CancelProductOrdersParams): Parameters required to cancel product orders.

Returns:

ExecuteResponse: The response from the engine execution containing information about the canceled product orders.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

cancel_and_place(params)[source]

Cancels orders and places a new one through the engine on the same request.

Return type:

ExecuteResponse

Args:

params (CancelAndPlaceParams): Parameters required to cancel orders and place a new one.

Returns:

ExecuteResponse: The response from the engine execution.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

close_position(subaccount, product_id)[source]

Places an order through the engine to close a position for the provided product_id.

Return type:

ExecuteResponse

Attributes:

subaccount (Subaccount): The subaccount to close position for. product_id (int): The ID of the product to close position for.

Returns:

ExecuteResponse: The response from the engine execution.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

class vertex_protocol.client.apis.MarketQueryAPI(context)[source]

Bases: VertexBaseAPI

The MarketQueryAPI class provides methods to interact with the Vertex’s market querying APIs.

This class provides functionality for querying various details about the market including fetching information about order books, fetching historical orders, and retrieving market matches, among others.

Attributes:

context (VertexClientContext): The context that provides connectivity configuration for VertexClient.

Note:

This class should not be instantiated directly, it is designed to be used through a VertexClient instance.

get_all_engine_markets()[source]

Retrieves all market states from the off-chain engine.

Return type:

AllProductsData

Returns:

AllProductsData: A data class object containing information about all products in the engine.

get_all_product_symbols()[source]

Retrieves all product symbols from the off-chain engine

Return type:

list[ProductSymbol]

Returns:

ProductSymbolsData: A list of all products with corresponding symbol.

get_market_liquidity(product_id, depth)[source]

Retrieves liquidity per price tick from the engine.

The engine will skip price levels that have no liquidity, so it is not guaranteed that the bids/asks are evenly spaced

Return type:

MarketLiquidityData

Parameters:

product_id (int): The product ID for which liquidity is to be fetched. depth (int): The depth of the order book to retrieve liquidity from.

Returns:

MarketLiquidityData: A data class object containing liquidity information for the specified product.

get_latest_market_price(product_id)[source]

Retrieves the latest off-chain orderbook price from the engine for a specific product.

Return type:

MarketPriceData

Args:

product_id (int): The identifier for the product to retrieve the latest market price.

Returns:

MarketPriceData: A data class object containing information about the latest market price for the given product.

get_subaccount_open_orders(product_id, sender)[source]

Queries the off-chain engine to retrieve the status of any open orders for a given subaccount.

This function fetches any open orders that a specific subaccount might have for a specific product from the off-chain engine. The orders are returned as an SubaccountOpenOrdersData object.

Return type:

SubaccountOpenOrdersData

Args:

product_id (int): The identifier for the product to fetch open orders.

sender (str): The address and subaccount identifier as a bytes32 hex string.

Returns:

SubaccountOpenOrdersData: A data class object containing information about the open orders of a subaccount.

get_subaccount_historical_orders(params)[source]

Queries the indexer to fetch historical orders of a specific subaccount.

This function retrieves a list of historical orders that a specific subaccount has placed. The order data can be filtered using various parameters provided in the IndexerSubaccountHistoricalOrdersParams object. The fetched historical orders data is returned as an IndexerHistoricalOrdersData object.

Return type:

IndexerHistoricalOrdersData

Args:
params (IndexerSubaccountHistoricalOrdersParams): Parameters to filter the historical orders data:
  • subaccount (str): The address and subaccount identifier as a bytes32 hex string.

  • product_ids (list[int], optional): A list of identifiers for the products to fetch orders for. If provided, the function will return orders related to these products.

  • idx (int, optional): Submission index. If provided, the function will return orders submitted before this index.

  • max_time (int, optional): Maximum timestamp for the orders. The function will return orders submitted before this time.

  • limit (int, optional): Maximum number of orders to return. If provided, the function will return at most ‘limit’ number of orders.

Returns:

IndexerHistoricalOrdersData: A data class object containing information about the historical orders of a subaccount.

get_historical_orders_by_digest(digests)[source]

Queries the indexer to fetch historical orders based on a list of provided digests.

This function retrieves historical order data for a given list of order digests. Each digest represents a unique order. The returned object includes the historical order data for each digest in the provided list.

Return type:

IndexerHistoricalOrdersData

Args:

digests (list[str]): List of order digests. An order digest is a unique identifier for each order.

Returns:

IndexerHistoricalOrdersData: A data class object containing information about the historical orders associated with the provided digests.

get_max_order_size(params)[source]

Queries the engine to determine the maximum order size that can be submitted within health requirements.

Return type:

MaxOrderSizeData

Args:
params (QueryMaxOrderSizeParams):
  • sender (str): The address and subaccount identifier in a bytes32 hex string.

  • product_id (int): The identifier for the spot/perp product.

  • price_x18 (str): The price of the order in x18 format as a string.

  • direction (MaxOrderSizeDirection): ‘long’ for max bid or ‘short’ for max ask.

  • spot_leverage (Optional[bool]): If False, calculates max size without borrowing. Defaults to True.

Returns:

MaxOrderSizeData: The maximum size of the order that can be placed.

get_max_lp_mintable(product_id, sender, spot_leverage=None)[source]

Queries the engine to determine the maximum base amount that can be contributed for minting LPs.

Return type:

MaxLpMintableData

Args:

product_id (int): The identifier for the spot/perp product.

sender (str): The address and subaccount identifier in a bytes32 hex string.

spot_leverage (Optional[bool]): If False, calculates max amount without considering leverage. Defaults to True.

Returns:

MaxLpMintableData: Maximum base amount that can be contributed for minting LPs, in string format.

get_candlesticks(params)[source]

Fetches historical candlestick data for a specific product using the indexer.

Return type:

IndexerCandlesticksData

Args:
params (IndexerCandlesticksParams): Parameters for the query, which include:
  • product_id (int): The identifier for the product.

  • granularity (IndexerCandlesticksGranularity): Duration for each candlestick in seconds.

Returns:

IndexerCandlesticksData: Contains a list of historical candlestick data (IndexerCandlestick) for the specified product at the specified granularity.

Note:

For obtaining the latest orderbook prices, consider using the ‘get_latest_market_price()’ method.

get_perp_funding_rate(product_id)[source]

Fetches the latest funding rate for a specific perp product.

Return type:

IndexerFundingRateData

Args:

product_id (int): Identifier for the perp product.

Returns:

IndexerFundingRateData: Contains the latest funding rate and related details for the given perp product.

get_perp_funding_rates(product_ids)[source]

Fetches the latest funding rates for a list of perp products.

Return type:

Dict[str, IndexerFundingRateData]

Args:

product_ids (list): List of identifiers for the perp products.

Returns:

dict: A dictionary mapping each product_id to its latest funding rate and related details.

get_product_snapshots(params)[source]

Fetches the historical snapshots for a specific product from the indexer.

Return type:

IndexerProductSnapshotsData

Args:
params (IndexerProductSnapshotsParams): Query parameters consisting of:
  • product_id (int): Identifier for the product.

  • idx (int, optional): Submission index to filter the returned snapshots.

  • max_time (int, optional): Maximum timestamp to filter the returned snapshots.

  • limit (int, optional): Maximum number of snapshots to return.

Returns:

IndexerProductSnapshotsData: Object containing lists of product snapshots and related transaction data.

get_market_snapshots(params)[source]

Fetches the historical market snapshots from the indexer.

Return type:

IndexerMarketSnapshotsData

Args:

params (IndexerMarketSnapshotsParams): Parameters specifying the historical market snapshot request.

Returns:

IndexerMarketSnapshotsData: The market snapshot data corresponding to the provided parameters.

class vertex_protocol.client.apis.SpotAPI(context)[source]

Bases: SpotExecuteAPI, SpotQueryAPI

A unified interface for spot operations in the Vertex Protocol.

This class combines functionalities from both SpotExecuteAPI and SpotQueryAPI into a single interface, providing a simpler and more consistent way to perform spot operations. It allows for both query (data retrieval) and execution (transaction) operations for spot products.

Inheritance:

SpotExecuteAPI: This provides functionalities to execute various operations related to spot products, such as depositing a specified amount into a spot product.

SpotQueryAPI: This provides functionalities to retrieve various kinds of information related to spot products, such as getting the wallet token balance of a given spot product.

Attributes and Methods: Inherited from SpotExecuteAPI and SpotQueryAPI.

class vertex_protocol.client.apis.BaseSpotAPI(context)[source]

Bases: VertexBaseAPI

Base class for Spot operations in the Vertex Protocol.

This class provides basic functionality for retrieving product-specific information from the spot market of the Vertex Protocol, such as the associated ERC20 token contract for a given spot product.

Attributes:

context (VertexClientContext): Provides connectivity details for accessing Vertex APIs.

Methods:

get_token_contract_for_product: Retrieves the associated ERC20 token contract for a given spot product.

get_token_contract_for_product(product_id)[source]

Retrieves the associated ERC20 token contract for a given spot product.

Return type:

Contract

Args:

product_id (int): The identifier for the spot product.

Returns:

Contract: The associated ERC20 token contract for the specified spot product.

Raises:

InvalidProductId: If the provided product ID is not valid.

class vertex_protocol.client.apis.SpotExecuteAPI(context)[source]

Bases: BaseSpotAPI

Class providing execution operations for the spot market in the Vertex Protocol.

This class provides functionality for executing transactions related to spot products, such as depositing a specified amount into a spot product.

Inheritance:

BaseSpotAPI: Base class for Spot operations. Inherits connectivity context and base functionalities.

deposit(params, signer=None)[source]

Executes the operation of depositing a specified amount into a spot product.

Return type:

str

Args:

params (DepositCollateralParams): Parameters required for depositing collateral.

signer (LocalAccount, optional): The account that will sign the deposit transaction. If no signer is provided, the signer set in the client context will be used.

Raises:

MissingSignerException: Raised when there is no signer provided and no signer set in the client context.

Returns:

str: The deposit collateral transaction hash.

withdraw(params)[source]

Executes a withdrawal for the specified spot product via the off-chain engine.

Return type:

ExecuteResponse

Args:

params (WithdrawCollateralParams): Parameters needed to execute the withdrawal.

Returns:

ExecuteResponse: The response from the engine execution.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

approve_allowance(product_id, amount, signer=None)[source]

Approves an allowance for a certain amount of tokens for a spot product.

Return type:

str

Args:

product_id (int): The identifier of the spot product for which to approve an allowance.

amount (int): The amount of the tokens to be approved.

signer (LocalAccount, optional): The account that will sign the approval transaction. If no signer is provided, the signer set in the client context will be used.

Returns:

str: The approve allowance transaction hash.

Raises:

MissingSignerException: Raised when there is no signer provided and no signer set in the client context. InvalidProductId: If the provided product ID is not valid.

class vertex_protocol.client.apis.SpotQueryAPI(context)[source]

Bases: BaseSpotAPI

Class providing querying operations for the spot market in the Vertex Protocol.

This class allows for retrieval of various kinds of information related to spot products, such as getting wallet token balance of a given spot product.

Inheritance:

BaseSpotAPI: Base class for Spot operations. Inherits connectivity context and base functionalities.

get_max_withdrawable(product_id, sender, spot_leverage=None)[source]

Retrieves the estimated maximum withdrawable amount for a provided spot product.

Return type:

MaxWithdrawableData

Args:

product_id (int): The identifier for the spot product.

sender (str): The address and subaccount identifier in a bytes32 hex string.

spot_leverage (Optional[bool]): If False, calculates max amount without considering leverage. Defaults to True.

Returns:

MaxWithdrawableData: The maximum withdrawable amount for the spot product.

get_token_wallet_balance(product_id, address)[source]

Retrieves the balance of a specific token in the user’s wallet (i.e. not in a Vertex subaccount)

Return type:

float

Args:

product_id (int): Identifier for the spot product.

address (str): User’s wallet address.

Returns:

float: The balance of the token in the user’s wallet in decimal form.

Raises:

InvalidProductId: If the provided product ID is not valid.

get_token_allowance(product_id, address)[source]

Retrieves the current token allowance of a specified spot product.

Return type:

float

Args:

product_id (int): Identifier for the spot product.

address (str): The user’s wallet address.

Returns:

float: The current token allowance of the user’s wallet address to the associated spot product.

Raises:

InvalidProductId: If the provided product ID is not valid.

class vertex_protocol.client.apis.SubaccountAPI(context)[source]

Bases: SubaccountExecuteAPI, SubaccountQueryAPI

A unified interface for subaccount operations in the Vertex Protocol.

This class combines functionalities from both SubaccountExecuteAPI and SubaccountQueryAPI into a single interface, providing a simpler and more consistent way to perform subaccount operations. It allows for both query (data retrieval) and execution (transaction) operations for subaccounts.

Inheritance:

SubaccountExecuteAPI: This provides functionalities to execute various operations related to subaccounts. These include actions like liquidating a subaccount or linking a signer to a subaccount.

SubaccountQueryAPI: This provides functionalities to retrieve various kinds of information related to subaccounts. These include operations like retrieving a summary of a subaccount’s state, retrieving the fee rates associated with a subaccount, querying token rewards for a wallet, and getting linked signer rate limits for a subaccount.

Attributes and Methods: Inherited from SubaccountExecuteAPI and SubaccountQueryAPI.

class vertex_protocol.client.apis.SubaccountExecuteAPI(context)[source]

Bases: VertexBaseAPI

Provides functionalities for executing operations related to subaccounts in the Vertex Protocol.

Inherits from VertexBaseAPI, which provides a basic context setup for accessing Vertex. This class extends the base class to provide specific functionalities for executing actions related to subaccounts.

The provided methods include: - liquidate_subaccount: Performs the liquidation of a subaccount. - link_signer: Links a signer to a subaccount, granting them transaction signing permissions.

Attributes:

context (VertexClientContext): Provides connectivity details for accessing Vertex APIs.

liquidate_subaccount(params)[source]

Liquidates a subaccount through the engine.

Return type:

ExecuteResponse

Args:

params (LiquidateSubaccountParams): Parameters for liquidating the subaccount.

Returns:

ExecuteResponse: Execution response from the engine.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

Links a signer to a subaccount to allow them to sign transactions on behalf of the subaccount.

Return type:

ExecuteResponse

Args:

params (LinkSignerParams): Parameters for linking a signer to a subaccount.

Returns:

ExecuteResponse: Execution response from the engine.

Raises:

Exception: If there is an error during the execution or the response status is not “success”.

class vertex_protocol.client.apis.SubaccountQueryAPI(context)[source]

Bases: VertexBaseAPI

Provides functionalities for querying data related to subaccounts in the Vertex Protocol.

Inherits from VertexBaseAPI, which provides a basic context setup for accessing Vertex Clearinghouse. This class extends the base class to provide specific functionalities for querying data related to subaccounts.

Attributes:

context (VertexClientContext): Provides connectivity details for accessing Vertex APIs.

get_engine_subaccount_summary(subaccount, txs=None)[source]

Retrieve a comprehensive summary of the specified subaccount’s state as per the off-chain engine.

You can optionally provide a list of txs to get an estimated view of your subaccount.

Return type:

SubaccountInfoData

Args:

subaccount (str): Unique identifier for the subaccount.

txs (list[QuerySubaccountInfoTx], optional): Optional list of transactions for the subaccount.

Returns:

SubaccountInfoData: A data class object containing detailed state information about the queried subaccount.

get_subaccount_fee_rates(subaccount)[source]

Retrieve the fee rates associated with a specific subaccount from the off-chain engine.

Return type:

FeeRatesData

Args:

subaccount (str): Unique identifier for the subaccount.

Returns:

FeeRatesData: A data class object containing detailed fee rates data for the specified subaccount.

get_subaccount_token_rewards(address)[source]

Query the $VRTX token rewards accumulated per epoch for a specified wallet from the indexer.

Return type:

IndexerTokenRewardsData

Args:

address (str): Wallet address to be queried.

Returns:

IndexerTokenRewardsData: A data class object containing detailed information about the accrued token rewards.

get_subaccount_linked_signer_rate_limits(subaccount)[source]

Retrieve the current linked signer and their rate limit for a specified subaccount from the indexer.

Return type:

IndexerLinkedSignerRateLimitData

Args:

subaccount (str): Unique identifier for the subaccount.

Returns:

IndexerLinkedSignerRateLimitData: A data class object containing information about the current linked signer and their rate limits for the queried subaccount.

get_referral_code(subaccount)[source]

Query the referral code for the specified wallet from the indexer.

Return type:

IndexerReferralCodeData

Args:

subaccount (str): Unique identifier for the subaccount.

Returns:

IndexerReferralCodeData: A data class object containing the wallet’s referral code.

get_subaccounts(address=None, start_idx=None, limit=None)[source]

List vertex subaccounts via the indexer.

Return type:

IndexerSubaccountsData

Args:

address (Optional[str]): An optional wallet address to find all subaccounts associated to it. start_idx (Optional[int]): Optional subaccount id to start from. Used for pagination. Defaults to 0. limit (Optional[int]): Maximum number of subaccounts to return. Defaults to 100. Max of 500.

Returns:

IndexerSubaccountsData: A data class object containing the list of subaccounts found.

class vertex_protocol.client.apis.PerpAPI(context)[source]

Bases: PerpQueryAPI

A unified interface for Perpetual (Perp) operations in the Vertex Protocol.

This class extends functionalities from PerpQueryAPI into a single interface, providing a simpler and more consistent way to perform Perp operations. Currently, it allows for querying (data retrieval) operations for Perp products.

Inheritance:

PerpQueryAPI: This provides functionalities to retrieve various kinds of information related to Perp products. These include operations like retrieving the latest index and mark price for a specific Perp product.

Attributes and Methods: Inherited from PerpQueryAPI.

class vertex_protocol.client.apis.PerpQueryAPI(context)[source]

Bases: VertexBaseAPI

Provides functionalities for querying data related to Perpetual (Perp) products in the Vertex Protocol.

Inherits from VertexBaseAPI, which provides a basic context setup for accessing Vertex. This class extends the base class to provide specific functionalities for querying data related to Perp products.

Attributes:

context (VertexClientContext): Provides connectivity details for accessing Vertex APIs.

get_prices(product_id)[source]

Retrieves the latest index and mark price for a specific perp product from the indexer.

Return type:

IndexerPerpPricesData

Args:

product_id (int): The identifier for the perp product.

Returns:
IndexerPerpPricesData: An object containing the latest index and mark price for the specified product.
  • product_id (int): The identifier for the perp product.

  • index_price_x18 (str): The latest index price for the product, scaled by 1e18.

  • mark_price_x18 (str): The latest mark price for the product, scaled by 1e18.

  • update_time (str): The timestamp of the last price update.

vertex-protocol.engine_client

class vertex_protocol.engine_client.EngineClient(opts)[source]

Bases: EngineQueryClient, EngineExecuteClient

Client for interacting with the engine service.

It allows users to both query data from and execute commands on the engine service.

Attributes:

opts (EngineClientOpts): Client configuration options for connecting and interacting with the engine service.

Methods:

__init__: Initializes the EngineClient with the provided options.

__init__(opts)[source]

Initializes the EngineClient with the provided options.

Args:

opts (EngineClientOpts): Client configuration options for connecting and interacting with the engine service.

class vertex_protocol.engine_client.EngineClientOpts(**data)[source]

Bases: BaseModel

Model defining the configuration options for the Engine Client. It includes various parameters such as the URL, the signer, the linked signer, the chain ID, and others.

Attributes:

url (AnyUrl): The URL of the server. signer (Optional[Signer]): The signer for the client, if any. It can either be a LocalAccount or a private key. linked_signer (Optional[Signer]): An optional signer linked the main subaccount to perform executes on it’s behalf. chain_id (Optional[int]): An optional network chain ID. endpoint_addr (Optional[str]): Vertex’s endpoint address used for verifying executes. book_addrs (Optional[list[str]]): Vertex’s book addresses used for verifying order placement.

Notes:
  • The class also includes several methods for validating and sanitizing the input values.

  • “linked_signer” cannot be set if “signer” is not set.

url: AnyUrl
signer: Union[LocalAccount, str, None]
linked_signer: Union[LocalAccount, str, None]
chain_id: Optional[int]
endpoint_addr: Optional[str]
book_addrs: Optional[list[str]]
class Config[source]

Bases: object

arbitrary_types_allowed = True
classmethod check_linked_signer(values)[source]

Validates that if a linked_signer is set, a signer must also be set.

Args:

values (dict): The input values to be validated.

Raises:

ValueError: If linked_signer is set but signer is not.

Returns:

dict: The validated values.

classmethod clean_url(v)[source]

Cleans the URL input by removing trailing slashes.

Return type:

str

Args:

v (AnyUrl): The input URL.

Returns:

str: The cleaned URL.

classmethod signer_to_local_account(v)[source]

Validates and converts the signer to a LocalAccount instance.

Return type:

Optional[LocalAccount]

Args:

v (Optional[Signer]): The signer instance or None.

Returns:

Optional[LocalAccount]: The LocalAccount instance or None.

classmethod linked_signer_to_local_account(v)[source]

Validates and converts the linked_signer to a LocalAccount instance.

Return type:

Optional[LocalAccount]

Args:

v (Optional[Signer]): The linked_signer instance or None.

Returns:

Optional[LocalAccount]: The LocalAccount instance or None.

class vertex_protocol.engine_client.EngineExecuteClient(opts, querier=None)[source]

Bases: object

Client class for executing operations against the off-chain engine.

__init__(opts, querier=None)[source]

Initialize the EngineExecuteClient with provided options.

Args:

opts (EngineClientOpts): Options for the client.

querier (EngineQueryClient, optional): An EngineQueryClient instance. If not provided, a new one is created.

tx_nonce()[source]

Get the transaction nonce. Used to perform executes such as withdraw_collateral.

Return type:

int

Returns:

int: The transaction nonce.

order_nonce(recv_time_ms=None)[source]

Generate the order nonce. Used for oder placements and cancellations.

Return type:

int

Args:

recv_time_ms (int, optional): Received time in milliseconds.

Returns:

int: The generated order nonce.

prepare_execute_params(params, use_order_nonce)[source]

Prepares the parameters for execution by ensuring that both owner and nonce are correctly set.

Args:

params (Type[BaseParams]): The original parameters.

Returns:

Type[BaseParams]: A copy of the original parameters with owner and nonce injected if needed.

execute(params)[source]

Executes the operation defined by the provided parameters.

Return type:

ExecuteResponse

Args:

params (ExecuteParams): The parameters for the operation to execute. This can represent a variety of operations, such as placing orders, cancelling orders, and more.

Returns:

ExecuteResponse: The response from the executed operation.

property endpoint_addr: str
property book_addrs: list[str]
property chain_id: int
property signer: LocalAccount
property linked_signer: LocalAccount
book_addr(product_id)[source]

Retrieves the book address corresponding to the provided product ID.

Needed for signing order placement executes for different products.

Return type:

str

Args:

product_id (int): The ID of the product.

Returns:

str: The book address associated with the given product ID.

Raises:

ValueError: If the provided product_id is greater than or equal to the number of book addresses available.

get_order_digest(order, product_id)[source]

Generates the order digest for a given order and product ID.

Return type:

str

Args:

order (OrderParams): The order parameters.

product_id (int): The ID of the product.

Returns:

str: The generated order digest.

build_digest(execute, msg, verifying_contract, chain_id)[source]

Build an EIP-712 compliant digest from given parameters.

Must provide the same input to build an EIP-712 typed data as the one provided for signing via .sign(…)

Return type:

str

Args:

execute (VertexExecuteType): The Vertex execute type to build digest for.

msg (dict): The EIP712 message.

verifying_contract (str): The contract used for verification.

chain_id (int): The network chain ID.

Returns:

str: The digest computed from the provided parameters.

sign(execute, msg, verifying_contract, chain_id, signer)[source]

Signs the EIP-712 typed data using the provided signer account.

Return type:

str

Args:

execute (VertexExecuteType): The type of operation.

msg (dict): The message to be signed.

verifying_contract (str): The contract used for verification.

chain_id (int): The network chain ID.

signer (LocalAccount): The account used to sign the data.

Returns:

str: The generated EIP-712 signature.

place_order(params)[source]

Execute a place order operation.

Return type:

ExecuteResponse

Args:

params (PlaceOrderParams): Parameters required for placing an order. The parameters include the order details and the product_id.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

place_market_order(params)[source]

Places an FOK order using top of the book price with provided slippage.

Return type:

ExecuteResponse

Args:

params (PlaceMarketOrderParams): Parameters required for placing a market order.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

cancel_orders(params)[source]

Execute a cancel orders operation.

Return type:

ExecuteResponse

Args:

params (CancelOrdersParams): Parameters required for canceling orders. The parameters include the order digests to be cancelled.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

cancel_product_orders(params)[source]

Execute a cancel product orders operation.

Return type:

ExecuteResponse

Args:

params (CancelProductOrdersParams): Parameters required for bulk canceling orders of specific products. The parameters include a list of product ids to bulk cancel orders for.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

cancel_and_place(params)[source]

Execute a cancel and place operation.

Return type:

ExecuteResponse

Args:

params (CancelAndPlaceParams): Parameters required for cancel and place.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

withdraw_collateral(params)[source]

Execute a withdraw collateral operation.

Return type:

ExecuteResponse

Args:

params (WithdrawCollateralParams): Parameters required for withdrawing collateral. The parameters include the collateral details.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

liquidate_subaccount(params)[source]

Execute a liquidate subaccount operation.

Return type:

ExecuteResponse

Args:

params (LiquidateSubaccountParams): Parameters required for liquidating a subaccount. The parameters include the liquidatee details.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

mint_lp(params)[source]

Execute a mint LP tokens operation.

Return type:

ExecuteResponse

Args:

params (MintLpParams): Parameters required for minting LP tokens. The parameters include the LP details.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

burn_lp(params)[source]

Execute a burn LP tokens operation.

Return type:

ExecuteResponse

Args:

params (BurnLpParams): Parameters required for burning LP tokens. The parameters include the LP details.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

Execute a link signer operation.

Return type:

ExecuteResponse

Args:

params (LinkSignerParams): Parameters required for linking a signer. The parameters include the signer details.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

close_position(subaccount, product_id)[source]

Execute a place order operation to close a position for the provided product_id.

Return type:

ExecuteResponse

Attributes:

subaccount (Subaccount): The subaccount to close position for. product_id (int): The ID of the product to close position for.

Returns:

ExecuteResponse: Response of the execution, including status and potential error message.

class vertex_protocol.engine_client.EngineQueryClient(opts)[source]

Bases: object

Client class for querying the off-chain engine.

__init__(opts)[source]

Initialize EngineQueryClient with provided options.

Args:

opts (EngineClientOpts): Options for the client.

query(req)[source]

Send a query to the engine.

Return type:

QueryResponse

Args:

req (QueryRequest): The query request parameters.

Returns:

QueryResponse: The response from the engine.

Raises:

BadStatusCodeException: If the response status code is not 200. QueryFailedException: If the query status is not “success”.

get_product_symbols()[source]

Retrieves symbols for all available products.

Return type:

list[ProductSymbol]

Returns:

ProductSymbolsData: Symbols for all available products.

get_status()[source]

Query the engine for its status.

Return type:

EngineStatus

Returns:

StatusData: The status of the engine.

get_contracts()[source]

Query the engine for Vertex contract addresses.

Use this to fetch verifying contracts needed for signing executes.

Return type:

ContractsData

Returns:

ContractsData: Vertex contracts info.

get_nonces(address)[source]

Query the engine for nonces of a specific address.

Return type:

NoncesData

Args:

address (str): Wallet address to fetch nonces for.

Returns:

NoncesData: The nonces of the address.

get_order(product_id, digest)[source]

Query the engine for an order with a specific product id and digest.

Return type:

OrderData

Args:

product_id (int): The id of the product.

digest (str): The digest of the order.

Returns:

OrderData: The order data.

get_subaccount_info(subaccount, txs=None)[source]

Query the engine for the state of a subaccount, including balances.

Return type:

SubaccountInfoData

Args:

subaccount (str): Identifier of the subaccount (owner’s address + subaccount name) sent as a hex string.

txs (list[QuerySubaccountInfoTx], optional): You can optionally provide a list of txs, to get an estimated view of what the subaccount state would look like if the transactions were applied.

Returns:

SubaccountInfoData: Information about the specified subaccount.

get_subaccount_open_orders(product_id, sender)[source]

Retrieves the open orders for a subaccount on a specific product.

Return type:

SubaccountOpenOrdersData

Args:

product_id (int): The identifier of the product for which open orders are to be fetched.

sender (str): Identifier of the subaccount (owner’s address + subaccount name) sent as a hex string.

Returns:

SubaccountOpenOrdersData: A data object containing the open orders for the specified subaccount on the provided product.

get_market_liquidity(product_id, depth)[source]

Query the engine for market liquidity data for a specific product.

Return type:

MarketLiquidityData

Args:

product_id (int): The id of the product.

depth (int): The depth of the market.

Returns:

MarketLiquidityData: Market liquidity data for the specified product.

get_symbols(product_type=None, product_ids=None)[source]

Query engine for symbols and product info

Return type:

SymbolsData

Args:

product_type (Optional[str): “spot” or “perp” products

product_ids (Optional[list[int]]): product_ids to return info for

get_all_products()[source]

Retrieves info about all available products, including: product id, oracle price, configuration, state, etc.

Return type:

AllProductsData

Returns:

AllProductsData: Data about all products.

get_market_price(product_id)[source]

Retrieves the highest bid and lowest ask price levels from the orderbook for a given product.

Return type:

MarketPriceData

Args:

product_id (int): The id of the product.

Returns:

MarketPriceData: Market price data for the specified product.

get_max_order_size(params)[source]

Retrieves the maximum order size of a given product for a specified subaccount.

Return type:

MaxOrderSizeData

Args:

params (QueryMaxOrderSizeParams): The parameters object that contains the details of the subaccount and product for which the max order size is to be fetched.

Returns:

MaxOrderSizeData: A data object containing the maximum order size possible for the given subaccount and product.

get_max_withdrawable(product_id, sender, spot_leverage=None)[source]

Retrieves the maximum withdrawable amount for a given spot product for a subaccount.

Return type:

MaxWithdrawableData

Args:

product_id (int): ID of the spot product.

sender (str): Identifier of the subaccount (owner’s address + subaccount name) sent as a hex string.

spot_leverage (bool, optional): If False, calculates without borrowing. Defaults to True.

Returns:

MaxWithdrawableData: Contains the maximum withdrawable amount.

get_max_lp_mintable(product_id, sender, spot_leverage=None)[source]

Retrieves the maximum LP token amount mintable for a given product for a subaccount.

Return type:

MaxLpMintableData

Args:

product_id (int): ID of the product.

sender (str): Identifier of the subaccount (owner’s address + subaccount name) sent as a hex string.

spot_leverage (bool, optional): If False, calculates without considering borrowing. Defaults to True.

Returns:

MaxLpMintableData: Contains the maximum LP token mintable amount.

get_fee_rates(sender)[source]

Retrieves the fee rates associated with a specific subaccount.

Return type:

FeeRatesData

Args:

sender (str): Identifier of the subaccount (owner’s address + subaccount name) sent as a hex string.

Returns:

FeeRatesData: Contains fee rates information associated with the subaccount.

get_health_groups()[source]

Retrieves all available health groups. A health group represents a set of perp and spot products whose health is calculated together, such as BTC and BTC-PERP.

Return type:

HealthGroupsData

Returns:

HealthGroupsData: Contains health group information, each including both a spot and a perp product.

get_linked_signer(subaccount)[source]

Retrieves the current linked signer for the specified subaccount.

Return type:

LinkedSignerData

Args:

subaccount (str): Identifier of the subaccount (owner’s address + subaccount name) sent as a hex string.

Returns:

LinkedSignerData: Information about the currently linked signer for the subaccount.

vertex-protocol.engine_client.types

class vertex_protocol.engine_client.types.BaseParams(**data)[source]

Bases: VertexBaseModel

Base class for defining request parameters to be sent to the Vertex API.

Attributes:

sender (Subaccount): The sender’s subaccount identifier. nonce (Optional[int]): An optional nonce for the request.

Note:
  • The sender attribute is validated and serialized to bytes32 format before sending the request.

sender: Union[str, bytes, SubaccountParams]
nonce: Optional[int]
class Config[source]

Bases: object

validate_assignment = True
classmethod serialize_sender(v)[source]

Validates and serializes the sender to bytes32 format.

Return type:

Union[bytes, str, SubaccountParams]

Args:

v (Subaccount): The sender’s subaccount identifier.

Returns:

(bytes|Subaccount): The serialized sender in bytes32 format or the original Subaccount if it cannot be converted to bytes32.

class vertex_protocol.engine_client.types.SignatureParams(**data)[source]

Bases: VertexBaseModel

Class for defining signature parameters in a request sent to the Vertex API.

Attributes:

signature (Optional[str]): An optional string representing the signature for the request.

signature: Optional[str]
class vertex_protocol.engine_client.types.BaseParamsSigned(**data)[source]

Bases: BaseParams, SignatureParams

Class that combines the base parameters and signature parameters for a signed request to the Vertex API. Inherits attributes from BaseParams and SignatureParams.

class vertex_protocol.engine_client.types.OrderParams(**data)[source]

Bases: MarketOrderParams

Class for defining the parameters of an order.

Attributes:

priceX18 (int): The price of the order with a precision of 18 decimal places.

expiration (int): The unix timestamp at which the order will expire.

amount (int): The amount of the asset to be bought or sold in the order. Positive for a long position and negative for a short.

nonce (Optional[int]): A unique number used to prevent replay attacks.

priceX18: int
expiration: int
class vertex_protocol.engine_client.types.PlaceOrderParams(**data)[source]

Bases: SignatureParams

Class for defining the parameters needed to place an order.

Attributes:

id (Optional[int]): An optional custom order id that is echoed back in subscription events e.g: fill orders, etc.

product_id (int): The id of the product for which the order is being placed.

order (OrderParams): The parameters of the order.

digest (Optional[str]): An optional hash of the order data.

spot_leverage (Optional[bool]): An optional flag indicating whether leverage should be used for the order. By default, leverage is assumed.

id: Optional[int]
product_id: int
order: OrderParams
digest: Optional[str]
spot_leverage: Optional[bool]
class vertex_protocol.engine_client.types.CancelOrdersParams(**data)[source]

Bases: BaseParamsSigned

Parameters to cancel specific orders.

Args:

productIds (list[int]): List of product IDs for the orders to be canceled.

digests (list[Digest]): List of digests of the orders to be canceled.

nonce (Optional[int]): A unique number used to prevent replay attacks.

Methods:

serialize_digests: Validates and converts a list of hex digests to bytes32.

productIds: list[int]
digests: list[Union[str, bytes]]
nonce: Optional[int]
classmethod serialize_digests(v)[source]
Return type:

list[bytes]

class vertex_protocol.engine_client.types.CancelProductOrdersParams(**data)[source]

Bases: BaseParamsSigned

Parameters to cancel all orders for specific products.

Args:

productIds (list[int]): List of product IDs for the orders to be canceled.

digest (str, optional): Optional EIP-712 digest of the CancelProductOrder request.

nonce (Optional[int]): A unique number used to prevent replay attacks.

productIds: list[int]
digest: Optional[str]
nonce: Optional[int]
class vertex_protocol.engine_client.types.CancelAndPlaceParams(**data)[source]

Bases: VertexBaseModel

Parameters to perform an order cancellation + order placement in the same request.

Args:

cancel_orders (CancelOrdersParams): Order cancellation object. place_order (PlaceOrderParams): Order placement object.

cancel_orders: CancelOrdersParams
place_order: PlaceOrderParams
class vertex_protocol.engine_client.types.WithdrawCollateralParams(**data)[source]

Bases: BaseParamsSigned

Parameters required to withdraw collateral from a specific product.

Attributes:

productId (int): The ID of the product to withdraw collateral from.

amount (int): The amount of collateral to be withdrawn.

spot_leverage (Optional[bool]): Indicates whether leverage is to be used. Defaults to True. If set to False, the transaction fails if it causes a borrow on the subaccount.

productId: int
amount: int
spot_leverage: Optional[bool]
class vertex_protocol.engine_client.types.LiquidateSubaccountParams(**data)[source]

Bases: BaseParamsSigned

Parameters required to liquidate a subaccount.

Attributes:

liquidatee (Subaccount): The subaccount that is to be liquidated.

productId (int): ID of product to liquidate.

isEncodedSpread (bool): When set to True, productId is expected to encode a perp and spot product Ids as follows: (perp_id << 16) | spot_id

amount (int): The amount to be liquidated.

Methods:

serialize_liquidatee(cls, v: Subaccount) -> bytes: Validates and converts the liquidatee subaccount to bytes32 format.

liquidatee: Union[str, bytes, SubaccountParams]
productId: int
isEncodedSpread: bool
amount: int
classmethod serialize_liquidatee(v)[source]
Return type:

bytes

class vertex_protocol.engine_client.types.MintLpParams(**data)[source]

Bases: BaseParamsSigned

Parameters required for minting a liquidity provider token for a specific product in a subaccount.

Attributes:

productId (int): The ID of the product.

amountBase (int): The amount of base to be consumed by minting LPs multiplied by 1e18.

quoteAmountLow (int): The minimum amount of quote to be consumed by minting LPs multiplied by 1e18.

quoteAmountHigh (int): The maximum amount of quote to be consumed by minting LPs multiplied by 1e18.

spot_leverage (Optional[bool]): Indicates whether leverage is to be used. Defaults to True. If set to False, the transaction fails if it causes a borrow on the subaccount.

productId: int
amountBase: int
quoteAmountLow: int
quoteAmountHigh: int
spot_leverage: Optional[bool]
class vertex_protocol.engine_client.types.BurnLpParams(**data)[source]

Bases: BaseParamsSigned

This class represents the parameters required to burn a liquidity provider token for a specific product in a subaccount.

Attributes:

productId (int): The ID of the product.

amount (int): Combined amount of base + quote to burn multiplied by 1e18.

productId: int
amount: int
class vertex_protocol.engine_client.types.LinkSignerParams(**data)[source]

Bases: BaseParamsSigned

This class represents the parameters required to link a signer to a subaccount.

Attributes:

signer (Subaccount): The subaccount to be linked.

Methods:

serialize_signer(cls, v: Subaccount) -> bytes: Validates and converts the subaccount to bytes32 format.

signer: Union[str, bytes, SubaccountParams]
classmethod serialize_signer(v)[source]
Return type:

bytes

class vertex_protocol.engine_client.types.TxRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a transaction request.

Attributes:

tx (dict): The transaction details.

signature (str): The signature for the transaction.

spot_leverage (Optional[bool]): Indicates whether leverage should be used. If set to false, it denotes no borrowing. Defaults to true.

digest (Optional[str]): The digest of the transaction.

Methods:

serialize: Validates and serializes the transaction parameters.

tx: dict
signature: str
spot_leverage: Optional[bool]
digest: Optional[str]
classmethod serialize(v)[source]

Validates and serializes the transaction parameters.

Return type:

dict

Args:

v (dict): The transaction parameters to be validated and serialized.

Raises:

ValueError: If the ‘nonce’ attribute is missing in the transaction parameters.

Returns:

dict: The validated and serialized transaction parameters.

class vertex_protocol.engine_client.types.PlaceOrderRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a request to place an order.

Attributes:

place_order (PlaceOrderParams): The parameters for the order to be placed.

Methods:

serialize: Validates and serializes the order parameters.

place_order: PlaceOrderParams
classmethod serialize(v)[source]
Return type:

PlaceOrderParams

class vertex_protocol.engine_client.types.CancelOrdersRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a cancel orders request.

Attributes:

cancel_orders (CancelOrdersParams): The parameters of the orders to be cancelled.

Methods:

serialize: Serializes ‘digests’ in ‘cancel_orders’ into their hexadecimal representation.

to_tx_request: Validates and converts ‘cancel_orders’ into a transaction request.

cancel_orders: CancelOrdersParams
classmethod serialize(v)[source]

Serializes ‘digests’ in ‘cancel_orders’ into their hexadecimal representation.

Return type:

CancelOrdersParams

Args:

v (CancelOrdersParams): The parameters of the orders to be cancelled.

Returns:

CancelOrdersParams: The ‘cancel_orders’ with serialized ‘digests’.

class vertex_protocol.engine_client.types.CancelProductOrdersRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a cancel product orders request.

Attributes:

cancel_product_orders (CancelProductOrdersParams): The parameters of the product orders to be cancelled.

Methods:

to_tx_request: Validates and converts ‘cancel_product_orders’ into a transaction request.

cancel_product_orders: CancelProductOrdersParams
class vertex_protocol.engine_client.types.CancelAndPlaceRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a cancel and place request.

Attributes:

cancel_and_place (CancelAndPlaceParams): Request parameters for engine cancel_and_place execution

cancel_and_place: CancelAndPlaceParams
classmethod serialize(v)[source]
Return type:

dict

class vertex_protocol.engine_client.types.WithdrawCollateralRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a withdraw collateral request.

Attributes:

withdraw_collateral (WithdrawCollateralParams): The parameters of the collateral to be withdrawn.

Methods:

serialize: Validates and converts the ‘amount’ attribute of ‘withdraw_collateral’ to string.

to_tx_request: Validates and converts ‘withdraw_collateral’ into a transaction request.

withdraw_collateral: WithdrawCollateralParams
classmethod serialize(v)[source]
Return type:

WithdrawCollateralParams

class vertex_protocol.engine_client.types.LiquidateSubaccountRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a liquidate subaccount request.

Attributes:

liquidate_subaccount (LiquidateSubaccountParams): The parameters for the subaccount to be liquidated.

Methods:

serialize: Validates and converts the ‘amount’ attribute and the ‘liquidatee’ attribute of ‘liquidate_subaccount’ to their proper serialized forms.

to_tx_request: Validates and converts ‘liquidate_subaccount’ into a transaction request.

liquidate_subaccount: LiquidateSubaccountParams
classmethod serialize(v)[source]
Return type:

LiquidateSubaccountParams

class vertex_protocol.engine_client.types.MintLpRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a mint LP request.

Attributes:

mint_lp (MintLpParams): The parameters for minting liquidity.

Methods:

serialize: Validates and converts the ‘amountBase’, ‘quoteAmountLow’, and ‘quoteAmountHigh’ attributes of ‘mint_lp’ to their proper serialized forms.

to_tx_request: Validates and converts ‘mint_lp’ into a transaction request.

mint_lp: MintLpParams
classmethod serialize(v)[source]
Return type:

MintLpParams

class vertex_protocol.engine_client.types.BurnLpRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a burn LP request.

Attributes:

burn_lp (BurnLpParams): The parameters for burning liquidity.

Methods:

serialize: Validates and converts the ‘amount’ attribute of ‘burn_lp’ to its proper serialized form.

to_tx_request: Validates and converts ‘burn_lp’ into a transaction request.

burn_lp: BurnLpParams
classmethod serialize(v)[source]
Return type:

BurnLpParams

class vertex_protocol.engine_client.types.LinkSignerRequest(**data)[source]

Bases: VertexBaseModel

Parameters for a request to link a signer to a subaccount.

Attributes:

link_signer (LinkSignerParams): Parameters including the subaccount to be linked.

Methods:

serialize: Validates and converts the ‘signer’ attribute of ‘link_signer’ into its hexadecimal representation.

to_tx_request: Validates and converts ‘link_signer’ into a transaction request.

classmethod serialize(v)[source]
Return type:

LinkSignerParams

class vertex_protocol.engine_client.types.ExecuteResponse(**data)[source]

Bases: VertexBaseModel

Represents the response returned from executing a request.

Attributes:

status (ResponseStatus): The status of the response.

signature (Optional[str]): The signature of the response. Only present if the request was successfully executed.

data (Optional[ExecuteResponseData]): Data returned from execute, not all executes currently return data.

error_code (Optional[int]): The error code, if any error occurred during the execution of the request.

error (Optional[str]): The error message, if any error occurred during the execution of the request.

request_type (Optional[str]): Type of the request.

req (Optional[dict]): The original request that was executed.

status: ResponseStatus
signature: Optional[str]
data: Union[PlaceOrderResponse, CancelOrdersResponse, None]
error_code: Optional[int]
error: Optional[str]
request_type: Optional[str]
req: Optional[dict]
class vertex_protocol.engine_client.types.EngineQueryType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Enumeration of the different types of engine queries.

STATUS = 'status'
CONTRACTS = 'contracts'
NONCES = 'nonces'
ORDER = 'order'
SYMBOLS = 'symbols'
ALL_PRODUCTS = 'all_products'
FEE_RATES = 'fee_rates'
HEALTH_GROUPS = 'health_groups'
LINKED_SIGNER = 'linked_signer'
MARKET_LIQUIDITY = 'market_liquidity'
MARKET_PRICE = 'market_price'
MAX_ORDER_SIZE = 'max_order_size'
MAX_WITHDRAWABLE = 'max_withdrawable'
MAX_LP_MINTABLE = 'max_lp_mintable'
SUBACCOUNT_INFO = 'subaccount_info'
SUBACCOUNT_ORDERS = 'subaccount_orders'
class vertex_protocol.engine_client.types.QueryStatusParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the status of the engine.

class vertex_protocol.engine_client.types.QueryContractsParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the Vertex contract addresses.

class vertex_protocol.engine_client.types.QueryNoncesParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the nonces associated with a specific address.

address: str
class vertex_protocol.engine_client.types.QueryOrderParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying a specific order using its product_id and digest.

product_id: int
digest: str
class vertex_protocol.engine_client.types.QuerySubaccountInfoParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the subaccount summary from engine, including balances.

subaccount: str
txs: Optional[list[Union[MintLpTx, BurnLpTx, ApplyDeltaTx]]]
class vertex_protocol.engine_client.types.QuerySubaccountOpenOrdersParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying open orders associated with a subaccount for a specific product.

product_id: int
sender: str
class vertex_protocol.engine_client.types.QueryMarketLiquidityParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the market liquidity for a specific product up to a defined depth.

product_id: int
depth: int
class vertex_protocol.engine_client.types.QueryAllProductsParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying all products available in the engine.

class vertex_protocol.engine_client.types.QueryMarketPriceParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the market price of a specific product.

product_id: int
class vertex_protocol.engine_client.types.QueryMaxOrderSizeParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the maximum order size for a specific product and a given sender.

sender: str
product_id: int
price_x18: str
direction: MaxOrderSizeDirection
spot_leverage: Optional[bool]
classmethod direction_to_str(v)[source]
Return type:

str

class vertex_protocol.engine_client.types.QueryMaxWithdrawableParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the maximum withdrawable amount for a specific product and a given sender.

sender: str
product_id: int
spot_leverage: Optional[bool]
class vertex_protocol.engine_client.types.QueryMaxLpMintableParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the maximum liquidity that can be minted by a specified sender for a specific product.

sender: str
product_id: int
spot_leverage: Optional[bool]
class vertex_protocol.engine_client.types.QueryFeeRatesParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the fee rates associated with a specified sender.

sender: str
class vertex_protocol.engine_client.types.QueryHealthGroupsParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the health groups in the engine.

class vertex_protocol.engine_client.types.QueryLinkedSignerParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying the signer linked to a specified subaccount.

subaccount: str
vertex_protocol.engine_client.types.StatusData

alias of EngineStatus

class vertex_protocol.engine_client.types.ContractsData(**data)[source]

Bases: VertexBaseModel

Data model for Vertex’s contract addresses.

chain_id: str
endpoint_addr: str
book_addrs: list[str]
class vertex_protocol.engine_client.types.NoncesData(**data)[source]

Bases: VertexBaseModel

Data model for nonce values for transactions and orders.

tx_nonce: str
order_nonce: str
class vertex_protocol.engine_client.types.OrderData(**data)[source]

Bases: VertexBaseModel

Data model for details of an order.

product_id: int
sender: str
price_x18: str
amount: str
expiration: str
nonce: str
unfilled_amount: str
digest: str
placed_at: str
class vertex_protocol.engine_client.types.SubaccountInfoData(**data)[source]

Bases: VertexBaseModel

Model for detailed info about a subaccount, including balances.

subaccount: str
exists: bool
healths: list[SubaccountHealth]
health_contributions: list[list[str]]
spot_count: int
perp_count: int
spot_balances: list[SpotProductBalance]
perp_balances: list[PerpProductBalance]
spot_products: list[SpotProduct]
perp_products: list[PerpProduct]
parse_subaccount_balance(product_id)[source]

Parses the balance of a subaccount for a given product.

Return type:

Union[SpotProductBalance, PerpProductBalance]

Args:

product_id (int): The ID of the product to lookup.

Returns:

Union[SpotProductBalance, PerpProductBalance]: The balance of the product in the subaccount.

Raises:

ValueError: If the product ID provided is not found.

class vertex_protocol.engine_client.types.SubaccountOpenOrdersData(**data)[source]

Bases: VertexBaseModel

Data model encapsulating open orders of a subaccount for a specific product.

sender: str
product_id: int
orders: list[OrderData]
class vertex_protocol.engine_client.types.MarketLiquidityData(**data)[source]

Bases: VertexBaseModel

Data model for market liquidity details.

bids: list[list]
asks: list[list]
timestamp: str
class vertex_protocol.engine_client.types.AllProductsData(**data)[source]

Bases: VertexBaseModel

Data model for all the products available.

spot_products: list[SpotProduct]
perp_products: list[PerpProduct]
class vertex_protocol.engine_client.types.MarketPriceData(**data)[source]

Bases: VertexBaseModel

Data model for the bid and ask prices of a specific product.

product_id: int
bid_x18: str
ask_x18: str
class vertex_protocol.engine_client.types.MaxOrderSizeData(**data)[source]

Bases: VertexBaseModel

Data model for the maximum order size.

max_order_size: str
class vertex_protocol.engine_client.types.MaxWithdrawableData(**data)[source]

Bases: VertexBaseModel

Data model for the maximum withdrawable amount.

max_withdrawable: str
class vertex_protocol.engine_client.types.MaxLpMintableData(**data)[source]

Bases: VertexBaseModel

Data model for the maximum liquidity that can be minted.

max_base_amount: str
max_quote_amount: str
class vertex_protocol.engine_client.types.FeeRatesData(**data)[source]

Bases: VertexBaseModel

Data model for various fee rates associated with transactions.

taker_fee_rates_x18: list[str]
maker_fee_rates_x18: list[str]
liquidation_sequencer_fee: str
health_check_sequencer_fee: str
taker_sequencer_fee: str
withdraw_sequencer_fees: list[str]
class vertex_protocol.engine_client.types.HealthGroupsData(**data)[source]

Bases: VertexBaseModel

Data model for health group IDs.

health_groups: list[list[int]]
class vertex_protocol.engine_client.types.LinkedSignerData(**data)[source]

Bases: VertexBaseModel

Data model for the signer linked to a subaccount.

linked_signer: str
class vertex_protocol.engine_client.types.QueryResponse(**data)[source]

Bases: VertexBaseModel

Represents a response to a query request.

Attributes:

status (ResponseStatus): The status of the query response.

data (Optional[QueryResponseData]): The data returned from the query, or an error message if the query failed.

error (Optional[str]): The error message, if any error occurred during the query.

error_code (Optional[int]): The error code, if any error occurred during the query.

request_type (Optional[str]): Type of the request.

status: ResponseStatus
data: Union[EngineStatus, ContractsData, NoncesData, OrderData, SubaccountInfoData, SubaccountOpenOrdersData, MarketLiquidityData, SymbolsData, AllProductsData, MarketPriceData, MaxOrderSizeData, MaxWithdrawableData, MaxLpMintableData, FeeRatesData, HealthGroupsData, LinkedSignerData, list[ProductSymbol], None]
error: Optional[str]
error_code: Optional[int]
request_type: Optional[str]
class vertex_protocol.engine_client.types.ResponseStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

SUCCESS = 'success'
FAILURE = 'failure'
class vertex_protocol.engine_client.types.EngineStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

ACTIVE = 'active'
FAILED = 'failed'
class vertex_protocol.engine_client.types.MintLp(**data)[source]

Bases: VertexBaseModel

product_id: int
subaccount: str
amount_base: str
quote_amount_low: str
quote_amount_high: str
class vertex_protocol.engine_client.types.BurnLp(**data)[source]

Bases: VertexBaseModel

product_id: int
subaccount: str
amount_lp: str
class vertex_protocol.engine_client.types.ApplyDelta(**data)[source]

Bases: VertexBaseModel

product_id: int
subaccount: str
amount_delta: str
v_quote_delta: str
class vertex_protocol.engine_client.types.MintLpTx(**data)[source]

Bases: VertexBaseModel

mint_lp: MintLp
class vertex_protocol.engine_client.types.BurnLpTx(**data)[source]

Bases: VertexBaseModel

burn_lp: BurnLp
class vertex_protocol.engine_client.types.ApplyDeltaTx(**data)[source]

Bases: VertexBaseModel

apply_delta: ApplyDelta
class vertex_protocol.engine_client.types.SubaccountHealth(**data)[source]

Bases: VertexBaseModel

assets: str
liabilities: str
health: str
class vertex_protocol.engine_client.types.SpotLpBalance(**data)[source]

Bases: VertexBaseModel

amount: str
class vertex_protocol.engine_client.types.SpotBalance(**data)[source]

Bases: VertexBaseModel

amount: str
last_cumulative_multiplier_x18: str
class vertex_protocol.engine_client.types.SpotProductBalance(**data)[source]

Bases: VertexBaseModel

product_id: int
lp_balance: SpotLpBalance
balance: SpotBalance
class vertex_protocol.engine_client.types.PerpLpBalance(**data)[source]

Bases: VertexBaseModel

amount: str
last_cumulative_funding_x18: str
class vertex_protocol.engine_client.types.PerpBalance(**data)[source]

Bases: VertexBaseModel

amount: str
v_quote_balance: str
last_cumulative_funding_x18: str
class vertex_protocol.engine_client.types.PerpProductBalance(**data)[source]

Bases: VertexBaseModel

product_id: int
lp_balance: PerpLpBalance
balance: PerpBalance
class vertex_protocol.engine_client.types.ProductRisk(**data)[source]

Bases: VertexBaseModel

long_weight_initial_x18: str
short_weight_initial_x18: str
long_weight_maintenance_x18: str
short_weight_maintenance_x18: str
large_position_penalty_x18: str
class vertex_protocol.engine_client.types.ProductBookInfo(**data)[source]

Bases: VertexBaseModel

size_increment: str
price_increment_x18: str
min_size: str
collected_fees: str
lp_spread_x18: str
class vertex_protocol.engine_client.types.BaseProduct(**data)[source]

Bases: VertexBaseModel

product_id: int
oracle_price_x18: str
risk: ProductRisk
book_info: ProductBookInfo
class vertex_protocol.engine_client.types.BaseProductLpState(**data)[source]

Bases: VertexBaseModel

supply: str
class vertex_protocol.engine_client.types.SpotProductConfig(**data)[source]

Bases: VertexBaseModel

token: str
interest_inflection_util_x18: str
interest_floor_x18: str
interest_small_cap_x18: str
interest_large_cap_x18: str
class vertex_protocol.engine_client.types.SpotProductState(**data)[source]

Bases: VertexBaseModel

cumulative_deposits_multiplier_x18: str
cumulative_borrows_multiplier_x18: str
total_deposits_normalized: str
total_borrows_normalized: str
class vertex_protocol.engine_client.types.SpotProductLpAmount(**data)[source]

Bases: VertexBaseModel

amount: str
last_cumulative_multiplier_x18: str
class vertex_protocol.engine_client.types.SpotProductLpState(**data)[source]

Bases: BaseProductLpState

quote: SpotProductLpAmount
base: SpotProductLpAmount
class vertex_protocol.engine_client.types.SpotProduct(**data)[source]

Bases: BaseProduct

config: SpotProductConfig
state: SpotProductState
lp_state: SpotProductLpState
class vertex_protocol.engine_client.types.PerpProductState(**data)[source]

Bases: VertexBaseModel

cumulative_funding_long_x18: str
cumulative_funding_short_x18: str
available_settle: str
open_interest: str
class vertex_protocol.engine_client.types.PerpProductLpState(**data)[source]

Bases: BaseProductLpState

last_cumulative_funding_x18: str
cumulative_funding_per_lp_x18: str
base: str
quote: str
class vertex_protocol.engine_client.types.PerpProduct(**data)[source]

Bases: BaseProduct

state: PerpProductState
lp_state: PerpProductLpState
class vertex_protocol.engine_client.types.MaxOrderSizeDirection(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

LONG = 'long'
SHORT = 'short'

vertex-protocol.indexer_client

class vertex_protocol.indexer_client.IndexerClient(opts)[source]

Bases: IndexerQueryClient

Client for interacting with the indexer service.

It provides methods for querying data from the indexer service.

Attributes:

opts (IndexerClientOpts): Client configuration options for connecting and interacting with the indexer service.

Methods:

__init__: Initializes the IndexerClient with the provided options.

__init__(opts)[source]

Initializes the IndexerClient with the provided options.

Args:

opts (IndexerClientOpts): Client configuration options for connecting and interacting with the indexer service.

class vertex_protocol.indexer_client.IndexerClientOpts(**data)[source]

Bases: BaseModel

Model representing the options for the Indexer Client

url: AnyUrl
classmethod clean_url(v)[source]
Return type:

str

class vertex_protocol.indexer_client.IndexerQueryClient(opts)[source]

Bases: object

Client for querying data from the indexer service.

Attributes:

_opts (IndexerClientOpts): Client configuration options for connecting and interacting with the indexer service. url (str): URL of the indexer service.

__init__(opts)[source]

Initializes the IndexerQueryClient with the provided options.

Args:

opts (IndexerClientOpts): Client configuration options for connecting and interacting with the indexer service.

query(params)[source]

Sends a query request to the indexer service and returns the response.

The query method is overloaded to accept either IndexerParams or a dictionary or IndexerRequest as the input parameters. Based on the type of the input, the appropriate internal method is invoked to process the query request.

Return type:

IndexerResponse

Args:

params (IndexerParams | dict | IndexerRequest): The parameters for the query request.

Returns:

IndexerResponse: The response from the indexer service.

get_subaccount_historical_orders(params)[source]

Retrieves the historical orders associated with a specific subaccount.

Return type:

IndexerHistoricalOrdersData

Args:

params (IndexerSubaccountHistoricalOrdersParams): The parameters specifying the subaccount for which to retrieve historical orders.

Returns:

IndexerHistoricalOrdersData: The historical orders associated with the specified subaccount.

get_historical_orders_by_digest(digests)[source]

Retrieves historical orders using their unique digests.

Return type:

IndexerHistoricalOrdersData

Args:

digests (list[str]): A list of order digests.

Returns:

IndexerHistoricalOrdersData: The historical orders corresponding to the provided digests.

get_matches(params)[source]

Retrieves match data based on provided parameters.

Return type:

IndexerMatchesData

Args:

params (IndexerMatchesParams): The parameters for the match data retrieval request.

Returns:

IndexerMatchesData: The match data corresponding to the provided parameters.

get_events(params)[source]

Retrieves event data based on provided parameters.

Return type:

IndexerEventsData

Args:

params (IndexerEventsParams): The parameters for the event data retrieval request.

Returns:

IndexerEventsData: The event data corresponding to the provided parameters.

get_subaccount_summary(subaccount, timestamp=None)[source]

Retrieves a summary of a specified subaccount at a certain timestamp.

Return type:

IndexerSubaccountSummaryData

Args:

subaccount (str): The identifier for the subaccount.

timestamp (int | None, optional): The timestamp for which to retrieve the subaccount summary. If not provided, the most recent summary is retrieved.

Returns:

IndexerSubaccountSummaryData: The summary of the specified subaccount at the provided timestamp.

get_product_snapshots(params)[source]

Retrieves snapshot data for specific products.

Return type:

IndexerProductSnapshotsData

Args:

params (IndexerProductSnapshotsParams): Parameters specifying the products for which to retrieve snapshot data.

Returns:

IndexerProductSnapshotsData: The product snapshot data corresponding to the provided parameters.

get_market_snapshots(params)[source]

Retrieves historical market snapshots.

Return type:

IndexerMarketSnapshotsData

Args:

params (IndexerMarketSnapshotsParams): Parameters specifying the historical market snapshot request.

Returns:

IndexerMarketSnapshotsData: The market snapshot data corresponding to the provided parameters.

get_candlesticks(params)[source]

Retrieves candlestick data based on provided parameters.

Return type:

IndexerCandlesticksData

Args:

params (IndexerCandlesticksParams): The parameters for retrieving candlestick data.

Returns:

IndexerCandlesticksData: The candlestick data corresponding to the provided parameters.

get_perp_funding_rate(product_id)[source]

Retrieves the funding rate data for a specific perp product.

Return type:

IndexerFundingRateData

Args:

product_id (int): The identifier of the perp product.

Returns:

IndexerFundingRateData: The funding rate data for the specified perp product.

get_perp_funding_rates(product_ids)[source]

Fetches the latest funding rates for a list of perp products.

Return type:

Dict[str, IndexerFundingRateData]

Args:

product_ids (list): List of identifiers for the perp products.

Returns:

dict: A dictionary mapping each product_id to its latest funding rate and related details.

get_perp_prices(product_id)[source]

Retrieves the price data for a specific perp product.

Return type:

IndexerPerpPricesData

Args:

product_id (int): The identifier of the perp product.

Returns:

IndexerPerpPricesData: The price data for the specified perp product.

get_oracle_prices(product_ids)[source]

Retrieves the oracle price data for specific products.

Return type:

IndexerOraclePricesData

Args:

product_ids (list[int]): A list of product identifiers.

Returns:

IndexerOraclePricesData: The oracle price data for the specified products.

get_token_rewards(address)[source]

Retrieves the token reward data for a specific address.

Return type:

IndexerTokenRewardsData

Args:

address (str): The address for which to retrieve token reward data.

Returns:

IndexerTokenRewardsData: The token reward data for the specified address.

get_maker_statistics(params)[source]

Retrieves maker statistics based on provided parameters.

Return type:

IndexerMakerStatisticsData

Args:

params (IndexerMakerStatisticsParams): The parameters for retrieving maker statistics.

Returns:

IndexerMakerStatisticsData: The maker statistics corresponding to the provided parameters.

get_liquidation_feed()[source]

Retrieves the liquidation feed data.

Return type:

list[IndexerLiquidatableAccount]

Returns:

IndexerLiquidationFeedData: The latest liquidation feed data.

get_linked_signer_rate_limits(subaccount)[source]

Retrieves the rate limits for a linked signer of a specific subaccount.

Return type:

IndexerLinkedSignerRateLimitData

Args:

subaccount (str): The identifier of the subaccount.

Returns:

IndexerLinkedSignerRateLimitData: The rate limits for the linked signer of the specified subaccount.

get_referral_code(subaccount)[source]

Retrieves the referral code for a given address.

Return type:

IndexerReferralCodeData

Args:

subaccount (str): Unique identifier for the subaccount.

Returns:

IndexerReferralCodeData: The referral code for the specific address.

get_subaccounts(params)[source]

Retrieves subaccounts via the indexer.

Return type:

IndexerSubaccountsData

Args:

params (IndexerSubaccountsParams): The filter parameters for retrieving subaccounts.

Returns:

IndexerSubaccountsData: List of subaccounts found.

get_usdc_price()[source]
Return type:

IndexerUsdcPriceData

vertex-protocol.indexer_client.types

class vertex_protocol.indexer_client.types.IndexerQueryType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Enumeration of query types available in the Indexer service.

ORDERS = 'orders'
MATCHES = 'matches'
EVENTS = 'events'
SUMMARY = 'summary'
PRODUCTS = 'products'
MARKET_SNAPSHOTS = 'market_snapshots'
CANDLESTICKS = 'candlesticks'
FUNDING_RATE = 'funding_rate'
FUNDING_RATES = 'funding_rates'
PERP_PRICES = 'price'
ORACLE_PRICES = 'oracle_price'
REWARDS = 'rewards'
MAKER_STATISTICS = 'maker_statistics'
LIQUIDATION_FEED = 'liquidation_feed'
LINKED_SIGNER_RATE_LIMIT = 'linked_signer_rate_limit'
REFERRAL_CODE = 'referral_code'
SUBACCOUNTS = 'subaccounts'
USDC_PRICE = 'usdc_price'
class vertex_protocol.indexer_client.types.IndexerBaseParams(**data)[source]

Bases: VertexBaseModel

Base parameters for the indexer queries.

idx: Optional[int]
max_time: Optional[int]
limit: Optional[int]
class Config[source]

Bases: object

allow_population_by_field_name = True
class vertex_protocol.indexer_client.types.IndexerSubaccountHistoricalOrdersParams(**data)[source]

Bases: IndexerBaseParams

Parameters for querying historical orders by subaccount.

subaccount: str
product_ids: Optional[list[int]]
class vertex_protocol.indexer_client.types.IndexerHistoricalOrdersByDigestParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying historical orders by digests.

digests: list[str]
class vertex_protocol.indexer_client.types.IndexerMatchesParams(**data)[source]

Bases: IndexerBaseParams

Parameters for querying matches.

subaccount: Optional[str]
product_ids: Optional[list[int]]
class vertex_protocol.indexer_client.types.IndexerEventsRawLimit(**data)[source]

Bases: VertexBaseModel

Parameters for limiting by events count.

raw: int
class vertex_protocol.indexer_client.types.IndexerEventsTxsLimit(**data)[source]

Bases: VertexBaseModel

Parameters for limiting events by transaction count.

txs: int
class vertex_protocol.indexer_client.types.IndexerEventsParams(**data)[source]

Bases: IndexerBaseParams

Parameters for querying events.

subaccount: Optional[str]
product_ids: Optional[list[int]]
event_types: Optional[list[IndexerEventType]]
limit: Union[IndexerEventsRawLimit, IndexerEventsTxsLimit, None]
class vertex_protocol.indexer_client.types.IndexerSubaccountSummaryParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying subaccount summary.

subaccount: str
timestamp: Optional[int]
class vertex_protocol.indexer_client.types.IndexerProductSnapshotsParams(**data)[source]

Bases: IndexerBaseParams

Parameters for querying product snapshots.

product_id: int
class vertex_protocol.indexer_client.types.IndexerCandlesticksParams(**data)[source]

Bases: IndexerBaseParams

Parameters for querying candlestick data.

product_id: int
granularity: IndexerCandlesticksGranularity
class Config[source]

Bases: object

fields = {'idx': {'exclude': True}}
class vertex_protocol.indexer_client.types.IndexerFundingRateParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying funding rates.

product_id: int
class vertex_protocol.indexer_client.types.IndexerPerpPricesParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying perpetual prices.

product_id: int
class vertex_protocol.indexer_client.types.IndexerOraclePricesParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying oracle prices.

product_ids: list[int]
class vertex_protocol.indexer_client.types.IndexerTokenRewardsParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying token rewards.

address: str
class vertex_protocol.indexer_client.types.IndexerMakerStatisticsParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying maker statistics.

product_id: int
epoch: int
interval: int
class vertex_protocol.indexer_client.types.IndexerLiquidationFeedParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying liquidation feed.

class vertex_protocol.indexer_client.types.IndexerLinkedSignerRateLimitParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying linked signer rate limits.

subaccount: str
class vertex_protocol.indexer_client.types.IndexerReferralCodeParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying a referral code.

subaccount: str
class vertex_protocol.indexer_client.types.IndexerSubaccountsParams(**data)[source]

Bases: VertexBaseModel

Parameters for querying subaccounts.

address: Optional[str]
limit: Optional[int]
start: Optional[int]
class vertex_protocol.indexer_client.types.IndexerHistoricalOrdersRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying historical orders.

orders: Union[IndexerSubaccountHistoricalOrdersParams, IndexerHistoricalOrdersByDigestParams]
class vertex_protocol.indexer_client.types.IndexerMatchesRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying matches.

matches: IndexerMatchesParams
class vertex_protocol.indexer_client.types.IndexerEventsRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying events.

events: IndexerEventsParams
class vertex_protocol.indexer_client.types.IndexerSubaccountSummaryRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying subaccount summary.

summary: IndexerSubaccountSummaryParams
class vertex_protocol.indexer_client.types.IndexerProductSnapshotsRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying product snapshots.

products: IndexerProductSnapshotsParams
class vertex_protocol.indexer_client.types.IndexerCandlesticksRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying candlestick data.

candlesticks: IndexerCandlesticksParams
class vertex_protocol.indexer_client.types.IndexerFundingRateRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying funding rates.

funding_rate: IndexerFundingRateParams
class vertex_protocol.indexer_client.types.IndexerFundingRatesRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying funding rates.

funding_rates: IndexerFundingRatesParams
class vertex_protocol.indexer_client.types.IndexerPerpPricesRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying perpetual prices.

price: IndexerPerpPricesParams
class vertex_protocol.indexer_client.types.IndexerOraclePricesRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying oracle prices.

oracle_price: IndexerOraclePricesParams
class vertex_protocol.indexer_client.types.IndexerTokenRewardsRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying token rewards.

rewards: IndexerTokenRewardsParams
class vertex_protocol.indexer_client.types.IndexerMakerStatisticsRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying maker statistics.

maker_statistics: IndexerMakerStatisticsParams
class vertex_protocol.indexer_client.types.IndexerLiquidationFeedRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying liquidation feed.

liquidation_feed: IndexerLiquidationFeedParams
class vertex_protocol.indexer_client.types.IndexerLinkedSignerRateLimitRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying linked signer rate limits.

linked_signer_rate_limit: IndexerLinkedSignerRateLimitParams
class vertex_protocol.indexer_client.types.IndexerReferralCodeRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying a referral code.

referral_code: IndexerReferralCodeParams
class vertex_protocol.indexer_client.types.IndexerSubaccountsRequest(**data)[source]

Bases: VertexBaseModel

Request object for querying subaccounts.

subaccounts: IndexerSubaccountsParams
class vertex_protocol.indexer_client.types.IndexerHistoricalOrdersData(**data)[source]

Bases: VertexBaseModel

Data object for historical orders.

orders: list[IndexerHistoricalOrder]
class vertex_protocol.indexer_client.types.IndexerMatchesData(**data)[source]

Bases: VertexBaseModel

Data object for matches.

matches: list[IndexerMatch]
txs: list[IndexerTx]
class vertex_protocol.indexer_client.types.IndexerEventsData(**data)[source]

Bases: VertexBaseModel

Data object for events.

events: list[IndexerEvent]
txs: list[IndexerTx]
class vertex_protocol.indexer_client.types.IndexerSubaccountSummaryData(**data)[source]

Bases: VertexBaseModel

Data object for subaccount summary.

events: list[IndexerEvent]
class vertex_protocol.indexer_client.types.IndexerProductSnapshotsData(**data)[source]

Bases: VertexBaseModel

Data object for product snapshots.

products: list[IndexerProduct]
txs: list[IndexerTx]
class vertex_protocol.indexer_client.types.IndexerCandlesticksData(**data)[source]

Bases: VertexBaseModel

Data object for candlestick data.

candlesticks: list[IndexerCandlestick]
class vertex_protocol.indexer_client.types.IndexerFundingRateData(**data)[source]

Bases: VertexBaseModel

Data object for funding rates.

product_id: int
funding_rate_x18: str
update_time: str
class vertex_protocol.indexer_client.types.IndexerPerpPricesData(**data)[source]

Bases: VertexBaseModel

Data object for perpetual prices.

product_id: int
index_price_x18: str
mark_price_x18: str
update_time: str
class vertex_protocol.indexer_client.types.IndexerOraclePricesData(**data)[source]

Bases: VertexBaseModel

Data object for oracle prices.

prices: list[IndexerOraclePrice]
class vertex_protocol.indexer_client.types.IndexerTokenRewardsData(**data)[source]

Bases: VertexBaseModel

Data object for token rewards.

rewards: list[IndexerTokenReward]
update_time: str
total_referrals: str
class vertex_protocol.indexer_client.types.IndexerMakerStatisticsData(**data)[source]

Bases: VertexBaseModel

Data object for maker statistics.

reward_coefficient: float
makers: list[IndexerMarketMaker]
class vertex_protocol.indexer_client.types.IndexerLinkedSignerRateLimitData(**data)[source]

Bases: VertexBaseModel

Data object for linked signer rate limits.

remaining_tx: str
total_tx_limit: str
wait_time: int
signer: str
class vertex_protocol.indexer_client.types.IndexerReferralCodeData(**data)[source]

Bases: VertexBaseModel

Data object for referral codes.

referral_code: str
class vertex_protocol.indexer_client.types.IndexerSubaccountsData(**data)[source]

Bases: VertexBaseModel

Data object for subaccounts response from the indexer.

subaccounts: list[IndexerSubaccount]
class vertex_protocol.indexer_client.types.IndexerResponse(**data)[source]

Bases: VertexBaseModel

Represents the response returned by the indexer.

Attributes:

data (IndexerResponseData): The data contained in the response.

data: Union[IndexerHistoricalOrdersData, IndexerMatchesData, IndexerEventsData, IndexerSubaccountSummaryData, IndexerProductSnapshotsData, IndexerCandlesticksData, IndexerFundingRateData, IndexerPerpPricesData, IndexerOraclePricesData, IndexerTokenRewardsData, IndexerMakerStatisticsData, IndexerLinkedSignerRateLimitData, IndexerReferralCodeData, IndexerSubaccountsData, IndexerUsdcPriceData, IndexerMarketSnapshotsData, list[IndexerLiquidatableAccount], Dict[str, IndexerFundingRateData]]
class vertex_protocol.indexer_client.types.IndexerEventType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

LIQUIDATE_SUBACCOUNT = 'liquidate_subaccount'
DEPOSIT_COLLATERAL = 'deposit_collateral'
WITHDRAW_COLLATERAL = 'withdraw_collateral'
SETTLE_PNL = 'settle_pnl'
MATCH_ORDERS = 'match_orders'
MINT_LP = 'mint_lp'
BURN_LP = 'burn_lp'
MANUAL_ASSERT = 'manual_assert'
class vertex_protocol.indexer_client.types.IndexerCandlesticksGranularity(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ONE_MINUTE = 60
FIVE_MINUTES = 300
FIFTEEN_MINUTES = 900
ONE_HOUR = 3600
TWO_HOURS = 7200
FOUR_HOURS = 14400
ONE_DAY = 86400
ONE_WEEK = 604800
FOUR_WEEKS = 2419200
class vertex_protocol.indexer_client.types.IndexerBaseModel(**data)[source]

Bases: VertexBaseModel

submission_idx: str
timestamp: Optional[str]
class vertex_protocol.indexer_client.types.IndexerBaseOrder(**data)[source]

Bases: VertexBaseModel

sender: str
priceX18: str
amount: str
expiration: Union[str, int]
nonce: Union[str, int]
class vertex_protocol.indexer_client.types.IndexerOrderFill(**data)[source]

Bases: IndexerBaseModel

digest: str
base_filled: str
quote_filled: str
fee: str
class vertex_protocol.indexer_client.types.IndexerHistoricalOrder(**data)[source]

Bases: IndexerOrderFill

subaccount: str
product_id: int
amount: str
price_x18: str
expiration: str
nonce: str
class vertex_protocol.indexer_client.types.IndexerSignedOrder(**data)[source]

Bases: VertexBaseModel

order: IndexerBaseOrder
signature: str
class vertex_protocol.indexer_client.types.IndexerMatch(**data)[source]

Bases: IndexerOrderFill

order: IndexerBaseOrder
cumulative_fee: str
cumulative_base_filled: str
cumulative_quote_filled: str
class vertex_protocol.indexer_client.types.IndexerMatchOrdersTxData(**data)[source]

Bases: VertexBaseModel

product_id: int
amm: bool
taker: IndexerSignedOrder
maker: IndexerSignedOrder
class vertex_protocol.indexer_client.types.IndexerMatchOrdersTx(**data)[source]

Bases: VertexBaseModel

match_orders: IndexerMatchOrdersTxData
class vertex_protocol.indexer_client.types.IndexerWithdrawCollateralTxData(**data)[source]

Bases: VertexBaseModel

sender: str
product_id: int
amount: str
nonce: int
class vertex_protocol.indexer_client.types.IndexerWithdrawCollateralTx(**data)[source]

Bases: VertexBaseModel

withdraw_collateral: IndexerWithdrawCollateralTxData
class vertex_protocol.indexer_client.types.IndexerLiquidateSubaccountTxData(**data)[source]

Bases: VertexBaseModel

sender: str
liquidatee: str
mode: int
health_group: int
amount: str
nonce: int
class vertex_protocol.indexer_client.types.IndexerLiquidateSubaccountTx(**data)[source]

Bases: VertexBaseModel

liquidate_subaccount: IndexerLiquidateSubaccountTxData
class vertex_protocol.indexer_client.types.IndexerMintLpTxData(**data)[source]

Bases: VertexBaseModel

sender: str
product_id: int
amount_base: str
quote_amount_low: str
quote_amount_high: str
nonce: int
class vertex_protocol.indexer_client.types.IndexerMintLpTx(**data)[source]

Bases: VertexBaseModel

mint_lp: IndexerMintLpTxData
class vertex_protocol.indexer_client.types.IndexerBurnLpTxData(**data)[source]

Bases: VertexBaseModel

sender: str
product_id: int
amount: str
nonce: int
class vertex_protocol.indexer_client.types.IndexerBurnLpTx(**data)[source]

Bases: VertexBaseModel

burn_lp: IndexerBurnLpTxData
class vertex_protocol.indexer_client.types.IndexerTx(**data)[source]

Bases: IndexerBaseModel

tx: Union[IndexerMatchOrdersTx, IndexerWithdrawCollateralTx, IndexerLiquidateSubaccountTx, IndexerMintLpTx, IndexerBurnLpTx, Any]
class vertex_protocol.indexer_client.types.IndexerSpotProductBalanceData(**data)[source]

Bases: VertexBaseModel

spot: SpotProductBalance
class vertex_protocol.indexer_client.types.IndexerSpotProductData(**data)[source]

Bases: VertexBaseModel

spot: SpotProduct
class vertex_protocol.indexer_client.types.IndexerPerpProductData(**data)[source]

Bases: VertexBaseModel

perp: PerpProduct
class vertex_protocol.indexer_client.types.IndexerEventTrackedData(**data)[source]

Bases: VertexBaseModel

net_interest_unrealized: str
net_interest_cumulative: str
net_funding_unrealized: str
net_funding_cumulative: str
net_entry_unrealized: str
net_entry_cumulative: str
net_entry_lp_unrealized: str
net_entry_lp_cumulative: str
class vertex_protocol.indexer_client.types.IndexerEvent(**data)[source]

Bases: IndexerBaseModel, IndexerEventTrackedData

subaccount: str
product_id: int
event_type: IndexerEventType
product: Union[IndexerSpotProductData, IndexerPerpProductData]
pre_balance: Union[IndexerSpotProductBalanceData, IndexerPerpProductBalanceData]
post_balance: Union[IndexerSpotProductBalanceData, IndexerPerpProductBalanceData]
class vertex_protocol.indexer_client.types.IndexerProduct(**data)[source]

Bases: IndexerBaseModel

product_id: int
product: Union[IndexerSpotProductData, IndexerPerpProductData]
class vertex_protocol.indexer_client.types.IndexerCandlestick(**data)[source]

Bases: IndexerBaseModel

product_id: int
granularity: int
open_x18: str
high_x18: str
low_x18: str
close_x18: str
volume: str
class vertex_protocol.indexer_client.types.IndexerOraclePrice(**data)[source]

Bases: VertexBaseModel

product_id: int
oracle_price_x18: str
update_time: str
class vertex_protocol.indexer_client.types.IndexerAddressReward(**data)[source]

Bases: VertexBaseModel

product_id: int
q_score: str
sum_q_min: str
uptime: int
maker_volume: str
taker_volume: str
maker_fee: str
taker_fee: str
maker_tokens: str
taker_tokens: str
taker_referral_tokens: str
rebates: str
class vertex_protocol.indexer_client.types.IndexerGlobalRewards(**data)[source]

Bases: VertexBaseModel

product_id: int
reward_coefficient: str
q_scores: str
maker_volumes: str
taker_volumes: str
maker_fees: str
taker_fees: str
maker_tokens: str
taker_tokens: str
class vertex_protocol.indexer_client.types.IndexerTokenReward(**data)[source]

Bases: VertexBaseModel

epoch: int
start_time: str
period: str
address_rewards: list[IndexerAddressReward]
global_rewards: list[IndexerGlobalRewards]
class vertex_protocol.indexer_client.types.IndexerMarketMakerData(**data)[source]

Bases: VertexBaseModel

timestamp: str
maker_fee: str
uptime: str
sum_q_min: str
q_score: str
maker_share: str
expected_maker_reward: str
class vertex_protocol.indexer_client.types.IndexerMarketMaker(**data)[source]

Bases: VertexBaseModel

address: str
data: list[IndexerMarketMakerData]
class vertex_protocol.indexer_client.types.IndexerLiquidatableAccount(**data)[source]

Bases: VertexBaseModel

subaccount: str
update_time: int
class vertex_protocol.indexer_client.types.IndexerSubaccount(**data)[source]

Bases: VertexBaseModel

id: str
subaccount: str
class vertex_protocol.indexer_client.types.IndexerUsdcPriceData(**data)[source]

Bases: VertexBaseModel

Data object for the usdc price response from the indexer.

price_x18: str

vertex-protocol.contracts

class vertex_protocol.contracts.VertexContractsContext(**data)[source]

Bases: BaseModel

Holds the context for various Vertex contracts.

Attributes:

endpoint_addr (str): The endpoint address.

querier_addr (str): The querier address.

spot_engine_addr (Optional[str]): The spot engine address. This may be None.

perp_engine_addr (Optional[str]): The perp engine address. This may be None.

clearinghouse_addr (Optional[str]): The clearinghouse address. This may be None.

network: Optional[VertexNetwork]
endpoint_addr: str
querier_addr: str
spot_engine_addr: Optional[str]
perp_engine_addr: Optional[str]
clearinghouse_addr: Optional[str]
class vertex_protocol.contracts.VertexContracts(node_url, contracts_context)[source]

Bases: object

Encapsulates the set of Vertex contracts required for querying and executing.

__init__(node_url, contracts_context)[source]

Initialize a VertexContracts instance.

This will set up the Web3 instance and contract addresses for querying and executing the Vertex contracts. It will also load and parse the ABI for the given contracts.

Args:

node_url (str): The Ethereum node URL.

contracts_context (VertexContractsContext): The Vertex contracts context, holding the relevant addresses.

network: Optional[VertexNetwork]
w3: Web3
contracts_context: VertexContractsContext
querier: Contract
endpoint: Contract
clearinghouse: Optional[Contract]
spot_engine: Optional[Contract]
perp_engine: Optional[Contract]
deposit_collateral(params, signer)[source]

Deposits a specified amount of collateral into a spot product.

Return type:

str

Args:

params (DepositCollateralParams): The parameters for depositing collateral.

signer (LocalAccount): The account that will sign the deposit transaction.

Returns:

str: The transaction hash of the deposit operation.

approve_allowance(erc20, amount, signer)[source]

Approves a specified amount of allowance for the ERC20 token contract.

Args:

erc20 (Contract): The ERC20 token contract.

amount (int): The amount of the ERC20 token to be approved.

signer (LocalAccount): The account that will sign the approval transaction.

Returns:

str: The transaction hash of the approval operation.

get_token_contract_for_product(product_id)[source]

Returns the ERC20 token contract for a given product.

Return type:

Contract

Args:

product_id (int): The ID of the product for which to get the ERC20 token contract.

Returns:

Contract: The ERC20 token contract for the specified product.

Raises:

InvalidProductId: If the provided product ID is not valid.

execute(func, signer)[source]

Executes a smart contract function.

This method builds a transaction for a given contract function, signs the transaction with the provided signer’s private key, sends the raw signed transaction to the network, and waits for the transaction to be mined.

Return type:

str

Args:

func (ContractFunction): The contract function to be executed.

signer (LocalAccount): The local account object that will sign the transaction. It should contain the private key.

Returns:

str: The hexadecimal representation of the transaction hash.

Raises:

ValueError: If the transaction is invalid, the method will not catch the error. TimeExhausted: If the transaction receipt isn’t available within the timeout limit set by the Web3 provider.

class vertex_protocol.contracts.DepositCollateralParams(**data)[source]

Bases: VertexBaseModel

Class representing parameters for depositing collateral in the Vertex protocol.

Attributes:

subaccount_name (str): The name of the subaccount.

product_id (int): The ID of the spot product to deposit collateral for.

amount (int): The amount of collateral to be deposited.

referral_code (Optional[str]): Use this to indicate you were referred by existing member.

subaccount_name: str
product_id: int
amount: int
referral_code: Optional[str]
class vertex_protocol.contracts.VertexExecuteType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Enumeration of possible actions to execute in Vertex.

PLACE_ORDER = 'place_order'
CANCEL_ORDERS = 'cancel_orders'
CANCEL_PRODUCT_ORDERS = 'cancel_product_orders'
CANCEL_AND_PLACE = 'cancel_and_place'
WITHDRAW_COLLATERAL = 'withdraw_collateral'
LIQUIDATE_SUBACCOUNT = 'liquidate_subaccount'
MINT_LP = 'mint_lp'
BURN_LP = 'burn_lp'
class vertex_protocol.contracts.VertexNetwork(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Enumeration representing various network environments for the Vertex protocol.

ARBITRUM_ONE = 'arbitrumOne'
BLAST_MAINNET = 'blastMainnet'
ARBITRUM_SEPOLIA = 'arbitrumSepolia'
HARDHAT = 'localhost'
TESTING = 'test'
class vertex_protocol.contracts.VertexAbiName(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Enumeration representing various contract names for which the ABI can be loaded in the Vertex protocol.

ENDPOINT = 'Endpoint'
FQUERIER = 'FQuerier'
ICLEARINGHOUSE = 'IClearinghouse'
IENDPOINT = 'IEndpoint'
IOFFCHAIN_BOOK = 'IOffchainBook'
IPERP_ENGINE = 'IPerpEngine'
ISPOT_ENGINE = 'ISpotEngine'
MOCK_ERC20 = 'MockERC20'
class vertex_protocol.contracts.VertexDeployment(**data)[source]

Bases: VertexBaseModel

Class representing deployment data for Vertex protocol contracts.

Attributes:

node_url (AnyUrl): The URL of the node.

quote_addr (str): The address of the quote contract.

querier_addr (str): The address of the querier contract.

clearinghouse_addr (str): The address of the clearinghouse contract.

endpoint_addr (str): The address of the endpoint contract.

spot_engine_addr (str): The address of the spot engine contract.

perp_engine_addr (str): The address of the perpetual engine contract.

node_url: AnyUrl
quote_addr: str
querier_addr: str
clearinghouse_addr: str
endpoint_addr: str
spot_engine_addr: str
perp_engine_addr: str

vertex-protocol.contracts.eip712

vertex_protocol.contracts.eip712.get_vertex_eip712_domain(verifying_contract, chain_id)[source]

Util to create an EIP712Domain instance specific to Vertex.

Return type:

EIP712Domain

Args:

verifying_contract (str): The address of the contract that will verify the EIP-712 signature.

chain_id (int): The chain ID of the originating network.

Returns:

EIP712Domain: An instance of EIP712Domain with name set to “Vertex”, version “0.0.1”, and the provided verifying contract and chain ID.

vertex_protocol.contracts.eip712.get_eip712_domain_type()[source]

Util to return the structure of an EIP712Domain as per EIP-712.

Return type:

list[dict[str, str]]

Returns:

dict: A list of dictionaries each containing the name and type of a field in EIP712Domain.

vertex_protocol.contracts.eip712.build_eip712_typed_data(execute, msg, verifying_contract, chain_id)[source]

Util to build EIP712 typed data for Vertex execution.

Return type:

EIP712TypedData

Args:

execute (VertexExecuteType): The Vertex execute type being signed.

msg (dict): The message being signed.

verifying_contract (str): The contract that will verify the signature.

chain_id (int): The chain ID of the originating network.

Returns:

EIP712TypedData: A structured data object that adheres to the EIP-712 standard.

vertex_protocol.contracts.eip712.get_eip712_typed_data_digest(typed_data)[source]

Util to get the EIP-712 typed data hash.

Return type:

str

Args:

typed_data (EIP712TypedData): The EIP-712 typed data to hash.

Returns:

str: The hexadecimal representation of the hash.

vertex_protocol.contracts.eip712.sign_eip712_typed_data(typed_data, signer)[source]

Util to sign EIP-712 typed data using a local Ethereum account.

Return type:

str

Args:

typed_data (EIP712TypedData): The EIP-712 typed data to sign.

signer (LocalAccount): The local Ethereum account to sign the data.

Returns:

str: The hexadecimal representation of the signature.

vertex_protocol.contracts.eip712.get_vertex_eip712_type(execute)[source]

Util that provides the EIP712 type information for Vertex execute types.

Return type:

dict

Args:

execute (VertexExecuteType): The Vertex execute type for which to retrieve EIP712 type information.

Returns:

dict: A dictionary containing the EIP712 type information for the given execute type.

class vertex_protocol.contracts.eip712.EIP712Domain(**data)[source]

Bases: BaseModel

Model that represents the EIP-712 Domain data structure.

Attributes:

name (str): The user-readable name of the signing domain, i.e., the name of the DApp or the protocol. version (str): The current major version of the signing domain. Signatures from different versions are not compatible. chainId (int): The chain ID of the originating network. verifyingContract (str): The address of the contract that will verify the signature.

name: str
version: str
chainId: int
verifyingContract: str
class vertex_protocol.contracts.eip712.EIP712Types(**data)[source]

Bases: BaseModel

Util to encapsulate the EIP-712 type data structure.

Attributes:

EIP712Domain (list[dict]): A list of dictionaries representing EIP-712 Domain data.

EIP712Domain: list[dict]
class Config[source]

Bases: object

arbitrary_types_allowed = True
extra = 'allow'
class vertex_protocol.contracts.eip712.EIP712TypedData(**data)[source]

Bases: BaseModel

Util to represent the EIP-712 Typed Data structure.

Attributes:

types (EIP712Types): EIP-712 type data. primaryType (str): The primary type for EIP-712 message signing. domain (EIP712Domain): The domain data of the EIP-712 typed message. message (dict): The actual data to sign.

types: EIP712Types
primaryType: str
domain: EIP712Domain
message: dict

vertex-protocol.utils

class vertex_protocol.utils.VertexBackendURL(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Enum representing different Vertex backend URLs.

SEPOLIA_TESTNET_GATEWAY = 'https://gateway.sepolia-test.vertexprotocol.com/v1'
SEPOLIA_TESTNET_INDEXER = 'https://archive.sepolia-test.vertexprotocol.com/v1'
MAINNET_GATEWAY = 'https://gateway.prod.vertexprotocol.com/v1'
MAINNET_INDEXER = 'https://archive.prod.vertexprotocol.com/v1'
BLAST_MAINNET_GATEWAY = 'https://gateway.blast-prod.vertexprotocol.com/v1'
BLAST_MAINNET_INDEXER = 'https://archive.blast-prod.vertexprotocol.com/v1'
DEVNET_GATEWAY = 'http://localhost:80'
DEVNET_INDEXER = 'http://localhost:8000'
class vertex_protocol.utils.SubaccountParams(**data)[source]

Bases: VertexBaseModel

A class used to represent parameters for a Subaccount in the Vertex system.

Attributes:

subaccount_owner (Optional[str]): The wallet address of the subaccount. subaccount_name (str): The subaccount name identifier.

subaccount_owner: Optional[str]
subaccount_name: str
vertex_protocol.utils.subaccount_to_bytes32(subaccount, name=None)[source]

Converts a subaccount representation to a bytes object of length 32.

Return type:

bytes

Args:

subaccount (Subaccount): The subaccount, which can be a string, bytes, or SubaccountParams instance.

name (str|bytes, optional): The subaccount name, when provided subaccount is expected to be the owner address.

Returns:

(bytes|SubaccountParams): The bytes object of length 32 representing the subaccount.

Raises:

ValueError: If the subaccount is a SubaccountParams instance and is missing either subaccount_owner or subaccount_name

Note:

If name is provided, subaccount must be the owner address, otherwise subaccount can be the bytes32 or hex representation of the subaccount or a SubaccountParams object.

vertex_protocol.utils.subaccount_to_hex(subaccount, name=None)[source]

Converts a subaccount representation to its hexadecimal representation.

Return type:

str

Args:

subaccount (Subaccount): The subaccount, which can be a string, bytes, or SubaccountParams instance.

name (str|bytes, optional): Additional string, if any, to be appended to the subaccount string before conversion. Defaults to None.

Returns:

(str|SubaccountParams): The hexadecimal representation of the subaccount.

vertex_protocol.utils.subaccount_name_to_bytes12(subaccount_name)[source]

Converts a subaccount name to a bytes object of length 12.

Return type:

bytes

Args:

subaccount_name (str): The subaccount name to be converted.

Returns:

bytes: A bytes object of length 12 representing the subaccount name.

vertex_protocol.utils.hex_to_bytes32(input)[source]

Converts a hexadecimal string or bytes to a bytes object of length 32.

Return type:

bytes

Args:

input (str | bytes): The hexadecimal string or bytes to be converted.

Returns:

bytes: The converted bytes object of length 32.

vertex_protocol.utils.hex_to_bytes12(input)[source]

Converts a hexadecimal string or bytes to a bytes object of length 12.

Return type:

bytes

Args:

input (str | bytes): The hexadecimal string or bytes to be converted.

Returns:

bytes: The converted bytes object of length 12.

vertex_protocol.utils.hex_to_bytes(input, size)[source]

Converts a hexadecimal string or bytes to a bytes object of specified size.

Return type:

bytes

Args:

input (str | bytes): The hexadecimal string or bytes to be converted.

size (int): The specified size for the output bytes object.

Returns:

bytes: The converted bytes object of the specified size.

vertex_protocol.utils.str_to_hex(input)[source]

Converts a string to its hexadecimal representation.

Return type:

str

Args:

input (str): The string to be converted.

Returns:

str: The hexadecimal representation of the input string.

vertex_protocol.utils.bytes32_to_hex(bytes32)[source]

Converts a bytes object of length 32 to its hexadecimal representation.

Return type:

str

Args:

bytes32 (bytes): The bytes object of length 32 to be converted.

Returns:

str: The hexadecimal representation of the input bytes object. If the input is not a bytes object, the function returns the input itself.

vertex_protocol.utils.zero_subaccount()[source]

Generates a bytes object of length 32 filled with zero bytes.

Return type:

bytes

Returns:

bytes: A bytes object of length 32 filled with zero bytes.

vertex_protocol.utils.zero_address()[source]

Generates a bytes object of length 20 filled with zero bytes.

Return type:

bytes

Returns:

bytes: A bytes object of length 20 filled with zero bytes.

class vertex_protocol.utils.OrderType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

DEFAULT = 0
IOC = 1
FOK = 2
POST_ONLY = 3
vertex_protocol.utils.get_expiration_timestamp(order_type, expiration)[source]

Encodes the order type into the expiration timestamp for special order types such as immediate-or-cancel.

Return type:

int

Args:

order_type (OrderType): The type of order.

expiration (int): The expiration timestamp in UNIX seconds.

Returns:

int: The properly formatted timestamp needed for the specified order type.

vertex_protocol.utils.gen_order_nonce(recv_time_ms=None, random_int=None)[source]

Generates an order nonce based on a received timestamp and a random integer.

Return type:

int

Args:

recv_time_ms (int, optional): Received timestamp in milliseconds. Defaults to the current time plus 90 seconds.

random_int (int, optional): An integer for the nonce. Defaults to a random integer between 0 and 999.

Returns:

int: The generated order nonce.

vertex_protocol.utils.decode_expiration(expiration)[source]

Decodes the expiration timestamp to retrieve the order type and original expiration timestamp.

Return type:

tuple[OrderType, int]

Args:

expiration (int): The encoded expiration timestamp.

Returns:

Tuple[OrderType, int]: The decoded order type and the original expiration timestamp.

vertex_protocol.utils.to_pow_10(x, pow)[source]

Converts integer to power of 10 format.

Return type:

int

Args:

x (int): Integer value.

pow (int): Power of 10.

Returns:

int: Converted value.

vertex_protocol.utils.to_x18(x)[source]

Converts a float to a fixed point of 1e18.

Return type:

int

Args:

x (float): Float value to convert.

Returns:

int: Fixed point value represented as an integer.

vertex_protocol.utils.from_pow_10(x, pow)[source]

Reverts integer from power of 10 format.

Return type:

float

Args:

x (int): Converted value.

pow (int): Power of 10.

Returns:

float: Original value.

vertex_protocol.utils.from_x18(x)[source]

Reverts integer from power of 10^18 format.

Return type:

float

Args:

x (int): Converted value.

Returns:

float: Original value.

exception vertex_protocol.utils.ExecuteFailedException(message='Execute failed')[source]

Bases: Exception

Raised when the execute status is not ‘success’

__init__(message='Execute failed')[source]
exception vertex_protocol.utils.QueryFailedException(message='Query failed')[source]

Bases: Exception

Raised when the query status is not ‘success’

__init__(message='Query failed')[source]
exception vertex_protocol.utils.BadStatusCodeException(message='Bad status code')[source]

Bases: Exception

Raised when the response status code is not 200

__init__(message='Bad status code')[source]
exception vertex_protocol.utils.MissingSignerException(message='Signer not provided')[source]

Bases: Exception

Raised when the Signer is required to perform an operation but it’s not provided.

__init__(message='Signer not provided')[source]
exception vertex_protocol.utils.InvalidProductId(message='Invalid product id provided')[source]

Bases: Exception

Raised when product id is invalid.

__init__(message='Invalid product id provided')[source]