@scallop-io/sui-scallop-sdk 1.4.21 → 1.4.22-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5085,9 +5085,9 @@ var getPythPrices = async ({
5085
5085
  {}
5086
5086
  );
5087
5087
  };
5088
- var getAllCoinPrices = async (query, marketPools, coinPrices) => {
5089
- coinPrices = coinPrices ?? await query.utils.getCoinPrices();
5090
- marketPools = marketPools ?? (await query.getMarketPools(void 0, { coinPrices })).pools;
5088
+ var getAllCoinPrices = async (query, marketPools, coinPrices, indexer = false) => {
5089
+ coinPrices = coinPrices ?? (indexer ? await query.getCoinPricesByIndexer() : await query.utils.getCoinPrices());
5090
+ marketPools = marketPools ?? (await query.getMarketPools(void 0, { coinPrices, indexer })).pools;
5091
5091
  if (!marketPools) {
5092
5092
  throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
5093
5093
  }
@@ -8357,6 +8357,16 @@ var ScallopIndexer = class {
8357
8357
  async getCoinPrice(poolCoinName) {
8358
8358
  return (await this.getMarketPool(poolCoinName))?.coinPrice ?? 0;
8359
8359
  }
8360
+ async getCoinPrices() {
8361
+ const marketPools = await this.getMarketPools();
8362
+ return Object.entries(marketPools).reduce(
8363
+ (prev, [coinName, market]) => {
8364
+ prev[coinName] = market.coinPrice;
8365
+ return prev;
8366
+ },
8367
+ {}
8368
+ );
8369
+ }
8360
8370
  };
8361
8371
 
8362
8372
  // src/models/scallopQuery.ts
@@ -8934,12 +8944,24 @@ var ScallopQuery = class {
8934
8944
  async getCoinPriceByIndexer(poolName) {
8935
8945
  return this.indexer.getCoinPrice(poolName);
8936
8946
  }
8947
+ /**
8948
+ * Get all supported pool price from indexer
8949
+ * @returns prices data
8950
+ */
8951
+ async getCoinPricesByIndexer() {
8952
+ return this.indexer.getCoinPrices();
8953
+ }
8937
8954
  /**
8938
8955
  * Get all coin prices, including sCoin
8939
8956
  * @returns prices data
8940
8957
  */
8941
8958
  async getAllCoinPrices(args) {
8942
- return getAllCoinPrices(this, args?.marketPools, args?.coinPrices);
8959
+ return getAllCoinPrices(
8960
+ this,
8961
+ args?.marketPools,
8962
+ args?.coinPrices,
8963
+ args?.indexer
8964
+ );
8943
8965
  }
8944
8966
  /**
8945
8967
  * Query all address (lending pool, collateral pool, borrow dynamics, interest models, etc.) of all pool