@scallop-io/sui-scallop-sdk 1.4.12 → 1.4.14

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
@@ -114,18 +114,7 @@ var SUPPORT_WORMHOLE = [
114
114
  "wsol"
115
115
  ];
116
116
  var SUPPORT_SPOOLS_REWARDS = ["sui"];
117
- var SUPPORT_BORROW_INCENTIVE_POOLS = [
118
- "sui",
119
- "wusdc",
120
- "wusdt",
121
- "afsui",
122
- "hasui",
123
- "vsui",
124
- "weth",
125
- "sbeth",
126
- "sca",
127
- "usdc"
128
- ];
117
+ var SUPPORT_BORROW_INCENTIVE_POOLS = [...SUPPORT_POOLS];
129
118
  var SUPPORT_BORROW_INCENTIVE_REWARDS = [
130
119
  ...SUPPORT_POOLS,
131
120
  ...SUPPORT_SCOIN
@@ -1363,7 +1352,7 @@ var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointDa
1363
1352
  createdAt: Number(originBorrowIncentivePoolPointData.created_at)
1364
1353
  };
1365
1354
  };
1366
- var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
1355
+ var parseOriginBorrowIncentivePoolData = (utils, originBorrowIncentivePoolData) => {
1367
1356
  return {
1368
1357
  poolType: normalizeStructTag(originBorrowIncentivePoolData.pool_type.name),
1369
1358
  minStakes: Number(originBorrowIncentivePoolData.min_stakes),
@@ -1372,12 +1361,9 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
1372
1361
  poolPoints: originBorrowIncentivePoolData.points.reduce(
1373
1362
  (acc, point) => {
1374
1363
  const parsed = parseOriginBorrowIncentivesPoolPointData(point);
1375
- let name = parseStructTag(
1376
- parsed.pointType
1377
- ).name.toLowerCase();
1378
- if (sCoinRawNameToName[name]) {
1379
- name = sCoinRawNameToName[name];
1380
- }
1364
+ const name = utils.parseSCoinTypeNameToMarketCoinName(
1365
+ parseStructTag(parsed.pointType).name.toLowerCase()
1366
+ );
1381
1367
  acc[name] = parsed;
1382
1368
  return acc;
1383
1369
  },
@@ -2534,7 +2520,10 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2534
2520
  );
2535
2521
  for (const pool of borrowIncentivePoolsQueryData?.incentive_pools ?? []) {
2536
2522
  const borrowIncentivePoolPoints = {};
2537
- const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
2523
+ const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(
2524
+ query.utils,
2525
+ pool
2526
+ );
2538
2527
  const poolCoinType = normalizeStructTag3(pool.pool_type.name);
2539
2528
  const poolCoinName = query.utils.parseCoinNameFromType(
2540
2529
  poolCoinType
@@ -2548,12 +2537,9 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2548
2537
  parsedBorrowIncentivePoolData.poolPoints
2549
2538
  )) {
2550
2539
  const rewardCoinType = poolPoint.pointType;
2551
- let rewardCoinName = query.utils.parseCoinNameFromType(
2540
+ const rewardCoinName = query.utils.parseCoinNameFromType(
2552
2541
  rewardCoinType
2553
2542
  );
2554
- if (sCoinRawNameToName[rewardCoinName]) {
2555
- rewardCoinName = sCoinRawNameToName[rewardCoinName];
2556
- }
2557
2543
  const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2558
2544
  const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2559
2545
  const symbol = query.utils.parseSymbol(rewardCoinName);
@@ -3863,7 +3849,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3863
3849
  const rewards = [];
3864
3850
  Object.entries(borrowIncentiveAccount.pointList).forEach(
3865
3851
  ([key, accountPoint]) => {
3866
- const poolPoint = borrowIncentivePool.points[key];
3852
+ const poolPoint = borrowIncentivePool.points[query.utils.parseSCoinTypeNameToMarketCoinName(key)];
3867
3853
  if (accountPoint && poolPoint) {
3868
3854
  let availableClaimAmount = BigNumber5(0);
3869
3855
  let availableClaimCoin = BigNumber5(0);
@@ -4895,13 +4881,14 @@ var ScallopUtils = class {
4895
4881
  }
4896
4882
  }
4897
4883
  /**
4898
- * Convert sCoin name to coin name.
4884
+ * Convert sCoin name to market coin name.
4899
4885
  * This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
4900
4886
  * e.g: `scallop_sui -> ssui
4887
+ * if no `scallop_...` is encountered, return coinName
4901
4888
  * @return sCoin name
4902
4889
  */
4903
- parseCoinNameFromSCoinName(coinName) {
4904
- return sCoinRawNameToName[coinName];
4890
+ parseSCoinTypeNameToMarketCoinName(coinName) {
4891
+ return sCoinRawNameToName[coinName] ?? coinName;
4905
4892
  }
4906
4893
  /**
4907
4894
  * Convert sCoin name into sCoin type
@@ -4950,6 +4937,9 @@ var ScallopUtils = class {
4950
4937
  }
4951
4938
  parseCoinNameFromType(coinType) {
4952
4939
  coinType = normalizeStructTag6(coinType);
4940
+ if (sCoinTypeToName[coinType]) {
4941
+ return sCoinTypeToName[coinType];
4942
+ }
4953
4943
  const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
4954
4944
  const coinTypeMatch = coinType.match(coinTypeRegex);
4955
4945
  const isMarketCoinType = coinType.includes("reserve::MarketCoin");