@scallop-io/sui-scallop-sdk 4.2.0 → 4.4.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 (59) hide show
  1. package/README.md +357 -139
  2. package/dist/builder.cjs +20 -5
  3. package/dist/builder.d.cts +3 -2
  4. package/dist/builder.d.ts +3 -2
  5. package/dist/builder.js +2 -2
  6. package/dist/chunk-H2NF725V.js +30 -0
  7. package/dist/{chunk-4IC4UXW5.js → chunk-HQFMP3PN.js} +2 -2
  8. package/dist/chunk-XP3YYPCP.js +11 -0
  9. package/dist/client.cjs +19 -4
  10. package/dist/client.d.cts +2 -1
  11. package/dist/client.d.ts +2 -1
  12. package/dist/client.js +3 -3
  13. package/dist/index.cjs +52 -37
  14. package/dist/index.d.cts +12 -10
  15. package/dist/index.d.ts +12 -10
  16. package/dist/index.js +4 -4
  17. package/dist/{query-CXvcpnYj.d.ts → query-BqdO3ECh.d.ts} +135 -11
  18. package/dist/query.cjs +19 -4
  19. package/dist/query.d.cts +2 -1
  20. package/dist/query.d.ts +2 -1
  21. package/dist/query.js +1 -1
  22. package/dist/types.d.cts +2 -1
  23. package/dist/types.d.ts +2 -1
  24. package/package.json +9 -6
  25. package/src/constants/queryKeys.ts +11 -20
  26. package/src/constants/testAddress.ts +2 -0
  27. package/src/datasources/api.ts +3 -3
  28. package/src/datasources/onchain.ts +193 -10
  29. package/src/models/scallopAddress/const.ts +1 -0
  30. package/src/models/scallopAddress/index.ts +2 -2
  31. package/src/models/scallopAddress/types.ts +1 -0
  32. package/src/models/scallopBuilder/index.ts +9 -3
  33. package/src/models/scallopConstants/index.ts +35 -7
  34. package/src/models/scallopQuery/index.ts +47 -0
  35. package/src/models/scallopQuery/types.ts +13 -0
  36. package/src/models/scallopUtils/index.ts +7 -3
  37. package/src/models/scallopUtils/types.ts +7 -1
  38. package/src/repositories/borrowIncentive/helpers.ts +2 -2
  39. package/src/repositories/coinBalance/helpers.ts +364 -49
  40. package/src/repositories/coinBalance/index.ts +24 -1
  41. package/src/repositories/coinBalance/types.ts +16 -0
  42. package/src/repositories/obligation/helpers.ts +59 -0
  43. package/src/repositories/obligation/index.ts +5 -0
  44. package/src/repositories/obligation/types.ts +17 -1
  45. package/src/repositories/obligation/utils.ts +22 -0
  46. package/src/repositories/price/const.ts +7 -0
  47. package/src/repositories/price/helpers.ts +54 -37
  48. package/src/repositories/price/index.ts +5 -1
  49. package/src/repositories/price/types.ts +11 -3
  50. package/src/repositories/veSca/helpers.ts +1 -1
  51. package/src/repositories/wiring/datasources.ts +29 -1
  52. package/src/repositories/wiring/metadata.ts +1 -0
  53. package/src/repositories/wiring/registry.ts +41 -2
  54. package/src/txBuilders/oracles/pyth.ts +1 -5
  55. package/src/txBuilders/vesca/quick.ts +9 -3
  56. package/src/types/constant/queryKeys.ts +7 -3
  57. package/src/utils/object.ts +9 -1
  58. package/dist/chunk-3T4T4AON.js +0 -15
  59. package/dist/chunk-6YLMI74S.js +0 -11
package/README.md CHANGED
@@ -4,149 +4,367 @@
4
4
  </a>
5
5
  </p>
6
6
  <p align="center">
