@scallop-io/sui-scallop-sdk 0.47.0-alpha.3 → 0.47.0-alpha.4
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 +48 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -47
- package/dist/index.mjs.map +1 -1
- package/dist/queries/borrowIncentiveQuery.d.ts +9 -9
- package/package.json +6 -3
- package/src/queries/borrowIncentiveQuery.ts +15 -17
- package/src/queries/coreQuery.ts +44 -39
- package/src/queries/spoolQuery.ts +6 -5
package/dist/index.js
CHANGED
|
@@ -2328,19 +2328,21 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2328
2328
|
const collaterals = {};
|
|
2329
2329
|
if (indexer) {
|
|
2330
2330
|
const marketIndexer = await query.indexer.getMarket();
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
}
|
|
2331
|
+
const updatePools = (item) => {
|
|
2332
|
+
item.coinPrice = coinPrices[item.coinName] || item.coinPrice;
|
|
2333
|
+
item.coinWrappedType = query.utils.getCoinWrappedType(item.coinName);
|
|
2334
|
+
pools[item.coinName] = item;
|
|
2335
|
+
};
|
|
2336
|
+
const updateCollaterals = (item) => {
|
|
2337
|
+
item.coinPrice = coinPrices[item.coinName] || item.coinPrice;
|
|
2338
|
+
item.coinWrappedType = query.utils.getCoinWrappedType(item.coinName);
|
|
2339
|
+
collaterals[item.coinName] = item;
|
|
2340
|
+
};
|
|
2341
|
+
Object.values(marketIndexer.pools).forEach(updatePools);
|
|
2342
|
+
Object.values(marketIndexer.collaterals).forEach(updateCollaterals);
|
|
2341
2343
|
return {
|
|
2342
|
-
pools
|
|
2343
|
-
collaterals
|
|
2344
|
+
pools,
|
|
2345
|
+
collaterals
|
|
2344
2346
|
};
|
|
2345
2347
|
}
|
|
2346
2348
|
const packageId = query.address.get("core.packages.query.id");
|
|
@@ -2450,8 +2452,7 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2450
2452
|
data: marketData
|
|
2451
2453
|
};
|
|
2452
2454
|
};
|
|
2453
|
-
var getMarketPools = async (query, poolCoinNames, indexer = false) => {
|
|
2454
|
-
poolCoinNames = poolCoinNames || [...SUPPORT_POOLS];
|
|
2455
|
+
var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer = false) => {
|
|
2455
2456
|
const marketId = query.address.get("core.market");
|
|
2456
2457
|
const marketObjectResponse = await query.cache.queryGetObject(marketId, {
|
|
2457
2458
|
showContent: true
|
|
@@ -2460,15 +2461,16 @@ var getMarketPools = async (query, poolCoinNames, indexer = false) => {
|
|
|
2460
2461
|
const marketPools = {};
|
|
2461
2462
|
if (indexer) {
|
|
2462
2463
|
const marketPoolsIndexer = await query.indexer.getMarketPools();
|
|
2463
|
-
|
|
2464
|
+
const updateMarketPool = (marketPool) => {
|
|
2464
2465
|
if (!poolCoinNames.includes(marketPool.coinName))
|
|
2465
|
-
|
|
2466
|
+
return;
|
|
2466
2467
|
marketPool.coinPrice = coinPrices[marketPool.coinName] || marketPool.coinPrice;
|
|
2467
2468
|
marketPool.coinWrappedType = query.utils.getCoinWrappedType(
|
|
2468
2469
|
marketPool.coinName
|
|
2469
2470
|
);
|
|
2470
2471
|
marketPools[marketPool.coinName] = marketPool;
|
|
2471
|
-
}
|
|
2472
|
+
};
|
|
2473
|
+
Object.values(marketPoolsIndexer).forEach(updateMarketPool);
|
|
2472
2474
|
return marketPools;
|
|
2473
2475
|
}
|
|
2474
2476
|
await Promise.allSettled(
|
|
@@ -2493,6 +2495,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2493
2495
|
let borrowIndex;
|
|
2494
2496
|
let interestModel;
|
|
2495
2497
|
let borrowFeeRate;
|
|
2498
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2496
2499
|
if (indexer) {
|
|
2497
2500
|
const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
|
|
2498
2501
|
marketPoolIndexer.coinPrice = coinPrice || marketPoolIndexer.coinPrice;
|
|
@@ -2505,7 +2508,6 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2505
2508
|
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2506
2509
|
showContent: true
|
|
2507
2510
|
}))?.data;
|
|
2508
|
-
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2509
2511
|
if (marketObject) {
|
|
2510
2512
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
2511
2513
|
const fields = marketObject.content.fields;
|
|
@@ -2635,29 +2637,27 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2635
2637
|
}
|
|
2636
2638
|
return marketPool;
|
|
2637
2639
|
};
|
|
2638
|
-
var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) => {
|
|
2639
|
-
collateralCoinNames = collateralCoinNames || [...SUPPORT_COLLATERALS];
|
|
2640
|
+
var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
|
|
2640
2641
|
const marketId = query.address.get("core.market");
|
|
2641
|
-
const
|
|
2642
|
-
await query.cache.queryGetObject(marketId, {
|
|
2643
|
-
showContent: true
|
|
2644
|
-
}),
|
|
2645
|
-
await query.utils.getCoinPrices(collateralCoinNames ?? [])
|
|
2646
|
-
]);
|
|
2642
|
+
const coinPrices = await query.utils.getCoinPrices(collateralCoinNames ?? []);
|
|
2647
2643
|
const marketCollaterals = {};
|
|
2648
2644
|
if (indexer) {
|
|
2649
2645
|
const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
|
|
2650
|
-
|
|
2646
|
+
const updateMarketCollateral = (marketCollateral) => {
|
|
2651
2647
|
if (!collateralCoinNames.includes(marketCollateral.coinName))
|
|
2652
|
-
|
|
2648
|
+
return;
|
|
2653
2649
|
marketCollateral.coinPrice = coinPrices[marketCollateral.coinName] || marketCollateral.coinPrice;
|
|
2654
2650
|
marketCollateral.coinWrappedType = query.utils.getCoinWrappedType(
|
|
2655
2651
|
marketCollateral.coinName
|
|
2656
2652
|
);
|
|
2657
2653
|
marketCollaterals[marketCollateral.coinName] = marketCollateral;
|
|
2658
|
-
}
|
|
2654
|
+
};
|
|
2655
|
+
Object.values(marketCollateralsIndexer).forEach(updateMarketCollateral);
|
|
2659
2656
|
return marketCollaterals;
|
|
2660
2657
|
}
|
|
2658
|
+
const marketObjectResponse = await query.cache.queryGetObject(marketId, {
|
|
2659
|
+
showContent: true
|
|
2660
|
+
});
|
|
2661
2661
|
await Promise.allSettled(
|
|
2662
2662
|
collateralCoinNames.map(async (collateralCoinName) => {
|
|
2663
2663
|
const marketCollateral = await getMarketCollateral(
|
|
@@ -2675,6 +2675,7 @@ var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) =
|
|
|
2675
2675
|
return marketCollaterals;
|
|
2676
2676
|
};
|
|
2677
2677
|
var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
|
|
2678
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
2678
2679
|
if (indexer) {
|
|
2679
2680
|
const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
|
|
2680
2681
|
marketCollateralIndexer.coinPrice = coinPrice || marketCollateralIndexer.coinPrice;
|
|
@@ -2690,7 +2691,6 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
2690
2691
|
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2691
2692
|
showContent: true
|
|
2692
2693
|
}))?.data;
|
|
2693
|
-
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
2694
2694
|
if (marketObject) {
|
|
2695
2695
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
2696
2696
|
const fields = marketObject.content.fields;
|
|
@@ -2940,8 +2940,7 @@ var getFlashLoanFees = async (query, assetNames) => {
|
|
|
2940
2940
|
|
|
2941
2941
|
// src/queries/spoolQuery.ts
|
|
2942
2942
|
var import_utils5 = require("@mysten/sui.js/utils");
|
|
2943
|
-
var getSpools = async (query, stakeMarketCoinNames, indexer = false) => {
|
|
2944
|
-
stakeMarketCoinNames = stakeMarketCoinNames || [...SUPPORT_SPOOLS];
|
|
2943
|
+
var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexer = false) => {
|
|
2945
2944
|
const stakeCoinNames = stakeMarketCoinNames.map(
|
|
2946
2945
|
(stakeMarketCoinName) => query.utils.parseCoinName(stakeMarketCoinName)
|
|
2947
2946
|
);
|
|
@@ -2956,9 +2955,9 @@ var getSpools = async (query, stakeMarketCoinNames, indexer = false) => {
|
|
|
2956
2955
|
const spools = {};
|
|
2957
2956
|
if (indexer) {
|
|
2958
2957
|
const spoolsIndexer = await query.indexer.getSpools();
|
|
2959
|
-
|
|
2958
|
+
const updateSpools = (spool) => {
|
|
2960
2959
|
if (!stakeMarketCoinNames.includes(spool.marketCoinName))
|
|
2961
|
-
|
|
2960
|
+
return;
|
|
2962
2961
|
const coinName = query.utils.parseCoinName(
|
|
2963
2962
|
spool.marketCoinName
|
|
2964
2963
|
);
|
|
@@ -2970,7 +2969,8 @@ var getSpools = async (query, stakeMarketCoinNames, indexer = false) => {
|
|
|
2970
2969
|
spool.marketCoinPrice = (coinPrices[coinName] ?? 0) * (marketPool ? marketPool.conversionRate : 0) || spool.marketCoinPrice;
|
|
2971
2970
|
spool.rewardCoinPrice = coinPrices[rewardCoinName] || spool.rewardCoinPrice;
|
|
2972
2971
|
spools[spool.marketCoinName] = spool;
|
|
2973
|
-
}
|
|
2972
|
+
};
|
|
2973
|
+
Object.values(spoolsIndexer).forEach(updateSpools);
|
|
2974
2974
|
return spools;
|
|
2975
2975
|
}
|
|
2976
2976
|
for (const stakeMarketCoinName of stakeMarketCoinNames) {
|
|
@@ -2996,6 +2996,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
|
|
|
2996
2996
|
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
2997
2997
|
);
|
|
2998
2998
|
let spool = void 0;
|
|
2999
|
+
coinPrices = coinPrices || await query.utils.getCoinPrices([coinName]);
|
|
2999
3000
|
if (indexer) {
|
|
3000
3001
|
const spoolIndexer = await query.indexer.getSpool(marketCoinName);
|
|
3001
3002
|
const coinName2 = query.utils.parseCoinName(marketCoinName);
|
|
@@ -3325,10 +3326,9 @@ var getStakeRewardPool = async ({
|
|
|
3325
3326
|
// src/queries/borrowIncentiveQuery.ts
|
|
3326
3327
|
var import_utils7 = require("@mysten/sui.js/utils");
|
|
3327
3328
|
var import_bignumber3 = __toESM(require("bignumber.js"));
|
|
3328
|
-
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
];
|
|
3329
|
+
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
3330
|
+
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
3331
|
+
], indexer = false) => {
|
|
3332
3332
|
const borrowIncentivePools = {};
|
|
3333
3333
|
const coinPrices = await query.utils.getCoinPrices(
|
|
3334
3334
|
[
|
|
@@ -3340,14 +3340,15 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
3340
3340
|
);
|
|
3341
3341
|
if (indexer) {
|
|
3342
3342
|
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3343
|
+
const updateBorrowIncentivePool = (pool) => {
|
|
3344
|
+
if (!borrowIncentiveCoinNames.includes(pool.coinName))
|
|
3345
|
+
return;
|
|
3346
|
+
pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
|
|
3347
|
+
borrowIncentivePools[pool.coinName] = pool;
|
|
3348
|
+
};
|
|
3349
|
+
Object.values(borrowIncentivePoolsIndexer).forEach(
|
|
3350
|
+
updateBorrowIncentivePool
|
|
3351
|
+
);
|
|
3351
3352
|
return borrowIncentivePools;
|
|
3352
3353
|
}
|
|
3353
3354
|
const queryPkgId = query.address.get("borrowIncentive.query");
|