haedal-vault-sdk 1.8.5 → 2.1.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,12 +1,11 @@
1
1
  import { CoinBalance, SuiObjectResponse } from '@mysten/sui/client';
2
2
  import { PreSwapLpChangeParams, AggregatorClient } from '@cetusprotocol/aggregator-sdk';
3
- import { PaginationArgs, DataPage, CoinPairType, TableHandle, IModule as IModule$1, Package, SuiAddressType, FullClient, CoinAsset, SuiResource } from '@cetusprotocol/common-sdk';
3
+ import { TableHandle, PaginationArgs, DataPage, CoinPairType, IModule as IModule$1, Package, SuiAddressType, FullClient, CoinAsset, SuiResource } from '@cetusprotocol/common-sdk';
4
4
  import { Pool as Pool$1, CetusClmmSDK } from '@cetusprotocol/sui-clmm-sdk';
5
5
  import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
6
- import * as _pythnetwork_price_service_sdk from '@pythnetwork/price-service-sdk';
7
- import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
8
6
  import * as CetusDlmmSDK from '@cetusprotocol/dlmm-sdk';
9
7
  import CetusDlmmSDK__default, { DlmmPosition, BinLiquidityInfo, DlmmPool } from '@cetusprotocol/dlmm-sdk';
8
+ import { SuiPriceServiceConnection, SuiPythClient, PriceUpdate } from '@pythnetwork/pyth-sui-js';
10
9
  import BN from 'bn.js';
11
10
  import Decimal from 'decimal.js';
12
11
 
@@ -14,6 +13,155 @@ interface IModule {
14
13
  readonly sdk: VolatileVaultsSDK;
15
14
  }
16
15
 
