Vault Utility Functions
The Vault Utility Functions module provides mAPTods for interacting with CDP (Collateralized Debt Position) vaults, including vault validation, address lookup, and price feed operations.
Vault Validation
vaultCollectionExists
Checks if a vault collection exists for the given collateral and borrow symbol pair.
vaultCollectionExists(
collateralSymbol: string,
borrowSymbol: string
): booleanExample:
const exists = mirageClient.vault.vaultCollectionExists(
"APT", // Collateral symbol
"mUSD" // Borrow symbol
)
console.log(exists) // true or falsegetVaultCollection
Retrieves vault configuration for the given collateral and borrow symbol pair.
getVaultCollection(
collateralSymbol: string,
borrowSymbol: string
): VaultConfigExample:
const vaultConfig = mirageClient.vault.getVaultCollection(
"APT", // Collateral symbol
"mUSD" // Borrow symbol
)Vault Enumeration
getAllVaultCollections
Retrieves configurations for all available vault collections.
getAllVaultCollections(): VaultConfig[]Example:
const vaults = mirageClient.vault.getAllVaultCollections()getAllVaultCollectionAddresses
Retrieves addresses for all available vault collections.
getAllVaultCollectionAddresses(): string[]Example:
const addresses = mirageClient.vault.getAllVaultCollectionAddresses()Vault Address Operations
getVaultTokensFromAddress
Retrieves collateral and borrow symbols for a given vault address.
getVaultTokensFromAddress(
vaultAddress: string
): { collateralSymbol: string; borrowSymbol: string }Example:
const tokens = mirageClient.vault.getVaultTokensFromAddress(
"0x123..." // Vault address
)
console.log(tokens.collateralSymbol) // "APT"
console.log(tokens.borrowSymbol) // "mUSD"getVaultCollectionAddress
Retrieves the vault address for given collateral and borrow symbols.
getVaultCollectionAddress(
collateralSymbol: string,
borrowSymbol: string
): stringExample:
const address = mirageClient.vault.getVaultCollectionAddress(
"APT", // Collateral symbol
"mUSD" // Borrow symbol
)Price Feed Operations
getCollateralPriceFeedId
Retrieves the price feed ID for the collateral asset.
getCollateralPriceFeedId(
collateralSymbol: string,
borrowSymbol: string
): stringExample:
const feedId = mirageClient.vault.getCollateralPriceFeedId(
"APT", // Collateral symbol
"mUSD" // Borrow symbol
)getBorrowPriceFeedId
Retrieves the price feed ID for the borrow asset.
getBorrowPriceFeedId(
collateralSymbol: string,
borrowSymbol: string
): stringExample:
const feedId = mirageClient.vault.getBorrowPriceFeedId(
"APT", // Collateral symbol
"mUSD" // Borrow symbol
)getCollateralPriceFeedUpdate
Retrieves the latest price feed update data for the collateral asset.
async getCollateralPriceFeedUpdate(
collateralSymbol: string,
borrowSymbol: string
): Promise<number[]>Example:
const updateData = await mirageClient.vault.getCollateralPriceFeedUpdate(
"APT", // Collateral symbol
"mUSD" // Borrow symbol
)getBorrowPriceFeedUpdate
Retrieves the latest price feed update data for the borrow asset.
async getBorrowPriceFeedUpdate(
collateralSymbol: string,
borrowSymbol: string
): Promise<number[]>Example:
const updateData = await mirageClient.vault.getBorrowPriceFeedUpdate(
"APT", // Collateral symbol
"mUSD" // Borrow symbol
)Collateral Asset Operations
getCollateralCoinType
Retrieves the coin type for the collateral asset.
getCollateralCoinType(
collateralSymbol: string
): string | undefinedExample:
const coinType = mirageClient.vault.getCollateralCoinType(
"APT" // Collateral symbol
)getCollateralCoinDecimals
Retrieves the decimal places for the collateral asset.
getCollateralCoinDecimals(
collateralSymbol: string
): numberExample:
const decimals = mirageClient.vault.getCollateralCoinDecimals(
"APT" // Collateral symbol
)