@scallop-io/sui-scallop-sdk 1.3.4-alpha.1 → 1.3.4-alpha.3

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 (103) hide show
  1. package/dist/index.js +550 -544
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +549 -544
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +2 -2
  6. package/src/builders/loyaltyProgramBuilder.ts +1 -1
  7. package/src/constants/common.ts +0 -1
  8. package/src/constants/enum.ts +12 -11
  9. package/src/constants/index.ts +0 -1
  10. package/src/constants/queryKeys.ts +1 -5
  11. package/src/constants/rpc.ts +16 -0
  12. package/src/constants/testAddress.ts +35 -76
  13. package/src/constants/tokenBucket.ts +1 -1
  14. package/src/models/scallop.ts +3 -2
  15. package/src/models/scallopAddress.ts +2 -2
  16. package/src/models/scallopBuilder.ts +7 -5
  17. package/src/models/scallopCache.ts +1 -1
  18. package/src/models/scallopClient.ts +27 -26
  19. package/src/models/scallopQuery.ts +61 -19
  20. package/src/models/scallopUtils.ts +74 -109
  21. package/src/models/suiKit.ts +11 -0
  22. package/src/queries/borrowIncentiveQuery.ts +6 -13
  23. package/src/queries/coreQuery.ts +245 -236
  24. package/src/queries/isolatedAsset.ts +4 -4
  25. package/src/queries/loyaltyProgramQuery.ts +1 -1
  26. package/src/queries/portfolioQuery.ts +58 -34
  27. package/src/queries/referralQuery.ts +1 -0
  28. package/src/queries/spoolQuery.ts +17 -17
  29. package/src/types/query/core.ts +0 -1
  30. package/src/types/query/index.ts +4 -4
  31. package/src/utils/tokenBucket.ts +2 -1
  32. package/dist/builders/borrowIncentiveBuilder.d.ts +0 -12
  33. package/dist/builders/coreBuilder.d.ts +0 -12
  34. package/dist/builders/index.d.ts +0 -12
  35. package/dist/builders/loyaltyProgramBuilder.d.ts +0 -12
  36. package/dist/builders/oracle.d.ts +0 -14
  37. package/dist/builders/referralBuilder.d.ts +0 -12
  38. package/dist/builders/sCoinBuilder.d.ts +0 -4
  39. package/dist/builders/spoolBuilder.d.ts +0 -12
  40. package/dist/builders/vescaBuilder.d.ts +0 -25
  41. package/dist/constants/cache.d.ts +0 -14
  42. package/dist/constants/coinGecko.d.ts +0 -2
  43. package/dist/constants/common.d.ts +0 -20
  44. package/dist/constants/enum.d.ts +0 -13
  45. package/dist/constants/flashloan.d.ts +0 -2
  46. package/dist/constants/index.d.ts +0 -12
  47. package/dist/constants/poolAddress.d.ts +0 -5
  48. package/dist/constants/pyth.d.ts +0 -5
  49. package/dist/constants/queryKeys.d.ts +0 -59
  50. package/dist/constants/testAddress.d.ts +0 -2
  51. package/dist/constants/tokenBucket.d.ts +0 -2
  52. package/dist/constants/vesca.d.ts +0 -5
  53. package/dist/index.d.ts +0 -3
  54. package/dist/models/index.d.ts +0 -8
  55. package/dist/models/scallop.d.ts +0 -74
  56. package/dist/models/scallopAddress.d.ts +0 -150
  57. package/dist/models/scallopBuilder.d.ts +0 -89
  58. package/dist/models/scallopCache.d.ts +0 -74
  59. package/dist/models/scallopClient.d.ts +0 -321
  60. package/dist/models/scallopIndexer.d.ts +0 -89
  61. package/dist/models/scallopQuery.d.ts +0 -474
  62. package/dist/models/scallopUtils.d.ts +0 -222
  63. package/dist/queries/borrowIncentiveQuery.d.ts +0 -61
  64. package/dist/queries/coreQuery.d.ts +0 -167
  65. package/dist/queries/index.d.ts +0 -8
  66. package/dist/queries/isolatedAsset.d.ts +0 -14
  67. package/dist/queries/loyaltyProgramQuery.d.ts +0 -10
  68. package/dist/queries/portfolioQuery.d.ts +0 -73
  69. package/dist/queries/priceQuery.d.ts +0 -16
  70. package/dist/queries/referralQuery.d.ts +0 -7
  71. package/dist/queries/sCoinQuery.d.ts +0 -41
  72. package/dist/queries/spoolQuery.d.ts +0 -70
  73. package/dist/queries/supplyLimit.d.ts +0 -9
  74. package/dist/queries/vescaQuery.d.ts +0 -36
  75. package/dist/types/address.d.ts +0 -107
  76. package/dist/types/builder/borrowIncentive.d.ts +0 -35
  77. package/dist/types/builder/core.d.ts +0 -56
  78. package/dist/types/builder/index.d.ts +0 -24
  79. package/dist/types/builder/loyaltyProgram.d.ts +0 -23
  80. package/dist/types/builder/referral.d.ts +0 -30
  81. package/dist/types/builder/sCoin.d.ts +0 -37
  82. package/dist/types/builder/spool.d.ts +0 -29
  83. package/dist/types/builder/vesca.d.ts +0 -51
  84. package/dist/types/constant/common.d.ts +0 -24
  85. package/dist/types/constant/enum.d.ts +0 -48
  86. package/dist/types/constant/index.d.ts +0 -2
  87. package/dist/types/index.d.ts +0 -6
  88. package/dist/types/model.d.ts +0 -54
  89. package/dist/types/query/borrowIncentive.d.ts +0 -124
  90. package/dist/types/query/core.d.ts +0 -362
  91. package/dist/types/query/index.d.ts +0 -7
  92. package/dist/types/query/loyaltyProgram.d.ts +0 -5
  93. package/dist/types/query/portfolio.d.ts +0 -115
  94. package/dist/types/query/sCoin.d.ts +0 -1
  95. package/dist/types/query/spool.d.ts +0 -122
  96. package/dist/types/query/vesca.d.ts +0 -26
  97. package/dist/types/utils.d.ts +0 -21
  98. package/dist/utils/builder.d.ts +0 -15
  99. package/dist/utils/index.d.ts +0 -5
  100. package/dist/utils/indexer.d.ts +0 -17
  101. package/dist/utils/query.d.ts +0 -62
  102. package/dist/utils/tokenBucket.d.ts +0 -11
  103. package/dist/utils/util.d.ts +0 -26
