@tetherto/wdk-wallet 1.0.0-beta.13 → 1.0.0-beta.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tetherto/wdk-wallet",
3
- "version": "1.0.0-beta.13",
3
+ "version": "1.0.0-beta.14",
4
4
  "description": "A simple package to manage BIP-32 wallets.",
5
5
  "keywords": [
6
6
  "wdk",
@@ -33,6 +33,7 @@ import { NotImplementedError } from '../errors.js'
33
33
  * @property {string} tokenIn - The address of the token to sell.
34
34
  * @property {string} tokenOut - The address of the token to buy.
35
35
  * @property {string} [to] - The address that will receive the output tokens. If not set, the account itself will receive the funds.
36
+ * @property {number | bigint} [minAmountOut] - The minimum acceptable amount of destination tokens to receive (in base unit).
36
37
  */
37
38
 
38
39
  /**
@@ -54,6 +54,7 @@ import { NotImplementedError } from '../errors.js'
54
54
  * @property {string} [recipient] - The address that will receive the output tokens.
55
55
  * @property {string} [refundAddress] - The address that will receive refunds if the tx cannot complete.
56
56
  * @property {number} [slippage] - The maximum acceptable slippage as a decimal (e.g., 0.01 for 1%).
57
+ * @property {number | bigint} [minAmountOut] - The minimum acceptable amount of destination tokens to receive (in base unit).
57
58
  */
58
59
 
59
60
  /**
@@ -270,7 +271,8 @@ export default class SwidgeProtocol {
270
271
  toToken: options.tokenOut,
271
272
  recipient: options.to,
272
273
  fromTokenAmount: options.tokenInAmount,
273
- toTokenAmount: options.tokenOutAmount
274
+ toTokenAmount: options.tokenOutAmount,
275
+ minAmountOut: options.minAmountOut
274
276
  })
275
277
  const fee = result.fees.reduce((acc, f) => acc + f.amount, 0n)
276
278
  return { hash: result.id, fee, tokenInAmount: result.fromTokenAmount, tokenOutAmount: result.toTokenAmount }
@@ -289,7 +291,8 @@ export default class SwidgeProtocol {
289
291
  toToken: options.tokenOut,
290
292
  recipient: options.to,
291
293
  fromTokenAmount: options.tokenInAmount,
292
- toTokenAmount: options.tokenOutAmount
294
+ toTokenAmount: options.tokenOutAmount,
295
+ minAmountOut: options.minAmountOut
293
296
  })
294
297
  const fee = result.fees.reduce((acc, f) => acc + f.amount, 0n)
295
298
  return { fee, tokenInAmount: result.fromTokenAmount, tokenOutAmount: result.toTokenAmount }
@@ -86,6 +86,10 @@ type SwapCommonOptions = {
86
86
  * - The address that will receive the output tokens. If not set, the account itself will receive the funds.
87
87
  */
88
88
  to?: string;
89
+ /**
90
+ * - The minimum acceptable amount of destination tokens to receive (in base unit).
91
+ */
92
+ minAmountOut?: number | bigint;
89
93
  };
90
94
  type SwapBuyOptions = {
91
95
  /**
@@ -85,6 +85,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
85
85
  *
86
86
  * @param {SwapOptions} options - The swap's options.
87
87
  * @returns {Promise<SwapResult>} The swap's result.
88
+ * @throws {Error} If no account, or a read-only account was given at construction.
88
89
  */
89
90
  swap(options: SwapOptions): Promise<SwapResult>;
90
91
  /**
@@ -92,6 +93,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
92
93
  *
93
94
  * @param {SwapOptions} options - The swap's options.
94
95
  * @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
96
+ * @throws {Error} If no account was given at construction.
95
97
  */
96
98
  quoteSwap(options: SwapOptions): Promise<Omit<SwapResult, "hash">>;
97
99
  /**
@@ -99,6 +101,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
99
101
  *
100
102
  * @param {BridgeOptions} options - The bridge's options.
101
103
  * @returns {Promise<BridgeResult>} The bridge's result.
104
+ * @throws {Error} If no account, or a read-only account was given at construction.
102
105
  */
103
106
  bridge(options: BridgeOptions): Promise<BridgeResult>;
104
107
  /**
@@ -106,6 +109,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
106
109
  *
107
110
  * @param {BridgeOptions} options - The bridge's options.
108
111
  * @returns {Promise<Omit<BridgeResult, 'hash'>>} The bridge's quotes.
112
+ * @throws {Error} If no account was given at construction.
109
113
  */
110
114
  quoteBridge(options: BridgeOptions): Promise<Omit<BridgeResult, "hash">>;
111
115
  /**
@@ -116,6 +120,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
116
120
  * @abstract
117
121
  * @param {SwidgeOptions} options - The swidge options.
118
122
  * @returns {Promise<SwidgeQuote>} The quoted swidge details.
123
+ * @throws {Error} If no account was given at construction.
119
124
  */
120
125
  abstract quoteSwidge(options: SwidgeOptions): Promise<SwidgeQuote>;
121
126
  /**
@@ -125,6 +130,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
125
130
  * @param {SwidgeOptions} options - The swidge options.
126
131
  * @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
127
132
  * @returns {Promise<SwidgeResult>} The swidge execution result.
133
+ * @throws {Error} If no account, or a read-only account was given at construction.
128
134
  */
129
135
  abstract swidge(options: SwidgeOptions, config?: SwidgeProtocolConfig): Promise<SwidgeResult>;
130
136
  /**
@@ -199,6 +205,10 @@ export type SwidgeCommonOptions = {
199
205
  * - The maximum acceptable slippage as a decimal (e.g., 0.01 for 1%).
200
206
  */
201
207
  slippage?: number | undefined;
208
+ /**
209
+ * - The minimum acceptable amount of destination tokens to receive (in base unit).
210
+ */
211
+ minAmountOut?: number | bigint;
202
212
  };
203
213
  export type SwidgeExactInOptions = {
204
214
  /**
@@ -260,6 +270,11 @@ export type SwidgeTransaction = {
260
270
  */
261
271
  type?: "other" | "source" | "destination" | "approval" | "refund" | undefined;
262
272
  };
273
+ /**
274
+ * Non-binding quote for a swidge operation.
275
+ * Providers that internally decompose the operation into multiple sequential transactions
276
+ * should encapsulate that decomposition behind a single quote.
277
+ */
263
278
  export type SwidgeQuote = {
264
279
  /**
265
280
  * - The amount of source tokens to spend.