16
+ type VaultsV2Configs = {
17
+ package_id: string;
18
+ published_at: string;
19
+ configs: {
20
+ registry_id: string;
21
+ pools_handle: string;
22
+ global_config_id: string;
23
+ versioned_id: string;
24
+ pyth_oracle_id: string;
25
+ oracle_infos_handle: string;
26
+ };
27
+ };
28
+ type ActionAcl = {
29
+ is_deposit_allowed: boolean;
30
+ is_withdraw_allowed: boolean;
31
+ };
32
+ type DLMMMarketPosition = {
33
+ id: string;
34
+ position: DlmmPosition;
35
+ valid_lower_bin_id: number;
36
+ valid_upper_bin_id: number;
37
+ amounts: Balances;
38
+ };
39
+ type DLMMMarket = {
40
+ id: string;
41
+ vault_id: string;
42
+ certified_pools: string[];
43
+ positions_handle: TableHandle;
44
+ position_list: DLMMMarketPosition[];
45
+ position_keys: string[];
46
+ } & PoolCoinTypes;
47
+ type VaultPool = {
48
+ id: string;
49
+ lp_token_treasury: string;
50
+ quote_type?: string;
51
+ buffer_assets: Balances[];
52
+ hard_cap: string;
53
+ markets_handle: TableHandle;
54
+ markets: DLMMMarket[];
55
+ protocol_fees_handle: TableHandle;
56
+ lp_token_type: string;
57
+ action_status: ActionAcl;
58
+ last_aum: string;
59
+ protocol_fee_rate: string;
60
+ } & PoolCoinTypes;
61
+ type CollectRewardOptionsV2 = {
62
+ reward_coin_types: string[];
63
+ lp_token_type: string;
64
+ pool_id: string;
65
+ certified_pool_id: string;
66
+ position_id: string;
67
+ withdraw_cert?: TransactionObjectArgument;
68
+ } & PoolCoinTypes;
69
+ type CollectFeeOptionsV2 = {
70
+ lp_token_type: string;
71
+ pool_id: string;
72
+ certified_pool_id: string;
73
+ position_id: string;
74
+ withdraw_cert?: TransactionObjectArgument;
75
+ } & PoolCoinTypes;
76
+ type DepositCalculationOptionsV2 = {
77
+ uuid?: string;
78
+ pool_id: string;
79
+ mode: DepositMode;
80
+ } & ({
81
+ mode: 'FixedOneSide';
82
+ fixed_amount: string;
83
+ fixed_coin_a: boolean;
84
+ } | {
85
+ mode: 'FlexibleBoth';
86
+ coin_amount_a: string;
87
+ coin_amount_b: string;
88
+ } | {
89
+ mode: 'OnlyCoinA';
90
+ coin_amount_a: string;
91
+ re_balance?: boolean;
92
+ } | {
93
+ mode: 'OnlyCoinB';
94
+ coin_amount_b: string;
95
+ re_balance?: boolean;
96
+ });
97
+ type DepositCalculationResultV2 = {
98
+ deposit_amount_a: string;
99
+ deposit_amount_b: string;
100
+ lp_amount?: string;
101
+ uuid?: string;
102
+ mode: DepositMode;
103
+ re_balance?: {
104
+ swap_result: SwapResult;
105
+ coin_amount: string;
106
+ mode: 'OnlyCoinA' | 'OnlyCoinB';
107
+ };
108
+ };
109
+ type WithdrawCalculationResultV2 = {
110
+ burn_lp_amount: string;
111
+ receive_amount_a: string;
112
+ receive_amount_b: string;
113
+ mode: DepositMode;
114
+ swap?: {
115
+ swap_amount_in: string;
116
+ swap_amount_out: string;
117
+ remove_amount_a: string;
118
+ remove_amount_b: string;
119
+ };
120
+ };
121
+ type VaultsBalanceV2 = {
122
+ vault_id: string;
123
+ certified_pool_id: string;
124
+ owner: string;
125
+ lp_token_type: string;
126
+ lp_token_balance: string;
127
+ liquidity_shares: string[];
128
+ valid_lower_bin_id: number;
129
+ valid_upper_bin_id: number;
130
+ original_lower_bin_id: number;
131
+ original_upper_bin_id: number;
132
+ amount_a: string;
133
+ amount_b: string;
134
+ position_amount_a: string;
135
+ position_amount_b: string;
136
+ coin_type_a: string;
137
+ coin_type_b: string;
138
+ bin_infos?: BinLiquidityInfo;
139
+ };
140
+ type DepositCalculationValueOptionsV2 = {
141
+ uuid?: string;
142
+ pool_id: string;
143
+ mode: 'FlexibleBoth' | 'OnlyCoinA' | 'OnlyCoinB';
144
+ amount_usd: string;
145
+ re_balance?: boolean;
146
+ };
147
+ type SwapResult = {
148
+ swap_in_amount: string;
149
+ swap_out_amount: string;
150
+ route_obj?: any;
151
+ };
152
+ type DepositOptionsV2 = {
153
+ pool_id: string;
154
+ amount_a: string;
155
+ amount_b: string;
156
+ return_lp_coin?: boolean;
157
+ re_balance?: {
158
+ swap_result: SwapResult;
159
+ coin_amount: string;
160
+ mode: 'OnlyCoinA' | 'OnlyCoinB';
161
+ swap_slippage: number;
162
+ };
163
+ };
164
+
17
165
  type PythConfigs = {
18
166
  pyth_package_id: string;
19
167
  pyth_published_at: string;
@@ -110,6 +258,12 @@ type DepositOptions = {
110
258
  amount_a: string;
111
259
  amount_b: string;
112
260
  return_lp_coin?: boolean;
261
+ re_balance?: {
262
+ swap_result: SwapResult;
263
+ coin_amount: string;
264
+ mode: 'OnlyCoinA' | 'OnlyCoinB';
265
+ swap_slippage: number;
266
+ };
113
267
  };
114
268
  type DepositMode = 'FixedOneSide' | 'FlexibleBoth' | 'OnlyCoinA' | 'OnlyCoinB';
115
269
  type LpCallback = {
@@ -131,9 +285,11 @@ type DepositCalculationOptions = {
131
285
  } | {
132
286
  mode: 'OnlyCoinA';
133
287
  coin_amount_a: string;
288
+ re_balance?: boolean;
134
289
  } | {
135
290
  mode: 'OnlyCoinB';
136
291
  coin_amount_b: string;
292
+ re_balance?: boolean;
137
293
  });
138
294
  type DepositCalculationValueOptions = {
139
295
  uuid?: string;
@@ -145,6 +301,11 @@ type DepositCalculationResult = {
145
301
  deposit_amount_a: string;
146
302
  deposit_amount_b: string;
147
303
  mode: DepositMode;
304
+ lp_amount?: string;
305
+ re_balance?: {
306
+ swap_result: SwapResult;
307
+ coin_amount: string;
308
+ };
148
309
  };
149
310
  type WithdrawOptions = {
150
311
  pool_id: string;
@@ -263,7 +424,7 @@ declare class PythPriceModule implements IModule {
263
424
  */
264
425
  getLatestPrice(coinTypeList: string[], useCache?: boolean): Promise<Record<string, Price>>;
265
426
  getPriceFeedsUpdateData(feedIds: string[]): Promise<Buffer[] | undefined>;
266
- getLatestPriceFeeds(feedIds: string[]): Promise<_pythnetwork_price_service_sdk.PriceFeed[] | undefined>;
427
+ getLatestPriceFeeds(feedIds: string[]): Promise<PriceUpdate | undefined>;
267
428
  /**
268
429
  * Builds the payload to update Pyth price feeds with the provided coin types and transaction.
269
430
  *
@@ -331,6 +492,7 @@ declare class VaultsModule implements IModule {
331
492
  * @returns A paginated list of pools.
332
493
  */
333
494
  getPoolList(paginationArgs?: PaginationArgs): Promise<DataPage<Pool>>;
495
+ getAssignPoolList(assign_pool_ids: string[]): Promise<Pool[]>;
334
496
  /**
335
497
  * Retrieves details of a specific pool by ID.
336
498
  * @param poolId - The unique identifier of the pool.
@@ -410,6 +572,7 @@ declare class VaultsModule implements IModule {
410
572
  */
411
573
  private buildWithdrawBufferReward;
412
574
  preCalculateDepositValue(options: DepositCalculationValueOptions, lpCallback?: LpCallback): Promise<DepositCalculationResult>;
575
+ private calculateBalanceSwapAmount;
413
576
  /**
414
577
  * Pre-calculates the deposit amounts for a liquidity pool based on different deposit modes.
415
578
  * The method calculates how much of each coin to deposit and how much LP (liquidity provider) tokens the user will receive.
@@ -418,7 +581,7 @@ declare class VaultsModule implements IModule {
418
581
  *
419
582
  * @returns {Promise<DepositCalculationResult>} A promise that resolves to the calculated deposit amounts and the LP tokens to be received.
420
583
  */
421
- preCalculateDepositAmount(options: DepositCalculationOptions, lpCallback: LpCallback): Promise<DepositCalculationResult>;
584
+ preCalculateDepositAmount(options: DepositCalculationOptions, lpCallback?: LpCallback): Promise<DepositCalculationResult>;
422
585
  /**
423
586
  * Retrieves the vault and pool information based on the provided pool_id.
424
587
  * It first fetches the vault details, then retrieves the associated CLMM (Constant Product Market Maker) pool details.
@@ -600,155 +763,6 @@ type RedeemOption = {
600
763
  period: number;
601
764
  } & CoinPairType;
602
765
 
603
- type VaultsV2Configs = {
604
- package_id: string;
605
- published_at: string;
606
- configs: {
607
- registry_id: string;
608
- pools_handle: string;
609
- global_config_id: string;
610
- versioned_id: string;
611
- pyth_oracle_id: string;
612
- oracle_infos_handle: string;
613
- };
614
- };
615
- type ActionAcl = {
616
- is_deposit_allowed: boolean;
617
- is_withdraw_allowed: boolean;
618
- };
619
- type DLMMMarketPosition = {
620
- id: string;
621
- position: DlmmPosition;
622
- valid_lower_bin_id: number;
623
- valid_upper_bin_id: number;
624
- amounts: Balances;
625
- };
626
- type DLMMMarket = {
627
- id: string;
628
- vault_id: string;
629
- certified_pools: string[];
630
- positions_handle: TableHandle;
631
- position_list: DLMMMarketPosition[];
632
- position_keys: string[];
633
- } & PoolCoinTypes;
634
- type VaultPool = {
635
- id: string;
636
- lp_token_treasury: string;
637
- quote_type?: string;
638
- buffer_assets: Balances[];
639
- hard_cap: string;
640
- markets_handle: TableHandle;
641
- markets: DLMMMarket[];
642
- protocol_fees_handle: TableHandle;
643
- lp_token_type: string;
644
- action_status: ActionAcl;
645
- last_aum: string;
646
- protocol_fee_rate: string;
647
- } & PoolCoinTypes;
648
- type CollectRewardOptionsV2 = {
649
- reward_coin_types: string[];
650
- lp_token_type: string;
651
- pool_id: string;
652
- certified_pool_id: string;
653
- position_id: string;
654
- withdraw_cert?: TransactionObjectArgument;
655
- } & PoolCoinTypes;
656
- type CollectFeeOptionsV2 = {
657
- lp_token_type: string;
658
- pool_id: string;
659
- certified_pool_id: string;
660
- position_id: string;
661
- withdraw_cert?: TransactionObjectArgument;
662
- } & PoolCoinTypes;
663
- type DepositCalculationOptionsV2 = {
664
- uuid?: string;
665
- pool_id: string;
666
- mode: DepositMode;
667
- } & ({
668
- mode: 'FixedOneSide';
669
- fixed_amount: string;
670
- fixed_coin_a: boolean;
671
- } | {
672
- mode: 'FlexibleBoth';
673
- coin_amount_a: string;
674
- coin_amount_b: string;
675
- } | {
676
- mode: 'OnlyCoinA';
677
- coin_amount_a: string;
678
- re_balance?: boolean;
679
- } | {
680
- mode: 'OnlyCoinB';
681
- coin_amount_b: string;
682
- re_balance?: boolean;
683
- });
684
- type DepositCalculationResultV2 = {
685
- deposit_amount_a: string;
686
- deposit_amount_b: string;
687
- lp_amount?: string;
688
- uuid?: string;
689
- mode: DepositMode;
690
- re_balance?: {
691
- swap_result: SwapResult;
692
- coin_amount: string;
693
- mode: 'OnlyCoinA' | 'OnlyCoinB';
694
- };
695
- };
696
- type WithdrawCalculationResultV2 = {
697
- burn_lp_amount: string;
698
- receive_amount_a: string;
699
- receive_amount_b: string;
700
- mode: DepositMode;
701
- swap?: {
702
- swap_amount_in: string;
703
- swap_amount_out: string;
704
- remove_amount_a: string;
705
- remove_amount_b: string;
706
- };
707
- };
708
- type VaultsBalanceV2 = {
709
- vault_id: string;
710
- certified_pool_id: string;
711
- owner: string;
712
- lp_token_type: string;
713
- lp_token_balance: string;
714
- liquidity_shares: string[];
715
- valid_lower_bin_id: number;
716
- valid_upper_bin_id: number;
717
- original_lower_bin_id: number;
718
- original_upper_bin_id: number;
719
- amount_a: string;
720
- amount_b: string;
721
- position_amount_a: string;
722
- position_amount_b: string;
723
- coin_type_a: string;
724
- coin_type_b: string;
725
- bin_infos?: BinLiquidityInfo;
726
- };
727
- type DepositCalculationValueOptionsV2 = {
728
- uuid?: string;
729
- pool_id: string;
730
- mode: 'FlexibleBoth' | 'OnlyCoinA' | 'OnlyCoinB';
731
- amount_usd: string;
732
- re_balance?: boolean;
733
- };
734
- type SwapResult = {
735
- swap_in_amount: string;
736
- swap_out_amount: string;
737
- route_obj?: any;
738
- };
739
- type DepositOptionsV2 = {
740
- pool_id: string;
741
- amount_a: string;
742
- amount_b: string;
743
- return_lp_coin?: boolean;
744
- re_balance?: {
745
- swap_result: SwapResult;
746
- coin_amount: string;
747
- mode: 'OnlyCoinA' | 'OnlyCoinB';
748
- swap_slippage: number;
749
- };
750
- };
751
-
752
766
  type BigNumber = Decimal.Value | number | string;
753
767
 
754
768
  declare class VestModule implements IModule$1<VolatileVaultsSDK> {