@tetherto/wdk-wallet 1.0.0-beta.2 → 1.0.0-beta.21

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.
Files changed (50) hide show
  1. package/AGENTS.md +49 -0
  2. package/README.md +2 -2
  3. package/bare.js +3 -3
  4. package/index.js +14 -2
  5. package/package.json +18 -4
  6. package/src/disposable.js +26 -0
  7. package/src/errors.js +318 -3
  8. package/src/multisig/errors.js +54 -0
  9. package/src/multisig/index.js +42 -0
  10. package/src/multisig/multisig-message-signing-read-only.js +63 -0
  11. package/src/multisig/multisig-message-signing.js +64 -0
  12. package/src/multisig/multisig-owner-management.js +94 -0
  13. package/src/multisig/wallet-account-multisig.js +144 -0
  14. package/src/multisig/wallet-account-read-only-multisig.js +98 -0
  15. package/src/protocols/bridge-protocol.js +35 -1
  16. package/src/protocols/errors.js +510 -0
  17. package/src/protocols/fiat-protocol.js +401 -0
  18. package/src/protocols/index.js +76 -0
  19. package/src/protocols/lending-protocol.js +114 -2
  20. package/src/protocols/sda-protocol.js +643 -0
  21. package/src/protocols/swap-protocol.js +36 -1
  22. package/src/protocols/swidge-protocol.js +516 -0
  23. package/src/signer.js +89 -0
  24. package/src/wallet-account-read-only-simple.js +162 -0
  25. package/src/wallet-account-read-only.js +186 -40
  26. package/src/wallet-account.js +59 -22
  27. package/src/wallet-manager.js +152 -25
  28. package/types/index.d.ts +13 -4
  29. package/types/src/disposable.d.ts +7 -0
  30. package/types/src/errors.d.ts +220 -2
  31. package/types/src/multisig/errors.d.ts +33 -0
  32. package/types/src/multisig/index.d.ts +15 -0
  33. package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
  34. package/types/src/multisig/multisig-message-signing.d.ts +40 -0
  35. package/types/src/multisig/multisig-owner-management.d.ts +65 -0
  36. package/types/src/multisig/wallet-account-multisig.d.ts +101 -0
  37. package/types/src/multisig/wallet-account-read-only-multisig.d.ts +83 -0
  38. package/types/src/protocols/bridge-protocol.d.ts +39 -3
  39. package/types/src/protocols/errors.d.ts +366 -0
  40. package/types/src/protocols/fiat-protocol.d.ts +409 -0
  41. package/types/src/protocols/index.d.ts +64 -0
  42. package/types/src/protocols/lending-protocol.d.ts +118 -4
  43. package/types/src/protocols/sda-protocol.d.ts +737 -0
  44. package/types/src/protocols/swap-protocol.d.ts +44 -4
  45. package/types/src/protocols/swidge-protocol.d.ts +483 -0
  46. package/types/src/signer.d.ts +53 -0
  47. package/types/src/wallet-account-read-only-simple.d.ts +144 -0
  48. package/types/src/wallet-account-read-only.d.ts +104 -27
  49. package/types/src/wallet-account.d.ts +55 -20
  50. package/types/src/wallet-manager.d.ts +109 -17
@@ -5,6 +5,13 @@ export interface ISwapProtocol {
5
5
  *
6
6
  * @param {SwapOptions} options - The swap's options.
7
7
  * @returns {Promise<SwapResult>} The swap's result.
8
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
9
+ * @throws {ValueError} If the swap options are not valid.
10
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
11
+ * @throws {ProviderRequiredError} If the method requires a provider.
12
+ * @throws {ProviderError} If the provider fails to perform the swap.
13
+ * @throws {SwapError} If the swap fails with an error.
14
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the swap max. fee option.
8
15
  */
9
16
  swap(options: SwapOptions): Promise<SwapResult>;
10
17
  /**
@@ -12,10 +19,19 @@ export interface ISwapProtocol {
12
19
  *
13
20
  * @param {SwapOptions} options - The swap's options.
14
21
  * @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
22
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swap.
23
+ * @throws {ValueError} If the swap options are not valid.
24
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
25
+ * @throws {ProviderRequiredError} If the method requires a provider.
26
+ * @throws {ProviderError} If the provider fails to estimate the costs of the swap.
27
+ * @throws {SwapError} If the swap fails with an error.
15
28
  */
16
29
  quoteSwap(options: SwapOptions): Promise<Omit<SwapResult, "hash">>;
17
30
  }
