@scallop-io/sui-scallop-sdk 2.0.13-merge-split-ve-sca-alpha.4 → 2.1.0-alpha.1

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 (55) hide show
  1. package/dist/index.d.mts +622 -697
  2. package/dist/index.d.ts +622 -697
  3. package/dist/index.js +32 -33
  4. package/dist/index.mjs +10 -10
  5. package/package.json +8 -18
  6. package/src/builders/borrowIncentiveBuilder.ts +8 -18
  7. package/src/builders/coreBuilder.ts +2 -2
  8. package/src/builders/index.ts +2 -2
  9. package/src/builders/oracles/index.ts +2 -3
  10. package/src/builders/oracles/pyth.ts +2 -2
  11. package/src/builders/spoolBuilder.ts +2 -2
  12. package/src/builders/vescaBuilder.ts +14 -132
  13. package/src/constants/queryKeys.ts +29 -54
  14. package/src/constants/testAddress.ts +6 -12
  15. package/src/index.ts +11 -1
  16. package/src/models/index.ts +11 -9
  17. package/src/models/interface.ts +36 -0
  18. package/src/models/scallop.ts +38 -133
  19. package/src/models/scallopAddress.ts +127 -142
  20. package/src/models/scallopAxios.ts +185 -0
  21. package/src/models/scallopBuilder.ts +45 -75
  22. package/src/models/scallopClient.ts +124 -154
  23. package/src/models/scallopConstants.ts +248 -323
  24. package/src/models/scallopIndexer.ts +54 -98
  25. package/src/models/scallopQuery.ts +145 -190
  26. package/src/models/scallopQueryClient.ts +29 -0
  27. package/src/models/scallopSuiKit.ts +432 -0
  28. package/src/models/scallopUtils.ts +260 -164
  29. package/src/queries/borrowIncentiveQuery.ts +28 -16
  30. package/src/queries/borrowLimitQuery.ts +1 -1
  31. package/src/queries/coreQuery.ts +148 -107
  32. package/src/queries/flashloanFeeQuery.ts +12 -6
  33. package/src/queries/index.ts +0 -1
  34. package/src/queries/isolatedAssetQuery.ts +3 -3
  35. package/src/queries/loyaltyProgramQuery.ts +10 -8
  36. package/src/queries/ownerQuery.ts +32 -0
  37. package/src/queries/portfolioQuery.ts +4 -5
  38. package/src/queries/priceQuery.ts +14 -8
  39. package/src/queries/referralQuery.ts +9 -3
  40. package/src/queries/sCoinQuery.ts +4 -4
  41. package/src/queries/spoolQuery.ts +11 -11
  42. package/src/queries/supplyLimitQuery.ts +1 -1
  43. package/src/queries/switchboardQuery.ts +1 -1
  44. package/src/queries/vescaQuery.ts +31 -27
  45. package/src/queries/xOracleQuery.ts +13 -8
  46. package/src/types/address.ts +0 -3
  47. package/src/types/builder/core.ts +1 -1
  48. package/src/types/builder/vesca.ts +10 -20
  49. package/src/types/constant/queryKeys.ts +48 -0
  50. package/src/types/index.ts +0 -1
  51. package/src/utils/builder.ts +1 -1
  52. package/src/utils/util.ts +1 -33
  53. package/src/models/scallopCache.ts +0 -428
  54. package/src/queries/objectsQuery.ts +0 -18
  55. package/src/types/model.ts +0 -117
