@scallop-io/sui-scallop-sdk 1.4.15-rc.3 → 1.4.17

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 (71) hide show
  1. package/dist/constants/common.d.ts +6 -6
  2. package/dist/constants/enum.d.ts +2 -2
  3. package/dist/constants/index.d.ts +0 -1
  4. package/dist/constants/poolAddress.d.ts +2 -1
  5. package/dist/constants/queryKeys.d.ts +3 -4
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.js +2019 -1634
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +2087 -1697
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/models/scallop.d.ts +1 -2
  12. package/dist/models/scallopBuilder.d.ts +3 -2
  13. package/dist/models/scallopCache.d.ts +18 -12
  14. package/dist/models/scallopClient.d.ts +1 -1
  15. package/dist/models/scallopIndexer.d.ts +1 -1
  16. package/dist/models/scallopQuery.d.ts +96 -11
  17. package/dist/models/scallopUtils.d.ts +4 -4
  18. package/dist/queries/borrowIncentiveQuery.d.ts +6 -1
  19. package/dist/queries/coreQuery.d.ts +2 -0
  20. package/dist/queries/objectsQuery.d.ts +1 -2
  21. package/dist/queries/poolAddressesQuery.d.ts +4 -2
  22. package/dist/queries/portfolioQuery.d.ts +71 -5
  23. package/dist/queries/priceQuery.d.ts +4 -0
  24. package/dist/queries/sCoinQuery.d.ts +1 -1
  25. package/dist/types/builder/core.d.ts +3 -3
  26. package/dist/types/model.d.ts +8 -2
  27. package/dist/utils/index.d.ts +0 -2
  28. package/package.json +7 -7
  29. package/src/builders/borrowIncentiveBuilder.ts +11 -5
  30. package/src/builders/coreBuilder.ts +61 -32
  31. package/src/builders/loyaltyProgramBuilder.ts +3 -2
  32. package/src/builders/referralBuilder.ts +16 -6
  33. package/src/builders/sCoinBuilder.ts +6 -4
  34. package/src/builders/spoolBuilder.ts +14 -7
  35. package/src/builders/vescaBuilder.ts +13 -7
  36. package/src/constants/coinGecko.ts +2 -0
  37. package/src/constants/common.ts +7 -1
  38. package/src/constants/enum.ts +46 -20
  39. package/src/constants/index.ts +0 -1
  40. package/src/constants/poolAddress.ts +163 -41
  41. package/src/constants/pyth.ts +2 -0
  42. package/src/constants/queryKeys.ts +7 -9
  43. package/src/constants/testAddress.ts +24 -0
  44. package/src/index.ts +0 -1
  45. package/src/models/scallop.ts +9 -13
  46. package/src/models/scallopAddress.ts +2 -9
  47. package/src/models/scallopBuilder.ts +63 -9
  48. package/src/models/scallopCache.ts +220 -114
  49. package/src/models/scallopClient.ts +4 -7
  50. package/src/models/scallopIndexer.ts +2 -6
  51. package/src/models/scallopQuery.ts +54 -20
  52. package/src/models/scallopUtils.ts +9 -13
  53. package/src/queries/borrowIncentiveQuery.ts +6 -13
  54. package/src/queries/coreQuery.ts +62 -48
  55. package/src/queries/loyaltyProgramQuery.ts +1 -3
  56. package/src/queries/objectsQuery.ts +3 -5
  57. package/src/queries/poolAddressesQuery.ts +13 -10
  58. package/src/queries/portfolioQuery.ts +256 -21
  59. package/src/queries/priceQuery.ts +2 -7
  60. package/src/queries/sCoinQuery.ts +2 -2
  61. package/src/queries/spoolQuery.ts +21 -20
  62. package/src/queries/vescaQuery.ts +3 -7
  63. package/src/types/builder/core.ts +21 -3
  64. package/src/types/model.ts +13 -2
  65. package/src/utils/index.ts +0 -2
  66. package/src/utils/indexer.ts +3 -1
  67. package/src/utils/query.ts +2 -2
  68. package/dist/constants/tokenBucket.d.ts +0 -2
  69. package/dist/utils/tokenBucket.d.ts +0 -11
  70. package/src/constants/tokenBucket.ts +0 -2
  71. package/src/utils/tokenBucket.ts +0 -68