@@ -18,6 +18,9 @@ const isolatedAssetZod = zod.object({
18
18
  }),
19
19
  });
20
20
 
21
+ const ISOLATED_ASSET_KEY =
22
+ '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::IsolatedAssetKey';
23
+
21
24
  /**
22
25
  * Return list of isolated assets coin types
23
26
  * @param utils ScallopUtils
@@ -28,8 +31,6 @@ export const getIsolatedAssets = async (
28
31
  ): Promise<string[]> => {
29
32
  try {
30
33
  const marketObject = address.get('core.market');
31
- const protocolObject = address.get('core.packages.protocol.id');
32
- const ISOLATED_ASSET_KEY = `${protocolObject}::market_dynamic_keys::IsolatedAssetKey`;
33
34
  const isolatedAssets: string[] = [];
34
35
  if (!marketObject) return isolatedAssets;
35
36
 
@@ -82,8 +83,7 @@ export const isIsolatedAsset = async (
82
83
  ): Promise<boolean> => {
83
84
  try {
84
85
  const marketObject = utils.address.get('core.market');
85
- const protocolObject = utils.address.get('core.packages.protocol.id');
86
- const ISOLATED_ASSET_KEY = `${protocolObject}::market_dynamic_keys::IsolatedAssetKey`;
86
+
87
87
  // check if the coin type is in the list
88
88
  const cachedData = utils.address.cache.queryClient.getQueryData<string[]>([
89
89
  'getDynamicFields',
@@ -53,7 +53,7 @@ export const getLoyaltyProgramInformations = async (
53
53
  };
54
54
 
55
55
  // query the user pending reward if exist
56
- veScaKey = veScaKey || (await query.getVeScas())[0]?.keyObject;
56
+ veScaKey = veScaKey ?? (await query.getVeScas())[0]?.keyObject;
57
57
  if (!veScaKey) return result;
58
58
 
59
59
  const userRewardTableId = query.address.get(
@@ -1,6 +1,7 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import {
3
3
  SUPPORT_BORROW_INCENTIVE_REWARDS,
4
+ SUPPORT_COLLATERALS,
4
5
  SUPPORT_POOLS,
5
6
  SUPPORT_SPOOLS,
6
7
  } from '../constants';
@@ -49,20 +50,18 @@ export const getLendings = async (
49
50
  (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName)
50
51
  ) as SupportStakeMarketCoins[];
51
52
 
52
- const [
53
+ const coinPrices = await query.utils.getCoinPrices(poolCoinNames);
54
+ const marketPools = await query.getMarketPools(poolCoinNames, indexer, {
55
+ coinPrices,
56
+ });
57
+ const spools = await query.getSpools(stakeMarketCoinNames, indexer, {
53
58
  marketPools,
54
- spools,
55
- coinAmounts,
56
- marketCoinAmounts,
57
- allStakeAccounts,
58
59
  coinPrices,
59
- ] = await Promise.all([
60
- query.getMarketPools(poolCoinNames, indexer),
61
- query.getSpools(stakeMarketCoinNames, indexer),
60
+ });
61
+ const [coinAmounts, marketCoinAmounts, allStakeAccounts] = await Promise.all([
62
62
  query.getCoinAmounts(poolCoinNames, ownerAddress),
63
63
  query.getMarketCoinAmounts(marketCoinNames, ownerAddress),
64
64
  query.getAllStakeAccounts(ownerAddress),
65
- query.utils.getCoinPrices(poolCoinNames),
66
65
  ]);
67
66
 
68
67
  const lendings: Lendings = {};
@@ -80,7 +79,7 @@ export const getLendings = async (
80
79
  indexer,
81
80
  marketPools?.[poolCoinName],
82
81
  stakeMarketCoinName ? spools[stakeMarketCoinName] : undefined,
83
- stakeMarketCoinName ? allStakeAccounts[stakeMarketCoinName] : undefined,
82
+ stakeMarketCoinName ? allStakeAccounts[stakeMarketCoinName] : [],
84
83
  coinAmounts?.[poolCoinName],
85
84
  marketCoinAmounts?.[marketCoinName],
86
85
  coinPrices?.[poolCoinName] ?? 0
@@ -122,12 +121,37 @@ export const getLending = async (
122
121
  sCoinAmount?: number
123
122
  ) => {
124
123
  const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
125
- marketPool = marketPool || (await query.getMarketPool(poolCoinName, indexer));
124
+ coinPrice =
125
+ coinPrice ??
126
+ (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ??
127
+ 0;
128
+
129
+ marketPool =
130
+ marketPool ??
131
+ (await query.getMarketPool(poolCoinName, indexer, {
132
+ coinPrice,
133
+ }));
134
+
135
+ if (!marketPool)
136
+ throw new Error(`Failed to fetch marketPool for ${poolCoinName}`);
137
+
126
138
  spool =
127
- spool ||
128
- (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName)
129
- ? await query.getSpool(marketCoinName as SupportStakeMarketCoins, indexer)
139
+ (spool ??
140
+ (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName))
141
+ ? await query.getSpool(
142
+ marketCoinName as SupportStakeMarketCoins,
143
+ indexer,
144
+ {
145
+ marketPool,
146
+ coinPrices: {
147
+ [poolCoinName]: coinPrice,
148
+ },
149
+ }
150
+ )
130
151
  : undefined;
152
+ // some pool does not have spool
153
+ // if (!spool) throw new Error(`Failed to fetch spool for ${poolCoinName}`);
154
+
131
155
  stakeAccounts =
132
156
  stakeAccounts ||
133
157
  (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName)
@@ -143,9 +167,6 @@ export const getLending = async (
143
167
  (await query.getMarketCoinAmount(marketCoinName, ownerAddress));
144
168
  sCoinAmount =
145
169
  sCoinAmount || (await query.getSCoinAmount(marketCoinName, ownerAddress));
146
- coinPrice =
147
- coinPrice ||
148
- (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
149
170
  const coinDecimal = query.utils.getCoinDecimal(poolCoinName);
150
171
 
151
172
  // Handle staked scoin
@@ -289,10 +310,12 @@ export const getObligationAccounts = async (
289
310
  ownerAddress?: string,
290
311
  indexer: boolean = false
291
312
  ) => {
292
- const market = await query.queryMarket(indexer);
293
313
  const coinPrices = await query.utils.getCoinPrices();
294
- const coinAmounts = await query.getCoinAmounts(undefined, ownerAddress);
295
- const obligations = await query.getObligations(ownerAddress);
314
+ const market = await query.queryMarket(indexer, { coinPrices });
315
+ const [coinAmounts, obligations] = await Promise.all([
316
+ query.getCoinAmounts(undefined, ownerAddress),
317
+ query.getObligations(ownerAddress),
318
+ ]);
296
319
 
297
320
  const obligationAccounts: ObligationAccounts = {};
298
321
  await Promise.allSettled(
@@ -329,24 +352,25 @@ export const getObligationAccount = async (
329
352
  coinPrices?: CoinPrices,
330
353
  coinAmounts?: CoinAmounts
331
354
  ) => {
332
- market = market || (await query.queryMarket(indexer));
333
- const poolAssetCoinNames: SupportCollateralCoins[] = [
334
- ...new Set([...Object.values(market.pools).map((pool) => pool.coinName)]),
355
+ const collateralAssetCoinNames: SupportCollateralCoins[] = [
356
+ ...SUPPORT_COLLATERALS,
335
357
  ];
336
- const obligationQuery = await query.queryObligation(obligationId);
337
- const borrowIncentivePools = await query.getBorrowIncentivePools(
338
- undefined,
339
- indexer
340
- );
341
- const borrowIncentiveAccounts =
342
- await query.getBorrowIncentiveAccounts(obligationId);
343
358
  coinPrices =
344
- coinPrices || (await query.utils.getCoinPrices(poolAssetCoinNames));
359
+ coinPrices ?? (await query.utils.getCoinPrices(collateralAssetCoinNames));
360
+ market = market ?? (await query.queryMarket(indexer, { coinPrices }));
345
361
  coinAmounts =
346
362
  coinAmounts ||
347
- (await query.getCoinAmounts(poolAssetCoinNames, ownerAddress));
363
+ (await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress));
364
+
365
+ const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] =
366
+ await Promise.all([
367
+ query.queryObligation(obligationId),
368
+ query.getBorrowIncentivePools(undefined, indexer, {
369
+ coinPrices,
370
+ }),
371
+ query.getBorrowIncentiveAccounts(obligationId),
372
+ ]);
348
373
 
349
- console.log(coinPrices);
350
374
  const collaterals: ObligationAccount['collaterals'] = {};
351
375
  const debts: ObligationAccount['debts'] = {};
352
376
  const borrowIncentives: ObligationAccount['borrowIncentives'] = {};
@@ -359,7 +383,7 @@ export const getObligationAccount = async (
359
383
  let totalBorrowedValue = BigNumber(0);
360
384
  let totalBorrowedValueWithWeight = BigNumber(0);
361
385
 
362
- for (const assetCoinName of poolAssetCoinNames) {
386
+ for (const assetCoinName of collateralAssetCoinNames) {
363
387
  const collateral = obligationQuery?.collaterals.find((collateral) => {
364
388
  const collateralCoinName =
365
389
  query.utils.parseCoinNameFromType<SupportCollateralCoins>(
@@ -10,6 +10,7 @@ export const queryVeScaKeyIdFromReferralBindings = async (
10
10
  refereeAddress: string
11
11
  ): Promise<string | null> => {
12
12
  const referralBindingTableId = address.get('referral.bindingTableId');
13
+
13
14
  const referralBindResponse = await address.cache.queryGetDynamicFieldObject({
14
15
  parentId: referralBindingTableId,
15
16
  name: {
@@ -19,6 +19,7 @@ import type {
19
19
  SupportStakeMarketCoins,
20
20
  SupportStakeCoins,
21
21
  CoinPrices,
22
+ MarketPools,
22
23
  } from '../types';
23
24
 
24
25
  /**
@@ -32,22 +33,20 @@ import type {
32
33
  export const getSpools = async (
33
34
  query: ScallopQuery,
34
35
  stakeMarketCoinNames: SupportStakeMarketCoins[] = [...SUPPORT_SPOOLS],
35
- indexer: boolean = false
36
+ indexer: boolean = false,
37
+ marketPools?: MarketPools,
38
+ coinPrices?: CoinPrices
36
39
  ) => {
37
40
  const stakeCoinNames = stakeMarketCoinNames.map((stakeMarketCoinName) =>
38
41
  query.utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName)
39
42
  );
40
- const rewardCoinNames = stakeMarketCoinNames.map((stakeMarketCoinName) => {
41
- const rewardCoinName =
42
- query.utils.getSpoolRewardCoinName(stakeMarketCoinName);
43
- return rewardCoinName;
44
- });
45
- const coinPrices =
46
- (await query.utils.getCoinPrices([
47
- ...new Set([...stakeCoinNames, ...rewardCoinNames]),
48
- ])) ?? {};
43
+ coinPrices = coinPrices ?? (await query.utils.getCoinPrices()) ?? {};
44
+
45
+ marketPools =
46
+ marketPools ?? (await query.getMarketPools(stakeCoinNames, indexer));
47
+ if (!marketPools)
48
+ throw new Error(`Fail to fetch marketPools for ${stakeCoinNames}`);
49
49
 
50
- const marketPools = await query.getMarketPools(stakeCoinNames, indexer);
51
50
  const spools: Spools = {};
52
51
 
53
52
  if (indexer) {
@@ -61,12 +60,13 @@ export const getSpools = async (
61
60
  spool.marketCoinName
62
61
  );
63
62
  const marketPool = marketPools[coinName];
64
- spool.coinPrice = coinPrices[coinName] || spool.coinPrice;
65
- spool.marketCoinPrice =
66
- (coinPrices[coinName] ?? 0) *
67
- (marketPool ? marketPool.conversionRate : 0) || spool.marketCoinPrice;
63
+ spool.coinPrice = coinPrices[coinName] ?? spool.coinPrice;
64
+ spool.marketCoinPrice = coinPrices[coinName]
65
+ ? (coinPrices[coinName] ?? 0) *
66
+ (marketPool ? marketPool.conversionRate : 0)
67
+ : spool.marketCoinPrice;
68
68
  spool.rewardCoinPrice =
69
- coinPrices[rewardCoinName] || spool.rewardCoinPrice;
69
+ coinPrices[rewardCoinName] ?? spool.rewardCoinPrice;
70
70
  spools[spool.marketCoinName] = spool;
71
71
  };
72
72
  Object.values(spoolsIndexer).forEach(updateSpools);
@@ -114,7 +114,7 @@ export const getSpool = async (
114
114
  const coinName = query.utils.parseCoinName<SupportStakeCoins>(marketCoinName);
115
115
  marketPool = marketPool || (await query.getMarketPool(coinName, indexer));
116
116
  if (!marketPool) {
117
- throw new Error(`Failed to fetch marketPool for ${marketCoinName}`);
117
+ throw new Error(`Fail to fetch marketPool for ${coinName}`);
118
118
  }
119
119
 
120
120
  const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
@@ -153,7 +153,6 @@ export type MarketCollateral = {
153
153
  coinWrappedType: CoinWrappedType;
154
154
  coinDecimal: number;
155
155
  coinPrice: number;
156
- isIsolated: boolean;
157
156
  } & Required<
158
157
  Pick<
159
158
  ParsedMarketCollateralData,
@@ -1,7 +1,7 @@
1
- export type * from './core';
2
- export type * from './spool';
3
1
  export type * from './borrowIncentive';
4
- export type * from './portfolio';
5
- export type * from './vesca';
2
+ export type * from './core';
6
3
  export type * from './loyaltyProgram';
4
+ export type * from './portfolio';
7
5
  export type * from './sCoin';
6
+ export type * from './spool';
7
+ export type * from './vesca';
@@ -38,7 +38,7 @@ const callWithRateLimit = async <T>(
38
38
  tokenBucket: TokenBucket,
39
39
  fn: () => Promise<T>,
40
40
  retryDelayInMs = DEFAULT_INTERVAL_IN_MS,
41
- maxRetries = 15,
41
+ maxRetries = 30,
42
42
  backoffFactor = 1.25 // The factor by which to increase the delay
43
43
  ): Promise<T | null> => {
44
44
  let retries = 0;
@@ -65,6 +65,7 @@ const callWithRateLimit = async <T>(
65
65
  await new Promise((resolve) => setTimeout(resolve, delay));
66
66
  return tryRequest();
67
67
  } else {
68
+ // console.error(error);
68
69
  console.error('An error occurred:', error.message);
69
70
  return null;
70
71
  }
@@ -1,12 +0,0 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
- import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
- import type { ScallopBuilder } from 'src/models';
4
- import type { BorrowIncentiveTxBlock, ScallopTxBlock } from '../types';
5
- /**
6
- * Create an enhanced transaction block instance for interaction with borrow incentive modules of the Scallop contract.
7
- *
8
- * @param builder - Scallop builder instance.
9
- * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
- * @return Scallop borrow incentive txBlock.
11
- */
12
- export declare const newBorrowIncentiveTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => BorrowIncentiveTxBlock;
@@ -1,12 +0,0 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
- import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
- import type { ScallopBuilder } from '../models';
4
- import type { CoreTxBlock, ScallopTxBlock, SuiTxBlockWithSpool } from '../types';
5
- /**
6
- * Create an enhanced transaction block instance for interaction with core modules of the Scallop contract.
7
- *
8
- * @param builder - Scallop builder instance.
9
- * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
- * @return Scallop core txBlock.
11
- */
12
- export declare const newCoreTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction | SuiTxBlockWithSpool) => CoreTxBlock;
@@ -1,12 +0,0 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
- import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
- import type { ScallopBuilder } from '../models';
4
- import type { ScallopTxBlock } from '../types';
5
- /**
6
- * Create a new ScallopTxBlock instance.
7
- *
8
- * @param builder - Scallop builder instance.
9
- * @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
- * @return ScallopTxBlock.
11
- */
12
- export declare const newScallopTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => ScallopTxBlock;
@@ -1,12 +0,0 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
- import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
- import { ScallopBuilder } from 'src/models';
4
- import { LoyaltyProgramTxBlock, ScallopTxBlock } from 'src/types';
5
- /**
6
- * Create an enhanced transaction block instance for interaction with loyalty program modules of the Scallop contract.
7
- *
8
- * @param builder - Scallop builder instance.
9
- * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
- * @return Scallop loyalty program txBlock.
11
- */
12
- export declare const newLoyaltyProgramTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => LoyaltyProgramTxBlock;
@@ -1,14 +0,0 @@
1
- import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
2
- import type { ScallopBuilder } from '../models';
3
- import type { SupportAssetCoins } from '../types';
4
- /**
5
- * Update the price of the oracle for multiple coin.
6
- *
7
- * @param builder - The scallop builder.
8
- * @param txBlock - TxBlock created by SuiKit.
9
- * @param assetCoinNames - Specific an array of support asset coin name.
10
- * @param options - The options for update oracles.
11
- */
12
- export declare const updateOracles: (builder: ScallopBuilder, txBlock: SuiKitTxBlock, assetCoinNames?: SupportAssetCoins[], options?: {
13
- usePythPullModel: boolean;
14
- }) => Promise<void>;
@@ -1,12 +0,0 @@
1
- import { ScallopBuilder } from 'src/models';
2
- import { ScallopTxBlock } from 'src/types';
3
- import { SuiTxBlock as SuiKitTxBlock, Transaction } from '@scallop-io/sui-kit';
4
- import { ReferralTxBlock } from 'src/types/builder/referral';
5
- /**
6
- * Create an enhanced transaction block instance for interaction with borrow incentive modules of the Scallop contract.
7
- *
8
- * @param builder - Scallop builder instance.
9
- * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
- * @return Scallop referral txBlock.
11
- */
12
- export declare const newReferralTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => ReferralTxBlock;
@@ -1,4 +0,0 @@
1
- import { Transaction, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
2
- import { ScallopBuilder } from 'src/models';
3
- import { BaseScallopTxBlock, SCoinTxBlock, ScallopTxBlock } from 'src/types';
4
- export declare const newSCoinTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction | BaseScallopTxBlock) => SCoinTxBlock;
@@ -1,12 +0,0 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
- import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
- import type { ScallopBuilder } from '../models';
4
- import type { SpoolTxBlock, ScallopTxBlock, SuiTxBlockWithSCoin } from '../types';
5
- /**
6
- * Create an enhanced transaction block instance for interaction with spool modules of the Scallop contract.
7
- *
8
- * @param builder - Scallop builder instance.
9
- * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
- * @return Scallop spool txBlock.
11
- */
12
- export declare const newSpoolTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction | SuiTxBlockWithSCoin) => SpoolTxBlock;
@@ -1,25 +0,0 @@
1
- import { SuiTxBlock, Transaction, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
2
- import { ScallopBuilder } from '../models';
3
- import type { SuiObjectArg } from '@scallop-io/sui-kit';
4
- import type { ScallopTxBlock, VeScaTxBlock } from 'src/types';
5
- /**
6
- * Check and get veSCA data from transaction block.
7
- *
8
- * @description
9
- * If the veScaKey id is provided, directly return it.
10
- * Otherwise, automatically get veScaKey from the sender.
11
- *
12
- * @param builder - Scallop builder instance.
13
- * @param txBlock - TxBlock created by SuiKit.
14
- * @param veScaKey - veSCA key.
15
- * @return veSCA key, ID, locked amount and unlock at timestamp.
16
- */
17
- export declare const requireVeSca: (builder: ScallopBuilder, SuiTxBlock: SuiTxBlock, veScaKey?: SuiObjectArg | undefined) => Promise<import("src/types").Vesca | undefined>;
18
- /**
19
- * Create an enhanced transaction block instance for interaction with veSCA modules of the Scallop contract.
20
- *
21
- * @param builder - Scallop builder instance.
22
- * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
23
- * @return Scallop borrow incentive txBlock.
24
- */
25
- export declare const newVeScaTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => VeScaTxBlock;
@@ -1,14 +0,0 @@
1
- /**
2
- * Default cache options for the QueryClient.
3
- * @type {QueryClientConfig}
4
- * @description Default cache options for the QueryClient
5
- * We set the default to 5s to prevent duplicate requests from being requested (e.g. query MarketObject, etc.)
6
- */
7
- export declare const DEFAULT_CACHE_OPTIONS: {
8
- defaultOptions: {
9
- queries: {
10
- staleTime: number;
11
- gcTime: number;
12
- };
13
- };
14
- };
@@ -1,2 +0,0 @@
1
- import { SupportPoolCoins } from 'src/types/constant/common';
2
- export declare const COIN_GECKGO_IDS: Record<SupportPoolCoins, string>;
@@ -1,20 +0,0 @@
1
- export declare const API_BASE_URL: "https://sui.apis.scallop.io";
2
- export declare const SDK_API_BASE_URL: "https://sdk.api.scallop.io";
3
- export declare const IS_VE_SCA_TEST: boolean;
4
- export declare const USE_TEST_ADDRESS: boolean;
5
- export declare const ADDRESSES_ID: "65fb07c39c845425d71d7b18" | "66f8e7ed9bb9e07fdfb86bbb";
6
- export declare const PROTOCOL_OBJECT_ID: "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" | "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf";
7
- export declare const BORROW_FEE_PROTOCOL_ID: "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" | "0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da";
8
- export declare const SCA_COIN_TYPE: "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524::sca::SCA" | "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA";
9
- export declare const OLD_BORROW_INCENTIVE_PROTOCOL_ID: "0xc63072e7f5f4983a2efaf5bdba1480d5e7d74d57948e1c7cc436f8e22cbeb410";
10
- export declare const SUPPORT_POOLS: readonly ["usdc", "sbeth", "weth", "wbtc", "wusdc", "wusdt", "sui", "wapt", "wsol", "cetus", "afsui", "hasui", "vsui", "sca"];
11
- export declare const SUPPORT_COLLATERALS: readonly ["usdc", "sbeth", "weth", "wbtc", "wusdc", "wusdt", "sui", "wapt", "wsol", "cetus", "afsui", "hasui", "vsui", "sca"];
12
- export declare const SUPPORT_SPOOLS: readonly ["susdc", "sweth", "ssui", "swusdc", "swusdt", "scetus", "safsui", "shasui", "svsui"];
13
- export declare const SUPPORT_SCOIN: readonly ["susdc", "ssbeth", "ssui", "swusdc", "swusdt", "safsui", "shasui", "svsui", "sweth", "ssca", "scetus", "swsol", "swbtc"];
14
- export declare const SUPPORT_SUI_BRIDGE: readonly ["sbeth"];
15
- export declare const SUPPORT_WORMHOLE: readonly ["wusdc", "wusdt", "weth", "wbtc", "wapt", "wsol"];
16
- export declare const SUPPORT_SPOOLS_REWARDS: readonly ["sui"];
17
- export declare const SUPPORT_BORROW_INCENTIVE_POOLS: readonly ["sui", "wusdc", "wusdt", "afsui", "hasui", "vsui", "weth", "sbeth", "sca", "usdc"];
18
- export declare const SUPPORT_BORROW_INCENTIVE_REWARDS: readonly ["sui", "sca"];
19
- export declare const SUPPORT_ORACLES: readonly ["supra", "switchboard", "pyth"];
20
- export declare const SUPPORT_PACKAGES: readonly ["coinDecimalsRegistry", "math", "whitelist", "x", "protocol", "protocolWhitelist", "query", "supra", "pyth", "switchboard", "xOracle", "testCoin"];
@@ -1,13 +0,0 @@
1
- import type * as types from '../types';
2
- export declare const coinDecimals: types.SupportCoinDecimals;
3
- export declare const assetCoins: types.AssetCoins;
4
- export declare const marketCoins: types.MarketCoins;
5
- export declare const sCoins: types.SCoins;
6
- export declare const stakeMarketCoins: types.StakeMarketCoins;
7
- export declare const spoolRewardCoins: types.StakeRewardCoins;
8
- export declare const suiBridgeCoins: types.SuiBridgeCoins;
9
- export declare const borrowIncentiveRewardCoins: types.BorrowIncentiveRewardCoins;
10
- export declare const coinIds: types.AssetCoinIds;
11
- export declare const wormholeCoinIds: types.WormholeCoinIds;
12
- export declare const voloCoinIds: types.VoloCoinIds;
13
- export declare const sCoinIds: types.SCoinIds;
@@ -1,2 +0,0 @@
1
- import { OptionalKeys, SupportPoolCoins } from 'src/types';
2
- export declare const FlashLoanFeeObjectMap: OptionalKeys<Record<SupportPoolCoins, string>>;
@@ -1,12 +0,0 @@
1
- export * from './cache';
2
- export * from './coinGecko';
3
- export * from './common';
4
- export * from './enum';
5
- export * from './flashloan';
6
- export * from './poolAddress';
7
- export * from './pyth';
8
- export * from './queryKeys';
9
- export * from './testAddress';
10
- export * from './tokenBucket';
11
- export * from './vesca';
12
- export * from './testAddress';
@@ -1,5 +0,0 @@
1
- import { SupportPoolCoins } from 'src/types';
2
- export declare const POOL_ADDRESSES: Record<SupportPoolCoins, {
3
- lendingPoolAddress: string;
4
- collateralPoolAddress: string;
5
- }>;
@@ -1,5 +0,0 @@
1
- import { SupportPoolCoins } from 'src/types';
2
- export declare const PYTH_ENDPOINTS: {
3
- [k in 'mainnet' | 'testnet']: string[];
4
- };
5
- export declare const PYTH_FEED_IDS: Record<SupportPoolCoins, string>;
@@ -1,59 +0,0 @@
1
- import type { GetDynamicFieldObjectParams, GetDynamicFieldsParams, GetOwnedObjectsParams, SuiObjectData, SuiObjectDataOptions } from '@mysten/sui/client';
2
- import type { SuiObjectArg } from '@scallop-io/sui-kit';
3
- export declare const queryKeys: {
4
- api: {
5
- getAddresses: (addressesId?: string) => (string | {
6
- addressesId: string | undefined;
7
- })[];
8
- getMarket: () => string[];
9
- getSpools: () => string[];
10
- getBorrowIncentivePool: () => string[];
11
- getTotalValueLocked: () => string[];
12
- };
13
- rpc: {
14
- getInspectTxn: (queryTarget?: string, args?: SuiObjectArg[], typeArgs?: any[]) => (string | {
15
- queryTarget: string | undefined;
16
- args: string;
17
- typeArgs: string | undefined;
18
- })[];
19
- getObject: (objectId?: string, walletAddress?: string, options?: SuiObjectDataOptions) => (string | {
20
- walletAddress: string | undefined;
21
- options: SuiObjectDataOptions | undefined;
22
- objectId: string | undefined;
23
- })[];
24
- getObjects: (objectIds?: string[], walletAddress?: string, options?: SuiObjectDataOptions) => (string | {
25
- walletAddress: string | undefined;
26
- options: SuiObjectDataOptions | undefined;
27
- objectIds: string;
28
- })[];
29
- getOwnedObjects: (input?: Partial<GetOwnedObjectsParams>) => (string | {
30
- walletAddress: string | undefined;
31
- cursor: string | undefined;
32
- options: SuiObjectDataOptions | undefined;
33
- filter: string;
34
- limit: number | undefined;
35
- })[];
36
- getDynamicFields: (input?: Partial<GetDynamicFieldsParams>) => (string | {
37
- parentId: string | undefined;
38
- cursor: string | undefined;
39
- limit: number | undefined;
40
- })[];
41
- getDynamicFieldObject: (input?: Partial<GetDynamicFieldObjectParams>) => (string | {
42
- parentId: string | undefined;
43
- name: string;
44
- })[];
45
- getTotalVeScaTreasuryAmount: (refreshArgs?: any[], vescaAmountArgs?: (string | SuiObjectData)[]) => (string | {
46
- refreshArgs: string;
47
- vescaAmountArgs: string;
48
- })[];
49
- getAllCoinBalances: (owner?: string) => (string | {
50
- owner: string | undefined;
51
- })[];
52
- };
53
- oracle: {
54
- getPythLatestPriceFeed: (pythPriceId?: string, endpoint?: string) => (string | {
55
- pythPriceId: string | undefined;
56
- endpoint: string | undefined;
57
- })[];
58
- };
59
- };
@@ -1,2 +0,0 @@
1
- import { AddressesInterface } from 'src/types';
2
- export declare const TEST_ADDRESSES: AddressesInterface;
@@ -1,2 +0,0 @@
1
- export declare const DEFAULT_TOKENS_PER_INTERVAL = 50;
2
- export declare const DEFAULT_INTERVAL_IN_MS = 300;
@@ -1,5 +0,0 @@
1
- export declare const UNLOCK_ROUND_DURATION: number;
2
- export declare const MAX_LOCK_ROUNDS: 1460;
3
- export declare const MAX_LOCK_DURATION: number;
4
- export declare const MIN_INITIAL_LOCK_AMOUNT: 10000000000;
5
- export declare const MIN_TOP_UP_AMOUNT: 1000000000;
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './constants';
2
- export * from './models';
3
- export type * from './types';
@@ -1,8 +0,0 @@
1
- export * from './scallop';
2
- export * from './scallopAddress';
3
- export * from './scallopClient';
4
- export * from './scallopBuilder';
5
- export * from './scallopQuery';
6
- export * from './scallopUtils';
7
- export * from './scallopIndexer';
8
- export * from './scallopCache';