haedal-vault-sdk 2.1.2 → 2.2.0

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 CHANGED
@@ -1,10 +1,10 @@
1
1
  import { CoinBalance, SuiObjectResponse } from '@mysten/sui/client';
2
2
  import { PreSwapLpChangeParams, AggregatorClient } from '@cetusprotocol/aggregator-sdk';
3
- import { TableHandle, PaginationArgs, DataPage, CoinPairType, IModule as IModule$1, Package, SuiAddressType, FullClient, CoinAsset, SuiResource } from '@cetusprotocol/common-sdk';
4
- import { Pool as Pool$1, CetusClmmSDK } from '@cetusprotocol/sui-clmm-sdk';
3
+ import * as _cetusprotocol_common_sdk from '@cetusprotocol/common-sdk';
4
+ import { CoinPairType, TableHandle, PaginationArgs, DataPage, IModule as IModule$1, Package, SuiAddressType, FullClient, CoinAsset, SuiResource } from '@cetusprotocol/common-sdk';
5
+ import CetusClmmSDK$1, { Pool as Pool$1, CetusClmmSDK } from '@cetusprotocol/sui-clmm-sdk';
5
6
  import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
6
- import * as CetusDlmmSDK from '@cetusprotocol/dlmm-sdk';
7
- import CetusDlmmSDK__default, { DlmmPosition, BinLiquidityInfo, DlmmPool } from '@cetusprotocol/dlmm-sdk';
7
+ import CetusDlmmSDK, { DlmmPosition, DlmmPool, BinLiquidityInfo } from '@cetusprotocol/dlmm-sdk';
8
8
  import { SuiPriceServiceConnection, SuiPythClient, PriceUpdate } from '@pythnetwork/pyth-sui-js';
9
9
  import BN from 'bn.js';
10
10
  import Decimal from 'decimal.js';
@@ -13,6 +13,7 @@ interface IModule {
13
13
  readonly sdk: VolatileVaultsSDK;
14
14
  }
15
15
 
