@scallop-io/sui-scallop-sdk 0.46.3 → 0.46.31

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.mjs CHANGED
@@ -2482,19 +2482,29 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
2482
2482
  const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
2483
2483
  const borrowIncentivePoolsQueryData = queryResult.events[0].parsedJson;
2484
2484
  const borrowIncentivePools = {};
2485
+ const coinPrices = await query.utils.getCoinPrices(
2486
+ [
2487
+ .../* @__PURE__ */ new Set([
2488
+ ...borrowIncentiveCoinNames,
2489
+ ...SUPPORT_BORROW_INCENTIVE_REWARDS
2490
+ ])
2491
+ ]
2492
+ );
2485
2493
  if (indexer) {
2494
+ const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
2495
+ for (const borrowIncentivePool of Object.values(
2496
+ borrowIncentivePoolsIndexer
2497
+ )) {
2498
+ if (!borrowIncentiveCoinNames.includes(borrowIncentivePool.coinName))
2499
+ continue;
2500
+ borrowIncentivePool.coinPrice = coinPrices[borrowIncentivePool.coinName] || borrowIncentivePool.coinPrice;
2501
+ borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
2502
+ }
2503
+ return borrowIncentivePools;
2486
2504
  }
2487
2505
  for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
2488
2506
  const borrowIncentivePoolPoints = {};
2489
2507
  const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
2490
- const coinPrices = await query.utils.getCoinPrices(
2491
- [
2492
- .../* @__PURE__ */ new Set([
2493
- ...borrowIncentiveCoinNames,
2494
- ...SUPPORT_BORROW_INCENTIVE_REWARDS
2495
- ])
2496
- ]
2497
- );
2498
2508
  const poolCoinType = normalizeStructTag5(pool.pool_type.name);
2499
2509
  const poolCoinName = query.utils.parseCoinNameFromType(
2500
2510
  poolCoinType
@@ -2853,17 +2863,19 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
2853
2863
  const coinAmounts = await query.getCoinAmounts(void 0, ownerAddress);
2854
2864
  const obligations = await query.getObligations(ownerAddress);
2855
2865
  const obligationAccounts = {};
2856
- for (const obligation of obligations) {
2857
- obligationAccounts[obligation.keyId] = await getObligationAccount(
2858
- query,
2859
- obligation.id,
2860
- ownerAddress,
2861
- indexer,
2862
- market,
2863
- coinPrices,
2864
- coinAmounts
2865
- );
2866
- }
2866
+ await Promise.allSettled(
2867
+ obligations.map(async (obligation) => {
2868
+ obligationAccounts[obligation.keyId] = await getObligationAccount(
2869
+ query,
2870
+ obligation.id,
2871
+ ownerAddress,
2872
+ indexer,
2873
+ market,
2874
+ coinPrices,
2875
+ coinAmounts
2876
+ );
2877
+ })
2878
+ );
2867
2879
  return obligationAccounts;
2868
2880
  };
2869
2881
  var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
@@ -3450,6 +3462,15 @@ var ScallopIndexer = class {
3450
3462
  if (response.status === 200) {
3451
3463
  return response.data.borrowIncentivePools.reduce(
3452
3464
  (borrowIncentivePools, borrowIncentivePool) => {
3465
+ if (Array.isArray(borrowIncentivePool.points)) {
3466
+ borrowIncentivePool.points = borrowIncentivePool.points.reduce(
3467
+ (prev, curr) => {
3468
+ prev[curr.coinName] = curr;
3469
+ return prev;
3470
+ },
3471
+ {}
3472
+ );
3473
+ }
3453
3474
  borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
3454
3475
  return borrowIncentivePools;
3455
3476
  },
@@ -5114,11 +5135,6 @@ var generateQuickVeScaMethod = ({
5114
5135
  newUnlockAt,
5115
5136
  veSca?.unlockAt
5116
5137
  );
5117
- console.log(
5118
- new Date(newUnlockAt * 1e3).toLocaleString("en-CA", {
5119
- hour12: true
5120
- })
5121
- );
5122
5138
  const isInitialLock = !veSca?.unlockAt;
5123
5139
  const isLockExpired = !isInitialLock && veSca.unlockAt * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
5124
5140
  if (isInitialLock || isLockExpired) {