@@ -0,0 +1,36 @@
1
+ import ScallopAddress from './scallopAddress';
2
+ import ScallopBuilder from './scallopBuilder';
3
+ import ScallopConstants from './scallopConstants';
4
+ import ScallopQuery from './scallopQuery';
5
+ import ScallopSuiKit from './scallopSuiKit';
6
+ import ScallopUtils from './scallopUtils';
7
+
8
+ interface ScallopBaseInterface {
9
+ scallopSuiKit: ScallopSuiKit;
10
+ constants: ScallopConstants;
11
+ walletAddress: string;
12
+ init: () => Promise<void>;
13
+ }
14
+
15
+ interface ScallopUtilsInterface extends ScallopBaseInterface {
16
+ address: ScallopAddress;
17
+ }
18
+
19
+ interface ScallopQueryInterface extends ScallopUtilsInterface {
20
+ utils: ScallopUtils;
21
+ }
22
+
23
+ interface ScallopBuilderInterface extends ScallopQueryInterface {
24
+ query: ScallopQuery;
25
+ }
26
+
27
+ interface ScallopClientInterface extends ScallopBaseInterface {
28
+ builder: ScallopBuilder;
29
+ }
30
+
31
+ export type {
32
+ ScallopUtilsInterface,
33
+ ScallopQueryInterface,
34
+ ScallopBuilderInterface,
35
+ ScallopClientInterface,
36
+ };
@@ -1,23 +1,4 @@
1
- import { SuiKit } from '@scallop-io/sui-kit';
2
- import { ScallopAddress } from './scallopAddress';
3
- import { ScallopClient } from './scallopClient';
4
- import { ScallopBuilder } from './scallopBuilder';
5
- import { ScallopQuery } from './scallopQuery';
6
- import { ScallopUtils } from './scallopUtils';
7
- import type {
8
- ScallopBuilderParams,
9
- ScallopClientParams,
10
- ScallopConstantsParams,
11
- ScallopParams,
12
- ScallopQueryParams,
13
- ScallopUtilsParams,
14
- } from 'src/types';
15
- import { ScallopIndexer } from './scallopIndexer';
16
- import { ScallopCache } from './scallopCache';
17
- import { QueryClientConfig } from '@tanstack/query-core';
18
- import { newSuiKit } from './suiKit';
19
- import { ScallopConstants } from './scallopConstants';
20
- import type { QueryClient } from '@tanstack/query-core';
1
+ import ScallopClient, { ScallopClientParams } from './scallopClient';
21
2
 
22
3
  /**
23
4
  * @argument params - The parameters for the Scallop instance.
@@ -36,65 +17,28 @@ import type { QueryClient } from '@tanstack/query-core';
36
17
  * const scallopUtils= await sdk.createScallopUtils();
37
18
  * ```
38
19
  */