@@ -37,19 +37,13 @@ export const queryKeys = {
37
37
  getObject: (objectId?: string, options?: SuiObjectDataOptions) => [
38
38
  'rpc',
39
39
  'getObject',
40
- { options, objectId },
40
+ { objectId, options },
41
41
  ],
42
- getObjects: (
43
- objectIds?: string[],
44
- walletAddress?: string,
45
- options?: SuiObjectDataOptions
46
- ) => [
42
+ getObjects: (objectIds?: string[]) => [
47
43
  'rpc',
48
44
  'getObjects',
49
45
  {
50
- walletAddress,
51
- options,
52
- objectIds: JSON.stringify(objectIds ?? []),
46
+ objectIds: JSON.stringify(objectIds ?? undefined),
53
47
  },
54
48
  ],
55
49
  getOwnedObjects: (input?: Partial<GetOwnedObjectsParams>) => [
@@ -97,6 +91,10 @@ export const queryKeys = {
97
91
  'getAllCoinBalances',
98
92
  { owner },
99
93
  ],
94
+
95
+ getNormalizedMoveFunction: (target?: string) => {
96
+ return ['rpc', 'getNormalizedMoveCall', target];
97
+ },
100
98
  },
101
99
  oracle: {
102
100
  getPythLatestPriceFeeds: () => ['oracle', 'getPythPriceIds'],
@@ -236,6 +236,24 @@ export const TEST_ADDRESSES: AddressesInterface = {
236
236
  },
237
237
  },
238
238
  },
239
+ // @TODO: add test address
240
+ // @ts-ignore
241
+ sbusdt: {},
242
+ fdusd: {
243
+ id: '0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a',
244
+ metaData:
245
+ '0xdebee5265a67c186ed87fe93303d33dfe1de53e3b4fd7d9329c2852860acd3e7',
246
+ treasury: '',
247
+ oracle: {
248
+ supra: '',
249
+ switchboard: '',
250
+ pyth: {
251
+ feed: '0xccdc1a08923e2e4f4b1e6ea89de6acbc5fe1948e9706f5604b8cb50bc1ed3979',
252
+ feedObject:
253
+ '0x5f6583b2b0fe1ecf94aaffeaab8a838794693960cea48c0da282d5f4a24be027',
254
+ },
255
+ },
256
+ },
239
257
  deep: {
240
258
  id: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270',
241
259
  metaData:
@@ -543,6 +561,12 @@ export const TEST_ADDRESSES: AddressesInterface = {
543
561
  treasury:
544
562
  '0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed',
545
563
  },
564
+ sfdusd: {
565
+ coinType:
566
+ '0x6711551c1e7652a270d9fbf0eee25d99594c157cde3cb5fbb49035eb59b1b001::scallop_fdusd::SCALLOP_FDUSD',
567
+ treasury:
568
+ '0xdad9bc6293e694f67a5274ea51b596e0bdabfafc585ae6d7e82888e65f1a03e0',
569
+ },
546
570
  sdeep: {
547
571
  coinType:
548
572
  '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './constants';
2
2
  export * from './models';
3
3
  export type * from './types';
4
- export * from './utils/tokenBucket';
@@ -15,12 +15,6 @@ import type {
15
15
  import { ScallopIndexer } from './scallopIndexer';
16
16
  import { ScallopCache } from './scallopCache';
17
17
  import { QueryClientConfig } from '@tanstack/query-core';
18
- import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
19
- import { TokenBucket } from 'src/utils';
20
- import {
21
- DEFAULT_INTERVAL_IN_MS,
22
- DEFAULT_TOKENS_PER_INTERVAL,
23
- } from 'src/constants/tokenBucket';
24
18
  import type { QueryClient } from '@tanstack/query-core';
25
19
  import { newSuiKit } from './suiKit';
26
20
 
@@ -51,18 +45,19 @@ export class Scallop {
51
45
  public constructor(
52
46
  params: ScallopParams,
53
47
  cacheOptions?: QueryClientConfig,
54
- tokenBucket?: TokenBucket,
55
48
  queryClient?: QueryClient
56
49
  ) {
57
50
  this.params = params;
58
51
  this.suiKit = newSuiKit(params);
59
52
  this.cache = new ScallopCache(
60
- this.suiKit,
61
- params.walletAddress,
62
- cacheOptions ?? DEFAULT_CACHE_OPTIONS,
63
- tokenBucket ??
64
- new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS),
65
- queryClient
53
+ {
54
+ ...this.params,
55
+ cacheOptions,
56
+ },
57
+ {
58
+ suiKit: this.suiKit,
59
+ queryClient,
60
+ }
66
61
  );
67
62
  this.address = new ScallopAddress(
68
63
  {
@@ -168,6 +163,7 @@ export class Scallop {
168
163
  },
169
164
  {
170
165
  address: this.address,
166
+ suiKit: this.suiKit,
171
167
  }
172
168
  );
173
169
 
@@ -1,5 +1,5 @@
1
1
  import { API_BASE_URL, USE_TEST_ADDRESS } from '../constants';
2
- import { SuiKit, type NetworkType } from '@scallop-io/sui-kit';
2
+ import { type NetworkType } from '@scallop-io/sui-kit';
3
3
  import type {
4
4
  ScallopAddressParams,
5
5
  AddressesInterface,
@@ -7,7 +7,6 @@ import type {
7
7
  ScallopAddressInstanceParams,
8
8
  } from '../types';
9
9
  import { ScallopCache } from './scallopCache';
10
- import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
11
10
  import axios, { AxiosInstance } from 'axios';
12
11
  import { TEST_ADDRESSES } from 'src/constants/testAddress';
13
12
  import { queryKeys } from 'src/constants';
@@ -379,13 +378,7 @@ export class ScallopAddress {
379
378
  instance?: ScallopAddressInstanceParams
380
379
  ) {
381
380
  const { id, auth, network, forceInterface } = params;
382
- this.cache =
383
- instance?.cache ??
384
- new ScallopCache(
385
- instance?.suiKit ?? new SuiKit({}),
386
- undefined,
387
- DEFAULT_CACHE_OPTIONS
388
- );
381
+ this.cache = instance?.cache ?? new ScallopCache({});
389
382
 
390
383
  this._requestClient = axios.create({
391
384
  baseURL: API_BASE_URL,
@@ -7,7 +7,13 @@ import { ScallopQuery } from './scallopQuery';
7
7
  import { ScallopUtils } from './scallopUtils';
8
8
  import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
9
9
  import type { Transaction } from '@mysten/sui/transactions';
10
- import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
10
+ import type {
11
+ SuiAmountsArg,
12
+ SuiTxBlock as SuiKitTxBlock,
13
+ SuiObjectArg,
14
+ SuiTxArg,
15
+ SuiVecTxArg,
16
+ } from '@scallop-io/sui-kit';
11
17
  import type {
12
18
  ScallopBuilderParams,
13
19
  ScallopTxBlock,
@@ -18,7 +24,6 @@ import type {
18
24
  SelectCoinReturnType,
19
25
  } from '../types';
20
26
  import { ScallopCache } from './scallopCache';
21
- import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
22
27
  import { newSuiKit } from './suiKit';
23
28
 
24
29
  /**
@@ -44,7 +49,7 @@ export class ScallopBuilder {
44
49
  public cache: ScallopCache;
45
50
 
46
51
  public constructor(
47
- params: ScallopBuilderParams,
52
+ params: ScallopBuilderParams = {},
48
53
  instance?: ScallopBuilderInstanceParams
49
54
  ) {
50
55
  this.suiKit = instance?.suiKit ?? newSuiKit(params);
@@ -60,11 +65,9 @@ export class ScallopBuilder {
60
65
  this.address = this.utils.address;
61
66
  this.cache = this.address.cache;
62
67
  } else {
63
- this.cache = new ScallopCache(
64
- this.suiKit,
65
- this.walletAddress,
66
- DEFAULT_CACHE_OPTIONS
67
- );
68
+ this.cache = new ScallopCache(this.params, {
69
+ suiKit: this.suiKit,
70
+ });
68
71
  this.address = new ScallopAddress(
69
72
  {
70
73
  id: params?.addressesId ?? ADDRESSES_ID,
@@ -104,7 +107,7 @@ export class ScallopBuilder {
104
107
  await this.address.read();
105
108
  }
106
109
  await this.query.init(force, this.address);
107
- await this.utils.init(force, this.address);
110
+ // await this.utils.init(force, this.address);
108
111
  }
109
112
 
110
113
  /**
@@ -215,4 +218,55 @@ export class ScallopBuilder {
215
218
  txBlock
216
219
  )) as SuiTransactionBlockResponse;
217
220
  }
221
+
222
+ public moveCall(
223
+ txb: ScallopTxBlock | SuiKitTxBlock,
224
+ target: string,
225
+ args?: (SuiTxArg | SuiVecTxArg | SuiObjectArg | SuiAmountsArg)[],
226
+ typeArgs?: string[]
227
+ ) {
228
+ // Disable for now
229
+ // const resolvedQueryTarget =
230
+ // await this.cache.queryGetNormalizedMoveFunction(target);
231
+ // if (!resolvedQueryTarget) throw new Error('Invalid query target');
232
+
233
+ // const { parameters } = resolvedQueryTarget;
234
+ // try {
235
+ // // we can try resolve the args first
236
+ // const resolvedArgs = await Promise.all(
237
+ // (args ?? []).map(async (arg, idx) => {
238
+ // if (typeof arg !== 'string') return arg;
239
+
240
+ // const cachedData = (await this.cache.queryGetObject(arg))?.data;
241
+ // if (!cachedData) return arg;
242
+
243
+ // const owner = cachedData.owner;
244
+ // if (!owner || typeof owner !== 'object' || !('Shared' in owner))
245
+ // return {
246
+ // objectId: cachedData.objectId,
247
+ // version: cachedData.version,
248
+ // digest: cachedData.digest,
249
+ // };
250
+
251
+ // const parameter = parameters[idx];
252
+ // if (
253
+ // typeof parameter !== 'object' ||
254
+ // !('MutableReference' in parameter || 'Reference' in parameter)
255
+ // )
256
+ // return arg;
257
+
258
+ // return {
259
+ // objectId: cachedData.objectId,
260
+ // initialSharedVersion: owner.Shared.initial_shared_version,
261
+ // mutable: 'MutableReference' in parameter,
262
+ // };
263
+ // })
264
+ // );
265
+ // return txb.moveCall(target, resolvedArgs, typeArgs);
266
+ // } catch (e: any) {
267
+ // console.error(e.message);
268
+ // return txb.moveCall(target, args, typeArgs);
269
+ // }
270
+ return txb.moveCall(target, args, typeArgs);
271
+ }
218
272
  }