Fungible Assets
The following module provides methods to interact with fungible assets in the Mirage ecosystem. It offers functionality for retrieving asset information and performing balance calculations.
Methods
getAllFASymbols
Returns an array of all fungible asset symbols.
getAllFASymbols(): string[]Example:
const symbols = mirageClient.fungibleAsset.getAllFASymbols()
console.log('Available FA Symbols:', symbols)getFA
Returns the configuration for a specific fungible asset.
getFA(faSymbol: string): FungibleAssetConfigExample:
const faConfig = mirageClient.fungibleAsset.getFA('mUSD')
console.log('FA Config:', faConfig)getAllFAs
Returns an array of all fungible asset configurations.
getAllFAs(): FungibleAssetConfig[]Example:
const allFAs = mirageClient.fungibleAsset.getAllFAs()
console.log('All FA Configs:', allFAs)getFADecimals
Returns the number of decimals for a specific token.
getFADecimals(tokenSymbol: string): numberExample:
const decimals = mirageClient.fungibleAsset.getFADecimals('mUSD')
console.log('mUSD Decimals:', decimals)getFACoinType
Returns the Move coin type for a token, if available.
getFACoinType(tokenSymbol: string): `${string}::${string}::${string}` | undefinedExample:
const coinType = mirageClient.fungibleAsset.getFACoinType('mUSD')
console.log('mUSD Coin Type:', coinType)getFAName
Returns the name of a fungible asset.
getFAName(tokenSymbol: string): stringExample:
const name = mirageClient.fungibleAsset.getFAName('mUSD')
console.log('FA Name:', name)getFAMetadataAddress
Returns the metadata address for a fungible asset.
getFAMetadataAddress(tokenSymbol: string): stringExample:
const address = mirageClient.fungibleAsset.getFAMetadataAddress('mUSD')
console.log('FA Metadata Address:', address)getFASymbolFromAddress
Returns the symbol of a fungible asset given its metadata address.
getFASymbolFromAddress(tokenMetadataAddress: string): stringExample:
const symbol = mirageClient.fungibleAsset.getFASymbolFromAddress('0x123...')
console.log('FA Symbol:', symbol)balanceToDecimal
Converts a raw balance to a human-readable decimal format.
balanceToDecimal(balance: BigNumber, tokenSymbol: string): BigNumberExample:
const rawBalance = new BigNumber('100000000') // 1 mUSD in base units
const humanReadable = mirageClient.fungibleAsset.balanceToDecimal(rawBalance, 'mUSD')
console.log('mUSD Balance:', humanReadable.toString())
// Output: '1.00'Type Definitions
interface FungibleAssetConfig {
name: string
decimals: number
address: string
coinType?: `${string}::${string}::${string}`
}Views
There is a views submodule that provides methods to query on-chain data about fungible assets.
Methods
getUserAssetBalance
Retrieves the balance of a specific fungible asset for a given user address.
getUserAssetBalance(tokenSymbol: string, userAddress: string): Promise<BigNumber>Example:
const balance = await mirageClient.fungibleAsset.views.getUserAssetBalance('mUSD', '0x123...')
console.log('User mUSD Balance:', balance.toString())getFATotalSupply
Retrieves the total supply of a specific fungible asset.
getFATotalSupply(tokenSymbol: string): Promise<BigNumber>Example:
const totalSupply = await mirageClient.fungibleAsset.views.getFATotalSupply('mUSD')
console.log('mUSD Total Supply:', totalSupply.toString())