@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.mjs
CHANGED
|
@@ -2254,19 +2254,21 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2254
2254
|
const collaterals = {};
|
|
2255
2255
|
if (indexer) {
|
|
2256
2256
|
const marketIndexer = await query.indexer.getMarket();
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
}
|
|
2257
|
+
const updatePools = (item) => {
|
|
2258
|
+
item.coinPrice = coinPrices[item.coinName] || item.coinPrice;
|
|
2259
|
+
item.coinWrappedType = query.utils.getCoinWrappedType(item.coinName);
|
|
2260
|
+
pools[item.coinName] = item;
|
|
2261
|
+
};
|
|
2262
|
+
const updateCollaterals = (item) => {
|
|
2263
|
+
item.coinPrice = coinPrices[item.coinName] || item.coinPrice;
|
|
2264
|
+
item.coinWrappedType = query.utils.getCoinWrappedType(item.coinName);
|
|
2265
|
+
collaterals[item.coinName] = item;
|
|
2266
|
+
};
|
|
2267
|
+
Object.values(marketIndexer.pools).forEach(updatePools);
|
|
2268
|
+
Object.values(marketIndexer.collaterals).forEach(updateCollaterals);
|
|
2267
2269
|
return {
|
|
2268
|
-
pools
|
|
2269
|
-
collaterals
|
|
2270
|
+
pools,
|
|
2271
|
+
collaterals
|
|
2270
2272
|
};
|
|
2271
2273
|
}
|
|
2272
2274
|
const packageId = query.address.get("core.packages.query.id");
|
|
@@ -2376,8 +2378,7 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2376
2378
|
data: marketData
|
|
2377
2379
|
};
|
|
2378
2380
|
};
|
|
2379
|
-
var getMarketPools = async (query, poolCoinNames, indexer = false) => {
|
|
2380
|
-
poolCoinNames = poolCoinNames || [...SUPPORT_POOLS];
|
|
2381
|
+
var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer = false) => {
|
|
2381
2382
|
const marketId = query.address.get("core.market");
|
|
2382
2383
|
const marketObjectResponse = await query.cache.queryGetObject(marketId, {
|
|
2383
2384
|
showContent: true
|
|
@@ -2386,15 +2387,16 @@ var getMarketPools = async (query, poolCoinNames, indexer = false) => {
|
|
|
2386
2387
|
const marketPools = {};
|
|
2387
2388
|
if (indexer) {
|
|
2388
2389
|
const marketPoolsIndexer = await query.indexer.getMarketPools();
|
|
2389
|
-
|
|
2390
|
+
const updateMarketPool = (marketPool) => {
|
|
2390
2391
|
if (!poolCoinNames.includes(marketPool.coinName))
|
|
2391
|
-
|
|
2392
|
+
return;
|
|
2392
2393
|
marketPool.coinPrice = coinPrices[marketPool.coinName] || marketPool.coinPrice;
|
|
2393
2394
|
marketPool.coinWrappedType = query.utils.getCoinWrappedType(
|
|
2394
2395
|
marketPool.coinName
|
|
2395
2396
|
);
|
|
2396
2397
|
marketPools[marketPool.coinName] = marketPool;
|
|
2397
|
-
}
|
|
2398
|
+
};
|
|
2399
|
+
Object.values(marketPoolsIndexer).forEach(updateMarketPool);
|
|
2398
2400
|
return marketPools;
|
|
2399
2401
|
}
|
|
2400
2402
|
await Promise.allSettled(
|
|
@@ -2419,6 +2421,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2419
2421
|
let borrowIndex;
|
|
2420
2422
|
let interestModel;
|
|
2421
2423
|
let borrowFeeRate;
|
|
2424
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2422
2425
|
if (indexer) {
|
|
2423
2426
|
const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
|
|
2424
2427
|
marketPoolIndexer.coinPrice = coinPrice || marketPoolIndexer.coinPrice;
|
|
@@ -2431,7 +2434,6 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2431
2434
|
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2432
2435
|
showContent: true
|
|
2433
2436
|
}))?.data;
|
|
2434
|
-
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2435
2437
|
if (marketObject) {
|
|
2436
2438
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
2437
2439
|
const fields = marketObject.content.fields;
|
|
@@ -2561,29 +2563,27 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2561
2563
|
}
|
|
2562
2564
|
return marketPool;
|
|
2563
2565
|
};
|
|
2564
|
-
var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) => {
|
|
2565
|
-
collateralCoinNames = collateralCoinNames || [...SUPPORT_COLLATERALS];
|
|
2566
|
+
var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
|
|
2566
2567
|
const marketId = query.address.get("core.market");
|
|
2567
|
-
const
|
|
2568
|
-
await query.cache.queryGetObject(marketId, {
|
|
2569
|
-
showContent: true
|
|
2570
|
-
}),
|
|
2571
|
-
await query.utils.getCoinPrices(collateralCoinNames ?? [])
|
|
2572
|
-
]);
|
|
2568
|
+
const coinPrices = await query.utils.getCoinPrices(collateralCoinNames ?? []);
|
|
2573
2569
|
const marketCollaterals = {};
|
|
2574
2570
|
if (indexer) {
|
|
2575
2571
|
const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
|
|
2576
|
-
|
|
2572
|
+
const updateMarketCollateral = (marketCollateral) => {
|
|
2577
2573
|
if (!collateralCoinNames.includes(marketCollateral.coinName))
|
|
2578
|
-
|
|
2574
|
+
return;
|
|
2579
2575
|
marketCollateral.coinPrice = coinPrices[marketCollateral.coinName] || marketCollateral.coinPrice;
|
|
2580
2576
|
marketCollateral.coinWrappedType = query.utils.getCoinWrappedType(
|
|
2581
2577
|
marketCollateral.coinName
|
|
2582
2578
|
);
|
|
2583
2579
|
marketCollaterals[marketCollateral.coinName] = marketCollateral;
|
|
2584
|
-
}
|
|
2580
|
+
};
|
|
2581
|
+
Object.values(marketCollateralsIndexer).forEach(updateMarketCollateral);
|
|
2585
2582
|
return marketCollaterals;
|
|
2586
2583
|
}
|
|
2584
|
+
const marketObjectResponse = await query.cache.queryGetObject(marketId, {
|
|
2585
|
+
showContent: true
|
|
2586
|
+
});
|
|
2587
2587
|
await Promise.allSettled(
|
|
2588
2588
|
collateralCoinNames.map(async (collateralCoinName) => {
|
|
2589
2589
|
const marketCollateral = await getMarketCollateral(
|
|
@@ -2601,6 +2601,7 @@ var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) =
|
|
|
2601
2601
|
return marketCollaterals;
|
|
2602
2602
|
};
|
|
2603
2603
|
var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
|
|
2604
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
2604
2605
|
if (indexer) {
|
|
2605
2606
|
const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
|
|
2606
2607
|
marketCollateralIndexer.coinPrice = coinPrice || marketCollateralIndexer.coinPrice;
|
|
@@ -2616,7 +2617,6 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
2616
2617
|
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2617
2618
|
showContent: true
|
|
2618
2619
|
}))?.data;
|
|
2619
|
-
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
2620
2620
|
if (marketObject) {
|
|
2621
2621
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
2622
2622
|
const fields = marketObject.content.fields;
|
|
@@ -2866,8 +2866,7 @@ var getFlashLoanFees = async (query, assetNames) => {
|
|
|
2866
2866
|
|
|
2867
2867
|
// src/queries/spoolQuery.ts
|
|
2868
2868
|
import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui.js/utils";
|
|
2869
|
-
var getSpools = async (query, stakeMarketCoinNames, indexer = false) => {
|
|
2870
|
-
stakeMarketCoinNames = stakeMarketCoinNames || [...SUPPORT_SPOOLS];
|
|
2869
|
+
var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexer = false) => {
|
|
2871
2870
|
const stakeCoinNames = stakeMarketCoinNames.map(
|
|
2872
2871
|
(stakeMarketCoinName) => query.utils.parseCoinName(stakeMarketCoinName)
|
|
2873
2872
|
);
|
|
@@ -2882,9 +2881,9 @@ var getSpools = async (query, stakeMarketCoinNames, indexer = false) => {
|
|
|
2882
2881
|
const spools = {};
|
|
2883
2882
|
if (indexer) {
|
|
2884
2883
|
const spoolsIndexer = await query.indexer.getSpools();
|
|
2885
|
-
|
|
2884
|
+
const updateSpools = (spool) => {
|
|
2886
2885
|
if (!stakeMarketCoinNames.includes(spool.marketCoinName))
|
|
2887
|
-
|
|
2886
|
+
return;
|
|
2888
2887
|
const coinName = query.utils.parseCoinName(
|
|
2889
2888
|
spool.marketCoinName
|
|
2890
2889
|
);
|
|
@@ -2896,7 +2895,8 @@ var getSpools = async (query, stakeMarketCoinNames, indexer = false) => {
|
|
|
2896
2895
|
spool.marketCoinPrice = (coinPrices[coinName] ?? 0) * (marketPool ? marketPool.conversionRate : 0) || spool.marketCoinPrice;
|
|
2897
2896
|
spool.rewardCoinPrice = coinPrices[rewardCoinName] || spool.rewardCoinPrice;
|
|
2898
2897
|
spools[spool.marketCoinName] = spool;
|
|
2899
|
-
}
|
|
2898
|
+
};
|
|
2899
|
+
Object.values(spoolsIndexer).forEach(updateSpools);
|
|
2900
2900
|
return spools;
|
|
2901
2901
|
}
|
|
2902
2902
|
for (const stakeMarketCoinName of stakeMarketCoinNames) {
|
|
@@ -2922,6 +2922,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
|
|
|
2922
2922
|
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
2923
2923
|
);
|
|
2924
2924
|
let spool = void 0;
|
|
2925
|
+
coinPrices = coinPrices || await query.utils.getCoinPrices([coinName]);
|
|
2925
2926
|
if (indexer) {
|
|
2926
2927
|
const spoolIndexer = await query.indexer.getSpool(marketCoinName);
|
|
2927
2928
|
const coinName2 = query.utils.parseCoinName(marketCoinName);
|
|
@@ -3251,10 +3252,9 @@ var getStakeRewardPool = async ({
|
|
|
3251
3252
|
// src/queries/borrowIncentiveQuery.ts
|
|
3252
3253
|
import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui.js/utils";
|
|
3253
3254
|
import BigNumber3 from "bignumber.js";
|
|
3254
|
-
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
];
|
|
3255
|
+
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
3256
|
+
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
3257
|
+
], indexer = false) => {
|
|
3258
3258
|
const borrowIncentivePools = {};
|
|
3259
3259
|
const coinPrices = await query.utils.getCoinPrices(
|
|
3260
3260
|
[
|
|
@@ -3266,14 +3266,15 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
3266
3266
|
);
|
|
3267
3267
|
if (indexer) {
|
|
3268
3268
|
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3269
|
+
const updateBorrowIncentivePool = (pool) => {
|
|
3270
|
+
if (!borrowIncentiveCoinNames.includes(pool.coinName))
|
|
3271
|
+
return;
|
|
3272
|
+
pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
|
|
3273
|
+
borrowIncentivePools[pool.coinName] = pool;
|
|
3274
|
+
};
|
|
3275
|
+
Object.values(borrowIncentivePoolsIndexer).forEach(
|
|
3276
|
+
updateBorrowIncentivePool
|
|
3277
|
+
);
|
|
3277
3278
|
return borrowIncentivePools;
|
|
3278
3279
|
}
|
|
3279
3280
|
const queryPkgId = query.address.get("borrowIncentive.query");
|