haedal-vault-sdk 2.0.0 → 2.1.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 +167 -152
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +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,
|
|
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 { SuiPriceServiceConnection, SuiPythClient, PriceUpdate } from '@pythnetwork/pyth-sui-js';
|
|
7
6
|
import * as CetusDlmmSDK from '@cetusprotocol/dlmm-sdk';
|
|
8
7
|
import CetusDlmmSDK__default, { DlmmPosition, BinLiquidityInfo, DlmmPool } from '@cetusprotocol/dlmm-sdk';
|
|
8
|
+
import { SuiPriceServiceConnection, SuiPythClient, PriceUpdate } from '@pythnetwork/pyth-sui-js';
|
|
9
9
|
import BN from 'bn.js';
|
|
10
10
|
import Decimal from 'decimal.js';
|
|
11
11
|
|
|
@@ -13,6 +13,155 @@ interface IModule {
|
|
|
13
13
|
readonly sdk: VolatileVaultsSDK;
|
|
14
14
|
}
|
|
15
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
|
+
|
|
16
165
|
type PythConfigs = {
|
|
17
166
|
pyth_package_id: string;
|
|
18
167
|
pyth_published_at: string;
|
|
@@ -109,6 +258,12 @@ type DepositOptions = {
|
|
|
109
258
|
amount_a: string;
|
|
110
259
|
amount_b: string;
|
|
111
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
|
+
};
|
|
112
267
|
};
|
|
113
268
|
type DepositMode = 'FixedOneSide' | 'FlexibleBoth' | 'OnlyCoinA' | 'OnlyCoinB';
|
|
114
269
|
type LpCallback = {
|
|
@@ -130,9 +285,11 @@ type DepositCalculationOptions = {
|
|
|
130
285
|
} | {
|
|
131
286
|
mode: 'OnlyCoinA';
|
|
132
287
|
coin_amount_a: string;
|
|
288
|
+
re_balance?: boolean;
|
|
133
289
|
} | {
|
|
134
290
|
mode: 'OnlyCoinB';
|
|
135
291
|
coin_amount_b: string;
|
|
292
|
+
re_balance?: boolean;
|
|
136
293
|
});
|
|
137
294
|
type DepositCalculationValueOptions = {
|
|
138
295
|
uuid?: string;
|
|
@@ -144,6 +301,11 @@ type DepositCalculationResult = {
|
|
|
144
301
|
deposit_amount_a: string;
|
|
145
302
|
deposit_amount_b: string;
|
|
146
303
|
mode: DepositMode;
|
|
304
|
+
lp_amount?: string;
|
|
305
|
+
re_balance?: {
|
|
306
|
+
swap_result: SwapResult;
|
|
307
|
+
coin_amount: string;
|
|
308
|
+
};
|
|
147
309
|
};
|
|
148
310
|
type WithdrawOptions = {
|
|
149
311
|
pool_id: string;
|
|
@@ -330,6 +492,7 @@ declare class VaultsModule implements IModule {
|
|
|
330
492
|
* @returns A paginated list of pools.
|
|
331
493
|
*/
|
|
332
494
|
getPoolList(paginationArgs?: PaginationArgs): Promise<DataPage<Pool>>;
|
|
495
|
+
getAssignPoolList(assign_pool_ids: string[]): Promise<Pool[]>;
|
|
333
496
|
/**
|
|
334
497
|
* Retrieves details of a specific pool by ID.
|
|
335
498
|
* @param poolId - The unique identifier of the pool.
|
|
@@ -409,6 +572,7 @@ declare class VaultsModule implements IModule {
|
|
|
409
572
|
*/
|
|
410
573
|
private buildWithdrawBufferReward;
|
|
411
574
|
preCalculateDepositValue(options: DepositCalculationValueOptions, lpCallback?: LpCallback): Promise<DepositCalculationResult>;
|
|
575
|
+
private calculateBalanceSwapAmount;
|
|
412
576
|
/**
|
|
413
577
|
* Pre-calculates the deposit amounts for a liquidity pool based on different deposit modes.
|
|
414
578
|
* The method calculates how much of each coin to deposit and how much LP (liquidity provider) tokens the user will receive.
|
|
@@ -417,7 +581,7 @@ declare class VaultsModule implements IModule {
|
|
|
417
581
|
*
|
|
418
582
|
* @returns {Promise<DepositCalculationResult>} A promise that resolves to the calculated deposit amounts and the LP tokens to be received.
|
|
419
583
|
*/
|
|
420
|
-
preCalculateDepositAmount(options: DepositCalculationOptions, lpCallback
|
|
584
|
+
preCalculateDepositAmount(options: DepositCalculationOptions, lpCallback?: LpCallback): Promise<DepositCalculationResult>;
|
|
421
585
|
/**
|
|
422
586
|
* Retrieves the vault and pool information based on the provided pool_id.
|
|
423
587
|
* It first fetches the vault details, then retrieves the associated CLMM (Constant Product Market Maker) pool details.
|
|
@@ -599,155 +763,6 @@ type RedeemOption = {
|
|
|
599
763
|
period: number;
|
|
600
764
|
} & CoinPairType;
|
|
601
765
|
|
|
602
|
-
type VaultsV2Configs = {
|
|
603
|
-
package_id: string;
|
|
604
|
-
published_at: string;
|
|
605
|
-
configs: {
|
|
606
|
-
registry_id: string;
|
|
607
|
-
pools_handle: string;
|
|
608
|
-
global_config_id: string;
|
|
609
|
-
versioned_id: string;
|
|
610
|
-
pyth_oracle_id: string;
|
|
611
|
-
oracle_infos_handle: string;
|
|
612
|
-
};
|
|
613
|
-
};
|
|
614
|
-
type ActionAcl = {
|
|
615
|
-
is_deposit_allowed: boolean;
|
|
616
|
-
is_withdraw_allowed: boolean;
|
|
617
|
-
};
|
|
618
|
-
type DLMMMarketPosition = {
|
|
619
|
-
id: string;
|
|
620
|
-
position: DlmmPosition;
|
|
621
|
-
valid_lower_bin_id: number;
|
|
622
|
-
valid_upper_bin_id: number;
|
|
623
|
-
amounts: Balances;
|
|
624
|
-
};
|
|
625
|
-
type DLMMMarket = {
|
|
626
|
-
id: string;
|
|
627
|
-
vault_id: string;
|
|
628
|
-
certified_pools: string[];
|
|
629
|
-
positions_handle: TableHandle;
|
|
630
|
-
position_list: DLMMMarketPosition[];
|
|
631
|
-
position_keys: string[];
|
|
632
|
-
} & PoolCoinTypes;
|
|
633
|
-
type VaultPool = {
|
|
634
|
-
id: string;
|
|
635
|
-
lp_token_treasury: string;
|
|
636
|
-
quote_type?: string;
|
|
637
|
-
buffer_assets: Balances[];
|
|
638
|
-
hard_cap: string;
|
|
639
|
-
markets_handle: TableHandle;
|
|
640
|
-
markets: DLMMMarket[];
|
|
641
|
-
protocol_fees_handle: TableHandle;
|
|
642
|
-
lp_token_type: string;
|
|
643
|
-
action_status: ActionAcl;
|
|
644
|
-
last_aum: string;
|
|
645
|
-
protocol_fee_rate: string;
|
|
646
|
-
} & PoolCoinTypes;
|
|
647
|
-
type CollectRewardOptionsV2 = {
|
|
648
|
-
reward_coin_types: string[];
|
|
649
|
-
lp_token_type: string;
|
|
650
|
-
pool_id: string;
|
|
651
|
-
certified_pool_id: string;
|
|
652
|
-
position_id: string;
|
|
653
|
-
withdraw_cert?: TransactionObjectArgument;
|
|
654
|
-
} & PoolCoinTypes;
|
|
655
|
-
type CollectFeeOptionsV2 = {
|
|
656
|
-
lp_token_type: string;
|
|
657
|
-
pool_id: string;
|
|
658
|
-
certified_pool_id: string;
|
|
659
|
-
position_id: string;
|
|
660
|
-
withdraw_cert?: TransactionObjectArgument;
|
|
661
|
-
} & PoolCoinTypes;
|
|
662
|
-
type DepositCalculationOptionsV2 = {
|
|
663
|
-
uuid?: string;
|
|
664
|
-
pool_id: string;
|
|
665
|
-
mode: DepositMode;
|
|
666
|
-
} & ({
|
|
667
|
-
mode: 'FixedOneSide';
|
|
668
|
-
fixed_amount: string;
|
|
669
|
-
fixed_coin_a: boolean;
|
|
670
|
-
} | {
|
|
671
|
-
mode: 'FlexibleBoth';
|
|
672
|
-
coin_amount_a: string;
|
|
673
|
-
coin_amount_b: string;
|
|
674
|
-
} | {
|
|
675
|
-
mode: 'OnlyCoinA';
|
|
676
|
-
coin_amount_a: string;
|
|
677
|
-
re_balance?: boolean;
|
|
678
|
-
} | {
|
|
679
|
-
mode: 'OnlyCoinB';
|
|
680
|
-
coin_amount_b: string;
|
|
681
|
-
re_balance?: boolean;
|
|
682
|
-
});
|
|
683
|
-
type DepositCalculationResultV2 = {
|
|
684
|
-
deposit_amount_a: string;
|
|
685
|
-
deposit_amount_b: string;
|
|
686
|
-
lp_amount?: string;
|
|
687
|
-
uuid?: string;
|
|
688
|
-
mode: DepositMode;
|
|
689
|
-
re_balance?: {
|
|
690
|
-
swap_result: SwapResult;
|
|
691
|
-
coin_amount: string;
|
|
692
|
-
mode: 'OnlyCoinA' | 'OnlyCoinB';
|
|
693
|
-
};
|
|
694
|
-
};
|
|
695
|
-
type WithdrawCalculationResultV2 = {
|
|
696
|
-
burn_lp_amount: string;
|
|
697
|
-
receive_amount_a: string;
|
|
698
|
-
receive_amount_b: string;
|
|
699
|
-
mode: DepositMode;
|
|
700
|
-
swap?: {
|
|
701
|
-
swap_amount_in: string;
|
|
702
|
-
swap_amount_out: string;
|
|
703
|
-
remove_amount_a: string;
|
|
704
|
-
remove_amount_b: string;
|
|
705
|
-
};
|
|
706
|
-
};
|
|
707
|
-
type VaultsBalanceV2 = {
|
|
708
|
-
vault_id: string;
|
|
709
|
-
certified_pool_id: string;
|
|
710
|
-
owner: string;
|
|
711
|
-
lp_token_type: string;
|
|
712
|
-
lp_token_balance: string;
|
|
713
|
-
liquidity_shares: string[];
|
|
714
|
-
valid_lower_bin_id: number;
|
|
715
|
-
valid_upper_bin_id: number;
|
|
716
|
-
original_lower_bin_id: number;
|
|
717
|
-
original_upper_bin_id: number;
|
|
718
|
-
amount_a: string;
|
|
719
|
-
amount_b: string;
|
|
720
|
-
position_amount_a: string;
|
|
721
|
-
position_amount_b: string;
|
|
722
|
-
coin_type_a: string;
|
|
723
|
-
coin_type_b: string;
|
|
724
|
-
bin_infos?: BinLiquidityInfo;
|
|
725
|
-
};
|
|
726
|
-
type DepositCalculationValueOptionsV2 = {
|
|
727
|
-
uuid?: string;
|
|
728
|
-
pool_id: string;
|
|
729
|
-
mode: 'FlexibleBoth' | 'OnlyCoinA' | 'OnlyCoinB';
|
|
730
|
-
amount_usd: string;
|
|
731
|
-
re_balance?: boolean;
|
|
732
|
-
};
|
|
733
|
-
type SwapResult = {
|
|
734
|
-
swap_in_amount: string;
|
|
735
|
-
swap_out_amount: string;
|
|
736
|
-
route_obj?: any;
|
|
737
|
-
};
|
|
738
|
-
type DepositOptionsV2 = {
|
|
739
|
-
pool_id: string;
|
|
740
|
-
amount_a: string;
|
|
741
|
-
amount_b: string;
|
|
742
|
-
return_lp_coin?: boolean;
|
|
743
|
-
re_balance?: {
|
|
744
|
-
swap_result: SwapResult;
|
|
745
|
-
coin_amount: string;
|
|
746
|
-
mode: 'OnlyCoinA' | 'OnlyCoinB';
|
|
747
|
-
swap_slippage: number;
|
|
748
|
-
};
|
|
749
|
-
};
|
|
750
|
-
|
|
751
766
|
type BigNumber = Decimal.Value | number | string;
|
|
752
767
|
|
|
753
768
|
declare class VestModule implements IModule$1<VolatileVaultsSDK> {
|