39
- export class Scallop {
40
- public params: ScallopParams;
41
- public suiKit: SuiKit;
42
- public cache: ScallopCache;
43
20
 
44
- private address: ScallopAddress;
45
- private constants: ScallopConstants;
46
-
47
- public constructor(
48
- params: ScallopParams,
49
- cacheOptions?: QueryClientConfig,
50
- queryClient?: QueryClient
51
- ) {
52
- this.params = params;
53
- this.suiKit = newSuiKit(params);
54
- this.cache = new ScallopCache(
55
- {
56
- ...this.params,
57
- cacheOptions,
58
- },
59
- {
60
- suiKit: this.suiKit,
61
- queryClient,
62
- }
63
- );
64
-
65
- this.address = new ScallopAddress(params, {
66
- cache: this.cache,
67
- });
68
- this.constants = new ScallopConstants(params, { address: this.address });
21
+ export type ScallopParams = {
22
+ client?: ScallopClient;
23
+ } & ScallopClientParams;
24
+ class Scallop {
25
+ public readonly client: ScallopClient;
26
+ public constructor(params: ScallopParams) {
27
+ this.client = params.client ?? new ScallopClient(params);
69
28
  }
70
29
 
71
- private async initConstants(params?: Partial<ScallopConstantsParams>) {
72
- if (!this.constants.isInitialized) await this.constants.init(params);
30
+ async init(force: boolean = false) {
31
+ await this.client.init(force);
73
32
  }
74
33
 
75
34
  /**
76
- * Get a scallop address instance that already has read addresses.
35
+ * Create a scallop client instance that already has initial data.
77
36
  *
78
- * @param id - The API id of the addresses.
79
- * @return Scallop Address.
80
- */
81
- public async getScallopAddress(id: string = this.params.addressId) {
82
- await this.address.read(id);
83
-
84
- return this.address;
85
- }
86
-
87
- /**
88
- * Get a scallop constants instance that already has initial data.
89
- * @returns Scallop Constants
37
+ * @return Scallop Client.
90
38
  */
91
- public async getScallopConstants(params?: Partial<ScallopConstantsParams>) {
92
- await this.initConstants({
93
- ...this.params,
94
- ...params,
95
- });
96
-
97
- return this.constants;
39
+ async createScallopClient() {
40
+ await this.init();
41
+ return this.client;
98
42
  }
99
43
 
100
44
  /**
@@ -102,55 +46,29 @@ export class Scallop {
102
46
  *
103
47
  * @return Scallop Builder.
104
48
  */
105
- public async createScallopBuilder(params?: Partial<ScallopBuilderParams>) {
106
- await this.initConstants(params);
107
- const builderParams = {
108
- ...this.params,
109
- ...params,
110
- };
111
- const scallopBuilder = new ScallopBuilder(builderParams, {
112
- query: await this.createScallopQuery(builderParams),
113
- });
114
-
115
- return scallopBuilder;
49
+ async createScallopBuilder() {
50
+ await this.init();
51
+ return this.client.builder;
116
52
  }
117
53
 
118
54
  /**
119
- * Create a scallop client instance that already has initial data.
55
+ * Create a scallop query instance.
120
56
  *
121
- * @param walletAddress - When user cannot provide a secret key or mnemonic, the scallop client cannot directly derive the address of the transaction the user wants to sign. This argument specifies the wallet address for signing the transaction.
122
- * @return Scallop Client.
57
+ * @return Scallop Query.
123
58
  */
124
- public async createScallopClient(params?: Partial<ScallopClientParams>) {
125
- await this.initConstants(params);
126
- const clientParams = {
127
- ...this.params,
128
- ...params,
129
- };
130
- const scallopClient = new ScallopClient(clientParams, {
131
- builder: await this.createScallopBuilder(clientParams),
132
- });
133
-
134
- return scallopClient;
59
+ async createScallopQuery() {
60
+ await this.init();
61
+ return this.client.query;
135
62
  }
136
63
 
137
64
  /**
138
- * Create a scallop query instance.
65
+ * Create a scallop utils instance.
139
66
  *
140
- * @return Scallop Query.
67
+ * @return Scallop Utils.
141
68
  */
142
- public async createScallopQuery(params?: Partial<ScallopQueryParams>) {
143
- await this.initConstants(params);
144
- const queryParams = {
145
- ...this.params,
146
- ...params,
147
- };
148
-
149
- const scallopQuery = new ScallopQuery(queryParams, {
150
- utils: await this.createScallopUtils(queryParams),
151
- });
152
-
153
- return scallopQuery;
69
+ async createScallopUtils() {
70
+ await this.init();
71
+ return this.client.utils;
154
72
  }
155
73
 
156
74
  /**
@@ -158,32 +76,19 @@ export class Scallop {
158
76
  *
159
77
  * @return Scallop Indexer.
160
78
  */
161
- public async createScallopIndexer() {
162
- const scallopIndexer = new ScallopIndexer(this.params, {
163
- cache: this.cache,
164
- });
165
-
166
- return scallopIndexer;
79
+ async createScallopIndexer() {
80
+ await this.init();
81
+ return this.client.query.indexer;
167
82
  }
168
83
 
169
84
  /**
170
- * Create a scallop utils instance.
171
- *
172
- * @return Scallop Utils.
85
+ * Get a scallop constants instance that already has initial data.
86
+ * @returns Scallop Constants
173
87
  */
174
- public async createScallopUtils(params?: Partial<ScallopUtilsParams>) {
175
- await this.initConstants(params);
176
- const scallopUtils = new ScallopUtils(
177
- {
178
- ...this.params,
179
- ...params,
180
- },
181
- {
182
- constants: this.constants,
183
- suiKit: this.suiKit,
184
- }
185
- );
186
-
187
- return scallopUtils;
88
+ async getScallopConstants() {
89
+ await this.init();
90
+ return this.client.constants;
188
91
  }
189
92
  }
93
+
94
+ export default Scallop;