@cetusprotocol/deepbook-utils 0.0.0-experimental-20251225165838
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.
- package/.editorconfig +15 -0
- package/.env +1 -0
- package/CHANGELOG.md +86 -0
- package/LICENSE +201 -0
- package/README.md +202 -0
- package/biome.json +96 -0
- package/dist/index.d.ts +1353 -0
- package/dist/index.js +15 -0
- package/dist/index.mjs +15 -0
- package/jest.config.js +15 -0
- package/package.json +88 -0
- package/tsconfig.tsbuildinfo +2 -0
- package/tsup.config.js +22 -0
- package/version.mjs +28 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1353 @@
|
|
|
1
|
+
import { SuiTransactionBlockResponse, SuiClient, SuiEventFilter, SuiObjectResponseQuery, SuiObjectDataOptions, CoinBalance, SuiObjectResponse, SuiObjectData, SuiObjectRef, OwnedObjectRef, SuiMoveObject, ObjectOwner, DisplayFieldsResponse, SuiParsedData } from '@mysten/sui/client';
|
|
2
|
+
import { SuiGraphQLClient } from '@mysten/sui/graphql';
|
|
3
|
+
import * as _mysten_sui_transactions from '@mysten/sui/transactions';
|
|
4
|
+
import { TransactionArgument, Transaction } from '@mysten/sui/transactions';
|
|
5
|
+
import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
|
|
6
|
+
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
7
|
+
import { Secp256k1Keypair } from '@mysten/sui/keypairs/secp256k1';
|
|
8
|
+
import Decimal from 'decimal.js';
|
|
9
|
+
|
|
10
|
+
interface IModule {
|
|
11
|
+
readonly sdk: DeepbookUtilsSDK;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents a SUI address, which is a string.
|
|
16
|
+
*/
|
|
17
|
+
type SuiAddressType = string;
|
|
18
|
+
/**
|
|
19
|
+
* Represents a SUI object identifier, which is a string.
|
|
20
|
+
*/
|
|
21
|
+
type SuiObjectIdType = string;
|
|
22
|
+
/**
|
|
23
|
+
* The address representing the clock in the system.
|
|
24
|
+
*/
|
|
25
|
+
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
26
|
+
/**
|
|
27
|
+
* Constants for different modules in the CLMM (Cryptocurrency Liquidity Mining Module).
|
|
28
|
+
*/
|
|
29
|
+
declare const ClmmIntegratePoolModule = "pool_script";
|
|
30
|
+
declare const ClmmIntegratePoolV2Module = "pool_script_v2";
|
|
31
|
+
declare const ClmmIntegrateRouterModule = "router";
|
|
32
|
+
declare const ClmmIntegrateRouterWithPartnerModule = "router_with_partner";
|
|
33
|
+
declare const ClmmFetcherModule = "fetcher_script";
|
|
34
|
+
declare const ClmmExpectSwapModule = "expect_swap";
|
|
35
|
+
declare const ClmmIntegrateUtilsModule = "utils";
|
|
36
|
+
/**
|
|
37
|
+
* The address for CoinInfo module.
|
|
38
|
+
*/
|
|
39
|
+
declare const CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
40
|
+
/**
|
|
41
|
+
* The address for CoinStore module.
|
|
42
|
+
*/
|
|
43
|
+
declare const CoinStoreAddress = "0x1::coin::CoinStore";
|
|
44
|
+
/**
|
|
45
|
+
* Constants for different modules in the Deepbook system.
|
|
46
|
+
*/
|
|
47
|
+
declare const DeepbookCustodianV2Moudle = "custodian_v2";
|
|
48
|
+
declare const DeepbookClobV2Moudle = "clob_v2";
|
|
49
|
+
declare const DeepbookEndpointsV2Moudle = "endpoints_v2";
|
|
50
|
+
/**
|
|
51
|
+
* Represents a SUI resource, which can be of any type.
|
|
52
|
+
*/
|
|
53
|
+
type SuiResource = any;
|
|
54
|
+
/**
|
|
55
|
+
* Represents a paginated data page with optional cursor and limit.
|
|
56
|
+
*/
|
|
57
|
+
type DataPage<T> = {
|
|
58
|
+
data: T[];
|
|
59
|
+
nextCursor?: any;
|
|
60
|
+
hasNextPage: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Represents query parameters for pagination.
|
|
64
|
+
*/
|
|
65
|
+
type PageQuery = {
|
|
66
|
+
cursor?: any;
|
|
67
|
+
limit?: number | null;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Represents arguments for pagination, with options for fetching all data or using PageQuery.
|
|
71
|
+
*/
|
|
72
|
+
type PaginationArgs = 'all' | PageQuery;
|
|
73
|
+
/**
|
|
74
|
+
* Represents a Non-Fungible Token (NFT) with associated metadata.
|
|
75
|
+
*/
|
|
76
|
+
type NFT = {
|
|
77
|
+
/**
|
|
78
|
+
* The address or identifier of the creator of the NFT.
|
|
79
|
+
*/
|
|
80
|
+
creator: string;
|
|
81
|
+
/**
|
|
82
|
+
* A description providing additional information about the NFT.
|
|
83
|
+
*/
|
|
84
|
+
description: string;
|
|
85
|
+
/**
|
|
86
|
+
* The URL to the image representing the NFT visually.
|
|
87
|
+
*/
|
|
88
|
+
image_url: string;
|
|
89
|
+
/**
|
|
90
|
+
* A link associated with the NFT, providing more details or interactions.
|
|
91
|
+
*/
|
|
92
|
+
link: string;
|
|
93
|
+
/**
|
|
94
|
+
* The name or title of the NFT.
|
|
95
|
+
*/
|
|
96
|
+
name: string;
|
|
97
|
+
/**
|
|
98
|
+
* The URL to the project or collection associated with the NFT.
|
|
99
|
+
*/
|
|
100
|
+
project_url: string;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Represents a SUI struct tag.
|
|
104
|
+
*/
|
|
105
|
+
type SuiStructTag = {
|
|
106
|
+
/**
|
|
107
|
+
* The full address of the struct.
|
|
108
|
+
*/
|
|
109
|
+
full_address: string;
|
|
110
|
+
/**
|
|
111
|
+
* The source address of the struct.
|
|
112
|
+
*/
|
|
113
|
+
source_address: string;
|
|
114
|
+
/**
|
|
115
|
+
* The address of the struct.
|
|
116
|
+
*/
|
|
117
|
+
address: SuiAddressType;
|
|
118
|
+
/**
|
|
119
|
+
* The module to which the struct belongs.
|
|
120
|
+
*/
|
|
121
|
+
module: string;
|
|
122
|
+
/**
|
|
123
|
+
* The name of the struct.
|
|
124
|
+
*/
|
|
125
|
+
name: string;
|
|
126
|
+
/**
|
|
127
|
+
* An array of type arguments (SUI addresses) for the struct.
|
|
128
|
+
*/
|
|
129
|
+
type_arguments: SuiAddressType[];
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Represents basic SUI data types.
|
|
133
|
+
*/
|
|
134
|
+
type SuiBasicTypes = 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256';
|
|
135
|
+
/**
|
|
136
|
+
* Represents a SUI transaction argument, which can be of various types.
|
|
137
|
+
*/
|
|
138
|
+
type SuiTxArg = TransactionArgument | string | number | bigint | boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Represents input types for SUI data.
|
|
141
|
+
*/
|
|
142
|
+
type SuiInputTypes = 'object' | SuiBasicTypes;
|
|
143
|
+
/**
|
|
144
|
+
* Gets the default SUI input type based on the provided value.
|
|
145
|
+
* @param value - The value to determine the default input type for.
|
|
146
|
+
* @returns The default SUI input type.
|
|
147
|
+
* @throws Error if the type of the value is unknown.
|
|
148
|
+
*/
|
|
149
|
+
declare const getDefaultSuiInputType: (value: any) => SuiInputTypes;
|
|
150
|
+
/**
|
|
151
|
+
* Represents a coin asset with address, object ID, and balance information.
|
|
152
|
+
*/
|
|
153
|
+
type CoinAsset = {
|
|
154
|
+
/**
|
|
155
|
+
* The address type of the coin asset.
|
|
156
|
+
*/
|
|
157
|
+
coinAddress: SuiAddressType;
|
|
158
|
+
/**
|
|
159
|
+
* The object identifier of the coin asset.
|
|
160
|
+
*/
|
|
161
|
+
coinObjectId: SuiObjectIdType;
|
|
162
|
+
/**
|
|
163
|
+
* The balance amount of the coin asset.
|
|
164
|
+
*/
|
|
165
|
+
balance: bigint;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Represents configuration data for a cryptocurrency coin.
|
|
170
|
+
*/
|
|
171
|
+
type CoinConfig = {
|
|
172
|
+
/**
|
|
173
|
+
* The unique identifier of the coin.
|
|
174
|
+
*/
|
|
175
|
+
id: string;
|
|
176
|
+
/**
|
|
177
|
+
* The name of the coin.
|
|
178
|
+
*/
|
|
179
|
+
name: string;
|
|
180
|
+
/**
|
|
181
|
+
* The symbol of the coin.
|
|
182
|
+
*/
|
|
183
|
+
symbol: string;
|
|
184
|
+
/**
|
|
185
|
+
* The address associated with the coin.
|
|
186
|
+
*/
|
|
187
|
+
address: string;
|
|
188
|
+
/**
|
|
189
|
+
* The Pyth identifier of the coin.
|
|
190
|
+
*/
|
|
191
|
+
pyth_id: string;
|
|
192
|
+
/**
|
|
193
|
+
* The project URL related to the coin.
|
|
194
|
+
*/
|
|
195
|
+
project_url: string;
|
|
196
|
+
/**
|
|
197
|
+
* The URL to the logo image of the coin.
|
|
198
|
+
*/
|
|
199
|
+
logo_url: string;
|
|
200
|
+
/**
|
|
201
|
+
* The number of decimal places used for the coin.
|
|
202
|
+
*/
|
|
203
|
+
decimals: number;
|
|
204
|
+
} & Record<string, any>;
|
|
205
|
+
/**
|
|
206
|
+
* Represents a package containing specific configuration or data.
|
|
207
|
+
* @template T - The type of configuration or data contained in the package.
|
|
208
|
+
*/
|
|
209
|
+
type Package<T = undefined> = {
|
|
210
|
+
/**
|
|
211
|
+
* The unique identifier of the package.
|
|
212
|
+
*/
|
|
213
|
+
package_id: string;
|
|
214
|
+
/**
|
|
215
|
+
* the package was published.
|
|
216
|
+
*/
|
|
217
|
+
published_at: string;
|
|
218
|
+
/**
|
|
219
|
+
* The version number of the package (optional).
|
|
220
|
+
*/
|
|
221
|
+
version?: number;
|
|
222
|
+
/**
|
|
223
|
+
* The configuration or data contained in the package (optional).
|
|
224
|
+
*/
|
|
225
|
+
config?: T;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
type OrderFee = {
|
|
229
|
+
takerFee: string;
|
|
230
|
+
makerFee: string;
|
|
231
|
+
feeType: string;
|
|
232
|
+
takerFeeDisplay: string;
|
|
233
|
+
makerFeeDisplay: string;
|
|
234
|
+
};
|
|
235
|
+
type OrderDeepPrice = {
|
|
236
|
+
asset_is_base: boolean;
|
|
237
|
+
deep_per_asset: number;
|
|
238
|
+
};
|
|
239
|
+
declare enum OrderType {
|
|
240
|
+
NO_RESTRICTION = 0,
|
|
241
|
+
IMMEDIATE_OR_CANCEL = 1,
|
|
242
|
+
FILL_OR_KILL = 2,
|
|
243
|
+
POST_ONLY = 3
|
|
244
|
+
}
|
|
245
|
+
type Token = {
|
|
246
|
+
coinType: string;
|
|
247
|
+
decimals: number;
|
|
248
|
+
};
|
|
249
|
+
type PoolInfo = {
|
|
250
|
+
address: string;
|
|
251
|
+
baseCoin: Token;
|
|
252
|
+
quoteCoin: Token;
|
|
253
|
+
[key: string]: any;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
type MarginCoinInfo = {
|
|
257
|
+
coinType: string;
|
|
258
|
+
feed?: string;
|
|
259
|
+
decimals?: number;
|
|
260
|
+
scalar?: number;
|
|
261
|
+
priceInfoObjectId?: string;
|
|
262
|
+
};
|
|
263
|
+
type MarginPoolInfo = {
|
|
264
|
+
id: string;
|
|
265
|
+
baseCoin: MarginCoinInfo;
|
|
266
|
+
quoteCoin: MarginCoinInfo;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
type BigNumber = Decimal.Value | number | string;
|
|
270
|
+
|
|
271
|
+
type CoinItem = {
|
|
272
|
+
coinType: string;
|
|
273
|
+
decimals: number;
|
|
274
|
+
};
|
|
275
|
+
type DeepCoin = {
|
|
276
|
+
coinType: string;
|
|
277
|
+
decimals: number;
|
|
278
|
+
};
|
|
279
|
+
type StateAccount = {
|
|
280
|
+
balance_manager_id: string;
|
|
281
|
+
open_orders: string[];
|
|
282
|
+
owed_balances: Balances;
|
|
283
|
+
settled_balances: Balances;
|
|
284
|
+
unclaimed_rebates: Balances;
|
|
285
|
+
taker_volume: string;
|
|
286
|
+
poolInfo: any;
|
|
287
|
+
};
|
|
288
|
+
type Balances = {
|
|
289
|
+
base: string;
|
|
290
|
+
quote: string;
|
|
291
|
+
deep: string;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Provides a high-level interface around deepbook utilities, handling
|
|
295
|
+
* transaction preparation, caching, and common workflows for interacting with
|
|
296
|
+
* DeepBook pools.
|
|
297
|
+
*/
|
|
298
|
+
declare class DeepbookUtilsModule implements IModule {
|
|
299
|
+
protected _sdk: DeepbookUtilsSDK;
|
|
300
|
+
protected _deep: DeepCoin;
|
|
301
|
+
private readonly _cache;
|
|
302
|
+
constructor(sdk: DeepbookUtilsSDK);
|
|
303
|
+
get sdk(): DeepbookUtilsSDK;
|
|
304
|
+
get deepCoin(): DeepCoin;
|
|
305
|
+
/**
|
|
306
|
+
* Creates a balance manager and shares it with the caller account.
|
|
307
|
+
*/
|
|
308
|
+
createAndShareBalanceManager(): Transaction;
|
|
309
|
+
/**
|
|
310
|
+
* Creates a new balance manager and deposits the specified coin amount into it.
|
|
311
|
+
*/
|
|
312
|
+
createAndDepsit({ account, coin, amountToDeposit }: {
|
|
313
|
+
account: string;
|
|
314
|
+
coin: CoinItem;
|
|
315
|
+
amountToDeposit: string;
|
|
316
|
+
}): Transaction;
|
|
317
|
+
/**
|
|
318
|
+
* Deposits assets into an existing balance manager, creating a transaction if
|
|
319
|
+
* one is not provided.
|
|
320
|
+
*/
|
|
321
|
+
depositIntoManager({ account, balanceManager, coin, amountToDeposit, tx, }: {
|
|
322
|
+
account: string;
|
|
323
|
+
balanceManager: string;
|
|
324
|
+
coin: CoinItem;
|
|
325
|
+
amountToDeposit: string;
|
|
326
|
+
tx?: Transaction;
|
|
327
|
+
}): Transaction | null;
|
|
328
|
+
/**
|
|
329
|
+
* Withdraws assets from a balance manager. Optionally returns the withdrawn
|
|
330
|
+
* asset objects instead of transferring them immediately.
|
|
331
|
+
*/
|
|
332
|
+
withdrawFromManager({ account, balanceManager, coin, amountToWithdraw, returnAssets, txb, }: {
|
|
333
|
+
account: string;
|
|
334
|
+
balanceManager: string;
|
|
335
|
+
coin: CoinItem;
|
|
336
|
+
amountToWithdraw: string;
|
|
337
|
+
returnAssets?: boolean;
|
|
338
|
+
txb?: Transaction;
|
|
339
|
+
}): Transaction | _mysten_sui_transactions.TransactionResult;
|
|
340
|
+
/**
|
|
341
|
+
* Withdraws free balances from multiple managers into the owner account.
|
|
342
|
+
*/
|
|
343
|
+
withdrawManagersFreeBalance({ account, balanceManagers, tx, }: {
|
|
344
|
+
account: string;
|
|
345
|
+
balanceManagers: Record<string, {
|
|
346
|
+
coinType: string;
|
|
347
|
+
amount: string;
|
|
348
|
+
}[]>;
|
|
349
|
+
tx?: Transaction;
|
|
350
|
+
}): Transaction;
|
|
351
|
+
/**
|
|
352
|
+
* Retrieves balance managers for an account, optionally using the cached
|
|
353
|
+
* result when it is still valid.
|
|
354
|
+
*/
|
|
355
|
+
getBalanceManager(account: string, forceRefresh?: boolean): Promise<any>;
|
|
356
|
+
withdrawSettledAmounts({ poolInfo, balanceManager }: {
|
|
357
|
+
poolInfo: any;
|
|
358
|
+
balanceManager: string;
|
|
359
|
+
}): Transaction;
|
|
360
|
+
/**
|
|
361
|
+
* Retrieves balances for the provided coins tracked by a specific balance
|
|
362
|
+
* manager.
|
|
363
|
+
*/
|
|
364
|
+
getManagerBalance({ account, balanceManager, coins }: {
|
|
365
|
+
account: string;
|
|
366
|
+
balanceManager: string;
|
|
367
|
+
coins: CoinItem[];
|
|
368
|
+
}): Promise<any>;
|
|
369
|
+
/**
|
|
370
|
+
* Retrieves balances for all balance managers owned by the account.
|
|
371
|
+
*/
|
|
372
|
+
getAccountAllManagerBalance({ account, coins }: {
|
|
373
|
+
account: string;
|
|
374
|
+
coins: CoinItem[];
|
|
375
|
+
}): Promise<any>;
|
|
376
|
+
/**
|
|
377
|
+
* Retrieves the mid-market price for a pool via dev-inspect.
|
|
378
|
+
*/
|
|
379
|
+
getMarketPrice(poolInfo: any): Promise<string>;
|
|
380
|
+
/**
|
|
381
|
+
* Queries on-chain events to retrieve known pools.
|
|
382
|
+
*/
|
|
383
|
+
getPools(): Promise<any>;
|
|
384
|
+
/**
|
|
385
|
+
* Estimates quote quantity output for a given base amount.
|
|
386
|
+
*/
|
|
387
|
+
getQuoteQuantityOut(poolInfo: any, baseQuantity: string, account: string): Promise<{
|
|
388
|
+
baseQuantityDisplay: string;
|
|
389
|
+
baseOutDisplay: string;
|
|
390
|
+
quoteOutDisplay: string;
|
|
391
|
+
deepRequiredDisplay: string;
|
|
392
|
+
baseQuantity: string;
|
|
393
|
+
baseOut: string;
|
|
394
|
+
quoteOut: string;
|
|
395
|
+
deepRequired: string;
|
|
396
|
+
}>;
|
|
397
|
+
/**
|
|
398
|
+
* Estimates base quantity output for a provided quote amount.
|
|
399
|
+
*/
|
|
400
|
+
getBaseQuantityOut(poolInfo: any, quoteQuantity: string, account: string): Promise<{
|
|
401
|
+
quoteQuantityDisplay: string;
|
|
402
|
+
baseOutDisplay: string;
|
|
403
|
+
quoteOutDisplay: string;
|
|
404
|
+
deepRequiredDisplay: string;
|
|
405
|
+
quoteQuantity: string;
|
|
406
|
+
baseOut: string;
|
|
407
|
+
quoteOut: string;
|
|
408
|
+
deepRequired: string;
|
|
409
|
+
}>;
|
|
410
|
+
/**
|
|
411
|
+
* Estimates both base and quote outputs given respective input amounts.
|
|
412
|
+
*/
|
|
413
|
+
getQuantityOut(poolInfo: any, baseQuantity: string, quoteQuantity: string, account: string): Promise<{
|
|
414
|
+
baseQuantityDisplay: string;
|
|
415
|
+
quoteQuantityDisplay: string;
|
|
416
|
+
baseOutDisplay: string;
|
|
417
|
+
quoteOutDisplay: string;
|
|
418
|
+
deepRequiredDisplay: string;
|
|
419
|
+
baseQuantity: string;
|
|
420
|
+
quoteQuantity: string;
|
|
421
|
+
baseOut: number;
|
|
422
|
+
quoteOut: number;
|
|
423
|
+
deepRequired: number;
|
|
424
|
+
}>;
|
|
425
|
+
/**
|
|
426
|
+
* Estimates taker and maker fees for a prospective trade.
|
|
427
|
+
*/
|
|
428
|
+
estimatedMaxFee(poolInfo: any, quantity: string, priceInput: string, payWithDeep: boolean, isBid: boolean, isLimit: boolean, priceOrigin?: string): Promise<OrderFee>;
|
|
429
|
+
/**
|
|
430
|
+
* Retrieves the deep price information required for fee calculation.
|
|
431
|
+
*/
|
|
432
|
+
getOrderDeepPrice(poolInfo: any): Promise<OrderDeepPrice | null>;
|
|
433
|
+
/**
|
|
434
|
+
* Parses a serialized `OrderDeepPrice` struct from Move into a JS object.
|
|
435
|
+
*/
|
|
436
|
+
parseOrderDeepPrice(bytes: Uint8Array): OrderDeepPrice;
|
|
437
|
+
/**
|
|
438
|
+
* Builds coin assets for the requested amount, sourcing from the owner's coins.
|
|
439
|
+
*/
|
|
440
|
+
getCoinAssets(coin: string, amount: string, allCoinAsset: any, txb: any): TransactionArgument;
|
|
441
|
+
/**
|
|
442
|
+
* Retrieves balances related to an upcoming transaction to determine deposit needs.
|
|
443
|
+
*/
|
|
444
|
+
getTransactionRelatedBalance(poolInfo: any, baseAmount: string, quoteAmount: string, noDeep: boolean, account: string, payWithDeep: boolean, balanceManager: string): Promise<{
|
|
445
|
+
baseManagerBlance: any;
|
|
446
|
+
quoteManagerBlance: any;
|
|
447
|
+
feeManaerBalance: any;
|
|
448
|
+
}>;
|
|
449
|
+
/**
|
|
450
|
+
* Determines the fee asset to use and whether additional deposits are required.
|
|
451
|
+
*/
|
|
452
|
+
getFeeAsset(maxFee: string, feeCoin: string, baseAmount: string, quoteAmount: string, feeManaerBalance: string, quoteIsDeep: boolean, baseIsDeep: boolean, allCoinAsset: any, payWithDeep: boolean, txb: Transaction): {
|
|
453
|
+
feeAsset: any;
|
|
454
|
+
haveDepositFee: string;
|
|
455
|
+
};
|
|
456
|
+
/**
|
|
457
|
+
* Prepares the assets necessary to execute a limit order transaction.
|
|
458
|
+
*/
|
|
459
|
+
getTransactionRelatedAssets(poolInfo: any, baseAmount: string, quoteAmount: string, maxFee: string, isBid: boolean, account: string, payWithDeep: boolean, balanceManager: string, txb: Transaction): Promise<{
|
|
460
|
+
baseAsset: any;
|
|
461
|
+
quoteAsset: any;
|
|
462
|
+
feeAsset: {
|
|
463
|
+
feeAsset: any;
|
|
464
|
+
haveDepositFee: string;
|
|
465
|
+
};
|
|
466
|
+
haveDeposit: boolean;
|
|
467
|
+
}>;
|
|
468
|
+
/**
|
|
469
|
+
* Prepares assets necessary to execute a market order transaction.
|
|
470
|
+
*/
|
|
471
|
+
getMarketTransactionRelatedAssets(poolInfo: any, baseAmount: string, quoteAmount: string, maxFee: string, isBid: boolean, account: string, payWithDeep: boolean, balanceManager: string, txb: Transaction): Promise<{
|
|
472
|
+
baseAsset: any;
|
|
473
|
+
quoteAsset: any;
|
|
474
|
+
feeAsset: any;
|
|
475
|
+
}>;
|
|
476
|
+
/**
|
|
477
|
+
* Creates a transaction that deposits required assets and then places a limit order.
|
|
478
|
+
*/
|
|
479
|
+
createDepositThenPlaceLimitOrder({ poolInfo, priceInput, quantity, orderType, isBid, maxFee, account, payWithDeep, expirationTimestamp, }: {
|
|
480
|
+
poolInfo: PoolInfo;
|
|
481
|
+
priceInput: string;
|
|
482
|
+
quantity: string;
|
|
483
|
+
orderType: OrderType;
|
|
484
|
+
isBid: boolean;
|
|
485
|
+
maxFee: string;
|
|
486
|
+
account: string;
|
|
487
|
+
payWithDeep: boolean;
|
|
488
|
+
expirationTimestamp?: number;
|
|
489
|
+
}): Promise<any>;
|
|
490
|
+
getEmptyCoin(txb: any, coin: string): any;
|
|
491
|
+
/**
|
|
492
|
+
* Creates a transaction that deposits necessary assets and places a market order.
|
|
493
|
+
*/
|
|
494
|
+
createDepositThenPlaceMarketOrder({ poolInfo, quantity, isBid, maxFee, account, payWithDeep, slippage, }: {
|
|
495
|
+
poolInfo: any;
|
|
496
|
+
quantity: string;
|
|
497
|
+
isBid: boolean;
|
|
498
|
+
maxFee: string;
|
|
499
|
+
account: string;
|
|
500
|
+
payWithDeep: boolean;
|
|
501
|
+
slippage?: number;
|
|
502
|
+
}): Promise<any>;
|
|
503
|
+
/**
|
|
504
|
+
* Builds a transaction to place a limit order and handles required deposits.
|
|
505
|
+
*/
|
|
506
|
+
placeLimitOrder({ balanceManager, poolInfo, priceInput, quantity, isBid, orderType, maxFee, account, payWithDeep, expirationTimestamp, }: {
|
|
507
|
+
balanceManager: string;
|
|
508
|
+
poolInfo: any;
|
|
509
|
+
priceInput: string;
|
|
510
|
+
quantity: string;
|
|
511
|
+
isBid: boolean;
|
|
512
|
+
orderType: OrderType;
|
|
513
|
+
maxFee: string;
|
|
514
|
+
account: string;
|
|
515
|
+
payWithDeep: boolean;
|
|
516
|
+
expirationTimestamp?: number;
|
|
517
|
+
}): Promise<Transaction>;
|
|
518
|
+
/**
|
|
519
|
+
* Builds a transaction to modify an existing order quantity.
|
|
520
|
+
*/
|
|
521
|
+
modifyOrder({ balanceManager, poolInfo, orderId, newOrderQuantity, }: {
|
|
522
|
+
balanceManager: string;
|
|
523
|
+
poolInfo: PoolInfo;
|
|
524
|
+
orderId: string;
|
|
525
|
+
newOrderQuantity: string;
|
|
526
|
+
}): Transaction;
|
|
527
|
+
getBestAskprice(poolInfo: any): Promise<any>;
|
|
528
|
+
getBestBidprice(poolInfo: any): Promise<any>;
|
|
529
|
+
getBestAskOrBidPrice(poolInfo: any, isBid: boolean): Promise<any>;
|
|
530
|
+
/**
|
|
531
|
+
* Builds a transaction to place a market order, handling deposits as needed.
|
|
532
|
+
*/
|
|
533
|
+
placeMarketOrder({ balanceManager, poolInfo, baseQuantity, quoteQuantity, isBid, maxFee, account, payWithDeep, slippage, }: {
|
|
534
|
+
balanceManager: string;
|
|
535
|
+
poolInfo: PoolInfo;
|
|
536
|
+
baseQuantity: string;
|
|
537
|
+
quoteQuantity: string;
|
|
538
|
+
isBid: boolean;
|
|
539
|
+
maxFee: string;
|
|
540
|
+
account: string;
|
|
541
|
+
payWithDeep: boolean;
|
|
542
|
+
slippage?: number;
|
|
543
|
+
}): Promise<any>;
|
|
544
|
+
getOrderInfoList(poolInfo: any, orderIds: string[], account: string): Promise<any>;
|
|
545
|
+
decodeOrderId(encodedOrderId: bigint): {
|
|
546
|
+
isBid: boolean;
|
|
547
|
+
price: bigint;
|
|
548
|
+
orderId: bigint;
|
|
549
|
+
};
|
|
550
|
+
getOpenOrder(poolInfo: any, account: string, balanceManager: string, orders?: string[]): Promise<any>;
|
|
551
|
+
cancelOrders(orderList: any, balanceManager: string): Transaction;
|
|
552
|
+
getDeepbookOrderBook(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean, account: string, balanceManager: string): Promise<void>;
|
|
553
|
+
/**
|
|
554
|
+
* Processes raw level 2 order book data returned from dev-inspect into
|
|
555
|
+
* aggregated price levels.
|
|
556
|
+
*/
|
|
557
|
+
processOrderBookData(data: any, baseCoin: any, quoteCoin: any, unit: number): unknown[];
|
|
558
|
+
getLevel2RangeTx(poolInfo: any, isBid: boolean, priceLow: string | number, priceHigh: string | number, tx?: Transaction): Transaction;
|
|
559
|
+
/**
|
|
560
|
+
* Fetches order book data for the specified price range and order side.
|
|
561
|
+
*/
|
|
562
|
+
fetchOrderBook(poolInfo: any, orderType: 'bid' | 'ask' | 'all', midPrice: string, low: number, high: number, unit: number): Promise<{
|
|
563
|
+
bid: any;
|
|
564
|
+
ask: any;
|
|
565
|
+
}>;
|
|
566
|
+
/**
|
|
567
|
+
* Retrieves the order book for the pool, performing additional requests if needed.
|
|
568
|
+
*/
|
|
569
|
+
getOrderBook(poolInfo: any, orderType: 'bid' | 'ask' | 'all', unit: number): Promise<any>;
|
|
570
|
+
/**
|
|
571
|
+
* Retrieves the raw order book without post-processing, primarily for debugging.
|
|
572
|
+
*/
|
|
573
|
+
getOrderBookOrigin(poolInfo: any, orderType: 'bid' | 'ask' | 'all'): Promise<{
|
|
574
|
+
bid: any;
|
|
575
|
+
ask: any;
|
|
576
|
+
bids?: undefined;
|
|
577
|
+
asks?: undefined;
|
|
578
|
+
} | {
|
|
579
|
+
bids: never[];
|
|
580
|
+
asks: never[];
|
|
581
|
+
bid?: undefined;
|
|
582
|
+
ask?: undefined;
|
|
583
|
+
}>;
|
|
584
|
+
getWalletBalance(account: string): Promise<{
|
|
585
|
+
[k: string]: any;
|
|
586
|
+
}>;
|
|
587
|
+
getAccount(balanceManager: string, poolList: any): Promise<StateAccount[] | null>;
|
|
588
|
+
/**
|
|
589
|
+
* Gets the SUI transaction response for a given transaction digest.
|
|
590
|
+
* @param digest - The digest of the transaction for which the SUI transaction response is requested.
|
|
591
|
+
* @param forceRefresh - A boolean flag indicating whether to force a refresh of the response.
|
|
592
|
+
* @returns A Promise that resolves with the SUI transaction block response or null if the response is not available.
|
|
593
|
+
*/
|
|
594
|
+
getSuiTransactionResponse(digest: string, forceRefresh?: boolean): Promise<SuiTransactionBlockResponse | null>;
|
|
595
|
+
private transformExtensions;
|
|
596
|
+
/**
|
|
597
|
+
* Get coin config list.
|
|
598
|
+
* @param {boolean} forceRefresh Whether to force a refresh of the cache entry.
|
|
599
|
+
* @param {boolean} transformExtensions Whether to transform extensions.
|
|
600
|
+
* @returns {Promise<CoinConfig[]>} Coin config list.
|
|
601
|
+
*/
|
|
602
|
+
getCoinConfigs(forceRefresh?: boolean, transformExtensions?: boolean): Promise<CoinConfig[]>;
|
|
603
|
+
/**
|
|
604
|
+
* Build coin config.
|
|
605
|
+
* @param {SuiObjectResponse} object Coin object.
|
|
606
|
+
* @param {boolean} transformExtensions Whether to transform extensions.
|
|
607
|
+
* @returns {CoinConfig} Coin config.
|
|
608
|
+
*/
|
|
609
|
+
private buildCoinConfig;
|
|
610
|
+
/**
|
|
611
|
+
* Updates the cache for the given key.
|
|
612
|
+
*
|
|
613
|
+
* @param key The key of the cache entry to update.
|
|
614
|
+
* @param data The data to store in the cache.
|
|
615
|
+
* @param time The time in minutes after which the cache entry should expire.
|
|
616
|
+
*/
|
|
617
|
+
updateCache(key: string, data: SuiResource, time?: number): void;
|
|
618
|
+
/**
|
|
619
|
+
* Gets the cache entry for the given key.
|
|
620
|
+
*
|
|
621
|
+
* @param key The key of the cache entry to get.
|
|
622
|
+
* @param forceRefresh Whether to force a refresh of the cache entry.
|
|
623
|
+
* @returns The cache entry for the given key, or undefined if the cache entry does not exist or is expired.
|
|
624
|
+
*/
|
|
625
|
+
getCache<T>(key: string, forceRefresh?: boolean): T | undefined;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
type Price = {
|
|
629
|
+
coin_type: string;
|
|
630
|
+
price: string;
|
|
631
|
+
oracle_price: bigint;
|
|
632
|
+
last_update_time: number;
|
|
633
|
+
};
|
|
634
|
+
declare class PythPriceModule implements IModule {
|
|
635
|
+
protected _sdk: DeepbookUtilsSDK;
|
|
636
|
+
protected connection: SuiPriceServiceConnection;
|
|
637
|
+
protected suiPythClient: SuiPythClient;
|
|
638
|
+
protected hasChangeConnection: boolean;
|
|
639
|
+
private readonly _cache;
|
|
640
|
+
constructor(sdk: DeepbookUtilsSDK);
|
|
641
|
+
get sdk(): DeepbookUtilsSDK;
|
|
642
|
+
updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
|
|
643
|
+
/**
|
|
644
|
+
* Checks if the price has been updated within the last 60 seconds.
|
|
645
|
+
*
|
|
646
|
+
* @param price - The price object to check.
|
|
647
|
+
* @returns The price object if it has been updated within the last 60 seconds, otherwise undefined.
|
|
648
|
+
*/
|
|
649
|
+
priceCheck(price: Price, age?: number): Price | undefined;
|
|
650
|
+
/**
|
|
651
|
+
* Fetches the latest prices for a list of coin types.
|
|
652
|
+
* Optionally uses cached prices if available.
|
|
653
|
+
*
|
|
654
|
+
* @param coinTypeList - The list of coin types for which prices are required.
|
|
655
|
+
* @param useCache - A flag to indicate whether to use cached prices (default: false).
|
|
656
|
+
* @returns A promise that resolves to a record mapping coin types to their respective price information.
|
|
657
|
+
*/
|
|
658
|
+
getLatestPrice(coinList: {
|
|
659
|
+
feed: string;
|
|
660
|
+
coinType: string;
|
|
661
|
+
}[], useCache?: boolean): Promise<Record<string, Price>>;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
declare class MarginUtilsModule implements IModule {
|
|
665
|
+
#private;
|
|
666
|
+
protected _sdk: DeepbookUtilsSDK;
|
|
667
|
+
protected pythPrice: PythPriceModule;
|
|
668
|
+
private readonly _cache;
|
|
669
|
+
constructor(sdk: DeepbookUtilsSDK);
|
|
670
|
+
get sdk(): DeepbookUtilsSDK;
|
|
671
|
+
/**
|
|
672
|
+
* Creates a margin manager and shares it with the caller account.
|
|
673
|
+
*/
|
|
674
|
+
createAndShareMarginManager(poolInfo: MarginPoolInfo, tx?: Transaction): Transaction;
|
|
675
|
+
getBalanceManagerByMarginManager(account: string): Promise<any>;
|
|
676
|
+
/**
|
|
677
|
+
* get margin manager by account
|
|
678
|
+
* @param account
|
|
679
|
+
* @returns
|
|
680
|
+
*/
|
|
681
|
+
getMarginManagerByAccount(account: string): Promise<any[]>;
|
|
682
|
+
getBaseBalance({ account, marginManager, baseCoinType, quoteCoinType, }: {
|
|
683
|
+
account: string;
|
|
684
|
+
marginManager: string;
|
|
685
|
+
baseCoinType: string;
|
|
686
|
+
quoteCoinType: string;
|
|
687
|
+
}): Promise<string>;
|
|
688
|
+
getQuoteBalance({ account, marginManager, baseCoinType, quoteCoinType, }: {
|
|
689
|
+
account: string;
|
|
690
|
+
marginManager: string;
|
|
691
|
+
baseCoinType: string;
|
|
692
|
+
quoteCoinType: string;
|
|
693
|
+
}): Promise<string>;
|
|
694
|
+
getBorrowedShares({ account, marginManager, baseCoinType, quoteCoinType, }: {
|
|
695
|
+
account: string;
|
|
696
|
+
marginManager: string;
|
|
697
|
+
baseCoinType: string;
|
|
698
|
+
quoteCoinType: string;
|
|
699
|
+
}): Promise<{
|
|
700
|
+
baseBorrowedShare: string;
|
|
701
|
+
quoteBorrowedShare: string;
|
|
702
|
+
}>;
|
|
703
|
+
managerState: ({ account, marginManager, baseCoin, quoteCoin, pool, baseMarginPool, quoteMarginPool, decimals, basePriceFeedObjectId, quotePriceFeedObjectId, }: {
|
|
704
|
+
account: string;
|
|
705
|
+
marginManager: string;
|
|
706
|
+
baseCoin: MarginCoinInfo;
|
|
707
|
+
quoteCoin: MarginCoinInfo;
|
|
708
|
+
pool: string;
|
|
709
|
+
baseMarginPool: string;
|
|
710
|
+
quoteMarginPool: string;
|
|
711
|
+
decimals?: number;
|
|
712
|
+
basePriceFeedObjectId: string;
|
|
713
|
+
quotePriceFeedObjectId: string;
|
|
714
|
+
}) => (tx: Transaction) => void;
|
|
715
|
+
getManagerState(params: {
|
|
716
|
+
account: string;
|
|
717
|
+
marginManager: string;
|
|
718
|
+
baseCoin: MarginCoinInfo;
|
|
719
|
+
quoteCoin: MarginCoinInfo;
|
|
720
|
+
pool: string;
|
|
721
|
+
baseMarginPool: string;
|
|
722
|
+
quoteMarginPool: string;
|
|
723
|
+
decimals?: number;
|
|
724
|
+
}, tx?: Transaction): Promise<{
|
|
725
|
+
managerId: string;
|
|
726
|
+
deepbookPoolId: string;
|
|
727
|
+
riskRatio: number;
|
|
728
|
+
baseAsset: string;
|
|
729
|
+
quoteAsset: string;
|
|
730
|
+
baseDebt: string;
|
|
731
|
+
quoteDebt: string;
|
|
732
|
+
basePythPrice: string;
|
|
733
|
+
basePythDecimals: number;
|
|
734
|
+
quotePythPrice: string;
|
|
735
|
+
quotePythDecimals: number;
|
|
736
|
+
currentPrice: bigint;
|
|
737
|
+
lowestTriggerAbovePrice: bigint;
|
|
738
|
+
highestTriggerBelowPrice: bigint;
|
|
739
|
+
}>;
|
|
740
|
+
calculateAssets({ account, marginManager, pool, baseCoin, quoteCoin, decimals, }: {
|
|
741
|
+
account: string;
|
|
742
|
+
marginManager: string;
|
|
743
|
+
pool: string;
|
|
744
|
+
baseCoin: MarginCoinInfo;
|
|
745
|
+
quoteCoin: MarginCoinInfo;
|
|
746
|
+
decimals?: number;
|
|
747
|
+
}): Promise<{
|
|
748
|
+
baseAsset: string;
|
|
749
|
+
quoteAsset: string;
|
|
750
|
+
}>;
|
|
751
|
+
getBorrowedAmount({ account, marginManager, baseCoinType, quoteCoinType, baseMarginPool, quoteMarginPool, }: {
|
|
752
|
+
account: string;
|
|
753
|
+
marginManager: string;
|
|
754
|
+
baseCoinType: string;
|
|
755
|
+
quoteCoinType: string;
|
|
756
|
+
baseMarginPool: string;
|
|
757
|
+
quoteMarginPool: string;
|
|
758
|
+
}): Promise<{
|
|
759
|
+
baseBorrowedAmount: string;
|
|
760
|
+
quoteBorrowedAmount: string;
|
|
761
|
+
}>;
|
|
762
|
+
/**
|
|
763
|
+
* deposit into margin manager
|
|
764
|
+
* @param marginManager
|
|
765
|
+
* @param baseCoinType
|
|
766
|
+
* @param quoteCoinType
|
|
767
|
+
* @param isBase
|
|
768
|
+
* @param quantity
|
|
769
|
+
* @returns
|
|
770
|
+
*/
|
|
771
|
+
deposit({ marginManager, baseCoin, quoteCoin, isBase, amount, }: {
|
|
772
|
+
marginManager: string;
|
|
773
|
+
baseCoin: MarginCoinInfo;
|
|
774
|
+
quoteCoin: MarginCoinInfo;
|
|
775
|
+
isBase: boolean;
|
|
776
|
+
amount: string;
|
|
777
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
778
|
+
/**
|
|
779
|
+
* withdraw from margin manager
|
|
780
|
+
* @param marginManager
|
|
781
|
+
* @param baseMarginPool
|
|
782
|
+
* @param quoteMarginPool
|
|
783
|
+
* @param baseCoin
|
|
784
|
+
* @param quoteCoin
|
|
785
|
+
* @param pool
|
|
786
|
+
* @param isBase
|
|
787
|
+
* @param amount
|
|
788
|
+
* @returns
|
|
789
|
+
*/
|
|
790
|
+
withdraw({ account, marginManager, baseMarginPool, quoteMarginPool, baseCoin, quoteCoin, pool, isBase, amount, }: {
|
|
791
|
+
account: string;
|
|
792
|
+
marginManager: string;
|
|
793
|
+
baseMarginPool: string;
|
|
794
|
+
quoteMarginPool: string;
|
|
795
|
+
baseCoin: MarginCoinInfo;
|
|
796
|
+
quoteCoin: MarginCoinInfo;
|
|
797
|
+
pool: string;
|
|
798
|
+
isBase: boolean;
|
|
799
|
+
amount: string;
|
|
800
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
801
|
+
borrowBase({ marginManager, baseMarginPool, baseCoin, quoteCoin, pool, amount, }: {
|
|
802
|
+
marginManager: string;
|
|
803
|
+
baseMarginPool: string;
|
|
804
|
+
baseCoin: MarginCoinInfo;
|
|
805
|
+
quoteCoin: MarginCoinInfo;
|
|
806
|
+
pool: string;
|
|
807
|
+
amount: string;
|
|
808
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
809
|
+
borrowQuote({ marginManager, quoteMarginPool, baseCoin, quoteCoin, pool, amount, }: {
|
|
810
|
+
marginManager: string;
|
|
811
|
+
quoteMarginPool: string;
|
|
812
|
+
baseCoin: MarginCoinInfo;
|
|
813
|
+
quoteCoin: MarginCoinInfo;
|
|
814
|
+
pool: string;
|
|
815
|
+
amount: string;
|
|
816
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
817
|
+
repayBase({ marginManager, baseMarginPool, baseCoinType, quoteCoinType, amount, }: {
|
|
818
|
+
marginManager: string;
|
|
819
|
+
baseMarginPool: string;
|
|
820
|
+
baseCoinType: string;
|
|
821
|
+
quoteCoinType: string;
|
|
822
|
+
amount?: string;
|
|
823
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
824
|
+
repayQuote({ marginManager, quoteMarginPool, baseCoinType, quoteCoinType, amount, }: {
|
|
825
|
+
marginManager: string;
|
|
826
|
+
quoteMarginPool: string;
|
|
827
|
+
baseCoinType: string;
|
|
828
|
+
quoteCoinType: string;
|
|
829
|
+
amount?: string;
|
|
830
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
831
|
+
placeMarginMarketOrder({ marginManager, poolInfo, selfMatchingOption, quantity, isBid, payWithDeep, }: {
|
|
832
|
+
marginManager: string;
|
|
833
|
+
poolInfo: MarginPoolInfo;
|
|
834
|
+
selfMatchingOption: number;
|
|
835
|
+
quantity: string;
|
|
836
|
+
isBid: boolean;
|
|
837
|
+
payWithDeep: boolean;
|
|
838
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
839
|
+
/**
|
|
840
|
+
* 提交限价单
|
|
841
|
+
* @param - orderType: 订单类型 (0=NO_RESTRICTION, 1=IMMEDIATE_OR_CANCEL, 2=FILL_OR_KILL, 3=POST_ONLY)
|
|
842
|
+
* @param - selfMatchingOption: 自成交选项 (0=SELF_MATCHING_ALLOWED, 1=CANCEL_TAKER, 2=CANCEL_MAKER)
|
|
843
|
+
* @param tx
|
|
844
|
+
* @returns
|
|
845
|
+
*/
|
|
846
|
+
placeMarginLimitOrder({ marginManager, poolInfo, orderType, selfMatchingOption, priceInput, quantity, isBid, payWithDeep, expirationTimestamp, }: {
|
|
847
|
+
marginManager: string;
|
|
848
|
+
poolInfo: MarginPoolInfo;
|
|
849
|
+
orderType: number;
|
|
850
|
+
selfMatchingOption: number;
|
|
851
|
+
priceInput: string;
|
|
852
|
+
quantity: string;
|
|
853
|
+
isBid: boolean;
|
|
854
|
+
payWithDeep: boolean;
|
|
855
|
+
expirationTimestamp?: number;
|
|
856
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
857
|
+
modifyMarginOrder({ marginManager, poolInfo, orderId, newQuantity, }: {
|
|
858
|
+
marginManager: string;
|
|
859
|
+
poolInfo: MarginPoolInfo;
|
|
860
|
+
orderId: string;
|
|
861
|
+
newQuantity: string;
|
|
862
|
+
}, tx?: Transaction): Transaction;
|
|
863
|
+
cancelMarginOrder({ marginManager, poolInfo, orderId, }: {
|
|
864
|
+
marginManager: string;
|
|
865
|
+
poolInfo: MarginPoolInfo;
|
|
866
|
+
orderId: string;
|
|
867
|
+
}, tx?: Transaction): Transaction;
|
|
868
|
+
cancelAllMarginOrders({ marginManager, poolInfo, }: {
|
|
869
|
+
marginManager: string;
|
|
870
|
+
poolInfo: MarginPoolInfo;
|
|
871
|
+
}, tx?: Transaction): Transaction;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Represents a module for making RPC (Remote Procedure Call) requests.
|
|
876
|
+
*/
|
|
877
|
+
declare class RpcModule extends SuiClient {
|
|
878
|
+
/**
|
|
879
|
+
* Get events for a given query criteria
|
|
880
|
+
* @param query
|
|
881
|
+
* @param paginationArgs
|
|
882
|
+
* @returns
|
|
883
|
+
*/
|
|
884
|
+
queryEventsByPage(query: SuiEventFilter, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
|
|
885
|
+
/**
|
|
886
|
+
* Get all objects owned by an address
|
|
887
|
+
* @param owner
|
|
888
|
+
* @param query
|
|
889
|
+
* @param paginationArgs
|
|
890
|
+
* @returns
|
|
891
|
+
*/
|
|
892
|
+
getOwnedObjectsByPage(owner: string, query: SuiObjectResponseQuery, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
|
|
893
|
+
/**
|
|
894
|
+
* Return the list of dynamic field objects owned by an object
|
|
895
|
+
* @param parentId
|
|
896
|
+
* @param paginationArgs
|
|
897
|
+
* @returns
|
|
898
|
+
*/
|
|
899
|
+
getDynamicFieldsByPage(parentId: SuiObjectIdType, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
|
|
900
|
+
/**
|
|
901
|
+
* Batch get details about a list of objects. If any of the object ids are duplicates the call will fail
|
|
902
|
+
* @param ids
|
|
903
|
+
* @param options
|
|
904
|
+
* @param limit
|
|
905
|
+
* @returns
|
|
906
|
+
*/
|
|
907
|
+
batchGetObjects(ids: SuiObjectIdType[], options?: SuiObjectDataOptions, limit?: number): Promise<any[]>;
|
|
908
|
+
/**
|
|
909
|
+
* Calculates the gas cost of a transaction block.
|
|
910
|
+
* @param {Transaction} tx - The transaction block to calculate gas for.
|
|
911
|
+
* @returns {Promise<number>} - The estimated gas cost of the transaction block.
|
|
912
|
+
* @throws {Error} - Throws an error if the sender is empty.
|
|
913
|
+
*/
|
|
914
|
+
calculationTxGas(tx: Transaction): Promise<number>;
|
|
915
|
+
/**
|
|
916
|
+
* Sends a transaction block after signing it with the provided keypair.
|
|
917
|
+
*
|
|
918
|
+
* @param {Ed25519Keypair | Secp256k1Keypair} keypair - The keypair used for signing the transaction.
|
|
919
|
+
* @param {Transaction} tx - The transaction block to send.
|
|
920
|
+
* @returns {Promise<SuiTransactionBlockResponse | undefined>} - The response of the sent transaction block.
|
|
921
|
+
*/
|
|
922
|
+
sendTransaction(keypair: Ed25519Keypair | Secp256k1Keypair, tx: Transaction): Promise<SuiTransactionBlockResponse | undefined>;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Represents options and configurations for an SDK.
|
|
927
|
+
*/
|
|
928
|
+
type SdkOptions = {
|
|
929
|
+
network: string;
|
|
930
|
+
/**
|
|
931
|
+
* The full URL for interacting with the RPC (Remote Procedure Call) service.
|
|
932
|
+
*/
|
|
933
|
+
fullRpcUrl: string;
|
|
934
|
+
graphqlUrl: string;
|
|
935
|
+
/**
|
|
936
|
+
* Configuration for the simulation account.
|
|
937
|
+
*/
|
|
938
|
+
simulationAccount: {
|
|
939
|
+
/**
|
|
940
|
+
* The address of the simulation account.
|
|
941
|
+
*/
|
|
942
|
+
address: string;
|
|
943
|
+
};
|
|
944
|
+
deepbook: {
|
|
945
|
+
package_id: string;
|
|
946
|
+
published_at: string;
|
|
947
|
+
margin_package_id: string;
|
|
948
|
+
margin_published_at: string;
|
|
949
|
+
};
|
|
950
|
+
deepbook_utils: {
|
|
951
|
+
package_id: string;
|
|
952
|
+
published_at: string;
|
|
953
|
+
global_config_id: string;
|
|
954
|
+
cetus_balance_manager_indexer_id: string;
|
|
955
|
+
vault_global_config_id?: string;
|
|
956
|
+
};
|
|
957
|
+
margin_utils: {
|
|
958
|
+
package_id: string;
|
|
959
|
+
published_at: string;
|
|
960
|
+
registry_id: string;
|
|
961
|
+
margin_registry_id: string;
|
|
962
|
+
wormhole_state_id: string;
|
|
963
|
+
pyth_state_id: string;
|
|
964
|
+
};
|
|
965
|
+
DEEP_COIN: {
|
|
966
|
+
coinType: string;
|
|
967
|
+
decimals: number;
|
|
968
|
+
};
|
|
969
|
+
coinlist: {
|
|
970
|
+
id: string;
|
|
971
|
+
handle: string;
|
|
972
|
+
};
|
|
973
|
+
};
|
|
974
|
+
/**
|
|
975
|
+
* The entry class of CetusClmmSDK, which is almost responsible for all interactions with CLMM.
|
|
976
|
+
*/
|
|
977
|
+
declare class DeepbookUtilsSDK {
|
|
978
|
+
private readonly _cache;
|
|
979
|
+
/**
|
|
980
|
+
* RPC provider on the SUI chain
|
|
981
|
+
*/
|
|
982
|
+
protected _rpcModule: RpcModule;
|
|
983
|
+
protected _deepbookUtils: any;
|
|
984
|
+
protected _marginUtils: any;
|
|
985
|
+
protected _pythPrice: PythPriceModule;
|
|
986
|
+
protected _graphqlClient: SuiGraphQLClient;
|
|
987
|
+
/**
|
|
988
|
+
* Provide sdk options
|
|
989
|
+
*/
|
|
990
|
+
protected _sdkOptions: SdkOptions;
|
|
991
|
+
/**
|
|
992
|
+
* After connecting the wallet, set the current wallet address to senderAddress.
|
|
993
|
+
*/
|
|
994
|
+
protected _senderAddress: string;
|
|
995
|
+
constructor(options: SdkOptions);
|
|
996
|
+
/**
|
|
997
|
+
* Getter for the sender address property.
|
|
998
|
+
* @returns {SuiAddressType} The sender address.
|
|
999
|
+
*/
|
|
1000
|
+
get senderAddress(): SuiAddressType;
|
|
1001
|
+
/**
|
|
1002
|
+
* Setter for the sender address property.
|
|
1003
|
+
* @param {string} value - The new sender address value.
|
|
1004
|
+
*/
|
|
1005
|
+
set senderAddress(value: string);
|
|
1006
|
+
get DeepbookUtils(): DeepbookUtilsModule;
|
|
1007
|
+
get MarginUtils(): MarginUtilsModule;
|
|
1008
|
+
get PythPrice(): PythPriceModule;
|
|
1009
|
+
/**
|
|
1010
|
+
* Getter for the fullClient property.
|
|
1011
|
+
* @returns {RpcModule} The fullClient property value.
|
|
1012
|
+
*/
|
|
1013
|
+
get fullClient(): RpcModule;
|
|
1014
|
+
get graphqlClient(): SuiGraphQLClient;
|
|
1015
|
+
/**
|
|
1016
|
+
* Getter for the sdkOptions property.
|
|
1017
|
+
* @returns {SdkOptions} The sdkOptions property value.
|
|
1018
|
+
*/
|
|
1019
|
+
get sdkOptions(): SdkOptions;
|
|
1020
|
+
/**
|
|
1021
|
+
* Gets all coin assets for the given owner and coin type.
|
|
1022
|
+
*
|
|
1023
|
+
* @param suiAddress The address of the owner.
|
|
1024
|
+
* @param coinType The type of the coin.
|
|
1025
|
+
* @returns an array of coin assets.
|
|
1026
|
+
*/
|
|
1027
|
+
getOwnerCoinAssets(suiAddress: string, coinType?: string | null, forceRefresh?: boolean): Promise<CoinAsset[]>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Gets all coin balances for the given owner and coin type.
|
|
1030
|
+
*
|
|
1031
|
+
* @param suiAddress The address of the owner.
|
|
1032
|
+
* @param coinType The type of the coin.
|
|
1033
|
+
* @returns an array of coin balances.
|
|
1034
|
+
*/
|
|
1035
|
+
getOwnerCoinBalances(suiAddress: string, coinType?: string | null): Promise<CoinBalance[]>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Updates the cache for the given key.
|
|
1038
|
+
*
|
|
1039
|
+
* @param key The key of the cache entry to update.
|
|
1040
|
+
* @param data The data to store in the cache.
|
|
1041
|
+
* @param time The time in minutes after which the cache entry should expire.
|
|
1042
|
+
*/
|
|
1043
|
+
updateCache(key: string, data: SuiResource, time?: number): void;
|
|
1044
|
+
/**
|
|
1045
|
+
* Gets the cache entry for the given key.
|
|
1046
|
+
*
|
|
1047
|
+
* @param key The key of the cache entry to get.
|
|
1048
|
+
* @param forceRefresh Whether to force a refresh of the cache entry.
|
|
1049
|
+
* @returns The cache entry for the given key, or undefined if the cache entry does not exist or is expired.
|
|
1050
|
+
*/
|
|
1051
|
+
getCache<T>(key: string, forceRefresh?: boolean): T | undefined;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
declare const cacheTime5min: number;
|
|
1055
|
+
declare const cacheTime24h: number;
|
|
1056
|
+
declare function getFutureTime(interval: number): number;
|
|
1057
|
+
/**
|
|
1058
|
+
* Defines the structure of a CachedContent object, used for caching resources in memory.
|
|
1059
|
+
*/
|
|
1060
|
+
declare class CachedContent {
|
|
1061
|
+
overdueTime: number;
|
|
1062
|
+
value: SuiResource | null;
|
|
1063
|
+
constructor(value: SuiResource | null, overdueTime?: number);
|
|
1064
|
+
isValid(): boolean;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
1068
|
+
declare function composeType(address: string, generics: SuiAddressType[]): SuiAddressType;
|
|
1069
|
+
declare function composeType(address: string, struct: string, generics?: SuiAddressType[]): SuiAddressType;
|
|
1070
|
+
declare function composeType(address: string, module: string, struct: string, generics?: SuiAddressType[]): SuiAddressType;
|
|
1071
|
+
declare function extractAddressFromType(type: string): string;
|
|
1072
|
+
declare function extractStructTagFromType(type: string): SuiStructTag;
|
|
1073
|
+
declare function normalizeCoinType(coinType: string): string;
|
|
1074
|
+
declare function fixSuiObjectId(value: string): string;
|
|
1075
|
+
/**
|
|
1076
|
+
* Fixes and normalizes a coin type by removing or keeping the prefix.
|
|
1077
|
+
*
|
|
1078
|
+
* @param {string} coinType - The coin type to be fixed.
|
|
1079
|
+
* @param {boolean} removePrefix - Whether to remove the prefix or not (default: true).
|
|
1080
|
+
* @returns {string} - The fixed and normalized coin type.
|
|
1081
|
+
*/
|
|
1082
|
+
declare const fixCoinType: (coinType: string, removePrefix?: boolean) => string;
|
|
1083
|
+
/**
|
|
1084
|
+
* Recursively traverses the given data object and patches any string values that represent Sui object IDs.
|
|
1085
|
+
*
|
|
1086
|
+
* @param {any} data - The data object to be patched.
|
|
1087
|
+
*/
|
|
1088
|
+
declare function patchFixSuiObjectId(data: any): void;
|
|
1089
|
+
declare const NORMALIZED_SUI_COIN_TYPE: string;
|
|
1090
|
+
|
|
1091
|
+
declare function addHexPrefix(hex: string): string;
|
|
1092
|
+
declare function removeHexPrefix(hex: string): string;
|
|
1093
|
+
declare function shortString(str: string, start?: number, end?: number): string;
|
|
1094
|
+
declare function shortAddress(address: string, start?: number, end?: number): string;
|
|
1095
|
+
declare function checkAddress(address: any, options?: {
|
|
1096
|
+
leadingZero: boolean;
|
|
1097
|
+
}): boolean;
|
|
1098
|
+
/**
|
|
1099
|
+
* 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.
|
|
1100
|
+
* @param v the value
|
|
1101
|
+
*/
|
|
1102
|
+
declare function toBuffer(v: any): Buffer;
|
|
1103
|
+
declare function bufferToHex(buffer: Buffer): string;
|
|
1104
|
+
/**
|
|
1105
|
+
* '\x02\x00\x00\x00' to 2
|
|
1106
|
+
* @param binaryData
|
|
1107
|
+
*/
|
|
1108
|
+
declare function hexToNumber(binaryData: string): number;
|
|
1109
|
+
declare function utf8to16(str: string): string;
|
|
1110
|
+
declare function hexToString(str: string): string;
|
|
1111
|
+
|
|
1112
|
+
declare function d(value?: Decimal.Value): Decimal.Instance;
|
|
1113
|
+
declare function decimalsMultiplier(decimals?: Decimal.Value): Decimal.Instance;
|
|
1114
|
+
declare const fixDown: (value: string | number, decimal: number) => string | number;
|
|
1115
|
+
declare const maxDecimal: (value1: Decimal.Value, value2: Decimal.Value) => Decimal.Instance;
|
|
1116
|
+
|
|
1117
|
+
type AdjustResult = {
|
|
1118
|
+
isAdjustCoinA: boolean;
|
|
1119
|
+
isAdjustCoinB: boolean;
|
|
1120
|
+
};
|
|
1121
|
+
type BuildCoinResult = {
|
|
1122
|
+
targetCoin: TransactionArgument;
|
|
1123
|
+
remainCoins: CoinAsset[];
|
|
1124
|
+
isMintZeroCoin: boolean;
|
|
1125
|
+
tragetCoinAmount: string;
|
|
1126
|
+
originalSplitedCoin?: TransactionArgument;
|
|
1127
|
+
};
|
|
1128
|
+
type CoinInputInterval = {
|
|
1129
|
+
amountSecond: bigint;
|
|
1130
|
+
amountFirst: bigint;
|
|
1131
|
+
};
|
|
1132
|
+
declare function printTransaction(tx: Transaction, isPrint?: boolean): Promise<void>;
|
|
1133
|
+
declare class TransactionUtil {
|
|
1134
|
+
/**
|
|
1135
|
+
* adjust transaction for gas
|
|
1136
|
+
* @param sdk
|
|
1137
|
+
* @param amount
|
|
1138
|
+
* @param tx
|
|
1139
|
+
* @returns
|
|
1140
|
+
*/
|
|
1141
|
+
static adjustTransactionForGas(sdk: DeepbookUtilsSDK, allCoins: CoinAsset[], amount: bigint, tx: Transaction): Promise<{
|
|
1142
|
+
fixAmount: bigint;
|
|
1143
|
+
newTx?: Transaction;
|
|
1144
|
+
}>;
|
|
1145
|
+
static buildCoinForAmount(tx: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
1146
|
+
private static buildCoin;
|
|
1147
|
+
private static buildZeroValueCoin;
|
|
1148
|
+
static buildCoinForAmountInterval(tx: Transaction, allCoins: CoinAsset[], amounts: CoinInputInterval, coinType: string, buildVector?: boolean): BuildCoinResult;
|
|
1149
|
+
static callMintZeroValueCoin: (txb: Transaction, coinType: string) => _mysten_sui_transactions.TransactionResult;
|
|
1150
|
+
static buildCoinTypePair(coinTypes: string[], partitionQuantities: number[]): string[][];
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
declare function getSuiObjectData(resp: SuiObjectResponse): SuiObjectData | null | undefined;
|
|
1154
|
+
declare function getObjectDeletedResponse(resp: SuiObjectResponse): SuiObjectRef | undefined;
|
|
1155
|
+
declare function getObjectNotExistsResponse(resp: SuiObjectResponse): string | undefined;
|
|
1156
|
+
declare function getObjectReference(resp: SuiObjectResponse | OwnedObjectRef): SuiObjectRef | undefined;
|
|
1157
|
+
declare function getObjectId(data: SuiObjectResponse | SuiObjectRef | OwnedObjectRef): string;
|
|
1158
|
+
declare function getObjectVersion(data: SuiObjectResponse | SuiObjectRef | SuiObjectData): string | number | undefined;
|
|
1159
|
+
declare function isSuiObjectResponse(resp: SuiObjectResponse | SuiObjectData): resp is SuiObjectResponse;
|
|
1160
|
+
declare function getMovePackageContent(data: SuiObjectResponse): any | undefined;
|
|
1161
|
+
declare function getMoveObject(data: SuiObjectResponse | SuiObjectData): SuiMoveObject | undefined;
|
|
1162
|
+
declare function getMoveObjectType(resp: SuiObjectResponse): string | undefined;
|
|
1163
|
+
/**
|
|
1164
|
+
* Deriving the object type from the object response
|
|
1165
|
+
* @returns 'package' if the object is a package, move object type(e.g., 0x2::coin::Coin<0x2::sui::SUI>)
|
|
1166
|
+
* if the object is a move object
|
|
1167
|
+
*/
|
|
1168
|
+
declare function getObjectType(resp: SuiObjectResponse | SuiObjectData): string | null | undefined;
|
|
1169
|
+
declare function getObjectPreviousTransactionDigest(resp: SuiObjectResponse): string | null | undefined;
|
|
1170
|
+
declare function getObjectOwner(resp: SuiObjectResponse): ObjectOwner | null | undefined;
|
|
1171
|
+
declare function getObjectDisplay(resp: SuiObjectResponse): DisplayFieldsResponse;
|
|
1172
|
+
declare function getObjectFields(resp: SuiObjectResponse | SuiObjectData): any | undefined;
|
|
1173
|
+
interface SuiObjectDataWithContent extends SuiObjectData {
|
|
1174
|
+
content: SuiParsedData;
|
|
1175
|
+
}
|
|
1176
|
+
declare function hasPublicTransfer(data: SuiObjectResponse | SuiObjectData): boolean;
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Converts an amount to a decimal value, based on the number of decimals specified.
|
|
1180
|
+
* @param {number | string} amount - The amount to convert to decimal.
|
|
1181
|
+
* @param {number | string} decimals - The number of decimals to use in the conversion.
|
|
1182
|
+
* @returns {number} - Returns the converted amount as a number.
|
|
1183
|
+
*/
|
|
1184
|
+
declare function toDecimalsAmount(amount: number | string, decimals: number | string): number;
|
|
1185
|
+
/**
|
|
1186
|
+
* Converts a bigint to an unsigned integer of the specified number of bits.
|
|
1187
|
+
* @param {bigint} int - The bigint to convert.
|
|
1188
|
+
* @param {number} bits - The number of bits to use in the conversion. Defaults to 32 bits.
|
|
1189
|
+
* @returns {string} - Returns the converted unsigned integer as a string.
|
|
1190
|
+
*/
|
|
1191
|
+
declare function asUintN(int: bigint, bits?: number): string;
|
|
1192
|
+
/**
|
|
1193
|
+
* Converts a bigint to a signed integer of the specified number of bits.
|
|
1194
|
+
* @param {bigint} int - The bigint to convert.
|
|
1195
|
+
* @param {number} bits - The number of bits to use in the conversion. Defaults to 32 bits.
|
|
1196
|
+
* @returns {number} - Returns the converted signed integer as a number.
|
|
1197
|
+
*/
|
|
1198
|
+
declare function asIntN(int: bigint, bits?: number): number;
|
|
1199
|
+
/**
|
|
1200
|
+
* Converts an amount in decimals to its corresponding numerical value.
|
|
1201
|
+
* @param {number|string} amount - The amount to convert.
|
|
1202
|
+
* @param {number|string} decimals - The number of decimal places used in the amount.
|
|
1203
|
+
* @returns {number} - Returns the converted numerical value.
|
|
1204
|
+
*/
|
|
1205
|
+
declare function fromDecimalsAmount(amount: number | string, decimals: number | string): number;
|
|
1206
|
+
/**
|
|
1207
|
+
* Converts a secret key in string or Uint8Array format to an Ed25519 key pair.
|
|
1208
|
+
* @param {string|Uint8Array} secretKey - The secret key to convert.
|
|
1209
|
+
* @param {string} ecode - The encoding of the secret key ('hex' or 'base64'). Defaults to 'hex'.
|
|
1210
|
+
* @returns {Ed25519Keypair} - Returns the Ed25519 key pair.
|
|
1211
|
+
*/
|
|
1212
|
+
declare function secretKeyToEd25519Keypair(secretKey: string | Uint8Array, ecode?: 'hex' | 'base64'): Ed25519Keypair;
|
|
1213
|
+
/**
|
|
1214
|
+
* Converts a secret key in string or Uint8Array format to a Secp256k1 key pair.
|
|
1215
|
+
* @param {string|Uint8Array} secretKey - The secret key to convert.
|
|
1216
|
+
* @param {string} ecode - The encoding of the secret key ('hex' or 'base64'). Defaults to 'hex'.
|
|
1217
|
+
* @returns {Ed25519Keypair} - Returns the Secp256k1 key pair.
|
|
1218
|
+
*/
|
|
1219
|
+
declare function secretKeyToSecp256k1Keypair(secretKey: string | Uint8Array, ecode?: 'hex' | 'base64'): Secp256k1Keypair;
|
|
1220
|
+
|
|
1221
|
+
declare const calculateRiskRatio: ({ totalAssetsValue, totalDebtValue }: {
|
|
1222
|
+
totalAssetsValue: string;
|
|
1223
|
+
totalDebtValue: string;
|
|
1224
|
+
}) => string;
|
|
1225
|
+
|
|
1226
|
+
declare const DEFAULT_GAS_BUDGET_FOR_SPLIT = 1000;
|
|
1227
|
+
declare const DEFAULT_GAS_BUDGET_FOR_MERGE = 500;
|
|
1228
|
+
declare const DEFAULT_GAS_BUDGET_FOR_TRANSFER = 100;
|
|
1229
|
+
declare const DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI = 100;
|
|
1230
|
+
declare const DEFAULT_GAS_BUDGET_FOR_STAKE = 1000;
|
|
1231
|
+
declare const GAS_TYPE_ARG = "0x2::sui::SUI";
|
|
1232
|
+
declare const GAS_TYPE_ARG_LONG = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
1233
|
+
declare const GAS_SYMBOL = "SUI";
|
|
1234
|
+
declare const DEFAULT_NFT_TRANSFER_GAS_FEE = 450;
|
|
1235
|
+
declare const SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000005";
|
|
1236
|
+
/**
|
|
1237
|
+
* This class provides helper methods for working with coins.
|
|
1238
|
+
*/
|
|
1239
|
+
declare class CoinAssist {
|
|
1240
|
+
/**
|
|
1241
|
+
* Get the coin type argument from a SuiMoveObject.
|
|
1242
|
+
*
|
|
1243
|
+
* @param obj The SuiMoveObject to get the coin type argument from.
|
|
1244
|
+
* @returns The coin type argument, or null if it is not found.
|
|
1245
|
+
*/
|
|
1246
|
+
static getCoinTypeArg(obj: SuiMoveObject): string | null;
|
|
1247
|
+
/**
|
|
1248
|
+
* Get whether a SuiMoveObject is a SUI coin.
|
|
1249
|
+
*
|
|
1250
|
+
* @param obj The SuiMoveObject to check.
|
|
1251
|
+
* @returns Whether the SuiMoveObject is a SUI coin.
|
|
1252
|
+
*/
|
|
1253
|
+
static isSUI(obj: SuiMoveObject): boolean;
|
|
1254
|
+
/**
|
|
1255
|
+
* Get the coin symbol from a coin type argument.
|
|
1256
|
+
*
|
|
1257
|
+
* @param coinTypeArg The coin type argument to get the symbol from.
|
|
1258
|
+
* @returns The coin symbol.
|
|
1259
|
+
*/
|
|
1260
|
+
static getCoinSymbol(coinTypeArg: string): string;
|
|
1261
|
+
/**
|
|
1262
|
+
* Get the balance of a SuiMoveObject.
|
|
1263
|
+
*
|
|
1264
|
+
* @param obj The SuiMoveObject to get the balance from.
|
|
1265
|
+
* @returns The balance of the SuiMoveObject.
|
|
1266
|
+
*/
|
|
1267
|
+
static getBalance(obj: SuiMoveObject): bigint;
|
|
1268
|
+
/**
|
|
1269
|
+
* Get the total balance of a list of CoinAsset objects for a given coin address.
|
|
1270
|
+
*
|
|
1271
|
+
* @param objs The list of CoinAsset objects to get the total balance for.
|
|
1272
|
+
* @param coinAddress The coin address to get the total balance for.
|
|
1273
|
+
* @returns The total balance of the CoinAsset objects for the given coin address.
|
|
1274
|
+
*/
|
|
1275
|
+
static totalBalance(objs: CoinAsset[], coinAddress: SuiAddressType): bigint;
|
|
1276
|
+
/**
|
|
1277
|
+
* Get the ID of a SuiMoveObject.
|
|
1278
|
+
*
|
|
1279
|
+
* @param obj The SuiMoveObject to get the ID from.
|
|
1280
|
+
* @returns The ID of the SuiMoveObject.
|
|
1281
|
+
*/
|
|
1282
|
+
static getID(obj: SuiMoveObject): string;
|
|
1283
|
+
/**
|
|
1284
|
+
* Get the coin type from a coin type argument.
|
|
1285
|
+
*
|
|
1286
|
+
* @param coinTypeArg The coin type argument to get the coin type from.
|
|
1287
|
+
* @returns The coin type.
|
|
1288
|
+
*/
|
|
1289
|
+
static getCoinTypeFromArg(coinTypeArg: string): string;
|
|
1290
|
+
/**
|
|
1291
|
+
* Get the FaucetCoin objects from a SuiTransactionBlockResponse.
|
|
1292
|
+
*
|
|
1293
|
+
* @param suiTransactionResponse The SuiTransactionBlockResponse to get the FaucetCoin objects from.
|
|
1294
|
+
* @returns The FaucetCoin objects.
|
|
1295
|
+
*/
|
|
1296
|
+
/**
|
|
1297
|
+
* Get the CoinAsset objects for a given coin type.
|
|
1298
|
+
*
|
|
1299
|
+
* @param coinType The coin type to get the CoinAsset objects for.
|
|
1300
|
+
* @param allSuiObjects The list of all SuiMoveObjects.
|
|
1301
|
+
* @returns The CoinAsset objects for the given coin type.
|
|
1302
|
+
*/
|
|
1303
|
+
static getCoinAssets(coinType: string, allSuiObjects: CoinAsset[]): CoinAsset[];
|
|
1304
|
+
/**
|
|
1305
|
+
* Get whether a coin address is a SUI coin.
|
|
1306
|
+
*
|
|
1307
|
+
* @param coinAddress The coin address to check.
|
|
1308
|
+
* @returns Whether the coin address is a SUI coin.
|
|
1309
|
+
*/
|
|
1310
|
+
static isSuiCoin(coinAddress: SuiAddressType): boolean;
|
|
1311
|
+
/**
|
|
1312
|
+
* Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
|
|
1313
|
+
*
|
|
1314
|
+
* @param coins The list of CoinAsset objects to select from.
|
|
1315
|
+
* @param amount The amount to select CoinAsset objects with a balance greater than or equal to.
|
|
1316
|
+
* @param exclude A list of CoinAsset objects to exclude from the selection.
|
|
1317
|
+
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
1318
|
+
*/
|
|
1319
|
+
static selectCoinObjectIdGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
|
|
1320
|
+
objectArray: string[];
|
|
1321
|
+
remainCoins: CoinAsset[];
|
|
1322
|
+
amountArray: string[];
|
|
1323
|
+
};
|
|
1324
|
+
/**
|
|
1325
|
+
* Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
|
|
1326
|
+
*
|
|
1327
|
+
* @param coins The list of CoinAsset objects to select from.
|
|
1328
|
+
* @param amount The amount to select CoinAsset objects with a balance greater than or equal to.
|
|
1329
|
+
* @param exclude A list of CoinAsset objects to exclude from the selection.
|
|
1330
|
+
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
1331
|
+
*/
|
|
1332
|
+
static selectCoinAssetGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
|
|
1333
|
+
selectedCoins: CoinAsset[];
|
|
1334
|
+
remainingCoins: CoinAsset[];
|
|
1335
|
+
};
|
|
1336
|
+
/**
|
|
1337
|
+
* Sort the CoinAsset objects by their balance.
|
|
1338
|
+
*
|
|
1339
|
+
* @param coins The CoinAsset objects to sort.
|
|
1340
|
+
* @returns The sorted CoinAsset objects.
|
|
1341
|
+
*/
|
|
1342
|
+
static sortByBalance(coins: CoinAsset[]): CoinAsset[];
|
|
1343
|
+
static sortByBalanceDes(coins: CoinAsset[]): CoinAsset[];
|
|
1344
|
+
/**
|
|
1345
|
+
* Calculate the total balance of a list of CoinAsset objects.
|
|
1346
|
+
*
|
|
1347
|
+
* @param coins The list of CoinAsset objects to calculate the total balance for.
|
|
1348
|
+
* @returns The total balance of the CoinAsset objects.
|
|
1349
|
+
*/
|
|
1350
|
+
static calculateTotalBalance(coins: CoinAsset[]): bigint;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
export { AdjustResult, Balances, BigNumber, BuildCoinResult, CLOCK_ADDRESS, CachedContent, DeepbookUtilsSDK as CetusClmmSDK, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinStoreAddress, 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, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, MarginCoinInfo, MarginPoolInfo, MarginUtilsModule, NFT, NORMALIZED_SUI_COIN_TYPE, OrderDeepPrice, OrderFee, OrderType, Package, PageQuery, PaginationArgs, PoolInfo, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, StateAccount, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, Token, TransactionUtil, addHexPrefix, asIntN, asUintN, bufferToHex, cacheTime24h, cacheTime5min, calculateRiskRatio, 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 };
|