@tetherto/wdk-wallet 1.0.0-beta.15 → 1.0.0-beta.17

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 (45) hide show
  1. package/index.js +11 -12
  2. package/package.json +5 -1
  3. package/src/errors.js +280 -19
  4. package/src/multisig/errors.js +54 -0
  5. package/src/multisig/index.js +42 -0
  6. package/src/multisig/multisig-message-signing-read-only.js +63 -0
  7. package/src/multisig/multisig-message-signing.js +64 -0
  8. package/src/multisig/multisig-owner-management.js +94 -0
  9. package/src/multisig/wallet-account-multisig.js +144 -0
  10. package/src/multisig/wallet-account-read-only-multisig.js +98 -0
  11. package/src/protocols/bridge-protocol.js +35 -1
  12. package/src/protocols/errors.js +510 -0
  13. package/src/protocols/fiat-protocol.js +104 -4
  14. package/src/protocols/index.js +13 -0
  15. package/src/protocols/lending-protocol.js +114 -2
  16. package/src/protocols/sda-protocol.js +103 -16
  17. package/src/protocols/swap-protocol.js +35 -1
  18. package/src/protocols/swidge-protocol.js +166 -55
  19. package/src/signer.js +8 -4
  20. package/src/wallet-account-read-only-simple.js +162 -0
  21. package/src/wallet-account-read-only.js +176 -55
  22. package/src/wallet-account.js +25 -1
  23. package/src/wallet-manager.js +38 -22
  24. package/types/index.d.ts +9 -2
  25. package/types/src/errors.d.ts +198 -14
  26. package/types/src/multisig/errors.d.ts +33 -0
  27. package/types/src/multisig/index.d.ts +15 -0
  28. package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
  29. package/types/src/multisig/multisig-message-signing.d.ts +40 -0
  30. package/types/src/multisig/multisig-owner-management.d.ts +65 -0
  31. package/types/src/multisig/wallet-account-multisig.d.ts +101 -0
  32. package/types/src/multisig/wallet-account-read-only-multisig.d.ts +83 -0
  33. package/types/src/protocols/bridge-protocol.d.ts +39 -3
  34. package/types/src/protocols/errors.d.ts +366 -0
  35. package/types/src/protocols/fiat-protocol.d.ts +103 -9
  36. package/types/src/protocols/index.d.ts +11 -0
  37. package/types/src/protocols/lending-protocol.d.ts +118 -4
  38. package/types/src/protocols/sda-protocol.d.ts +120 -23
  39. package/types/src/protocols/swap-protocol.d.ts +40 -4
  40. package/types/src/protocols/swidge-protocol.d.ts +106 -38
  41. package/types/src/signer.d.ts +6 -4
  42. package/types/src/wallet-account-read-only-simple.d.ts +144 -0
  43. package/types/src/wallet-account-read-only.d.ts +97 -39
  44. package/types/src/wallet-account.d.ts +27 -3
  45. package/types/src/wallet-manager.d.ts +37 -35
@@ -13,19 +13,31 @@
13
13
  // limitations under the License.
14
14
  'use strict'
15
15
 
16
- import { NotImplementedError } from '../errors.js'
16
+ import { NotImplementedError } from './errors.js'
17
17
 
18
18
  /** @typedef {import('../wallet-account-read-only.js').IWalletAccountReadOnly} IWalletAccountReadOnly */
19
19
 
20
20
  /** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
21
21
 
22
+ /** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
23
+ /** @typedef {import('./errors.js').BuyError} BuyError */
24
+ /** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
25
+ /** @typedef {import('./errors.js').NoSuchElementError} NoSuchElementError */
26
+ /** @typedef {import('./errors.js').ReadOnlyAccountRequiredError} ReadOnlyAccountRequiredError */
27
+ /** @typedef {import('./errors.js').ProviderError} ProviderError */
28
+ /** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
29
+ /** @typedef {import('./errors.js').SellError} SellError */
30
+ /** @typedef {import('./errors.js').ValueError} ValueError */
31
+
22
32
  /**
23
33
  * Standardized status for an on/off-ramp transaction.
34
+ *
24
35
  * @typedef {'in_progress' | 'failed' | 'completed'} FiatTransactionStatus
25
36
  */