18
- /** @abstract */
31
+ /**
32
+ * @abstract
33
+ * @implements {ISwapProtocol}
34
+ */
19
35
  export default abstract class SwapProtocol implements ISwapProtocol {
20
36
  /**
21
37
  * Creates a new read-only swap protocol.
@@ -53,6 +69,13 @@ export default abstract class SwapProtocol implements ISwapProtocol {
53
69
  * @abstract
54
70
  * @param {SwapOptions} options - The swap's options.
55
71
  * @returns {Promise<SwapResult>} The swap's result.
72
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
73
+ * @throws {ValueError} If the swap options are not valid.
74
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
75
+ * @throws {ProviderRequiredError} If the method requires a provider.
76
+ * @throws {ProviderError} If the provider fails to perform the swap.
77
+ * @throws {SwapError} If the swap fails with an error.
78
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the swap max. fee option.
56
79
  */
57
80
  abstract swap(options: SwapOptions): Promise<SwapResult>;
58
81
  /**
@@ -61,11 +84,24 @@ export default abstract class SwapProtocol implements ISwapProtocol {
61
84
  * @abstract
62
85
  * @param {SwapOptions} options - The swap's options.
63
86
  * @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
87
+ * @throws {ValueError} If the swap options are not valid.
88
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
89
+ * @throws {ProviderRequiredError} If the method requires a provider.
90
+ * @throws {ProviderError} If the provider fails to estimate the costs of the swap.
91
+ * @throws {SwapError} If the swap fails with an error.
64
92
  */
65
93
  abstract quoteSwap(options: SwapOptions): Promise<Omit<SwapResult, "hash">>;
66
94
  }
67
95
  export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
68
96
  export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
