Views

Vault Views

The Vault Views module provides methods for querying vault data and metadata through Aptos nodes. It handles interactions with vault collections, tokens, and oracles in the Mirage protocol.

Collection Queries

allVaultCollectionAddresses

Retrieves all vault collection addresses deployed by the protocol.

async allVaultCollectionAddresses(): Promise<MoveObjectType[]>

Example:

const collections = await mirageClient.vault.views.allVaultCollectionAddresses()
// Returns array of collection object addresses

getVaultCollectionName

Retrieves the name of a specific vault collection.

async getVaultCollectionName(collectionObjectAddress: MoveObjectType): Promise<string>

Example:

const name = await mirageClient.vault.views.getVaultCollectionName("0x123...")
// Returns the collection name as a string

Token and Oracle Queries

getCollateralTokenAddress

Gets the collateral token address for a vault collection.

async getCollateralTokenAddress(
  collectionObjectAddress: MoveObjectType
): Promise<MoveObjectType>

Example:

const tokenAddress = await mirageClient.vault.views.getCollateralTokenAddress("0x123...")

getBorrowToken

Gets the borrow token address for a vault collection.

async getBorrowToken(
  collectionObjectAddress: MoveObjectType
): Promise<MoveObjectType>

Example:

const tokenAddress = await mirageClient.vault.views.getBorrowToken("0x123...")

getCollateralOracle

Gets the oracle address for the collateral token of a vault collection.

async getCollateralOracle(
  collectionObjectAddress: MoveObjectType
): Promise<MoveObjectType>

Example:

const oracleAddress = await mirageClient.vault.views.getCollateralOracle("0x123...")

getBorrowOracle

Gets the oracle address for the borrow token of a vault collection.

async getBorrowOracle(
  collectionObjectAddress: MoveObjectType
): Promise<MoveObjectType>

Example:

const oracleAddress = await mirageClient.vault.views.getBorrowOracle("0x123...")

Liquidation Queries

getLiquidatableAmountsBulk

Gets the liquidatable amounts for multiple vault objects simultaneously.

async getLiquidatableAmountsBulk(
  vaultObjectAddresses: MoveObjectType[]
): Promise<number[]>

Example:

const liquidatableAmounts = await mirageClient.vault.views.getLiquidatableAmountsBulk(
  ["0x123...", "0x456..."] // Vault object addresses
)
// Returns array of liquidatable amounts with 8 decimal precision