@scallop-io/sui-scallop-sdk 0.46.39 → 0.46.41

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/builders/loyaltyProgramBuilder.d.ts +1 -1
  2. package/dist/builders/sCoinBuilder.d.ts +4 -0
  3. package/dist/constants/common.d.ts +3 -1
  4. package/dist/constants/enum.d.ts +12 -10
  5. package/dist/constants/flashloan.d.ts +2 -0
  6. package/dist/constants/index.d.ts +1 -0
  7. package/dist/index.js +742 -97
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +739 -92
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/models/scallopBuilder.d.ts +16 -1
  12. package/dist/models/scallopClient.d.ts +5 -0
  13. package/dist/models/scallopQuery.d.ts +24 -1
  14. package/dist/models/scallopUtils.d.ts +32 -2
  15. package/dist/queries/coreQuery.d.ts +7 -0
  16. package/dist/queries/portfolioQuery.d.ts +1 -1
  17. package/dist/queries/sCoinQuery.d.ts +27 -0
  18. package/dist/test.d.ts +1 -0
  19. package/dist/types/address.d.ts +8 -1
  20. package/dist/types/builder/core.d.ts +12 -4
  21. package/dist/types/builder/index.d.ts +6 -1
  22. package/dist/types/builder/sCoin.d.ts +37 -0
  23. package/dist/types/builder/spool.d.ts +2 -1
  24. package/dist/types/constant/common.d.ts +3 -2
  25. package/dist/types/constant/enum.d.ts +13 -1
  26. package/dist/types/query/core.d.ts +2 -1
  27. package/dist/types/query/index.d.ts +1 -0
  28. package/dist/types/query/portfolio.d.ts +1 -0
  29. package/dist/types/query/sCoin.d.ts +1 -0
  30. package/package.json +3 -3
  31. package/src/builders/coreBuilder.ts +72 -17
  32. package/src/builders/index.ts +5 -1
  33. package/src/builders/loyaltyProgramBuilder.ts +1 -1
  34. package/src/builders/referralBuilder.ts +1 -1
  35. package/src/builders/sCoinBuilder.ts +119 -0
  36. package/src/builders/spoolBuilder.ts +1 -1
  37. package/src/builders/vescaBuilder.ts +3 -3
  38. package/src/constants/common.ts +19 -5
  39. package/src/constants/enum.ts +98 -20
  40. package/src/constants/flashloan.ts +18 -0
  41. package/src/constants/index.ts +1 -0
  42. package/src/constants/testAddress.ts +115 -21
  43. package/src/models/scallopAddress.ts +44 -3
  44. package/src/models/scallopBuilder.ts +43 -7
  45. package/src/models/scallopCache.ts +32 -4
  46. package/src/models/scallopClient.ts +121 -0
  47. package/src/models/scallopQuery.ts +57 -1
  48. package/src/models/scallopUtils.ts +56 -2
  49. package/src/queries/coreQuery.ts +102 -4
  50. package/src/queries/portfolioQuery.ts +25 -3
  51. package/src/queries/sCoinQuery.ts +94 -0
  52. package/src/queries/vescaQuery.ts +0 -1
  53. package/src/test.ts +19 -0
  54. package/src/types/address.ts +13 -0
  55. package/src/types/builder/core.ts +19 -4
  56. package/src/types/builder/index.ts +11 -3
  57. package/src/types/builder/sCoin.ts +61 -0
  58. package/src/types/builder/spool.ts +2 -0
  59. package/src/types/constant/common.ts +4 -1
  60. package/src/types/constant/enum.ts +17 -0
  61. package/src/types/query/core.ts +3 -0
  62. package/src/types/query/index.ts +1 -0
  63. package/src/types/query/portfolio.ts +1 -0
  64. package/src/types/query/sCoin.ts +1 -0
  65. package/src/utils/builder.ts +1 -1
  66. package/src/utils/util.ts +13 -17
