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

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 (60) hide show
  1. package/dist/index.d.mts +451 -602
  2. package/dist/index.d.ts +451 -602
  3. package/dist/index.js +29 -60
  4. package/dist/index.mjs +6 -6
  5. package/package.json +1 -1
  6. package/src/builders/loyaltyProgramBuilder.ts +5 -3
  7. package/src/builders/oracle.ts +10 -24
  8. package/src/builders/referralBuilder.ts +5 -9
  9. package/src/builders/sCoinBuilder.ts +9 -8
  10. package/src/builders/spoolBuilder.ts +4 -6
  11. package/src/constants/common.ts +114 -126
  12. package/src/constants/index.ts +0 -5
  13. package/src/constants/pyth.ts +25 -34
  14. package/src/constants/queryKeys.ts +2 -0
  15. package/src/models/index.ts +1 -0
  16. package/src/models/scallop.ts +23 -19
  17. package/src/models/scallopAddress.ts +7 -4
  18. package/src/models/scallopBuilder.ts +36 -41
  19. package/src/models/scallopCache.ts +1 -1
  20. package/src/models/scallopClient.ts +93 -94
  21. package/src/models/scallopConstants.ts +342 -0
  22. package/src/models/scallopIndexer.ts +11 -24
  23. package/src/models/scallopQuery.ts +70 -77
  24. package/src/models/scallopUtils.ts +122 -249
  25. package/src/queries/borrowIncentiveQuery.ts +21 -56
  26. package/src/queries/borrowLimitQuery.ts +3 -6
  27. package/src/queries/coreQuery.ts +94 -112
  28. package/src/queries/flashloanFeeQuery.ts +86 -0
  29. package/src/queries/isolatedAssetQuery.ts +12 -11
  30. package/src/queries/poolAddressesQuery.ts +187 -112
  31. package/src/queries/portfolioQuery.ts +65 -67
  32. package/src/queries/priceQuery.ts +16 -22
  33. package/src/queries/sCoinQuery.ts +15 -16
  34. package/src/queries/spoolQuery.ts +49 -59
  35. package/src/queries/supplyLimitQuery.ts +2 -6
  36. package/src/queries/xOracleQuery.ts +4 -15
  37. package/src/types/address.ts +12 -18
  38. package/src/types/builder/borrowIncentive.ts +2 -3
  39. package/src/types/builder/core.ts +20 -27
  40. package/src/types/builder/index.ts +1 -2
  41. package/src/types/builder/referral.ts +4 -8
  42. package/src/types/builder/sCoin.ts +4 -8
  43. package/src/types/builder/spool.ts +7 -10
  44. package/src/types/constant/common.ts +43 -49
  45. package/src/types/constant/enum.ts +15 -27
  46. package/src/types/constant/xOracle.ts +3 -5
  47. package/src/types/model.ts +49 -28
  48. package/src/types/query/borrowIncentive.ts +7 -24
  49. package/src/types/query/core.ts +8 -18
  50. package/src/types/query/portfolio.ts +8 -17
  51. package/src/types/query/spool.ts +5 -11
  52. package/src/types/utils.ts +1 -21
  53. package/src/utils/core.ts +1 -1
  54. package/src/utils/query.ts +13 -20
  55. package/src/utils/util.ts +6 -84
  56. package/src/constants/coinGecko.ts +0 -34
  57. package/src/constants/enum.ts +0 -268
  58. package/src/constants/flashloan.ts +0 -18
  59. package/src/constants/poolAddress.ts +0 -898
  60. 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,10 @@ 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] as readonly string[]).includes(
46
+ marketCoinName
47
+ )
48
+ ) as string[];
59
49
 
60
50
  coinPrices = coinPrices ?? (await query.utils.getCoinPrices());
61
51
  marketPools =
