@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.
@@ -313,13 +313,19 @@ export declare class ScallopQuery {
313
313
  usdc?: import("../types").BorrowIncentivePool | undefined;
314
314
  sbeth?: import("../types").BorrowIncentivePool | undefined;
315
315
  weth?: import("../types").BorrowIncentivePool | undefined;
316
+ wbtc?: import("../types").BorrowIncentivePool | undefined;
316
317
  wusdc?: import("../types").BorrowIncentivePool | undefined;
317
318
  wusdt?: import("../types").BorrowIncentivePool | undefined;
318
319
  sui?: import("../types").BorrowIncentivePool | undefined;
320
+ wapt?: import("../types").BorrowIncentivePool | undefined;
321
+ wsol?: import("../types").BorrowIncentivePool | undefined;
322
+ cetus?: import("../types").BorrowIncentivePool | undefined;
319
323
  afsui?: import("../types").BorrowIncentivePool | undefined;
320
324
  hasui?: import("../types").BorrowIncentivePool | undefined;
321
325
  vsui?: import("../types").BorrowIncentivePool | undefined;
322
326
  sca?: import("../types").BorrowIncentivePool | undefined;
327
+ fud?: import("../types").BorrowIncentivePool | undefined;
328
+ deep?: import("../types").BorrowIncentivePool | undefined;
323
329
  }>;
324
330
  /**
325
331
  * Get borrow incentive accounts data.
@@ -332,13 +338,19 @@ export declare class ScallopQuery {
332
338
  usdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
333
339
  sbeth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
334
340
  weth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
341
+ wbtc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
335
342
  wusdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
336
343
  wusdt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
337
344
  sui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
345
+ wapt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
346
+ wsol?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
347
+ cetus?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
338
348
  afsui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
339
349
  hasui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
340
350
  vsui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
341
351
  sca?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
352
+ fud?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
353
+ deep?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
342
354
  }>;
343
355
  /**
344
356
  * Get user lending and spool infomation for specific pools.
@@ -59,12 +59,13 @@ export declare class ScallopUtils {
59
59
  */
60
60
  parseSCoinName<T extends SupportSCoin>(coinName: SupportCoins | SupportMarketCoins): T | undefined;
61
61
  /**
62
- * Convert sCoin name to coin name.
62
+ * Convert sCoin name to market coin name.
63
63
  * This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
64
64
  * e.g: `scallop_sui -> ssui
65
+ * if no `scallop_...` is encountered, return coinName
65
66
  * @return sCoin name
66
67
  */
67
- parseCoinNameFromSCoinName(coinName: string): "susdc" | "ssbeth" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "sfud" | "sdeep";
68
+ parseSCoinTypeNameToMarketCoinName(coinName: string): "susdc" | "ssbeth" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "sfud" | "sdeep";
68
69
  /**
69
70
  * Convert sCoin name into sCoin type
70
71
  * @param sCoinName
@@ -110,6 +111,7 @@ export declare class ScallopUtils {
110
111
  parseCoinNameFromType<T extends SupportAssetCoins>(coinType: string): T extends SupportAssetCoins ? T : SupportAssetCoins;
111
112
  parseCoinNameFromType<T extends SupportMarketCoins>(coinType: string): T extends SupportMarketCoins ? T : SupportMarketCoins;
112
113
  parseCoinNameFromType<T extends SupportCoins>(coinType: string): T extends SupportCoins ? T : SupportCoins;
114
+ parseCoinNameFromType<T extends SupportSCoin>(coinType: string): T extends SupportSCoin ? T : SupportSCoin;
113
115
  /**
114
116
  * Convert market coin name to coin name.
115
117
  *
@@ -18,13 +18,19 @@ export declare const getBorrowIncentivePools: (query: ScallopQuery, borrowIncent
18
18
  usdc?: BorrowIncentivePool | undefined;
19
19
  sbeth?: BorrowIncentivePool | undefined;
20
20
  weth?: BorrowIncentivePool | undefined;
21
+ wbtc?: BorrowIncentivePool | undefined;
21
22
  wusdc?: BorrowIncentivePool | undefined;
22
23
  wusdt?: BorrowIncentivePool | undefined;
23
24
  sui?: BorrowIncentivePool | undefined;
25
+ wapt?: BorrowIncentivePool | undefined;
26
+ wsol?: BorrowIncentivePool | undefined;
27
+ cetus?: BorrowIncentivePool | undefined;
24
28
  afsui?: BorrowIncentivePool | undefined;
25
29
  hasui?: BorrowIncentivePool | undefined;
26
30
  vsui?: BorrowIncentivePool | undefined;
27
31
  sca?: BorrowIncentivePool | undefined;
32
+ fud?: BorrowIncentivePool | undefined;
33
+ deep?: BorrowIncentivePool | undefined;
28
34
  }>;
29
35
  /**
30
36
  * Query borrow incentive accounts data.
@@ -39,13 +45,19 @@ export declare const queryBorrowIncentiveAccounts: ({ utils, }: {
39
45
  usdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
40
46
  sbeth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
41
47
  weth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
48
+ wbtc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
42
49
  wusdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
43
50
  wusdt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
44
51
  sui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
52
+ wapt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
53
+ wsol?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
54
+ cetus?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
45
55
  afsui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
46
56
  hasui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
47
57
  vsui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
48
58
  sca?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
59
+ fud?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
60
+ deep?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
49
61
  }>;
50
62
  /**
51
63
  * Check veSca bind status
@@ -40,7 +40,7 @@ export declare const parseOriginBorrowIncentivesPoolPointData: (originBorrowInce
40
40
  * @param originBorrowIncentivePoolData - Origin borrow incentive pool data
41
41
  * @return Parsed borrow incentive pool data
42
42
  */
