@cetusprotocol/deepbook-utils 1.4.7 → 1.4.9
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/babel.config.js +11 -0
- package/biome.json +5 -2
- package/dist/index.d.ts +122 -190
- package/dist/index.js +1044 -15
- package/package.json +7 -7
package/babel.config.js
ADDED
package/biome.json
CHANGED
|
@@ -47,12 +47,15 @@
|
|
|
47
47
|
"noForEach": "off",
|
|
48
48
|
"useOptionalChain": "off",
|
|
49
49
|
"noStaticOnlyClass": "off",
|
|
50
|
-
"noUselessTernary": "off"
|
|
50
|
+
"noUselessTernary": "off",
|
|
51
|
+
"noThisInStatic": "off"
|
|
51
52
|
},
|
|
52
53
|
"correctness": {
|
|
53
54
|
"noUnusedImports": "warn",
|
|
54
55
|
"useExhaustiveDependencies": "off",
|
|
55
|
-
"noUnusedVariables": "off"
|
|
56
|
+
"noUnusedVariables": "off",
|
|
57
|
+
"noUnnecessaryContinue": "off",
|
|
58
|
+
"noConstantCondition": "off"
|
|
56
59
|
},
|
|
57
60
|
"style": {
|
|
58
61
|
"noParameterAssign": "off",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PythPriceModule as PythPriceModule$1, FullClient } from '@cetusprotocol/common-sdk';
|
|
2
|
-
import { SuiGraphQLClient } from '@mysten/sui/graphql';
|
|
3
|
-
import { SuiObjectResponse, SuiTransactionBlockResponse, CoinBalance, SuiObjectData, SuiObjectRef, OwnedObjectRef, SuiMoveObject, ObjectOwner, DisplayFieldsResponse, SuiParsedData } from '@mysten/sui/jsonRpc';
|
|
4
2
|
import * as _mysten_sui_transactions from '@mysten/sui/transactions';
|
|
5
|
-
import { TransactionArgument,
|
|
3
|
+
import { TransactionArgument, TransactionObjectArgument, Transaction, TransactionResult } from '@mysten/sui/transactions';
|
|
4
|
+
import { SuiClientTypes } from '@mysten/sui/client';
|
|
5
|
+
import { SuiObjectResponse, SuiObjectData, SuiObjectRef, OwnedObjectRef, SuiMoveObject, SuiParsedData } from '@mysten/sui/jsonRpc';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
8
8
|
import { Secp256k1Keypair } from '@mysten/sui/keypairs/secp256k1';
|
|
@@ -148,22 +148,9 @@ type SuiInputTypes = 'object' | SuiBasicTypes;
|
|
|
148
148
|
*/
|
|
149
149
|
declare const getDefaultSuiInputType: (value: any) => SuiInputTypes;
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
151
|
+
* Error handling RPC priority list
|
|
152
152
|
*/
|
|
153
|
-
|
|
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
|
-
};
|
|
153
|
+
declare const ERROR_HANDLING_RPC_LIST: string[];
|
|
167
154
|
|
|
168
155
|
/**
|
|
169
156
|
* Represents configuration data for a cryptocurrency coin.
|
|
@@ -352,6 +339,45 @@ type ConditionalOrder = {
|
|
|
352
339
|
pending_order: PendingOrder;
|
|
353
340
|
};
|
|
354
341
|
|
|
342
|
+
/**
|
|
343
|
+
* Represents a coin asset with address, object ID, and balance information.
|
|
344
|
+
*/
|
|
345
|
+
type CoinAsset = {
|
|
346
|
+
/**
|
|
347
|
+
* The address type of the coin asset.
|
|
348
|
+
*/
|
|
349
|
+
coin_type: string;
|
|
350
|
+
/**
|
|
351
|
+
* The object identifier of the coin asset.
|
|
352
|
+
*/
|
|
353
|
+
coin_object_id: SuiObjectIdType;
|
|
354
|
+
/**
|
|
355
|
+
* The balance amount of the coin asset.
|
|
356
|
+
*/
|
|
357
|
+
balance: bigint;
|
|
358
|
+
};
|
|
359
|
+
type BuildCoinResult = {
|
|
360
|
+
target_coin: TransactionObjectArgument;
|
|
361
|
+
selected_coins: string[];
|
|
362
|
+
remain_coins: CoinAsset[];
|
|
363
|
+
is_mint_zero_coin: boolean;
|
|
364
|
+
target_coin_amount: string;
|
|
365
|
+
original_spited_coin?: TransactionObjectArgument;
|
|
366
|
+
};
|
|
367
|
+
type CoinInputInterval = {
|
|
368
|
+
amount_second: bigint;
|
|
369
|
+
amount_first: bigint;
|
|
370
|
+
};
|
|
371
|
+
type MultiCoinInput = {
|
|
372
|
+
amount_coin_array: {
|
|
373
|
+
coin_object_id: TransactionObjectArgument;
|
|
374
|
+
amount: string;
|
|
375
|
+
used: boolean;
|
|
376
|
+
}[];
|
|
377
|
+
coin_type: string;
|
|
378
|
+
remain_coins: CoinAsset[];
|
|
379
|
+
};
|
|
380
|
+
|
|
355
381
|
type BigNumber = Decimal.Value | number | string;
|
|
356
382
|
|
|
357
383
|
declare const DEEP_SCALAR = 1000000;
|
|
@@ -544,17 +570,17 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
544
570
|
* Determines the fee asset to use and whether additional deposits are required.
|
|
545
571
|
*/
|
|
546
572
|
getFeeAsset(maxFee: string, feeCoin: string, baseAmount: string, quoteAmount: string, feeManaerBalance: string, quoteIsDeep: boolean, baseIsDeep: boolean, payWithDeep: boolean, txb: Transaction): {
|
|
547
|
-
feeAsset:
|
|
573
|
+
feeAsset: TransactionObjectArgument;
|
|
548
574
|
haveDepositFee: string;
|
|
549
575
|
};
|
|
550
576
|
/**
|
|
551
577
|
* Prepares the assets necessary to execute a limit order transaction.
|
|
552
578
|
*/
|
|
553
579
|
getTransactionRelatedAssets(poolInfo: any, baseAmount: string, quoteAmount: string, maxFee: string, isBid: boolean, account: string, payWithDeep: boolean, balanceManager: string, txb: Transaction): Promise<{
|
|
554
|
-
baseAsset:
|
|
555
|
-
quoteAsset:
|
|
580
|
+
baseAsset: TransactionObjectArgument;
|
|
581
|
+
quoteAsset: TransactionObjectArgument;
|
|
556
582
|
feeAsset: {
|
|
557
|
-
feeAsset:
|
|
583
|
+
feeAsset: TransactionObjectArgument;
|
|
558
584
|
haveDepositFee: string;
|
|
559
585
|
};
|
|
560
586
|
haveDeposit: boolean;
|
|
@@ -566,9 +592,9 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
566
592
|
base: string;
|
|
567
593
|
quote: string;
|
|
568
594
|
}): Promise<{
|
|
569
|
-
baseAsset:
|
|
570
|
-
quoteAsset:
|
|
571
|
-
feeAsset:
|
|
595
|
+
baseAsset: TransactionObjectArgument | Transaction;
|
|
596
|
+
quoteAsset: TransactionObjectArgument | Transaction;
|
|
597
|
+
feeAsset: TransactionObjectArgument;
|
|
572
598
|
}>;
|
|
573
599
|
/**
|
|
574
600
|
* Creates a transaction that deposits required assets and then places a limit order.
|
|
@@ -584,7 +610,7 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
584
610
|
payWithDeep: boolean;
|
|
585
611
|
expirationTimestamp?: number;
|
|
586
612
|
}): Promise<any>;
|
|
587
|
-
getEmptyCoin(txb: any, coin: string):
|
|
613
|
+
getEmptyCoin(txb: any, coin: string): TransactionObjectArgument;
|
|
588
614
|
/**
|
|
589
615
|
* Creates a transaction that deposits necessary assets and places a market order.
|
|
590
616
|
*/
|
|
@@ -687,7 +713,12 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
687
713
|
ask?: undefined;
|
|
688
714
|
}>;
|
|
689
715
|
getWalletBalance(account: string): Promise<{
|
|
690
|
-
[k: string]:
|
|
716
|
+
[k: string]: {
|
|
717
|
+
coinType: any;
|
|
718
|
+
totalBalance: any;
|
|
719
|
+
coinBalance: any;
|
|
720
|
+
addressBalance: any;
|
|
721
|
+
};
|
|
691
722
|
}>;
|
|
692
723
|
getAccount(balanceManager: string | TransactionArgument, poolList: any, txb?: Transaction): Promise<StateAccount[] | null>;
|
|
693
724
|
/**
|
|
@@ -696,7 +727,7 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
696
727
|
* @param forceRefresh - A boolean flag indicating whether to force a refresh of the response.
|
|
697
728
|
* @returns A Promise that resolves with the SUI transaction block response or null if the response is not available.
|
|
698
729
|
*/
|
|
699
|
-
getSuiTransactionResponse(digest: string, forceRefresh?: boolean): Promise<
|
|
730
|
+
getSuiTransactionResponse(digest: string, forceRefresh?: boolean): Promise<SuiClientTypes.TransactionResult | null>;
|
|
700
731
|
private transformExtensions;
|
|
701
732
|
/**
|
|
702
733
|
* Get coin config list.
|
|
@@ -754,7 +785,7 @@ declare class PythPriceModule implements IModule {
|
|
|
754
785
|
private readonly _cache;
|
|
755
786
|
constructor(sdk: DeepbookUtilsSDK);
|
|
756
787
|
get sdk(): DeepbookUtilsSDK;
|
|
757
|
-
updatePythPriceIDs(priceIDs: string[], txb:
|
|
788
|
+
updatePythPriceIDs(priceIDs: string[], txb: any): Promise<Map<string, string>>;
|
|
758
789
|
/**
|
|
759
790
|
* Checks if the price has been updated within the last 60 seconds.
|
|
760
791
|
*
|
|
@@ -1231,6 +1262,8 @@ declare class MarginUtilsModule implements IModule {
|
|
|
1231
1262
|
* @param {Object} params - Parameters object
|
|
1232
1263
|
* @param {string} params.marginManager - The margin manager object ID
|
|
1233
1264
|
* @param {MarginPoolInfo} params.poolInfo - Pool information
|
|
1265
|
+
* @param {string} params.baseMarginPool - Base asset MarginPool shared object id
|
|
1266
|
+
* @param {string} params.quoteMarginPool - Quote asset MarginPool shared object id
|
|
1234
1267
|
* @param {SelfMatchingOption} params.selfMatchingOption - Self-matching behavior option
|
|
1235
1268
|
* @param {string} params.quantity - Order quantity
|
|
1236
1269
|
* @param {boolean} params.isBid - Whether this is a buy order (true) or sell order (false)
|
|
@@ -1239,9 +1272,11 @@ declare class MarginUtilsModule implements IModule {
|
|
|
1239
1272
|
* @returns {Promise<Transaction>} The transaction object with market order operation
|
|
1240
1273
|
* @throws {Error} If parameters are invalid or decimals are missing
|
|
1241
1274
|
*/
|
|
1242
|
-
placeMarginMarketOrder({ marginManager, poolInfo, selfMatchingOption, quantity, amountLimit, isBid, payWithDeep, exactBase, referralKey, }: {
|
|
1275
|
+
placeMarginMarketOrder({ marginManager, poolInfo, baseMarginPool, quoteMarginPool, selfMatchingOption, quantity, amountLimit, isBid, payWithDeep, exactBase, referralKey, }: {
|
|
1243
1276
|
marginManager: string | TransactionArgument;
|
|
1244
1277
|
poolInfo: MarginPoolInfo;
|
|
1278
|
+
baseMarginPool: string;
|
|
1279
|
+
quoteMarginPool: string;
|
|
1245
1280
|
selfMatchingOption: SelfMatchingOption;
|
|
1246
1281
|
quantity: string;
|
|
1247
1282
|
amountLimit: string;
|
|
@@ -1257,6 +1292,8 @@ declare class MarginUtilsModule implements IModule {
|
|
|
1257
1292
|
* @param {Object} params - Parameters object
|
|
1258
1293
|
* @param {string} params.marginManager - The margin manager object ID
|
|
1259
1294
|
* @param {MarginPoolInfo} params.poolInfo - Pool information
|
|
1295
|
+
* @param {string} params.baseMarginPool - Base asset MarginPool shared object id
|
|
1296
|
+
* @param {string} params.quoteMarginPool - Quote asset MarginPool shared object id
|
|
1260
1297
|
* @param {OrderType} params.orderType - Order type (0=NO_RESTRICTION, 1=IMMEDIATE_OR_CANCEL, 2=FILL_OR_KILL, 3=POST_ONLY)
|
|
1261
1298
|
* @param {SelfMatchingOption} params.selfMatchingOption - Self-matching behavior option (0=SELF_MATCHING_ALLOWED, 1=CANCEL_TAKER, 2=CANCEL_MAKER)
|
|
1262
1299
|
* @param {string} params.priceInput - Limit price as a string
|
|
@@ -1268,9 +1305,11 @@ declare class MarginUtilsModule implements IModule {
|
|
|
1268
1305
|
* @returns {Promise<Transaction>} The transaction object with limit order operation
|
|
1269
1306
|
* @throws {Error} If parameters are invalid or decimals are missing
|
|
1270
1307
|
*/
|
|
1271
|
-
placeMarginLimitOrder({ marginManager, poolInfo, orderType, selfMatchingOption, priceInput, quantity, isBid, payWithDeep, expirationTimestamp, referralKey, }: {
|
|
1308
|
+
placeMarginLimitOrder({ marginManager, poolInfo, baseMarginPool, quoteMarginPool, orderType, selfMatchingOption, priceInput, quantity, isBid, payWithDeep, expirationTimestamp, referralKey, }: {
|
|
1272
1309
|
marginManager: string;
|
|
1273
1310
|
poolInfo: MarginPoolInfo;
|
|
1311
|
+
baseMarginPool: string;
|
|
1312
|
+
quoteMarginPool: string;
|
|
1274
1313
|
orderType: OrderType;
|
|
1275
1314
|
selfMatchingOption: SelfMatchingOption;
|
|
1276
1315
|
priceInput: string;
|
|
@@ -1328,29 +1367,39 @@ declare class MarginUtilsModule implements IModule {
|
|
|
1328
1367
|
marginManager: string;
|
|
1329
1368
|
poolInfo: MarginPoolInfo;
|
|
1330
1369
|
}, tx?: Transaction): Transaction;
|
|
1331
|
-
|
|
1370
|
+
/**
|
|
1371
|
+
* Places a reduce-only limit order (`place_reduce_only_limit_order_v2<Base, Quote>`).
|
|
1372
|
+
* DebtAsset generic removed; single `margin_pool<Debt>` replaced by base/quote MarginPools + oracles.
|
|
1373
|
+
*/
|
|
1374
|
+
placeReduceOnlyLimitOrder({ marginManager, poolInfo, baseMarginPool, quoteMarginPool, orderType, selfMatchingOption, priceInput, quantity, isBid, payWithDeep, expirationTimestamp, }: {
|
|
1332
1375
|
marginManager: string;
|
|
1333
1376
|
poolInfo: MarginPoolInfo;
|
|
1334
|
-
|
|
1377
|
+
baseMarginPool: string;
|
|
1378
|
+
quoteMarginPool: string;
|
|
1335
1379
|
orderType: OrderType;
|
|
1336
1380
|
selfMatchingOption: SelfMatchingOption;
|
|
1337
1381
|
priceInput: string;
|
|
1338
1382
|
quantity: string;
|
|
1339
1383
|
isBid: boolean;
|
|
1340
1384
|
payWithDeep: boolean;
|
|
1341
|
-
expirationTimestamp
|
|
1342
|
-
}, tx?: Transaction): Transaction
|
|
1343
|
-
|
|
1385
|
+
expirationTimestamp?: number;
|
|
1386
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
1387
|
+
/**
|
|
1388
|
+
* Places a reduce-only market order (`place_reduce_only_market_order_v2<Base, Quote>`).
|
|
1389
|
+
* DebtAsset generic removed; single `margin_pool<Debt>` replaced by base/quote MarginPools + oracles.
|
|
1390
|
+
*/
|
|
1391
|
+
placeReduceOnlyMarketOrder({ marginManager, poolInfo, baseMarginPool, quoteMarginPool, selfMatchingOption, quantity, amountLimit, isBid, payWithDeep, }: {
|
|
1344
1392
|
marginManager: string;
|
|
1345
1393
|
poolInfo: MarginPoolInfo;
|
|
1346
|
-
|
|
1347
|
-
|
|
1394
|
+
baseMarginPool: string;
|
|
1395
|
+
quoteMarginPool: string;
|
|
1348
1396
|
selfMatchingOption: SelfMatchingOption;
|
|
1349
1397
|
quantity: string;
|
|
1398
|
+
amountLimit: string;
|
|
1350
1399
|
isBid: boolean;
|
|
1351
1400
|
payWithDeep: boolean;
|
|
1352
|
-
|
|
1353
|
-
|
|
1401
|
+
}, tx?: Transaction): Promise<Transaction>;
|
|
1402
|
+
getOpenOrder(poolInfo: any, account: string, balanceManager: string | TransactionArgument, orders?: string[], isMargin?: boolean, tx?: Transaction): Promise<any>;
|
|
1354
1403
|
getAccountOpenOrders({ poolInfo, marginManager }: {
|
|
1355
1404
|
poolInfo: PoolInfo;
|
|
1356
1405
|
marginManager: string;
|
|
@@ -1440,7 +1489,7 @@ declare class MarginUtilsModule implements IModule {
|
|
|
1440
1489
|
quote_amount: string;
|
|
1441
1490
|
deep_fee_amount: string;
|
|
1442
1491
|
}>;
|
|
1443
|
-
getAccount(marginManager: string, poolInfo: any): Promise<StateAccount[] | null>;
|
|
1492
|
+
getAccount(marginManager: string, poolInfo: any, txb?: Transaction): Promise<StateAccount[] | null>;
|
|
1444
1493
|
withdrawSettledAmounts({ poolInfo, marginManager, }: {
|
|
1445
1494
|
poolInfo: any;
|
|
1446
1495
|
marginManager: string;
|
|
@@ -1616,7 +1665,6 @@ type SdkOptions = {
|
|
|
1616
1665
|
* The entry class of CetusClmmSDK, which is almost responsible for all interactions with CLMM.
|
|
1617
1666
|
*/
|
|
1618
1667
|
declare class DeepbookUtilsSDK {
|
|
1619
|
-
private readonly _cache;
|
|
1620
1668
|
/**
|
|
1621
1669
|
* RPC provider on the SUI chain
|
|
1622
1670
|
*/
|
|
@@ -1624,7 +1672,6 @@ declare class DeepbookUtilsSDK {
|
|
|
1624
1672
|
protected _deepbookUtils: any;
|
|
1625
1673
|
protected _marginUtils: any;
|
|
1626
1674
|
protected _pythPrice: PythPriceModule;
|
|
1627
|
-
protected _graphqlClient: SuiGraphQLClient;
|
|
1628
1675
|
/**
|
|
1629
1676
|
* Provide sdk options
|
|
1630
1677
|
*/
|
|
@@ -1652,44 +1699,11 @@ declare class DeepbookUtilsSDK {
|
|
|
1652
1699
|
* @returns {FullClient} The fullClient property value.
|
|
1653
1700
|
*/
|
|
1654
1701
|
get fullClient(): FullClient;
|
|
1655
|
-
get graphqlClient(): SuiGraphQLClient;
|
|
1656
1702
|
/**
|
|
1657
1703
|
* Getter for the sdkOptions property.
|
|
1658
1704
|
* @returns {SdkOptions} The sdkOptions property value.
|
|
1659
1705
|
*/
|
|
1660
1706
|
get sdkOptions(): SdkOptions;
|
|
1661
|
-
/**
|
|
1662
|
-
* Gets all coin assets for the given owner and coin type.
|
|
1663
|
-
*
|
|
1664
|
-
* @param suiAddress The address of the owner.
|
|
1665
|
-
* @param coinType The type of the coin.
|
|
1666
|
-
* @returns an array of coin assets.
|
|
1667
|
-
*/
|
|
1668
|
-
getOwnerCoinAssets(suiAddress: string, coinType?: string | null, forceRefresh?: boolean): Promise<CoinAsset[]>;
|
|
1669
|
-
/**
|
|
1670
|
-
* Gets all coin balances for the given owner and coin type.
|
|
1671
|
-
*
|
|
1672
|
-
* @param suiAddress The address of the owner.
|
|
1673
|
-
* @param coinType The type of the coin.
|
|
1674
|
-
* @returns an array of coin balances.
|
|
1675
|
-
*/
|
|
1676
|
-
getOwnerCoinBalances(suiAddress: string, coinType?: string | null): Promise<CoinBalance[]>;
|
|
1677
|
-
/**
|
|
1678
|
-
* Updates the cache for the given key.
|
|
1679
|
-
*
|
|
1680
|
-
* @param key The key of the cache entry to update.
|
|
1681
|
-
* @param data The data to store in the cache.
|
|
1682
|
-
* @param time The time in minutes after which the cache entry should expire.
|
|
1683
|
-
*/
|
|
1684
|
-
updateCache(key: string, data: SuiResource, time?: number): void;
|
|
1685
|
-
/**
|
|
1686
|
-
* Gets the cache entry for the given key.
|
|
1687
|
-
*
|
|
1688
|
-
* @param key The key of the cache entry to get.
|
|
1689
|
-
* @param forceRefresh Whether to force a refresh of the cache entry.
|
|
1690
|
-
* @returns The cache entry for the given key, or undefined if the cache entry does not exist or is expired.
|
|
1691
|
-
*/
|
|
1692
|
-
getCache<T>(key: string, forceRefresh?: boolean): T | undefined;
|
|
1693
1707
|
}
|
|
1694
1708
|
|
|
1695
1709
|
declare const cacheTime1min: number;
|
|
@@ -1756,66 +1770,17 @@ declare function decimalsMultiplier(decimals?: Decimal.Value): Decimal.Instance;
|
|
|
1756
1770
|
declare const fixDown: (value: string | number, decimal: number) => string | number;
|
|
1757
1771
|
declare const maxDecimal: (value1: Decimal.Value, value2: Decimal.Value) => Decimal.Instance;
|
|
1758
1772
|
|
|
1759
|
-
type AdjustResult = {
|
|
1760
|
-
isAdjustCoinA: boolean;
|
|
1761
|
-
isAdjustCoinB: boolean;
|
|
1762
|
-
};
|
|
1763
|
-
type BuildCoinResult = {
|
|
1764
|
-
targetCoin: TransactionArgument;
|
|
1765
|
-
remainCoins: CoinAsset[];
|
|
1766
|
-
isMintZeroCoin: boolean;
|
|
1767
|
-
tragetCoinAmount: string;
|
|
1768
|
-
originalSplitedCoin?: TransactionArgument;
|
|
1769
|
-
};
|
|
1770
|
-
type CoinInputInterval = {
|
|
1771
|
-
amountSecond: bigint;
|
|
1772
|
-
amountFirst: bigint;
|
|
1773
|
-
};
|
|
1774
|
-
declare function printTransaction(tx: Transaction, isPrint?: boolean): Promise<void>;
|
|
1775
|
-
declare class TransactionUtil {
|
|
1776
|
-
/**
|
|
1777
|
-
* adjust transaction for gas
|
|
1778
|
-
* @param sdk
|
|
1779
|
-
* @param amount
|
|
1780
|
-
* @param tx
|
|
1781
|
-
* @returns
|
|
1782
|
-
*/
|
|
1783
|
-
static adjustTransactionForGas(sdk: DeepbookUtilsSDK, allCoins: CoinAsset[], amount: bigint, tx: Transaction): Promise<{
|
|
1784
|
-
fixAmount: bigint;
|
|
1785
|
-
newTx?: Transaction;
|
|
1786
|
-
}>;
|
|
1787
|
-
static buildCoinForAmount(tx: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
1788
|
-
static buildCoin(tx: Transaction, allCoins: CoinAsset[], coinAssets: CoinAsset[], amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
1789
|
-
private static buildZeroValueCoin;
|
|
1790
|
-
static buildCoinForAmountInterval(tx: Transaction, allCoins: CoinAsset[], amounts: CoinInputInterval, coinType: string, buildVector?: boolean): BuildCoinResult;
|
|
1791
|
-
static callMintZeroValueCoin: (txb: Transaction, coinType: string) => _mysten_sui_transactions.TransactionResult;
|
|
1792
|
-
static buildCoinTypePair(coinTypes: string[], partitionQuantities: number[]): string[][];
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1795
1773
|
declare function getSuiObjectData(resp: SuiObjectResponse): SuiObjectData | null | undefined;
|
|
1796
1774
|
declare function getObjectDeletedResponse(resp: SuiObjectResponse): SuiObjectRef | undefined;
|
|
1797
1775
|
declare function getObjectNotExistsResponse(resp: SuiObjectResponse): string | undefined;
|
|
1798
1776
|
declare function getObjectReference(resp: SuiObjectResponse | OwnedObjectRef): SuiObjectRef | undefined;
|
|
1799
1777
|
declare function getObjectId(data: SuiObjectResponse | SuiObjectRef | OwnedObjectRef): string;
|
|
1800
|
-
declare function getObjectVersion(data: SuiObjectResponse | SuiObjectRef | SuiObjectData): string | number | undefined;
|
|
1801
1778
|
declare function isSuiObjectResponse(resp: SuiObjectResponse | SuiObjectData): resp is SuiObjectResponse;
|
|
1802
|
-
declare function getMovePackageContent(data: SuiObjectResponse): any | undefined;
|
|
1803
1779
|
declare function getMoveObject(data: SuiObjectResponse | SuiObjectData): SuiMoveObject | undefined;
|
|
1804
|
-
declare function getMoveObjectType(resp: SuiObjectResponse): string | undefined;
|
|
1805
|
-
/**
|
|
1806
|
-
* Deriving the object type from the object response
|
|
1807
|
-
* @returns 'package' if the object is a package, move object type(e.g., 0x2::coin::Coin<0x2::sui::SUI>)
|
|
1808
|
-
* if the object is a move object
|
|
1809
|
-
*/
|
|
1810
|
-
declare function getObjectType(resp: SuiObjectResponse | SuiObjectData): string | null | undefined;
|
|
1811
|
-
declare function getObjectPreviousTransactionDigest(resp: SuiObjectResponse): string | null | undefined;
|
|
1812
|
-
declare function getObjectOwner(resp: SuiObjectResponse): ObjectOwner | null | undefined;
|
|
1813
|
-
declare function getObjectDisplay(resp: SuiObjectResponse): DisplayFieldsResponse;
|
|
1814
1780
|
declare function getObjectFields(resp: SuiObjectResponse | SuiObjectData): any | undefined;
|
|
1815
1781
|
interface SuiObjectDataWithContent extends SuiObjectData {
|
|
1816
1782
|
content: SuiParsedData;
|
|
1817
1783
|
}
|
|
1818
|
-
declare function hasPublicTransfer(data: SuiObjectResponse | SuiObjectData): boolean;
|
|
1819
1784
|
|
|
1820
1785
|
/**
|
|
1821
1786
|
* Converts an amount to a decimal value, based on the number of decimals specified.
|
|
@@ -1847,19 +1812,20 @@ declare function asIntN(int: bigint, bits?: number): number;
|
|
|
1847
1812
|
declare function fromDecimalsAmount(amount: number | string, decimals: number | string): number;
|
|
1848
1813
|
/**
|
|
1849
1814
|
* Converts a secret key in string or Uint8Array format to an Ed25519 key pair.
|
|
1850
|
-
* @param {string|Uint8Array}
|
|
1815
|
+
* @param {string|Uint8Array} secret_key - The secret key to convert.
|
|
1851
1816
|
* @param {string} ecode - The encoding of the secret key ('hex' or 'base64'). Defaults to 'hex'.
|
|
1852
1817
|
* @returns {Ed25519Keypair} - Returns the Ed25519 key pair.
|
|
1853
1818
|
*/
|
|
1854
|
-
declare function secretKeyToEd25519Keypair(
|
|
1819
|
+
declare function secretKeyToEd25519Keypair(secret_key: string | Uint8Array, ecode?: 'hex' | 'base64'): Ed25519Keypair;
|
|
1855
1820
|
/**
|
|
1856
1821
|
* Converts a secret key in string or Uint8Array format to a Secp256k1 key pair.
|
|
1857
|
-
* @param {string|Uint8Array}
|
|
1822
|
+
* @param {string|Uint8Array} secret_key - The secret key to convert.
|
|
1858
1823
|
* @param {string} ecode - The encoding of the secret key ('hex' or 'base64'). Defaults to 'hex'.
|
|
1859
1824
|
* @returns {Ed25519Keypair} - Returns the Secp256k1 key pair.
|
|
1860
1825
|
*/
|
|
1861
|
-
declare function secretKeyToSecp256k1Keypair(
|
|
1826
|
+
declare function secretKeyToSecp256k1Keypair(secret_key: string | Uint8Array, ecode?: 'hex' | 'base64'): Secp256k1Keypair;
|
|
1862
1827
|
declare const sleepTime: (s: number) => Promise<unknown>;
|
|
1828
|
+
declare function printTransaction(tx: Transaction, is_print?: boolean): Promise<void>;
|
|
1863
1829
|
|
|
1864
1830
|
declare const calculateRiskRatio: ({ totalAssetsValue, totalDebtValue }: {
|
|
1865
1831
|
totalAssetsValue: string;
|
|
@@ -1992,77 +1958,29 @@ declare const SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000
|
|
|
1992
1958
|
* This class provides helper methods for working with coins.
|
|
1993
1959
|
*/
|
|
1994
1960
|
declare class CoinAssist {
|
|
1995
|
-
/**
|
|
1996
|
-
* Get the coin type argument from a SuiMoveObject.
|
|
1997
|
-
*
|
|
1998
|
-
* @param obj The SuiMoveObject to get the coin type argument from.
|
|
1999
|
-
* @returns The coin type argument, or null if it is not found.
|
|
2000
|
-
*/
|
|
2001
|
-
static getCoinTypeArg(obj: SuiMoveObject): string | null;
|
|
2002
|
-
/**
|
|
2003
|
-
* Get whether a SuiMoveObject is a SUI coin.
|
|
2004
|
-
*
|
|
2005
|
-
* @param obj The SuiMoveObject to check.
|
|
2006
|
-
* @returns Whether the SuiMoveObject is a SUI coin.
|
|
2007
|
-
*/
|
|
2008
|
-
static isSUI(obj: SuiMoveObject): boolean;
|
|
2009
|
-
/**
|
|
2010
|
-
* Get the coin symbol from a coin type argument.
|
|
2011
|
-
*
|
|
2012
|
-
* @param coinTypeArg The coin type argument to get the symbol from.
|
|
2013
|
-
* @returns The coin symbol.
|
|
2014
|
-
*/
|
|
2015
|
-
static getCoinSymbol(coinTypeArg: string): string;
|
|
2016
|
-
/**
|
|
2017
|
-
* Get the balance of a SuiMoveObject.
|
|
2018
|
-
*
|
|
2019
|
-
* @param obj The SuiMoveObject to get the balance from.
|
|
2020
|
-
* @returns The balance of the SuiMoveObject.
|
|
2021
|
-
*/
|
|
2022
|
-
static getBalance(obj: SuiMoveObject): bigint;
|
|
2023
1961
|
/**
|
|
2024
1962
|
* Get the total balance of a list of CoinAsset objects for a given coin address.
|
|
2025
1963
|
*
|
|
2026
1964
|
* @param objs The list of CoinAsset objects to get the total balance for.
|
|
2027
|
-
* @param
|
|
1965
|
+
* @param coin_address The coin address to get the total balance for.
|
|
2028
1966
|
* @returns The total balance of the CoinAsset objects for the given coin address.
|
|
2029
1967
|
*/
|
|
2030
|
-
static totalBalance(objs: CoinAsset[],
|
|
2031
|
-
/**
|
|
2032
|
-
* Get the ID of a SuiMoveObject.
|
|
2033
|
-
*
|
|
2034
|
-
* @param obj The SuiMoveObject to get the ID from.
|
|
2035
|
-
* @returns The ID of the SuiMoveObject.
|
|
2036
|
-
*/
|
|
2037
|
-
static getID(obj: SuiMoveObject): string;
|
|
2038
|
-
/**
|
|
2039
|
-
* Get the coin type from a coin type argument.
|
|
2040
|
-
*
|
|
2041
|
-
* @param coinTypeArg The coin type argument to get the coin type from.
|
|
2042
|
-
* @returns The coin type.
|
|
2043
|
-
*/
|
|
2044
|
-
static getCoinTypeFromArg(coinTypeArg: string): string;
|
|
2045
|
-
/**
|
|
2046
|
-
* Get the FaucetCoin objects from a SuiTransactionBlockResponse.
|
|
2047
|
-
*
|
|
2048
|
-
* @param suiTransactionResponse The SuiTransactionBlockResponse to get the FaucetCoin objects from.
|
|
2049
|
-
* @returns The FaucetCoin objects.
|
|
2050
|
-
*/
|
|
1968
|
+
static totalBalance(objs: CoinAsset[], coin_address: SuiAddressType): bigint;
|
|
2051
1969
|
/**
|
|
2052
1970
|
* Get the CoinAsset objects for a given coin type.
|
|
2053
1971
|
*
|
|
2054
|
-
* @param
|
|
2055
|
-
* @param
|
|
1972
|
+
* @param coin_type The coin type to get the CoinAsset objects for.
|
|
1973
|
+
* @param all_sui_objects The list of all SuiMoveObjects.
|
|
2056
1974
|
* @returns The CoinAsset objects for the given coin type.
|
|
2057
1975
|
*/
|
|
2058
|
-
static getCoinAssets(
|
|
1976
|
+
static getCoinAssets(coin_type: string, all_sui_objects: CoinAsset[]): CoinAsset[];
|
|
2059
1977
|
/**
|
|
2060
1978
|
* Get whether a coin address is a SUI coin.
|
|
2061
1979
|
*
|
|
2062
|
-
* @param
|
|
1980
|
+
* @param coin_address The coin address to check.
|
|
2063
1981
|
* @returns Whether the coin address is a SUI coin.
|
|
2064
1982
|
*/
|
|
2065
|
-
static isSuiCoin(
|
|
1983
|
+
static isSuiCoin(coin_address: SuiAddressType): boolean;
|
|
2066
1984
|
/**
|
|
2067
1985
|
* Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
|
|
2068
1986
|
*
|
|
@@ -2072,9 +1990,9 @@ declare class CoinAssist {
|
|
|
2072
1990
|
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
2073
1991
|
*/
|
|
2074
1992
|
static selectCoinObjectIdGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
1993
|
+
object_array: string[];
|
|
1994
|
+
remain_coins: CoinAsset[];
|
|
1995
|
+
amount_array: string[];
|
|
2078
1996
|
};
|
|
2079
1997
|
/**
|
|
2080
1998
|
* Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
|
|
@@ -2085,8 +2003,8 @@ declare class CoinAssist {
|
|
|
2085
2003
|
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
2086
2004
|
*/
|
|
2087
2005
|
static selectCoinAssetGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
|
|
2088
|
-
|
|
2089
|
-
|
|
2006
|
+
selected_coins: CoinAsset[];
|
|
2007
|
+
remain_coins: CoinAsset[];
|
|
2090
2008
|
};
|
|
2091
2009
|
/**
|
|
2092
2010
|
* Sort the CoinAsset objects by their balance.
|
|
@@ -2103,7 +2021,21 @@ declare class CoinAssist {
|
|
|
2103
2021
|
* @returns The total balance of the CoinAsset objects.
|
|
2104
2022
|
*/
|
|
2105
2023
|
static calculateTotalBalance(coins: CoinAsset[]): bigint;
|
|
2024
|
+
static buildCoinForAmount(tx: Transaction, all_coins: CoinAsset[], amount: bigint, coin_type: string, build_vector?: boolean, fix_amount?: boolean): BuildCoinResult;
|
|
2106
2025
|
static buildCoinWithBalance(amount: bigint, coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2026
|
+
private static buildVectorCoin;
|
|
2027
|
+
private static buildOneCoin;
|
|
2028
|
+
private static buildSpitTargeCoin;
|
|
2029
|
+
private static buildCoin;
|
|
2030
|
+
private static buildZeroValueCoin;
|
|
2031
|
+
static buildCoinForAmountInterval(tx: Transaction, all_coins: CoinAsset[], amounts: CoinInputInterval, coin_type: string, build_vector?: boolean, fix_amount?: boolean): BuildCoinResult;
|
|
2032
|
+
static callMintZeroValueCoin: (txb: Transaction, coin_type: string) => _mysten_sui_transactions.TransactionResult;
|
|
2033
|
+
static fromBalance(balance: TransactionObjectArgument, coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2034
|
+
static intoBalance(coin_obj: TransactionObjectArgument | string, coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2035
|
+
static mintBalanceZero(coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2036
|
+
static destroyBalanceZero(balance: TransactionObjectArgument, coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2037
|
+
static getCoinAmountObjId(coin_input: MultiCoinInput, amount: string): TransactionObjectArgument;
|
|
2038
|
+
static buildMultiCoinInput(tx: Transaction, all_coin_assets: CoinAsset[], coin_type: string, amount_arr: bigint[]): MultiCoinInput;
|
|
2107
2039
|
}
|
|
2108
2040
|
|
|
2109
|
-
export { AddConditionalOrderOptions,
|
|
2041
|
+
export { AddConditionalOrderOptions, Balances, BigNumber, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CancelAllConditionalOrdersOptions, CancelConditionalOrdersOptions, DeepbookUtilsSDK as CetusClmmSDK, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinInputInterval, CoinStoreAddress, Condition, ConditionalOrder, 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, DebtDetail, DeepCoin, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookUtilsModule, ERROR_HANDLING_RPC_LIST, FLOAT_SCALAR, FLOAT_SCALING, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, GetConditionalIdsOptions, GetConditionalOrderIdsResponse, GetConditionalOrdersOptions, InterestConfig, MarginCoinInfo, MarginPoolConfig, MarginPoolInfo, MarginUtilsModule, MultiCoinInput, NFT, NORMALIZED_SUI_COIN_TYPE, OrderDeepPrice, OrderFee, OrderType, Package, PageQuery, PaginationArgs, PendingLimitOrderOptions, PendingMarketOrderOptions, PendingOrder, PoolInfo, PoolState, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SelfMatchingOption, StateAccount, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, Token, UserBorrowInfo, YEAR_MS, addHexPrefix, asIntN, asUintN, bufferToHex, cacheTime1min, cacheTime24h, cacheTime5min, calc100PercentRepay, calcDebtDetail, calcInterestRate, calcUtilizationRate, calculateRiskRatio, checkAddress, composeType, d, decimalsMultiplier, DeepbookUtilsSDK as default, extractAddressFromType, extractStructTagFromType, fixCoinType, fixDown, fixSuiObjectId, fromDecimalsAmount, getDefaultSuiInputType, getFutureTime, getMoveObject, getObjectDeletedResponse, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectReference, getSuiObjectData, hexToNumber, hexToString, isSortedSymbols, isSuiObjectResponse, maxDecimal, mulRoundUp, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, sleepTime, toBuffer, toDecimalsAmount, utf8to16, wrapDeepBookMarginPoolInfo, wrapDeepBookPoolInfo };
|