@cetusprotocol/deepbook-utils 0.0.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.
@@ -0,0 +1,897 @@
1
+ import { CoinBalance } from '@mysten/sui/dist/cjs/client/types/coins';
2
+ import * as _mysten_sui_transactions from '@mysten/sui/transactions';
3
+ import { TransactionArgument, Transaction } from '@mysten/sui/transactions';
4
+ import { SuiClient, SuiEventFilter, SuiObjectResponseQuery, SuiObjectDataOptions, SuiTransactionBlockResponse, SuiObjectResponse, SuiObjectData, SuiObjectRef, OwnedObjectRef, SuiMoveObject, ObjectOwner, DisplayFieldsResponse, SuiParsedData } from '@mysten/sui/client';
5
+ import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
6
+ import { Secp256k1Keypair } from '@mysten/sui/keypairs/secp256k1';
7
+ import Decimal from 'decimal.js';
8
+
9
+ /**
10
+ * Represents a SUI address, which is a string.
11
+ */
12
+ type SuiAddressType = string;
13
+ /**
14
+ * Represents a SUI object identifier, which is a string.
15
+ */
16
+ type SuiObjectIdType = string;
17
+ /**
18
+ * The address representing the clock in the system.
19
+ */
20
+ declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
21
+ /**
22
+ * Constants for different modules in the CLMM (Cryptocurrency Liquidity Mining Module).
23
+ */
24
+ declare const ClmmIntegratePoolModule = "pool_script";
25
+ declare const ClmmIntegratePoolV2Module = "pool_script_v2";
26
+ declare const ClmmIntegrateRouterModule = "router";
27
+ declare const ClmmIntegrateRouterWithPartnerModule = "router_with_partner";
28
+ declare const ClmmFetcherModule = "fetcher_script";
29
+ declare const ClmmExpectSwapModule = "expect_swap";
30
+ declare const ClmmIntegrateUtilsModule = "utils";
31
+ /**
32
+ * The address for CoinInfo module.
33
+ */
34
+ declare const CoinInfoAddress = "0x1::coin::CoinInfo";
35
+ /**
36
+ * The address for CoinStore module.
37
+ */
38
+ declare const CoinStoreAddress = "0x1::coin::CoinStore";
39
+ /**
40
+ * Constants for different modules in the Deepbook system.
41
+ */
42
+ declare const DeepbookCustodianV2Moudle = "custodian_v2";
43
+ declare const DeepbookClobV2Moudle = "clob_v2";
44
+ declare const DeepbookEndpointsV2Moudle = "endpoints_v2";
45
+ /**
46
+ * Represents a SUI resource, which can be of any type.
47
+ */
48
+ type SuiResource = any;
49
+ /**
50
+ * Represents a paginated data page with optional cursor and limit.
51
+ */
52
+ type DataPage<T> = {
53
+ data: T[];
54
+ nextCursor?: any;
55
+ hasNextPage: boolean;
56
+ };
57
+ /**
58
+ * Represents query parameters for pagination.
59
+ */
60
+ type PageQuery = {
61
+ cursor?: any;
62
+ limit?: number | null;
63
+ };
64
+ /**
65
+ * Represents arguments for pagination, with options for fetching all data or using PageQuery.
66
+ */
67
+ type PaginationArgs = 'all' | PageQuery;
68
+ /**
69
+ * Represents a Non-Fungible Token (NFT) with associated metadata.
70
+ */
71
+ type NFT = {
72
+ /**
73
+ * The address or identifier of the creator of the NFT.
74
+ */
75
+ creator: string;
76
+ /**
77
+ * A description providing additional information about the NFT.
78
+ */
79
+ description: string;
80
+ /**
81
+ * The URL to the image representing the NFT visually.
82
+ */
83
+ image_url: string;
84
+ /**
85
+ * A link associated with the NFT, providing more details or interactions.
86
+ */
87
+ link: string;
88
+ /**
89
+ * The name or title of the NFT.
90
+ */
91
+ name: string;
92
+ /**
93
+ * The URL to the project or collection associated with the NFT.
94
+ */
95
+ project_url: string;
96
+ };
97
+ /**
98
+ * Represents a SUI struct tag.
99
+ */
100
+ type SuiStructTag = {
101
+ /**
102
+ * The full address of the struct.
103
+ */
104
+ full_address: string;
105
+ /**
106
+ * The source address of the struct.
107
+ */
108
+ source_address: string;
109
+ /**
110
+ * The address of the struct.
111
+ */
112
+ address: SuiAddressType;
113
+ /**
114
+ * The module to which the struct belongs.
115
+ */
116
+ module: string;
117
+ /**
118
+ * The name of the struct.
119
+ */
120
+ name: string;
121
+ /**
122
+ * An array of type arguments (SUI addresses) for the struct.
123
+ */
124
+ type_arguments: SuiAddressType[];
125
+ };
126
+ /**
127
+ * Represents basic SUI data types.
128
+ */
129
+ type SuiBasicTypes = 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256';
130
+ /**
131
+ * Represents a SUI transaction argument, which can be of various types.
132
+ */
133
+ type SuiTxArg = TransactionArgument | string | number | bigint | boolean;
134
+ /**
135
+ * Represents input types for SUI data.
136
+ */
137
+ type SuiInputTypes = 'object' | SuiBasicTypes;
138
+ /**
139
+ * Gets the default SUI input type based on the provided value.
140
+ * @param value - The value to determine the default input type for.
141
+ * @returns The default SUI input type.
142
+ * @throws Error if the type of the value is unknown.
143
+ */
144
+ declare const getDefaultSuiInputType: (value: any) => SuiInputTypes;
145
+ /**
146
+ * Represents a coin asset with address, object ID, and balance information.
147
+ */
148
+ type CoinAsset = {
149
+ /**
150
+ * The address type of the coin asset.
151
+ */
152
+ coinAddress: SuiAddressType;
153
+ /**
154
+ * The object identifier of the coin asset.
155
+ */
156
+ coinObjectId: SuiObjectIdType;
157
+ /**
158
+ * The balance amount of the coin asset.
159
+ */
160
+ balance: bigint;
161
+ };
162
+
163
+ /**
164
+ * Represents configuration data for a cryptocurrency coin.
165
+ */
166
+ type CoinConfig = {
167
+ /**
168
+ * The unique identifier of the coin.
169
+ */
170
+ id: string;
171
+ /**
172
+ * The name of the coin.
173
+ */
174
+ name: string;
175
+ /**
176
+ * The symbol of the coin.
177
+ */
178
+ symbol: string;
179
+ /**
180
+ * The address associated with the coin.
181
+ */
182
+ address: string;
183
+ /**
184
+ * The Pyth identifier of the coin.
185
+ */
186
+ pyth_id: string;
187
+ /**
188
+ * The project URL related to the coin.
189
+ */
190
+ project_url: string;
191
+ /**
192
+ * The URL to the logo image of the coin.
193
+ */
194
+ logo_url: string;
195
+ /**
196
+ * The number of decimal places used for the coin.
197
+ */
198
+ decimals: number;
199
+ } & Record<string, any>;
200
+ /**
201
+ * Represents a package containing specific configuration or data.
202
+ * @template T - The type of configuration or data contained in the package.
203
+ */
204
+ type Package<T = undefined> = {
205
+ /**
206
+ * The unique identifier of the package.
207
+ */
208
+ package_id: string;
209
+ /**
210
+ * the package was published.
211
+ */
212
+ published_at: string;
213
+ /**
214
+ * The version number of the package (optional).
215
+ */
216
+ version?: number;
217
+ /**
218
+ * The configuration or data contained in the package (optional).
219
+ */
220
+ config?: T;
221
+ };
222
+
223
+ type OrderFee = {
224
+ quantity: string;
225
+ feeType: string;
226
+ };
227
+ type OrderDeepPrice = {
228
+ asset_is_base: boolean;
229
+ deep_per_asset: number;
230
+ };
231
+
232
+ type BigNumber = Decimal.Value | number | string;
233
+
234
+ /**
235
+ * Represents a module for making RPC (Remote Procedure Call) requests.
236
+ */
237
+ declare class RpcModule extends SuiClient {
238
+ /**
239
+ * Get events for a given query criteria
240
+ * @param query
241
+ * @param paginationArgs
242
+ * @returns
243
+ */
244
+ queryEventsByPage(query: SuiEventFilter, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
245
+ /**
246
+ * Get all objects owned by an address
247
+ * @param owner
248
+ * @param query
249
+ * @param paginationArgs
250
+ * @returns
251
+ */
252
+ getOwnedObjectsByPage(owner: string, query: SuiObjectResponseQuery, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
253
+ /**
254
+ * Return the list of dynamic field objects owned by an object
255
+ * @param parentId
256
+ * @param paginationArgs
257
+ * @returns
258
+ */
259
+ getDynamicFieldsByPage(parentId: SuiObjectIdType, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
260
+ /**
261
+ * Batch get details about a list of objects. If any of the object ids are duplicates the call will fail
262
+ * @param ids
263
+ * @param options
264
+ * @param limit
265
+ * @returns
266
+ */
267
+ batchGetObjects(ids: SuiObjectIdType[], options?: SuiObjectDataOptions, limit?: number): Promise<any[]>;
268
+ /**
269
+ * Calculates the gas cost of a transaction block.
270
+ * @param {Transaction} tx - The transaction block to calculate gas for.
271
+ * @returns {Promise<number>} - The estimated gas cost of the transaction block.
272
+ * @throws {Error} - Throws an error if the sender is empty.
273
+ */
274
+ calculationTxGas(tx: Transaction): Promise<number>;
275
+ /**
276
+ * Sends a transaction block after signing it with the provided keypair.
277
+ *
278
+ * @param {Ed25519Keypair | Secp256k1Keypair} keypair - The keypair used for signing the transaction.
279
+ * @param {Transaction} tx - The transaction block to send.
280
+ * @returns {Promise<SuiTransactionBlockResponse | undefined>} - The response of the sent transaction block.
281
+ */
282
+ sendTransaction(keypair: Ed25519Keypair | Secp256k1Keypair, tx: Transaction): Promise<SuiTransactionBlockResponse | undefined>;
283
+ }
284
+
285
+ interface IModule {
286
+ readonly sdk: DeepbookUtilsSDK;
287
+ }
288
+
289
+ declare const DEEP_SCALAR = 1000000;
290
+ declare const FLOAT_SCALAR = 1000000000;
291
+ type CoinItem = {
292
+ coinType: string;
293
+ decimals: number;
294
+ };
295
+ type DeepCoin = {
296
+ coinType: string;
297
+ decimals: number;
298
+ };
299
+ type StateAccount = {
300
+ balance_manager_id: string;
301
+ open_orders: string[];
302
+ owed_balances: Balances;
303
+ settled_balances: Balances;
304
+ unclaimed_rebates: Balances;
305
+ taker_volume: string;
306
+ poolInfo: any;
307
+ };
308
+ type Balances = {
309
+ base: string;
310
+ quote: string;
311
+ deep: string;
312
+ };
313
+ declare class DeepbookUtilsModule implements IModule {
314
+ protected _sdk: DeepbookUtilsSDK;
315
+ protected _deep: DeepCoin;
316
+ private readonly _cache;
317
+ constructor(sdk: DeepbookUtilsSDK);
318
+ get sdk(): DeepbookUtilsSDK;
319
+ get deepCoin(): DeepCoin;
320
+ createAndShareBalanceManager(): Transaction;
321
+ getBalanceManager(account: string): Promise<any>;
322
+ createAndDepsit({ account, coin, amountToDeposit }: {
323
+ account: string;
324
+ coin: CoinItem;
325
+ amountToDeposit: string;
326
+ }): Transaction;
327
+ depositIntoManager({ account, balanceManager, coin, amountToDeposit, tx, }: {
328
+ account: string;
329
+ balanceManager: string;
330
+ coin: CoinItem;
331
+ amountToDeposit: string;
332
+ tx?: Transaction;
333
+ }): Transaction | null;
334
+ withdrawFromManager({ account, balanceManager, coin, amountToWithdraw, returnAssets, txb, }: {
335
+ account: string;
336
+ balanceManager: string;
337
+ coin: CoinItem;
338
+ amountToWithdraw: string;
339
+ returnAssets?: boolean;
340
+ txb?: Transaction;
341
+ }): Transaction | _mysten_sui_transactions.TransactionResult;
342
+ withdrawSettledAmounts({ poolInfo, balanceManager }: {
343
+ poolInfo: any;
344
+ balanceManager: string;
345
+ }): Transaction;
346
+ getManagerBalance({ account, balanceManager, coins }: {
347
+ account: string;
348
+ balanceManager: string;
349
+ coins: CoinItem[];
350
+ }): Promise<any>;
351
+ getMarketPrice(poolInfo: any): Promise<string>;
352
+ getPools(): Promise<any>;
353
+ getQuoteQuantityOut(poolInfo: any, baseQuantity: string, account: string): Promise<{
354
+ baseQuantityDisplay: string;
355
+ baseOutDisplay: string;
356
+ quoteOutDisplay: string;
357
+ deepRequiredDisplay: string;
358
+ baseQuantity: string;
359
+ baseOut: string;
360
+ quoteOut: string;
361
+ deepRequired: string;
362
+ }>;
363
+ getBaseQuantityOut(poolInfo: any, quoteQuantity: string, account: string): Promise<{
364
+ quoteQuantityDisplay: string;
365
+ baseOutDisplay: string;
366
+ quoteOutDisplay: string;
367
+ deepRequiredDisplay: string;
368
+ quoteQuantity: string;
369
+ baseOut: string;
370
+ quoteOut: string;
371
+ deepRequired: string;
372
+ }>;
373
+ getQuantityOut(poolInfo: any, baseQuantity: string, quoteQuantity: string, account: string): Promise<{
374
+ baseQuantityDisplay: string;
375
+ quoteQuantityDisplay: string;
376
+ baseOutDisplay: string;
377
+ quoteOutDisplay: string;
378
+ deepRequiredDisplay: string;
379
+ baseQuantity: string;
380
+ quoteQuantity: string;
381
+ baseOut: number;
382
+ quoteOut: number;
383
+ deepRequired: number;
384
+ }>;
385
+ estimatedMaxFee(poolInfo: any, quantity: string, priceInput: string, payWithDeep: boolean, isBid: boolean, isLimit: boolean, priceOrigin?: string): Promise<OrderFee>;
386
+ getOrderDeepPrice(poolInfo: any): Promise<OrderDeepPrice | null>;
387
+ parseOrderDeepPrice(bytes: Uint8Array): OrderDeepPrice;
388
+ getCoinAssets(coin: string, amount: string, allCoinAsset: any, txb: any): TransactionArgument;
389
+ getTransactionRelatedBalance(poolInfo: any, baseCoin: string, quoteCoin: string, noDeep: boolean, account: string, payWithDeep: boolean, balanceManager: string): Promise<{
390
+ baseManagerBlance: any;
391
+ quoteManagerBlance: any;
392
+ feeManaerBalance: any;
393
+ }>;
394
+ getFeeAsset(maxFee: string, feeCoin: string, baseAmount: string, quoteAmount: string, feeManaerBalance: string, quoteIsDeep: boolean, baseIsDeep: boolean, allCoinAsset: any, payWithDeep: boolean, txb: Transaction): {
395
+ feeAsset: any;
396
+ haveDepositFee: string;
397
+ };
398
+ getTransactionRelatedAssets(poolInfo: any, baseAmount: string, quoteAmount: string, maxFee: string, isBid: boolean, account: string, payWithDeep: boolean, balanceManager: string, txb: Transaction): Promise<{
399
+ baseAsset: any;
400
+ quoteAsset: any;
401
+ feeAsset: {
402
+ feeAsset: any;
403
+ haveDepositFee: string;
404
+ };
405
+ haveDeposit: boolean;
406
+ }>;
407
+ getMarketTransactionRelatedAssets(poolInfo: any, baseAmount: string, quoteAmount: string, maxFee: string, isBid: boolean, account: string, payWithDeep: boolean, balanceManager: string, txb: Transaction): Promise<{
408
+ baseAsset: any;
409
+ quoteAsset: any;
410
+ feeAsset: any;
411
+ }>;
412
+ createDepositThenPlaceLimitOrder(poolInfo: any, priceInput: string, quantity: string, orderType: 'bid' | 'ask', maxFee: string, account: string, payWithDeep: boolean, expirationTimestamp?: number): Promise<any>;
413
+ getEmptyCoin(txb: any, coin: string): any;
414
+ createDepositThenPlaceMarketOrder(poolInfo: any, quantity: string, orderType: 'bid' | 'ask', maxFee: string, account: string, payWithDeep: boolean, slippage?: number): Promise<any>;
415
+ placeLimitOrder(balanceManager: string, poolInfo: any, priceInput: string, quantity: string, orderType: 'bid' | 'ask', maxFee: string, account: string, payWithDeep: boolean, expirationTimestamp?: number): Promise<Transaction>;
416
+ getBestAskprice(poolInfo: any): Promise<any>;
417
+ getBestBidprice(poolInfo: any): Promise<any>;
418
+ getBestAskOrBidPrice(poolInfo: any, isBid: boolean): Promise<any>;
419
+ placeMarketOrder(balanceManager: string, poolInfo: any, baseQuantity: string, quoteQuantity: string, isBid: boolean, maxFee: string, account: string, payWithDeep: boolean, slippage?: number): Promise<any>;
420
+ getOpenOrderFromDeepbook(account: string, balanceManager: string): Promise<void>;
421
+ getOrderInfoList(poolInfo: any, orderIds: string[], account: string): Promise<any>;
422
+ decodeOrderId(encodedOrderId: bigint): {
423
+ isBid: boolean;
424
+ price: bigint;
425
+ orderId: bigint;
426
+ };
427
+ getOpenOrder(poolInfo: any, account: string, balanceManager: string, orders?: string[]): Promise<any>;
428
+ cancelOrders(orderList: any, balanceManager: string): Transaction;
429
+ getDeepbookOrderBook(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean, account: string, balanceManager: string): Promise<void>;
430
+ processOrderBookData(data: any, baseCoin: any, quoteCoin: any, unit: number): unknown[];
431
+ getLevel2RangeTx(poolInfo: any, isBid: boolean, priceLow: string | number, priceHigh: string | number, tx?: Transaction): Transaction;
432
+ fetchOrderBook(poolInfo: any, orderType: 'bid' | 'ask' | 'all', midPrice: string, low: number, high: number, unit: number): Promise<{
433
+ bid: any;
434
+ ask: any;
435
+ }>;
436
+ getOrderBook(poolInfo: any, orderType: 'bid' | 'ask' | 'all', unit: number): Promise<any>;
437
+ getOrderBookOrigin(poolInfo: any, orderType: 'bid' | 'ask' | 'all'): Promise<{
438
+ bid: any;
439
+ ask: any;
440
+ bids?: undefined;
441
+ asks?: undefined;
442
+ } | {
443
+ bids: never[];
444
+ asks: never[];
445
+ bid?: undefined;
446
+ ask?: undefined;
447
+ }>;
448
+ getWalletBalance(account: string): Promise<{
449
+ [k: string]: any;
450
+ }>;
451
+ getAccount(balanceManager: string, poolList: any): Promise<StateAccount[] | null>;
452
+ /**
453
+ * Gets the SUI transaction response for a given transaction digest.
454
+ * @param digest - The digest of the transaction for which the SUI transaction response is requested.
455
+ * @param forceRefresh - A boolean flag indicating whether to force a refresh of the response.
456
+ * @returns A Promise that resolves with the SUI transaction block response or null if the response is not available.
457
+ */
458
+ getSuiTransactionResponse(digest: string, forceRefresh?: boolean): Promise<SuiTransactionBlockResponse | null>;
459
+ private transformExtensions;
460
+ /**
461
+ * Get coin config list.
462
+ * @param {boolean} forceRefresh Whether to force a refresh of the cache entry.
463
+ * @param {boolean} transformExtensions Whether to transform extensions.
464
+ * @returns {Promise<CoinConfig[]>} Coin config list.
465
+ */
466
+ getCoinConfigs(forceRefresh?: boolean, transformExtensions?: boolean): Promise<CoinConfig[]>;
467
+ /**
468
+ * Build coin config.
469
+ * @param {SuiObjectResponse} object Coin object.
470
+ * @param {boolean} transformExtensions Whether to transform extensions.
471
+ * @returns {CoinConfig} Coin config.
472
+ */
473
+ private buildCoinConfig;
474
+ /**
475
+ * Updates the cache for the given key.
476
+ *
477
+ * @param key The key of the cache entry to update.
478
+ * @param data The data to store in the cache.
479
+ * @param time The time in minutes after which the cache entry should expire.
480
+ */
481
+ updateCache(key: string, data: SuiResource, time?: number): void;
482
+ /**
483
+ * Gets the cache entry for the given key.
484
+ *
485
+ * @param key The key of the cache entry to get.
486
+ * @param forceRefresh Whether to force a refresh of the cache entry.
487
+ * @returns The cache entry for the given key, or undefined if the cache entry does not exist or is expired.
488
+ */
489
+ getCache<T>(key: string, forceRefresh?: boolean): T | undefined;
490
+ }
491
+
492
+ /**
493
+ * Represents options and configurations for an SDK.
494
+ */
495
+ type SdkOptions = {
496
+ network: string;
497
+ /**
498
+ * The full URL for interacting with the RPC (Remote Procedure Call) service.
499
+ */
500
+ fullRpcUrl: string;
501
+ /**
502
+ * Configuration for the simulation account.
503
+ */
504
+ simulationAccount: {
505
+ /**
506
+ * The address of the simulation account.
507
+ */
508
+ address: string;
509
+ };
510
+ deepbook: {
511
+ package_id: string;
512
+ published_at: string;
513
+ };
514
+ deepbook_utils: {
515
+ package_id: string;
516
+ published_at: string;
517
+ global_config_id: string;
518
+ cetus_balance_manager_indexer_id: string;
519
+ };
520
+ DEEP_COIN: {
521
+ coinType: string;
522
+ decimals: number;
523
+ };
524
+ coinlist: {
525
+ id: string;
526
+ handle: string;
527
+ };
528
+ };
529
+ /**
530
+ * The entry class of CetusClmmSDK, which is almost responsible for all interactions with CLMM.
531
+ */
532
+ declare class DeepbookUtilsSDK {
533
+ private readonly _cache;
534
+ /**
535
+ * RPC provider on the SUI chain
536
+ */
537
+ protected _rpcModule: RpcModule;
538
+ protected _deepbookUtils: any;
539
+ /**
540
+ * Provide sdk options
541
+ */
542
+ protected _sdkOptions: SdkOptions;
543
+ /**
544
+ * After connecting the wallet, set the current wallet address to senderAddress.
545
+ */
546
+ protected _senderAddress: string;
547
+ constructor(options: SdkOptions);
548
+ /**
549
+ * Getter for the sender address property.
550
+ * @returns {SuiAddressType} The sender address.
551
+ */
552
+ get senderAddress(): SuiAddressType;
553
+ /**
554
+ * Setter for the sender address property.
555
+ * @param {string} value - The new sender address value.
556
+ */
557
+ set senderAddress(value: string);
558
+ get DeepbookUtils(): DeepbookUtilsModule;
559
+ /**
560
+ * Getter for the fullClient property.
561
+ * @returns {RpcModule} The fullClient property value.
562
+ */
563
+ get fullClient(): RpcModule;
564
+ /**
565
+ * Getter for the sdkOptions property.
566
+ * @returns {SdkOptions} The sdkOptions property value.
567
+ */
568
+ get sdkOptions(): SdkOptions;
569
+ /**
570
+ * Gets all coin assets for the given owner and coin type.
571
+ *
572
+ * @param suiAddress The address of the owner.
573
+ * @param coinType The type of the coin.
574
+ * @returns an array of coin assets.
575
+ */
576
+ getOwnerCoinAssets(suiAddress: string, coinType?: string | null, forceRefresh?: boolean): Promise<CoinAsset[]>;
577
+ /**
578
+ * Gets all coin balances for the given owner and coin type.
579
+ *
580
+ * @param suiAddress The address of the owner.
581
+ * @param coinType The type of the coin.
582
+ * @returns an array of coin balances.
583
+ */
584
+ getOwnerCoinBalances(suiAddress: string, coinType?: string | null): Promise<CoinBalance[]>;
585
+ /**
586
+ * Updates the cache for the given key.
587
+ *
588
+ * @param key The key of the cache entry to update.
589
+ * @param data The data to store in the cache.
590
+ * @param time The time in minutes after which the cache entry should expire.
591
+ */
592
+ updateCache(key: string, data: SuiResource, time?: number): void;
593
+ /**
594
+ * Gets the cache entry for the given key.
595
+ *
596
+ * @param key The key of the cache entry to get.
597
+ * @param forceRefresh Whether to force a refresh of the cache entry.
598
+ * @returns The cache entry for the given key, or undefined if the cache entry does not exist or is expired.
599
+ */
600
+ getCache<T>(key: string, forceRefresh?: boolean): T | undefined;
601
+ }
602
+
603
+ declare const cacheTime5min: number;
604
+ declare const cacheTime24h: number;
605
+ declare function getFutureTime(interval: number): number;
606
+ /**
607
+ * Defines the structure of a CachedContent object, used for caching resources in memory.
608
+ */
609
+ declare class CachedContent {
610
+ overdueTime: number;
611
+ value: SuiResource | null;
612
+ constructor(value: SuiResource | null, overdueTime?: number);
613
+ isValid(): boolean;
614
+ }
615
+
616
+ declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
617
+ declare function composeType(address: string, generics: SuiAddressType[]): SuiAddressType;
618
+ declare function composeType(address: string, struct: string, generics?: SuiAddressType[]): SuiAddressType;
619
+ declare function composeType(address: string, module: string, struct: string, generics?: SuiAddressType[]): SuiAddressType;
620
+ declare function extractAddressFromType(type: string): string;
621
+ declare function extractStructTagFromType(type: string): SuiStructTag;
622
+ declare function normalizeCoinType(coinType: string): string;
623
+ declare function fixSuiObjectId(value: string): string;
624
+ /**
625
+ * Fixes and normalizes a coin type by removing or keeping the prefix.
626
+ *
627
+ * @param {string} coinType - The coin type to be fixed.
628
+ * @param {boolean} removePrefix - Whether to remove the prefix or not (default: true).
629
+ * @returns {string} - The fixed and normalized coin type.
630
+ */
631
+ declare const fixCoinType: (coinType: string, removePrefix?: boolean) => string;
632
+ /**
633
+ * Recursively traverses the given data object and patches any string values that represent Sui object IDs.
634
+ *
635
+ * @param {any} data - The data object to be patched.
636
+ */
637
+ declare function patchFixSuiObjectId(data: any): void;
638
+ declare const NORMALIZED_SUI_COIN_TYPE: string;
639
+
640
+ declare function addHexPrefix(hex: string): string;
641
+ declare function removeHexPrefix(hex: string): string;
642
+ declare function shortString(str: string, start?: number, end?: number): string;
643
+ declare function shortAddress(address: string, start?: number, end?: number): string;
644
+ declare function checkAddress(address: any, options?: {
645
+ leadingZero: boolean;
646
+ }): boolean;
647
+ /**
648
+ * Attempts to turn a value into a `Buffer`. As input it supports `Buffer`, `String`, `Number`, null/undefined, `BN` and other objects with a `toArray()` method.
649
+ * @param v the value
650
+ */
651
+ declare function toBuffer(v: any): Buffer;
652
+ declare function bufferToHex(buffer: Buffer): string;
653
+ /**
654
+ * '\x02\x00\x00\x00' to 2
655
+ * @param binaryData
656
+ */
657
+ declare function hexToNumber(binaryData: string): number;
658
+ declare function utf8to16(str: string): string;
659
+ declare function hexToString(str: string): string;
660
+
661
+ declare function d(value?: Decimal.Value): Decimal.Instance;
662
+ declare function decimalsMultiplier(decimals?: Decimal.Value): Decimal.Instance;
663
+ declare const fixDown: (value: string | number, decimal: number) => string | number;
664
+ declare const maxDecimal: (value1: Decimal.Value, value2: Decimal.Value) => Decimal.Instance;
665
+
666
+ type AdjustResult = {
667
+ isAdjustCoinA: boolean;
668
+ isAdjustCoinB: boolean;
669
+ };
670
+ type BuildCoinResult = {
671
+ targetCoin: TransactionArgument;
672
+ remainCoins: CoinAsset[];
673
+ isMintZeroCoin: boolean;
674
+ tragetCoinAmount: string;
675
+ originalSplitedCoin?: TransactionArgument;
676
+ };
677
+ type CoinInputInterval = {
678
+ amountSecond: bigint;
679
+ amountFirst: bigint;
680
+ };
681
+ declare function printTransaction(tx: Transaction, isPrint?: boolean): Promise<void>;
682
+ declare class TransactionUtil {
683
+ /**
684
+ * adjust transaction for gas
685
+ * @param sdk
686
+ * @param amount
687
+ * @param tx
688
+ * @returns
689
+ */
690
+ static adjustTransactionForGas(sdk: DeepbookUtilsSDK, allCoins: CoinAsset[], amount: bigint, tx: Transaction): Promise<{
691
+ fixAmount: bigint;
692
+ newTx?: Transaction;
693
+ }>;
694
+ static buildCoinForAmount(tx: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
695
+ private static buildCoin;
696
+ private static buildZeroValueCoin;
697
+ static buildCoinForAmountInterval(tx: Transaction, allCoins: CoinAsset[], amounts: CoinInputInterval, coinType: string, buildVector?: boolean): BuildCoinResult;
698
+ static callMintZeroValueCoin: (txb: Transaction, coinType: string) => _mysten_sui_transactions.TransactionResult;
699
+ static buildCoinTypePair(coinTypes: string[], partitionQuantities: number[]): string[][];
700
+ }
701
+
702
+ declare function getSuiObjectData(resp: SuiObjectResponse): SuiObjectData | null | undefined;
703
+ declare function getObjectDeletedResponse(resp: SuiObjectResponse): SuiObjectRef | undefined;
704
+ declare function getObjectNotExistsResponse(resp: SuiObjectResponse): string | undefined;
705
+ declare function getObjectReference(resp: SuiObjectResponse | OwnedObjectRef): SuiObjectRef | undefined;
706
+ declare function getObjectId(data: SuiObjectResponse | SuiObjectRef | OwnedObjectRef): string;
707
+ declare function getObjectVersion(data: SuiObjectResponse | SuiObjectRef | SuiObjectData): string | number | undefined;
708
+ declare function isSuiObjectResponse(resp: SuiObjectResponse | SuiObjectData): resp is SuiObjectResponse;
709
+ declare function getMovePackageContent(data: SuiObjectResponse): any | undefined;
710
+ declare function getMoveObject(data: SuiObjectResponse | SuiObjectData): SuiMoveObject | undefined;
711
+ declare function getMoveObjectType(resp: SuiObjectResponse): string | undefined;
712
+ /**
713
+ * Deriving the object type from the object response
714
+ * @returns 'package' if the object is a package, move object type(e.g., 0x2::coin::Coin<0x2::sui::SUI>)
715
+ * if the object is a move object
716
+ */
717
+ declare function getObjectType(resp: SuiObjectResponse | SuiObjectData): string | null | undefined;
718
+ declare function getObjectPreviousTransactionDigest(resp: SuiObjectResponse): string | null | undefined;
719
+ declare function getObjectOwner(resp: SuiObjectResponse): ObjectOwner | null | undefined;
720
+ declare function getObjectDisplay(resp: SuiObjectResponse): DisplayFieldsResponse;
721
+ declare function getObjectFields(resp: SuiObjectResponse | SuiObjectData): any | undefined;
722
+ interface SuiObjectDataWithContent extends SuiObjectData {
723
+ content: SuiParsedData;
724
+ }
725
+ declare function hasPublicTransfer(data: SuiObjectResponse | SuiObjectData): boolean;
726
+
727
+ /**
728
+ * Converts an amount to a decimal value, based on the number of decimals specified.
729
+ * @param {number | string} amount - The amount to convert to decimal.
730
+ * @param {number | string} decimals - The number of decimals to use in the conversion.
731
+ * @returns {number} - Returns the converted amount as a number.
732
+ */
733
+ declare function toDecimalsAmount(amount: number | string, decimals: number | string): number;
734
+ /**
735
+ * Converts a bigint to an unsigned integer of the specified number of bits.
736
+ * @param {bigint} int - The bigint to convert.
737
+ * @param {number} bits - The number of bits to use in the conversion. Defaults to 32 bits.
738
+ * @returns {string} - Returns the converted unsigned integer as a string.
739
+ */
740
+ declare function asUintN(int: bigint, bits?: number): string;
741
+ /**
742
+ * Converts a bigint to a signed integer of the specified number of bits.
743
+ * @param {bigint} int - The bigint to convert.
744
+ * @param {number} bits - The number of bits to use in the conversion. Defaults to 32 bits.
745
+ * @returns {number} - Returns the converted signed integer as a number.
746
+ */
747
+ declare function asIntN(int: bigint, bits?: number): number;
748
+ /**
749
+ * Converts an amount in decimals to its corresponding numerical value.
750
+ * @param {number|string} amount - The amount to convert.
751
+ * @param {number|string} decimals - The number of decimal places used in the amount.
752
+ * @returns {number} - Returns the converted numerical value.
753
+ */
754
+ declare function fromDecimalsAmount(amount: number | string, decimals: number | string): number;
755
+ /**
756
+ * Converts a secret key in string or Uint8Array format to an Ed25519 key pair.
757
+ * @param {string|Uint8Array} secretKey - The secret key to convert.
758
+ * @param {string} ecode - The encoding of the secret key ('hex' or 'base64'). Defaults to 'hex'.
759
+ * @returns {Ed25519Keypair} - Returns the Ed25519 key pair.
760
+ */
761
+ declare function secretKeyToEd25519Keypair(secretKey: string | Uint8Array, ecode?: 'hex' | 'base64'): Ed25519Keypair;
762
+ /**
763
+ * Converts a secret key in string or Uint8Array format to a Secp256k1 key pair.
764
+ * @param {string|Uint8Array} secretKey - The secret key to convert.
765
+ * @param {string} ecode - The encoding of the secret key ('hex' or 'base64'). Defaults to 'hex'.
766
+ * @returns {Ed25519Keypair} - Returns the Secp256k1 key pair.
767
+ */
768
+ declare function secretKeyToSecp256k1Keypair(secretKey: string | Uint8Array, ecode?: 'hex' | 'base64'): Secp256k1Keypair;
769
+
770
+ declare const DEFAULT_GAS_BUDGET_FOR_SPLIT = 1000;
771
+ declare const DEFAULT_GAS_BUDGET_FOR_MERGE = 500;
772
+ declare const DEFAULT_GAS_BUDGET_FOR_TRANSFER = 100;
773
+ declare const DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI = 100;
774
+ declare const DEFAULT_GAS_BUDGET_FOR_STAKE = 1000;
775
+ declare const GAS_TYPE_ARG = "0x2::sui::SUI";
776
+ declare const GAS_TYPE_ARG_LONG = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
777
+ declare const GAS_SYMBOL = "SUI";
778
+ declare const DEFAULT_NFT_TRANSFER_GAS_FEE = 450;
779
+ declare const SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000005";
780
+ /**
781
+ * This class provides helper methods for working with coins.
782
+ */
783
+ declare class CoinAssist {
784
+ /**
785
+ * Get the coin type argument from a SuiMoveObject.
786
+ *
787
+ * @param obj The SuiMoveObject to get the coin type argument from.
788
+ * @returns The coin type argument, or null if it is not found.
789
+ */
790
+ static getCoinTypeArg(obj: SuiMoveObject): string | null;
791
+ /**
792
+ * Get whether a SuiMoveObject is a SUI coin.
793
+ *
794
+ * @param obj The SuiMoveObject to check.
795
+ * @returns Whether the SuiMoveObject is a SUI coin.
796
+ */
797
+ static isSUI(obj: SuiMoveObject): boolean;
798
+ /**
799
+ * Get the coin symbol from a coin type argument.
800
+ *
801
+ * @param coinTypeArg The coin type argument to get the symbol from.
802
+ * @returns The coin symbol.
803
+ */
804
+ static getCoinSymbol(coinTypeArg: string): string;
805
+ /**
806
+ * Get the balance of a SuiMoveObject.
807
+ *
808
+ * @param obj The SuiMoveObject to get the balance from.
809
+ * @returns The balance of the SuiMoveObject.
810
+ */
811
+ static getBalance(obj: SuiMoveObject): bigint;
812
+ /**
813
+ * Get the total balance of a list of CoinAsset objects for a given coin address.
814
+ *
815
+ * @param objs The list of CoinAsset objects to get the total balance for.
816
+ * @param coinAddress The coin address to get the total balance for.
817
+ * @returns The total balance of the CoinAsset objects for the given coin address.
818
+ */
819
+ static totalBalance(objs: CoinAsset[], coinAddress: SuiAddressType): bigint;
820
+ /**
821
+ * Get the ID of a SuiMoveObject.
822
+ *
823
+ * @param obj The SuiMoveObject to get the ID from.
824
+ * @returns The ID of the SuiMoveObject.
825
+ */
826
+ static getID(obj: SuiMoveObject): string;
827
+ /**
828
+ * Get the coin type from a coin type argument.
829
+ *
830
+ * @param coinTypeArg The coin type argument to get the coin type from.
831
+ * @returns The coin type.
832
+ */
833
+ static getCoinTypeFromArg(coinTypeArg: string): string;
834
+ /**
835
+ * Get the FaucetCoin objects from a SuiTransactionBlockResponse.
836
+ *
837
+ * @param suiTransactionResponse The SuiTransactionBlockResponse to get the FaucetCoin objects from.
838
+ * @returns The FaucetCoin objects.
839
+ */
840
+ /**
841
+ * Get the CoinAsset objects for a given coin type.
842
+ *
843
+ * @param coinType The coin type to get the CoinAsset objects for.
844
+ * @param allSuiObjects The list of all SuiMoveObjects.
845
+ * @returns The CoinAsset objects for the given coin type.
846
+ */
847
+ static getCoinAssets(coinType: string, allSuiObjects: CoinAsset[]): CoinAsset[];
848
+ /**
849
+ * Get whether a coin address is a SUI coin.
850
+ *
851
+ * @param coinAddress The coin address to check.
852
+ * @returns Whether the coin address is a SUI coin.
853
+ */
854
+ static isSuiCoin(coinAddress: SuiAddressType): boolean;
855
+ /**
856
+ * Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
857
+ *
858
+ * @param coins The list of CoinAsset objects to select from.
859
+ * @param amount The amount to select CoinAsset objects with a balance greater than or equal to.
860
+ * @param exclude A list of CoinAsset objects to exclude from the selection.
861
+ * @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
862
+ */
863
+ static selectCoinObjectIdGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
864
+ objectArray: string[];
865
+ remainCoins: CoinAsset[];
866
+ amountArray: string[];
867
+ };
868
+ /**
869
+ * Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
870
+ *
871
+ * @param coins The list of CoinAsset objects to select from.
872
+ * @param amount The amount to select CoinAsset objects with a balance greater than or equal to.
873
+ * @param exclude A list of CoinAsset objects to exclude from the selection.
874
+ * @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
875
+ */
876
+ static selectCoinAssetGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
877
+ selectedCoins: CoinAsset[];
878
+ remainingCoins: CoinAsset[];
879
+ };
880
+ /**
881
+ * Sort the CoinAsset objects by their balance.
882
+ *
883
+ * @param coins The CoinAsset objects to sort.
884
+ * @returns The sorted CoinAsset objects.
885
+ */
886
+ static sortByBalance(coins: CoinAsset[]): CoinAsset[];
887
+ static sortByBalanceDes(coins: CoinAsset[]): CoinAsset[];
888
+ /**
889
+ * Calculate the total balance of a list of CoinAsset objects.
890
+ *
891
+ * @param coins The list of CoinAsset objects to calculate the total balance for.
892
+ * @returns The total balance of the CoinAsset objects.
893
+ */
894
+ static calculateTotalBalance(coins: CoinAsset[]): bigint;
895
+ }
896
+
897
+ export { AdjustResult, Balances, BigNumber, BuildCoinResult, CLOCK_ADDRESS, CachedContent, DeepbookUtilsSDK as CetusClmmSDK, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinStoreAddress, DEEP_SCALAR, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookUtilsModule, FLOAT_SCALAR, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, NFT, NORMALIZED_SUI_COIN_TYPE, OrderDeepPrice, OrderFee, Package, PageQuery, PaginationArgs, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, StateAccount, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, TransactionUtil, addHexPrefix, asIntN, asUintN, bufferToHex, cacheTime24h, cacheTime5min, checkAddress, composeType, d, decimalsMultiplier, DeepbookUtilsSDK as default, extractAddressFromType, extractStructTagFromType, fixCoinType, fixDown, fixSuiObjectId, fromDecimalsAmount, getDefaultSuiInputType, getFutureTime, getMoveObject, getMoveObjectType, getMovePackageContent, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getSuiObjectData, hasPublicTransfer, hexToNumber, hexToString, isSortedSymbols, isSuiObjectResponse, maxDecimal, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, toBuffer, toDecimalsAmount, utf8to16 };