97
+ export type AccountRequiredError = import("./errors.js").AccountRequiredError;
98
+ export type InvalidTokenError = import("./errors.js").InvalidTokenError;
99
+ export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
100
+ export type ReadOnlyAccountRequiredError = import("./errors.js").ReadOnlyAccountRequiredError;
101
+ export type ProviderError = import("./errors.js").ProviderError;
102
+ export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
103
+ export type SwapError = import("./errors.js").SwapError;
104
+ export type ValueError = import("./errors.js").ValueError;
69
105
  export type SwapProtocolConfig = {
70
106
  /**
71
107
  * - The maximum fee amount for swap operations.
@@ -73,7 +109,7 @@ export type SwapProtocolConfig = {
73
109
  swapMaxFee?: number | bigint;
74
110
  };
75
111
  export type SwapOptions = SwapCommonOptions & (SwapBuyOptions | SwapSellOptions);
76
- type SwapCommonOptions = {
112
+ export type SwapCommonOptions = {
77
113
  /**
78
114
  * - The address of the token to sell.
79
115
  */
@@ -86,8 +122,12 @@ type SwapCommonOptions = {
86
122
  * - The address that will receive the output tokens. If not set, the account itself will receive the funds.
87
123
  */
88
124
  to?: string;
125
+ /**
126
+ * - The minimum acceptable amount of destination tokens to receive (in base unit).
127
+ */
128
+ minAmountOut?: number | bigint;
89
129
  };
90
- type SwapBuyOptions = {
130
+ export type SwapBuyOptions = {
91
131
  /**
92
132
  * - The amount of input tokens to sell (in base unit).
93
133
  */
@@ -97,7 +137,7 @@ type SwapBuyOptions = {
97
137
  */
98
138
  tokenOutAmount: number | bigint;
99
139
  };
100
- type SwapSellOptions = {
140
+ export type SwapSellOptions = {
101
141
  /**
102
142
  * - The amount of input tokens to sell (in base unit).
103
143
  */
@@ -0,0 +1,483 @@
1
+ /** @interface */
2
+ export interface ISwidgeProtocol extends ISwapProtocol, IBridgeProtocol {
3
+ /**
4
+ * Quotes the estimated costs and output of a cross-chain swap/bridge operation.
5
+ * Returns a non-binding quote; the actual execution is performed
6
+ * by {@link swidge}.
7
+ *
8
+ * @param {SwidgeOptions} options - The swidge options.
9
+ * @returns {Promise<SwidgeQuote>} The quoted swidge details.
10
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swidge.
11
+ * @throws {ValueError} If the swidge options are not valid.
12
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
13
+ * @throws {ProviderRequiredError} If the method requires a provider.
14
+ * @throws {ProviderError} If the provider fails to perform the swidge.
15
+ * @throws {SwidgeError} If the swidge fails with an error.
16
+ */
17
+ quoteSwidge(options: SwidgeOptions): Promise<SwidgeQuote>;
18
+ /**
19
+ * Executes a swidge operation.
20
+ *
21
+ * @param {SwidgeOptions} options - The swidge options.
22
+ * @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
23
+ * @returns {Promise<SwidgeResult>} The swidge execution result.
24
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
25
+ * @throws {ValueError} If the swidge options are not valid.
26
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
27
+ * @throws {ProviderRequiredError} If the method requires a provider.
28
+ * @throws {ProviderError} If the provider fails to perform the swidge.
29
+ * @throws {SwidgeError} If the swidge fails with an error.
30
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
31
+ */
32
+ swidge(options: SwidgeOptions, config?: SwidgeProtocolConfig): Promise<SwidgeResult>;
33
+ /**
34
+ * Retrieves the current status of an in-flight swidge.
35
+ *
36
+ * @param {string} id - The swidge execution identifier returned by swidge.
37
+ * @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
38
+ * @returns {Promise<SwidgeStatusResult>} The current swidge status.
39
+ * @throws {ValueError} If the id is not valid.
40
+ * @throws {NoSuchElementError} If no swidge exists for the given id.
41
+ * @throws {ProviderRequiredError} If the method requires a provider.
42
+ * @throws {ProviderError} If the provider fails to fetch the swidge's status.
43
+ */
44
+ getSwidgeStatus(id: string, options?: SwidgeStatusOptions): Promise<SwidgeStatusResult>;
45
+ /**
46
+ * Retrieves the chains supported by the provider for swidge operations.
47
+ *
48
+ * @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
49
+ * @throws {ProviderRequiredError} If the method requires a provider.
50
+ * @throws {ProviderError} If the provider fails to fetch the available blockchains.
51
+ */
52
+ getSupportedChains(): Promise<SwidgeSupportedChain[]>;
53
+ /**
54
+ * Retrieves the tokens supported by the provider for swidge operations.
55
+ *
56
+ * @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
57
+ * @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
58
+ * @throws {ProviderRequiredError} If the method requires a provider.
59
+ * @throws {ProviderError} If the provider fails to fetch the available tokens.
60
+ */
61
+ getSupportedTokens(options?: SwidgeSupportedTokensOptions): Promise<SwidgeSupportedToken[]>;
62
+ }
63
+ /** @abstract */
64
+ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapProtocol, IBridgeProtocol {
65
+ /**
66
+ * Creates a new swidge protocol without binding it to a wallet account.
67
+ *
68
+ * @overload
69
+ * @param {undefined} [account] - The wallet account to use to interact with the protocol.
70
+ * @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
71
+ */
72
+ constructor(account?: undefined, config?: SwidgeProtocolConfig);
73
+ /**
74
+ * Creates a new read-only swidge protocol.
75
+ *
76
+ * @overload
77
+ * @param {IWalletAccountReadOnly} account - The wallet account to use to interact with the protocol.
78
+ * @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
79
+ */
80
+ constructor(account: IWalletAccountReadOnly, config?: SwidgeProtocolConfig);
81
+ /**
82
+ * Creates a new swidge protocol.
83
+ *
84
+ * @overload
85
+ * @param {IWalletAccount} account - The wallet account to use to interact with the protocol.
86
+ * @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
87
+ */
88
+ constructor(account: IWalletAccount, config?: SwidgeProtocolConfig);
89
+ /**
90
+ * The wallet account to use to interact with the protocol.
91
+ *
92
+ * @protected
93
+ * @type {IWalletAccountReadOnly | IWalletAccount | undefined}
94
+ */
95
+ protected _account: IWalletAccountReadOnly | IWalletAccount | undefined;
96
+ /**
97
+ * The swidge protocol configuration.
98
+ *
99
+ * @protected
100
+ * @type {SwidgeProtocolConfig}
101
+ */
102
+ protected _config: SwidgeProtocolConfig;
103
+ /**
104
+ * Swaps a pair of tokens by delegating to {@link swidge}.
105
+ *
106
+ * @param {SwapOptions} options - The swap's options.
107
+ * @returns {Promise<SwapResult>} The swap's result.
108
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
109
+ * @throws {ValueError} If the swap options are not valid.
110
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
111
+ * @throws {ProviderRequiredError} If the method requires a provider.
112
+ * @throws {ProviderError} If the provider fails to perform the swap.
113
+ * @throws {SwapError} If the swap fails with an error.
114
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
115
+ */
116
+ swap(options: SwapOptions): Promise<SwapResult>;
117
+ /**
118
+ * Quotes the costs of a swap operation by delegating to {@link quoteSwidge}.
119
+ *
120
+ * @param {SwapOptions} options - The swap's options.
121
+ * @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
122
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swap.
123
+ * @throws {ValueError} If the swap options are not valid.
124
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
125
+ * @throws {ProviderRequiredError} If the method requires a provider.
126
+ * @throws {ProviderError} If the provider fails to estimate the costs of the swap.
127
+ * @throws {SwapError} If the swap fails with an error.
128
+ */
129
+ quoteSwap(options: SwapOptions): Promise<Omit<SwapResult, "hash">>;
130
+ /**
131
+ * Bridges a token to a different blockchain by delegating to {@link swidge}.
132
+ *
133
+ * @param {BridgeOptions} options - The bridge's options.
134
+ * @returns {Promise<BridgeResult>} The bridge's result.
135
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a bridge.
136
+ * @throws {ValueError} If the bridge options are not valid.
137
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
138
+ * @throws {ProviderRequiredError} If the method requires a provider.
139
+ * @throws {ProviderError} If the provider fails to perform the bridge.
140
+ * @throws {BridgeError} If the bridge fails with an error.
141
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
142
+ */
143
+ bridge(options: BridgeOptions): Promise<BridgeResult>;
144
+ /**
145
+ * Quotes the costs of a bridge operation by delegating to {@link quoteSwidge}.
146
+ *
147
+ * @param {BridgeOptions} options - The bridge's options.
148
+ * @returns {Promise<Omit<BridgeResult, 'hash'>>} The bridge's quotes.
149
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swap.
150
+ * @throws {ValueError} If the bridge options are not valid.
151
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
152
+ * @throws {ProviderRequiredError} If the method requires a provider.
153
+ * @throws {ProviderError} If the provider fails to perform the bridge.
154
+ * @throws {BridgeError} If the bridge fails with an error.
155
+ */
156
+ quoteBridge(options: BridgeOptions): Promise<Omit<BridgeResult, "hash">>;
157
+ /**
158
+ * Quotes the estimated costs and output of a swidge operation.
159
+ * Returns a non-binding quote; the actual execution is performed
160
+ * by {@link swidge}.
161
+ *
162
+ * @abstract
163
+ * @param {SwidgeOptions} options - The swidge options.
164
+ * @returns {Promise<SwidgeQuote>} The quoted swidge details.
165
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swidge.
166
+ * @throws {ValueError} If the swidge options are not valid.
167
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
168
+ * @throws {ProviderRequiredError} If the method requires a provider.
169
+ * @throws {ProviderError} If the provider fails to perform the swidge.
170
+ * @throws {SwidgeError} If the swidge fails with an error.
171
+ */
172
+ abstract quoteSwidge(options: SwidgeOptions): Promise<SwidgeQuote>;
173
+ /**
174
+ * Executes a swidge operation.
175
+ *
176
+ * @abstract
177
+ * @param {SwidgeOptions} options - The swidge options.
178
+ * @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
179
+ * @returns {Promise<SwidgeResult>} The swidge execution result.
180
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
181
+ * @throws {ValueError} If the swidge options are not valid.
182
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
183
+ * @throws {ProviderRequiredError} If the method requires a provider.
184
+ * @throws {ProviderError} If the provider fails to perform the swidge.
185
+ * @throws {SwidgeError} If the swidge fails with an error.
186
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
187
+ */
188
+ abstract swidge(options: SwidgeOptions, config?: SwidgeProtocolConfig): Promise<SwidgeResult>;
189
+ /**
190
+ * Retrieves the current status of an in-flight swidge.
191
+ *
192
+ * @abstract
193
+ * @param {string} id - The swidge execution identifier returned by swidge.
194
+ * @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
195
+ * @returns {Promise<SwidgeStatusResult>} The current swidge status.
196
+ * @throws {ValueError} If the id is not valid.
197
+ * @throws {NoSuchElementError} If no swidge exists for the given id.
198
+ * @throws {ProviderRequiredError} If the method requires a provider.
199
+ * @throws {ProviderError} If the provider fails to fetch the swidge's status.
200
+ */
201
+ abstract getSwidgeStatus(id: string, options?: SwidgeStatusOptions): Promise<SwidgeStatusResult>;
202
+ /**
203
+ * Retrieves the chains supported by the provider for swidge operations.
204
+ *
205
+ * @abstract
206
+ * @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
207
+ * @throws {ProviderRequiredError} If the method requires a provider.
208
+ * @throws {ProviderError} If the provider fails to fetch the available blockchains.
209
+ */
210
+ abstract getSupportedChains(): Promise<SwidgeSupportedChain[]>;
211
+ /**
212
+ * Retrieves the tokens supported by the provider for swidge operations.
213
+ *
214
+ * @abstract
215
+ * @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
216
+ * @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
217
+ * @throws {ProviderRequiredError} If the method requires a provider.
218
+ * @throws {ProviderError} If the provider fails to fetch the available tokens.
219
+ */
220
+ abstract getSupportedTokens(options?: SwidgeSupportedTokensOptions): Promise<SwidgeSupportedToken[]>;
221
+ }
222
+ export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
223
+ export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
224
+ export type ISwapProtocol = import("./swap-protocol.js").ISwapProtocol;
225
+ export type SwapOptions = import("./swap-protocol.js").SwapOptions;
226
+ export type SwapResult = import("./swap-protocol.js").SwapResult;
227
+ export type IBridgeProtocol = import("./bridge-protocol.js").IBridgeProtocol;
228
+ export type BridgeOptions = import("./bridge-protocol.js").BridgeOptions;
229
+ export type BridgeResult = import("./bridge-protocol.js").BridgeResult;
230
+ export type AccountRequiredError = import("./errors.js").AccountRequiredError;
231
+ export type InvalidTokenError = import("./errors.js").InvalidTokenError;
232
+ export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
233
+ export type NoSuchElementError = import("./errors.js").NoSuchElementError;
234
+ export type ReadOnlyAccountRequiredError = import("./errors.js").ReadOnlyAccountRequiredError;
235
+ export type ProviderError = import("./errors.js").ProviderError;
236
+ export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
237
+ export type ValueError = import("./errors.js").ValueError;
238
+ export type SwidgeStatus = "pending" | "action-required" | "completed" | "failed" | "refund-pending" | "refunded" | "cancelled" | "expired" | "partial";
239
+ export type SwidgeFeeType = "network" | "protocol" | "affiliate" | "other";
240
+ export type SwidgeProtocolConfig = {
241
+ /**
242
+ * - Maximum acceptable network fee in basis points of the input amount.
243
+ */
244
+ maxNetworkFeeBps?: number | bigint;
245
+ /**
246
+ * - Maximum acceptable protocol fee in basis points of the input amount.
247
+ */
248
+ maxProtocolFeeBps?: number | bigint;
249
+ };
250
+ export type SwidgeOptions = SwidgeCommonOptions & (SwidgeExactInOptions | SwidgeExactOutOptions);
251
+ export type SwidgeCommonOptions = {
252
+ /**
253
+ * - The provider-specific identifier or address of the source token.
254
+ */
255
+ fromToken: string;
256
+ /**
257
+ * - The provider-specific identifier or address of the destination token.
258
+ */
259
+ toToken: string;
260
+ /**
261
+ * - The identifier of the destination chain. If omitted, defaults to the source chain (same-chain swap).
262
+ */
263
+ toChain?: string | number;
264
+ /**
265
+ * - The address that will receive the output tokens.
266
+ */
267
+ recipient?: string;
268
+ /**
269
+ * - The address that will receive refunds if the tx cannot complete.
270
+ */
271
+ refundAddress?: string;
272
+ /**
273
+ * - The maximum acceptable slippage as a decimal (e.g., 0.01 for 1%).
274
+ */
275
+ slippage?: number;
276
+ /**
277
+ * - The minimum acceptable amount of destination tokens to receive (in base unit).
278
+ */
279
+ minAmountOut?: number | bigint;
280
+ };
281
+ export type SwidgeExactInOptions = {
282
+ /**
283
+ * - The exact amount of source tokens to spend (in base unit).
284
+ */
285
+ fromTokenAmount: number | bigint;
286
+ /**
287
+ * - Not applicable for exact-in operations.
288
+ */
289
+ toTokenAmount?: never;
290
+ };
291
+ export type SwidgeExactOutOptions = {
292
+ /**
293
+ * - Not applicable for exact-out operations.
294
+ */
295
+ fromTokenAmount?: never;
296
+ /**
297
+ * - The exact amount of destination tokens to receive (in base unit).
298
+ */
299
+ toTokenAmount: number | bigint;
300
+ };
301
+ export type SwidgeFee = {
302
+ /**
303
+ * - The category of the fee.
304
+ */
305
+ type: SwidgeFeeType;
306
+ /**
307
+ * - The fee amount in base units.
308
+ */
309
+ amount: bigint;
310
+ /**
311
+ * - The token in which the fee is denominated.
312
+ */
313
+ token: string;
314
+ /**
315
+ * - The chain on which the fee is charged.
316
+ */
317
+ chain?: string | number;
318
+ /**
319
+ * - Whether the fee is already included in the quoted amounts.
320
+ */
321
+ included?: boolean;
322
+ /**
323
+ * - A human-readable description of the fee.
324
+ */
325
+ description?: string;
326
+ };
327
+ export type SwidgeTransaction = {
328
+ /**
329
+ * - The transaction hash.
330
+ */
331
+ hash: string;
332
+ /**
333
+ * - The chain on which the transaction occurred.
334
+ */
335
+ chain?: string | number;
336
+ /**
337
+ * - The role of the transaction within the swidge.
338
+ */
339
+ type?: "source" | "destination" | "approval" | "refund" | "other";
340
+ };
341
+ /**
342
+ * Non-binding quote for a swidge operation.
343
+ * Providers that internally decompose the operation into multiple sequential transactions
344
+ * should encapsulate that decomposition behind a single quote.
345
+ */
346
+ export type SwidgeQuote = {
347
+ /**
348
+ * - The amount of source tokens to spend.
349
+ */
350
+ fromTokenAmount: bigint;
351
+ /**
352
+ * - The estimated amount of destination tokens to receive.
353
+ */
354
+ toTokenAmount: bigint;
355
+ /**
356
+ * - The minimum guaranteed amount after slippage.
357
+ */
358
+ toTokenAmountMin: bigint;
359
+ /**
360
+ * - Itemised fee breakdown.
361
+ */
362
+ fees: SwidgeFee[];
363
+ /**
364
+ * - Estimated duration in seconds.
365
+ */
366
+ estimatedDuration?: number;
367
+ /**
368
+ * - Unix timestamp (seconds) at which the quote expires.
369
+ */
370
+ expiry?: number;
371
+ /**
372
+ * - Provider-reported estimated price impact as a decimal (e.g., 0.01 for 1%).
373
+ */
374
+ priceImpact?: number;
375
+ };
376
+ export type SwidgeResult = {
377
+ /**
378
+ * - The unique swidge execution identifier.
379
+ */
380
+ id: string;
381
+ /**
382
+ * - The primary transaction hash (if available immediately).
383
+ */
384
+ hash?: string;
385
+ /**
386
+ * - Itemised fee breakdown.
387
+ */
388
+ fees: SwidgeFee[];
389
+ /**
390
+ * - Transactions produced by the swidge execution.
391
+ */
392
+ transactions?: SwidgeTransaction[];
393
+ /**
394
+ * - The actual amount of source tokens spent.
395
+ */
396
+ fromTokenAmount: bigint;
397
+ /**
398
+ * - The actual or expected amount of destination tokens.
399
+ */
400
+ toTokenAmount: bigint;
401
+ /**
402
+ * - The minimum guaranteed amount after slippage.
403
+ */
404
+ toTokenAmountMin?: bigint;
405
+ };
406
+ export type SwidgeStatusOptions = {
407
+ /**
408
+ * - The source chain identifier.
409
+ */
410
+ fromChain?: string | number;
411
+ /**
412
+ * - The destination chain identifier.
413
+ */
414
+ toChain?: string | number;
415
+ };
416
+ export type SwidgeStatusResult = {
417
+ /**
418
+ * - The current status of the swidge.
419
+ */
420
+ status: SwidgeStatus;
421
+ /**
422
+ * - Transactions associated with the swidge.
423
+ */
424
+ transactions?: SwidgeTransaction[];
425
+ };
426
+ export type SwidgeSupportedChain = {
427
+ /**
428
+ * - The provider-specific chain identifier.
429
+ */
430
+ id: string | number;
431
+ /**
432
+ * - The human-readable chain name.
433
+ */
434
+ name: string;
435
+ /**
436
+ * - The chain or virtual machine type (e.g., 'evm', 'svm', 'utxo').
437
+ */
438
+ type: string;
439
+ /**
440
+ * - The symbol of the chain's native token.
441
+ */
442
+ nativeToken: string;
443
+ };
444
+ export type SwidgeSupportedToken = {
445
+ /**
446
+ * - The provider-specific token identifier to use in swidge operations.
447
+ */
448
+ token: string;
449
+ /**
450
+ * - The chain on which the token is available.
451
+ */
452
+ chain: string | number;
453
+ /**
454
+ * - The token symbol.
455
+ */
456
+ symbol: string;
457
+ /**
458
+ * - The number of decimal places for the token's base unit.
459
+ */
460
+ decimals: number;
461
+ /**
462
+ * - The token contract address, if applicable.
463
+ */
464
+ address?: string;
465
+ /**
466
+ * - The token's full name.
467
+ */
468
+ name?: string;
469
+ };
470
+ export type SwidgeSupportedTokensOptions = {
471
+ /**
472
+ * - The optional source chain for route-scoped discovery.
473
+ */
474
+ fromChain?: string | number;
475
+ /**
476
+ * - The optional source token for route-scoped discovery.
477
+ */
478
+ fromToken?: string;
479
+ /**
480
+ * - The optional destination chain for route-scoped discovery.
481
+ */
482
+ toChain?: string | number;
483
+ };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * A minimal, cross-chain signer interface.
3
+ *
4
+ * @interface
5
+ */
6
+ export class ISigner extends IDisposable {
7
+ /**
8
+ * Whether the signer supports account derivation via {@link derive}.
9
+ *
10
+ * @type {boolean}
11
+ */
12
+ get isDerivable(): boolean;
13
+ /**
14
+ * The signer's key pair, or null if the signer does not allow retrieving
15
+ * key material (e.g. hardware signers).
16
+ *
17
+ * @type {KeyPair | null}
18
+ */
19
+ get keyPair(): KeyPair | null;
20
+ /**
21
+ * The BIP 0032 derivation path, or null if the signer is not bound to a derivation position
22
+ * (e.g. private-key signers).
23
+ *
24
+ * @type {string | null}
25
+ */
26
+ get path(): string | null;
27
+ /**
28
+ * Derive a child signer using a relative path (e.g., "0'/0/0").
29
+ *
30
+ * @param {string} path - The relative derivation path.
31
+ * @returns {Promise<ISigner>} The derived signer.
32
+ * @throws {UnsupportedOperationError} If the signer does not support account derivation.
33
+ * @throws {ValueError} If the path is not valid.
34
+ */
35
+ derive(path: string): Promise<ISigner>;
36
+ /**
37
+ * Returns the signer's address.
38
+ *
39
+ * @returns {Promise<string>} The address.
40
+ */
41
+ getAddress(): Promise<string>;
42
+ /**
43
+ * Signs a message.
44
+ *
45
+ * @param {string} message - The message to sign.
46
+ * @returns {Promise<string>} The message's signature.
47
+ */
48
+ sign(message: string): Promise<string>;
49
+ }
50
+ export type KeyPair = import("./wallet-account.js").KeyPair;
51
+ import { IDisposable } from "./disposable.js";
52
+ export type UnsupportedOperationError = import("./errors.js").UnsupportedOperationError;
53
+ export type ValueError = import("./errors.js").ValueError;