16
+ declare const dlmm_split_rate = 0.2;
16
17
  type VaultsV2Configs = {
17
18
  package_id: string;
18
19
  published_at: string;
@@ -36,14 +37,35 @@ type DLMMMarketPosition = {
36
37
  valid_upper_bin_id: number;
37
38
  amounts: Balances;
38
39
  };
39
- type DLMMMarket = {
40
+ type ClmmPosition = {
40
41
  id: string;
42
+ pool_id: string;
43
+ index: number;
44
+ description: string;
45
+ uri: string;
46
+ liquidity: string;
47
+ tick_lower_index: number;
48
+ tick_upper_index: number;
49
+ name: string;
50
+ } & CoinPairType;
51
+ type CLMMMarketPosition = {
52
+ id: string;
53
+ position: ClmmPosition;
54
+ amounts: Balances;
55
+ };
56
+ type VaultMarketType = 'DLMM' | 'CLMM';
57
+ type VaultMarket = {
58
+ id: string;
59
+ type: VaultMarketType;
41
60
  vault_id: string;
42
61
  certified_pools: string[];
43
62
  positions_handle: TableHandle;
44
- position_list: DLMMMarketPosition[];
63
+ position_list: (DLMMMarketPosition | CLMMMarketPosition)[];
45
64
  position_keys: string[];
46
65
  } & PoolCoinTypes;
66
+ type WarpVaultMarket = {
67
+ certified_pool_obj: Record<string, DlmmPool | Pool$1>;
68
+ } & VaultMarket;
47
69
  type VaultPool = {
48
70
  id: string;
49
71
  lp_token_treasury: string;
@@ -51,12 +73,14 @@ type VaultPool = {
51
73
  buffer_assets: Balances[];
52
74
  hard_cap: string;
53
75
  markets_handle: TableHandle;
54
- markets: DLMMMarket[];
76
+ markets: VaultMarket[];
55
77
  protocol_fees_handle: TableHandle;
56
78
  lp_token_type: string;
57
79
  action_status: ActionAcl;
58
80
  last_aum: string;
81
+ is_multiple_pool: boolean;
59
82
  protocol_fee_rate: string;
83
+ version: 'v2';
60
84
  } & PoolCoinTypes;
61
85
  type CollectRewardOptionsV2 = {
62
86
  reward_coin_types: string[];
@@ -77,6 +101,8 @@ type DepositCalculationOptionsV2 = {
77
101
  uuid?: string;
78
102
  pool_id: string;
79
103
  mode: DepositMode;
104
+ coin_decimals_a: number;
105
+ coin_decimals_b: number;
80
106
  } & ({
81
107
  mode: 'FixedOneSide';
82
108
  fixed_amount: string;
@@ -118,31 +144,52 @@ type WithdrawCalculationResultV2 = {
118
144
  remove_amount_b: string;
119
145
  };
120
146
  };
121
- type VaultsBalanceV2 = {
122
- vault_id: string;
147
+ type DlmmBalance = {
148
+ position_id: string;
123
149
  certified_pool_id: string;
124
- owner: string;
125
- lp_token_type: string;
126
- lp_token_balance: string;
127
150
  liquidity_shares: string[];
128
151
  valid_lower_bin_id: number;
129
152
  valid_upper_bin_id: number;
130
153
  original_lower_bin_id: number;
131
154
  original_upper_bin_id: number;
132
- amount_a: string;
133
- amount_b: string;
134
155
  position_amount_a: string;
135
156
  position_amount_b: string;
136
157
  coin_type_a: string;
137
158
  coin_type_b: string;
138
159
  bin_infos?: BinLiquidityInfo;
139
160
  };
161
+ type ClmmBalance = {
162
+ position_id: string;
163
+ certified_pool_id: string;
164
+ liquidity: string;
165
+ tick_lower_index: number;
166
+ tick_upper_index: number;
167
+ position_amount_a: string;
168
+ position_amount_b: string;
169
+ };
170
+ type VaultsBalanceV2 = {
171
+ vault_id: string;
172
+ lp_token_type: string;
173
+ lp_token_balance: string;
174
+ owner: string;
175
+ coin_type_a: string;
176
+ coin_type_b: string;
177
+ amount_a: string;
178
+ amount_b: string;
179
+ position_amount_a: string;
180
+ position_amount_b: string;
181
+ dlmm_balances: DlmmBalance[];
182
+ clmm_balances: ClmmBalance[];
183
+ share_buffer_assets: Balances[];
184
+ };
140
185
  type DepositCalculationValueOptionsV2 = {
141
186
  uuid?: string;
142
187
  pool_id: string;
143
188
  mode: 'FlexibleBoth' | 'OnlyCoinA' | 'OnlyCoinB';
144
189
  amount_usd: string;
145
190
  re_balance?: boolean;
191
+ coin_decimals_a: number;
192
+ coin_decimals_b: number;
146
193
  };
147
194
  type SwapResult = {
148
195
  swap_in_amount: string;
@@ -154,6 +201,8 @@ type DepositOptionsV2 = {
154
201
  amount_a: string;
155
202
  amount_b: string;
156
203
  return_lp_coin?: boolean;
204
+ coin_a_input?: TransactionObjectArgument;
205
+ coin_b_input?: TransactionObjectArgument;
157
206
  re_balance?: {
158
207
  swap_result: SwapResult;
159
208
  coin_amount: string;
@@ -236,6 +285,7 @@ type Pool = {
236
285
  quote_type: string;
237
286
  lp_token_type: string;
238
287
  protocol_fee_rate: string;
288
+ version: 'v1';
239
289
  };
240
290
  type CollectRewardOptions = {
241
291
  reward_coin_types: string[];
@@ -313,6 +363,7 @@ type WithdrawOptions = {
313
363
  mode: WithdrawMode;
314
364
  slippage?: number;
315
365
  partner?: string;
366
+ return_coin?: boolean;
316
367
  extra_burn?: {
317
368
  lp_burn_coin: TransactionObjectArgument;
318
369
  burn_lp_amount: string;
@@ -350,6 +401,7 @@ type VaultsBalance = {
350
401
  amount_b: string;
351
402
  coin_type_a: string;
352
403
  coin_type_b: string;
404
+ share_buffer_assets: Balances[];
353
405
  };
354
406
  type ClmmPoolBalance = {
355
407
  vault_id: string;
@@ -433,6 +485,7 @@ declare class PythPriceModule implements IModule {
433
485
  * @returns The transaction object with the Pyth price update payload.
434
486
  */
435
487
  buildUpdatePythPricePayload(coinTypeList: string[], tx: Transaction): Promise<Transaction>;
488
+ buildUpdatePythPricePayloadV2(coinTypeList: string[], tx: Transaction): Promise<Transaction>;
436
489
  /**
437
490
  * Retrieves feed information by parsing JSON data based on the environment and coin type.
438
491
  *
@@ -451,6 +504,77 @@ declare class PythPriceModule implements IModule {
451
504
  getFeedInfo(coinType: string, forceRefresh: boolean): Promise<FeedInfo>;
452
505
  }
453
506
 
507
+ type VaultVersionRef = {
508
+ vault_id: string;
509
+ version: 'v1' | 'v2';
510
+ };
511
+ type CalculateMigrateWithdrawOptions = {
512
+ from_vault: VaultVersionRef;
513
+ to_vault: VaultVersionRef;
514
+ burn_ft_amount: string;
515
+ };
516
+ type VaultAndPoolV2 = {
517
+ marketList: WarpVaultMarket[];
518
+ pool: VaultPool;
519
+ };
520
+ type VaultAndPoolV1 = {
521
+ clmmPool: Pool$1;
522
+ pool: Pool;
523
+ };
524
+ type CalculateMigrateWithdrawResult = {
525
+ from_vault: VaultVersionRef;
526
+ to_vault: VaultVersionRef;
527
+ burn_ft_amount: string;
528
+ deposit_amount_a: string;
529
+ deposit_amount_b: string;
530
+ obtained_ft_amount: string;
531
+ from_swap_result: SwapCoinResult;
532
+ };
533
+ type MigrateWithdrawOptions = {
534
+ withdraw_result: CalculateMigrateWithdrawResult;
535
+ return_ft_coin?: boolean;
536
+ liquidity_slippage: number;
537
+ extra_burn?: {
538
+ lp_burn_coin: TransactionObjectArgument;
539
+ burn_lp_amount: string;
540
+ };
541
+ };
542
+ type SwapCoinOptions = {
543
+ from: {
544
+ coin_type_a: string;
545
+ coin_amount_a: string;
546
+ coin_type_b: string;
547
+ coin_amount_b: string;
548
+ };
549
+ to: {
550
+ coin_type_a: string;
551
+ coin_type_b: string;
552
+ };
553
+ };
554
+ type RebalanceSwapResult = {
555
+ final_amount_a: string;
556
+ final_amount_b: string;
557
+ route_obj?: {
558
+ swap_direction: 'A_TO_B' | 'B_TO_A';
559
+ } & SwapResult;
560
+ };
561
+ type SwapCoinResult = {
562
+ coin_output_a: {
563
+ from_coin_type: string;
564
+ from_coin_amount: string;
565
+ to_coin_type: string;
566
+ to_coin_amount: string;
567
+ route_obj?: SwapResult;
568
+ };
569
+ coin_output_b: {
570
+ from_coin_type: string;
571
+ from_coin_amount: string;
572
+ to_coin_type: string;
573
+ to_coin_amount: string;
574
+ route_obj?: SwapResult;
575
+ };
576
+ };
577
+
454
578
  /**
455
579
  * VaultsModule handles interactions with vaults and pools within the system.
456
580
  */
@@ -468,15 +592,17 @@ declare class VaultsModule implements IModule {
468
592
  * Retrieves the balance of a specific vault for a given wallet address.
469
593
  * @param walletAddress - The wallet address to query.
470
594
  * @param poolId - The ID of the pool associated with the vault.
595
+ * @param append_buffer_assets - Whether to append buffer assets to the balance.
471
596
  * @returns The balance information of the vault.
472
597
  */
473
- getOwnerVaultsBalance(walletAddress: string, poolId: string): Promise<VaultsBalance>;
598
+ getOwnerVaultsBalance(walletAddress: string, poolId: string, append_buffer_assets?: boolean): Promise<VaultsBalance>;
474
599
  /**
475
600
  * Retrieves the list of vault balances for a given wallet address.
476
601
  * @param walletAddress - The wallet address to query.
602
+ * @param append_buffer_assets - Whether to append buffer assets to the balance.
477
603
  * @returns A list of vault balances.
478
604
  */
479
- getOwnerVaultsBalanceList(walletAddress: string): Promise<VaultsBalance[]>;
605
+ getOwnerVaultsBalanceList(walletAddress: string, append_buffer_assets?: boolean): Promise<VaultsBalance[]>;
480
606
  /**
481
607
  * Retrieves the rewards and fees for a specific vault position.
482
608
  * @param poolId - The ID of the pool associated with the vault.
@@ -527,7 +653,10 @@ declare class VaultsModule implements IModule {
527
653
  * @param tx - An optional transaction object to append to, or a new one if not provided.
528
654
  * @returns The updated transaction object.
529
655
  */
530
- buildWithdrawPayload(options: WithdrawOptions, tx?: Transaction): Promise<Transaction>;
656
+ buildWithdrawPayload(options: WithdrawOptions, tx: Transaction): Promise<{
657
+ return_coin_a?: TransactionObjectArgument;
658
+ return_coin_b?: TransactionObjectArgument;
659
+ }>;
531
660
  /**
532
661
  * Handles the swap operation for liquidity pool tokens, calculates the amounts to be received after withdrawal,
533
662
  * finds the best swap route using the AggregatorClient, and executes the swap transaction.
@@ -555,7 +684,7 @@ declare class VaultsModule implements IModule {
555
684
  is_receive_coin_a: boolean, // Boolean flag to determine if the user is receiving coin A or coin B.
556
685
  slippage: number, // The slippage tolerance for the swap.
557
686
  partner?: string, // Optional partner address for the swap.
558
- liquidityChanges?: PreSwapLpChangeParams[]): Promise<void>;
687
+ liquidityChanges?: PreSwapLpChangeParams[], return_coin?: boolean): Promise<TransactionObjectArgument | undefined>;
559
688
  /**
560
689
  * Builds a list of transaction objects to withdraw rewards from a liquidity pool.
561
690
  * The method generates multiple `moveCall` transaction objects for each reward coin type,
@@ -572,7 +701,10 @@ declare class VaultsModule implements IModule {
572
701
  */
573
702
  private buildWithdrawBufferReward;
574
703
  preCalculateDepositValue(options: DepositCalculationValueOptions, lpCallback?: LpCallback): Promise<DepositCalculationResult>;
575
- private calculateBalanceSwapAmount;
704
+ calculateBalanceSwapAmount(options: DepositCalculationOptions): Promise<{
705
+ swap_result: SwapResult;
706
+ liquidity_info: _cetusprotocol_common_sdk.LiquidityInput;
707
+ }>;
576
708
  /**
577
709
  * Pre-calculates the deposit amounts for a liquidity pool based on different deposit modes.
578
710
  * The method calculates how much of each coin to deposit and how much LP (liquidity provider) tokens the user will receive.
@@ -593,10 +725,7 @@ declare class VaultsModule implements IModule {
593
725
  *
594
726
  * @throws {Error} Throws an error if the vault or CLMM pool cannot be fetched.
595
727
  */
596
- getVaultAndPool(pool_id: string, refreshPool?: boolean): Promise<{
597
- clmmPool: Pool$1;
598
- pool: Pool;
599
- }>;
728
+ getVaultAndPool(pool_id: string, refreshPool?: boolean): Promise<VaultAndPoolV1>;
600
729
  /**
601
730
  * Calculates the deposit amount for the "other side" of a liquidity pool when one side of the deposit is fixed.
602
731
  * This function is used in scenarios where a fixed amount of one coin is deposited, and the corresponding amount
@@ -818,19 +947,22 @@ declare class VaultsModuleV2 implements IModule {
818
947
  /**
819
948
  * Retrieves the balance of a specific vault for a given wallet address.
820
949
  * @param walletAddress - The wallet address to query.
821
- * @param poolId - The ID of the pool associated with the vault.
950
+ * @param vaultId - The ID of the pool associated with the vault.
822
951
  * @returns The balance information of the vault.
823
952
  */
824
- getOwnerVaultsBalance(walletAddress: string, poolId: string): Promise<VaultsBalanceV2>;
953
+ getOwnerVaultsBalance(walletAddress: string, vaultId: string, append_buffer_assets?: boolean): Promise<VaultsBalanceV2>;
825
954
  /**
826
955
  * Retrieves the list of vault balances for a given wallet address.
827
956
  * @param walletAddress - The wallet address to query.
828
957
  * @returns A list of vault balances.
829
958
  */
830
959
  getOwnerVaultsBalanceList(walletAddress: string): Promise<VaultsBalanceV2[]>;
831
- getVaultsPositionRewarderAndFee(poolId: string, positionId: string, useBuildCollectFeePayload?: boolean): Promise<{
832
- feeList: Balances[];
833
- rewarderList: Balances[];
960
+ private buildCollectRewardAndFeePayload;
961
+ getVaultsPositionRewarderAndFee(poolId: string): Promise<{
962
+ dlmmRewarderList: Balances[];
963
+ dlmmFeeList: Balances[];
964
+ clmmRewarderList: Balances[];
965
+ clmmFeeList: Balances[];
834
966
  }>;
835
967
  /**
836
968
  * Retrieves the list of pools with optional pagination.
@@ -851,10 +983,12 @@ declare class VaultsModuleV2 implements IModule {
851
983
  * @returns The list of pools.
852
984
  */
853
985
  getAssignPoolList(poolIds: string[]): Promise<VaultPool[]>;
854
- geMarketList(vaultIds: string[]): Promise<Record<string, DLMMMarket>>;
855
- getMarketPositionList(positionTableId: string): Promise<DLMMMarketPosition[]>;
856
- buildCollectRewardPayload(options: CollectRewardOptionsV2, tx: Transaction): void;
857
- buildCollectFeePayload(options: CollectFeeOptionsV2, tx: Transaction): void;
986
+ geMarketList(vaultIds: string[]): Promise<Record<string, VaultMarket[]>>;
987
+ getMarketPositionList(positionTableId: string): Promise<(DLMMMarketPosition | CLMMMarketPosition)[]>;
988
+ buildDlmmCollectRewardPayload(options: CollectRewardOptionsV2, tx: Transaction): void;
989
+ buildClmmCollectRewardPayload(options: CollectRewardOptionsV2, tx: Transaction): void;
990
+ buildDlmmCollectFeePayload(options: CollectFeeOptionsV2, tx: Transaction): void;
991
+ buildClmmCollectFeePayload(options: CollectFeeOptionsV2, tx: Transaction): void;
858
992
  /**
859
993
  * Builds a transaction payload to deposit from a pool.
860
994
  * @param options - The options required to collect fees.
@@ -904,6 +1038,10 @@ declare class VaultsModuleV2 implements IModule {
904
1038
  */
905
1039
  private buildWithdrawBufferReward;
906
1040
  preCalculateDepositValue(options: DepositCalculationValueOptionsV2, lpCallback?: LpCallback): Promise<DepositCalculationResultV2>;
1041
+ calculateClmmBalanceSwapAmount(options: DepositCalculationOptionsV2, clmmMarket: WarpVaultMarket): Promise<{
1042
+ swap_result: SwapResult;
1043
+ liquidity_info: _cetusprotocol_common_sdk.LiquidityInput;
1044
+ }>;
907
1045
  private calculateBalanceSwapAmount;
908
1046
  /**
909
1047
  * Pre-calculates the deposit amounts for a liquidity pool based on different deposit modes.
@@ -914,15 +1052,14 @@ declare class VaultsModuleV2 implements IModule {
914
1052
  * @returns {Promise<DepositCalculationResult>} A promise that resolves to the calculated deposit amounts and the LP tokens to be received.
915
1053
  */
916
1054
  preCalculateDepositAmount(options: DepositCalculationOptionsV2, lpCallback?: LpCallback): Promise<DepositCalculationResultV2>;
917
- getVaultAndPool(pool_id: string, refreshPool?: boolean): Promise<{
918
- dlmmPool: DlmmPool;
919
- pool: VaultPool;
920
- }>;
1055
+ getVaultAndPool(pool_id: string, refreshPool?: boolean): Promise<VaultAndPoolV2>;
921
1056
  private calculatePositionValueRates;
922
- private calculateDepositAmountsV2;
1057
+ private calculateDepositAmountByValue;
1058
+ private calculateDepositDlmmAmountsV2;
1059
+ private calculateDepositClmmAmounts;
923
1060
  private calculateDepositOtherSide;
924
1061
  private calculateDepositFlexibleBoth;
925
- private calculateDepositLpAmountBoth;
1062
+ calculateDepositLpAmountBoth(pool: VaultPool, coin_amount_a: string, coin_amount_b: string): Promise<string>;
926
1063
  /**
927
1064
  * Pre-calculates the withdrawal amounts based on the provided options.
928
1065
  * Depending on the withdrawal mode, it calculates how much of each coin (A and B) the user will receive
@@ -940,6 +1077,55 @@ declare class VaultsModuleV2 implements IModule {
940
1077
  findRouters(from: string, target: string, amount: string): Promise<SwapResult>;
941
1078
  }
942
1079
 
1080
+ /**
1081
+ * Helper class to help interact with Migrate interface.
1082
+ */
1083
+ declare class MigrateModule implements IModule {
1084
+ protected _sdk: VolatileVaultsSDK;
1085
+ constructor(sdk: VolatileVaultsSDK);
1086
+ get sdk(): VolatileVaultsSDK;
1087
+ getVaultAndPool<T extends VaultAndPoolV1 | VaultAndPoolV2>(vault: VaultVersionRef): Promise<T>;
1088
+ /**
1089
+ * Build the migrate withdraw transaction
1090
+ * @param options MigrateWithdrawOptions
1091
+ * @param tx Transaction
1092
+ * @returns TransactionObjectArgument | undefined
1093
+ * @description
1094
+ * 1. Withdraw from the from vault
1095
+ * 2. Swap assets
1096
+ * 3. Calculate the amount of the to vault
1097
+ * 4. Return the result
1098
+ */
1099
+ buildMigrateWithdrawTx(options: MigrateWithdrawOptions, tx: Transaction): Promise<TransactionObjectArgument | undefined>;
1100
+ /**
1101
+ * Calculate the migrate withdraw amount
1102
+ * @param options CalculateMigrateWithdrawOptions
1103
+ * @returns CalculateMigrateWithdrawResult
1104
+ * @description
1105
+ * 1. Extract liquidity from the from vault
1106
+ * 2. Swap assets
1107
+ * 3. Calculate the amount of the to vault
1108
+ * 4. Return the result
1109
+ */
1110
+ calculateMigrateWithdraw(options: CalculateMigrateWithdrawOptions): Promise<CalculateMigrateWithdrawResult>;
1111
+ private buildSwapAssetsTx;
1112
+ /**
1113
+ * Matching algorithm: Match liquidity extracted from the from pool to the coin types of the to pool
1114
+ *
1115
+ * Matching process:
1116
+ * 1. Determine which from coin should match toCoinTypeA and which should match toCoinTypeB
1117
+ * - Prioritize matching coins of the same type (to minimize swaps)
1118
+ * - coinOutputA always represents toCoinTypeA, coinOutputB always represents toCoinTypeB
1119
+ * - from_coin_type can be adjusted based on which from coin matches the corresponding to coin type
1120
+ * 2. For coins that don't match, find swap route and calculate the amount after swap
1121
+ * 3. Return matching result, including swap route and final coin amounts
1122
+ *
1123
+ * @param options SwapCoinOptions - Contains coin types and amounts from the from pool, and coin types from the to pool
1124
+ * @returns SwapCoinResult - Matching result, including swap route and final coin amounts
1125
+ */
1126
+ matchSwapCoins(options: SwapCoinOptions): Promise<SwapCoinResult>;
1127
+ }
1128
+
943
1129
  /**
944
1130
  * Represents options and configurations for an SDK.
945
1131
  */
@@ -997,6 +1183,7 @@ declare class VolatileVaultsSDK {
997
1183
  * Module for managing vaultsV2.
998
1184
  */
999
1185
  protected _vaultsV2: VaultsModuleV2;
1186
+ protected _migrate: MigrateModule;
1000
1187
  /**
1001
1188
  * Client for interacting with the Aggregator service.
1002
1189
  */
@@ -1012,8 +1199,8 @@ declare class VolatileVaultsSDK {
1012
1199
  /**
1013
1200
  * SDK for interacting with Cetus DLMM (Dynamic Liquidity Market Maker).
1014
1201
  */
1015
- protected _cetusDlmmSDK: CetusDlmmSDK__default;
1016
- constructor(options: SdkOptions);
1202
+ protected _cetusDlmmSDK: CetusDlmmSDK;
1203
+ constructor(options: SdkOptions, clmmSdk?: CetusClmmSDK, dlmmSdk?: CetusDlmmSDK);
1017
1204
  /**
1018
1205
  * Getter for the sender address property.
1019
1206
  * @returns {SuiAddressType} The sender address.
@@ -1058,12 +1245,17 @@ declare class VolatileVaultsSDK {
1058
1245
  * Getter for the CetusDlmmSDK instance.
1059
1246
  * @returns {CetusDlmmSDK} The CetusDlmmSDK instance.
1060
1247
  */
1061
- get CetusDlmmSDK(): CetusDlmmSDK__default;
1248
+ get CetusDlmmSDK(): CetusDlmmSDK;
1062
1249
  /**
1063
1250
  * Getter for the VestModule instance.
1064
1251
  * @returns {VestModule} The VestModule instance.
1065
1252
  */
1066
1253
  get Vest(): VestModule;
1254
+ /**
1255
+ * Getter for the MigrateModule instance.
1256
+ * @returns {MigrateModule} The MigrateModule instance.
1257
+ */
1258
+ get Migrate(): MigrateModule;
1067
1259
  /**
1068
1260
  * Verifies if the sender address is valid.
1069
1261
  * @throws Error if the sender address is invalid.
@@ -1210,7 +1402,8 @@ declare function getShareBufferAssets(lp_amount: string, balances: Balances[], l
1210
1402
  declare function buildVaultsBalance(walletAddress: string, // The address of the wallet holding the vault
1211
1403
  token_amount: string, // The amount of LP tokens the wallet has in the pool
1212
1404
  pool: Pool, // The pool containing liquidity and tick information
1213
- clmmPool: Pool$1): VaultsBalance;
1405
+ clmmPool: Pool$1, // The CLMM pool containing current market conditions (e.g., price)
1406
+ append_buffer_assets?: boolean): VaultsBalance;
1214
1407
  declare function getVaultValidBalances(poolBalances: Balances[], feeList: Balances[], rewarderList: Balances[]): Balances[];
1215
1408
  declare function getUpdatePriceType(rewarderList: string[], coin_type_a: string, coin_type_b: string): string[];
1216
1409
  /**
@@ -1261,25 +1454,15 @@ declare function parseVaultsVestInfo(res: SuiObjectResponse): VaultsVestInfo;
1261
1454
  */
1262
1455
  declare function parseVaultVestNFT(res: SuiObjectResponse): VaultVestNFT;
1263
1456
 
1264
- declare function buildDLMMMarket(data: any): DLMMMarket | undefined;
1457
+ declare function buildVaultMarket(data: any): VaultMarket | undefined;
1265
1458
  declare function buildDLMMMarketPosition(data: any): DLMMMarketPosition;
1459
+ declare function buildCLMMMarketPosition(data: any): CLMMMarketPosition;
1266
1460
  declare function buildPoolV2Data(data: any): VaultPool;
1267
- declare function calculateAumV2(sdk: VolatileVaultsSDK, pool: VaultPool, balances: Balances[], usePriceCache?: boolean): Promise<string>;
1268
- declare function buildVaultsBalanceV2(sdk: VolatileVaultsSDK, lp_token_amount: string, pool: VaultPool, dlmmPool: DlmmPool, walletAddress: string): Promise<VaultsBalanceV2>;
1269
- declare function getAmountBalanceByLpAmount(sdk: VolatileVaultsSDK, lp_token_amount: string, pool: VaultPool, dlmmPool: DlmmPool): Promise<{
1270
- valid_lower_bin_id: number;
1271
- valid_upper_bin_id: number;
1272
- receive_amount_a: string;
1273
- receive_amount_b: string;
1274
- position_coin_amount_a: string;
1275
- position_coin_amount_b: string;
1276
- bin_infos: {
1277
- bins: CetusDlmmSDK.BinAmount[];
1278
- amount_a: string;
1279
- amount_b: string;
1280
- };
1281
- }>;
1461
+ declare function calculateAumV2(sdk: VolatileVaultsSDK, vaultId: string, balances: Balances[], usePriceCache?: boolean): Promise<string>;
1462
+ declare function buildVaultsBalanceV2(sdk: VolatileVaultsSDK, lp_token_amount: string, vaultId: string, walletAddress?: string, append_buffer_assets?: boolean): Promise<VaultsBalanceV2>;
1463
+ declare function getAmountBalanceByLpAmount(sdk: VolatileVaultsSDK, lp_token_amount: string, vault_id: string, append_buffer_assets?: boolean): Promise<VaultsBalanceV2>;
1282
1464
  declare function buildDLMMMarketId(vaultId: string): string;
1465
+ declare function buildCLMMMarketId(vaultId: string): string;
1283
1466
  declare function buildDLMMPositionId(positionTableId: string, posId: string): string;
1284
1467
  /**
1285
1468
  * Calculate the swap amount needed to achieve target ratio
@@ -1308,6 +1491,7 @@ declare function calcExactSwapAmount(coin_amount: string, fix_amount_a: boolean,
1308
1491
  final_amount_b: string;
1309
1492
  best: string;
1310
1493
  };
1494
+ declare function calcSingleSideSwap(balanceA: string, balanceB: string, priceA: string, priceB: string, swapPrice: string, fixAmountA: boolean): string;
1311
1495
 
1312
1496
  declare const checkIsMinOrMaxIndex: (tick: number, type: "min" | "max", tickSpacing: number) => boolean;
1313
1497
  declare function convertU64BytesToDecimal(bytes: number[]): string;
@@ -1343,7 +1527,7 @@ declare const feed_map_mainnet: Record<string, FeedInfo>;
1343
1527
  * @param fullNodeUrl. If provided, it will be used as the full node URL.
1344
1528
  * @returns
1345
1529
  */
1346
- declare function initMainnetSDK(fullNodeUrl?: string): VolatileVaultsSDK;
1530
+ declare function initMainnetSDK(fullNodeUrl?: string, clmmSdk?: CetusClmmSDK$1, dlmmSdk?: CetusDlmmSDK): VolatileVaultsSDK;
1347
1531
 
1348
1532
  declare const vaults_testnet: SdkOptions;
1349
1533
  declare const feed_map_testnet: Record<string, FeedInfo>;
@@ -1352,7 +1536,7 @@ declare const feed_map_testnet: Record<string, FeedInfo>;
1352
1536
  * @param fullNodeUrl. If provided, it will be used as the full node URL.
1353
1537
  * @returns
1354
1538
  */
1355
- declare function initTestnetSDK(fullNodeUrl?: string): VolatileVaultsSDK;
1539
+ declare function initTestnetSDK(fullNodeUrl?: string, clmmSdk?: CetusClmmSDK$1, dlmmSdk?: CetusDlmmSDK): VolatileVaultsSDK;
1356
1540
 
1357
1541
  declare enum SdkEnv {
1358
1542
  mainnet = "mainnet",
@@ -1368,7 +1552,7 @@ interface InitSDKOptions {
1368
1552
  * @param fullNodeUrl - The full node URL to use.
1369
1553
  * @returns The initialized Volatile Vaults SDK.
1370
1554
  */
1371
- declare function initVaultSDK(options: InitSDKOptions): VolatileVaultsSDK;
1555
+ declare function initVaultSDK(options: InitSDKOptions, clmmSdk?: CetusClmmSDK$1, dlmmSdk?: CetusDlmmSDK): VolatileVaultsSDK;
1372
1556
  declare const defaultProvider: string[];
1373
1557
 
1374
- export { ActionAcl, Balances, BigNumber, ClmmPoolBalance, ClmmVault, CollectFeeOptions, CollectFeeOptionsV2, CollectRewardOptions, CollectRewardOptionsV2, DLMMMarket, DLMMMarketPosition, DepositCalculationOptions, DepositCalculationOptionsV2, DepositCalculationResult, DepositCalculationResultV2, DepositCalculationValueOptions, DepositCalculationValueOptionsV2, DepositMode, DepositOptions, DepositOptionsV2, FeedInfo, GlobalVestingPeriod, LiquidityRange, LpCallback, PackageConfigs, PeriodInfo, Pool, PoolCoinTypes, Price, PythConfigs, PythNodeError, PythPriceModule, RedeemOption, SdkEnv, SdkOptions, SwapResult, VaultPool, VaultVestNFT, VaultsBalance, VaultsBalanceV2, VaultsConfigs, VaultsModule, VaultsModuleV2, VaultsPosition, VaultsV2Configs, VaultsVestInfo, VestConfigs, VestCreateEvent, VestModule, VolatileVaultsSDK, WithdrawCalculationOptions, WithdrawCalculationResult, WithdrawCalculationResultV2, WithdrawMode, WithdrawOptions, WrapperPosition, buildDLMMMarket, buildDLMMMarketId, buildDLMMMarketPosition, buildDLMMPositionId, buildPoolData, buildPoolV2Data, buildVaultsBalance, buildVaultsBalanceV2, calcExactSwapAmount, calculateAum, calculateAumV2, calculateDepositRatioFixTokenA, calculateTotalAumBasedOnQuote, checkIsMinOrMaxIndex, convertU64BytesToDecimal, VolatileVaultsSDK as default, defaultProvider, estCoinAmountsFromTotalAmount, feed_map_mainnet, feed_map_testnet, getAmountBalanceByLpAmount, getCoinAmountsFromRatio, getPositionPriceRange, getPriceWithFormattedDecimals, getPrimitivePricesFromBaseQuote, getQuotePerBaseAndBasePerQuote, getShareBufferAssets, getUpdatePriceType, getVaultValidBalances, get_lp_amount_by_liquidity, get_lp_amount_by_tvl, get_share_liquidity_by_amount, initMainnetSDK, initTestnetSDK, initVaultSDK, oraclePriceMultiplierDecimal, parseVaultVestNFT, parseVaultsVestInfo, printTransaction, toSuiObjectId, vaults_mainnet, vaults_testnet };
1558
+ export { ActionAcl, Balances, BigNumber, CLMMMarketPosition, CalculateMigrateWithdrawOptions, CalculateMigrateWithdrawResult, ClmmBalance, ClmmPoolBalance, ClmmPosition, ClmmVault, CollectFeeOptions, CollectFeeOptionsV2, CollectRewardOptions, CollectRewardOptionsV2, DLMMMarketPosition, DepositCalculationOptions, DepositCalculationOptionsV2, DepositCalculationResult, DepositCalculationResultV2, DepositCalculationValueOptions, DepositCalculationValueOptionsV2, DepositMode, DepositOptions, DepositOptionsV2, DlmmBalance, FeedInfo, GlobalVestingPeriod, LiquidityRange, LpCallback, MigrateWithdrawOptions, PackageConfigs, PeriodInfo, Pool, PoolCoinTypes, Price, PythConfigs, PythNodeError, PythPriceModule, RebalanceSwapResult, RedeemOption, SdkEnv, SdkOptions, SwapCoinOptions, SwapCoinResult, SwapResult, VaultAndPoolV1, VaultAndPoolV2, VaultMarket, VaultMarketType, VaultPool, VaultVersionRef, VaultVestNFT, VaultsBalance, VaultsBalanceV2, VaultsConfigs, VaultsModule, VaultsModuleV2, VaultsPosition, VaultsV2Configs, VaultsVestInfo, VestConfigs, VestCreateEvent, VestModule, VolatileVaultsSDK, WarpVaultMarket, WithdrawCalculationOptions, WithdrawCalculationResult, WithdrawCalculationResultV2, WithdrawMode, WithdrawOptions, WrapperPosition, buildCLMMMarketId, buildCLMMMarketPosition, buildDLMMMarketId, buildDLMMMarketPosition, buildDLMMPositionId, buildPoolData, buildPoolV2Data, buildVaultMarket, buildVaultsBalance, buildVaultsBalanceV2, calcExactSwapAmount, calcSingleSideSwap, calculateAum, calculateAumV2, calculateDepositRatioFixTokenA, calculateTotalAumBasedOnQuote, checkIsMinOrMaxIndex, convertU64BytesToDecimal, VolatileVaultsSDK as default, defaultProvider, dlmm_split_rate, estCoinAmountsFromTotalAmount, feed_map_mainnet, feed_map_testnet, getAmountBalanceByLpAmount, getCoinAmountsFromRatio, getPositionPriceRange, getPriceWithFormattedDecimals, getPrimitivePricesFromBaseQuote, getQuotePerBaseAndBasePerQuote, getShareBufferAssets, getUpdatePriceType, getVaultValidBalances, get_lp_amount_by_liquidity, get_lp_amount_by_tvl, get_share_liquidity_by_amount, initMainnetSDK, initTestnetSDK, initVaultSDK, oraclePriceMultiplierDecimal, parseVaultVestNFT, parseVaultsVestInfo, printTransaction, toSuiObjectId, vaults_mainnet, vaults_testnet };