@cetusprotocol/deepbook-utils 1.4.6 → 1.4.8
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 +103 -180
- 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 { SuiTransactionBlockResponse, CoinBalance, SuiObjectResponse, 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;
|
|
@@ -438,9 +464,13 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
438
464
|
}): Transaction;
|
|
439
465
|
/**
|
|
440
466
|
* Retrieves balance managers for an account, optionally using the cached
|
|
441
|
-
* result when it is still valid.
|
|
467
|
+
* result when it is still valid. Only managers that satisfy the cap rule
|
|
468
|
+
* are returned: no allow-list yet (`listed.length === 0`), or every
|
|
469
|
+
* allow-listed object is owned by `account` (`owned.length === listed.length`).
|
|
442
470
|
*/
|
|
443
471
|
getBalanceManager(account: string, forceRefresh?: boolean): Promise<any>;
|
|
472
|
+
batchGetObjectsByIdMap(objectIdMap: Record<string, string[]>): Promise<Record<string, SuiObjectResponse[]>>;
|
|
473
|
+
getSuiObjectOwnerAddress(resp: SuiObjectResponse): string | undefined;
|
|
444
474
|
withdrawSettledAmounts({ poolInfo, balanceManager, }: {
|
|
445
475
|
poolInfo: any;
|
|
446
476
|
balanceManager: string;
|
|
@@ -540,17 +570,17 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
540
570
|
* Determines the fee asset to use and whether additional deposits are required.
|
|
541
571
|
*/
|
|
542
572
|
getFeeAsset(maxFee: string, feeCoin: string, baseAmount: string, quoteAmount: string, feeManaerBalance: string, quoteIsDeep: boolean, baseIsDeep: boolean, payWithDeep: boolean, txb: Transaction): {
|
|
543
|
-
feeAsset:
|
|
573
|
+
feeAsset: TransactionObjectArgument;
|
|
544
574
|
haveDepositFee: string;
|
|
545
575
|
};
|
|
546
576
|
/**
|
|
547
577
|
* Prepares the assets necessary to execute a limit order transaction.
|
|
548
578
|
*/
|
|
549
579
|
getTransactionRelatedAssets(poolInfo: any, baseAmount: string, quoteAmount: string, maxFee: string, isBid: boolean, account: string, payWithDeep: boolean, balanceManager: string, txb: Transaction): Promise<{
|
|
550
|
-
baseAsset:
|
|
551
|
-
quoteAsset:
|
|
580
|
+
baseAsset: TransactionObjectArgument;
|
|
581
|
+
quoteAsset: TransactionObjectArgument;
|
|
552
582
|
feeAsset: {
|
|
553
|
-
feeAsset:
|
|
583
|
+
feeAsset: TransactionObjectArgument;
|
|
554
584
|
haveDepositFee: string;
|
|
555
585
|
};
|
|
556
586
|
haveDeposit: boolean;
|
|
@@ -562,9 +592,9 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
562
592
|
base: string;
|
|
563
593
|
quote: string;
|
|
564
594
|
}): Promise<{
|
|
565
|
-
baseAsset:
|
|
566
|
-
quoteAsset:
|
|
567
|
-
feeAsset:
|
|
595
|
+
baseAsset: TransactionObjectArgument | Transaction;
|
|
596
|
+
quoteAsset: TransactionObjectArgument | Transaction;
|
|
597
|
+
feeAsset: TransactionObjectArgument;
|
|
568
598
|
}>;
|
|
569
599
|
/**
|
|
570
600
|
* Creates a transaction that deposits required assets and then places a limit order.
|
|
@@ -580,7 +610,7 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
580
610
|
payWithDeep: boolean;
|
|
581
611
|
expirationTimestamp?: number;
|
|
582
612
|
}): Promise<any>;
|
|
583
|
-
getEmptyCoin(txb: any, coin: string):
|
|
613
|
+
getEmptyCoin(txb: any, coin: string): TransactionObjectArgument;
|
|
584
614
|
/**
|
|
585
615
|
* Creates a transaction that deposits necessary assets and places a market order.
|
|
586
616
|
*/
|
|
@@ -683,7 +713,12 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
683
713
|
ask?: undefined;
|
|
684
714
|
}>;
|
|
685
715
|
getWalletBalance(account: string): Promise<{
|
|
686
|
-
[k: string]:
|
|
716
|
+
[k: string]: {
|
|
717
|
+
coinType: any;
|
|
718
|
+
totalBalance: any;
|
|
719
|
+
coinBalance: any;
|
|
720
|
+
addressBalance: any;
|
|
721
|
+
};
|
|
687
722
|
}>;
|
|
688
723
|
getAccount(balanceManager: string | TransactionArgument, poolList: any, txb?: Transaction): Promise<StateAccount[] | null>;
|
|
689
724
|
/**
|
|
@@ -692,7 +727,7 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
692
727
|
* @param forceRefresh - A boolean flag indicating whether to force a refresh of the response.
|
|
693
728
|
* @returns A Promise that resolves with the SUI transaction block response or null if the response is not available.
|
|
694
729
|
*/
|
|
695
|
-
getSuiTransactionResponse(digest: string, forceRefresh?: boolean): Promise<
|
|
730
|
+
getSuiTransactionResponse(digest: string, forceRefresh?: boolean): Promise<SuiClientTypes.TransactionResult | null>;
|
|
696
731
|
private transformExtensions;
|
|
697
732
|
/**
|
|
698
733
|
* Get coin config list.
|
|
@@ -731,6 +766,10 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
731
766
|
baseCoinType: string;
|
|
732
767
|
quoteCoinType: string;
|
|
733
768
|
}): Promise<Transaction>;
|
|
769
|
+
newWithCustomOwnerCaps({ owner, appType, }: {
|
|
770
|
+
owner: string;
|
|
771
|
+
appType?: string;
|
|
772
|
+
}): Transaction;
|
|
734
773
|
}
|
|
735
774
|
|
|
736
775
|
type Price = {
|
|
@@ -746,7 +785,7 @@ declare class PythPriceModule implements IModule {
|
|
|
746
785
|
private readonly _cache;
|
|
747
786
|
constructor(sdk: DeepbookUtilsSDK);
|
|
748
787
|
get sdk(): DeepbookUtilsSDK;
|
|
749
|
-
updatePythPriceIDs(priceIDs: string[], txb:
|
|
788
|
+
updatePythPriceIDs(priceIDs: string[], txb: any): Promise<Map<string, string>>;
|
|
750
789
|
/**
|
|
751
790
|
* Checks if the price has been updated within the last 60 seconds.
|
|
752
791
|
*
|
|
@@ -1343,6 +1382,7 @@ declare class MarginUtilsModule implements IModule {
|
|
|
1343
1382
|
payWithDeep: boolean;
|
|
1344
1383
|
expirationTimestamp: number;
|
|
1345
1384
|
}, tx?: Transaction): Transaction;
|
|
1385
|
+
getOpenOrder(poolInfo: any, account: string, balanceManager: string | TransactionArgument, orders?: string[], isMargin?: boolean, tx?: Transaction): Promise<any>;
|
|
1346
1386
|
getAccountOpenOrders({ poolInfo, marginManager }: {
|
|
1347
1387
|
poolInfo: PoolInfo;
|
|
1348
1388
|
marginManager: string;
|
|
@@ -1432,7 +1472,7 @@ declare class MarginUtilsModule implements IModule {
|
|
|
1432
1472
|
quote_amount: string;
|
|
1433
1473
|
deep_fee_amount: string;
|
|
1434
1474
|
}>;
|
|
1435
|
-
getAccount(marginManager: string, poolInfo: any): Promise<StateAccount[] | null>;
|
|
1475
|
+
getAccount(marginManager: string, poolInfo: any, txb?: Transaction): Promise<StateAccount[] | null>;
|
|
1436
1476
|
withdrawSettledAmounts({ poolInfo, marginManager, }: {
|
|
1437
1477
|
poolInfo: any;
|
|
1438
1478
|
marginManager: string;
|
|
@@ -1608,7 +1648,6 @@ type SdkOptions = {
|
|
|
1608
1648
|
* The entry class of CetusClmmSDK, which is almost responsible for all interactions with CLMM.
|
|
1609
1649
|
*/
|
|
1610
1650
|
declare class DeepbookUtilsSDK {
|
|
1611
|
-
private readonly _cache;
|
|
1612
1651
|
/**
|
|
1613
1652
|
* RPC provider on the SUI chain
|
|
1614
1653
|
*/
|
|
@@ -1616,7 +1655,6 @@ declare class DeepbookUtilsSDK {
|
|
|
1616
1655
|
protected _deepbookUtils: any;
|
|
1617
1656
|
protected _marginUtils: any;
|
|
1618
1657
|
protected _pythPrice: PythPriceModule;
|
|
1619
|
-
protected _graphqlClient: SuiGraphQLClient;
|
|
1620
1658
|
/**
|
|
1621
1659
|
* Provide sdk options
|
|
1622
1660
|
*/
|
|
@@ -1644,44 +1682,11 @@ declare class DeepbookUtilsSDK {
|
|
|
1644
1682
|
* @returns {FullClient} The fullClient property value.
|
|
1645
1683
|
*/
|
|
1646
1684
|
get fullClient(): FullClient;
|
|
1647
|
-
get graphqlClient(): SuiGraphQLClient;
|
|
1648
1685
|
/**
|
|
1649
1686
|
* Getter for the sdkOptions property.
|
|
1650
1687
|
* @returns {SdkOptions} The sdkOptions property value.
|
|
1651
1688
|
*/
|
|
1652
1689
|
get sdkOptions(): SdkOptions;
|
|
1653
|
-
/**
|
|
1654
|
-
* Gets all coin assets for the given owner and coin type.
|
|
1655
|
-
*
|
|
1656
|
-
* @param suiAddress The address of the owner.
|
|
1657
|
-
* @param coinType The type of the coin.
|
|
1658
|
-
* @returns an array of coin assets.
|
|
1659
|
-
*/
|
|
1660
|
-
getOwnerCoinAssets(suiAddress: string, coinType?: string | null, forceRefresh?: boolean): Promise<CoinAsset[]>;
|
|
1661
|
-
/**
|
|
1662
|
-
* Gets all coin balances 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 balances.
|
|
1667
|
-
*/
|
|
1668
|
-
getOwnerCoinBalances(suiAddress: string, coinType?: string | null): Promise<CoinBalance[]>;
|
|
1669
|
-
/**
|
|
1670
|
-
* Updates the cache for the given key.
|
|
1671
|
-
*
|
|
1672
|
-
* @param key The key of the cache entry to update.
|
|
1673
|
-
* @param data The data to store in the cache.
|
|
1674
|
-
* @param time The time in minutes after which the cache entry should expire.
|
|
1675
|
-
*/
|
|
1676
|
-
updateCache(key: string, data: SuiResource, time?: number): void;
|
|
1677
|
-
/**
|
|
1678
|
-
* Gets the cache entry for the given key.
|
|
1679
|
-
*
|
|
1680
|
-
* @param key The key of the cache entry to get.
|
|
1681
|
-
* @param forceRefresh Whether to force a refresh of the cache entry.
|
|
1682
|
-
* @returns The cache entry for the given key, or undefined if the cache entry does not exist or is expired.
|
|
1683
|
-
*/
|
|
1684
|
-
getCache<T>(key: string, forceRefresh?: boolean): T | undefined;
|
|
1685
1690
|
}
|
|
1686
1691
|
|
|
1687
1692
|
declare const cacheTime1min: number;
|
|
@@ -1748,66 +1753,17 @@ declare function decimalsMultiplier(decimals?: Decimal.Value): Decimal.Instance;
|
|
|
1748
1753
|
declare const fixDown: (value: string | number, decimal: number) => string | number;
|
|
1749
1754
|
declare const maxDecimal: (value1: Decimal.Value, value2: Decimal.Value) => Decimal.Instance;
|
|
1750
1755
|
|
|
1751
|
-
type AdjustResult = {
|
|
1752
|
-
isAdjustCoinA: boolean;
|
|
1753
|
-
isAdjustCoinB: boolean;
|
|
1754
|
-
};
|
|
1755
|
-
type BuildCoinResult = {
|
|
1756
|
-
targetCoin: TransactionArgument;
|
|
1757
|
-
remainCoins: CoinAsset[];
|
|
1758
|
-
isMintZeroCoin: boolean;
|
|
1759
|
-
tragetCoinAmount: string;
|
|
1760
|
-
originalSplitedCoin?: TransactionArgument;
|
|
1761
|
-
};
|
|
1762
|
-
type CoinInputInterval = {
|
|
1763
|
-
amountSecond: bigint;
|
|
1764
|
-
amountFirst: bigint;
|
|
1765
|
-
};
|
|
1766
|
-
declare function printTransaction(tx: Transaction, isPrint?: boolean): Promise<void>;
|
|
1767
|
-
declare class TransactionUtil {
|
|
1768
|
-
/**
|
|
1769
|
-
* adjust transaction for gas
|
|
1770
|
-
* @param sdk
|
|
1771
|
-
* @param amount
|
|
1772
|
-
* @param tx
|
|
1773
|
-
* @returns
|
|
1774
|
-
*/
|
|
1775
|
-
static adjustTransactionForGas(sdk: DeepbookUtilsSDK, allCoins: CoinAsset[], amount: bigint, tx: Transaction): Promise<{
|
|
1776
|
-
fixAmount: bigint;
|
|
1777
|
-
newTx?: Transaction;
|
|
1778
|
-
}>;
|
|
1779
|
-
static buildCoinForAmount(tx: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
1780
|
-
static buildCoin(tx: Transaction, allCoins: CoinAsset[], coinAssets: CoinAsset[], amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
1781
|
-
private static buildZeroValueCoin;
|
|
1782
|
-
static buildCoinForAmountInterval(tx: Transaction, allCoins: CoinAsset[], amounts: CoinInputInterval, coinType: string, buildVector?: boolean): BuildCoinResult;
|
|
1783
|
-
static callMintZeroValueCoin: (txb: Transaction, coinType: string) => _mysten_sui_transactions.TransactionResult;
|
|
1784
|
-
static buildCoinTypePair(coinTypes: string[], partitionQuantities: number[]): string[][];
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
1756
|
declare function getSuiObjectData(resp: SuiObjectResponse): SuiObjectData | null | undefined;
|
|
1788
1757
|
declare function getObjectDeletedResponse(resp: SuiObjectResponse): SuiObjectRef | undefined;
|
|
1789
1758
|
declare function getObjectNotExistsResponse(resp: SuiObjectResponse): string | undefined;
|
|
1790
1759
|
declare function getObjectReference(resp: SuiObjectResponse | OwnedObjectRef): SuiObjectRef | undefined;
|
|
1791
1760
|
declare function getObjectId(data: SuiObjectResponse | SuiObjectRef | OwnedObjectRef): string;
|
|
1792
|
-
declare function getObjectVersion(data: SuiObjectResponse | SuiObjectRef | SuiObjectData): string | number | undefined;
|
|
1793
1761
|
declare function isSuiObjectResponse(resp: SuiObjectResponse | SuiObjectData): resp is SuiObjectResponse;
|
|
1794
|
-
declare function getMovePackageContent(data: SuiObjectResponse): any | undefined;
|
|
1795
1762
|
declare function getMoveObject(data: SuiObjectResponse | SuiObjectData): SuiMoveObject | undefined;
|
|
1796
|
-
declare function getMoveObjectType(resp: SuiObjectResponse): string | undefined;
|
|
1797
|
-
/**
|
|
1798
|
-
* Deriving the object type from the object response
|
|
1799
|
-
* @returns 'package' if the object is a package, move object type(e.g., 0x2::coin::Coin<0x2::sui::SUI>)
|
|
1800
|
-
* if the object is a move object
|
|
1801
|
-
*/
|
|
1802
|
-
declare function getObjectType(resp: SuiObjectResponse | SuiObjectData): string | null | undefined;
|
|
1803
|
-
declare function getObjectPreviousTransactionDigest(resp: SuiObjectResponse): string | null | undefined;
|
|
1804
|
-
declare function getObjectOwner(resp: SuiObjectResponse): ObjectOwner | null | undefined;
|
|
1805
|
-
declare function getObjectDisplay(resp: SuiObjectResponse): DisplayFieldsResponse;
|
|
1806
1763
|
declare function getObjectFields(resp: SuiObjectResponse | SuiObjectData): any | undefined;
|
|
1807
1764
|
interface SuiObjectDataWithContent extends SuiObjectData {
|
|
1808
1765
|
content: SuiParsedData;
|
|
1809
1766
|
}
|
|
1810
|
-
declare function hasPublicTransfer(data: SuiObjectResponse | SuiObjectData): boolean;
|
|
1811
1767
|
|
|
1812
1768
|
/**
|
|
1813
1769
|
* Converts an amount to a decimal value, based on the number of decimals specified.
|
|
@@ -1839,19 +1795,20 @@ declare function asIntN(int: bigint, bits?: number): number;
|
|
|
1839
1795
|
declare function fromDecimalsAmount(amount: number | string, decimals: number | string): number;
|
|
1840
1796
|
/**
|
|
1841
1797
|
* Converts a secret key in string or Uint8Array format to an Ed25519 key pair.
|
|
1842
|
-
* @param {string|Uint8Array}
|
|
1798
|
+
* @param {string|Uint8Array} secret_key - The secret key to convert.
|
|
1843
1799
|
* @param {string} ecode - The encoding of the secret key ('hex' or 'base64'). Defaults to 'hex'.
|
|
1844
1800
|
* @returns {Ed25519Keypair} - Returns the Ed25519 key pair.
|
|
1845
1801
|
*/
|
|
1846
|
-
declare function secretKeyToEd25519Keypair(
|
|
1802
|
+
declare function secretKeyToEd25519Keypair(secret_key: string | Uint8Array, ecode?: 'hex' | 'base64'): Ed25519Keypair;
|
|
1847
1803
|
/**
|
|
1848
1804
|
* Converts a secret key in string or Uint8Array format to a Secp256k1 key pair.
|
|
1849
|
-
* @param {string|Uint8Array}
|
|
1805
|
+
* @param {string|Uint8Array} secret_key - The secret key to convert.
|
|
1850
1806
|
* @param {string} ecode - The encoding of the secret key ('hex' or 'base64'). Defaults to 'hex'.
|
|
1851
1807
|
* @returns {Ed25519Keypair} - Returns the Secp256k1 key pair.
|
|
1852
1808
|
*/
|
|
1853
|
-
declare function secretKeyToSecp256k1Keypair(
|
|
1809
|
+
declare function secretKeyToSecp256k1Keypair(secret_key: string | Uint8Array, ecode?: 'hex' | 'base64'): Secp256k1Keypair;
|
|
1854
1810
|
declare const sleepTime: (s: number) => Promise<unknown>;
|
|
1811
|
+
declare function printTransaction(tx: Transaction, is_print?: boolean): Promise<void>;
|
|
1855
1812
|
|
|
1856
1813
|
declare const calculateRiskRatio: ({ totalAssetsValue, totalDebtValue }: {
|
|
1857
1814
|
totalAssetsValue: string;
|
|
@@ -1984,77 +1941,29 @@ declare const SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000
|
|
|
1984
1941
|
* This class provides helper methods for working with coins.
|
|
1985
1942
|
*/
|
|
1986
1943
|
declare class CoinAssist {
|
|
1987
|
-
/**
|
|
1988
|
-
* Get the coin type argument from a SuiMoveObject.
|
|
1989
|
-
*
|
|
1990
|
-
* @param obj The SuiMoveObject to get the coin type argument from.
|
|
1991
|
-
* @returns The coin type argument, or null if it is not found.
|
|
1992
|
-
*/
|
|
1993
|
-
static getCoinTypeArg(obj: SuiMoveObject): string | null;
|
|
1994
|
-
/**
|
|
1995
|
-
* Get whether a SuiMoveObject is a SUI coin.
|
|
1996
|
-
*
|
|
1997
|
-
* @param obj The SuiMoveObject to check.
|
|
1998
|
-
* @returns Whether the SuiMoveObject is a SUI coin.
|
|
1999
|
-
*/
|
|
2000
|
-
static isSUI(obj: SuiMoveObject): boolean;
|
|
2001
|
-
/**
|
|
2002
|
-
* Get the coin symbol from a coin type argument.
|
|
2003
|
-
*
|
|
2004
|
-
* @param coinTypeArg The coin type argument to get the symbol from.
|
|
2005
|
-
* @returns The coin symbol.
|
|
2006
|
-
*/
|
|
2007
|
-
static getCoinSymbol(coinTypeArg: string): string;
|
|
2008
|
-
/**
|
|
2009
|
-
* Get the balance of a SuiMoveObject.
|
|
2010
|
-
*
|
|
2011
|
-
* @param obj The SuiMoveObject to get the balance from.
|
|
2012
|
-
* @returns The balance of the SuiMoveObject.
|
|
2013
|
-
*/
|
|
2014
|
-
static getBalance(obj: SuiMoveObject): bigint;
|
|
2015
1944
|
/**
|
|
2016
1945
|
* Get the total balance of a list of CoinAsset objects for a given coin address.
|
|
2017
1946
|
*
|
|
2018
1947
|
* @param objs The list of CoinAsset objects to get the total balance for.
|
|
2019
|
-
* @param
|
|
1948
|
+
* @param coin_address The coin address to get the total balance for.
|
|
2020
1949
|
* @returns The total balance of the CoinAsset objects for the given coin address.
|
|
2021
1950
|
*/
|
|
2022
|
-
static totalBalance(objs: CoinAsset[],
|
|
2023
|
-
/**
|
|
2024
|
-
* Get the ID of a SuiMoveObject.
|
|
2025
|
-
*
|
|
2026
|
-
* @param obj The SuiMoveObject to get the ID from.
|
|
2027
|
-
* @returns The ID of the SuiMoveObject.
|
|
2028
|
-
*/
|
|
2029
|
-
static getID(obj: SuiMoveObject): string;
|
|
2030
|
-
/**
|
|
2031
|
-
* Get the coin type from a coin type argument.
|
|
2032
|
-
*
|
|
2033
|
-
* @param coinTypeArg The coin type argument to get the coin type from.
|
|
2034
|
-
* @returns The coin type.
|
|
2035
|
-
*/
|
|
2036
|
-
static getCoinTypeFromArg(coinTypeArg: string): string;
|
|
2037
|
-
/**
|
|
2038
|
-
* Get the FaucetCoin objects from a SuiTransactionBlockResponse.
|
|
2039
|
-
*
|
|
2040
|
-
* @param suiTransactionResponse The SuiTransactionBlockResponse to get the FaucetCoin objects from.
|
|
2041
|
-
* @returns The FaucetCoin objects.
|
|
2042
|
-
*/
|
|
1951
|
+
static totalBalance(objs: CoinAsset[], coin_address: SuiAddressType): bigint;
|
|
2043
1952
|
/**
|
|
2044
1953
|
* Get the CoinAsset objects for a given coin type.
|
|
2045
1954
|
*
|
|
2046
|
-
* @param
|
|
2047
|
-
* @param
|
|
1955
|
+
* @param coin_type The coin type to get the CoinAsset objects for.
|
|
1956
|
+
* @param all_sui_objects The list of all SuiMoveObjects.
|
|
2048
1957
|
* @returns The CoinAsset objects for the given coin type.
|
|
2049
1958
|
*/
|
|
2050
|
-
static getCoinAssets(
|
|
1959
|
+
static getCoinAssets(coin_type: string, all_sui_objects: CoinAsset[]): CoinAsset[];
|
|
2051
1960
|
/**
|
|
2052
1961
|
* Get whether a coin address is a SUI coin.
|
|
2053
1962
|
*
|
|
2054
|
-
* @param
|
|
1963
|
+
* @param coin_address The coin address to check.
|
|
2055
1964
|
* @returns Whether the coin address is a SUI coin.
|
|
2056
1965
|
*/
|
|
2057
|
-
static isSuiCoin(
|
|
1966
|
+
static isSuiCoin(coin_address: SuiAddressType): boolean;
|
|
2058
1967
|
/**
|
|
2059
1968
|
* Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
|
|
2060
1969
|
*
|
|
@@ -2064,9 +1973,9 @@ declare class CoinAssist {
|
|
|
2064
1973
|
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
2065
1974
|
*/
|
|
2066
1975
|
static selectCoinObjectIdGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
1976
|
+
object_array: string[];
|
|
1977
|
+
remain_coins: CoinAsset[];
|
|
1978
|
+
amount_array: string[];
|
|
2070
1979
|
};
|
|
2071
1980
|
/**
|
|
2072
1981
|
* Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
|
|
@@ -2077,8 +1986,8 @@ declare class CoinAssist {
|
|
|
2077
1986
|
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
2078
1987
|
*/
|
|
2079
1988
|
static selectCoinAssetGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
|
|
2080
|
-
|
|
2081
|
-
|
|
1989
|
+
selected_coins: CoinAsset[];
|
|
1990
|
+
remain_coins: CoinAsset[];
|
|
2082
1991
|
};
|
|
2083
1992
|
/**
|
|
2084
1993
|
* Sort the CoinAsset objects by their balance.
|
|
@@ -2095,7 +2004,21 @@ declare class CoinAssist {
|
|
|
2095
2004
|
* @returns The total balance of the CoinAsset objects.
|
|
2096
2005
|
*/
|
|
2097
2006
|
static calculateTotalBalance(coins: CoinAsset[]): bigint;
|
|
2007
|
+
static buildCoinForAmount(tx: Transaction, all_coins: CoinAsset[], amount: bigint, coin_type: string, build_vector?: boolean, fix_amount?: boolean): BuildCoinResult;
|
|
2098
2008
|
static buildCoinWithBalance(amount: bigint, coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2009
|
+
private static buildVectorCoin;
|
|
2010
|
+
private static buildOneCoin;
|
|
2011
|
+
private static buildSpitTargeCoin;
|
|
2012
|
+
private static buildCoin;
|
|
2013
|
+
private static buildZeroValueCoin;
|
|
2014
|
+
static buildCoinForAmountInterval(tx: Transaction, all_coins: CoinAsset[], amounts: CoinInputInterval, coin_type: string, build_vector?: boolean, fix_amount?: boolean): BuildCoinResult;
|
|
2015
|
+
static callMintZeroValueCoin: (txb: Transaction, coin_type: string) => _mysten_sui_transactions.TransactionResult;
|
|
2016
|
+
static fromBalance(balance: TransactionObjectArgument, coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2017
|
+
static intoBalance(coin_obj: TransactionObjectArgument | string, coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2018
|
+
static mintBalanceZero(coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2019
|
+
static destroyBalanceZero(balance: TransactionObjectArgument, coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2020
|
+
static getCoinAmountObjId(coin_input: MultiCoinInput, amount: string): TransactionObjectArgument;
|
|
2021
|
+
static buildMultiCoinInput(tx: Transaction, all_coin_assets: CoinAsset[], coin_type: string, amount_arr: bigint[]): MultiCoinInput;
|
|
2099
2022
|
}
|
|
2100
2023
|
|
|
2101
|
-
export { AddConditionalOrderOptions,
|
|
2024
|
+
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 };
|