@@ -123,7 +113,7 @@ export const getLendings = async (
123
113
  */
124
114
  export const getLending = async (
125
115
  query: ScallopQuery,
126
- poolCoinName: SupportPoolCoins,
116
+ poolCoinName: string,
127
117
  ownerAddress?: string,
128
118
  indexer: boolean = false,
129
119
  marketPool?: MarketPool,
@@ -150,8 +140,10 @@ export const getLending = async (
150
140
 
151
141
  spool =
152
142
  (spool ??
153
- (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName))
154
- ? await query.getSpool(marketCoinName as SupportStakeMarketCoins, {
143
+ ([...query.constants.whitelist.spool] as readonly string[]).includes(
144
+ marketCoinName
145
+ ))
146
+ ? await query.getSpool(marketCoinName as string, {
155
147
  indexer,
156
148
  marketPool,
157
149
  coinPrices: {
@@ -164,11 +156,10 @@ export const getLending = async (
164
156
 
165
157
  stakeAccounts =
166
158
  stakeAccounts ||
167
- (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName)
168
- ? await query.getStakeAccounts(
169
- marketCoinName as SupportStakeMarketCoins,
170
- ownerAddress
171
- )
159
+ ([...query.constants.whitelist.spool] as readonly string[]).includes(
160
+ marketCoinName
161
+ )
162
+ ? await query.getStakeAccounts(marketCoinName as string, ownerAddress)
172
163
  : [];
173
164
  coinAmount =
174
165
  coinAmount || (await query.getCoinAmount(poolCoinName, ownerAddress));
@@ -375,18 +366,15 @@ export const getObligationAccount = async (
375
366
  coinPrices?: CoinPrices,
376
367
  coinAmounts?: CoinAmounts
377
368
  ) => {
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
369
  market = market ?? (await query.getMarketPools(undefined, { indexer }));
386
370
  coinPrices =
387
371
  coinPrices ?? (await query.getAllCoinPrices({ marketPools: market.pools }));
388
372
  coinAmounts =
389
- coinAmounts ?? (await query.getCoinAmounts(coinNames, ownerAddress));
373
+ coinAmounts ??
374
+ (await query.getCoinAmounts(
375
+ Array.from(query.constants.whitelist.lending),
376
+ ownerAddress
377
+ ));
390
378
 
391
379
  const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] =
392
380
  await Promise.all([
@@ -410,12 +398,13 @@ export const getObligationAccount = async (
410
398
  let totalBorrowedValue = BigNumber(0);
411
399
  let totalBorrowedValueWithWeight = BigNumber(0);
412
400
 
413
- for (const assetCoinName of collateralAssetCoinNames) {
401
+ for (const assetCoinName of Array.from(
402
+ query.constants.whitelist.collateral
403
+ )) {
414
404
  const collateral = obligationQuery?.collaterals.find((collateral) => {
415
- const collateralCoinName =
416
- query.utils.parseCoinNameFromType<SupportCollateralCoins>(
417
- collateral.type.name
418
- );
405
+ const collateralCoinName = query.utils.parseCoinNameFromType(
406
+ collateral.type.name
407
+ );
419
408
  return assetCoinName === collateralCoinName;
420
409
  });
421
410
 
@@ -474,15 +463,17 @@ export const getObligationAccount = async (
474
463
  }
475
464
  }
476
465
 
477
- const borrowAssetCoinNames: SupportPoolCoins[] = [
478
- ...new Set([...Object.values(market.pools).map((pool) => pool.coinName)]),
466
+ const borrowAssetCoinNames: string[] = [
467
+ ...new Set([
468
+ ...Object.values(market.pools)
469
+ .filter((t) => !!t)
470
+ .map((pool) => pool.coinName),
471
+ ]),
479
472
  ];
480
473
 
481
474
  for (const assetCoinName of borrowAssetCoinNames) {
482
475
  const debt = obligationQuery?.debts.find((debt) => {
483
- const poolCoinName = query.utils.parseCoinNameFromType<SupportPoolCoins>(
484
- debt.type.name
485
- );
476
+ const poolCoinName = query.utils.parseCoinNameFromType(debt.type.name);
486
477
  return assetCoinName === poolCoinName;
487
478
  });
488
479
 
@@ -546,7 +537,9 @@ export const getObligationAccount = async (
546
537
  for (const [poolCoinName, borrowIncentiveAccount] of Object.entries(
547
538
  borrowIncentiveAccounts
548
539
  )) {
549
- const coinName = poolCoinName as SupportBorrowIncentiveCoins;
540
+ if (!borrowIncentiveAccount) continue;
541
+
542
+ const coinName = poolCoinName as string;
550
543
  const borrowIncentivePool = borrowIncentivePools[coinName];
551
544
  if (borrowIncentivePool) {
552
545
  const rewards: ObligationBorrowIcentiveReward[] = [];
@@ -599,11 +592,6 @@ export const getObligationAccount = async (
599
592
  .toNumber()
600
593
  : 1;
601
594
 
602
- // console.log({
603
- // availableClaimAmount: availableClaimAmount.toString(),
604
- // coinName: poolPoint.coinName,
605
- // coinType: poolPoint.coinType,
606
- // });
607
595
  if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
608
596
  rewards.push({
609
597
  coinName: poolPoint.coinName,
@@ -623,9 +611,7 @@ export const getObligationAccount = async (
623
611
  if (
624
612
  Object.keys(borrowIncentivePool.points).some((coinName: any) => {
625
613
  const rewardApr =
626
- borrowIncentivePool.points[
627
- coinName as SupportBorrowIncentiveRewardCoins
628
- ]?.rewardApr;
614
+ borrowIncentivePool.points[coinName as string]?.rewardApr;
629
615
  return (
630
616
  rewardApr !== Infinity &&
631
617
  typeof rewardApr == 'number' &&
@@ -706,8 +692,8 @@ export const getObligationAccount = async (
706
692
  for (const [collateralCoinName, obligationCollateral] of Object.entries(
707
693
  obligationAccount.collaterals
708
694
  )) {
709
- const marketCollateral =
710
- market.collaterals[collateralCoinName as SupportCollateralCoins];
695
+ if (!obligationCollateral) continue;
696
+ const marketCollateral = market.collaterals[collateralCoinName as string];
711
697
  if (marketCollateral) {
712
698
  let estimatedAvailableWithdrawAmount = BigNumber(
713
699
  obligationAccount.totalAvailableCollateralValue
@@ -746,7 +732,8 @@ export const getObligationAccount = async (
746
732
  for (const [poolCoinName, obligationDebt] of Object.entries(
747
733
  obligationAccount.debts
748
734
  )) {
749
- const marketPool = market.pools[poolCoinName as SupportPoolCoins];
735
+ if (!obligationDebt) continue;
736
+ const marketPool = market.pools[poolCoinName as string];
750
737
  if (marketPool) {
751
738
  const estimatedRequiredRepayAmount = BigNumber(
752
739
  obligationDebt.requiredRepayAmount
@@ -836,6 +823,7 @@ export const getTotalValueLocked = async (
836
823
  }
837
824
 
838
825
  for (const pool of Object.values(market.pools)) {
826
+ if (!pool) continue;
839
827
  supplyLendingValue = supplyLendingValue.plus(
840
828
  BigNumber(pool.supplyCoin).multipliedBy(pool.coinPrice)
841
829
  );
@@ -846,6 +834,7 @@ export const getTotalValueLocked = async (
846
834
 
847
835
  // console.dir(market.collaterals, { depth: null });
848
836
  for (const collateral of Object.values(market.collaterals)) {
837
+ if (!collateral) continue;
849
838
  supplyCollateralValue = supplyCollateralValue.plus(
850
839
  BigNumber(collateral.depositCoin).multipliedBy(collateral.coinPrice)
851
840
  );
@@ -897,7 +886,9 @@ export const getUserPortfolio = async (
897
886
 
898
887
  // get pending rewards (spool and borrow incentive)
899
888
  const parsedLendings = Object.values(lendings)
900
- .filter((t) => t.availableWithdrawCoin > 0)
889
+ .filter(
890
+ (t): t is NonNullable<typeof t> => !!t && t.availableWithdrawCoin > 0
891
+ )
901
892
  .map((lending) => ({
902
893
  suppliedCoin: lending.availableWithdrawCoin,
903
894
  suppliedValue: lending.suppliedValue,
@@ -928,7 +919,10 @@ export const getUserPortfolio = async (
928
919
  totalUnhealthyCollateralInUsd:
929
920
  obligationAccount.totalUnhealthyCollateralValue,
930
921
  borrowedPools: Object.values(obligationAccount.debts)
931
- .filter((debt) => debt.borrowedCoin > 0)
922
+ .filter(
923
+ (debt): debt is NonNullable<typeof debt> =>
924
+ !!debt && debt.borrowedCoin > 0
925
+ )
932
926
  .map((debt) => ({
933
927
  coinName: debt.coinName,
934
928
  symbol: debt.symbol,
@@ -942,7 +936,9 @@ export const getUserPortfolio = async (
942
936
  incentiveInfos: Object.values(
943
937
  borrowIncentivePools[debt.coinName]?.points ?? {}
944
938
  )
945
- .filter((t) => isFinite(t.rewardApr))
939
+ .filter(
940
+ (t): t is NonNullable<typeof t> => !!t && isFinite(t.rewardApr)
941
+ )
946
942
  .map((t) => ({
947
943
  coinName: t.coinName,
948
944
  symbol: t.symbol,
@@ -955,16 +951,18 @@ export const getUserPortfolio = async (
955
951
 
956
952
  const pendingLendingRewards = Object.values(lendings).reduce(
957
953
  (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;
954
+ if (reward) {
955
+ if (reward.availableClaimCoin === 0) return acc;
956
+ if (!acc[reward.symbol]) {
957
+ acc[reward.symbol] = {
958
+ symbol: reward.symbol,
959
+ coinType: normalizeStructTag(SUI_TYPE_ARG), // @TODO: for now lending reward is all in SUI
960
+ coinPrice: reward.coinPrice,
961
+ pendingRewardInCoin: reward.availableClaimCoin,
962
+ };
963
+ } else {
964
+ acc[reward.symbol].pendingRewardInCoin += reward.availableClaimCoin;
965
+ }
968
966
  }
969
967
  return acc;
970
968
  },
@@ -984,7 +982,7 @@ export const getUserPortfolio = async (
984
982
  .reduce(
985
983
  (acc, curr) => {
986
984
  Object.values(curr.borrowIncentives).forEach((incentive) => {
987
- incentive.rewards.forEach((reward) => {
985
+ incentive?.rewards.forEach((reward) => {
988
986
  if (reward.availableClaimCoin === 0) return acc;
989
987
  if (!acc[reward.coinName]) {
990
988
  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