Market Utility Functions
The Market Utility Functions module provides methods for interacting with perpetual markets, including market validation, address lookup, and price feed operations.
Market Validation
marketExists
Checks if a market exists for the given perpetual and collateral symbol pair.
marketExists(
perpSymbol: string,
collateralSymbol: string
): booleanExample:
const exists = mirageClient.market.marketExists(
"BTCPERP", // Perpetual symbol
"mUSD" // Collateral symbol
)
console.log(exists) // true or falsegetMarket
Retrieves market configuration for the given perpetual and margin symbol pair.
getMarket(
perpSymbol: string,
marginSymbol: string
): MarketConfigExample:
const marketConfig = mirageClient.market.getMarket(
"BTCPERP", // Perpetual symbol
"mUSD" // Margin symbol
)Market Enumeration
getAllMarkets
Retrieves configurations for all available markets.
getAllMarkets(): MarketConfig[]Example:
const markets = mirageClient.market.getAllMarkets()getAllMarketAddresses
Retrieves addresses for all available markets.
getAllMarketAddresses(): string[]Example:
const addresses = mirageClient.market.getAllMarketAddresses()Market Address Operations
getMarketIdFromAddress
Retrieves perpetual and margin symbols for a given market address.
getMarketIdFromAddress(
marketAddress: string
): { perpSymbol: string; marginSymbol: string }Example:
const marketId = mirageClient.market.getMarketIdFromAddress(
"0x123..." // Market address
)
console.log(marketId.perpSymbol) // "BTCPERP"
console.log(marketId.marginSymbol) // "mUSD"getMarketAddress
Retrieves the market address for given perpetual and margin symbols.
getMarketAddress(
perpSymbol: string,
marginSymbol: string
): stringExample:
const address = mirageClient.market.getMarketAddress(
"BTCPERP", // Perpetual symbol
"mUSD" // Margin symbol
)Price Feed Operations
getPerpPriceFeedId
Retrieves the price feed ID for the perpetual asset.
getPerpPriceFeedId(
perpSymbol: string,
marginSymbol: string
): stringExample:
const feedId = mirageClient.market.getPerpPriceFeedId(
"BTCPERP", // Perpetual symbol
"mUSD" // Margin symbol
)getMarginPriceFeedId
Retrieves the price feed ID for the margin asset.
getMarginPriceFeedId(
perpSymbol: string,
marginSymbol: string
): stringExample:
const feedId = mirageClient.market.getMarginPriceFeedId(
"BTCPERP", // Perpetual symbol
"mUSD" // Margin symbol
)getPerpPriceFeedUpdate
Retrieves the latest price feed update data for the perpetual asset.
async getPerpPriceFeedUpdate(
perpSymbol: string,
marginSymbol: string
): Promise<number[]>Example:
const updateData = await mirageClient.market.getPerpPriceFeedUpdate(
"BTCPERP", // Perpetual symbol
"mUSD" // Margin symbol
)getMarginPriceFeedUpdate
Retrieves the latest price feed update data for the margin asset.
async getMarginPriceFeedUpdate(
perpSymbol: string,
marginSymbol: string
): Promise<number[]>Example:
const updateData = await mirageClient.market.getMarginPriceFeedUpdate(
"BTCPERP", // Perpetual symbol
"mUSD" // Margin symbol
)getPerpPrice
Retrieves the current price for the perpetual asset.
async getPerpPrice(
perpSymbol: string,
marginSymbol: string
): Promise<number>Example:
const price = await mirageClient.market.getPerpPrice(
"BTCPERP", // Perpetual symbol
"mUSD" // Margin symbol
)getMarginPrice
Retrieves the current price for the margin asset.
async getMarginPrice(
perpSymbol: string,
marginSymbol: string
): Promise<number>Example:
const price = await mirageClient.market.getMarginPrice(
"BTCPERP", // Perpetual symbol
"mUSD" // Margin symbol
)