MirageClient
The MirageClient is the main entry point for interacting with the Mirage protocol. It provides access to all protocol features including market operations, vault management, referral system, and asset handling.
Installation
yarn add @mirage-protocol/sdkConfiguration Options
The MirageClient is initialized using MirageClientOptions:
type MirageClientOptions = {
fullnodeUrl?: string // Custom fullnode URL
indexerUrl?: string // Custom aptos indexer URL
mirageIndexerUrl?: string // Custom Mirage indexer URL
pythUrl?: string // Custom Pyth network URL
aptosApiKey?: string // Optional Aptos indexer API key
deployment?: Deployment // Optional deployment type
customConfig?: MirageJsonConfig // Optional custom mirage configuration
}
enum Deployment {
APTOS_TESTNET = 'testnet',
MOVEMENT_PORTO = 'porto'
}Initialization Examples
Basic Initialization
import { MirageClient, MirageConfig, Deployment } from '@mirage/sdk'
const mirageClient = new MirageClient(
new MirageConfig({
deployment: Deployment.APTOS_TESTNET
})
)Advanced Initialization
import { MirageClient, MirageConfig, Deployment } from '@mirage/sdk'
const config = new MirageConfig({
deployment: Deployment.APTOS_TESTNET,
fullnodeUrl: 'https://custom-fullnode.example.com/v1',
indexerUrl: 'https://custom-indexer.example.com/v1/graphql',
mirageIndexerUrl: 'https://custom-mirage-indexer.example.com/v1/graphql',
pythUrl: 'https://custom-pyth.example.com',
aptosApiKey: 'your-aptos-api-key',
customConfig: {
chainId: 2,
deployerAddress: '0x123...abc',
markets: [
{
address: '0xabc...',
name: 'BTC-USD',
perpSymbol: 'BTC',
marginSymbol: 'USD',
marginOracle: '0xdef...',
perpOracle: '0xghi...'
}
],
vaults: [
{
address: '0xjkl...',
name: 'USDC-USD',
collateralSymbol: 'USDC',
borrowSymbol: 'USD',
collateralOracle: '0xmno...',
borrowOracle: '0xpqr...'
}
],
fungibleAssets: [
{
symbol: 'USDC',
address: '0xstu...',
name: 'USD Coin',
decimals: 6
}
],
oracles: [
{
name: 'BTC/USD',
address: '0xvwx...',
priceFeedId: '0xyz...',
priceMultiplier: 1000000
}
]
}
})
const mirageClient = new MirageClient(config)Default Network Configuration
The client provides default configurations for different deployments:
const defaultMirageNetworks = {
testnet: {
fullnodeUrl: 'https://fullnode.testnet.aptoslabs.com/v1',
indexerUrl: 'https://api.testnet.aptoslabs.com/v1/graphql',
mirageIndexerUrl: 'https://testnet.mirage.money/v1/graphql',
pythUrl: 'https://hermes-beta.pyth.network'
},
porto: {
fullnodeUrl: 'https://aptos.testnet.porto.movementlabs.xyz/v1',
indexerUrl: 'https://indexer.testnet.porto.movementnetwork.xyz/v1/graphql',
mirageIndexerUrl: 'https://porto.mirage.money/v1/graphql',
pythUrl: 'https://hermes-beta.pyth.network'
}
}