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

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
@@ -1401,7 +1401,7 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
1401
1401
  )
1402
1402
  };
1403
1403
  };
1404
- var calculateBorrowIncentivePoolPointData = (pasredBorrowIncentinvePoolData, parsedBorrowIncentivePoolPointData, rewardCoinPrice, rewardCoinDecimal, poolCoinPrice, poolCoinDecimal) => {
1404
+ var calculateBorrowIncentivePoolPointData = (parsedBorrowIncentivePoolData, parsedBorrowIncentivePoolPointData, rewardCoinPrice, rewardCoinDecimal, poolCoinPrice, poolCoinDecimal) => {
1405
1405
  const baseIndexRate = 1e9;
1406
1406
  const distributedPointPerSec = BigNumber(
1407
1407
  parsedBorrowIncentivePoolPointData.distributedPointPerPeriod
@@ -1423,9 +1423,6 @@ var calculateBorrowIncentivePoolPointData = (pasredBorrowIncentinvePoolData, par
1423
1423
  const currentTotalDistributedPoint = BigNumber(
1424
1424
  parsedBorrowIncentivePoolPointData.distributedPoint
1425
1425
  ).plus(accumulatedPoints);
1426
- const stakedAmount = BigNumber(pasredBorrowIncentinvePoolData.staked);
1427
- const stakedCoin = stakedAmount.shiftedBy(-1 * poolCoinDecimal);
1428
- const stakedValue = stakedCoin.multipliedBy(poolCoinPrice);
1429
1426
  const baseWeight = BigNumber(parsedBorrowIncentivePoolPointData.baseWeight);
1430
1427
  const weightedStakedAmount = BigNumber(
1431
1428
  parsedBorrowIncentivePoolPointData.weightedAmount
@@ -1454,9 +1451,6 @@ var calculateBorrowIncentivePoolPointData = (pasredBorrowIncentinvePoolData, par
1454
1451
  accumulatedPoints: accumulatedPoints.toNumber(),
1455
1452
  currentPointIndex: currentPointIndex.toNumber(),
1456
1453
  currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
1457
- stakedAmount: stakedAmount.toNumber(),
1458
- stakedCoin: stakedCoin.toNumber(),
1459
- stakedValue: stakedValue.toNumber(),
1460
1454
  baseWeight: baseWeight.toNumber(),
1461
1455
  weightedStakedAmount: weightedStakedAmount.toNumber(),
1462
1456
  weightedStakedCoin: weightedStakedCoin.toNumber(),
@@ -2471,6 +2465,7 @@ var getStakeRewardPool = async (query, marketCoinName) => {
2471
2465
 
2472
2466
  // src/queries/borrowIncentiveQuery.ts
2473
2467
  import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui.js/utils";
2468
+ import BigNumber3 from "bignumber.js";
2474
2469
  var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer = false) => {
2475
2470
  borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
2476
2471
  ...SUPPORT_BORROW_INCENTIVE_POOLS
@@ -2482,19 +2477,29 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
2482
2477
  const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
2483
2478
  const borrowIncentivePoolsQueryData = queryResult.events[0].parsedJson;
2484
2479
  const borrowIncentivePools = {};
2480
+ const coinPrices = await query.utils.getCoinPrices(
2481
+ [
2482
+ .../* @__PURE__ */ new Set([
2483
+ ...borrowIncentiveCoinNames,
2484
+ ...SUPPORT_BORROW_INCENTIVE_REWARDS
2485
+ ])
2486
+ ]
2487
+ );
2485
2488
  if (indexer) {
2489
+ const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
2490
+ for (const borrowIncentivePool of Object.values(
2491
+ borrowIncentivePoolsIndexer
2492
+ )) {
2493
+ if (!borrowIncentiveCoinNames.includes(borrowIncentivePool.coinName))
2494
+ continue;
2495
+ borrowIncentivePool.coinPrice = coinPrices[borrowIncentivePool.coinName] || borrowIncentivePool.coinPrice;
2496
+ borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
2497
+ }
2498
+ return borrowIncentivePools;
2486
2499
  }
2487
2500
  for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
2488
2501
  const borrowIncentivePoolPoints = {};
2489
2502
  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
2503
  const poolCoinType = normalizeStructTag5(pool.pool_type.name);
2499
2504
  const poolCoinName = query.utils.parseCoinNameFromType(
2500
2505
  poolCoinType
@@ -2535,14 +2540,19 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
2535
2540
  ...calculatedPoolPoint
2536
2541
  };
2537
2542
  }
2543
+ const stakedAmount = BigNumber3(parsedBorrowIncentivePoolData.staked);
2544
+ const stakedCoin = stakedAmount.shiftedBy(-1 * poolCoinDecimal);
2545
+ const stakedValue = stakedCoin.multipliedBy(poolCoinPrice);
2538
2546
  borrowIncentivePools[poolCoinName] = {
2539
2547
  coinName: poolCoinName,
2540
2548
  symbol: query.utils.parseSymbol(poolCoinName),
2541
2549
  coinType: poolCoinType,
2542
2550
  coinDecimal: poolCoinDecimal,
2543
2551
  coinPrice: poolCoinPrice,
2544
- points: borrowIncentivePoolPoints,
2545
- staked: parsedBorrowIncentivePoolData.staked
2552
+ stakedAmount: stakedAmount.toNumber(),
2553
+ stakedCoin: stakedCoin.toNumber(),
2554
+ stakedValue: stakedValue.toNumber(),
2555
+ points: borrowIncentivePoolPoints
2546
2556
  };
2547
2557
  }
2548
2558
  return borrowIncentivePools;
@@ -2689,7 +2699,7 @@ var getPythPrices = async (query, assetCoinNames) => {
2689
2699
  };
2690
2700
 
2691
2701
  // src/queries/portfolioQuery.ts
2692
- import BigNumber3 from "bignumber.js";
2702
+ import BigNumber4 from "bignumber.js";
2693
2703
  var getLendings = async (query, poolCoinNames, ownerAddress, indexer = false) => {
2694
2704
  poolCoinNames = poolCoinNames || [...SUPPORT_POOLS];
2695
2705
  const marketCoinNames = poolCoinNames.map(
@@ -2740,18 +2750,18 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
2740
2750
  marketCoinAmount = marketCoinAmount || await query.getMarketCoinAmount(marketCoinName, ownerAddress);
2741
2751
  coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
2742
2752
  const coinDecimal = query.utils.getCoinDecimal(poolCoinName);
2743
- let stakedMarketAmount = BigNumber3(0);
2744
- let stakedMarketCoin = BigNumber3(0);
2745
- let stakedAmount = BigNumber3(0);
2746
- let stakedCoin = BigNumber3(0);
2747
- let stakedValue = BigNumber3(0);
2748
- let availableUnstakeAmount = BigNumber3(0);
2749
- let availableUnstakeCoin = BigNumber3(0);
2750
- let availableClaimAmount = BigNumber3(0);
2751
- let availableClaimCoin = BigNumber3(0);
2753
+ let stakedMarketAmount = BigNumber4(0);
2754
+ let stakedMarketCoin = BigNumber4(0);
2755
+ let stakedAmount = BigNumber4(0);
2756
+ let stakedCoin = BigNumber4(0);
2757
+ let stakedValue = BigNumber4(0);
2758
+ let availableUnstakeAmount = BigNumber4(0);
2759
+ let availableUnstakeCoin = BigNumber4(0);
2760
+ let availableClaimAmount = BigNumber4(0);
2761
+ let availableClaimCoin = BigNumber4(0);
2752
2762
  if (spool) {
2753
2763
  for (const stakeAccount of stakeAccounts) {
2754
- const accountStakedMarketCoinAmount = BigNumber3(stakeAccount.staked);
2764
+ const accountStakedMarketCoinAmount = BigNumber4(stakeAccount.staked);
2755
2765
  const accountStakedMarketCoin = accountStakedMarketCoinAmount.shiftedBy(
2756
2766
  -1 * spool.coinDecimal
2757
2767
  );
@@ -2778,7 +2788,7 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
2778
2788
  -1 * spool.coinDecimal
2779
2789
  );
2780
2790
  const baseIndexRate = 1e9;
2781
- const increasedPointRate = spool.currentPointIndex ? BigNumber3(spool.currentPointIndex - stakeAccount.index).dividedBy(
2791
+ const increasedPointRate = spool.currentPointIndex ? BigNumber4(spool.currentPointIndex - stakeAccount.index).dividedBy(
2782
2792
  baseIndexRate
2783
2793
  ) : 1;
2784
2794
  availableClaimAmount = availableClaimAmount.plus(
@@ -2789,17 +2799,17 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
2789
2799
  );
2790
2800
  }
2791
2801
  }
2792
- const suppliedAmount = BigNumber3(marketCoinAmount).multipliedBy(
2802
+ const suppliedAmount = BigNumber4(marketCoinAmount).multipliedBy(
2793
2803
  marketPool?.conversionRate ?? 1
2794
2804
  );
2795
2805
  const suppliedCoin = suppliedAmount.shiftedBy(-1 * coinDecimal);
2796
2806
  const suppliedValue = suppliedCoin.multipliedBy(coinPrice ?? 0);
2797
- const marketCoinPrice = BigNumber3(coinPrice ?? 0).multipliedBy(
2807
+ const marketCoinPrice = BigNumber4(coinPrice ?? 0).multipliedBy(
2798
2808
  marketPool?.conversionRate ?? 1
2799
2809
  );
2800
- const unstakedMarketAmount = BigNumber3(marketCoinAmount);
2810
+ const unstakedMarketAmount = BigNumber4(marketCoinAmount);
2801
2811
  const unstakedMarketCoin = unstakedMarketAmount.shiftedBy(-1 * coinDecimal);
2802
- const availableSupplyAmount = BigNumber3(coinAmount);
2812
+ const availableSupplyAmount = BigNumber4(coinAmount);
2803
2813
  const availableSupplyCoin = availableSupplyAmount.shiftedBy(-1 * coinDecimal);
2804
2814
  const availableWithdrawAmount = minBigNumber(
2805
2815
  suppliedAmount,
@@ -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) => {
@@ -2887,12 +2899,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
2887
2899
  const debts = {};
2888
2900
  const borrowIncentives = {};
2889
2901
  let totalDepositedPools = 0;
2890
- let totalDepositedValue = BigNumber3(0);
2891
- let totalBorrowCapacityValue = BigNumber3(0);
2892
- let totalRequiredCollateralValue = BigNumber3(0);
2902
+ let totalDepositedValue = BigNumber4(0);
2903
+ let totalBorrowCapacityValue = BigNumber4(0);
2904
+ let totalRequiredCollateralValue = BigNumber4(0);
2893
2905
  let totalBorrowedPools = 0;
2894
- let totalBorrowedValue = BigNumber3(0);
2895
- let totalBorrowedValueWithWeight = BigNumber3(0);
2906
+ let totalBorrowedValue = BigNumber4(0);
2907
+ let totalBorrowedValueWithWeight = BigNumber4(0);
2896
2908
  for (const assetCoinName of collateralAssetCoinNames) {
2897
2909
  const collateral = obligationQuery.collaterals.find((collateral2) => {
2898
2910
  const collateralCoinName = query.utils.parseCoinNameFromType(
@@ -2905,7 +2917,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
2905
2917
  const coinPrice = coinPrices?.[assetCoinName];
2906
2918
  const coinAmount = coinAmounts?.[assetCoinName] ?? 0;
2907
2919
  if (marketCollateral && coinPrice) {
2908
- const depositedAmount = BigNumber3(collateral?.amount ?? 0);
2920
+ const depositedAmount = BigNumber4(collateral?.amount ?? 0);
2909
2921
  const depositedCoin = depositedAmount.shiftedBy(-1 * coinDecimal);
2910
2922
  const depositedValue = depositedCoin.multipliedBy(coinPrice);
2911
2923
  const borrowCapacityValue = depositedValue.multipliedBy(
@@ -2914,11 +2926,11 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
2914
2926
  const requiredCollateralValue2 = depositedValue.multipliedBy(
2915
2927
  marketCollateral.liquidationFactor
2916
2928
  );
2917
- const poolSizeAmount = BigNumber3(marketCollateral.maxDepositAmount).minus(
2929
+ const poolSizeAmount = BigNumber4(marketCollateral.maxDepositAmount).minus(
2918
2930
  marketCollateral.depositAmount
2919
2931
  );
2920
2932
  const availableDepositAmount = minBigNumber(
2921
- BigNumber3(coinAmount),
2933
+ BigNumber4(coinAmount),
2922
2934
  poolSizeAmount
2923
2935
  );
2924
2936
  const availableDepositCoin = availableDepositAmount.shiftedBy(
@@ -2966,13 +2978,13 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
2966
2978
  const coinAmount = coinAmounts?.[assetCoinName] ?? 0;
2967
2979
  if (marketPool && coinPrice) {
2968
2980
  const increasedRate = debt?.borrowIndex ? marketPool.borrowIndex / Number(debt.borrowIndex) - 1 : 0;
2969
- const borrowedAmount = BigNumber3(debt?.amount ?? 0);
2981
+ const borrowedAmount = BigNumber4(debt?.amount ?? 0);
2970
2982
  const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
2971
2983
  const requiredRepayAmount = borrowedAmount.multipliedBy(
2972
2984
  increasedRate + 1
2973
2985
  );
2974
2986
  const requiredRepayCoin = requiredRepayAmount.shiftedBy(-1 * coinDecimal);
2975
- const availableRepayAmount = BigNumber3(coinAmount);
2987
+ const availableRepayAmount = BigNumber4(coinAmount);
2976
2988
  const availableRepayCoin = availableRepayAmount.shiftedBy(
2977
2989
  -1 * coinDecimal
2978
2990
  );
@@ -3018,11 +3030,11 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3018
3030
  const accountPoint = borrowIncentiveAccount.pointList[rewardCoinName];
3019
3031
  const poolPoint = borrowIncentivePool.points[rewardCoinName];
3020
3032
  if (accountPoint && poolPoint) {
3021
- let availableClaimAmount = BigNumber3(0);
3022
- let availableClaimCoin = BigNumber3(0);
3023
- const accountBorrowedAmount = BigNumber3(accountPoint.weightedAmount);
3033
+ let availableClaimAmount = BigNumber4(0);
3034
+ let availableClaimCoin = BigNumber4(0);
3035
+ const accountBorrowedAmount = BigNumber4(accountPoint.weightedAmount);
3024
3036
  const baseIndexRate = 1e9;
3025
- const increasedPointRate = poolPoint.currentPointIndex ? BigNumber3(
3037
+ const increasedPointRate = poolPoint.currentPointIndex ? BigNumber4(
3026
3038
  poolPoint.currentPointIndex - accountPoint.index
3027
3039
  ).dividedBy(baseIndexRate) : 1;
3028
3040
  availableClaimAmount = availableClaimAmount.plus(
@@ -3031,11 +3043,11 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3031
3043
  availableClaimCoin = availableClaimAmount.shiftedBy(
3032
3044
  -1 * poolPoint.coinDecimal
3033
3045
  );
3034
- const weightScale = BigNumber3(1e12);
3035
- const boostValue = BigNumber3(accountPoint.weightedAmount).div(
3036
- BigNumber3(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3037
- ).isFinite() ? BigNumber3(accountPoint.weightedAmount).div(
3038
- BigNumber3(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3046
+ const weightScale = BigNumber4(1e12);
3047
+ const boostValue = BigNumber4(accountPoint.weightedAmount).div(
3048
+ BigNumber4(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3049
+ ).isFinite() ? BigNumber4(accountPoint.weightedAmount).div(
3050
+ BigNumber4(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3039
3051
  ).toNumber() : 1;
3040
3052
  if (availableClaimAmount.isGreaterThan(0)) {
3041
3053
  rewards.push({
@@ -3061,12 +3073,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3061
3073
  };
3062
3074
  }
3063
3075
  }
3064
- let riskLevel = totalRequiredCollateralValue.isZero() ? BigNumber3(0) : totalBorrowedValueWithWeight.dividedBy(totalRequiredCollateralValue);
3065
- riskLevel = riskLevel.isLessThan(1) ? riskLevel : BigNumber3(1);
3066
- const accountBalanceValue = totalDepositedValue.minus(totalBorrowedValue).isGreaterThan(0) ? totalDepositedValue.minus(totalBorrowedValue) : BigNumber3(0);
3067
- const availableCollateralValue = totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight).isGreaterThan(0) ? totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight) : BigNumber3(0);
3068
- const requiredCollateralValue = totalBorrowedValueWithWeight.isGreaterThan(0) ? totalRequiredCollateralValue : BigNumber3(0);
3069
- const unhealthyCollateralValue = totalBorrowedValueWithWeight.minus(requiredCollateralValue).isGreaterThan(0) ? totalBorrowedValueWithWeight.minus(requiredCollateralValue) : BigNumber3(0);
3076
+ let riskLevel = totalRequiredCollateralValue.isZero() ? BigNumber4(0) : totalBorrowedValueWithWeight.dividedBy(totalRequiredCollateralValue);
3077
+ riskLevel = riskLevel.isLessThan(1) ? riskLevel : BigNumber4(1);
3078
+ const accountBalanceValue = totalDepositedValue.minus(totalBorrowedValue).isGreaterThan(0) ? totalDepositedValue.minus(totalBorrowedValue) : BigNumber4(0);
3079
+ const availableCollateralValue = totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight).isGreaterThan(0) ? totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight) : BigNumber4(0);
3080
+ const requiredCollateralValue = totalBorrowedValueWithWeight.isGreaterThan(0) ? totalRequiredCollateralValue : BigNumber4(0);
3081
+ const unhealthyCollateralValue = totalBorrowedValueWithWeight.minus(requiredCollateralValue).isGreaterThan(0) ? totalBorrowedValueWithWeight.minus(requiredCollateralValue) : BigNumber4(0);
3070
3082
  const obligationAccount = {
3071
3083
  obligationId,
3072
3084
  // Deposited collateral value (collateral balance)
@@ -3097,16 +3109,16 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3097
3109
  )) {
3098
3110
  const marketCollateral = market.collaterals[collateralCoinName];
3099
3111
  if (marketCollateral) {
3100
- let estimatedAvailableWithdrawAmount = BigNumber3(
3112
+ let estimatedAvailableWithdrawAmount = BigNumber4(
3101
3113
  obligationAccount.totalAvailableCollateralValue
3102
3114
  ).dividedBy(marketCollateral.collateralFactor).dividedBy(marketCollateral.coinPrice).shiftedBy(marketCollateral.coinDecimal);
3103
3115
  estimatedAvailableWithdrawAmount = obligationAccount.totalBorrowedValueWithWeight === 0 ? (
3104
3116
  // Note: when there is no debt record, there is no need to estimate and the deposited amount is directly used as available withdraw.
3105
- BigNumber3(obligationCollateral.depositedAmount)
3117
+ BigNumber4(obligationCollateral.depositedAmount)
3106
3118
  ) : minBigNumber(
3107
3119
  estimatedAvailableWithdrawAmount.multipliedBy(
3108
3120
  estimatedFactor(
3109
- BigNumber3(obligationAccount.totalAvailableCollateralValue).dividedBy(marketCollateral.collateralFactor).toNumber(),
3121
+ BigNumber4(obligationAccount.totalAvailableCollateralValue).dividedBy(marketCollateral.collateralFactor).toNumber(),
3110
3122
  3,
3111
3123
  "increase"
3112
3124
  )
@@ -3123,12 +3135,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3123
3135
  )) {
3124
3136
  const marketPool = market.pools[poolCoinName];
3125
3137
  if (marketPool) {
3126
- const estimatedRequiredRepayAmount = BigNumber3(
3138
+ const estimatedRequiredRepayAmount = BigNumber4(
3127
3139
  obligationDebt.requiredRepayAmount
3128
3140
  ).multipliedBy(
3129
3141
  estimatedFactor(obligationDebt.borrowedValue, 3, "decrease")
3130
3142
  );
3131
- let estimatedAvailableBorrowAmount = BigNumber3(
3143
+ let estimatedAvailableBorrowAmount = BigNumber4(
3132
3144
  obligationAccount.totalAvailableCollateralValue
3133
3145
  ).dividedBy(marketPool.borrowWeight).shiftedBy(marketPool.coinDecimal).dividedBy(marketPool.coinPrice);
3134
3146
  estimatedAvailableBorrowAmount = obligationAccount.totalAvailableCollateralValue !== 0 ? minBigNumber(
@@ -3140,7 +3152,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3140
3152
  )
3141
3153
  ).toNumber(),
3142
3154
  marketPool.supplyAmount
3143
- ) : BigNumber3(0);
3155
+ ) : BigNumber4(0);
3144
3156
  obligationDebt.availableBorrowAmount = estimatedAvailableBorrowAmount.toNumber();
3145
3157
  obligationDebt.availableBorrowCoin = estimatedAvailableBorrowAmount.shiftedBy(-1 * obligationDebt.coinDecimal).toNumber();
3146
3158
  obligationDebt.requiredRepayAmount = estimatedRequiredRepayAmount.toNumber();
@@ -3151,8 +3163,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3151
3163
  };
3152
3164
  var getTotalValueLocked = async (query, indexer = false) => {
3153
3165
  const market = await query.queryMarket(indexer);
3154
- let supplyValue = BigNumber3(0);
3155
- let borrowValue = BigNumber3(0);
3166
+ let supplyValue = BigNumber4(0);
3167
+ let borrowValue = BigNumber4(0);
3156
3168
  if (indexer) {
3157
3169
  const tvlIndexer = await query.indexer.getTotalValueLocked();
3158
3170
  const tvl2 = {
@@ -3167,15 +3179,15 @@ var getTotalValueLocked = async (query, indexer = false) => {
3167
3179
  }
3168
3180
  for (const pool of Object.values(market.pools)) {
3169
3181
  supplyValue = supplyValue.plus(
3170
- BigNumber3(pool.supplyCoin).multipliedBy(pool.coinPrice)
3182
+ BigNumber4(pool.supplyCoin).multipliedBy(pool.coinPrice)
3171
3183
  );
3172
3184
  borrowValue = borrowValue.plus(
3173
- BigNumber3(pool.borrowCoin).multipliedBy(pool.coinPrice)
3185
+ BigNumber4(pool.borrowCoin).multipliedBy(pool.coinPrice)
3174
3186
  );
3175
3187
  }
3176
3188
  for (const collateral of Object.values(market.collaterals)) {
3177
3189
  supplyValue = supplyValue.plus(
3178
- BigNumber3(collateral.depositCoin).multipliedBy(collateral.coinPrice)
3190
+ BigNumber4(collateral.depositCoin).multipliedBy(collateral.coinPrice)
3179
3191
  );
3180
3192
  }
3181
3193
  const tvl = {
@@ -3187,7 +3199,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
3187
3199
  };
3188
3200
 
3189
3201
  // src/queries/vescaQuery.ts
3190
- import BigNumber4 from "bignumber.js";
3202
+ import BigNumber5 from "bignumber.js";
3191
3203
  import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
3192
3204
  import { bcs } from "@mysten/sui.js/bcs";
3193
3205
  var getVescaKeys = async (query, ownerAddress) => {
@@ -3248,7 +3260,7 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
3248
3260
  0
3249
3261
  );
3250
3262
  const lockedScaAmount = String(dynamicFields.locked_sca_amount);
3251
- const lockedScaCoin = BigNumber4(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
3263
+ const lockedScaCoin = BigNumber5(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
3252
3264
  const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
3253
3265
  vesca = {
3254
3266
  id: veScaDynamicFieldObject.objectId,
@@ -3256,7 +3268,7 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
3256
3268
  lockedScaAmount,
3257
3269
  lockedScaCoin,
3258
3270
  currentVeScaBalance,
3259
- unlockAt: BigNumber4(dynamicFields.unlock_at * 1e3).toNumber()
3271
+ unlockAt: BigNumber5(dynamicFields.unlock_at * 1e3).toNumber()
3260
3272
  };
3261
3273
  }
3262
3274
  return vesca;
@@ -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) {