7
- <a style="padding-right: 5px;" href="https://github.com/scallop-io/sui-scallop-sdk/releases">
8
- <img alt="GitHub release" src="https://img.shields.io/github/v/release/scallop-io/sui-scallop-sdk?display_name=tag">
9
- </a>
10
- <a href="https://github.com/scallop-io/sui-scallop-sdk/blob/main/LICENSE">
11
- <img alt="GitHub licence" src="https://img.shields.io/github/license/scallop-io/sui-scallop-sdk?logoColor=blue">
12
- </a>
7
+ <a style="padding-right: 5px;" href="https://github.com/scallop-io/sui-scallop-sdk/releases">
8
+ <img alt="GitHub release" src="https://img.shields.io/github/v/release/scallop-io/sui-scallop-sdk?display_name=tag">
9
+ </a>
10
+ <a href="https://github.com/scallop-io/sui-scallop-sdk/blob/main/LICENSE">
11
+ <img alt="GitHub licence" src="https://img.shields.io/github/license/scallop-io/sui-scallop-sdk?logoColor=blue">
12
+ </a>
13
13
  </p>
14
14
 
15
- # The Typescript SDK for interacting with the Scallop lending protocol on the SUI network
16
-
17
- ## Description
18
-
19
- This SDK is used to interact with [sui-lending-protocol](https://github.com/scallop-io/sui-lending-protocol) and is written based on another sui-integrated tool, [sui-kit](https://github.com/scallop-io/sui-kit). It consists of seven main functional models, here's a brief introduction to each of them:
20
-
21
- - **Scallop**: Provide an entry to quickly create an instance (client, address, query, builder, utils) and complete initialization at the same time.
22
-
23
- - **ScallopClient**: Helps users encapsulate basic operations for interacting with the contract. Once the instance is created, it can be called directly for use.
24
-
25
- - **ScallopAddress**: Used to manage the addresses of the lending contract. It's prepackaged into the client and provides the addresses of mainly production environment for customers to query addresses, usually used in conjunction with the builder.
26
-
27
- - **ScallopQuery**: Used to encapsulate all methods for querying on-chain data of the scallop contract. More useful information will be provided here in the future, such as lending, collateral, or borrowing portfolios.
28
-
29
- - **ScallopBuilder**: Used for more detailed organization of the lending protocol's transaction blocks. You can build your own transaction combinations according to your needs by this model.
30
-
31
- - **ScallopUtils**: Used to encapsulate some useful methods that will be used when interacting with the scallop contract.
32
-
33
- - **ScallopIndexer**: It is used to query the on-chain index data through the SDK API. It is mainly used in query instances, effectively reducing the number of RPC requests..
34
-
35
- ## Pre-requisites
36
-
37
- - Installation:
38
- ```bash
39
- pnpm install @scallop-io/sui-scallop-sdk
40
- ```
41
- - Create an instance:
42
-
43
- > **Note**: Currently, this SDK only supports the mainnet network. When you use the testnet network, it will give errors because there is no address package ID for the testnet.
44
-
45
- ```typescript
46
- // Create an instance quickly through the`Scallop` class to construct other models.
47
- const scallopSDK = new Scallop({
48
- addressId: '695fcdc084f790c04eb068dc',
49
- networkType: 'mainnet',
50
- secretKey: [secretKey]
51
- ...
52
- });
53
-
54
- const scallopConstants = await scallopSDK.getScallopConstants();
55
- // Note: ScallopConstants inherits from ScallopAddress, so you can access addresses via scallopConstants
56
- const scallopQuery = await scallopSDK.createScallopQuery();
57
- const scallopBuilder = await scallopSDK.createScallopBuilder();
58
- const scallopUtils = await scallopSDK.createScallopUtils();
59
- const scallopClient = await scallopSDK.createScallopClient();
60
- const scallopIndexer = await scallopSDK.createScallopIndexer();
61
-
62
- // Or with single init
63
- await scallopSDK.init();
64
- const scallopClient = scallopSDK.client;
65
- const {
66
- query,
67
- builder,
68
- constants,
69
- address,
70
- indexer
71
- } = scallopClient;
72
- const { indexer } = query;
73
-
74
- // Or, you can choose to import the class directly to create an instance.
75
- import {
76
- ScallopAddress,
77
- ScallopConstants,
78
- ScallopBuilder,
79
- ScallopQuery,
80
- ScallopUtils,
81
- ScallopIndexer,
82
- ScallopClient,
83
- } from '@scallop-io/sui-scallop-sdk'
84
-
85
- const scallopAddress = new ScallopAddress(
86
- addressId: '695fcdc084f790c04eb068dc',
87
- ...
88
- );
89
- const scallopConstants = new ScallopConstants(
90
- addressId: '695fcdc084f790c04eb068dc',
91
- ...
92
- );
93
- const scallopQuery = new ScallopQuery(
94
- addressId: '695fcdc084f790c04eb068dc',
95
- ...
96
- );
97
- const scallopBuilder = new ScallopBuilder(
98
- addressId: '695fcdc084f790c04eb068dc',
99
- ...
100
- );
101
- const scallopUtils = new ScallopUtils(
102
- addressId: '695fcdc084f790c04eb068dc',
103
- ...
104
- );
105
- const scallopClient = new ScallopClient(
106
- addressId: '695fcdc084f790c04eb068dc',
107
- ...
108
- );
109
- const scallopIndexer = new ScallopIndexer();
110
-
111
- // Remember to initialize the instance before using it
112
- await scallopAddress.read();
113
- await scallopConstants.init();
114
- await scallopQuery.init();
115
- await scallopBuilder.init();
116
- await scallopUtils.init();
117
- await scallopClient.init();
118
- ```
119
-
120
- ## Quick Guide for each model
121
-
122
- Below we will give a brief introduction to these instances respectively, and introduce the functions through test codes.
123
-
124
- - [Use Scallop Client](./document/client.md)
125
- - [Use Scallop Query](./document/query.md)
126
- - [Use Scallop Address](./document/address.md)
127
- - [Use Scallop Builder](./document/builder.md)
128
- - [Use Scallop Utils](./document/utils.md)
129
- - [Use Scallop Constants](./document/constants.md)
130
-
131
- For the original codes, please refer to `test` folder.
132
-
133
- You need to set up the `.env` file before testing. (Reference `.env.example`)
134
-
135
- - Run the test
136
-
137
- ```bash
138
- pnpm run test:unit test/index.spec.ts
139
- pnpm run test:unit test/address.spec.ts
140
- pnpm run test:unit test/builder.spec.ts
141
- pnpm run test:unit test/query.spec.ts
142
- pnpm run test:unit test/utils.spec.ts
143
- pnpm run test:unit test/indexer.spec.ts
144
- pnpm run test:unit test/constants.spec.ts
145
- pnpm run test:unit test/rate-limiter.spec.ts
146
- ```
15
+ # Scallop TypeScript SDK
16
+
17
+ TypeScript SDK for integrating with the Scallop lending protocol on Sui.
18
+
19
+ Current package: `@scallop-io/sui-scallop-sdk` v4.x. ESM package, Node `>=22`, peer dependency `@mysten/sui@^2.0.0`.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pnpm add @scallop-io/sui-scallop-sdk @mysten/sui
25
+ ```
26
+
27
+ ## Public Entry Points
28
+
29
+ Root export:
30
+
31
+ ```ts
32
+ import {
33
+ Scallop,
34
+ ScallopClient,
35
+ ScallopBuilder,
36
+ ScallopQuery,
37
+ ScallopUtils,
38
+ ScallopConstants,
39
+ ScallopAddress,
40
+ } from '@scallop-io/sui-scallop-sdk';
41
+ ```
42
+
43
+ Subpath exports:
44
+
45
+ ```ts
46
+ import { ScallopClient } from '@scallop-io/sui-scallop-sdk/client';
47
+ import { ScallopBuilder } from '@scallop-io/sui-scallop-sdk/builder';
48
+ import { ScallopQuery } from '@scallop-io/sui-scallop-sdk/query';
49
+ import type { ScallopTxBlock } from '@scallop-io/sui-scallop-sdk/types';
50
+ import { ScallopError } from '@scallop-io/sui-scallop-sdk/errors';
51
+ import { consoleLogger } from '@scallop-io/sui-scallop-sdk/logger';
52
+ ```
53
+
54
+ Supported subpaths:
55
+
56
+ - `@scallop-io/sui-scallop-sdk`
57
+ - `@scallop-io/sui-scallop-sdk/client`
58
+ - `@scallop-io/sui-scallop-sdk/query`
59
+ - `@scallop-io/sui-scallop-sdk/builder`
60
+ - `@scallop-io/sui-scallop-sdk/errors`
61
+ - `@scallop-io/sui-scallop-sdk/logger`
62
+ - `@scallop-io/sui-scallop-sdk/types`
63
+
64
+ ## Main Models
65
+
66
+ `Scallop` is the convenience factory. It owns one initialized `ScallopClient` and exposes factory methods for the other facades.
67
+
68
+ ```text
69
+ Scallop
70
+ -> ScallopClient write facade; signs/sends user actions
71
+ -> ScallopBuilder tx-block builder; owns SuiKit + TransactionExecutor
72
+ -> ScallopQuery read facade; delegates to repositories
73
+ -> ScallopUtils
74
+ -> ScallopConstants
75
+ -> ScallopAddress
76
+ ```
77
+
78
+ Important v4 details:
79
+
80
+ - `ScallopIndexer` model was removed. Query/indexer access is internal to repositories.
81
+ - `ScallopConstants` composes `ScallopAddress`; use `constants.address` for the address adapter.
82
+ - Back-compatible address forwarders remain on constants: `get`, `set`, `getAddresses`, `setAddresses`, `getId`, `getAllAddresses`, `switchCurrentAddresses`.
83
+ - Write-path signer/executor lives on `builder.executor`; raw SuiKit lives on `builder.suiKit`.
84
+
85
+ ## Create SDK
86
+
87
+ Mainnet example:
88
+
89
+ ```ts
90
+ import { Scallop } from '@scallop-io/sui-scallop-sdk';
91
+
92
+ const sdk = new Scallop({
93
+ addressId: '695fcdc084f790c04eb068dc',
94
+ network: 'mainnet',
95
+ fullnodeUrl: 'https://fullnode.mainnet.sui.io:443',
96
+ secretKey: process.env.SECRET_KEY,
97
+ pythEndpoints: ['https://hermes.pyth.network'],
98
+ });
99
+
100
+ const client = await sdk.createScallopClient();
101
+ const query = await sdk.createScallopQuery();
102
+ const builder = await sdk.createScallopBuilder();
103
+ const utils = await sdk.createScallopUtils();
104
+ const constants = await sdk.getScallopConstants();
105
+ ```
106
+
107
+ Read-only example:
108
+
109
+ ```ts
110
+ const sdk = new Scallop({
111
+ addressId: '695fcdc084f790c04eb068dc',
112
+ network: 'mainnet',
113
+ fullnodeUrl: 'https://fullnode.mainnet.sui.io:443',
114
+ walletAddress: '0x...',
115
+ pythEndpoints: ['https://hermes.pyth.network'],
116
+ });
117
+
118
+ const query = await sdk.createScallopQuery();
119
+ const pools = await query.getMarketPools();
120
+ ```
121
+
122
+ Manual construction is supported. Call `.init()` before use:
123
+
124
+ ```ts
125
+ import { ScallopQuery } from '@scallop-io/sui-scallop-sdk/query';
126
+
127
+ const query = new ScallopQuery({
128
+ addressId: '695fcdc084f790c04eb068dc',
129
+ network: 'mainnet',
130
+ fullnodeUrl: 'https://fullnode.mainnet.sui.io:443',
131
+ walletAddress: '0x...',
132
+ });
133
+
134
+ await query.init();
135
+ ```
136
+
137
+ ## Constructor Options
138
+
139
+ Common required options:
140
+
141
+ - `addressId`: Scallop API address config id.
142
+ - `network`: Sui network, usually `'mainnet'`.
143
+ - `fullnodeUrl`: Sui RPC URL.
144
+ - `walletAddress`: required for read-only/wallet-scoped queries when no signer is supplied.
145
+ - `secretKey` or `mnemonics`: required for signing via `ScallopClient`.
146
+
147
+ Common optional options:
148
+
149
+ - `pythEndpoints`: Pyth Hermes endpoints for price-update flows.
150
+ - `queryClient` / `queryClientConfig`: custom `@tanstack/query-core` cache.
151
+ - `priceTimeout`: cache lifetime (ms) for the full Pyth price-feed list. Default `5_000`. Within this window, single/subset price reads are served from one cached full-list fetch instead of re-hitting the Pyth API; a longer value cuts API traffic at the cost of price staleness.
152
+ - `logger`: SDK logger. Default is silent `noopLogger`; pass `consoleLogger` to opt into console output.
153
+ - `strictInit`: when `true`, `init()` throws `ScallopConfigError` if required config is missing.
154
+ - `tokensPerSecond`: RPC read rate limit.
155
+ - `usePythPullModel`, `useOnChainXOracleList`, `sponsoredFeeds`: tx-builder oracle behavior.
156
+
157
+ ### Overriding the underlying clients
158
+
159
+ The SDK builds its own transport clients by default, but you can inject your own:
160
+
161
+ - `suiClient` (`ClientWithCoreApi` from `@mysten/sui`): overrides the Sui RPC client used for on-chain reads. When omitted, the SDK builds a `SuiGrpcClient` from `network` + `fullnodeUrl`. Accepted by `ScallopUtils` / `ScallopQuery` / `ScallopBuilder` / `ScallopClient` / `Scallop`.
162
+ - `httpClient` (`AxiosInstance`): overrides the HTTP client used for Scallop API / address-config fetches. When omitted, the SDK creates an Axios instance from the API `url` + `timeout`. Accepted anywhere `ScallopAddress` config flows (`Scallop`, `ScallopConstants`, `ScallopAddress`).
163
+ - `client` (`ScallopClient`): only on the top-level `Scallop` constructor — reuse an already-built `ScallopClient` instead of constructing a new one. Unrelated to the two transport clients above.
164
+
165
+ ```ts
166
+ import { Scallop } from '@scallop-io/sui-scallop-sdk';
167
+ import { SuiClient } from '@mysten/sui/client';
168
+ import axios from 'axios';
169
+
170
+ const sdk = new Scallop({
171
+ addressId: '695fcdc084f790c04eb068dc',
172
+ network: 'mainnet',
173
+ fullnodeUrl: 'https://fullnode.mainnet.sui.io:443',
174
+ walletAddress: '0x...',
175
+ suiClient: new SuiClient({ url: 'https://fullnode.mainnet.sui.io:443' }), // custom Sui RPC client
176
+ httpClient: axios.create({ timeout: 15_000 }), // custom HTTP client for API/address fetches
177
+ });
178
+ ```
179
+
180
+ > Note: prior to v4.3.0 these were all named `client` and collided into an unusable intersection type. Use `suiClient` / `httpClient` (and the top-level `client`) on v4.3.0+.
181
+
182
+ ## Query Examples
183
+
184
+ ```ts
185
+ const marketPools = await query.getMarketPools();
186
+ const suiPool = await query.getMarketPool('sui');
187
+ const collaterals = await query.getMarketCollaterals();
188
+
189
+ const obligations = await query.getObligations('0xOwner');
190
+ const obligation = await query.queryObligation('0xObligationId');
191
+ const portfolio = await query.getUserPortfolio({ walletAddress: '0xOwner' });
192
+
193
+ const prices = await query.getPythCoinPrices({ coinNames: ['sui', 'usdc'] });
194
+ const allPrices = await query.getAllCoinPrices();
195
+
196
+ const stakeAccounts = await query.getAllStakeAccounts('0xOwner');
197
+ const tvl = await query.getTvl();
198
+ ```
199
+
200
+ Read source selection is available on supported facade methods via legacy-compatible flags:
201
+
202
+ ```ts
203
+ await query.getMarketPools(undefined, { source: 'rpc' }); // on-chain RPC
204
+ await query.getMarketPools(undefined, { source: 'indexer' }); // API/indexer only
205
+ await query.getMarketPools(undefined, { source: 'indexer-first' }); // API/indexer with RPC fallback
206
+ await query.getMarketPools(undefined, { indexer: true }); // same as indexer-first
207
+ ```
208
+
209
+ Repository internals normalize those values to `onchain`, `api`, or `api-first`.
210
+
211
+ ## Client Examples
212
+
213
+ `ScallopClient` methods sign and execute by default. Pass `false` where supported to receive an unsigned transaction instead.
214
+
215
+ ```ts
216
+ const result = await client.openObligation();
217
+
218
+ await client.supply('sui', 1_000_000_000);
219
+ await client.depositCollateral('sui', 1_000_000_000);
220
+ await client.withdraw('sui', 1_000_000_000);
221
+ await client.withdrawCollateral('sui', 1_000_000_000);
222
+
223
+ await client.borrow(
224
+ 'usdc',
225
+ 1_000_000,
226
+ true,
227
+ '0xObligationId',
228
+ '0xObligationKey'
229
+ );
230
+ await client.repay(
231
+ 'usdc',
232
+ 1_000_000,
233
+ true,
234
+ '0xObligationId',
235
+ '0xObligationKey'
236
+ );
237
+
238
+ const tx = await client.supply('sui', 1_000_000_000, false);
239
+ ```
240
+
241
+ Other write helpers include:
242
+
243
+ - lending: `supply`, `withdraw`, `flashLoan`
244
+ - collateral: `depositCollateral`, `withdrawCollateral`
245
+ - borrow: `openObligation`, `borrow`, `repay`
246
+ - spool: `createStakeAccount`, `stake`, `unstake`, `claim`, `supplyAndStake`, `unstakeAndWithdraw`
247
+ - veSCA / incentives: `stakeObligation`, `unstakeObligation`, `claimBorrowIncentive`, `claimAllUnlockedSca`
248
+ - migration/test helpers: `migrateAllMarketCoin`, `mintTestCoin`
249
+
250
+ ## Transaction Builder
251
+
252
+ Use `ScallopBuilder` for custom transaction composition.
253
+
254
+ ```ts
255
+ const tx = builder.createTxBlock();
256
+
257
+ await tx.supplyQuick('sui', 1_000_000_000);
258
+ await tx.depositCollateralQuick('sui', 1_000_000_000);
259
+
260
+ const result = await builder.executor.signAndSendTxn(tx);
261
+ ```
262
+
263
+ `ScallopTxBlock` exposes both flat methods and module-grouped methods. References are identity-equal:
264
+
265
+ ```ts
266
+ tx.supplyQuick === tx.core.supplyQuick; // true
267
+ tx.stake === tx.spool.stake; // true
268
+ ```
269
+
270
+ Modules:
271
+
272
+ - `tx.core`: lending, collateral, borrow, liquidations, flash loans
273
+ - `tx.spool`: staking market coins
274
+ - `tx.vesca`: veSCA lock/split/merge/redeem flows
275
+ - `tx.borrowIncentive`: obligation staking and incentive claims
276
+ - `tx.referral`: referral binding/revenue flows
277
+ - `tx.loyalty`: loyalty reward claims
278
+ - `tx.sCoin`: sCoin mint/burn
279
+
280
+ Method conventions:
281
+
282
+ - normal methods are synchronous Move-call wrappers and return `TransactionResult`.
283
+ - `*Quick` methods are async helpers that fetch required coins/objects/oracle updates, call normal methods, and return leftovers where needed.
284
+ - canonical lending names are `supply` / `supplyQuick` / `depositCollateral` / `depositCollateralQuick`.
285
+ - legacy `deposit*` and `addCollateral*` names are deprecated.
286
+
287
+ ## Constants And Addresses
288
+
289
+ ```ts
290
+ const constants = await sdk.getScallopConstants();
291
+
292
+ const corePackage = constants.get('core.packages.protocol.id');
293
+ const allAddresses = constants.getAddresses();
294
+
295
+ const addressAdapter = constants.address;
296
+ const addressId = addressAdapter.addressId;
297
+ ```
298
+
299
+ `constants.whitelist` and `constants.poolAddresses` are frozen snapshots after `init()`.
300
+
301
+ ## Errors And Logging
302
+
303
+ SDK internals throw typed errors:
304
+
305
+ - `ScallopRpcError`: Sui RPC / gRPC failures
306
+ - `ScallopIndexerError`: Scallop API/indexer HTTP failures
307
+ - `ScallopParseError`: invalid or unexpected payload
308
+ - `ScallopConfigError`: config validation failure
309
+ - `ScallopTransactionBuildError`: tx construction failure
310
+
311
+ ```ts
312
+ import { ScallopError } from '@scallop-io/sui-scallop-sdk/errors';
313
+ import { consoleLogger } from '@scallop-io/sui-scallop-sdk/logger';
314
+
315
+ const sdk = new Scallop({
316
+ addressId: '695fcdc084f790c04eb068dc',
317
+ network: 'mainnet',
318
+ fullnodeUrl: 'https://fullnode.mainnet.sui.io:443',
319
+ walletAddress: '0x...',
320
+ logger: consoleLogger,
321
+ });
322
+
323
+ try {
324
+ await query.getMarketPools();
325
+ } catch (error) {
326
+ if (error instanceof ScallopError) {
327
+ // error.cause and error.context are available where provided
328
+ }
329
+ }
330
+ ```
331
+
332
+ ## Local Development
333
+
334
+ ```bash
335
+ pnpm install
336
+ pnpm run build
337
+ pnpm run test:typecheck
338
+ pnpm run test:unit
339
+ ```
340
+
341
+ Useful scripts:
342
+
343
+ ```bash
344
+ pnpm run build # production build
345
+ pnpm run build:dev # development build
346
+ pnpm run test:typecheck # TypeScript checks for tests
347
+ pnpm run test:no-console # no console.* in SDK internals
348
+ pnpm run test:unit # network-free unit tests
349
+ pnpm run test:integration # integration tests; needs network + local env setup
350
+ pnpm run lint:fix
351
+ pnpm run format:fix
352
+ ```
353
+
354
+ Integration/query/full test runs require local environment variables such as `SECRET_KEY`. Do not commit secrets.
355
+
356
+ ## More Docs
357
+
358
+ - Contributor architecture: [`docs/SDK_STRUCTURE.md`](docs/SDK_STRUCTURE.md)
359
+ - Client guide: [`document/client.md`](document/client.md)
360
+ - Query guide: [`document/query.md`](document/query.md)
361
+ - Address guide: [`document/address.md`](document/address.md)
362
+ - Builder guide: [`document/builder.md`](document/builder.md)
363
+ - Utils guide: [`document/utils.md`](document/utils.md)
364
+ - Constants guide: [`document/constants.md`](document/constants.md)
147
365
 
148
366
  ## License
149
367
 
150
- [APACHE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
368
+ [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)
151
369
 
152
370
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/scallop-io/sui-scallop-sdk)