The Prices class provides methods for fetching and managing price information for coins on the Sui network, including current prices and 24-hour price changes.
Retrieves detailed price information for a single coin. Please note that 24h price change percentage is currently not supported for any coins, and will return 0.
constpriceInfo=awaitprices.getCoinPriceInfo({ coin:"0x2::sui::SUI",// CoinType});console.log(priceInfo);/*{ price: 1.23, // Current price in USD priceChange24HoursPercentage: 5.67 // 24h price change percentage}*/
getCoinsToPriceInfo()
Fetches price information for multiple coins simultaneously. Please note that 24h price change percentage is currently not supported for any coins, and will return 0.
typeCoinType=string; // Coin address/identifiertypeCoinDecimal=number; // Number of decimal placestypeCoinSymbol=string; // Trading symbol for the coininterfaceCoinPriceInfo { price:number; priceChange24HoursPercentage:number;}interfaceCoinWithAmount { coin:CoinType; amount:number;}interfaceAmountInCoinAndUsd { amount:number; amountUsd:number;}
constafSdk=newAftermath("MAINNET");awaitafSdk.init();constprices=afSdk.Prices();// Get price info for SUIconstsuiPriceInfo=awaitprices.getCoinPriceInfo({ coin:"0x2::sui::SUI",});// Get prices for multiple coinsconstmultiPrices=awaitprices.getCoinsToPrice({ coins: ["0x2::sui::SUI","0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN", ],});console.log(`SUI Price: $${suiPriceInfo.price}`);console.log(`24h Change: ${suiPriceInfo.priceChange24HoursPercentage}%`);