26
37
 
27
38
  /**
28
39
  * A protocol-agnostic, standardized object representing the details of an on/off-ramp transaction.
40
+ *
29
41
  * @typedef {Object} FiatTransactionDetail
30
42
  * @property {FiatTransactionStatus} status - The current status of the transaction.
31
43
  * @property {string} cryptoAsset - The provider-specific code of the crypto asset (e.g., 'btc').
@@ -34,6 +46,7 @@ import { NotImplementedError } from '../errors.js'
34
46
 
35
47
  /**
36
48
  * A protocol-agnostic, standardized object representing a supported crypto asset.
49
+ *
37
50
  * @typedef {Object} SupportedCryptoAsset
38
51
  * @property {string} code - Provider-specific asset code for the crypto asset.
39
52
  * @property {string} networkCode - The network code for the asset, if applicable (e.g., 'ethereum', 'tron').
@@ -116,6 +129,7 @@ import { NotImplementedError } from '../errors.js'
116
129
 
117
130
  /**
118
131
  * A protocol-agnostic, standardized object representing a quote for an on/off-ramp transaction.
132
+ *
119
133
  * @typedef {Object} FiatQuote
120
134
  * @property {bigint} cryptoAmount - The amount of the crypto asset, in its base unit (e.g., wei).
121
135
  * @property {bigint} fiatAmount - The amount of the fiat currency, in its smallest unit (e.g., cents).
@@ -123,14 +137,18 @@ import { NotImplementedError } from '../errors.js'
123
137
  * @property {string} rate - The effective exchange rate, expressed as a string to avoid precision loss (e.g., a rate of "3000.50" for ETH/USD means 1 ETH = 3000.50 USD). Note: This rate applies to the standard units (e.g., ETH and USD).
124
138
  */
125
139
 
