paradex_vault_balance
Retrieve detailed balance information for a specific vault, including available, locked, and total funds, to assess financial status before trades or withdrawals on the Paradex platform.
Instructions
Get the current balance of a specific vault.
Retrieves the current balance information for a specific vault, including available funds, locked funds, and total balance. This is essential for understanding the financial state of a vault before executing trades or withdrawals.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault_address | Yes | The address of the vault to get balance for. |
Implementation Reference
- src/mcp_paradex/tools/vaults.py:123-148 (handler)The handler function get_vault_balance implements the core logic of the paradex_vault_balance tool. It is registered via the @server.tool decorator with the exact name. Takes vault_address as input, fetches data from Paradex API endpoint 'vaults/balance', validates using TypeAdapter(list[VaultBalance]), and returns the list.@server.tool(name="paradex_vault_balance") async def get_vault_balance( vault_address: Annotated[ str, Field(description="The address of the vault to get balance for.") ], ) -> list[VaultBalance]: """ Get the current balance of a specific vault. Retrieves the current balance information for a specific vault, including available funds, locked funds, and total balance. This is essential for understanding the financial state of a vault before executing trades or withdrawals. """ try: client = await get_paradex_client() response = await api_call(client, "vaults/balance", params={"address": vault_address}) if "error" in response: raise Exception(response["error"]) results = response["results"] balances = vault_balance_adapter.validate_python(results) return balances except Exception as e: logger.error(f"Error fetching balance for vault {vault_address}: {e!s}") raise e
- src/mcp_paradex/models.py:265-271 (schema)Pydantic model defining the output schema for vault balances. Used by the TypeAdapter for validation. Includes fields: token (str), size (str), last_updated_at (int).class VaultBalance(BaseModel): """Model representing the balance of a vault.""" token: Annotated[str, Field(description="Name of the token")] size: Annotated[str, Field(description="Balance amount of settlement token")] last_updated_at: Annotated[int, Field(description="Balance last updated time")]
- TypeAdapter instance for list[VaultBalance] used to validate the API response in the handler function.vault_balance_adapter = TypeAdapter(list[VaultBalance])
- src/mcp_paradex/tools/vaults.py:123-123 (registration)The @server.tool decorator registers the get_vault_balance function as the MCP tool named 'paradex_vault_balance'.@server.tool(name="paradex_vault_balance")