{"version":3,"file":"assets-conversion.mjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-conversion.ts"],"names":[],"mappings":"","sourcesContent":["import { type CaipAssetType } from '@metamask/utils';\n\n/**\n * The market data for an asset.\n *\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport type MarketData = {\n  marketCap: string;\n  totalVolume: string;\n  circulatingSupply: string;\n  allTimeHigh: string;\n  allTimeLow: string;\n  pricePercentChange: {\n    [interval: string]: number;\n  };\n};\n\n/**\n * The conversion rate between two assets.\n *\n * @property rate - The conversion rate between the two assets.\n * @property marketData - The market data for the asset, if requested.\n * @property conversionTime - The time at which the conversion rate was calculated.\n * @property expirationTime - The time at which the conversion rate expires.\n */\nexport type AssetConversion = {\n  rate: string;\n  marketData?: MarketData;\n  conversionTime: number;\n  expirationTime?: number;\n};\n\n/**\n * The arguments for the `onAssetsConversion` handler.\n *\n * @property conversions - An array of objects containing the `from` and `to` asset types.\n * @property includeMarketData - Whether to include market data in the response.\n */\nexport type OnAssetsConversionArguments = {\n  conversions: { from: CaipAssetType; to: CaipAssetType }[];\n  includeMarketData?: boolean;\n};\n\n/**\n * The `onAssetsConversion` handler. This is called by MetaMask when querying about asset conversion on specific chains.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsConversionArguments}.\n * @returns The conversion for each asset. See\n * {@link OnAssetsConversionResponse}.\n */\nexport type OnAssetsConversionHandler = (\n  args: OnAssetsConversionArguments,\n) => Promise<OnAssetsConversionResponse>;\n\n/**\n * The response from the conversion query, containing rates about each requested asset pair.\n *\n * @property conversionRates - A nested object with two CAIP-19 keys that contains a conversion rate or null between the two keys.\n */\nexport type OnAssetsConversionResponse = {\n  conversionRates: Record<\n    CaipAssetType,\n    Record<CaipAssetType, AssetConversion | null>\n  >;\n};\n"]}