126
- /**
127
- * @interface
128
- */
140
+ /** @interface */
129
141
  export class IFiatProtocol {
130
142
  /**
131
143
  * Gets a quote for a crypto asset purchase.
144
+ *
132
145
  * @param {Omit<BuyOptions, 'recipient'>} options - The options for the buy operation.
133
146
  * @returns {Promise<FiatQuote>} A quote for the transaction.
147
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a purchase.
148
+ * @throws {ValueError} If the buy options are not valid.
149
+ * @throws {ProviderRequiredError} If the method requires a provider.
150
+ * @throws {ProviderError} If the provider fails to estimate the costs of the purchase.
151
+ * @throws {BuyError} If the purchase fails with an error.
134
152
  */
135
153
  async quoteBuy (options) {
136
154
  throw new NotImplementedError('quoteBuy(options)')
@@ -138,8 +156,15 @@ export class IFiatProtocol {
138
156
 
139
157
  /**
140
158
  * Generates a widget URL for a user to purchase a crypto asset with fiat currency.
159
+ *
141
160
  * @param {BuyOptions} options - The options for the buy operation.
142
161
  * @returns {Promise<BuyResult>} The operation's result.
162
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a purchase.
163
+ * @throws {ValueError} If the buy options are not valid.
164
+ * @throws {ProviderRequiredError} If the method requires a provider.
165
+ * @throws {ProviderError} If the provider fails to perform the purchase.
166
+ * @throws {BuyError} If the purchase fails with an error.
167
+ * @throws {MaximumFeeExceededError} If the the costs of the purchase exceeds the buy max. fee option.
143
168
  */
144
169
  async buy (options) {
145
170
  throw new NotImplementedError('buy(options)')
@@ -147,8 +172,14 @@ export class IFiatProtocol {
147
172
 
148
173
  /**
149
174
  * Gets a quote for a crypto asset sale.
175
+ *
150
176
  * @param {Omit<SellOptions, 'refundAddress'>} options - The options for the sell operation.
151
177
  * @returns {Promise<FiatQuote>} A quote for the transaction.
178
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a sale.
179
+ * @throws {ValueError} If the sell options are not valid.
180
+ * @throws {ProviderRequiredError} If the method requires a provider.
181
+ * @throws {ProviderError} If the provider fails to estimate the costs of the sale.
182
+ * @throws {SellError} If the sale fails with an error.
152
183
  */
153
184
  async quoteSell (options) {
154
185
  throw new NotImplementedError('quoteSell(options)')
@@ -156,8 +187,15 @@ export class IFiatProtocol {
156
187
 
157
188
  /**
158
189
  * Generates a widget URL for a user to sell a crypto asset for fiat currency.
190
+ *
159
191
  * @param {SellOptions} options - The options for the sell operation.
160
192
  * @returns {Promise<SellResult>} The operation's result.
193
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a sale.
194
+ * @throws {ValueError} If the buy options are not valid.
195
+ * @throws {ProviderRequiredError} If the method requires a provider.
196
+ * @throws {ProviderError} If the provider fails to perform the sale.
197
+ * @throws {SellError} If the sale fails with an error.
198
+ * @throws {MaximumFeeExceededError} If the the costs of the sale exceeds the sell max. fee option.
161
199
  */
162
200
  async sell (options) {
163
201
  throw new NotImplementedError('sell(options)')
@@ -165,8 +203,13 @@ export class IFiatProtocol {
165
203
 
166
204
  /**
167
205
  * Retrieves the details of a specific transaction from the provider.
206
+ *
168
207
  * @param {string} txId - The unique identifier of the transaction.
169
208
  * @returns {Promise<FiatTransactionDetail>} The transaction details.
209
+ * @throws {ValueError} If the transaction's id is not valid.
210
+ * @throws {NoSuchElementError} If no transaction exists for the given id.
211
+ * @throws {ProviderRequiredError} If the method requires a provider.
212
+ * @throws {ProviderError} If the provider fails to fetch the transaction's details.
170
213
  */
171
214
  async getTransactionDetail (txId) {
172
215
  throw new NotImplementedError('getTransactionDetail(txId)')
@@ -174,7 +217,10 @@ export class IFiatProtocol {
174
217
 
175
218
  /**
176
219
  * Retrieves a list of supported crypto assets from the provider.
220
+ *
177
221
  * @returns {Promise<SupportedCryptoAsset[]>} An array of supported crypto assets.
222
+ * @throws {ProviderRequiredError} If the method requires a provider.
223
+ * @throws {ProviderError} If the provider fails to fetch the available crypto assets.
178
224
  */
179
225
  async getSupportedCryptoAssets () {
180
226
  throw new NotImplementedError('getSupportedCryptoAssets()')
@@ -182,7 +228,10 @@ export class IFiatProtocol {
182
228
 
183
229
  /**
184
230
  * Retrieves a list of supported fiat currencies from the provider.
231
+ *
185
232
  * @returns {Promise<SupportedFiatCurrency[]>} An array of supported fiat currencies.
233
+ * @throws {ProviderRequiredError} If the method requires a provider.
234
+ * @throws {ProviderError} If the provider fails to fetch the available fiat currencies.
186
235
  */
187
236
  async getSupportedFiatCurrencies () {
188
237
  throw new NotImplementedError('getSupportedFiatCurrencies()')
@@ -190,7 +239,10 @@ export class IFiatProtocol {
190
239
 
191
240
  /**
192
241
  * Retrieves a list of supported countries from the provider.
242
+ *
193
243
  * @returns {Promise<SupportedCountry[]>} An array of supported countries.
244
+ * @throws {ProviderRequiredError} If the method requires a provider.
245
+ * @throws {ProviderError} If the provider fails to fetch the available countries.
194
246
  */
195
247
  async getSupportedCountries () {
196
248
  throw new NotImplementedError('getSupportedCountries()')
@@ -232,8 +284,15 @@ export default class FiatProtocol {
232
284
 
233
285
  /**
234
286
  * Gets a quote for a crypto asset purchase.
287
+ *
288
+ * @abstract
235
289
  * @param {Omit<BuyOptions, 'recipient'>} options - The options for the buy operation.
236
290
  * @returns {Promise<FiatQuote>} A quote for the transaction.
291
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a purchase.
292
+ * @throws {ValueError} If the buy options are not valid.
293
+ * @throws {ProviderRequiredError} If the method requires a provider.
294
+ * @throws {ProviderError} If the provider fails to estimate the costs of the purchase.
295
+ * @throws {BuyError} If the purchase fails with an error.
237
296
  */
238
297
  async quoteBuy (options) {
239
298
  throw new NotImplementedError('quoteBuy(options)')
@@ -241,8 +300,16 @@ export default class FiatProtocol {
241
300
 
242
301
  /**
243
302
  * Generates a URL for a user to purchase a crypto asset with fiat currency.
303
+ *
304
+ * @abstract
244
305
  * @param {BuyOptions} options - The options for the buy operation.
245
306
  * @returns {Promise<BuyResult>} The URL for the user to complete the purchase.
307
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a purchase.
308
+ * @throws {ValueError} If the buy options are not valid.
309
+ * @throws {ProviderRequiredError} If the method requires a provider.
310
+ * @throws {ProviderError} If the provider fails to perform the purchase.
311
+ * @throws {BuyError} If the purchase fails with an error.
312
+ * @throws {MaximumFeeExceededError} If the the costs of the purchase exceeds the buy max. fee option.
246
313
  */
247
314
  async buy (options) {
248
315
  throw new NotImplementedError('buy(options)')
@@ -250,8 +317,15 @@ export default class FiatProtocol {
250
317
 
251
318
  /**
252
319
  * Gets a quote for a crypto asset sale.
320
+ *
321
+ * @abstract
253
322
  * @param {Omit<SellOptions, 'refundAddress'>} options - The options for the sell operation.
254
323
  * @returns {Promise<FiatQuote>} A quote for the transaction.
324
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a sale.
325
+ * @throws {ValueError} If the sell options are not valid.
326
+ * @throws {ProviderRequiredError} If the method requires a provider.
327
+ * @throws {ProviderError} If the provider fails to estimate the costs of the sale.
328
+ * @throws {SellError} If the sale fails with an error.
255
329
  */
256
330
  async quoteSell (options) {
257
331
  throw new NotImplementedError('quoteSell(options)')
@@ -259,8 +333,16 @@ export default class FiatProtocol {
259
333
 
260
334
  /**
261
335
  * Generates a URL for a user to sell a crypto asset for fiat currency.
336
+ *
337
+ * @abstract
262
338
  * @param {SellOptions} options - The options for the sell operation.
263
339
  * @returns {Promise<SellResult>} The URL for the user to complete the sale.
340
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a sale.
341
+ * @throws {ValueError} If the buy options are not valid.
342
+ * @throws {ProviderRequiredError} If the method requires a provider.
343
+ * @throws {ProviderError} If the provider fails to perform the sale.
344
+ * @throws {SellError} If the sale fails with an error.
345
+ * @throws {MaximumFeeExceededError} If the the costs of the sale exceeds the sell max. fee option.
264
346
  */
265
347
  async sell (options) {
266
348
  throw new NotImplementedError('sell(options)')
@@ -268,8 +350,14 @@ export default class FiatProtocol {
268
350
 
269
351
  /**
270
352
  * Retrieves the details of a specific transaction from the provider.
353
+ *
354
+ * @abstract
271
355
  * @param {string} txId - The unique identifier of the transaction.
272
356
  * @returns {Promise<FiatTransactionDetail>} The transaction details.
357
+ * @throws {ValueError} If the transaction's id is not valid.
358
+ * @throws {NoSuchElementError} If no transaction exists for the given id.
359
+ * @throws {ProviderRequiredError} If the method requires a provider.
360
+ * @throws {ProviderError} If the provider fails to fetch the transaction's details.
273
361
  */
274
362
  async getTransactionDetail (txId) {
275
363
  throw new NotImplementedError('getTransactionDetail(txId)')
@@ -277,7 +365,11 @@ export default class FiatProtocol {
277
365
 
278
366
  /**
279
367
  * Retrieves a list of supported crypto assets from the provider.
368
+ *
369
+ * @abstract
280
370
  * @returns {Promise<SupportedCryptoAsset[]>} An array of supported crypto assets.
371
+ * @throws {ProviderRequiredError} If the method requires a provider.
372
+ * @throws {ProviderError} If the provider fails to fetch the available crypto assets.
281
373
  */
282
374
  async getSupportedCryptoAssets () {
283
375
  throw new NotImplementedError('getSupportedCryptoAssets()')
@@ -285,7 +377,11 @@ export default class FiatProtocol {
285
377
 
286
378
  /**
287
379
  * Retrieves a list of supported fiat currencies from the provider.
380
+ *
381
+ * @abstract
288
382
  * @returns {Promise<SupportedFiatCurrency[]>} An array of supported fiat currencies.
383
+ * @throws {ProviderRequiredError} If the method requires a provider.
384
+ * @throws {ProviderError} If the provider fails to fetch the available fiat currencies.
289
385
  */
290
386
  async getSupportedFiatCurrencies () {
291
387
  throw new NotImplementedError('getSupportedFiatCurrencies()')
@@ -293,7 +389,11 @@ export default class FiatProtocol {
293
389
 
294
390
  /**
295
391
  * Retrieves a list of supported countries or regions from the provider.
392
+ *
393
+ * @abstract
296
394
  * @returns {Promise<SupportedCountry[]>} An array of supported countries.
395
+ * @throws {ProviderRequiredError} If the method requires a provider.
396
+ * @throws {ProviderError} If the provider fails to fetch the available countries.
297
397
  */
298
398
  async getSupportedCountries () {
299
399
  throw new NotImplementedError('getSupportedCountries()')
@@ -87,6 +87,17 @@
87
87
  /** @typedef {import('./sda-protocol.js').SdaRecoveryOptions} SdaRecoveryOptions */
88
88
  /** @typedef {import('./sda-protocol.js').SdaRecoveryResult} SdaRecoveryResult */
89
89
 
90
+ /** @typedef {import('./errors.js').SwapErrorOptions} SwapErrorOptions */
91
+ /** @typedef {import('./errors.js').BridgeErrorOptions} BridgeErrorOptions */
92
+ /** @typedef {import('./errors.js').SupplyErrorOptions} SupplyErrorOptions */
93
+ /** @typedef {import('./errors.js').WithdrawErrorOptions} WithdrawErrorOptions */
94
+ /** @typedef {import('./errors.js').BorrowErrorOptions} BorrowErrorOptions */
95
+ /** @typedef {import('./errors.js').RepayErrorOptions} RepayErrorOptions */
96
+ /** @typedef {import('./errors.js').BuyErrorOptions} BuyErrorOptions */
97
+ /** @typedef {import('./errors.js').SellErrorOptions} SellErrorOptions */
98
+ /** @typedef {import('./errors.js').SwidgeErrorOptions} SwidgeErrorOptions */
99
+ /** @typedef {import('./errors.js').SdaErrorOptions} SdaErrorOptions */
100
+
90
101
  export { default as SwapProtocol, ISwapProtocol } from './swap-protocol.js'
91
102
 
92
103
  export { default as BridgeProtocol, IBridgeProtocol } from './bridge-protocol.js'
@@ -98,3 +109,5 @@ export { default as FiatProtocol, IFiatProtocol } from './fiat-protocol.js'
98
109
  export { default as SwidgeProtocol, ISwidgeProtocol } from './swidge-protocol.js'
99
110
 
100
111
  export { default as SdaProtocol, ISdaProtocol } from './sda-protocol.js'
112
+
113
+ export { AccountRequiredError, BorrowError, BorrowErrorReason, BridgeError, BridgeErrorReason, BuyError, BuyErrorReason, InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, ReadOnlyAccountRequiredError, RepayError, RepayErrorReason, SdaError, SdaErrorReason, SellError, SellErrorReason, SupplyError, SupplyErrorReason, SwapError, SwapErrorReason, SwidgeError, SwidgeErrorReason, UnsupportedOperationError, ValueError, WdkError, WithdrawError, WithdrawErrorReason } from './errors.js'
@@ -13,12 +13,24 @@
13
13
  // limitations under the License.
14
14
  'use strict'
15
15
 
16
- import { NotImplementedError } from '../errors.js'
16
+ import { NotImplementedError } from './errors.js'
17
17
 
18
18
  /** @typedef {import('../wallet-account-read-only.js').IWalletAccountReadOnly} IWalletAccountReadOnly */
19
19
 
20
20
  /** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
21
21
 
22
+ /** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
23
+ /** @typedef {import('./errors.js').BorrowError} BorrowError */
24
+ /** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
25
+ /** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
26
+ /** @typedef {import('./errors.js').ReadOnlyAccountRequiredError} ReadOnlyAccountRequiredError */
27
+ /** @typedef {import('./errors.js').ProviderError} ProviderError */
28
+ /** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
29
+ /** @typedef {import('./errors.js').RepayError} RepayError */
30
+ /** @typedef {import('./errors.js').SupplyError} SupplyError */
31
+ /** @typedef {import('./errors.js').ValueError} ValueError */
32
+ /** @typedef {import('./errors.js').WithdrawError} WithdrawError */
33
+
22
34
  /**
23
35
  * @typedef {Object} SupplyOptions
24
36
  * @property {string} token - The address of the token to supply.
@@ -78,6 +90,13 @@ export class ILendingProtocol {
78
90
  *
79
91
  * @param {SupplyOptions} options - The supply's options.
80
92
  * @returns {Promise<SupplyResult>} The supply's result.
93
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
94
+ * @throws {ValueError} If the supply options are not valid.
95
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
96
+ * @throws {ProviderRequiredError} If the method requires a provider.
97
+ * @throws {ProviderError} If the provider fails to perform the supply.
98
+ * @throws {SupplyError} If the supply fails with an error.
99
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the supply max. fee option.
81
100
  */
82
101
  async supply (options) {
83
102
  throw new NotImplementedError('supply(options)')
@@ -88,6 +107,12 @@ export class ILendingProtocol {
88
107
  *
89
108
  * @param {SupplyOptions} options - The supply's options.
90
109
  * @returns {Promise<Omit<SupplyResult, 'hash'>>} The supply's costs.
110
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a supply.
111
+ * @throws {ValueError} If the supply options are not valid.
112
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
113
+ * @throws {ProviderRequiredError} If the method requires a provider.
114
+ * @throws {ProviderError} If the provider fails to estimate the costs of the supply.
115
+ * @throws {SupplyError} If the supply fails with an error.
91
116
  */
92
117
  async quoteSupply (options) {
93
118
  throw new NotImplementedError('quoteSupply(options)')
@@ -98,6 +123,13 @@ export class ILendingProtocol {
98
123
  *
99
124
  * @param {WithdrawOptions} options - The withdraw's options.
100
125
  * @returns {Promise<WithdrawResult>} The withdraw's result.
126
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
127
+ * @throws {ValueError} If the withdraw options are not valid.
128
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
129
+ * @throws {ProviderRequiredError} If the method requires a provider.
130
+ * @throws {ProviderError} If the provider fails to perform the withdraw.
131
+ * @throws {WithdrawError} If the withdraw fails with an error.
132
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the withdraw max. fee option.
101
133
  */
102
134
  async withdraw (options) {
103
135
  throw new NotImplementedError('withdraw(options)')
@@ -108,6 +140,12 @@ export class ILendingProtocol {
108
140
  *
109
141
  * @param {WithdrawOptions} options - The withdraw's options.
110
142
  * @returns {Promise<Omit<WithdrawResult, 'hash'>>} The withdraw's costs.
143
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a supply.
144
+ * @throws {ValueError} If the withdraw options are not valid.
145
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
146
+ * @throws {ProviderRequiredError} If the method requires a provider.
147
+ * @throws {ProviderError} If the provider fails to estimate the costs of the withdraw.
148
+ * @throws {WithdrawError} If the withdraw fails with an error.
111
149
  */
112
150
  async quoteWithdraw (options) {
113
151
  throw new NotImplementedError('quoteWithdraw(options)')
@@ -118,6 +156,13 @@ export class ILendingProtocol {
118
156
  *
119
157
  * @param {BorrowOptions} options - The borrow's options.
120
158
  * @returns {Promise<BorrowResult>} The borrow's result.
159
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
160
+ * @throws {ValueError} If the borrow options are not valid.
161
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
162
+ * @throws {ProviderRequiredError} If the method requires a provider.
163
+ * @throws {ProviderError} If the provider fails to perform the borrow.
164
+ * @throws {BorrowError} If the borrow fails with an error.
165
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the borrow max. fee option.
121
166
  */
122
167
  async borrow (options) {
123
168
  throw new NotImplementedError('borrow(options)')
@@ -128,6 +173,12 @@ export class ILendingProtocol {
128
173
  *
129
174
  * @param {BorrowOptions} options - The borrow's options.
130
175
  * @returns {Promise<Omit<BorrowResult, 'hash'>>} The borrow's costs.
176
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a borrow.
177
+ * @throws {ValueError} If the borrow options are not valid.
178
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
179
+ * @throws {ProviderRequiredError} If the method requires a provider.
180
+ * @throws {ProviderError} If the provider fails to estimate the costs of the borrow.
181
+ * @throws {BorrowError} If the borrow fails with an error.
131
182
  */
132
183
  async quoteBorrow (options) {
133
184
  throw new NotImplementedError('quoteBorrow(options)')
@@ -136,8 +187,15 @@ export class ILendingProtocol {
136
187
  /**
137
188
  * Repays a specific token amount.
138
189
  *
139
- * @param {RepayOptions} options - The borrow's options.
190
+ * @param {RepayOptions} options - The repay's options.
140
191
  * @returns {Promise<RepayResult>} The repay's result.
192
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
193
+ * @throws {ValueError} If the repay options are not valid.
194
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
195
+ * @throws {ProviderRequiredError} If the method requires a provider.
196
+ * @throws {ProviderError} If the provider fails to perform the repay.
197
+ * @throws {RepayError} If the repay fails with an error.
198
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the repay max. fee option.
141
199
  */
142
200
  async repay (options) {
143
201
  throw new NotImplementedError('repay(options)')
@@ -148,6 +206,12 @@ export class ILendingProtocol {
148
206
  *
149
207
  * @param {RepayOptions} options - The repay's options.
150
208
  * @returns {Promise<Omit<RepayResult, 'hash'>>} The repay's costs.
209
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a repay.
210
+ * @throws {ValueError} If the repay options are not valid.
211
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
212
+ * @throws {ProviderRequiredError} If the method requires a provider.
213
+ * @throws {ProviderError} If the provider fails to estimate the costs of the repay.
214
+ * @throws {RepayError} If the repay fails with an error.
151
215
  */
152
216
  async quoteRepay (options) {
153
217
  throw new NotImplementedError('quoteRepay(options)')
@@ -188,6 +252,13 @@ export default class LendingProtocol {
188
252
  * @abstract
189
253
  * @param {SupplyOptions} options - The supply's options.
190
254
  * @returns {Promise<SupplyResult>} The supply's result.
255
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
256
+ * @throws {ValueError} If the supply options are not valid.
257
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
258
+ * @throws {ProviderRequiredError} If the method requires a provider.
259
+ * @throws {ProviderError} If the provider fails to perform the supply.
260
+ * @throws {SupplyError} If the supply fails with an error.
261
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the supply max. fee option.
191
262
  */
192
263
  async supply (options) {
193
264
  throw new NotImplementedError('supply(options)')
@@ -199,6 +270,11 @@ export default class LendingProtocol {
199
270
  * @abstract
200
271
  * @param {SupplyOptions} options - The supply's options.
201
272
  * @returns {Promise<Omit<SupplyResult, 'hash'>>} The supply's costs.
273
+ * @throws {ValueError} If the supply options are not valid.
274
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
275
+ * @throws {ProviderRequiredError} If the method requires a provider.
276
+ * @throws {ProviderError} If the provider fails to estimate the costs of the supply.
277
+ * @throws {SupplyError} If the supply fails with an error.
202
278
  */
203
279
  async quoteSupply (options) {
204
280
  throw new NotImplementedError('quoteSupply(options)')
@@ -210,6 +286,13 @@ export default class LendingProtocol {
210
286
  * @abstract
211
287
  * @param {WithdrawOptions} options - The withdraw's options.
212
288
  * @returns {Promise<WithdrawResult>} The withdraw's result.
289
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
290
+ * @throws {ValueError} If the withdraw options are not valid.
291
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
292
+ * @throws {ProviderRequiredError} If the method requires a provider.
293
+ * @throws {ProviderError} If the provider fails to perform the withdraw.
294
+ * @throws {WithdrawError} If the withdraw fails with an error.
295
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the withdraw max. fee option.
213
296
  */
214
297
  async withdraw (options) {
215
298
  throw new NotImplementedError('withdraw(options)')
@@ -221,6 +304,11 @@ export default class LendingProtocol {
221
304
  * @abstract
222
305
  * @param {WithdrawOptions} options - The withdraw's options.
223
306
  * @returns {Promise<Omit<WithdrawResult, 'hash'>>} The withdraw's costs.
307
+ * @throws {ValueError} If the withdraw options are not valid.
308
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
309
+ * @throws {ProviderRequiredError} If the method requires a provider.
310
+ * @throws {ProviderError} If the provider fails to estimate the costs of the withdraw.
311
+ * @throws {WithdrawError} If the withdraw fails with an error.
224
312
  */
225
313
  async quoteWithdraw (options) {
226
314
  throw new NotImplementedError('quoteWithdraw(options)')
@@ -232,6 +320,13 @@ export default class LendingProtocol {
232
320
  * @abstract
233
321
  * @param {BorrowOptions} options - The borrow's options.
234
322
  * @returns {Promise<BorrowResult>} The borrow's result.
323
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
324
+ * @throws {ValueError} If the borrow options are not valid.
325
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
326
+ * @throws {ProviderRequiredError} If the method requires a provider.
327
+ * @throws {ProviderError} If the provider fails to perform the borrow.
328
+ * @throws {BorrowError} If the borrow fails with an error.
329
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the borrow max. fee option.
235
330
  */
236
331
  async borrow (options) {
237
332
  throw new NotImplementedError('borrow(options)')
@@ -243,6 +338,11 @@ export default class LendingProtocol {
243
338
  * @abstract
244
339
  * @param {BorrowOptions} options - The borrow's options.
245
340
  * @returns {Promise<Omit<BorrowResult, 'hash'>>} The borrow's costs.
341
+ * @throws {ValueError} If the borrow options are not valid.
342
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
343
+ * @throws {ProviderRequiredError} If the method requires a provider.
344
+ * @throws {ProviderError} If the provider fails to estimate the costs of the borrow.
345
+ * @throws {BorrowError} If the borrow fails with an error.
246
346
  */
247
347
  async quoteBorrow (options) {
248
348
  throw new NotImplementedError('quoteBorrow(options)')
@@ -254,6 +354,13 @@ export default class LendingProtocol {
254
354
  * @abstract
255
355
  * @param {RepayOptions} options - The borrow's options.
256
356
  * @returns {Promise<RepayResult>} The repay's result.
357
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
358
+ * @throws {ValueError} If the repay options are not valid.
359
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
360
+ * @throws {ProviderRequiredError} If the method requires a provider.
361
+ * @throws {ProviderError} If the provider fails to perform the repay.
362
+ * @throws {RepayError} If the repay fails with an error.
363
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the repay max. fee option.
257
364
  */
258
365
  async repay (options) {
259
366
  throw new NotImplementedError('repay(options)')
@@ -265,6 +372,11 @@ export default class LendingProtocol {
265
372
  * @abstract
266
373
  * @param {RepayOptions} options - The repay's options.
267
374
  * @returns {Promise<Omit<RepayResult, 'hash'>>} The repay's costs.
375
+ * @throws {ValueError} If the repay options are not valid.
376
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
377
+ * @throws {ProviderRequiredError} If the method requires a provider.
378
+ * @throws {ProviderError} If the provider fails to estimate the costs of the repay.
379
+ * @throws {RepayError} If the repay fails with an error.
268
380
  */
269
381
  async quoteRepay (options) {
270
382
  throw new NotImplementedError('quoteRepay(options)')