@cetusprotocol/dlmm-sdk 0.0.2 → 0.0.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/.turbo/turbo-build.log +1025 -963
- package/README.md +9 -1
- package/dist/index.d.mts +39 -11
- package/dist/index.d.ts +39 -11
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
- package/src/config/mainnet.ts +10 -10
- package/src/config/testnet.ts +3 -3
- package/src/modules/poolModule.ts +59 -12
- package/src/modules/positionModule.ts +35 -16
- package/src/types/dlmm.ts +25 -4
- package/src/utils/feeUtils.ts +13 -13
- package/src/utils/parseData.ts +39 -2
- package/src/utils/strategyUtils.ts +133 -52
- package/src/utils/weightUtils.ts +167 -6
- package/tests/add_liquidity_bidask.test.ts +26 -14
- package/tests/add_liquidity_curve.test.ts +16 -16
- package/tests/add_liquidity_spot.test.ts +74 -22
- package/tests/config.test.ts +23 -1
- package/tests/pool.test.ts +12 -2
- package/tests/position.test.ts +2 -2
package/README.md
CHANGED
|
@@ -373,6 +373,9 @@ const addOption = {
|
|
|
373
373
|
decimals_a: 6,
|
|
374
374
|
decimals_b: 6,
|
|
375
375
|
max_bin_slippage: 0.01,
|
|
376
|
+
active_id,
|
|
377
|
+
// If use_bin_infos is true, liquidity is allocated according to bin_infos; otherwise, it is calculated internally by the contract
|
|
378
|
+
use_bin_infos: false,
|
|
376
379
|
}
|
|
377
380
|
const tx = sdk.Position.addLiquidityWithPricePayload(addOption)
|
|
378
381
|
```
|
|
@@ -408,8 +411,13 @@ const removeOption = {
|
|
|
408
411
|
coin_type_a: pool.coin_type_a,
|
|
409
412
|
coin_type_b: pool.coin_type_b,
|
|
410
413
|
position_id,
|
|
414
|
+
active_id,
|
|
411
415
|
slippage: 0.01,
|
|
412
|
-
reward_coins: []
|
|
416
|
+
reward_coins: [],
|
|
417
|
+
collect_fee: true,
|
|
418
|
+
reward_coins: [],
|
|
419
|
+
bin_step,
|
|
420
|
+
remove_percent: 0.5, // If remove_percent is specified, bin_infos will not be effective
|
|
413
421
|
}
|
|
414
422
|
const tx = sdk.Position.removeLiquidityPayload(removeOption)
|
|
415
423
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CoinPairType, TableHandle, IModule, PaginationArgs, DataPage, PageQuery, SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
2
2
|
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
3
|
-
import { SuiEvent, SuiObjectResponse, DevInspectResults, SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
4
3
|
import Decimal from 'decimal.js';
|
|
4
|
+
import { SuiEvent, SuiObjectResponse, DevInspectResults, SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
|
|
7
7
|
type DlmmConfigs = {
|
|
@@ -137,6 +137,7 @@ type CreatePoolOption = {
|
|
|
137
137
|
active_id: number;
|
|
138
138
|
} & BaseCreatePoolOption;
|
|
139
139
|
type CreatePoolAndAddWithPriceOption = {
|
|
140
|
+
pool_id: string;
|
|
140
141
|
price_base_coin: 'coin_a' | 'coin_b';
|
|
141
142
|
price: string;
|
|
142
143
|
lower_price: string;
|
|
@@ -160,12 +161,12 @@ type BaseAddLiquidityOption = {
|
|
|
160
161
|
use_bin_infos?: boolean;
|
|
161
162
|
} & CoinPairType;
|
|
162
163
|
type BaseCalculateAddLiquidityOption = {
|
|
164
|
+
pool_id?: string;
|
|
163
165
|
active_id: number;
|
|
164
166
|
bin_step: number;
|
|
165
167
|
lower_bin_id: number;
|
|
166
168
|
upper_bin_id: number;
|
|
167
|
-
|
|
168
|
-
amount_b_in_active_bin: string;
|
|
169
|
+
active_bin_of_pool?: BinAmount;
|
|
169
170
|
strategy_type: StrategyType;
|
|
170
171
|
};
|
|
171
172
|
type CalculateAddLiquidityOption = {
|
|
@@ -190,8 +191,7 @@ type OpenAndAddLiquidityWithPriceOption = BaseAddLiquidityOption & {
|
|
|
190
191
|
price: string;
|
|
191
192
|
lower_price: string;
|
|
192
193
|
upper_price: string;
|
|
193
|
-
|
|
194
|
-
amount_b_in_active_bin: string;
|
|
194
|
+
active_bin_of_pool?: BinAmount;
|
|
195
195
|
strategy_type: StrategyType;
|
|
196
196
|
decimals_a: number;
|
|
197
197
|
decimals_b: number;
|
|
@@ -387,11 +387,30 @@ type FeeRate = {
|
|
|
387
387
|
var_fee_rate: string;
|
|
388
388
|
total_fee_rate: string;
|
|
389
389
|
};
|
|
390
|
+
type WeightsOptions = {
|
|
391
|
+
strategy_type: StrategyType;
|
|
392
|
+
active_id: number;
|
|
393
|
+
bin_step: number;
|
|
394
|
+
lower_bin_id: number;
|
|
395
|
+
upper_bin_id: number;
|
|
396
|
+
total_amount_a: string;
|
|
397
|
+
total_amount_b: string;
|
|
398
|
+
active_bin_of_pool?: BinAmount;
|
|
399
|
+
};
|
|
400
|
+
type WeightsInfo = {
|
|
401
|
+
total_weight_a: Decimal;
|
|
402
|
+
total_weight_b: Decimal;
|
|
403
|
+
weights: Decimal[];
|
|
404
|
+
weight_per_prices: Decimal[];
|
|
405
|
+
active_weight_a: Decimal;
|
|
406
|
+
active_weight_b: Decimal;
|
|
407
|
+
} & WeightsOptions;
|
|
390
408
|
|
|
391
409
|
declare class PoolModule implements IModule<CetusDlmmSDK> {
|
|
392
410
|
protected _sdk: CetusDlmmSDK;
|
|
393
411
|
constructor(sdk: CetusDlmmSDK);
|
|
394
412
|
get sdk(): CetusDlmmSDK;
|
|
413
|
+
getPoolAddress(coin_type_a: string, coin_type_b: string, bin_step: number, base_factor: number): Promise<string | undefined>;
|
|
395
414
|
/**
|
|
396
415
|
* Get the list of DLMM base pools
|
|
397
416
|
* @param pagination_args - The pagination arguments
|
|
@@ -526,7 +545,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
526
545
|
* @param option - The option for calculating the result of adding liquidity
|
|
527
546
|
* @returns The result of adding liquidity
|
|
528
547
|
*/
|
|
529
|
-
calculateAddLiquidityInfo(option: CalculateAddLiquidityOption | CalculateAddLiquidityAutoFillOption): BinLiquidityInfo
|
|
548
|
+
calculateAddLiquidityInfo(option: CalculateAddLiquidityOption | CalculateAddLiquidityAutoFillOption): Promise<BinLiquidityInfo>;
|
|
530
549
|
/**
|
|
531
550
|
* Remove liquidity
|
|
532
551
|
* @param option - The option for removing liquidity
|
|
@@ -538,7 +557,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
538
557
|
* @param option - The option for adding liquidity with price
|
|
539
558
|
* @returns The transaction
|
|
540
559
|
*/
|
|
541
|
-
addLiquidityWithPricePayload(option: OpenAndAddLiquidityWithPriceOption): Transaction
|
|
560
|
+
addLiquidityWithPricePayload(option: OpenAndAddLiquidityWithPriceOption): Promise<Transaction>;
|
|
542
561
|
/**
|
|
543
562
|
* Add liquidity
|
|
544
563
|
* @param option - The option for adding liquidity
|
|
@@ -735,7 +754,9 @@ declare function generateRewardSchedule(baseTime: number, maxIntervals: number,
|
|
|
735
754
|
declare function parseRewardPeriodEmission(periodEmissionList: RewardPeriodEmission[], startTimeInSeconds: number, endTimeInSeconds: number, durationSeconds: number): RewardPeriodEmissionFormat[];
|
|
736
755
|
declare function parseCurrentRewardPeriodEmission(periodEmissionList: RewardPeriodEmission[]): RewardPeriodEmission | undefined;
|
|
737
756
|
declare function safeMulAmount(amount: Decimal, rate: Decimal): Decimal;
|
|
757
|
+
declare function safeAmount(amount: Decimal): Decimal;
|
|
738
758
|
declare function getRouterModule(strategy_type: StrategyType): "spot" | "curve" | "bid_ask";
|
|
759
|
+
declare function buildPoolKey(coin_type_a: string, coin_type_b: string, bin_step: number, base_factor: number): string;
|
|
739
760
|
|
|
740
761
|
declare const SCALE_OFFSET = 64;
|
|
741
762
|
declare const ONE: BN;
|
|
@@ -904,6 +925,7 @@ declare class BinUtils {
|
|
|
904
925
|
}
|
|
905
926
|
|
|
906
927
|
declare class WeightUtils {
|
|
928
|
+
static toWeight(options: WeightsOptions): WeightsInfo;
|
|
907
929
|
static toWeightSpotBalanced(min_bin_id: number, max_bin_id: number): BinWeight[];
|
|
908
930
|
static toWeightDescendingOrder(min_bin_id: number, max_bin_id: number): BinWeight[];
|
|
909
931
|
static toWeightAscendingOrder(min_bin_id: number, max_bin_id: number): BinWeight[];
|
|
@@ -955,6 +977,10 @@ declare class WeightUtils {
|
|
|
955
977
|
* @returns An array of objects containing binId, amountA, and amountB for each bin.
|
|
956
978
|
*/
|
|
957
979
|
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;
|
|
980
|
+
static calculateActiveWeights(amount_a_in_active_id: string, amount_b_in_active_id: string, active_bin_price: string, base_weight: Decimal): {
|
|
981
|
+
active_weight_a: Decimal;
|
|
982
|
+
active_weight_b: Decimal;
|
|
983
|
+
};
|
|
958
984
|
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'): {
|
|
959
985
|
totalWeightA: Decimal;
|
|
960
986
|
totalWeightB: Decimal;
|
|
@@ -964,6 +990,7 @@ declare class WeightUtils {
|
|
|
964
990
|
}
|
|
965
991
|
|
|
966
992
|
declare class StrategyUtils {
|
|
993
|
+
static toAmountsByWeights(weights_info: WeightsInfo): BinLiquidityInfo;
|
|
967
994
|
/**
|
|
968
995
|
* Given a strategy type and amounts of X and Y, returns the distribution of liquidity.
|
|
969
996
|
* @param active_id The bin id of the active bin.
|
|
@@ -977,8 +1004,9 @@ declare class StrategyUtils {
|
|
|
977
1004
|
* @param strategy_type The strategy type.
|
|
978
1005
|
* @returns The distribution of liquidity.
|
|
979
1006
|
*/
|
|
980
|
-
static toAmountsBothSideByStrategy(active_id: number, bin_step: number, min_bin_id: number, max_bin_id: number, amount_a: string, amount_b: string,
|
|
981
|
-
static autoFillCoinByStrategy(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean,
|
|
1007
|
+
static toAmountsBothSideByStrategy(active_id: number, bin_step: number, min_bin_id: number, max_bin_id: number, amount_a: string, amount_b: string, strategy_type: StrategyType, active_bin_of_pool?: BinAmount): BinLiquidityInfo;
|
|
1008
|
+
static autoFillCoinByStrategy(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean, min_bin_id: number, max_bin_id: number, strategy_type: StrategyType, active_bin_of_pool?: BinAmount): BinLiquidityInfo;
|
|
1009
|
+
static autoFillCoinByStrategyV2(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean, min_bin_id: number, max_bin_id: number, strategy_type: StrategyType, active_bin_of_pool?: BinAmount): BinLiquidityInfo;
|
|
982
1010
|
}
|
|
983
1011
|
|
|
984
1012
|
declare class FeeUtils {
|
|
@@ -989,7 +1017,7 @@ declare class FeeUtils {
|
|
|
989
1017
|
protocol_fee_a: string;
|
|
990
1018
|
protocol_fee_b: string;
|
|
991
1019
|
};
|
|
992
|
-
static getCompositionFees(active_bin: BinAmount, used_bin: BinAmount,
|
|
1020
|
+
static getCompositionFees(active_bin: BinAmount, used_bin: BinAmount, variableParameters: VariableParameters): {
|
|
993
1021
|
fees_a: string;
|
|
994
1022
|
fees_b: string;
|
|
995
1023
|
};
|
|
@@ -1012,4 +1040,4 @@ declare const dlmmMainnet: SdkOptions;
|
|
|
1012
1040
|
|
|
1013
1041
|
declare const dlmmTestnet: SdkOptions;
|
|
1014
1042
|
|
|
1015
|
-
export { type AddLiquidityOption, type AddRewardOption, BASIS_POINT, BASIS_POINT_MAX, BIN_BOUND, type BaseAddLiquidityOption, type BaseCalculateAddLiquidityOption, type BaseCreatePoolAndAddOption, type BaseCreatePoolOption, type BinAmount, 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 GetPoolBinInfoOption, type GetTotalFeeRateOption, type InitRewardOption, MAX_BIN_ID, MAX_BIN_PER_POSITION, MAX_FEE_RATE, MIN_BIN_ID, ONE, type OpenAndAddLiquidityOption, type OpenAndAddLiquidityWithPriceOption, type OpenPositionOption, type Partner, PoolModule, type PoolPermissions, 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, StrategyType, StrategyUtils, type SwapOption, type UpdatePositionFeeAndRewardsOption, type UpdateRefFeeRateOption, type UpdateTimeRangeOption, type ValidateActiveIdSlippageOption, type VariableParameters, WeightUtils, CetusDlmmSDK as default, dlmmMainnet, dlmmTestnet, generateRewardSchedule, getRouterModule, parseBinInfo, parseBinInfoList, parseCurrentRewardPeriodEmission, parseDlmmBasePool, parseDlmmPool, parseDlmmPosition, parseLiquidityShares, parsePartner, parsePoolTransactionInfo, parseRewardPeriodEmission, parseStrategyType, parsedDlmmPosFeeData, parsedDlmmPosRewardData, parsedSwapQuoteData, poolFilterEvenTypes, safeMulAmount };
|
|
1043
|
+
export { type AddLiquidityOption, type AddRewardOption, BASIS_POINT, BASIS_POINT_MAX, BIN_BOUND, type BaseAddLiquidityOption, type BaseCalculateAddLiquidityOption, type BaseCreatePoolAndAddOption, type BaseCreatePoolOption, type BinAmount, 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 GetPoolBinInfoOption, type GetTotalFeeRateOption, type InitRewardOption, MAX_BIN_ID, MAX_BIN_PER_POSITION, MAX_FEE_RATE, MIN_BIN_ID, ONE, type OpenAndAddLiquidityOption, type OpenAndAddLiquidityWithPriceOption, type OpenPositionOption, type Partner, PoolModule, type PoolPermissions, 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, StrategyType, StrategyUtils, type SwapOption, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CoinPairType, TableHandle, IModule, PaginationArgs, DataPage, PageQuery, SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
2
2
|
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
3
|
-
import { SuiEvent, SuiObjectResponse, DevInspectResults, SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
4
3
|
import Decimal from 'decimal.js';
|
|
4
|
+
import { SuiEvent, SuiObjectResponse, DevInspectResults, SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
|
|
7
7
|
type DlmmConfigs = {
|
|
@@ -137,6 +137,7 @@ type CreatePoolOption = {
|
|
|
137
137
|
active_id: number;
|
|
138
138
|
} & BaseCreatePoolOption;
|
|
139
139
|
type CreatePoolAndAddWithPriceOption = {
|
|
140
|
+
pool_id: string;
|
|
140
141
|
price_base_coin: 'coin_a' | 'coin_b';
|
|
141
142
|
price: string;
|
|
142
143
|
lower_price: string;
|
|
@@ -160,12 +161,12 @@ type BaseAddLiquidityOption = {
|
|
|
160
161
|
use_bin_infos?: boolean;
|
|
161
162
|
} & CoinPairType;
|
|
162
163
|
type BaseCalculateAddLiquidityOption = {
|
|
164
|
+
pool_id?: string;
|
|
163
165
|
active_id: number;
|
|
164
166
|
bin_step: number;
|
|
165
167
|
lower_bin_id: number;
|
|
166
168
|
upper_bin_id: number;
|
|
167
|
-
|
|
168
|
-
amount_b_in_active_bin: string;
|
|
169
|
+
active_bin_of_pool?: BinAmount;
|
|
169
170
|
strategy_type: StrategyType;
|
|
170
171
|
};
|
|
171
172
|
type CalculateAddLiquidityOption = {
|
|
@@ -190,8 +191,7 @@ type OpenAndAddLiquidityWithPriceOption = BaseAddLiquidityOption & {
|
|
|
190
191
|
price: string;
|
|
191
192
|
lower_price: string;
|
|
192
193
|
upper_price: string;
|
|
193
|
-
|
|
194
|
-
amount_b_in_active_bin: string;
|
|
194
|
+
active_bin_of_pool?: BinAmount;
|
|
195
195
|
strategy_type: StrategyType;
|
|
196
196
|
decimals_a: number;
|
|
197
197
|
decimals_b: number;
|
|
@@ -387,11 +387,30 @@ type FeeRate = {
|
|
|
387
387
|
var_fee_rate: string;
|
|
388
388
|
total_fee_rate: string;
|
|
389
389
|
};
|
|
390
|
+
type WeightsOptions = {
|
|
391
|
+
strategy_type: StrategyType;
|
|
392
|
+
active_id: number;
|
|
393
|
+
bin_step: number;
|
|
394
|
+
lower_bin_id: number;
|
|
395
|
+
upper_bin_id: number;
|
|
396
|
+
total_amount_a: string;
|
|
397
|
+
total_amount_b: string;
|
|
398
|
+
active_bin_of_pool?: BinAmount;
|
|
399
|
+
};
|
|
400
|
+
type WeightsInfo = {
|
|
401
|
+
total_weight_a: Decimal;
|
|
402
|
+
total_weight_b: Decimal;
|
|
403
|
+
weights: Decimal[];
|
|
404
|
+
weight_per_prices: Decimal[];
|
|
405
|
+
active_weight_a: Decimal;
|
|
406
|
+
active_weight_b: Decimal;
|
|
407
|
+
} & WeightsOptions;
|
|
390
408
|
|
|
391
409
|
declare class PoolModule implements IModule<CetusDlmmSDK> {
|
|
392
410
|
protected _sdk: CetusDlmmSDK;
|
|
393
411
|
constructor(sdk: CetusDlmmSDK);
|
|
394
412
|
get sdk(): CetusDlmmSDK;
|
|
413
|
+
getPoolAddress(coin_type_a: string, coin_type_b: string, bin_step: number, base_factor: number): Promise<string | undefined>;
|
|
395
414
|
/**
|
|
396
415
|
* Get the list of DLMM base pools
|
|
397
416
|
* @param pagination_args - The pagination arguments
|
|
@@ -526,7 +545,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
526
545
|
* @param option - The option for calculating the result of adding liquidity
|
|
527
546
|
* @returns The result of adding liquidity
|
|
528
547
|
*/
|
|
529
|
-
calculateAddLiquidityInfo(option: CalculateAddLiquidityOption | CalculateAddLiquidityAutoFillOption): BinLiquidityInfo
|
|
548
|
+
calculateAddLiquidityInfo(option: CalculateAddLiquidityOption | CalculateAddLiquidityAutoFillOption): Promise<BinLiquidityInfo>;
|
|
530
549
|
/**
|
|
531
550
|
* Remove liquidity
|
|
532
551
|
* @param option - The option for removing liquidity
|
|
@@ -538,7 +557,7 @@ declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
|
538
557
|
* @param option - The option for adding liquidity with price
|
|
539
558
|
* @returns The transaction
|
|
540
559
|
*/
|
|
541
|
-
addLiquidityWithPricePayload(option: OpenAndAddLiquidityWithPriceOption): Transaction
|
|
560
|
+
addLiquidityWithPricePayload(option: OpenAndAddLiquidityWithPriceOption): Promise<Transaction>;
|
|
542
561
|
/**
|
|
543
562
|
* Add liquidity
|
|
544
563
|
* @param option - The option for adding liquidity
|
|
@@ -735,7 +754,9 @@ declare function generateRewardSchedule(baseTime: number, maxIntervals: number,
|
|
|
735
754
|
declare function parseRewardPeriodEmission(periodEmissionList: RewardPeriodEmission[], startTimeInSeconds: number, endTimeInSeconds: number, durationSeconds: number): RewardPeriodEmissionFormat[];
|
|
736
755
|
declare function parseCurrentRewardPeriodEmission(periodEmissionList: RewardPeriodEmission[]): RewardPeriodEmission | undefined;
|
|
737
756
|
declare function safeMulAmount(amount: Decimal, rate: Decimal): Decimal;
|
|
757
|
+
declare function safeAmount(amount: Decimal): Decimal;
|
|
738
758
|
declare function getRouterModule(strategy_type: StrategyType): "spot" | "curve" | "bid_ask";
|
|
759
|
+
declare function buildPoolKey(coin_type_a: string, coin_type_b: string, bin_step: number, base_factor: number): string;
|
|
739
760
|
|
|
740
761
|
declare const SCALE_OFFSET = 64;
|
|
741
762
|
declare const ONE: BN;
|
|
@@ -904,6 +925,7 @@ declare class BinUtils {
|
|
|
904
925
|
}
|
|
905
926
|
|
|
906
927
|
declare class WeightUtils {
|
|
928
|
+
static toWeight(options: WeightsOptions): WeightsInfo;
|
|
907
929
|
static toWeightSpotBalanced(min_bin_id: number, max_bin_id: number): BinWeight[];
|
|
908
930
|
static toWeightDescendingOrder(min_bin_id: number, max_bin_id: number): BinWeight[];
|
|
909
931
|
static toWeightAscendingOrder(min_bin_id: number, max_bin_id: number): BinWeight[];
|
|
@@ -955,6 +977,10 @@ declare class WeightUtils {
|
|
|
955
977
|
* @returns An array of objects containing binId, amountA, and amountB for each bin.
|
|
956
978
|
*/
|
|
957
979
|
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;
|
|
980
|
+
static calculateActiveWeights(amount_a_in_active_id: string, amount_b_in_active_id: string, active_bin_price: string, base_weight: Decimal): {
|
|
981
|
+
active_weight_a: Decimal;
|
|
982
|
+
active_weight_b: Decimal;
|
|
983
|
+
};
|
|
958
984
|
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'): {
|
|
959
985
|
totalWeightA: Decimal;
|
|
960
986
|
totalWeightB: Decimal;
|
|
@@ -964,6 +990,7 @@ declare class WeightUtils {
|
|
|
964
990
|
}
|
|
965
991
|
|
|
966
992
|
declare class StrategyUtils {
|
|
993
|
+
static toAmountsByWeights(weights_info: WeightsInfo): BinLiquidityInfo;
|
|
967
994
|
/**
|
|
968
995
|
* Given a strategy type and amounts of X and Y, returns the distribution of liquidity.
|
|
969
996
|
* @param active_id The bin id of the active bin.
|
|
@@ -977,8 +1004,9 @@ declare class StrategyUtils {
|
|
|
977
1004
|
* @param strategy_type The strategy type.
|
|
978
1005
|
* @returns The distribution of liquidity.
|
|
979
1006
|
*/
|
|
980
|
-
static toAmountsBothSideByStrategy(active_id: number, bin_step: number, min_bin_id: number, max_bin_id: number, amount_a: string, amount_b: string,
|
|
981
|
-
static autoFillCoinByStrategy(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean,
|
|
1007
|
+
static toAmountsBothSideByStrategy(active_id: number, bin_step: number, min_bin_id: number, max_bin_id: number, amount_a: string, amount_b: string, strategy_type: StrategyType, active_bin_of_pool?: BinAmount): BinLiquidityInfo;
|
|
1008
|
+
static autoFillCoinByStrategy(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean, min_bin_id: number, max_bin_id: number, strategy_type: StrategyType, active_bin_of_pool?: BinAmount): BinLiquidityInfo;
|
|
1009
|
+
static autoFillCoinByStrategyV2(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean, min_bin_id: number, max_bin_id: number, strategy_type: StrategyType, active_bin_of_pool?: BinAmount): BinLiquidityInfo;
|
|
982
1010
|
}
|
|
983
1011
|
|
|
984
1012
|
declare class FeeUtils {
|
|
@@ -989,7 +1017,7 @@ declare class FeeUtils {
|
|
|
989
1017
|
protocol_fee_a: string;
|
|
990
1018
|
protocol_fee_b: string;
|
|
991
1019
|
};
|
|
992
|
-
static getCompositionFees(active_bin: BinAmount, used_bin: BinAmount,
|
|
1020
|
+
static getCompositionFees(active_bin: BinAmount, used_bin: BinAmount, variableParameters: VariableParameters): {
|
|
993
1021
|
fees_a: string;
|
|
994
1022
|
fees_b: string;
|
|
995
1023
|
};
|
|
@@ -1012,4 +1040,4 @@ declare const dlmmMainnet: SdkOptions;
|
|
|
1012
1040
|
|
|
1013
1041
|
declare const dlmmTestnet: SdkOptions;
|
|
1014
1042
|
|
|
1015
|
-
export { type AddLiquidityOption, type AddRewardOption, BASIS_POINT, BASIS_POINT_MAX, BIN_BOUND, type BaseAddLiquidityOption, type BaseCalculateAddLiquidityOption, type BaseCreatePoolAndAddOption, type BaseCreatePoolOption, type BinAmount, 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 GetPoolBinInfoOption, type GetTotalFeeRateOption, type InitRewardOption, MAX_BIN_ID, MAX_BIN_PER_POSITION, MAX_FEE_RATE, MIN_BIN_ID, ONE, type OpenAndAddLiquidityOption, type OpenAndAddLiquidityWithPriceOption, type OpenPositionOption, type Partner, PoolModule, type PoolPermissions, 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, StrategyType, StrategyUtils, type SwapOption, type UpdatePositionFeeAndRewardsOption, type UpdateRefFeeRateOption, type UpdateTimeRangeOption, type ValidateActiveIdSlippageOption, type VariableParameters, WeightUtils, CetusDlmmSDK as default, dlmmMainnet, dlmmTestnet, generateRewardSchedule, getRouterModule, parseBinInfo, parseBinInfoList, parseCurrentRewardPeriodEmission, parseDlmmBasePool, parseDlmmPool, parseDlmmPosition, parseLiquidityShares, parsePartner, parsePoolTransactionInfo, parseRewardPeriodEmission, parseStrategyType, parsedDlmmPosFeeData, parsedDlmmPosRewardData, parsedSwapQuoteData, poolFilterEvenTypes, safeMulAmount };
|
|
1043
|
+
export { type AddLiquidityOption, type AddRewardOption, BASIS_POINT, BASIS_POINT_MAX, BIN_BOUND, type BaseAddLiquidityOption, type BaseCalculateAddLiquidityOption, type BaseCreatePoolAndAddOption, type BaseCreatePoolOption, type BinAmount, 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 GetPoolBinInfoOption, type GetTotalFeeRateOption, type InitRewardOption, MAX_BIN_ID, MAX_BIN_PER_POSITION, MAX_FEE_RATE, MIN_BIN_ID, ONE, type OpenAndAddLiquidityOption, type OpenAndAddLiquidityWithPriceOption, type OpenPositionOption, type Partner, PoolModule, type PoolPermissions, 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, StrategyType, StrategyUtils, type SwapOption, 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 };
|