@scallop-io/sui-scallop-sdk 1.5.3 → 2.0.0-alpha.10

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.
Files changed (66) hide show
  1. package/dist/index.d.mts +509 -602
  2. package/dist/index.d.ts +509 -602
  3. package/dist/index.js +28 -59
  4. package/dist/index.mjs +7 -7
  5. package/package.json +1 -1
  6. package/src/builders/coreBuilder.ts +33 -33
  7. package/src/builders/loyaltyProgramBuilder.ts +5 -3
  8. package/src/builders/{oracle.ts → oracles/index.ts} +48 -60
  9. package/src/builders/oracles/pyth.ts +44 -0
  10. package/src/builders/oracles/switchboard.ts +270 -0
  11. package/src/builders/referralBuilder.ts +5 -9
  12. package/src/builders/sCoinBuilder.ts +9 -8
  13. package/src/builders/spoolBuilder.ts +4 -6
  14. package/src/constants/common.ts +114 -126
  15. package/src/constants/index.ts +0 -5
  16. package/src/constants/pyth.ts +25 -34
  17. package/src/constants/queryKeys.ts +2 -0
  18. package/src/constants/testAddress.ts +36 -487
  19. package/src/models/index.ts +1 -0
  20. package/src/models/scallop.ts +23 -19
  21. package/src/models/scallopAddress.ts +17 -5
  22. package/src/models/scallopBuilder.ts +36 -41
  23. package/src/models/scallopCache.ts +3 -3
  24. package/src/models/scallopClient.ts +93 -98
  25. package/src/models/scallopConstants.ts +399 -0
  26. package/src/models/scallopIndexer.ts +11 -24
  27. package/src/models/scallopQuery.ts +76 -79
  28. package/src/models/scallopUtils.ts +126 -250
  29. package/src/queries/borrowIncentiveQuery.ts +25 -58
  30. package/src/queries/borrowLimitQuery.ts +3 -6
  31. package/src/queries/coreQuery.ts +98 -114
  32. package/src/queries/flashloanFeeQuery.ts +86 -0
  33. package/src/queries/index.ts +1 -0
  34. package/src/queries/isolatedAssetQuery.ts +12 -11
  35. package/src/queries/poolAddressesQuery.ts +211 -117
  36. package/src/queries/portfolioQuery.ts +60 -70
  37. package/src/queries/priceQuery.ts +16 -22
  38. package/src/queries/sCoinQuery.ts +15 -16
  39. package/src/queries/spoolQuery.ts +49 -59
  40. package/src/queries/supplyLimitQuery.ts +2 -6
  41. package/src/queries/switchboardQuery.ts +64 -0
  42. package/src/queries/xOracleQuery.ts +29 -32
  43. package/src/types/address.ts +21 -19
  44. package/src/types/builder/borrowIncentive.ts +2 -3
  45. package/src/types/builder/core.ts +20 -27
  46. package/src/types/builder/index.ts +1 -2
  47. package/src/types/builder/referral.ts +4 -8
  48. package/src/types/builder/sCoin.ts +4 -8
  49. package/src/types/builder/spool.ts +7 -10
  50. package/src/types/constant/common.ts +44 -49
  51. package/src/types/constant/enum.ts +15 -27
  52. package/src/types/constant/xOracle.ts +3 -2
  53. package/src/types/model.ts +49 -28
  54. package/src/types/query/borrowIncentive.ts +7 -24
  55. package/src/types/query/core.ts +8 -18
  56. package/src/types/query/portfolio.ts +9 -17
  57. package/src/types/query/spool.ts +5 -11
  58. package/src/types/utils.ts +1 -21
  59. package/src/utils/core.ts +1 -1
  60. package/src/utils/query.ts +15 -23
  61. package/src/utils/util.ts +6 -84
  62. package/src/constants/coinGecko.ts +0 -34
  63. package/src/constants/enum.ts +0 -268
  64. package/src/constants/flashloan.ts +0 -18
  65. package/src/constants/poolAddress.ts +0 -898
  66. package/src/models/scallopPrice.ts +0 -0
