@cetusprotocol/deepbook-utils 1.4.1 → 1.4.3
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/dist/index.d.ts +54 -70
- package/dist/index.js +44 -2
- package/package.json +21 -13
- package/tsup.config.js +9 -20
- package/dist/index.mjs +0 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PythPriceModule as PythPriceModule$1, FullClient } from '@cetusprotocol/common-sdk';
|
|
2
2
|
import { SuiGraphQLClient } from '@mysten/sui/graphql';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
3
|
+
import { SuiTransactionBlockResponse, CoinBalance, SuiObjectResponse, SuiObjectData, SuiObjectRef, OwnedObjectRef, SuiMoveObject, ObjectOwner, DisplayFieldsResponse, SuiParsedData } from '@mysten/sui/jsonRpc';
|
|
4
|
+
import * as _mysten_sui_transactions from '@mysten/sui/transactions';
|
|
5
|
+
import { TransactionArgument, Transaction, TransactionObjectArgument, TransactionResult } from '@mysten/sui/transactions';
|
|
6
|
+
import Decimal from 'decimal.js';
|
|
6
7
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
7
8
|
import { Secp256k1Keypair } from '@mysten/sui/keypairs/secp256k1';
|
|
8
|
-
import Decimal from 'decimal.js';
|
|
9
9
|
|
|
10
10
|
interface IModule {
|
|
11
11
|
readonly sdk: DeepbookUtilsSDK;
|
|
@@ -424,7 +424,7 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
424
424
|
amountToWithdraw: string;
|
|
425
425
|
returnAssets?: boolean;
|
|
426
426
|
txb?: Transaction;
|
|
427
|
-
}): Transaction |
|
|
427
|
+
}): Transaction | _mysten_sui_transactions.TransactionResult;
|
|
428
428
|
/**
|
|
429
429
|
* Withdraws free balances from multiple managers into the owner account.
|
|
430
430
|
*/
|
|
@@ -527,7 +527,7 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
527
527
|
/**
|
|
528
528
|
* Builds coin assets for the requested amount, sourcing from the owner's coins.
|
|
529
529
|
*/
|
|
530
|
-
getCoinAssets(coin: string, amount: string,
|
|
530
|
+
getCoinAssets(coin: string, amount: string, txb: any): TransactionObjectArgument;
|
|
531
531
|
/**
|
|
532
532
|
* Retrieves balances related to an upcoming transaction to determine deposit needs.
|
|
533
533
|
*/
|
|
@@ -539,7 +539,7 @@ declare class DeepbookUtilsModule implements IModule {
|
|
|
539
539
|
/**
|
|
540
540
|
* Determines the fee asset to use and whether additional deposits are required.
|
|
541
541
|
*/
|
|
542
|
-
getFeeAsset(maxFee: string, feeCoin: string, baseAmount: string, quoteAmount: string, feeManaerBalance: string, quoteIsDeep: boolean, baseIsDeep: boolean,
|
|
542
|
+
getFeeAsset(maxFee: string, feeCoin: string, baseAmount: string, quoteAmount: string, feeManaerBalance: string, quoteIsDeep: boolean, baseIsDeep: boolean, payWithDeep: boolean, txb: Transaction): {
|
|
543
543
|
feeAsset: any;
|
|
544
544
|
haveDepositFee: string;
|
|
545
545
|
};
|
|
@@ -741,9 +741,8 @@ type Price = {
|
|
|
741
741
|
};
|
|
742
742
|
declare class PythPriceModule implements IModule {
|
|
743
743
|
protected _sdk: DeepbookUtilsSDK;
|
|
744
|
-
protected connection: SuiPriceServiceConnection;
|
|
745
|
-
protected suiPythClient: SuiPythClient;
|
|
746
744
|
protected hasChangeConnection: boolean;
|
|
745
|
+
protected _commonPythPrice: PythPriceModule$1;
|
|
747
746
|
private readonly _cache;
|
|
748
747
|
constructor(sdk: DeepbookUtilsSDK);
|
|
749
748
|
get sdk(): DeepbookUtilsSDK;
|
|
@@ -807,23 +806,23 @@ declare class MarginUtilsModule implements IModule {
|
|
|
807
806
|
createAndShareMarginManager(poolInfo: MarginPoolInfo, tx?: Transaction): {
|
|
808
807
|
tx: Transaction;
|
|
809
808
|
margin_manager: {
|
|
810
|
-
$kind: "NestedResult";
|
|
811
809
|
NestedResult: [number, number];
|
|
810
|
+
$kind: "NestedResult";
|
|
812
811
|
};
|
|
813
812
|
initializer: {
|
|
814
|
-
$kind: "NestedResult";
|
|
815
813
|
NestedResult: [number, number];
|
|
814
|
+
$kind: "NestedResult";
|
|
816
815
|
};
|
|
817
816
|
};
|
|
818
817
|
createMarginManager(poolInfo: MarginPoolInfo, tx?: Transaction): {
|
|
819
818
|
tx: Transaction;
|
|
820
819
|
margin_manager: {
|
|
821
|
-
$kind: "NestedResult";
|
|
822
820
|
NestedResult: [number, number];
|
|
821
|
+
$kind: "NestedResult";
|
|
823
822
|
};
|
|
824
823
|
initializer: {
|
|
825
|
-
$kind: "NestedResult";
|
|
826
824
|
NestedResult: [number, number];
|
|
825
|
+
$kind: "NestedResult";
|
|
827
826
|
};
|
|
828
827
|
};
|
|
829
828
|
shareMarginManager({ marginManager, initializer, baseCoin, quoteCoin, }: {
|
|
@@ -995,6 +994,34 @@ declare class MarginUtilsModule implements IModule {
|
|
|
995
994
|
lowestTriggerAbovePrice: bigint;
|
|
996
995
|
highestTriggerBelowPrice: bigint;
|
|
997
996
|
}>;
|
|
997
|
+
/**
|
|
998
|
+
* Detects whether `price` is exactly on the tolerance boundary used by margin price checks.
|
|
999
|
+
*
|
|
1000
|
+
* Mapping (from `getManagerState`):
|
|
1001
|
+
* - For bids (`is_bid=true`): the relevant boundary is `lowestTriggerAbovePrice` (upper bound).
|
|
1002
|
+
* - For asks (`is_bid=false`): the relevant boundary is `highestTriggerBelowPrice` (lower bound).
|
|
1003
|
+
*
|
|
1004
|
+
* NOTE: `price` must be in the same scaled `u64` units used by the on-chain margin module.
|
|
1005
|
+
*/
|
|
1006
|
+
detectPriceBoundary({ account, marginManager, baseCoin, quoteCoin, pool, baseMarginPool, quoteMarginPool, price, is_bid, decimals, }: {
|
|
1007
|
+
account: string;
|
|
1008
|
+
marginManager: string;
|
|
1009
|
+
baseCoin: MarginCoinInfo;
|
|
1010
|
+
quoteCoin: MarginCoinInfo;
|
|
1011
|
+
pool: string;
|
|
1012
|
+
baseMarginPool: string;
|
|
1013
|
+
quoteMarginPool: string;
|
|
1014
|
+
price: bigint | string | number;
|
|
1015
|
+
is_bid: boolean;
|
|
1016
|
+
decimals?: number;
|
|
1017
|
+
}): Promise<{
|
|
1018
|
+
is_bid: boolean;
|
|
1019
|
+
price: bigint;
|
|
1020
|
+
lower_bound: bigint;
|
|
1021
|
+
upper_bound: bigint;
|
|
1022
|
+
is_within: boolean;
|
|
1023
|
+
is_boundary: boolean;
|
|
1024
|
+
}>;
|
|
998
1025
|
/**
|
|
999
1026
|
* Calculates the current assets (base and quote) for a margin manager.
|
|
1000
1027
|
*
|
|
@@ -1511,57 +1538,14 @@ declare class MarginUtilsModule implements IModule {
|
|
|
1511
1538
|
getConditionalOrders(options: GetConditionalOrdersOptions[], tx: Transaction): Promise<ConditionalOrder[]>;
|
|
1512
1539
|
getConditionalOrderIds(options: GetConditionalIdsOptions[], tx?: Transaction): Promise<Record<string, GetConditionalOrderIdsResponse>>;
|
|
1513
1540
|
private normalizeConditionalOrder;
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
* @param query
|
|
1523
|
-
* @param paginationArgs
|
|
1524
|
-
* @returns
|
|
1525
|
-
*/
|
|
1526
|
-
queryEventsByPage(query: SuiEventFilter, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
|
|
1527
|
-
/**
|
|
1528
|
-
* Get all objects owned by an address
|
|
1529
|
-
* @param owner
|
|
1530
|
-
* @param query
|
|
1531
|
-
* @param paginationArgs
|
|
1532
|
-
* @returns
|
|
1533
|
-
*/
|
|
1534
|
-
getOwnedObjectsByPage(owner: string, query: SuiObjectResponseQuery, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
|
|
1535
|
-
/**
|
|
1536
|
-
* Return the list of dynamic field objects owned by an object
|
|
1537
|
-
* @param parentId
|
|
1538
|
-
* @param paginationArgs
|
|
1539
|
-
* @returns
|
|
1540
|
-
*/
|
|
1541
|
-
getDynamicFieldsByPage(parentId: SuiObjectIdType, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
|
|
1542
|
-
/**
|
|
1543
|
-
* Batch get details about a list of objects. If any of the object ids are duplicates the call will fail
|
|
1544
|
-
* @param ids
|
|
1545
|
-
* @param options
|
|
1546
|
-
* @param limit
|
|
1547
|
-
* @returns
|
|
1548
|
-
*/
|
|
1549
|
-
batchGetObjects(ids: SuiObjectIdType[], options?: SuiObjectDataOptions, limit?: number): Promise<any[]>;
|
|
1550
|
-
/**
|
|
1551
|
-
* Calculates the gas cost of a transaction block.
|
|
1552
|
-
* @param {Transaction} tx - The transaction block to calculate gas for.
|
|
1553
|
-
* @returns {Promise<number>} - The estimated gas cost of the transaction block.
|
|
1554
|
-
* @throws {Error} - Throws an error if the sender is empty.
|
|
1555
|
-
*/
|
|
1556
|
-
calculationTxGas(tx: Transaction): Promise<number>;
|
|
1557
|
-
/**
|
|
1558
|
-
* Sends a transaction block after signing it with the provided keypair.
|
|
1559
|
-
*
|
|
1560
|
-
* @param {Ed25519Keypair | Secp256k1Keypair} keypair - The keypair used for signing the transaction.
|
|
1561
|
-
* @param {Transaction} tx - The transaction block to send.
|
|
1562
|
-
* @returns {Promise<SuiTransactionBlockResponse | undefined>} - The response of the sent transaction block.
|
|
1563
|
-
*/
|
|
1564
|
-
sendTransaction(keypair: Ed25519Keypair | Secp256k1Keypair, tx: Transaction): Promise<SuiTransactionBlockResponse | undefined>;
|
|
1541
|
+
getPoolsPriceBounds(poolInfos: {
|
|
1542
|
+
poolId: string;
|
|
1543
|
+
baseDecimals: number;
|
|
1544
|
+
quoteDecimals: number;
|
|
1545
|
+
}[]): Promise<{
|
|
1546
|
+
priceBounds: any;
|
|
1547
|
+
priceBoundsMap: Map<string, any>;
|
|
1548
|
+
}>;
|
|
1565
1549
|
}
|
|
1566
1550
|
|
|
1567
1551
|
/**
|
|
@@ -1628,7 +1612,7 @@ declare class DeepbookUtilsSDK {
|
|
|
1628
1612
|
/**
|
|
1629
1613
|
* RPC provider on the SUI chain
|
|
1630
1614
|
*/
|
|
1631
|
-
protected _rpcModule:
|
|
1615
|
+
protected _rpcModule: FullClient;
|
|
1632
1616
|
protected _deepbookUtils: any;
|
|
1633
1617
|
protected _marginUtils: any;
|
|
1634
1618
|
protected _pythPrice: PythPriceModule;
|
|
@@ -1657,9 +1641,9 @@ declare class DeepbookUtilsSDK {
|
|
|
1657
1641
|
get PythPrice(): PythPriceModule;
|
|
1658
1642
|
/**
|
|
1659
1643
|
* Getter for the fullClient property.
|
|
1660
|
-
* @returns {
|
|
1644
|
+
* @returns {FullClient} The fullClient property value.
|
|
1661
1645
|
*/
|
|
1662
|
-
get fullClient():
|
|
1646
|
+
get fullClient(): FullClient;
|
|
1663
1647
|
get graphqlClient(): SuiGraphQLClient;
|
|
1664
1648
|
/**
|
|
1665
1649
|
* Getter for the sdkOptions property.
|
|
@@ -1796,7 +1780,7 @@ declare class TransactionUtil {
|
|
|
1796
1780
|
private static buildCoin;
|
|
1797
1781
|
private static buildZeroValueCoin;
|
|
1798
1782
|
static buildCoinForAmountInterval(tx: Transaction, allCoins: CoinAsset[], amounts: CoinInputInterval, coinType: string, buildVector?: boolean): BuildCoinResult;
|
|
1799
|
-
static callMintZeroValueCoin: (txb: Transaction, coinType: string) =>
|
|
1783
|
+
static callMintZeroValueCoin: (txb: Transaction, coinType: string) => _mysten_sui_transactions.TransactionResult;
|
|
1800
1784
|
static buildCoinTypePair(coinTypes: string[], partitionQuantities: number[]): string[][];
|
|
1801
1785
|
}
|
|
1802
1786
|
|
|
@@ -2114,4 +2098,4 @@ declare class CoinAssist {
|
|
|
2114
2098
|
static buildCoinWithBalance(amount: bigint, coin_type: string, tx: Transaction): TransactionObjectArgument;
|
|
2115
2099
|
}
|
|
2116
2100
|
|
|
2117
|
-
export { AddConditionalOrderOptions, AdjustResult, Balances, BigNumber, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CancelAllConditionalOrdersOptions, CancelConditionalOrdersOptions, DeepbookUtilsSDK as CetusClmmSDK, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, 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, FLOAT_SCALAR, FLOAT_SCALING, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, GetConditionalIdsOptions, GetConditionalOrderIdsResponse, GetConditionalOrdersOptions, InterestConfig, MarginCoinInfo, MarginPoolConfig, MarginPoolInfo, MarginUtilsModule, NFT, NORMALIZED_SUI_COIN_TYPE, OrderDeepPrice, OrderFee, OrderType, Package, PageQuery, PaginationArgs, PendingLimitOrderOptions, PendingMarketOrderOptions, PendingOrder, PoolInfo, PoolState,
|
|
2101
|
+
export { AddConditionalOrderOptions, AdjustResult, Balances, BigNumber, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CancelAllConditionalOrdersOptions, CancelConditionalOrdersOptions, DeepbookUtilsSDK as CetusClmmSDK, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, 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, FLOAT_SCALAR, FLOAT_SCALING, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, GetConditionalIdsOptions, GetConditionalOrderIdsResponse, GetConditionalOrdersOptions, InterestConfig, MarginCoinInfo, MarginPoolConfig, MarginPoolInfo, MarginUtilsModule, 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, TransactionUtil, 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, getMoveObjectType, getMovePackageContent, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getSuiObjectData, hasPublicTransfer, hexToNumber, hexToString, isSortedSymbols, isSuiObjectResponse, maxDecimal, mulRoundUp, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, sleepTime, toBuffer, toDecimalsAmount, utf8to16, wrapDeepBookMarginPoolInfo, wrapDeepBookPoolInfo };
|