@@ -24,6 +24,7 @@ import type {
24
24
  TotalValueLocked,
25
25
  SupportBorrowIncentiveCoins,
26
26
  ObligationBorrowIcentiveReward,
27
+ SupportBorrowIncentiveRewardCoins,
27
28
  } from '../types';
28
29
 
29
30
  /**
@@ -118,6 +119,7 @@ export const getLending = async (
118
119
  stakeAccounts?: StakeAccount[],
119
120
  coinAmount?: number,
120
121
  marketCoinAmount?: number,
122
+ sCoinAmount?: number,
121
123
  coinPrice?: number
122
124
  ) => {
123
125
  const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
@@ -140,6 +142,8 @@ export const getLending = async (
140
142
  marketCoinAmount =
141
143
  marketCoinAmount ||
142
144
  (await query.getMarketCoinAmount(marketCoinName, ownerAddress));
145
+ sCoinAmount =
146
+ sCoinAmount || (await query.getSCoinAmount(marketCoinName, ownerAddress));
143
147
  coinPrice =
144
148
  coinPrice ||
145
149
  (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
@@ -206,9 +210,9 @@ export const getLending = async (
206
210
  }
207
211
 
208
212
  // Handle supplied coin
209
- const suppliedAmount = BigNumber(marketCoinAmount).multipliedBy(
210
- marketPool?.conversionRate ?? 1
211
- );
213
+ const suppliedAmount = BigNumber(marketCoinAmount)
214
+ .plus(BigNumber(sCoinAmount))
215
+ .multipliedBy(marketPool?.conversionRate ?? 1);
212
216
  const suppliedCoin = suppliedAmount.shiftedBy(-1 * coinDecimal);
213
217
  const suppliedValue = suppliedCoin.multipliedBy(coinPrice ?? 0);
214
218
 
@@ -351,6 +355,7 @@ export const getObligationAccount = async (
351
355
  let totalBorrowCapacityValue = BigNumber(0);
352
356
  let totalRequiredCollateralValue = BigNumber(0);
353
357
  let totalBorrowedPools = 0;
358
+ let totalRewardedPools = 0;
354
359
  let totalBorrowedValue = BigNumber(0);
355
360
  let totalBorrowedValueWithWeight = BigNumber(0);
356
361
 
@@ -555,6 +560,22 @@ export const getObligationAccount = async (
555
560
  }
556
561
  }
557
562
 
563
+ if (
564
+ Object.keys(borrowIncentivePool.points).some((coinName: any) => {
565
+ const rewardApr =
566
+ borrowIncentivePool.points[
567
+ coinName as SupportBorrowIncentiveRewardCoins
568
+ ]?.rewardApr;
569
+ return (
570
+ rewardApr !== Infinity &&
571
+ typeof rewardApr == 'number' &&
572
+ rewardApr > 0
573
+ );
574
+ }) &&
575
+ borrowIncentiveAccount.debtAmount > 0
576
+ ) {
577
+ totalRewardedPools++;
578
+ }
558
579
  borrowIncentives[coinName] = {
559
580
  coinName: borrowIncentivePool.coinName,
560
581
  coinType: borrowIncentivePool.coinType,
@@ -612,6 +633,7 @@ export const getObligationAccount = async (
612
633
  totalRiskLevel: riskLevel.toNumber(),
613
634
  totalDepositedPools,
614
635
  totalBorrowedPools,
636
+ totalRewardedPools,
615
637
  collaterals,
616
638
  debts,
617
639
  borrowIncentives,
@@ -0,0 +1,94 @@
1
+ import { bcs } from '@mysten/sui.js/bcs';
2
+ import assert from 'assert';
3
+ import BigNumber from 'bignumber.js';
4
+ import { SUPPORT_SCOIN } from 'src/constants';
5
+ import { ScallopQuery } from 'src/models';
6
+ import { OptionalKeys, SupportSCoin, sCoinBalance } from 'src/types';
7
+
8
+ /**
9
+ * Get total supply of sCoin
10
+ * @param query
11
+ * @param sCoinName
12
+ * @returns `number`
13
+ */
14
+ export const getSCoinTotalSupply = async (
15
+ query: ScallopQuery,
16
+ sCoinName: SupportSCoin
17
+ ): Promise<sCoinBalance> => {
18
+ const sCoinPkgId = query.address.get('scoin.id');
19
+ // get treasury
20
+ const args = [query.utils.getSCoinTreasury(sCoinName)];
21
+ const typeArgs = [
22
+ query.utils.parseSCoinType(sCoinName),
23
+ query.utils.parseUnderlyingSCoinType(sCoinName),
24
+ ];
25
+ const queryTarget = `${sCoinPkgId}::s_coin_converter::total_supply`;
26
+ const queryResults = await query.cache.queryInspectTxn({
27
+ queryTarget,
28
+ args,
29
+ typeArgs,
30
+ });
31
+ const results = queryResults.results;
32
+ if (results && results[0].returnValues) {
33
+ const value = Uint8Array.from(results[0].returnValues[0][0]);
34
+ const type = results[0].returnValues[0][1]; // should be u64
35
+ assert(type === 'u64', 'Result type is not u64');
36
+
37
+ return BigNumber(bcs.de(type, value))
38
+ .shiftedBy(
39
+ query.utils.getCoinDecimal(query.utils.parseCoinName(sCoinName))
40
+ )
41
+ .toNumber();
42
+ }
43
+
44
+ return 0;
45
+ };
46
+
47
+ /**
48
+ * Query all owned sCoin amount.
49
+ *
50
+ * @param query - The Scallop query instance.
51
+ * @param sCoinNames - Specific an array of support sCoin name.
52
+ * @param ownerAddress - The owner address.
53
+ * @return All owned sCoins amount.
54
+ */
55
+ export const getSCoinAmounts = async (
56
+ query: ScallopQuery,
57
+ sCoinNames?: SupportSCoin[],
58
+ ownerAddress?: string
59
+ ) => {
60
+ sCoinNames = sCoinNames || [...SUPPORT_SCOIN];
61
+ const owner = ownerAddress || query.suiKit.currentAddress();
62
+ const sCoins = {} as OptionalKeys<Record<SupportSCoin, number>>;
63
+
64
+ await Promise.allSettled(
65
+ sCoinNames.map(async (sCoinName) => {
66
+ const sCoin = await getSCoinAmount(query, sCoinName, owner);
67
+ sCoins[sCoinName] = sCoin;
68
+ })
69
+ );
70
+
71
+ return sCoins;
72
+ };
73
+
74
+ /**
75
+ * Query owned sCoin amount.
76
+ *
77
+ * @param query - The Scallop query instance.
78
+ * @param sCoinNames - Specific support sCoin name.
79
+ * @param ownerAddress - The owner address.
80
+ * @return Owned sCoin amount.
81
+ */
82
+ export const getSCoinAmount = async (
83
+ query: ScallopQuery,
84
+ sCoinName: SupportSCoin,
85
+ ownerAddress?: string
86
+ ) => {
87
+ const owner = ownerAddress || query.suiKit.currentAddress();
88
+ const sCoinType = query.utils.parseSCoinType(sCoinName);
89
+ const amount = await query.cache.queryGetCoinBalance({
90
+ owner,
91
+ coinType: sCoinType,
92
+ });
93
+ return BigNumber(amount).toNumber();
94
+ };
@@ -244,7 +244,6 @@ export const getVeScaTreasuryInfo = async (
244
244
  const treasuryFields = veScaTreasury.data.content
245
245
  .fields as VeScaTreasuryFields;
246
246
 
247
- console.log(treasuryFields);
248
247
  const totalLockedSca = BigNumber(
249
248
  treasuryFields.unlock_schedule.fields.locked_sca_amount
250
249
  )
package/src/test.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { Scallop } from './models';
2
+ import * as dotenv from 'dotenv';
3
+ dotenv.config();
4
+ const scallop = new Scallop({
5
+ secretKey: process.env.SECRET_KEY as string,
6
+ });
7
+
8
+ const main = async () => {
9
+ const query = await scallop.createScallopQuery();
10
+
11
+ const res = await query.getVeScas(
12
+ '0xd1a70cfe7332e994a950b9c570e93def4b6d2ec53b34ff5c0cc9946226a7cf3d'
13
+ );
14
+ console.dir(res, { depth: null });
15
+ };
16
+ main()
17
+ .then()
18
+ .catch(console.error)
19
+ .finally(() => process.exit(0));
@@ -3,6 +3,7 @@ import type {
3
3
  SupportAssetCoins,
4
4
  SupportOracleType,
5
5
  SupportPackageType,
6
+ SupportSCoin,
6
7
  SupportStakeMarketCoins,
7
8
  } from './constant';
8
9
 
@@ -121,6 +122,18 @@ export interface AddressesInterface {
121
122
  rewardPool: string;
122
123
  userRewardTableId: string;
123
124
  };
125
+ scoin: {
126
+ id: string;
127
+ coins: Partial<
128
+ Record<
129
+ SupportSCoin,
130
+ {
131
+ coinType: string;
132
+ treasury: string;
133
+ }
134
+ >
135
+ >;
136
+ };
124
137
  }
