@cetusprotocol/dlmm-sdk 1.3.0 → 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 +122 -40
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -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,17 +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[]>;
|
|
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[]>;
|
|
451
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[];
|
|
457
|
-
}): Promise<DataPage<PoolTransactionInfo>>;
|
|
470
|
+
}, requestOptions?: RpcRequestOptions): Promise<DataPage<PoolTransactionInfo>>;
|
|
458
471
|
/**
|
|
459
472
|
* Get the bin info by range (TODO: need to optimize this method)
|
|
460
473
|
* @param bin_manager_handle - The bin manager handle
|
|
@@ -463,20 +476,20 @@ declare class PoolModule implements IModule<CetusDlmmSDK> {
|
|
|
463
476
|
* @param bin_step - The bin step
|
|
464
477
|
* @returns The bin info by range
|
|
465
478
|
*/
|
|
466
|
-
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[]>;
|
|
467
480
|
/**
|
|
468
481
|
* Get the list of DLMM pools by assign pool ids
|
|
469
482
|
* @param assign_pool_ids - The assign pool ids
|
|
470
483
|
* @returns The list of DLMM pools
|
|
471
484
|
*/
|
|
472
|
-
getAssignPoolList(assign_pool_ids: string[]): Promise<DlmmPool[]>;
|
|
485
|
+
getAssignPoolList(assign_pool_ids: string[], requestOptions?: RpcRequestOptions): Promise<DlmmPool[]>;
|
|
473
486
|
/**
|
|
474
487
|
* Get a DLMM pool by its object ID.
|
|
475
488
|
* @param {string} pool_id The object ID of the pool to get.
|
|
476
489
|
* @param {true} force_refresh Whether to force a refresh of the cache.
|
|
477
490
|
* @returns {Promise<DlmmPool>} A promise that resolves to a DlmmPool object.
|
|
478
491
|
*/
|
|
479
|
-
getPool(pool_id: string, force_refresh?: boolean): Promise<DlmmPool>;
|
|
492
|
+
getPool(pool_id: string, force_refresh?: boolean, requestOptions?: RpcRequestOptions): Promise<DlmmPool>;
|
|
480
493
|
/**
|
|
481
494
|
* Create a pool and add liquidity with a given price
|
|
482
495
|
* @param option - The option for creating a pool and adding liquidity with a given price
|
|
@@ -503,8 +516,8 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
503
516
|
constructor(sdk: CetusDlmmSDK);
|
|
504
517
|
get sdk(): CetusDlmmSDK;
|
|
505
518
|
buildPositionType(): string;
|
|
506
|
-
getOwnerPositionList(owner: string): Promise<DlmmPosition[]>;
|
|
507
|
-
getPosition(position_id: string): Promise<DlmmPosition>;
|
|
519
|
+
getOwnerPositionList(owner: string, requestOptions?: RpcRequestOptions): Promise<DlmmPosition[]>;
|
|
520
|
+
getPosition(position_id: string, requestOptions?: RpcRequestOptions): Promise<DlmmPosition>;
|
|
508
521
|
/**
|
|
509
522
|
* Collect fee
|
|
510
523
|
* @param option - The option for collecting fee
|
|
@@ -571,7 +584,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
571
584
|
* @param active_id - The active id
|
|
572
585
|
* @returns The amounts in the active bin if in range
|
|
573
586
|
*/
|
|
574
|
-
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>;
|
|
575
588
|
/**
|
|
576
589
|
* Calculate the result of removing liquidity
|
|
577
590
|
* @param option - The option for calculating the result of removing liquidity
|
|
@@ -583,7 +596,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
583
596
|
* @param option - The option for calculating the result of adding liquidity
|
|
584
597
|
* @returns The result of adding liquidity
|
|
585
598
|
*/
|
|
586
|
-
calculateAddLiquidityInfo(option: CalculateAddLiquidityOption | CalculateAddLiquidityAutoFillOption): Promise<BinLiquidityInfo>;
|
|
599
|
+
calculateAddLiquidityInfo(option: CalculateAddLiquidityOption | CalculateAddLiquidityAutoFillOption, requestOptions?: RpcRequestOptions): Promise<BinLiquidityInfo>;
|
|
587
600
|
/**
|
|
588
601
|
* Remove liquidity
|
|
589
602
|
* @param option - The option for removing liquidity
|
|
@@ -613,7 +626,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
613
626
|
* @param options - The option for fetching the fee and reward of the position
|
|
614
627
|
* @returns The fee and reward of the position
|
|
615
628
|
*/
|
|
616
|
-
fetchPositionFeeAndReward(options: CollectRewardAndFeeOption[]): Promise<{
|
|
629
|
+
fetchPositionFeeAndReward(options: CollectRewardAndFeeOption[], requestOptions?: RpcRequestOptions): Promise<{
|
|
617
630
|
feeData: Record<string, PositionFee>;
|
|
618
631
|
rewardData: Record<string, PositionReward>;
|
|
619
632
|
}>;
|
|
@@ -623,7 +636,7 @@ declare class SwapModule implements IModule<CetusDlmmSDK> {
|
|
|
623
636
|
protected _sdk: CetusDlmmSDK;
|
|
624
637
|
constructor(sdk: CetusDlmmSDK);
|
|
625
638
|
get sdk(): CetusDlmmSDK;
|
|
626
|
-
preSwapQuote(option: PreSwapOption): Promise<PreSwapQuote>;
|
|
639
|
+
preSwapQuote(option: PreSwapOption, requestOptions?: RpcRequestOptions): Promise<PreSwapQuote>;
|
|
627
640
|
swapPayload(option: SwapOption): Transaction;
|
|
628
641
|
}
|
|
629
642
|
|
|
@@ -635,20 +648,20 @@ declare class PartnerModule implements IModule<CetusDlmmSDK> {
|
|
|
635
648
|
* Get a list of partners.
|
|
636
649
|
* @returns {Promise<Partner[]>} A promise that resolves to an array of Partner objects.
|
|
637
650
|
*/
|
|
638
|
-
getPartnerList(): Promise<Partner[]>;
|
|
651
|
+
getPartnerList(requestOptions?: RpcRequestOptions): Promise<Partner[]>;
|
|
639
652
|
/**
|
|
640
653
|
* Get the partner cap ID for a given owner and partner ID.
|
|
641
654
|
* @param owner - The owner of the partner.
|
|
642
655
|
* @param partner_id - The ID of the partner.
|
|
643
656
|
* @returns A promise that resolves to the partner cap ID or undefined if not found.
|
|
644
657
|
*/
|
|
645
|
-
getPartnerCapId(owner: string, partner_id: string): Promise<string>;
|
|
658
|
+
getPartnerCapId(owner: string, partner_id: string, requestOptions?: RpcRequestOptions): Promise<string>;
|
|
646
659
|
/**
|
|
647
660
|
* Get the balance of a partner
|
|
648
661
|
* @param partner_balance_handle - The handle of the partner balance
|
|
649
662
|
* @returns A promise that resolves to an array of { coin_type: string; balance: string } objects.
|
|
650
663
|
*/
|
|
651
|
-
getPartnerBalance(partner_balance_handle: string): Promise<{
|
|
664
|
+
getPartnerBalance(partner_balance_handle: string, requestOptions?: RpcRequestOptions): Promise<{
|
|
652
665
|
coin_type: string;
|
|
653
666
|
balance: string;
|
|
654
667
|
}[]>;
|
|
@@ -657,7 +670,7 @@ declare class PartnerModule implements IModule<CetusDlmmSDK> {
|
|
|
657
670
|
* @param {string} partner_id The object ID of the partner to get.
|
|
658
671
|
* @returns {Promise<Partner>} A promise that resolves to a Partner object.
|
|
659
672
|
*/
|
|
660
|
-
getPartner(partner_id: string): Promise<Partner>;
|
|
673
|
+
getPartner(partner_id: string, requestOptions?: RpcRequestOptions): Promise<Partner>;
|
|
661
674
|
/**
|
|
662
675
|
* Update the ref fee rate of a partner
|
|
663
676
|
* @param option - The option for updating the ref fee rate
|
|
@@ -683,7 +696,7 @@ declare class RewardModule implements IModule<CetusDlmmSDK> {
|
|
|
683
696
|
protected _sdk: CetusDlmmSDK;
|
|
684
697
|
constructor(sdk: CetusDlmmSDK);
|
|
685
698
|
get sdk(): CetusDlmmSDK;
|
|
686
|
-
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[]>;
|
|
687
700
|
/**
|
|
688
701
|
* Add reward to a pool
|
|
689
702
|
* @param options - The options for adding reward
|
|
@@ -717,17 +730,17 @@ declare class ConfigModule implements IModule<CetusDlmmSDK> {
|
|
|
717
730
|
* @returns The transaction for adding or removing reward white list
|
|
718
731
|
*/
|
|
719
732
|
buildRewardWhiteListPayload(option: RewardWhiteListOption, tx?: Transaction): Transaction;
|
|
720
|
-
getBinStepConfigList(bin_steps_handle: string): Promise<BinStepConfig[]>;
|
|
733
|
+
getBinStepConfigList(bin_steps_handle: string, requestOptions?: RpcRequestOptions): Promise<BinStepConfig[]>;
|
|
721
734
|
/**
|
|
722
735
|
* Get the list of bin step configs
|
|
723
736
|
* @returns The list of bin step configs
|
|
724
737
|
*/
|
|
725
|
-
getDlmmGlobalConfig(): Promise<DlmmGlobalConfig>;
|
|
738
|
+
getDlmmGlobalConfig(requestOptions?: RpcRequestOptions): Promise<DlmmGlobalConfig>;
|
|
726
739
|
/**
|
|
727
740
|
* Fetch the configs of the dlmm SDK
|
|
728
741
|
* @returns The configs of the dlmm
|
|
729
742
|
*/
|
|
730
|
-
fetchDlmmSdkConfigs(): Promise<DlmmConfigs>;
|
|
743
|
+
fetchDlmmSdkConfigs(requestOptions?: RpcRequestOptions): Promise<DlmmConfigs>;
|
|
731
744
|
}
|
|
732
745
|
|
|
733
746
|
/**
|
|
@@ -783,7 +796,7 @@ declare function parseDlmmBasePool(data: SuiEvent): DlmmBasePool;
|
|
|
783
796
|
declare function parseDlmmPool(data: any): DlmmPool;
|
|
784
797
|
declare function parsePartner(data: any): Partner;
|
|
785
798
|
declare function parseDlmmPosition(data: any): DlmmPosition;
|
|
786
|
-
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;
|
|
787
800
|
declare function parseBinInfoList(res: any): BinAmount[];
|
|
788
801
|
declare function parseBinInfo(fields: any): BinAmount;
|
|
789
802
|
declare function parsedDlmmPosFeeData(events: any[]): Record<string, PositionFee>;
|
|
@@ -1035,11 +1048,9 @@ declare class BinUtils {
|
|
|
1035
1048
|
*/
|
|
1036
1049
|
static getBinIdFromPrice(price: string, binStep: number, min: boolean, decimal_a: number, decimal_b: number): number;
|
|
1037
1050
|
/**
|
|
1038
|
-
* Get the bin id from a price per lamport
|
|
1039
|
-
*
|
|
1040
|
-
*
|
|
1041
|
-
* @param min - Whether to use the minimum or maximum bin id
|
|
1042
|
-
* @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.
|
|
1043
1054
|
*/
|
|
1044
1055
|
static getBinIdFromLamportPrice(pricePerLamport: string, binStep: number, min: boolean): number;
|
|
1045
1056
|
/**
|
|
@@ -1065,12 +1076,74 @@ declare class BinUtils {
|
|
|
1065
1076
|
*/
|
|
1066
1077
|
static getReversePrice(price: string): string;
|
|
1067
1078
|
/**
|
|
1068
|
-
*
|
|
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.
|
|
1069
1081
|
* @param binId - The bin id
|
|
1070
1082
|
* @param binStep - The bin step
|
|
1071
|
-
* @returns The price of the bin
|
|
1083
|
+
* @returns The price of the bin in Q64.64
|
|
1072
1084
|
*/
|
|
1073
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;
|
|
1074
1147
|
/**
|
|
1075
1148
|
* Convert QPrice (Q64x64 format) to actual price
|
|
1076
1149
|
* @param qPrice - The price in Q64x64 format
|
|
@@ -1120,7 +1193,7 @@ declare class WeightUtils {
|
|
|
1120
1193
|
* @param distributions - weight distribution of each bin
|
|
1121
1194
|
* @returns array of {binId, amount} where amount is the amount of coin b in each bin
|
|
1122
1195
|
*/
|
|
1123
|
-
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;
|
|
1124
1197
|
/**
|
|
1125
1198
|
* Distribute totalAmount to all ask side bins according to given distributions.
|
|
1126
1199
|
* @param active_id active bin id
|
|
@@ -1128,7 +1201,7 @@ declare class WeightUtils {
|
|
|
1128
1201
|
* @param distributions weight distribution of each bin
|
|
1129
1202
|
* @returns array of {binId, amount} where amount is the amount of coin a in each bin
|
|
1130
1203
|
*/
|
|
1131
|
-
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;
|
|
1132
1205
|
/**
|
|
1133
1206
|
* Distributes the given amounts of tokens X and Y to both bid and ask side bins
|
|
1134
1207
|
* based on the provided weight distributions.
|
|
@@ -1145,7 +1218,7 @@ declare class WeightUtils {
|
|
|
1145
1218
|
* @param clock - Clock instance. Get from DLMM instance.
|
|
1146
1219
|
* @returns An array of objects containing binId, amountX, and amountY for each bin.
|
|
1147
1220
|
*/
|
|
1148
|
-
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;
|
|
1149
1222
|
/**
|
|
1150
1223
|
* Distributes the given amount of coin B to both bid and ask side bins
|
|
1151
1224
|
* based on the provided weight distributions.
|
|
@@ -1158,12 +1231,12 @@ declare class WeightUtils {
|
|
|
1158
1231
|
* @param distributions - Array of bins with their respective weight distributions.
|
|
1159
1232
|
* @returns An array of objects containing binId, amountA, and amountB for each bin.
|
|
1160
1233
|
*/
|
|
1161
|
-
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;
|
|
1162
1235
|
static calculateActiveWeights(amount_a_in_active_id: string, amount_b_in_active_id: string, active_bin_price: string, base_weight: Decimal): {
|
|
1163
1236
|
active_weight_a: Decimal;
|
|
1164
1237
|
active_weight_b: Decimal;
|
|
1165
1238
|
};
|
|
1166
|
-
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): {
|
|
1167
1240
|
totalWeightA: Decimal;
|
|
1168
1241
|
totalWeightB: Decimal;
|
|
1169
1242
|
activeWeightA: Decimal;
|
|
@@ -1192,6 +1265,11 @@ declare class StrategyUtils {
|
|
|
1192
1265
|
}
|
|
1193
1266
|
|
|
1194
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;
|
|
1195
1273
|
static getVariableFee(variableParameters: VariableParameters): string;
|
|
1196
1274
|
static calculateCompositionFee(amount: string, total_fee_rate: string): string;
|
|
1197
1275
|
static calculateProtocolFee(fee_amount: string, protocol_fee_rate: string): string;
|
|
@@ -1256,9 +1334,13 @@ declare class IlmUtils {
|
|
|
1256
1334
|
}
|
|
1257
1335
|
|
|
1258
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`. */
|
|
1259
1339
|
declare const MIN_BIN_ID = -443636;
|
|
1260
1340
|
declare const MAX_BIN_ID = 443636;
|
|
1261
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;
|
|
1262
1344
|
declare const DEFAULT_MAX_WEIGHT = 2000;
|
|
1263
1345
|
declare const DEFAULT_MIN_WEIGHT = 200;
|
|
1264
1346
|
declare const BIN_BOUND = 443636n;
|
|
@@ -1272,4 +1354,4 @@ declare const dlmmMainnet: SdkOptions;
|
|
|
1272
1354
|
|
|
1273
1355
|
declare const dlmmTestnet: SdkOptions;
|
|
1274
1356
|
|
|
1275
|
-
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 };
|