@naviprotocol/wallet-client 1.0.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.
@@ -0,0 +1,218 @@
1
+ import { DryRunTransactionBlockResponse, SuiTransactionBlockResponse } from '@mysten/sui/client';
2
+ import { Module } from '../module';
3
+ import { AssetIdentifier, CacheOption, LendingReward, AccountCapOption, Pool } from '@naviprotocol/lending';
4
+
5
+ /**
6
+ * Configuration options for the lending module
7
+ */
8
+ export interface LendingModuleConfig {
9
+ /** Environment setting for protocol interaction */
10
+ env: 'dev' | 'prod';
11
+ }
12
+ /**
13
+ * Events emitted by the lending module
14
+ */
15
+ export type Events = {
16
+ /** Emitted when a deposit is successfully completed */
17
+ 'lending:deposit-success': {
18
+ /** Asset identifier for the deposited asset */
19
+ identifier: AssetIdentifier;
20
+ /** Amount deposited */
21
+ amount: number;
22
+ };
23
+ /** Emitted when a withdrawal is successfully completed */
24
+ 'lending:withdraw-success': {
25
+ /** Asset identifier for the withdrawn asset */
26
+ identifier: AssetIdentifier;
27
+ /** Amount withdrawn */
28
+ amount: number;
29
+ };
30
+ /** Emitted when a borrow is successfully completed */
31
+ 'lending:borrow-success': {
32
+ /** Asset identifier for the borrowed asset */
33
+ identifier: AssetIdentifier;
34
+ /** Amount borrowed */
35
+ amount: number;
36
+ };
37
+ /** Emitted when a repayment is successfully completed */
38
+ 'lending:repay-success': {
39
+ /** Asset identifier for the repaid asset */
40
+ identifier: AssetIdentifier;
41
+ /** Amount repaid */
42
+ amount: number;
43
+ };
44
+ /** Emitted when a liquidation is successfully completed */
45
+ 'lending:liquidate-success': {
46
+ /** Asset identifier for the debt being paid */
47
+ payIdentifier: AssetIdentifier;
48
+ /** Amount of debt paid */
49
+ payAmount: number;
50
+ /** Asset identifier for the collateral being liquidated */
51
+ collateralIdentifier: AssetIdentifier;
52
+ /** Address of the account being liquidated */
53
+ liquidationAddress: string;
54
+ };
55
+ /** Emitted when rewards are successfully claimed */
56
+ 'lending:claim-rewards-success': {
57
+ /** Array of claimed rewards */
58
+ rewards: LendingReward[];
59
+ };
60
+ };
61
+ /**
62
+ * Lending protocol module for wallet operations
63
+ *
64
+ * This module provides comprehensive lending functionality including:
65
+ * - Deposit and withdraw operations
66
+ * - Borrow and repay operations
67
+ * - Liquidation functionality
68
+ * - Reward claiming
69
+ * - Oracle price updates
70
+ * - Health factor monitoring
71
+ * - Pool information retrieval
72
+ */
73
+ export declare class LendingModule extends Module<LendingModuleConfig, Events> {
74
+ /** Module name identifier */
75
+ readonly name = "lending";
76
+ /** Default configuration values */
77
+ readonly defaultConfig: LendingModuleConfig;
78
+ /**
79
+ * Gets all available lending pools
80
+ *
81
+ * @param options - Optional caching options
82
+ * @returns Array of pool information
83
+ */
84
+ getPools(options?: Partial<CacheOption>): Promise<Pool[]>;
85
+ /**
86
+ * Gets information for a specific lending pool
87
+ *
88
+ * @param identifier - Asset identifier (string, Pool object, or number)
89
+ * @param options - Optional caching options
90
+ * @returns Pool information
91
+ */
92
+ getPool(identifier: AssetIdentifier, options?: Partial<CacheOption>): Promise<Pool>;
93
+ /**
94
+ * Deposits coins into a lending pool
95
+ *
96
+ * @param identifier - Asset identifier for the pool
97
+ * @param amount - Amount to deposit
98
+ * @param options - Optional parameters including dry run mode and account capability
99
+ * @returns Transaction response or dry run response
100
+ */
101
+ deposit<T extends boolean = false>(identifier: AssetIdentifier, amount: number, options?: {
102
+ dryRun: T;
103
+ } & Partial<AccountCapOption>): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
104
+ /**
105
+ * Withdraws coins from a lending pool
106
+ *
107
+ * @param identifier - Asset identifier for the pool
108
+ * @param amount - Amount to withdraw
109
+ * @param options - Optional parameters including dry run mode and account capability
110
+ * @returns Transaction response or dry run response
111
+ */
112
+ withdraw<T extends boolean = false>(identifier: AssetIdentifier, amount: number, options?: {
113
+ dryRun: T;
114
+ disableUpdateOracle?: boolean;
115
+ } & Partial<AccountCapOption>): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
116
+ /**
117
+ * Borrows coins from a lending pool
118
+ *
119
+ * @param identifier - Asset identifier for the pool
120
+ * @param amount - Amount to borrow
121
+ * @param options - Optional parameters including dry run mode and account capability
122
+ * @returns Transaction response or dry run response
123
+ */
124
+ borrow<T extends boolean = false>(identifier: AssetIdentifier, amount: number, options?: {
125
+ dryRun: T;
126
+ disableUpdateOracle?: boolean;
127
+ } & Partial<AccountCapOption>): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
128
+ /**
129
+ * Repays borrowed coins to a lending pool
130
+ *
131
+ * @param identifier - Asset identifier for the pool
132
+ * @param amount - Amount to repay
133
+ * @param options - Optional parameters including dry run mode and account capability
134
+ * @returns Transaction response or dry run response
135
+ */
136
+ repay<T extends boolean = false>(identifier: AssetIdentifier, amount: number, options?: {
137
+ dryRun: T;
138
+ } & Partial<AccountCapOption>): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
139
+ /**
140
+ * Gets the current health factor for the user
141
+ *
142
+ * @returns Current health factor value
143
+ */
144
+ getHealthFactor(): Promise<number>;
145
+ /**
146
+ * Initiates a liquidation process
147
+ *
148
+ * @param payIdentifier - Asset identifier for the debt being paid
149
+ * @param payAmount - Amount of debt to pay
150
+ * @param collateralIdentifier - Asset identifier for the collateral being liquidated
151
+ * @param liquidationAddress - Address of the account being liquidated
152
+ * @param options - Optional parameters including dry run mode
153
+ * @returns Transaction response or dry run response
154
+ */
155
+ liquidate<T extends boolean = false>(payIdentifier: AssetIdentifier, payAmount: number, collateralIdentifier: AssetIdentifier, liquidationAddress: string, options?: {
156
+ dryRun: T;
157
+ }): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
158
+ /**
159
+ * Gets the available lending rewards for the current user.
160
+ *
161
+ * @param options - Optional cache options.
162
+ * @returns The available lending rewards for the user.
163
+ * @throws If the wallet client is not found.
164
+ */
165
+ getAvailableRewards(options?: Partial<CacheOption>): Promise<LendingReward[]>;
166
+ /**
167
+ * Gets the claimed reward history for the current user.
168
+ *
169
+ * @param options - Optional cache options.
170
+ * @returns The claimed reward history for the user.
171
+ * @throws If the wallet client is not found.
172
+ */
173
+ getClaimedRewardHistory(options?: Partial<CacheOption> & {
174
+ page?: number;
175
+ size?: number;
176
+ }): Promise<{
177
+ data: import('@naviprotocol/lending').HistoryClaimedReward[];
178
+ cursor?: string;
179
+ }>;
180
+ /**
181
+ * Claims all available lending rewards for the user
182
+ *
183
+ * @param options - Optional parameters including dry run mode and account capability
184
+ * @returns Transaction response or dry run response
185
+ */
186
+ claimAllRewards<T extends boolean = false>(options?: {
187
+ dryRun: T;
188
+ } & Partial<AccountCapOption>): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
189
+ private updateOraclePTB;
190
+ /**
191
+ * Updates the oracle prices for the lending protocol
192
+ *
193
+ * @param options - Optional parameters including dry run mode and pools
194
+ * @param options.dryRun - Whether to perform a dry run
195
+ * @returns Transaction response or dry run response
196
+ */
197
+ updateOracle<T extends boolean = false>(options?: {
198
+ dryRun: T;
199
+ pools?: Pool[];
200
+ }): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
201
+ /**
202
+ * Gets all active lending positions for the user
203
+ *
204
+ * @param options - Optional caching options
205
+ * @returns User's lending state information
206
+ */
207
+ getLendingState(options?: Partial<CacheOption>): Promise<import('@naviprotocol/lending').UserLendingInfo[]>;
208
+ /**
209
+ * Creates an account capability for the lending protocol
210
+ *
211
+ * @param options - Optional parameters including dry run mode
212
+ * @returns Transaction response or dry run response
213
+ */
214
+ createAccountCap<T extends boolean = false>(options?: {
215
+ dryRun: T;
216
+ }): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
217
+ }
218
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/lending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oB7B;;;;;;OAMG;IACG,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EAAE,OAAO,CAAC,EAAE;QACtD,MAAM,EAAE,CAAC,CAAA;QACT,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;KACf,GAAG,OAAO,CAAC,CAAC,SAAS,IAAI,GAAG,8BAA8B,GAAG,2BAA2B,CAAC;IAiB1F;;;;;OAKG;IACG,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC;IAWpD;;;;;OAKG;IACG,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EAAE,OAAO,CAAC,EAAE;QAC1D,MAAM,EAAE,CAAC,CAAA;KACV,GAAG,OAAO,CAAC,CAAC,SAAS,IAAI,GAAG,8BAA8B,GAAG,2BAA2B,CAAC;CAkB3F"}
@@ -0,0 +1,69 @@
1
+ import { WalletClient } from '../client';
2
+
3
+ /**
4
+ * Base interface for module configuration
5
+ *
6
+ * All modules must implement this interface to define their configuration structure.
7
+ */
8
+ export interface ModuleConfig {
9
+ [key: string]: any;
10
+ }
11
+ /**
12
+ * Base interface for module events
13
+ *
14
+ * All modules must implement this interface to define their event structure.
15
+ */
16
+ export type ModuleEvents = {
17
+ [key: string]: any;
18
+ };
19
+ /**
20
+ * Abstract base class for all wallet client modules
21
+ *
22
+ * This class provides the foundation for modular functionality in the wallet client.
23
+ * Each module (swap, lending, balance, etc.) extends this class to provide
24
+ * specific functionality while maintaining a consistent interface.
25
+ *
26
+ * @template TConfig - The configuration type for this module
27
+ * @template TEvents - The events type for this module
28
+ */
29
+ export declare abstract class Module<TConfig extends ModuleConfig, TEvents extends ModuleEvents> {
30
+ /** The unique name identifier for this module */
31
+ abstract readonly name: string;
32
+ /** Default configuration values for this module */
33
+ abstract readonly defaultConfig: TConfig;
34
+ /** Reference to the wallet client instance that owns this module */
35
+ protected walletClient?: WalletClient;
36
+ /**
37
+ * Gets the current configuration for this module
38
+ *
39
+ * This combines the default configuration with any user-provided overrides
40
+ * from the wallet client configuration.
41
+ *
42
+ * @returns The merged configuration for this module
43
+ */
44
+ get config(): TConfig;
45
+ /**
46
+ * Emits an event through the wallet client's event system
47
+ *
48
+ * @param event - The event name to emit
49
+ * @param data - The event data to emit
50
+ */
51
+ emit(event: keyof TEvents, data: TEvents[keyof TEvents]): void;
52
+ /**
53
+ * Installs this module into a wallet client
54
+ *
55
+ * This method is called by the wallet client during initialization
56
+ * to establish the connection between the module and the client.
57
+ *
58
+ * @param walletClient - The wallet client instance to install into
59
+ */
60
+ install(walletClient: WalletClient): void;
61
+ /**
62
+ * Uninstalls this module from the wallet client
63
+ *
64
+ * This method removes the reference to the wallet client,
65
+ * effectively disconnecting the module.
66
+ */
67
+ uninstall(): void;
68
+ }
69
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/modules/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAGxC;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED;;;;;;;;;GASG;AACH,8BAAsB,MAAM,CAAC,OAAO,SAAS,YAAY,EAAE,OAAO,SAAS,YAAY;IACrF,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAE9B,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;IAExC,oEAAoE;IACpE,SAAS,CAAC,YAAY,CAAC,EAAE,YAAY,CAAA;IAErC;;;;;;;OAOG;IACH,IAAI,MAAM,IAAI,OAAO,CAIpB;IAED;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,OAAO,CAAC;IAIvD;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAIzC;;;;;OAKG;IACH,SAAS;CAGV"}
@@ -0,0 +1,81 @@
1
+ import { Dex, FeeOption } from '@naviprotocol/astros-aggregator-sdk';
2
+ import { Module } from '../module';
3
+ import { SuiTransactionBlockResponse, DryRunTransactionBlockResponse } from '@mysten/sui/client';
4
+
5
+ /**
6
+ * Configuration options for the swap module
7
+ */
8
+ export interface SwapModuleConfig {
9
+ /** API key for aggregator access */
10
+ apiKey: string;
11
+ /** Base URL for the aggregator API */
12
+ baseUrl: string;
13
+ /** List of DEXes to use for routing */
14
+ dexList: Dex[];
15
+ /** Maximum routing depth for finding optimal paths */
16
+ depth: number;
17
+ /** Service fee configuration */
18
+ serviceFee: FeeOption | undefined;
19
+ /** Environment setting */
20
+ env: 'dev' | 'prod';
21
+ }
22
+ /**
23
+ * Events emitted by the swap module
24
+ */
25
+ export type Events = {
26
+ /** Emitted when a swap is successfully completed */
27
+ 'swap:swap-success': {
28
+ /** Source coin type */
29
+ fromCoinType: string;
30
+ /** Target coin type */
31
+ toCoinType: string;
32
+ /** Input amount */
33
+ fromAmount: number;
34
+ /** Applied slippage tolerance */
35
+ slippage: number;
36
+ /** Output amount received */
37
+ toAmount: number;
38
+ };
39
+ };
40
+ /**
41
+ * DEX swapping module for wallet operations
42
+ *
43
+ * This module provides functionality for:
44
+ * - Getting swap quotes from multiple DEXes
45
+ * - Executing swaps with slippage protection
46
+ * - Managing swap transactions and events
47
+ * - Integrating with the balance module for coin management
48
+ */
49
+ export declare class SwapModule extends Module<SwapModuleConfig, Events> {
50
+ /** Module name identifier */
51
+ readonly name = "swap";
52
+ /** Default configuration values */
53
+ readonly defaultConfig: SwapModuleConfig;
54
+ /**
55
+ * Gets the referral ID for this swap module
56
+ *
57
+ * @returns Referral ID if API key is configured, otherwise 0
58
+ */
59
+ get referral(): number;
60
+ /**
61
+ * Executes a swap between two coin types
62
+ *
63
+ * This method performs a complete swap operation including:
64
+ * - Balance validation
65
+ * - Quote retrieval from aggregator
66
+ * - Transaction building with slippage protection
67
+ * - Transaction execution
68
+ * - Event emission on success
69
+ *
70
+ * @param fromCoinType - Source coin type
71
+ * @param toCoinType - Target coin type
72
+ * @param fromAmount - Amount to swap
73
+ * @param slippage - Slippage tolerance (0-1)
74
+ * @param options - Optional parameters including dry run mode
75
+ * @returns Transaction response or dry run response
76
+ */
77
+ swap<T extends boolean = false>(fromCoinType: string, toCoinType: string, fromAmount: number, slippage: number, options?: {
78
+ dryRun: T;
79
+ }): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
80
+ }
81
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/swapModule/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAGL,GAAG,EACH,SAAS,EAEV,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,2BAA2B,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAA;AAIhG;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAA;IACf,uCAAuC;IACvC,OAAO,EAAE,GAAG,EAAE,CAAA;IACd,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,gCAAgC;IAChC,UAAU,EAAE,SAAS,GAAG,SAAS,CAAA;IACjC,0BAA0B;IAC1B,GAAG,EAAE,KAAK,GAAG,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,oDAAoD;IACpD,mBAAmB,EAAE;QACnB,uBAAuB;QACvB,YAAY,EAAE,MAAM,CAAA;QACpB,uBAAuB;QACvB,UAAU,EAAE,MAAM,CAAA;QAClB,mBAAmB;QACnB,UAAU,EAAE,MAAM,CAAA;QAClB,iCAAiC;QACjC,QAAQ,EAAE,MAAM,CAAA;QAChB,6BAA6B;QAC7B,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;CACF,CAAA;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAW,SAAQ,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC9D,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,UAAS;IAEtB,mCAAmC;IACnC,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAOvC;IAED;;;;OAIG;IACH,IAAI,QAAQ,WAEX;IAED;;;;;;;;;;;;;;;;OAgBG;IACG,IAAI,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EAClC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,CAAC,CAAA;KAAE,GACtB,OAAO,CAAC,CAAC,SAAS,IAAI,GAAG,8BAA8B,GAAG,2BAA2B,CAAC;CAsF1F"}
@@ -0,0 +1,148 @@
1
+ import { CoinObject } from '@naviprotocol/lending';
2
+ import { Transaction } from '@mysten/sui/transactions';
3
+ import { Module } from '../module';
4
+ import { SuiTransactionBlockResponse, DryRunTransactionBlockResponse } from '@mysten/sui/client';
5
+
6
+ /**
7
+ * Configuration interface for the Volo staking module
8
+ */
9
+ export interface VoloModuleConfig {
10
+ /** The package ID of the Volo staking contract */
11
+ packageId: string;
12
+ /** The pool ID for the staking pool */
13
+ poolId: string;
14
+ /** The coin type for vSUI tokens */
15
+ coinType: string;
16
+ /** The metadata ID for the staking pool */
17
+ metadataId: string;
18
+ }
19
+ /**
20
+ * Event types emitted by the Volo module
21
+ */
22
+ export type Events = {
23
+ /** Emitted when staking is successful */
24
+ 'volo:stake-success': {
25
+ /** Amount of SUI staked */
26
+ suiAmount: number;
27
+ };
28
+ /** Emitted when unstaking is successful */
29
+ 'volo:unstake-success': {
30
+ /** Amount of vSUI unstaked */
31
+ vSuiAmount: number;
32
+ };
33
+ };
34
+ /**
35
+ * Statistics and information about the Volo staking pool
36
+ */
37
+ export type VoloStats = {
38
+ /** Current operator balance */
39
+ operatorBalance: string;
40
+ /** Collectable fees in the pool */
41
+ collectableFee: string;
42
+ /** Pending stakes waiting to be processed */
43
+ pendingStakes: string;
44
+ /** Total amount staked in the pool */
45
+ totalStaked: string;
46
+ /** Total rewards distributed to stakers */
47
+ totalRewardsInStakes: string;
48
+ /** Currently active stake amount */
49
+ activeStake: string;
50
+ /** Current epoch number */
51
+ currentEpoch: string;
52
+ /** List of validators in the pool */
53
+ validators: {
54
+ /** Validator address */
55
+ address: string;
56
+ /** Total amount staked with this validator */
57
+ totalStaked: string;
58
+ /** Assigned weight for this validator */
59
+ assigned_weight: string;
60
+ /** Annual percentage yield for this validator */
61
+ apy: string;
62
+ /** Validator name */
63
+ name: string;
64
+ }[];
65
+ /** Current exchange rate between SUI and vSUI */
66
+ exchangeRate: number;
67
+ /** Total supply of vSUI tokens */
68
+ totalSupply: string;
69
+ /** Overall APY for the staking pool */
70
+ apy: number;
71
+ /** Maximum amount that can be instantly unstaked */
72
+ maxInstantUnstake: string;
73
+ /** Maximum amount that can be unstaked without fees */
74
+ maxNoFeeUnstake: string;
75
+ /** Total number of stakers in the pool */
76
+ totalStakers: number;
77
+ /** Timestamp of last update */
78
+ lastUpdated: number;
79
+ };
80
+ /**
81
+ * Volo Module for Sui Staking Protocol
82
+ *
83
+ * Provides functionality to stake SUI tokens and receive vSUI tokens,
84
+ * enabling liquid staking with potential rewards and instant unstaking.
85
+ */
86
+ export declare class VoloModule extends Module<VoloModuleConfig, Events> {
87
+ /** Module name identifier */
88
+ readonly name = "volo";
89
+ /** Default configuration for the Volo staking protocol */
90
+ readonly defaultConfig: {
91
+ packageId: string;
92
+ poolId: string;
93
+ metadataId: string;
94
+ coinType: string;
95
+ };
96
+ /**
97
+ * Get current statistics and information about the Volo staking pool
98
+ * Uses caching to avoid repeated API calls
99
+ *
100
+ * @returns Volo staking pool information
101
+ */
102
+ getStats: () => Promise<VoloStats>;
103
+ /**
104
+ * Adds staking operation to a transaction black
105
+ *
106
+ * @param tx - The transaction block to add the staking operation to
107
+ * @param suiCoin - The SUI coin object to stake
108
+ * @returns The vSUI coin object received from staking
109
+ */
110
+ stakePTB(tx: Transaction, suiCoin: CoinObject): Promise<{
111
+ $kind: "NestedResult";
112
+ NestedResult: [number, number];
113
+ }>;
114
+ /**
115
+ * Adds unstaking operation to a transaction black
116
+ *
117
+ * @param tx - The transaction block to add the unstaking operation to
118
+ * @param vSuiCoin - The vSUI coin object to unstake
119
+ * @returns The SUI coin object received from unstaking
120
+ */
121
+ unstakePTB(tx: Transaction, vSuiCoin: CoinObject): Promise<{
122
+ $kind: "NestedResult";
123
+ NestedResult: [number, number];
124
+ }>;
125
+ /**
126
+ * Stake SUI tokens to receive vSUI tokens
127
+ *
128
+ * @param suiAmount - Amount of SUI to stake (in MIST units)
129
+ * @param options - Optional parameters including dryRun flag
130
+ * @returns Transaction response or dry run response
131
+ * @throws Error if wallet client not found or stake amount is too low
132
+ */
133
+ stake<T extends boolean = false>(suiAmount: number, options?: {
134
+ dryRun: T;
135
+ }): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
136
+ /**
137
+ * Unstake vSUI tokens to receive SUI tokens
138
+ *
139
+ * @param vSuiAmount - Amount of vSUI to unstake (in MIST units)
140
+ * @param options - Optional parameters including dryRun flag
141
+ * @returns Transaction response or dry run response
142
+ * @throws Error if wallet client not found or unstake amount is too low
143
+ */
144
+ unstake<T extends boolean = false>(vSuiAmount: number, options?: {
145
+ dryRun: T;
146
+ }): Promise<T extends true ? DryRunTransactionBlockResponse : SuiTransactionBlockResponse>;
147
+ }
148
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/voloModule/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,UAAU,EAKX,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,2BAA2B,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAA;AAEhG;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAA;IACjB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,yCAAyC;IACzC,oBAAoB,EAAE;QACpB,2BAA2B;QAC3B,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,2CAA2C;IAC3C,sBAAsB,EAAE;QACtB,8BAA8B;QAC9B,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;CACF,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,+BAA+B;IAC/B,eAAe,EAAE,MAAM,CAAA;IACvB,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAA;IACrB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,2CAA2C;IAC3C,oBAAoB,EAAE,MAAM,CAAA;IAC5B,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAA;IACnB,2BAA2B;IAC3B,YAAY,EAAE,MAAM,CAAA;IACpB,qCAAqC;IACrC,UAAU,EAAE;QACV,wBAAwB;QACxB,O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AM,EAClB,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,CAAC,CAAA;KAAE,GACtB,OAAO,CAAC,CAAC,SAAS,IAAI,GAAG,8BAA8B,GAAG,2BAA2B,CAAC;CAwC1F"}
@@ -0,0 +1,113 @@
1
+ import { Signer, SignatureWithBytes } from '@mysten/sui/cryptography';
2
+ import { Transaction } from '@mysten/sui/transactions';
3
+ import { SuiClient } from '@mysten/sui/client';
4
+ import { Experimental_SuiClientTypes } from '@mysten/sui/experimental';
5
+
6
+ /**
7
+ * Options for signing and executing transactions
8
+ */
9
+ interface SignAndExecuteOptions {
10
+ /** Transaction to sign and execute */
11
+ transaction: Transaction;
12
+ /** Sui client instance */
13
+ client: SuiClient;
14
+ }
15
+ /**
16
+ * Watch-only signer implementation
17
+ *
18
+ * This signer provides read-only access to wallet information without
19
+ * the ability to sign transactions. It's useful for viewing wallet
20
+ * balances, transaction history, and other non-signing operations.
21
+ *
22
+ * Note: This signer cannot actually sign transactions and will return
23
+ * empty signatures or throw errors when signing is attempted.
24
+ */
25
+ export declare class WatchSigner extends Signer {
26
+ /** The wallet address this signer represents */
27
+ private address;
28
+ /**
29
+ * Creates a new watch-only signer
30
+ *
31
+ * @param address - The wallet address to watch
32
+ */
33
+ constructor(address: string);
34
+ /**
35
+ * Signs transaction bytes (not implemented for watch-only mode)
36
+ *
37
+ * This method is required by the Signer interface but cannot
38
+ * actually sign transactions in watch-only mode.
39
+ *
40
+ * @param bytes - Transaction bytes to sign
41
+ * @returns Promise<Uint8Array> - Empty signature (not valid)
42
+ */
43
+ sign(bytes: Uint8Array): Promise<Uint8Array>;
44
+ /**
45
+ * Gets the public key information for this signer
46
+ *
47
+ * Returns a mock public key object that provides the wallet address
48
+ * but cannot be used for actual cryptographic operations.
49
+ *
50
+ * @returns Mock public key object
51
+ */
52
+ getPublicKey(): any;
53
+ /**
54
+ * Gets the key scheme for this signer
55
+ *
56
+ * @returns Key scheme string (ed25519 for compatibility)
57
+ */
58
+ getKeyScheme(): any;
59
+ /**
60
+ * Signs and executes a transaction (not implemented for watch-only mode)
61
+ *
62
+ * This method is required by the Signer interface but cannot
63
+ * actually sign and execute transactions in watch-only mode.
64
+ *
65
+ * @param options - Sign and execute options
66
+ * @returns Promise<any> - Empty result (not a real transaction result)
67
+ */
68
+ signAndExecuteTransaction({ transaction, client }: SignAndExecuteOptions): Promise<any>;
69
+ }
70
+ /**
71
+ * Web signer implementation
72
+ *
73
+ * For use in browser environments
74
+ */
75
+ export declare abstract class WebSigner extends Signer {
76
+ private address;
77
+ /**
78
+ * Creates a new watch-only signer
79
+ *
80
+ * @param address - The wallet address to watch
81
+ */
82
+ constructor(address: string);
83
+ /**
84
+ * Signs transaction bytes (not implemented for watch-only mode)
85
+ *
86
+ * This method is required by the Signer interface but cannot
87
+ * actually sign transactions in watch-only mode.
88
+ *
89
+ * @param bytes - Transaction bytes to sign
90
+ * @returns Promise<Uint8Array> - Empty signature (not valid)
91
+ */
92
+ sign(bytes: Uint8Array): Promise<Uint8Array>;
93
+ /**
94
+ * Gets the public key information for this signer
95
+ *
96
+ * Returns a mock public key object that provides the wallet address
97
+ * but cannot be used for actual cryptographic operations.
98
+ *
99
+ * @returns Mock public key object
100
+ */
101
+ getPublicKey(): any;
102
+ /**
103
+ * Gets the key scheme for this signer
104
+ *
105
+ * @returns Key scheme string (ed25519 for compatibility)
106
+ */
107
+ getKeyScheme(): any;
108
+ abstract signPersonalMessage(bytes: Uint8Array): Promise<SignatureWithBytes>;
109
+ abstract signTransaction(bytes: Uint8Array): Promise<SignatureWithBytes>;
110
+ abstract signAndExecuteTransaction({ transaction, client }: SignAndExecuteOptions): Promise<Experimental_SuiClientTypes.TransactionResponse>;
111
+ }
112
+ export {};
113
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAA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