@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 +26 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -4
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopIndexer.d.ts +1 -0
- package/dist/models/scallopQuery.d.ts +6 -0
- package/dist/queries/priceQuery.d.ts +1 -1
- package/package.json +1 -1
- package/src/models/scallopIndexer.ts +11 -0
- package/src/models/scallopQuery.ts +15 -1
- package/src/queries/priceQuery.ts +10 -3
package/dist/index.mjs
CHANGED
|
@@ -4999,9 +4999,9 @@ var getPythPrices = async ({
|
|
|
4999
4999
|
{}
|
|
5000
5000
|
);
|
|
5001
5001
|
};
|
|
5002
|
-
var getAllCoinPrices = async (query, marketPools, coinPrices) => {
|
|
5003
|
-
coinPrices = coinPrices ?? await query.utils.getCoinPrices();
|
|
5004
|
-
marketPools = marketPools ?? (await query.getMarketPools(void 0, { coinPrices })).pools;
|
|
5002
|
+
var getAllCoinPrices = async (query, marketPools, coinPrices, indexer = false) => {
|
|
5003
|
+
coinPrices = coinPrices ?? (indexer ? await query.getCoinPricesByIndexer() : await query.utils.getCoinPrices());
|
|
5004
|
+
marketPools = marketPools ?? (await query.getMarketPools(void 0, { coinPrices, indexer })).pools;
|
|
5005
5005
|
if (!marketPools) {
|
|
5006
5006
|
throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
|
|
5007
5007
|
}
|
|
@@ -8285,6 +8285,16 @@ var ScallopIndexer = class {
|
|
|
8285
8285
|
async getCoinPrice(poolCoinName) {
|
|
8286
8286
|
return (await this.getMarketPool(poolCoinName))?.coinPrice ?? 0;
|
|
8287
8287
|
}
|
|
8288
|
+
async getCoinPrices() {
|
|
8289
|
+
const marketPools = await this.getMarketPools();
|
|
8290
|
+
return Object.entries(marketPools).reduce(
|
|
8291
|
+
(prev, [coinName, market]) => {
|
|
8292
|
+
prev[coinName] = market.coinPrice;
|
|
8293
|
+
return prev;
|
|
8294
|
+
},
|
|
8295
|
+
{}
|
|
8296
|
+
);
|
|
8297
|
+
}
|
|
8288
8298
|
};
|
|
8289
8299
|
|
|
8290
8300
|
// src/models/scallopQuery.ts
|
|
@@ -8862,12 +8872,24 @@ var ScallopQuery = class {
|
|
|
8862
8872
|
async getCoinPriceByIndexer(poolName) {
|
|
8863
8873
|
return this.indexer.getCoinPrice(poolName);
|
|
8864
8874
|
}
|
|
8875
|
+
/**
|
|
8876
|
+
* Get all supported pool price from indexer
|
|
8877
|
+
* @returns prices data
|
|
8878
|
+
*/
|
|
8879
|
+
async getCoinPricesByIndexer() {
|
|
8880
|
+
return this.indexer.getCoinPrices();
|
|
8881
|
+
}
|
|
8865
8882
|
/**
|
|
8866
8883
|
* Get all coin prices, including sCoin
|
|
8867
8884
|
* @returns prices data
|
|
8868
8885
|
*/
|
|
8869
8886
|
async getAllCoinPrices(args) {
|
|
8870
|
-
return getAllCoinPrices(
|
|
8887
|
+
return getAllCoinPrices(
|
|
8888
|
+
this,
|
|
8889
|
+
args?.marketPools,
|
|
8890
|
+
args?.coinPrices,
|
|
8891
|
+
args?.indexer
|
|
8892
|
+
);
|
|
8871
8893
|
}
|
|
8872
8894
|
/**
|
|
8873
8895
|
* Query all address (lending pool, collateral pool, borrow dynamics, interest models, etc.) of all pool
|