125
138
 
126
139
  type AddressPathsProps<T> = T extends string
@@ -4,13 +4,17 @@ import type {
4
4
  SuiObjectArg,
5
5
  SuiTxArg,
6
6
  } from '@scallop-io/sui-kit';
7
- import type { TransactionResult } from '@mysten/sui.js/transactions';
7
+ import type {
8
+ TransactionArgument,
9
+ TransactionResult,
10
+ } from '@mysten/sui.js/transactions';
8
11
  import type { ScallopBuilder } from '../../models';
9
12
  import type {
10
13
  SupportCollateralCoins,
11
14
  SupportPoolCoins,
12
15
  SupportAssetCoins,
13
16
  } from '../constant';
17
+ import { ScallopTxBlockWithoutCoreTxBlock } from '.';
14
18
 
15
19
  export type CoreIds = {
16
20
  protocolPkg: string;
@@ -20,8 +24,16 @@ export type CoreIds = {
20
24
  xOracle: string;
21
25
  };
22
26
 
27
+ export type NestedResult = Extract<
28
+ TransactionArgument,
29
+ { kind: 'NestedResult' }
30
+ >;
31
+ type Obligation = NestedResult;
32
+ type ObligationKey = NestedResult;
33
+ type ObligationHotPotato = NestedResult;
34
+
23
35
  export type CoreNormalMethods = {
24
- openObligation: () => TransactionResult;
36
+ openObligation: () => [Obligation, ObligationKey, ObligationHotPotato];
25
37
  returnObligation: (
26
38
  obligation: SuiAddressArg,
27
39
  obligationHotPotato: SuiObjectArg
@@ -113,7 +125,8 @@ export type CoreQuickMethods = {
113
125
  ) => Promise<TransactionResult>;
114
126
  depositQuick: (
115
127
  amount: number,
116
- poolCoinName: SupportPoolCoins
128
+ poolCoinName: SupportPoolCoins,
129
+ returnSCoin?: boolean
117
130
  ) => Promise<TransactionResult>;
118
131
  withdrawQuick: (
119
132
  amount: number,
@@ -129,7 +142,9 @@ export type CoreQuickMethods = {
129
142
  ) => Promise<void>;
130
143
  };
131
144
 
132
- export type SuiTxBlockWithCoreNormalMethods = SuiKitTxBlock & CoreNormalMethods;
145
+ export type SuiTxBlockWithCoreNormalMethods = SuiKitTxBlock &
146
+ ScallopTxBlockWithoutCoreTxBlock &
147
+ CoreNormalMethods;
133
148
 
134
149
  export type CoreTxBlock = SuiTxBlockWithCoreNormalMethods & CoreQuickMethods;
135
150
 
@@ -4,16 +4,24 @@ import type { BorrowIncentiveTxBlock } from './borrowIncentive';
4
4
  import type { VeScaTxBlock } from './vesca';
5
5
  import type { ReferralTxBlock } from './referral';
6
6
  import { LoyaltyProgramTxBlock } from './loyaltyProgram';
7
+ import { SCoinTxBlock } from './sCoin';
7
8
 
8
9
  export type * from './core';
9
10
  export type * from './spool';
10
11
  export type * from './borrowIncentive';
11
12
  export type * from './vesca';
12
13
  export type * from './loyaltyProgram';
14
+ export type * from './sCoin';
13
15
 
14
- export type ScallopTxBlock = CoreTxBlock &
15
- SpoolTxBlock &
16
- ReferralTxBlock &
16
+ export type BaseScallopTxBlock = ReferralTxBlock &
17
17
  LoyaltyProgramTxBlock &
18
18
  BorrowIncentiveTxBlock &
19
19
  VeScaTxBlock;
20
+
21
+ export type ScallopTxBlockWithoutSCoinTxBlock = SpoolTxBlock &
22
+ BaseScallopTxBlock;
23
+
24
+ export type ScallopTxBlockWithoutCoreTxBlock = SCoinTxBlock &
25
+ ScallopTxBlockWithoutSCoinTxBlock;
26
+
27
+ export type ScallopTxBlock = CoreTxBlock & ScallopTxBlockWithoutCoreTxBlock;
@@ -0,0 +1,61 @@
1
+ import {
2
+ SuiObjectArg,
3
+ SuiTxBlock as SuiKitTxBlock,
4
+ TransactionResult,
5
+ } from '@scallop-io/sui-kit';
6
+ import { SupportSCoin } from '../constant';
7
+ import { ScallopBuilder } from 'src/models';
8
+ import { ScallopTxBlockWithoutSCoinTxBlock } from '.';
9
+
10
+ export type sCoinPkgIds = {
11
+ pkgId: string;
12
+ };
13
+
14
+ export type sCoinNormalMethods = {
15
+ /**
16
+ * Lock marketCoin and return sCoin
17
+ * @param marketCoinName
18
+ * @param marketCoin
19
+ * @returns
20
+ */
21
+ mintSCoin: (
22
+ marketCoinName: SupportSCoin,
23
+ marketCoin: SuiObjectArg
24
+ ) => TransactionResult;
25
+ /**
26
+ * Burn sCoin and return marketCoin
27
+ * @param sCoinName
28
+ * @param sCoin
29
+ * @returns
30
+ */
31
+ burnSCoin: (
32
+ sCoinName: SupportSCoin,
33
+ sCoin: SuiObjectArg
34
+ ) => TransactionResult; // returns marketCoin
35
+ };
36
+
37
+ export type sCoinQuickMethods = {
38
+ mintSCoinQuick: (
39
+ marketCoinName: SupportSCoin,
40
+ amount: number
41
+ ) => Promise<TransactionResult>;
42
+ burnSCoinQuick: (
43
+ sCoinName: SupportSCoin,
44
+ amount: number
45
+ ) => Promise<TransactionResult>;
46
+ };
47
+
48
+ export type SuiTxBlockWithSCoinNormalMethods = SuiKitTxBlock &
49
+ ScallopTxBlockWithoutSCoinTxBlock &
50
+ sCoinNormalMethods;
51
+ export type SCoinTxBlock = SuiTxBlockWithSCoinNormalMethods & sCoinQuickMethods;
52
+
53
+ export type GenerateSCoinNormalMethod = (params: {
54
+ builder: ScallopBuilder;
55
+ txBlock: SuiKitTxBlock;
56
+ }) => sCoinNormalMethods;
57
+
58
+ export type GenerateSCoinQuickMethod = (params: {
59
+ builder: ScallopBuilder;
60
+ txBlock: SuiTxBlockWithSCoinNormalMethods;
61
+ }) => sCoinQuickMethods;
@@ -7,6 +7,7 @@ import type {
7
7
  import type { TransactionResult } from '@mysten/sui.js/transactions';
8
8
  import type { ScallopBuilder } from '../../models';
9
9
  import type { SupportStakeMarketCoins } from '../constant';
10
+ import { BaseScallopTxBlock } from '.';
10
11
 
11
12
  export type SpoolIds = {
12
13
  spoolPkg: string;
@@ -50,6 +51,7 @@ export type SpoolQuickMethods = {
50
51
  };
51
52
 
52
53
  export type SuiTxBlockWithSpoolNormalMethods = SuiKitTxBlock &
54
+ BaseScallopTxBlock &
53
55
  SpoolNormalMethods;
54
56
 
55
57
  export type SpoolTxBlock = SuiTxBlockWithSpoolNormalMethods & SpoolQuickMethods;
@@ -7,6 +7,7 @@ import {
7
7
  SUPPORT_SPOOLS_REWARDS,
8
8
  SUPPORT_BORROW_INCENTIVE_POOLS,
9
9
  SUPPORT_BORROW_INCENTIVE_REWARDS,
10
+ SUPPORT_SCOIN,
10
11
  } from '../../constants';
11
12
 
12
13
  type ParseMarketCoins<T extends string> = `s${T}`;
@@ -15,7 +16,8 @@ type ParseCoins<T extends string> = T extends `s${infer R}` ? R : never;
15
16
  export type SupportCoins =
16
17
  | SupportAssetCoins
17
18
  | SupportMarketCoins
18
- | SupportStakeMarketCoins;
19
+ | SupportStakeMarketCoins
20
+ | SupportSCoin;
19
21
  export type SupportAssetCoins =
20
22
  | SupportPoolCoins
21
23
  | SupportCollateralCoins
@@ -36,6 +38,7 @@ export type SupportBorrowIncentiveCoins =
36
38
  (typeof SUPPORT_BORROW_INCENTIVE_POOLS)[number];
37
39
  export type SupportBorrowIncentiveRewardCoins =
38
40
  (typeof SUPPORT_BORROW_INCENTIVE_REWARDS)[number];
41
+ export type SupportSCoin = (typeof SUPPORT_SCOIN)[number];
39
42
 
40
43
  export type SupportOracleType = (typeof SUPPORT_ORACLES)[number];
41
44
 
@@ -6,6 +6,7 @@ import {
6
6
  SupportStakeRewardCoins,
7
7
  SupportBorrowIncentiveCoins,
8
8
  SupportBorrowIncentiveRewardCoins,
9
+ SupportSCoin,
9
10
  } from './common';
10
11
 
11
12
  export type Coins = {
@@ -20,6 +21,10 @@ export type MarketCoins = {
20
21
  [K in SupportMarketCoins]: K;
21
22
  };
22
23
 
24
+ export type SCoins = {
25
+ [K in SupportSCoin]: K;
26
+ };
27
+
23
28
  export type StakeMarketCoins = {
24
29
  [K in SupportStakeMarketCoins]: K;
25
30
  };
@@ -36,6 +41,18 @@ export type AssetCoinIds = {
36
41
  [key in SupportAssetCoins]: string;
37
42
  };
38
43
 
44
+ export type SCoinIds = {
45
+ [key in SupportSCoin]: string;
46
+ };
47
+
48
+ export type SCoinTreasuryCaps = {
49
+ [key in SupportSCoin]: string;
50
+ };
51
+
52
+ export type SCoinConverterTreasury = {
53
+ [key in SupportSCoin]: string;
54
+ };
55
+
39
56
  type PickFromUnion<T, K extends string> = K extends T ? K : never;
40
57
 
41
58
  export type WormholeCoinIds = {
@@ -3,6 +3,7 @@ import type {
3
3
  SupportCollateralCoins,
4
4
  SupportMarketCoins,
5
5
  CoinWrappedType,
6
+ SupportSCoin,
6
7
  } from '../constant';
7
8
 
8
9
  type OptionalKeys<T> = {
@@ -18,6 +19,8 @@ export type MarketCoinAmounts = OptionalKeys<
18
19
  Record<SupportMarketCoins, number>
19
20
  >;
20
21
 
22
+ export type SCoinAmounts = OptionalKeys<Record<SupportSCoin, number>>;
23
+
21
24
  export type BalanceSheet = {
22
25
  cash: string;
23
26
  debt: string;
@@ -4,3 +4,4 @@ export type * from './borrowIncentive';
4
4
  export type * from './portfolio';
5
5
  export type * from './vesca';
6
6
  export type * from './loyaltyProgram';
7
+ export type * from './sCoin';
@@ -69,6 +69,7 @@ export type ObligationAccount = {
69
69
  totalRiskLevel: number;
70
70
  totalDepositedPools: number;
71
71
  totalBorrowedPools: number;
72
+ totalRewardedPools: number;
72
73
  collaterals: OptionalKeys<
73
74
  Record<SupportCollateralCoins, ObligationCollateral>
74
75
  >;
@@ -0,0 +1 @@
1
+ export type sCoinBalance = number;
@@ -52,7 +52,7 @@ export const checkExtendLockPeriod = (
52
52
  (newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) /
53
53
  UNLOCK_ROUND_DURATION
54
54
  );
55
- console.log('availableLockPeriodInDays', availableLockPeriodInDays);
55
+
56
56
  if (lockPeriodInDays > availableLockPeriodInDays) {
57
57
  throw new Error(
58
58
  `Cannot extend lock period by ${lockPeriodInDays} days, maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days), remaining lock period is ${
package/src/utils/util.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  SUPPORT_SPOOLS_REWARDS,
6
6
  MAX_LOCK_DURATION,
7
7
  SUPPORT_BORROW_INCENTIVE_REWARDS,
8
+ SUPPORT_SCOIN,
8
9
  } from '../constants';
9
10
  import type { ScallopAddress } from '../models';
10
11
  import type {
@@ -13,20 +14,22 @@ import type {
13
14
  SupportMarketCoins,
14
15
  } from '../types';
15
16
 
17
+ const COIN_SET = Array.from(
18
+ new Set([
19
+ ...SUPPORT_POOLS,
20
+ ...SUPPORT_COLLATERALS,
21
+ ...SUPPORT_SPOOLS_REWARDS,
22
+ ...SUPPORT_BORROW_INCENTIVE_REWARDS,
23
+ ...SUPPORT_SCOIN,
24
+ ])
25
+ );
26
+
16
27
  export const isMarketCoin = (
17
28
  coinName: SupportCoins
18
29
  ): coinName is SupportMarketCoins => {
19
30
  const assetCoinName = coinName.slice(1).toLowerCase() as SupportAssetCoins;
20
31
  return (
21
- coinName.charAt(0).toLowerCase() === 's' &&
22
- [
23
- ...new Set([
24
- ...SUPPORT_POOLS,
25
- ...SUPPORT_COLLATERALS,
26
- ...SUPPORT_SPOOLS_REWARDS,
27
- ...SUPPORT_BORROW_INCENTIVE_REWARDS,
28
- ]),
29
- ].includes(assetCoinName)
32
+ coinName.charAt(0).toLowerCase() === 's' && COIN_SET.includes(assetCoinName)
30
33
  );
31
34
  };
32
35
 
@@ -54,14 +57,7 @@ export const parseDataFromPythPriceFeed = (
54
57
  feed: PriceFeed,
55
58
  address: ScallopAddress
56
59
  ) => {
57
- const assetCoinNames = [
58
- ...new Set([
59
- ...SUPPORT_POOLS,
60
- ...SUPPORT_COLLATERALS,
61
- ...SUPPORT_SPOOLS_REWARDS,
62
- ...SUPPORT_BORROW_INCENTIVE_REWARDS,
63
- ]),
64
- ] as SupportAssetCoins[];
60
+ const assetCoinNames = COIN_SET as SupportAssetCoins[];
65
61
  const assetCoinName = assetCoinNames.find((assetCoinName) => {
66
62
  return (
67
63
  address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`) === feed.id