@cetusprotocol/dlmm-sdk 1.2.9 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +127 -44
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CoinPairType, TableHandle, IModule, PaginationArgs, DataPage, PageQuery, SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
1
|
+
import { CoinPairType, TableHandle, IModule, RpcRequestOptions, PaginationArgs, DataPage, PageQuery, SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
2
2
|
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
3
3
|
import Decimal from 'decimal.js';
|
|
4
4
|
import * as _mysten_sui_bcs from '@mysten/sui/bcs';
|
|
5
|
-
import { SuiEvent
|
|
5
|
+
import { SuiEvent } from '@mysten/sui/jsonRpc';
|
|
6
6
|
import BN from 'bn.js';
|
|
7
7
|
|
|
8
8
|
type DlmmConfigs = {
|
|
@@ -102,6 +102,8 @@ type BinAmount = {
|
|
|
102
102
|
amount_a: string;
|
|
103
103
|
amount_b: string;
|
|
104
104
|
liquidity?: string;
|
|
105
|
+
/** Q64.64 stored price when read from chain; predicted V2 price when the group does not exist yet. */
|
|
106
|
+
price?: string;
|
|
105
107
|
price_per_lamport: string;
|
|
106
108
|
};
|
|
107
109
|
type BinLiquidityInfo = {
|
|
@@ -109,6 +111,17 @@ type BinLiquidityInfo = {
|
|
|
109
111
|
amount_a: string;
|
|
110
112
|
amount_b: string;
|
|
111
113
|
};
|
|
114
|
+
type BinIdBoundary = {
|
|
115
|
+
/** Inclusive V2 price-valid interval for a single bin. */
|
|
116
|
+
minPriceBinId: number;
|
|
117
|
+
maxPriceBinId: number;
|
|
118
|
+
/** Inclusive group interval whose complete 16-bin endpoints are V2-valid. */
|
|
119
|
+
minGroupIndex: number;
|
|
120
|
+
maxGroupIndex: number;
|
|
121
|
+
/** Inclusive bin-id interval for newly creatable groups. Use this for new positions. */
|
|
122
|
+
minCreatableBinId: number;
|
|
123
|
+
maxCreatableBinId: number;
|
|
124
|
+
};
|
|
112
125
|
declare enum StrategyType {
|
|
113
126
|
Spot = 0,
|
|
114
127
|
Curve = 1,
|
|
@@ -423,19 +436,19 @@ declare class PoolModule implements IModule<CetusDlmmSDK> {
|
|
|
423
436
|
protected _sdk: CetusDlmmSDK;
|
|
424
437
|
constructor(sdk: CetusDlmmSDK);
|
|
425
438
|
get sdk(): CetusDlmmSDK;
|
|
426
|
-
getPoolAddress(coin_type_a: string, coin_type_b: string, bin_step: number, base_factor: number): Promise<string | undefined>;
|
|
439
|
+
getPoolAddress(coin_type_a: string, coin_type_b: string, bin_step: number, base_factor: number, requestOptions?: RpcRequestOptions): Promise<string | undefined>;
|
|
427
440
|
/**
|
|
428
441
|
* Get the list of DLMM base pools
|
|
429
442
|
* @param pagination_args - The pagination arguments
|
|
430
443
|
* @returns The list of DLMM base pools
|
|
431
444
|
*/
|
|
432
|
-
getBasePoolList(pagination_args?: PaginationArgs, force_refresh?: boolean): Promise<DataPage<DlmmBasePool>>;
|
|
445
|
+
getBasePoolList(pagination_args?: PaginationArgs, force_refresh?: boolean, requestOptions?: RpcRequestOptions): Promise<DataPage<DlmmBasePool>>;
|
|
433
446
|
/**
|
|
434
447
|
* Get the list of DLMM pools
|
|
435
448
|
* @param pagination_args - The pagination arguments
|
|
436
449
|
* @returns The list of DLMM pools
|
|
437
450
|
*/
|
|
438
|
-
getPools(pagination_args?: PaginationArgs, force_refresh?: boolean): Promise<DataPage<DlmmPool>>;
|
|
451
|
+
getPools(pagination_args?: PaginationArgs, force_refresh?: boolean, requestOptions?: RpcRequestOptions): Promise<DataPage<DlmmPool>>;
|
|
439
452
|
/**
|
|
440
453
|
* Get the bin info by bin id
|
|
441
454
|
* @param bin_manager_handle - The bin manager handle
|
|
@@ -444,16 +457,17 @@ declare class PoolModule implements IModule<CetusDlmmSDK> {
|
|
|
444
457
|
* @param force_refresh - Whether to force a refresh of the cache
|
|
445
458
|
* @returns The bin info
|
|
446
459
|
*/
|
|
447
|
-
getBinInfo(bin_manager_handle: string, bin_id: number, bin_step: number, force_refresh?: boolean): Promise<BinAmount>;
|
|
448
|
-
getBinInfoList(options: GetBinInfoOption[]): Promise<GetBinInfoResult[]>;
|
|
449
|
-
getTotalFeeRate(option: GetTotalFeeRateOption): Promise<FeeRate>;
|
|
450
|
-
getPoolBinInfo(option: GetPoolBinInfoOption): Promise<BinAmount[]>;
|
|
451
|
-
getPoolTransactionList({ pool_id, pagination_args, order, full_rpc_url, }: {
|
|
460
|
+
getBinInfo(bin_manager_handle: string, bin_id: number, bin_step: number, force_refresh?: boolean, requestOptions?: RpcRequestOptions): Promise<BinAmount>;
|
|
461
|
+
getBinInfoList(options: GetBinInfoOption[], requestOptions?: RpcRequestOptions): Promise<GetBinInfoResult[]>;
|
|
462
|
+
getTotalFeeRate(option: GetTotalFeeRateOption, requestOptions?: RpcRequestOptions): Promise<FeeRate>;
|
|
463
|
+
getPoolBinInfo(option: GetPoolBinInfoOption, requestOptions?: RpcRequestOptions): Promise<BinAmount[]>;
|
|
464
|
+
getPoolTransactionList({ pool_id, pagination_args, order, full_rpc_url, event_types, }: {
|
|
452
465
|
pool_id: string;
|
|
453
466
|
full_rpc_url?: string;
|
|
454
467
|
pagination_args: PageQuery;
|
|
455
468
|
order?: 'ascending' | 'descending' | null | undefined;
|
|
456
|
-
|
|
469
|
+
event_types?: string[];
|
|
470
|
+
}, requestOptions?: RpcRequestOptions): Promise<DataPage<PoolTransactionInfo>>;
|
|
457
471
|
/**
|
|
458
472
|
* Get the bin info by range (TODO: need to optimize this method)
|
|
459
473
|
* @param bin_manager_handle - The bin manager handle
|
|
@@ -462,20 +476,20 @@ declare class PoolModule implements IModule<CetusDlmmSDK> {
|
|
|
462
476
|
* @param bin_step - The bin step
|
|
463
477
|
* @returns The bin info by range
|
|
464
478
|
*/
|
|
465
|
-
getRangeBinInfo(bin_manager_handle: string, lower_bin_id: number, upper_bin_id: number, bin_step: number): Promise<BinAmount[]>;
|
|
479
|
+
getRangeBinInfo(bin_manager_handle: string, lower_bin_id: number, upper_bin_id: number, bin_step: number, requestOptions?: RpcRequestOptions): Promise<BinAmount[]>;
|
|
466
480
|
/**
|
|
467
481
|
* Get the list of DLMM pools by assign pool ids
|
|
468
482
|
* @param assign_pool_ids - The assign pool ids
|
|
469
483
|
* @returns The list of DLMM pools
|
|
470
484
|
*/
|
|
471
|
-
getAssignPoolList(assign_pool_ids: string[]): Promise<DlmmPool[]>;
|
|
485
|
+
getAssignPoolList(assign_pool_ids: string[], requestOptions?: RpcRequestOptions): Promise<DlmmPool[]>;
|
|
472
486
|
/**
|
|
473
487
|
* Get a DLMM pool by its object ID.
|
|
474
488
|
* @param {string} pool_id The object ID of the pool to get.
|
|
475
489
|
* @param {true} force_refresh Whether to force a refresh of the cache.
|
|
476
490
|
* @returns {Promise<DlmmPool>} A promise that resolves to a DlmmPool object.
|
|
477
491
|
*/
|
|
478
|
-
getPool(pool_id: string, force_refresh?: boolean): Promise<DlmmPool>;
|
|
492
|
+
getPool(pool_id: string, force_refresh?: boolean, requestOptions?: RpcRequestOptions): Promise<DlmmPool>;
|
|
479
493
|
/**
|
|
480
494
|
* Create a pool and add liquidity with a given price
|
|
481
495
|
* @param option - The option for creating a pool and adding liquidity with a given price
|
|
@@ -502,8 +516,8 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
502
516
|
constructor(sdk: CetusDlmmSDK);
|
|
503
517
|
get sdk(): CetusDlmmSDK;
|
|
504
518
|
buildPositionType(): string;
|
|
505
|
-
getOwnerPositionList(owner: string): Promise<DlmmPosition[]>;
|
|
506
|
-
getPosition(position_id: string): Promise<DlmmPosition>;
|
|
519
|
+
getOwnerPositionList(owner: string, requestOptions?: RpcRequestOptions): Promise<DlmmPosition[]>;
|
|
520
|
+
getPosition(position_id: string, requestOptions?: RpcRequestOptions): Promise<DlmmPosition>;
|
|
507
521
|
/**
|
|
508
522
|
* Collect fee
|
|
509
523
|
* @param option - The option for collecting fee
|
|
@@ -570,7 +584,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
570
584
|
* @param active_id - The active id
|
|
571
585
|
* @returns The amounts in the active bin if in range
|
|
572
586
|
*/
|
|
573
|
-
getActiveBinIfInRange(bin_manager_handle: string, lower_bin_id: number, upper_bin_id: number, active_id: number, bin_step: number, force_refresh?: boolean): Promise<BinAmount | undefined>;
|
|
587
|
+
getActiveBinIfInRange(bin_manager_handle: string, lower_bin_id: number, upper_bin_id: number, active_id: number, bin_step: number, force_refresh?: boolean, requestOptions?: RpcRequestOptions): Promise<BinAmount | undefined>;
|
|
574
588
|
/**
|
|
575
589
|
* Calculate the result of removing liquidity
|
|
576
590
|
* @param option - The option for calculating the result of removing liquidity
|
|
@@ -582,7 +596,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
582
596
|
* @param option - The option for calculating the result of adding liquidity
|
|
583
597
|
* @returns The result of adding liquidity
|
|
584
598
|
*/
|
|
585
|
-
calculateAddLiquidityInfo(option: CalculateAddLiquidityOption | CalculateAddLiquidityAutoFillOption): Promise<BinLiquidityInfo>;
|
|
599
|
+
calculateAddLiquidityInfo(option: CalculateAddLiquidityOption | CalculateAddLiquidityAutoFillOption, requestOptions?: RpcRequestOptions): Promise<BinLiquidityInfo>;
|
|
586
600
|
/**
|
|
587
601
|
* Remove liquidity
|
|
588
602
|
* @param option - The option for removing liquidity
|
|
@@ -612,7 +626,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
612
626
|
* @param options - The option for fetching the fee and reward of the position
|
|
613
627
|
* @returns The fee and reward of the position
|
|
614
628
|
*/
|
|
615
|
-
fetchPositionFeeAndReward(options: CollectRewardAndFeeOption[]): Promise<{
|
|
629
|
+
fetchPositionFeeAndReward(options: CollectRewardAndFeeOption[], requestOptions?: RpcRequestOptions): Promise<{
|
|
616
630
|
feeData: Record<string, PositionFee>;
|
|
617
631
|
rewardData: Record<string, PositionReward>;
|
|
618
632
|
}>;
|
|
@@ -622,7 +636,7 @@ declare class SwapModule implements IModule<CetusDlmmSDK> {
|
|
|
622
636
|
protected _sdk: CetusDlmmSDK;
|
|
623
637
|
constructor(sdk: CetusDlmmSDK);
|
|
624
638
|
get sdk(): CetusDlmmSDK;
|
|
625
|
-
preSwapQuote(option: PreSwapOption): Promise<PreSwapQuote>;
|
|
639
|
+
preSwapQuote(option: PreSwapOption, requestOptions?: RpcRequestOptions): Promise<PreSwapQuote>;
|
|
626
640
|
swapPayload(option: SwapOption): Transaction;
|
|
627
641
|
}
|
|
628
642
|
|
|
@@ -634,20 +648,20 @@ declare class PartnerModule implements IModule<CetusDlmmSDK> {
|
|
|
634
648
|
* Get a list of partners.
|
|
635
649
|
* @returns {Promise<Partner[]>} A promise that resolves to an array of Partner objects.
|
|
636
650
|
*/
|
|
637
|
-
getPartnerList(): Promise<Partner[]>;
|
|
651
|
+
getPartnerList(requestOptions?: RpcRequestOptions): Promise<Partner[]>;
|
|
638
652
|
/**
|
|
639
653
|
* Get the partner cap ID for a given owner and partner ID.
|
|
640
654
|
* @param owner - The owner of the partner.
|
|
641
655
|
* @param partner_id - The ID of the partner.
|
|
642
656
|
* @returns A promise that resolves to the partner cap ID or undefined if not found.
|
|
643
657
|
*/
|
|
644
|
-
getPartnerCapId(owner: string, partner_id: string): Promise<string>;
|
|
658
|
+
getPartnerCapId(owner: string, partner_id: string, requestOptions?: RpcRequestOptions): Promise<string>;
|
|
645
659
|
/**
|
|
646
660
|
* Get the balance of a partner
|
|
647
661
|
* @param partner_balance_handle - The handle of the partner balance
|
|
648
662
|
* @returns A promise that resolves to an array of { coin_type: string; balance: string } objects.
|
|
649
663
|
*/
|
|
650
|
-
getPartnerBalance(partner_balance_handle: string): Promise<{
|
|
664
|
+
getPartnerBalance(partner_balance_handle: string, requestOptions?: RpcRequestOptions): Promise<{
|
|
651
665
|
coin_type: string;
|
|
652
666
|
balance: string;
|
|
653
667
|
}[]>;
|
|
@@ -656,7 +670,7 @@ declare class PartnerModule implements IModule<CetusDlmmSDK> {
|
|
|
656
670
|
* @param {string} partner_id The object ID of the partner to get.
|
|
657
671
|
* @returns {Promise<Partner>} A promise that resolves to a Partner object.
|
|
658
672
|
*/
|
|
659
|
-
getPartner(partner_id: string): Promise<Partner>;
|
|
673
|
+
getPartner(partner_id: string, requestOptions?: RpcRequestOptions): Promise<Partner>;
|
|
660
674
|
/**
|
|
661
675
|
* Update the ref fee rate of a partner
|
|
662
676
|
* @param option - The option for updating the ref fee rate
|
|
@@ -682,7 +696,7 @@ declare class RewardModule implements IModule<CetusDlmmSDK> {
|
|
|
682
696
|
protected _sdk: CetusDlmmSDK;
|
|
683
697
|
constructor(sdk: CetusDlmmSDK);
|
|
684
698
|
get sdk(): CetusDlmmSDK;
|
|
685
|
-
getRewardPeriodEmission(period_emission_handle: string, curr_emission_per_second: string, last_updated_time: number): Promise<RewardPeriodEmission[]>;
|
|
699
|
+
getRewardPeriodEmission(period_emission_handle: string, curr_emission_per_second: string, last_updated_time: number, requestOptions?: RpcRequestOptions): Promise<RewardPeriodEmission[]>;
|
|
686
700
|
/**
|
|
687
701
|
* Add reward to a pool
|
|
688
702
|
* @param options - The options for adding reward
|
|
@@ -716,17 +730,17 @@ declare class ConfigModule implements IModule<CetusDlmmSDK> {
|
|
|
716
730
|
* @returns The transaction for adding or removing reward white list
|
|
717
731
|
*/
|
|
718
732
|
buildRewardWhiteListPayload(option: RewardWhiteListOption, tx?: Transaction): Transaction;
|
|
719
|
-
getBinStepConfigList(bin_steps_handle: string): Promise<BinStepConfig[]>;
|
|
733
|
+
getBinStepConfigList(bin_steps_handle: string, requestOptions?: RpcRequestOptions): Promise<BinStepConfig[]>;
|
|
720
734
|
/**
|
|
721
735
|
* Get the list of bin step configs
|
|
722
736
|
* @returns The list of bin step configs
|
|
723
737
|
*/
|
|
724
|
-
getDlmmGlobalConfig(): Promise<DlmmGlobalConfig>;
|
|
738
|
+
getDlmmGlobalConfig(requestOptions?: RpcRequestOptions): Promise<DlmmGlobalConfig>;
|
|
725
739
|
/**
|
|
726
740
|
* Fetch the configs of the dlmm SDK
|
|
727
741
|
* @returns The configs of the dlmm
|
|
728
742
|
*/
|
|
729
|
-
fetchDlmmSdkConfigs(): Promise<DlmmConfigs>;
|
|
743
|
+
fetchDlmmSdkConfigs(requestOptions?: RpcRequestOptions): Promise<DlmmConfigs>;
|
|
730
744
|
}
|
|
731
745
|
|
|
732
746
|
/**
|
|
@@ -782,15 +796,15 @@ declare function parseDlmmBasePool(data: SuiEvent): DlmmBasePool;
|
|
|
782
796
|
declare function parseDlmmPool(data: any): DlmmPool;
|
|
783
797
|
declare function parsePartner(data: any): Partner;
|
|
784
798
|
declare function parseDlmmPosition(data: any): DlmmPosition;
|
|
785
|
-
declare function parseLiquidityShares(liquidity_shares: string[], bin_step: number, lower_bin_id: number, active_bin: BinAmount): BinLiquidityInfo;
|
|
799
|
+
declare function parseLiquidityShares(liquidity_shares: string[], bin_step: number, lower_bin_id: number, active_bin: BinAmount, stored_bins?: BinAmount[]): BinLiquidityInfo;
|
|
786
800
|
declare function parseBinInfoList(res: any): BinAmount[];
|
|
787
801
|
declare function parseBinInfo(fields: any): BinAmount;
|
|
788
802
|
declare function parsedDlmmPosFeeData(events: any[]): Record<string, PositionFee>;
|
|
789
803
|
declare function parsedDlmmPosRewardData(events: any[]): Record<string, PositionReward>;
|
|
790
|
-
declare function parsedSwapQuoteData(simulate_res:
|
|
804
|
+
declare function parsedSwapQuoteData(simulate_res: any, a2b: boolean): PreSwapQuote | undefined;
|
|
791
805
|
declare function parseStrategyType(strategy_type: StrategyType): number;
|
|
792
806
|
declare const poolFilterEvenTypes: string[];
|
|
793
|
-
declare function parsePoolTransactionInfo(rawData: any, txIndex: number, package_id: string, pool_id: string): PoolTransactionInfo[];
|
|
807
|
+
declare function parsePoolTransactionInfo(rawData: any, txIndex: number, package_id: string, pool_id: string, event_types?: string[]): PoolTransactionInfo[];
|
|
794
808
|
declare function generateRewardSchedule(baseTime: number, maxIntervals: number, timeInterval: number): number[];
|
|
795
809
|
declare function parseRewardPeriodEmission(periodEmissionList: RewardPeriodEmission[], startTimeInSeconds: number, endTimeInSeconds: number, durationSeconds: number): RewardPeriodEmissionFormat[];
|
|
796
810
|
declare function parseCurrentRewardPeriodEmission(periodEmissionList: RewardPeriodEmission[]): RewardPeriodEmission | undefined;
|
|
@@ -1034,11 +1048,9 @@ declare class BinUtils {
|
|
|
1034
1048
|
*/
|
|
1035
1049
|
static getBinIdFromPrice(price: string, binStep: number, min: boolean, decimal_a: number, decimal_b: number): number;
|
|
1036
1050
|
/**
|
|
1037
|
-
* Get the bin id from a price per lamport
|
|
1038
|
-
*
|
|
1039
|
-
*
|
|
1040
|
-
* @param min - Whether to use the minimum or maximum bin id
|
|
1041
|
-
* @returns The bin id
|
|
1051
|
+
* Get the bin id from a price per lamport using V2 integer search.
|
|
1052
|
+
* `min=true` floors to the last bin whose predicted price is <= target;
|
|
1053
|
+
* `min=false` ceils to the first bin whose price is >= target.
|
|
1042
1054
|
*/
|
|
1043
1055
|
static getBinIdFromLamportPrice(pricePerLamport: string, binStep: number, min: boolean): number;
|
|
1044
1056
|
/**
|
|
@@ -1064,12 +1076,74 @@ declare class BinUtils {
|
|
|
1064
1076
|
*/
|
|
1065
1077
|
static getReversePrice(price: string): string;
|
|
1066
1078
|
/**
|
|
1067
|
-
*
|
|
1079
|
+
* Closed-form V1 Q64.64 price matching Move `price_math::get_price_from_id`.
|
|
1080
|
+
* New groups store V2 recurrence prices; use `predictBinPrice` / `effectiveBinPrice` for those.
|
|
1068
1081
|
* @param binId - The bin id
|
|
1069
1082
|
* @param binStep - The bin step
|
|
1070
|
-
* @returns The price of the bin
|
|
1083
|
+
* @returns The price of the bin in Q64.64
|
|
1071
1084
|
*/
|
|
1072
1085
|
static getQPriceFromId(binId: number, binStep: number): string;
|
|
1086
|
+
/**
|
|
1087
|
+
* V2 Q64.64 price matching Move `price_math::get_price_from_id_v2`.
|
|
1088
|
+
*/
|
|
1089
|
+
static getQPriceFromIdV2(binId: number, binStep: number): string;
|
|
1090
|
+
/**
|
|
1091
|
+
* Binary exponentiation matching Move `price_math::pow_v2`.
|
|
1092
|
+
*/
|
|
1093
|
+
static powV2(base: BN, exp: number): BN;
|
|
1094
|
+
private static binIdFromGroupOffset;
|
|
1095
|
+
/**
|
|
1096
|
+
* Prices a newly initialized Move bin group would store: one V2 anchor
|
|
1097
|
+
* followed by 15 floor-rounded recurrence steps.
|
|
1098
|
+
*/
|
|
1099
|
+
static calculateGroupPrices(groupIndex: string | number | bigint, binStep: number): string[];
|
|
1100
|
+
/**
|
|
1101
|
+
* Predicts the exact Q64.64 price a missing group would store for `binId`.
|
|
1102
|
+
*/
|
|
1103
|
+
static predictBinPrice(binId: number, binStep: number): string;
|
|
1104
|
+
/**
|
|
1105
|
+
* Returns a stored Q64.64 price when available, otherwise predicts the
|
|
1106
|
+
* price using the new-group initialization path.
|
|
1107
|
+
*/
|
|
1108
|
+
static effectiveBinPrice(binId: number, binStep: number, storedPrice?: string): string;
|
|
1109
|
+
/**
|
|
1110
|
+
* Resolves the Q64.64 price a bin will actually use, plus the lamport price.
|
|
1111
|
+
* Pass `storedPrice` for existing groups so legacy V1 bins are not recomputed.
|
|
1112
|
+
*/
|
|
1113
|
+
static resolveBinPrice(binId: number, binStep: number, storedPrice?: string): {
|
|
1114
|
+
price: string;
|
|
1115
|
+
price_per_lamport: string;
|
|
1116
|
+
};
|
|
1117
|
+
/**
|
|
1118
|
+
* Inclusive individually valid V2 bin-id interval for a configured bin step.
|
|
1119
|
+
*/
|
|
1120
|
+
static validBinIdRangeV2(binStep: number): {
|
|
1121
|
+
minBinId: number;
|
|
1122
|
+
maxBinId: number;
|
|
1123
|
+
};
|
|
1124
|
+
/**
|
|
1125
|
+
* V2 price-valid, group-valid, and creatable bin-id boundaries for a bin step.
|
|
1126
|
+
* New positions should use `minCreatableBinId` / `maxCreatableBinId`.
|
|
1127
|
+
*/
|
|
1128
|
+
static getBinIdBoundary(binStep: number): BinIdBoundary;
|
|
1129
|
+
/**
|
|
1130
|
+
* Inclusive group interval whose complete 16-bin endpoints are V2-valid.
|
|
1131
|
+
*/
|
|
1132
|
+
static validGroupIndexRangeV2(binStep: number): {
|
|
1133
|
+
firstGroup: string;
|
|
1134
|
+
lastGroup: string;
|
|
1135
|
+
};
|
|
1136
|
+
/**
|
|
1137
|
+
* Inclusive bin-id interval corresponding to complete, creatable groups.
|
|
1138
|
+
*/
|
|
1139
|
+
static validGroupBinIdRangeV2(binStep: number): {
|
|
1140
|
+
minBinId: number;
|
|
1141
|
+
maxBinId: number;
|
|
1142
|
+
};
|
|
1143
|
+
/**
|
|
1144
|
+
* New groups / positions must stay inside the creatable interval.
|
|
1145
|
+
*/
|
|
1146
|
+
static assertCreatableBinIds(binStep: number, binIds: number[], methodName?: string): void;
|
|
1073
1147
|
/**
|
|
1074
1148
|
* Convert QPrice (Q64x64 format) to actual price
|
|
1075
1149
|
* @param qPrice - The price in Q64x64 format
|
|
@@ -1119,7 +1193,7 @@ declare class WeightUtils {
|
|
|
1119
1193
|
* @param distributions - weight distribution of each bin
|
|
1120
1194
|
* @returns array of {binId, amount} where amount is the amount of coin b in each bin
|
|
1121
1195
|
*/
|
|
1122
|
-
static toAmountBidSide(active_id: number, amount_b: string, bin_step: number, distributions: BinWeight[], contain_active_bin?: boolean): BinLiquidityInfo;
|
|
1196
|
+
static toAmountBidSide(active_id: number, amount_b: string, bin_step: number, distributions: BinWeight[], contain_active_bin?: boolean, storedPrice?: string): BinLiquidityInfo;
|
|
1123
1197
|
/**
|
|
1124
1198
|
* Distribute totalAmount to all ask side bins according to given distributions.
|
|
1125
1199
|
* @param active_id active bin id
|
|
@@ -1127,7 +1201,7 @@ declare class WeightUtils {
|
|
|
1127
1201
|
* @param distributions weight distribution of each bin
|
|
1128
1202
|
* @returns array of {binId, amount} where amount is the amount of coin a in each bin
|
|
1129
1203
|
*/
|
|
1130
|
-
static toAmountAskSide(active_id: number, bin_step: number, amount_a: string, distributions: BinWeight[], contain_active_bin?: boolean): BinLiquidityInfo;
|
|
1204
|
+
static toAmountAskSide(active_id: number, bin_step: number, amount_a: string, distributions: BinWeight[], contain_active_bin?: boolean, storedPrice?: string): BinLiquidityInfo;
|
|
1131
1205
|
/**
|
|
1132
1206
|
* Distributes the given amounts of tokens X and Y to both bid and ask side bins
|
|
1133
1207
|
* based on the provided weight distributions.
|
|
@@ -1144,7 +1218,7 @@ declare class WeightUtils {
|
|
|
1144
1218
|
* @param clock - Clock instance. Get from DLMM instance.
|
|
1145
1219
|
* @returns An array of objects containing binId, amountX, and amountY for each bin.
|
|
1146
1220
|
*/
|
|
1147
|
-
static toAmountBothSide(active_id: number, bin_step: number, amount_a: string, amount_b: string, amount_a_in_active_bin: string, amount_b_in_active_bin: string, distributions: BinWeight[]): BinLiquidityInfo;
|
|
1221
|
+
static toAmountBothSide(active_id: number, bin_step: number, amount_a: string, amount_b: string, amount_a_in_active_bin: string, amount_b_in_active_bin: string, distributions: BinWeight[], storedPrice?: string): BinLiquidityInfo;
|
|
1148
1222
|
/**
|
|
1149
1223
|
* Distributes the given amount of coin B to both bid and ask side bins
|
|
1150
1224
|
* based on the provided weight distributions.
|
|
@@ -1157,12 +1231,12 @@ declare class WeightUtils {
|
|
|
1157
1231
|
* @param distributions - Array of bins with their respective weight distributions.
|
|
1158
1232
|
* @returns An array of objects containing binId, amountA, and amountB for each bin.
|
|
1159
1233
|
*/
|
|
1160
|
-
static autoFillCoinByWeight(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean, amount_a_in_active_bin: string, amount_b_in_active_bin: string, distributions: BinWeight[]): BinLiquidityInfo;
|
|
1234
|
+
static autoFillCoinByWeight(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean, amount_a_in_active_bin: string, amount_b_in_active_bin: string, distributions: BinWeight[], storedPrice?: string): BinLiquidityInfo;
|
|
1161
1235
|
static calculateActiveWeights(amount_a_in_active_id: string, amount_b_in_active_id: string, active_bin_price: string, base_weight: Decimal): {
|
|
1162
1236
|
active_weight_a: Decimal;
|
|
1163
1237
|
active_weight_b: Decimal;
|
|
1164
1238
|
};
|
|
1165
|
-
static calculateTotalWeights(bin_step: number, distributions: BinWeight[], active_id: number, activeBin?: BinWeight, amount_a_in_active_bin?: string, amount_b_in_active_bin?: string, is_only_amount?: 'a' | 'b'): {
|
|
1239
|
+
static calculateTotalWeights(bin_step: number, distributions: BinWeight[], active_id: number, activeBin?: BinWeight, amount_a_in_active_bin?: string, amount_b_in_active_bin?: string, is_only_amount?: 'a' | 'b', storedPrice?: string): {
|
|
1166
1240
|
totalWeightA: Decimal;
|
|
1167
1241
|
totalWeightB: Decimal;
|
|
1168
1242
|
activeWeightA: Decimal;
|
|
@@ -1191,6 +1265,11 @@ declare class StrategyUtils {
|
|
|
1191
1265
|
}
|
|
1192
1266
|
|
|
1193
1267
|
declare class FeeUtils {
|
|
1268
|
+
/**
|
|
1269
|
+
* Mirrors Move `preview_volatility_parameter`: apply the volatility update
|
|
1270
|
+
* locally without mutating the stored pool parameters.
|
|
1271
|
+
*/
|
|
1272
|
+
static previewVolatilityParameter(variableParameters: VariableParameters, activeId: number, currentTimestamp?: number): VariableParameters;
|
|
1194
1273
|
static getVariableFee(variableParameters: VariableParameters): string;
|
|
1195
1274
|
static calculateCompositionFee(amount: string, total_fee_rate: string): string;
|
|
1196
1275
|
static calculateProtocolFee(fee_amount: string, protocol_fee_rate: string): string;
|
|
@@ -1255,9 +1334,13 @@ declare class IlmUtils {
|
|
|
1255
1334
|
}
|
|
1256
1335
|
|
|
1257
1336
|
declare const MAX_BIN_PER_POSITION = 1000;
|
|
1337
|
+
declare const MAX_BIN_PER_GROUP = 16;
|
|
1338
|
+
/** Structural bin-id bounds. Do not use these as new-group / position limits; use `BinUtils.getBinIdBoundary`. */
|
|
1258
1339
|
declare const MIN_BIN_ID = -443636;
|
|
1259
1340
|
declare const MAX_BIN_ID = 443636;
|
|
1260
1341
|
declare const BASIS_POINT_MAX = 10000;
|
|
1342
|
+
/** Minimum accepted raw Q64.64 price for V2 group recurrence. */
|
|
1343
|
+
declare const MIN_PRICE_Q64_V2 = 16000000;
|
|
1261
1344
|
declare const DEFAULT_MAX_WEIGHT = 2000;
|
|
1262
1345
|
declare const DEFAULT_MIN_WEIGHT = 200;
|
|
1263
1346
|
declare const BIN_BOUND = 443636n;
|
|
@@ -1271,4 +1354,4 @@ declare const dlmmMainnet: SdkOptions;
|
|
|
1271
1354
|
|
|
1272
1355
|
declare const dlmmTestnet: SdkOptions;
|
|
1273
1356
|
|
|
1274
|
-
export { type AddLiquidityOption, type AddRewardOption, type Axis, BASIS_POINT, BASIS_POINT_MAX, BIN_BOUND, type BaseAddLiquidityOption, type BaseCalculateAddLiquidityOption, type BaseCreatePoolAndAddOption, type BaseCreatePoolOption, Bin, type BinAmount, BinGroup, BinGroupRefRaw, type BinLiquidityInfo, type BinManager, type BinStepConfig, type BinSwap, BinUtils, type BinWeight, type CalculateAddLiquidityAutoFillOption, type CalculateAddLiquidityOption, type CalculateRemoveLiquidityBothOption, type CalculateRemoveLiquidityOnlyOption, CetusDlmmSDK, type ClaimRefFeeOption, type ClosePositionOption, type CollectFeeOption, type CollectRewardAndFeeOption, type CollectRewardOption, type CreatePartnerOption, type CreatePoolAndAddOption, type CreatePoolAndAddWithPriceOption, type CreatePoolOption, DEFAULT_MAX_WEIGHT, DEFAULT_MIN_WEIGHT, type DlmmBasePool, type DlmmConfigs, type DlmmGlobalConfig, type DlmmPool, type DlmmPosition, FEE_PRECISION, type FeeRate, FeeUtils, type GetBinInfoOption, type GetBinInfoResult, type GetPoolBinInfoOption, type GetTotalFeeRateOption, type IlmInputOptions, type IlmInputResult, IlmUtils, type InitRewardOption, MAX_BIN_ID, MAX_BIN_PER_POSITION, MAX_FEE_RATE, MIN_BIN_ID, NodeIDPoolSimpleInfo, ONE, type OpenAndAddLiquidityOption, type OpenAndAddLiquidityWithPriceOption, type OpenPositionOption, type Partner, PoolModule, type PoolPermissions, PoolSimpleInfoRaw, type PoolTransactionInfo, type PositionFee, type PositionManager, type PositionReward, type PreSwapOption, type PreSwapQuote, REWARD_PERIOD, REWARD_PERIOD_START_AT, type RemoveLiquidityOption, type Reward, type RewardAccessOption, type RewardInfo, type RewardManager, type RewardPeriodEmission, type RewardPeriodEmissionFormat, type RewardWhiteListOption, SCALE_OFFSET, type SdkOptions, SkipListNodeBinGroupRefRaw, StrategyType, StrategyUtils, type SwapOption, type TokenTable, type UpdatePositionFeeAndRewardsOption, type UpdateRefFeeRateOption, type UpdateTimeRangeOption, type ValidateActiveIdSlippageOption, type VariableParameters, WeightUtils, type WeightsInfo, type WeightsOptions, buildPoolKey, CetusDlmmSDK as default, dlmmMainnet, dlmmTestnet, generateRewardSchedule, getRouterModule, parseBinInfo, parseBinInfoList, parseCurrentRewardPeriodEmission, parseDlmmBasePool, parseDlmmPool, parseDlmmPosition, parseLiquidityShares, parsePartner, parsePoolTransactionInfo, parseRewardPeriodEmission, parseStrategyType, parsedDlmmPosFeeData, parsedDlmmPosRewardData, parsedSwapQuoteData, poolFilterEvenTypes, safeAmount, safeMulAmount };
|
|
1357
|
+
export { type AddLiquidityOption, type AddRewardOption, type Axis, BASIS_POINT, BASIS_POINT_MAX, BIN_BOUND, type BaseAddLiquidityOption, type BaseCalculateAddLiquidityOption, type BaseCreatePoolAndAddOption, type BaseCreatePoolOption, Bin, type BinAmount, BinGroup, BinGroupRefRaw, type BinIdBoundary, type BinLiquidityInfo, type BinManager, type BinStepConfig, type BinSwap, BinUtils, type BinWeight, type CalculateAddLiquidityAutoFillOption, type CalculateAddLiquidityOption, type CalculateRemoveLiquidityBothOption, type CalculateRemoveLiquidityOnlyOption, CetusDlmmSDK, type ClaimRefFeeOption, type ClosePositionOption, type CollectFeeOption, type CollectRewardAndFeeOption, type CollectRewardOption, type CreatePartnerOption, type CreatePoolAndAddOption, type CreatePoolAndAddWithPriceOption, type CreatePoolOption, DEFAULT_MAX_WEIGHT, DEFAULT_MIN_WEIGHT, type DlmmBasePool, type DlmmConfigs, type DlmmGlobalConfig, type DlmmPool, type DlmmPosition, FEE_PRECISION, type FeeRate, FeeUtils, type GetBinInfoOption, type GetBinInfoResult, type GetPoolBinInfoOption, type GetTotalFeeRateOption, type IlmInputOptions, type IlmInputResult, IlmUtils, type InitRewardOption, MAX_BIN_ID, MAX_BIN_PER_GROUP, MAX_BIN_PER_POSITION, MAX_FEE_RATE, MIN_BIN_ID, MIN_PRICE_Q64_V2, NodeIDPoolSimpleInfo, ONE, type OpenAndAddLiquidityOption, type OpenAndAddLiquidityWithPriceOption, type OpenPositionOption, type Partner, PoolModule, type PoolPermissions, PoolSimpleInfoRaw, type PoolTransactionInfo, type PositionFee, type PositionManager, type PositionReward, type PreSwapOption, type PreSwapQuote, REWARD_PERIOD, REWARD_PERIOD_START_AT, type RemoveLiquidityOption, type Reward, type RewardAccessOption, type RewardInfo, type RewardManager, type RewardPeriodEmission, type RewardPeriodEmissionFormat, type RewardWhiteListOption, SCALE_OFFSET, type SdkOptions, SkipListNodeBinGroupRefRaw, StrategyType, StrategyUtils, type SwapOption, type TokenTable, type UpdatePositionFeeAndRewardsOption, type UpdateRefFeeRateOption, type UpdateTimeRangeOption, type ValidateActiveIdSlippageOption, type VariableParameters, WeightUtils, type WeightsInfo, type WeightsOptions, buildPoolKey, CetusDlmmSDK as default, dlmmMainnet, dlmmTestnet, generateRewardSchedule, getRouterModule, parseBinInfo, parseBinInfoList, parseCurrentRewardPeriodEmission, parseDlmmBasePool, parseDlmmPool, parseDlmmPosition, parseLiquidityShares, parsePartner, parsePoolTransactionInfo, parseRewardPeriodEmission, parseStrategyType, parsedDlmmPosFeeData, parsedDlmmPosRewardData, parsedSwapQuoteData, poolFilterEvenTypes, safeAmount, safeMulAmount };
|