43
- export declare const parseOriginBorrowIncentivePoolData: (originBorrowIncentivePoolData: OriginBorrowIncentivePoolData) => ParsedBorrowIncentivePoolData;
43
+ export declare const parseOriginBorrowIncentivePoolData: (utils: ScallopUtils, originBorrowIncentivePoolData: OriginBorrowIncentivePoolData) => ParsedBorrowIncentivePoolData;
44
44
  export declare const calculateBorrowIncentivePoolPointData: (parsedBorrowIncentivePoolPointData: ParsedBorrowIncentivePoolPointData, rewardCoinPrice: number, rewardCoinDecimal: number, poolCoinPrice: number, poolCoinDecimal: number) => CalculatedBorrowIncentivePoolPointData;
45
45
  export declare const parseOriginBorrowIncentiveAccountPoolPointData: (originBorrowIncentiveAccountPoolPointData: OriginBorrowIncentiveAccountPoolData) => ParsedBorrowIncentiveAccountPoolData;
46
46
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "1.4.12",
3
+ "version": "1.4.14",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -107,18 +107,7 @@ export const SUPPORT_WORMHOLE = [
107
107
 
108
108
  export const SUPPORT_SPOOLS_REWARDS = ['sui'] as const;
109
109
 
110
- export const SUPPORT_BORROW_INCENTIVE_POOLS = [
111
- 'sui',
112
- 'wusdc',
113
- 'wusdt',
114
- 'afsui',
115
- 'hasui',
116
- 'vsui',
117
- 'weth',
118
- 'sbeth',
119
- 'sca',
120
- 'usdc',
121
- ] as const;
110
+ export const SUPPORT_BORROW_INCENTIVE_POOLS = [...SUPPORT_POOLS] as const;
122
111
 
123
112
  export const SUPPORT_BORROW_INCENTIVE_REWARDS = [
124
113
  ...SUPPORT_POOLS,
@@ -232,13 +232,14 @@ export class ScallopUtils {
232
232
  }
233
233
 
234
234
  /**
235
- * Convert sCoin name to coin name.
235
+ * Convert sCoin name to market coin name.
236
236
  * This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
237
237
  * e.g: `scallop_sui -> ssui
238
+ * if no `scallop_...` is encountered, return coinName
238
239
  * @return sCoin name
239
240
  */
240
- public parseCoinNameFromSCoinName(coinName: string) {
241
- return sCoinRawNameToName[coinName];
241
+ public parseSCoinTypeNameToMarketCoinName(coinName: string) {
242
+ return sCoinRawNameToName[coinName] ?? coinName;
242
243
  }
243
244
 
244
245
  /**
@@ -311,8 +312,14 @@ export class ScallopUtils {
311
312
  public parseCoinNameFromType<T extends SupportCoins>(
312
313
  coinType: string
313
314
  ): T extends SupportCoins ? T : SupportCoins;
315
+ public parseCoinNameFromType<T extends SupportSCoin>(
316
+ coinType: string
317
+ ): T extends SupportSCoin ? T : SupportSCoin;
314
318
  public parseCoinNameFromType(coinType: string) {
315
319
  coinType = normalizeStructTag(coinType);
320
+ if (sCoinTypeToName[coinType]) {
321
+ return sCoinTypeToName[coinType] as SupportSCoin;
322
+ }
316
323
 
317
324
  const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
318
325
  const coinTypeMatch = coinType.match(coinTypeRegex);
@@ -1,6 +1,5 @@
1
1
  import { normalizeStructTag } from '@mysten/sui/utils';
2
2
  import {
3
- sCoinRawNameToName,
4
3
  SUPPORT_BORROW_INCENTIVE_POOLS,
5
4
  SUPPORT_BORROW_INCENTIVE_REWARDS,
6
5
  } from '../constants';
@@ -100,8 +99,10 @@ export const getBorrowIncentivePools = async (
100
99
  const borrowIncentivePoolPoints: OptionalKeys<
101
100
  Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>
102
101
  > = {};
103
- const parsedBorrowIncentivePoolData =
104
- parseOriginBorrowIncentivePoolData(pool);
102
+ const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(
103
+ query.utils,
104
+ pool
105
+ );
105
106
 
106
107
  const poolCoinType = normalizeStructTag(pool.pool_type.name);
107
108
  const poolCoinName =
@@ -121,13 +122,10 @@ export const getBorrowIncentivePools = async (
121
122
  parsedBorrowIncentivePoolData.poolPoints
122
123
  )) {
123
124
  const rewardCoinType = poolPoint.pointType;
124
- let rewardCoinName = query.utils.parseCoinNameFromType(
125
+ const rewardCoinName = query.utils.parseCoinNameFromType(
125
126
  rewardCoinType
126
127
  ) as SupportBorrowIncentiveRewardCoins;
127
128
  // handle for scoin name
128
- if (sCoinRawNameToName[rewardCoinName]) {
129
- rewardCoinName = sCoinRawNameToName[rewardCoinName];
130
- }
131
129
  const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
132
130
  const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
133
131
 
@@ -532,7 +532,7 @@ export const getObligationAccount = async (
532
532
  ([key, accountPoint]) => {
533
533
  const poolPoint =
534
534
  borrowIncentivePool.points[
535
- key as SupportBorrowIncentiveRewardCoins
535
+ query.utils.parseSCoinTypeNameToMarketCoinName(key)
536
536
  ];
537
537
 
538
538
  if (accountPoint && poolPoint) {
@@ -577,6 +577,11 @@ export const getObligationAccount = async (
577
577
  .toNumber()
578
578
  : 1;
579
579
 
580
+ // console.log({
581
+ // availableClaimAmount: availableClaimAmount.toString(),
582
+ // coinName: poolPoint.coinName,
583
+ // coinType: poolPoint.coinType,
584
+ // });
580
585
  if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
581
586
  rewards.push({
582
587
  coinName: poolPoint.coinName,
@@ -27,7 +27,6 @@ import type {
27
27
  ParsedBorrowIncentiveAccountPoolData,
28
28
  SupportBorrowIncentiveRewardCoins,
29
29
  } from '../types';
30
- import { sCoinRawNameToName } from 'src/constants';
31
30
 
32
31
  /**
33
32
  * Parse origin market pool data to a more readable format.
@@ -424,6 +423,7 @@ export const parseOriginBorrowIncentivesPoolPointData = (
424
423
  * @return Parsed borrow incentive pool data
425
424
  */
426
425
  export const parseOriginBorrowIncentivePoolData = (
426
+ utils: ScallopUtils,
427
427
  originBorrowIncentivePoolData: OriginBorrowIncentivePoolData
428
428
  ): ParsedBorrowIncentivePoolData => {
429
429
  return {
@@ -434,12 +434,10 @@ export const parseOriginBorrowIncentivePoolData = (
434
434
  poolPoints: originBorrowIncentivePoolData.points.reduce(
435
435
  (acc, point) => {
436
436
  const parsed = parseOriginBorrowIncentivesPoolPointData(point);
437
- let name = parseStructTag(
438
- parsed.pointType
439
- ).name.toLowerCase() as SupportBorrowIncentiveRewardCoins;
440
- if (sCoinRawNameToName[name]) {
441
- name = sCoinRawNameToName[name];
442
- }
437
+ const name = utils.parseSCoinTypeNameToMarketCoinName(
438
+ parseStructTag(parsed.pointType).name.toLowerCase()
439
+ ) as SupportBorrowIncentiveRewardCoins;
440
+
443
441
  acc[name] = parsed;
444
442
  return acc;
445
443
  },