Queries

Vault Queries

The Vault Queries module provides (wrapped) GraphQL-based methods for querying vault data across collections. This client specifically handles vault ownership using the Aptos GraphQL endpoint, and APR queries using the Mirage GraphQL endpoint.

Vault Collection Queries

getAllOwnedVaultAddresses

Retrieves all vault addresses owned by a specific address across all vault collections.

async getAllOwnedVaultAddresses(ownerAddress: string): Promise<string[]>

Parameters:

  • ownerAddress: The Aptos address of the vault owner

Returns:

  • Array of vault object addresses owned by the specified address

Example:

const owner = "0x123..."
const vaultAddresses = await mirageClient.vault.queries.getAllOwnedVaultAddresses(owner)
// Returns ["0xabc...", "0xdef..."]

getOwnedVaultAddressesByCollection

Retrieves vault addresses owned by a specific address for a particular vault collection.

async getOwnedVaultAddressesByCollection(
  collateralSymbol: string,
  borrowSymbol: string,
  ownerAddress: string
): Promise<string[]>

Parameters:

  • collateralSymbol: The symbol of the collateral token
  • borrowSymbol: The symbol of the borrow token
  • ownerAddress: The Aptos address of the vault owner

Returns:

  • Array of vault object addresses for the specified collection owned by the address

Example:

const owner = "0x123..."
const vaultAddresses = await mirageClient.vault.queries.getOwnedVaultAddressesByCollection(
  "BTC",    // Collateral symbol
  "USD",    // Borrow symbol
  owner
)
// Returns ["0xabc..."] - vaults in BTC-USD collection owned by the address

getVaultCollectionAPR

Retrieves the Annual Percentage Rate (APR) for a specific vault collection from a given start date.

async getVaultCollectionAPR(
  perpSymbol: string,
  marginSymbol: string,
  beginDate: Date
): Promise<number>

Parameters:

  • perpSymbol: The symbol of the perpetual token
  • marginSymbol: The symbol of the margin token
  • beginDate: The start date from which to calculate the APR

Returns:

  • The calculated APR as a number (percentage)

Example:

const beginDate = new Date("2024-01-01")
const apr = await mirageClient.vault.queries.getVaultCollectionAPR(
  "BTC",     // Perpetual symbol
  "USD",     // Margin symbol
  beginDate
)
// Returns 5.75 (representing 5.75% APR)