@@ -1,14 +1,8 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import {
3
- SUPPORT_COLLATERALS,
4
- SUPPORT_POOLS,
5
- SUPPORT_SPOOLS,
6
- } from '../constants';
7
2
  import { minBigNumber, estimatedFactor } from 'src/utils';
8
3
  import type { ScallopQuery } from '../models';
9
4
  import type {
10
5
  Market,
11
- SupportPoolCoins,
12
6
  MarketPool,
13
7
  Spool,
14
8
  StakeAccount,
@@ -16,16 +10,10 @@ import type {
16
10
  Lending,
17
11
  ObligationAccounts,
18
12
  ObligationAccount,
19
- SupportStakeMarketCoins,
20
- SupportCollateralCoins,
21
13
  CoinAmounts,
22
14
  CoinPrices,
23
- SupportMarketCoins,
24
15
  TotalValueLocked,
25
- SupportBorrowIncentiveCoins,
26
16
  ObligationBorrowIcentiveReward,
27
- SupportBorrowIncentiveRewardCoins,
28
- SupportAssetCoins,
29
17
  MarketPools,
30
18
  MarketCollaterals,
31
19
  } from '../types';
@@ -44,7 +32,7 @@ import { normalizeStructTag, SUI_TYPE_ARG } from '@scallop-io/sui-kit';
44
32
  */
45
33
  export const getLendings = async (
46
34
  query: ScallopQuery,
47
- poolCoinNames: SupportPoolCoins[] = [...SUPPORT_POOLS],
35
+ poolCoinNames: string[] = [...query.constants.whitelist.lending],
48
36
  ownerAddress?: string,
49
37
  marketPools?: MarketPools,
50
38
  coinPrices?: CoinPrices,
@@ -54,8 +42,8 @@ export const getLendings = async (
54
42
  query.utils.parseMarketCoinName(poolCoinName)
55
43
  );
56
44
  const stakeMarketCoinNames = marketCoinNames.filter((marketCoinName) =>
57
- (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName)
58
- ) as SupportStakeMarketCoins[];
45
+ query.constants.whitelist.spool.has(marketCoinName)
46
+ ) as string[];
59
47
 
60
48
  coinPrices = coinPrices ?? (await query.utils.getCoinPrices());
61
49
  marketPools =
@@ -123,7 +111,7 @@ export const getLendings = async (
123
111
  */
124
112
  export const getLending = async (
125
113
  query: ScallopQuery,
126
- poolCoinName: SupportPoolCoins,
114
+ poolCoinName: string,
127
115
  ownerAddress?: string,
128
116
  indexer: boolean = false,
129
117
  marketPool?: MarketPool,
@@ -149,9 +137,8 @@ export const getLending = async (
149
137
  throw new Error(`Failed to fetch marketPool for ${poolCoinName}`);
150
138
 
151
139
  spool =
152
- (spool ??
153
- (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName))
154
- ? await query.getSpool(marketCoinName as SupportStakeMarketCoins, {
140
+ (spool ?? query.constants.whitelist.spool.has(marketCoinName))
141
+ ? await query.getSpool(marketCoinName as string, {
155
142
  indexer,
156
143
  marketPool,
157
144
  coinPrices: {
@@ -163,12 +150,8 @@ export const getLending = async (
163
150
  // if (!spool) throw new Error(`Failed to fetch spool for ${poolCoinName}`);
164
151
 
165
152
  stakeAccounts =
166
- stakeAccounts ||
167
- (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName)
168
- ? await query.getStakeAccounts(
169
- marketCoinName as SupportStakeMarketCoins,
170
- ownerAddress
171
- )
153
+ stakeAccounts || query.constants.whitelist.spool.has(marketCoinName)
154
+ ? await query.getStakeAccounts(marketCoinName as string, ownerAddress)
172
155
  : [];
173
156
  coinAmount =
174
157
  coinAmount || (await query.getCoinAmount(poolCoinName, ownerAddress));
@@ -375,18 +358,15 @@ export const getObligationAccount = async (
375
358
  coinPrices?: CoinPrices,
376
359
  coinAmounts?: CoinAmounts
377
360
  ) => {
378
- const coinNames: SupportAssetCoins[] = Array.from(
379
- new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
380
- );
381
- const collateralAssetCoinNames = [
382
- ...SUPPORT_COLLATERALS,
383
- ] as SupportCollateralCoins[];
384
-
385
361
  market = market ?? (await query.getMarketPools(undefined, { indexer }));
386
362
  coinPrices =
387
363
  coinPrices ?? (await query.getAllCoinPrices({ marketPools: market.pools }));
388
364
  coinAmounts =
389
- coinAmounts ?? (await query.getCoinAmounts(coinNames, ownerAddress));
365
+ coinAmounts ??
366
+ (await query.getCoinAmounts(
367
+ Array.from(query.constants.whitelist.lending),
368
+ ownerAddress
369
+ ));
390
370
 
391
371
  const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] =
392
372
  await Promise.all([
@@ -410,12 +390,13 @@ export const getObligationAccount = async (
410
390
  let totalBorrowedValue = BigNumber(0);
411
391
  let totalBorrowedValueWithWeight = BigNumber(0);
412
392
 
413
- for (const assetCoinName of collateralAssetCoinNames) {
393
+ for (const assetCoinName of Array.from(
394
+ query.constants.whitelist.collateral
395
+ )) {
414
396
  const collateral = obligationQuery?.collaterals.find((collateral) => {
415
- const collateralCoinName =
416
- query.utils.parseCoinNameFromType<SupportCollateralCoins>(
417
- collateral.type.name
418
- );
397
+ const collateralCoinName = query.utils.parseCoinNameFromType(
398
+ collateral.type.name
399
+ );
419
400
  return assetCoinName === collateralCoinName;
420
401
  });
421
402
 
@@ -474,15 +455,17 @@ export const getObligationAccount = async (
474
455
  }
475
456
  }
476
457
 
477
- const borrowAssetCoinNames: SupportPoolCoins[] = [
478
- ...new Set([...Object.values(market.pools).map((pool) => pool.coinName)]),
458
+ const borrowAssetCoinNames: string[] = [
459
+ ...new Set([
460
+ ...Object.values(market.pools)
461
+ .filter((t) => !!t)
462
+ .map((pool) => pool.coinName),
463
+ ]),
479
464
  ];
480
465
 
481
466
  for (const assetCoinName of borrowAssetCoinNames) {
482
467
  const debt = obligationQuery?.debts.find((debt) => {
483
- const poolCoinName = query.utils.parseCoinNameFromType<SupportPoolCoins>(
484
- debt.type.name
485
- );
468
+ const poolCoinName = query.utils.parseCoinNameFromType(debt.type.name);
486
469
  return assetCoinName === poolCoinName;
487
470
  });
488
471
 
@@ -546,7 +529,9 @@ export const getObligationAccount = async (
546
529
  for (const [poolCoinName, borrowIncentiveAccount] of Object.entries(
547
530
  borrowIncentiveAccounts
548
531
  )) {
549
- const coinName = poolCoinName as SupportBorrowIncentiveCoins;
532
+ if (!borrowIncentiveAccount) continue;
533
+
534
+ const coinName = poolCoinName as string;
550
535
  const borrowIncentivePool = borrowIncentivePools[coinName];
551
536
  if (borrowIncentivePool) {
552
537
  const rewards: ObligationBorrowIcentiveReward[] = [];
@@ -556,7 +541,6 @@ export const getObligationAccount = async (
556
541
  borrowIncentivePool.points[
557
542
  query.utils.parseSCoinTypeNameToMarketCoinName(key)
558
543
  ];
559
-
560
544
  if (accountPoint && poolPoint) {
561
545
  let availableClaimAmount = BigNumber(0);
562
546
  let availableClaimCoin = BigNumber(0);
@@ -599,11 +583,6 @@ export const getObligationAccount = async (
599
583
  .toNumber()
600
584
  : 1;
601
585
 
602
- // console.log({
603
- // availableClaimAmount: availableClaimAmount.toString(),
604
- // coinName: poolPoint.coinName,
605
- // coinType: poolPoint.coinType,
606
- // });
607
586
  if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
608
587
  rewards.push({
609
588
  coinName: poolPoint.coinName,
@@ -611,6 +590,7 @@ export const getObligationAccount = async (
611
590
  symbol: poolPoint.symbol,
612
591
  coinDecimal: poolPoint.coinDecimal,
613
592
  coinPrice: poolPoint.coinPrice,
593
+ weightedBorrowAmount: accountBorrowedAmount.toNumber(),
614
594
  availableClaimAmount: availableClaimAmount.toNumber(),
615
595
  availableClaimCoin: availableClaimCoin.toNumber(),
616
596
  boostValue,
@@ -623,9 +603,7 @@ export const getObligationAccount = async (
623
603
  if (
624
604
  Object.keys(borrowIncentivePool.points).some((coinName: any) => {
625
605
  const rewardApr =
626
- borrowIncentivePool.points[
627
- coinName as SupportBorrowIncentiveRewardCoins
628
- ]?.rewardApr;
606
+ borrowIncentivePool.points[coinName as string]?.rewardApr;
629
607
  return (
630
608
  rewardApr !== Infinity &&
631
609
  typeof rewardApr == 'number' &&
@@ -706,8 +684,8 @@ export const getObligationAccount = async (
706
684
  for (const [collateralCoinName, obligationCollateral] of Object.entries(
707
685
  obligationAccount.collaterals
708
686
  )) {
709
- const marketCollateral =
710
- market.collaterals[collateralCoinName as SupportCollateralCoins];
687
+ if (!obligationCollateral) continue;
688
+ const marketCollateral = market.collaterals[collateralCoinName as string];
711
689
  if (marketCollateral) {
712
690
  let estimatedAvailableWithdrawAmount = BigNumber(
713
691
  obligationAccount.totalAvailableCollateralValue
@@ -746,7 +724,8 @@ export const getObligationAccount = async (
746
724
  for (const [poolCoinName, obligationDebt] of Object.entries(
747
725
  obligationAccount.debts
748
726
  )) {
749
- const marketPool = market.pools[poolCoinName as SupportPoolCoins];
727
+ if (!obligationDebt) continue;
728
+ const marketPool = market.pools[poolCoinName as string];
750
729
  if (marketPool) {
751
730
  const estimatedRequiredRepayAmount = BigNumber(
752
731
  obligationDebt.requiredRepayAmount
@@ -836,6 +815,7 @@ export const getTotalValueLocked = async (
836
815
  }
837
816
 
838
817
  for (const pool of Object.values(market.pools)) {
818
+ if (!pool) continue;
839
819
  supplyLendingValue = supplyLendingValue.plus(
840
820
  BigNumber(pool.supplyCoin).multipliedBy(pool.coinPrice)
841
821
  );
@@ -846,6 +826,7 @@ export const getTotalValueLocked = async (
846
826
 
847
827
  // console.dir(market.collaterals, { depth: null });
848
828
  for (const collateral of Object.values(market.collaterals)) {
829
+ if (!collateral) continue;
849
830
  supplyCollateralValue = supplyCollateralValue.plus(
850
831
  BigNumber(collateral.depositCoin).multipliedBy(collateral.coinPrice)
851
832
  );
@@ -897,7 +878,9 @@ export const getUserPortfolio = async (
897
878
 
898
879
  // get pending rewards (spool and borrow incentive)
899
880
  const parsedLendings = Object.values(lendings)
900
- .filter((t) => t.availableWithdrawCoin > 0)
881
+ .filter(
882
+ (t): t is NonNullable<typeof t> => !!t && t.availableWithdrawCoin > 0
883
+ )
901
884
  .map((lending) => ({
902
885
  suppliedCoin: lending.availableWithdrawCoin,
903
886
  suppliedValue: lending.suppliedValue,
@@ -928,7 +911,10 @@ export const getUserPortfolio = async (
928
911
  totalUnhealthyCollateralInUsd:
929
912
  obligationAccount.totalUnhealthyCollateralValue,
930
913
  borrowedPools: Object.values(obligationAccount.debts)
931
- .filter((debt) => debt.borrowedCoin > 0)
914
+ .filter(
915
+ (debt): debt is NonNullable<typeof debt> =>
916
+ !!debt && debt.borrowedCoin > 0
917
+ )
932
918
  .map((debt) => ({
933
919
  coinName: debt.coinName,
934
920
  symbol: debt.symbol,
@@ -942,7 +928,9 @@ export const getUserPortfolio = async (
942
928
  incentiveInfos: Object.values(
943
929
  borrowIncentivePools[debt.coinName]?.points ?? {}
944
930
  )
945
- .filter((t) => isFinite(t.rewardApr))
931
+ .filter(
932
+ (t): t is NonNullable<typeof t> => !!t && isFinite(t.rewardApr)
933
+ )
946
934
  .map((t) => ({
947
935
  coinName: t.coinName,
948
936
  symbol: t.symbol,
@@ -955,16 +943,18 @@ export const getUserPortfolio = async (
955
943
 
956
944
  const pendingLendingRewards = Object.values(lendings).reduce(
957
945
  (acc, reward) => {
958
- if (reward.availableClaimCoin === 0) return acc;
959
- if (!acc[reward.symbol]) {
960
- acc[reward.symbol] = {
961
- symbol: reward.symbol,
962
- coinType: normalizeStructTag(SUI_TYPE_ARG), // @TODO: for now lending reward is all in SUI
963
- coinPrice: reward.coinPrice,
964
- pendingRewardInCoin: reward.availableClaimCoin,
965
- };
966
- } else {
967
- acc[reward.symbol].pendingRewardInCoin += reward.availableClaimCoin;
946
+ if (reward) {
947
+ if (reward.availableClaimCoin === 0) return acc;
948
+ if (!acc[reward.symbol]) {
949
+ acc[reward.symbol] = {
950
+ symbol: reward.symbol,
951
+ coinType: normalizeStructTag(SUI_TYPE_ARG), // @TODO: for now lending reward is all in SUI
952
+ coinPrice: reward.coinPrice,
953
+ pendingRewardInCoin: reward.availableClaimCoin,
954
+ };
955
+ } else {
956
+ acc[reward.symbol].pendingRewardInCoin += reward.availableClaimCoin;
957
+ }
968
958
  }
969
959
  return acc;
970
960
  },
@@ -984,7 +974,7 @@ export const getUserPortfolio = async (
984
974
  .reduce(
985
975
  (acc, curr) => {
986
976
  Object.values(curr.borrowIncentives).forEach((incentive) => {
987
- incentive.rewards.forEach((reward) => {
977
+ incentive?.rewards.forEach((reward) => {
988
978
  if (reward.availableClaimCoin === 0) return acc;
989
979
  if (!acc[reward.coinName]) {
990
980
  acc[reward.coinName] = {
@@ -1,14 +1,8 @@
1
1
  import { SuiObjectData } from '@mysten/sui/client';
2
2
  import type { ScallopAddress, ScallopQuery } from '../models';
3
- import type {
4
- CoinPrices,
5
- MarketPools,
6
- OptionalKeys,
7
- SupportAssetCoins,
8
- SupportSCoin,
9
- } from '../types';
10
- import { SUPPORT_SCOIN } from 'src/constants/common';
3
+ import type { CoinPrices, MarketPools, OptionalKeys } from '../types';
11
4
  import BigNumber from 'bignumber.js';
5
+ import { ScallopConstants } from 'src/models/scallopConstants';
12
6
 
13
7
  /**
14
8
  * Get price from pyth fee object.
@@ -23,7 +17,7 @@ export const getPythPrice = async (
23
17
  }: {
24
18
  address: ScallopAddress;
25
19
  },
26
- assetCoinName: SupportAssetCoins,
20
+ assetCoinName: string,
27
21
  priceFeedObject?: SuiObjectData | null
28
22
  ) => {
29
23
  const pythFeedObjectId = address.get(
@@ -70,15 +64,15 @@ export const getPythPrice = async (
70
64
 
71
65
  export const getPythPrices = async (
72
66
  {
73
- address,
67
+ constants,
74
68
  }: {
75
- address: ScallopAddress;
69
+ constants: ScallopConstants;
76
70
  },
77
- assetCoinNames: SupportAssetCoins[]
71
+ assetCoinNames: string[]
78
72
  ) => {
79
73
  const pythPriceFeedIds = assetCoinNames.reduce(
80
74
  (prev, assetCoinName) => {
81
- const pythPriceFeed = address.get(
75
+ const pythPriceFeed = constants.address.get(
82
76
  `core.coins.${assetCoinName}.oracle.pyth.feedObject`
83
77
  );
84
78
  if (pythPriceFeed) {
@@ -90,11 +84,11 @@ export const getPythPrices = async (
90
84
  }
91
85
  return prev;
92
86
  },
93
- {} as Record<string, SupportAssetCoins[]>
87
+ {} as Record<string, string[]>
94
88
  );
95
89
 
96
90
  // Fetch multiple objects at once to save rpc calls
97
- const priceFeedObjects = await address.cache.queryGetObjects(
91
+ const priceFeedObjects = await constants.address.cache.queryGetObjects(
98
92
  Object.keys(pythPriceFeedIds)
99
93
  );
100
94
 
@@ -105,7 +99,7 @@ export const getPythPrices = async (
105
99
  });
106
100
  return prev;
107
101
  },
108
- {} as Record<SupportAssetCoins, SuiObjectData>
102
+ {} as Record<string, SuiObjectData>
109
103
  );
110
104
 
111
105
  return (
@@ -114,8 +108,8 @@ export const getPythPrices = async (
114
108
  async ([assetCoinName, priceFeedObject]) => ({
115
109
  coinName: assetCoinName,
116
110
  price: await getPythPrice(
117
- { address },
118
- assetCoinName as SupportAssetCoins,
111
+ constants,
112
+ assetCoinName as string,
119
113
  priceFeedObject
120
114
  ),
121
115
  })
@@ -123,10 +117,10 @@ export const getPythPrices = async (
123
117
  )
124
118
  ).reduce(
125
119
  (prev, curr) => {
126
- prev[curr.coinName as SupportAssetCoins] = curr.price;
120
+ prev[curr.coinName as string] = curr.price;
127
121
  return prev;
128
122
  },
129
- {} as Record<SupportAssetCoins, number>
123
+ {} as Record<string, number>
130
124
  );
131
125
  };
132
126
 
@@ -150,8 +144,8 @@ export const getAllCoinPrices = async (
150
144
  throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
151
145
  }
152
146
 
153
- const sCoinPrices: OptionalKeys<Record<SupportSCoin, number>> = {};
154
- SUPPORT_SCOIN.forEach((sCoinName) => {
147
+ const sCoinPrices: OptionalKeys<Record<string, number>> = {};
148
+ query.constants.whitelist.scoin.forEach((sCoinName) => {
155
149
  const coinName = query.utils.parseCoinName(sCoinName);
156
150
  sCoinPrices[sCoinName] = BigNumber(coinPrices[coinName] ?? 0)
157
151
  .multipliedBy(marketPools[coinName]?.conversionRate ?? 1)
@@ -1,9 +1,8 @@
1
1
  import { bcs } from '@mysten/sui/bcs';
2
2
  import assert from 'assert';
3
3
  import BigNumber from 'bignumber.js';
4
- import { SUPPORT_SCOIN } from 'src/constants';
5
4
  import { ScallopQuery, ScallopUtils } from 'src/models';
6
- import { OptionalKeys, SupportSCoin, sCoinBalance } from 'src/types';
5
+ import { OptionalKeys, sCoinBalance } from 'src/types';
7
6
 
8
7
  /**
9
8
  * Get total supply of sCoin
@@ -17,7 +16,7 @@ export const getSCoinTotalSupply = async (
17
16
  }: {
18
17
  utils: ScallopUtils;
19
18
  },
20
- sCoinName: SupportSCoin
19
+ sCoinName: string
21
20
  ): Promise<sCoinBalance> => {
22
21
  const sCoinPkgId = utils.address.get('scoin.id');
23
22
  // get treasury
@@ -60,11 +59,11 @@ export const getSCoinAmounts = async (
60
59
  }: {
61
60
  utils: ScallopUtils;
62
61
  },
63
- sCoinNames: SupportSCoin[] = [...SUPPORT_SCOIN],
62
+ sCoinNames: string[] = [...utils.constants.whitelist.scoin],
64
63
  ownerAddress?: string
65
64
  ) => {
66
65
  const owner = ownerAddress || utils.suiKit.currentAddress();
67
- const sCoins = {} as OptionalKeys<Record<SupportSCoin, number>>;
66
+ const sCoins = {} as OptionalKeys<Record<string, number>>;
68
67
 
69
68
  await Promise.allSettled(
70
69
  sCoinNames.map(async (sCoinName) => {
@@ -90,7 +89,7 @@ export const getSCoinAmount = async (
90
89
  }: {
91
90
  utils: ScallopUtils;
92
91
  },
93
- sCoinName: SupportSCoin,
92
+ sCoinName: string,
94
93
  ownerAddress?: string
95
94
  ) => {
96
95
  const owner = ownerAddress || utils.suiKit.currentAddress();
@@ -102,18 +101,18 @@ export const getSCoinAmount = async (
102
101
  return BigNumber(coinBalance?.totalBalance ?? '0').toNumber();
103
102
  };
104
103
 
105
- const isSupportStakeCoins = (value: string): value is SupportSCoin => {
106
- return SUPPORT_SCOIN.includes(value as SupportSCoin);
107
- };
108
-
109
- const checkAssetParams = (fromSCoin: SupportSCoin, toSCoin: SupportSCoin) => {
104
+ const checkAssetParams = (
105
+ utils: ScallopUtils,
106
+ fromSCoin: string,
107
+ toSCoin: string
108
+ ) => {
110
109
  if (fromSCoin === toSCoin)
111
110
  throw new Error('fromAsset and toAsset must be different');
112
111
 
113
- if (!isSupportStakeCoins(fromSCoin))
112
+ if (!utils.constants.whitelist.scoin.has(fromSCoin))
114
113
  throw new Error('fromAsset is not supported');
115
114
 
116
- if (!isSupportStakeCoins(toSCoin)) {
115
+ if (!utils.constants.whitelist.scoin.has(toSCoin)) {
117
116
  throw new Error('toAsset is not supported');
118
117
  }
119
118
  };
@@ -129,11 +128,11 @@ const checkAssetParams = (fromSCoin: SupportSCoin, toSCoin: SupportSCoin) => {
129
128
  */
130
129
  export const getSCoinSwapRate = async (
131
130
  query: ScallopQuery,
132
- fromSCoin: SupportSCoin,
133
- toSCoin: SupportSCoin,
131
+ fromSCoin: string,
132
+ toSCoin: string,
134
133
  underlyingCoinPrice?: number
135
134
  ) => {
136
- checkAssetParams(fromSCoin, toSCoin);
135
+ checkAssetParams(query.utils, fromSCoin, toSCoin);
137
136
  const fromCoinName = query.utils.parseCoinName(fromSCoin);
138
137
  const toCoinName = query.utils.parseCoinName(toSCoin);
139
138