@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.
- package/AGENTS.md +49 -0
- package/README.md +2 -2
- package/bare.js +3 -3
- package/index.js +14 -2
- package/package.json +18 -4
- package/src/disposable.js +26 -0
- package/src/errors.js +318 -3
- package/src/multisig/errors.js +54 -0
- package/src/multisig/index.js +42 -0
- package/src/multisig/multisig-message-signing-read-only.js +63 -0
- package/src/multisig/multisig-message-signing.js +64 -0
- package/src/multisig/multisig-owner-management.js +94 -0
- package/src/multisig/wallet-account-multisig.js +144 -0
- package/src/multisig/wallet-account-read-only-multisig.js +98 -0
- package/src/protocols/bridge-protocol.js +35 -1
- package/src/protocols/errors.js +510 -0
- package/src/protocols/fiat-protocol.js +401 -0
- package/src/protocols/index.js +76 -0
- package/src/protocols/lending-protocol.js +114 -2
- package/src/protocols/sda-protocol.js +643 -0
- package/src/protocols/swap-protocol.js +36 -1
- package/src/protocols/swidge-protocol.js +516 -0
- package/src/signer.js +89 -0
- package/src/wallet-account-read-only-simple.js +162 -0
- package/src/wallet-account-read-only.js +186 -40
- package/src/wallet-account.js +59 -22
- package/src/wallet-manager.js +152 -25
- package/types/index.d.ts +13 -4
- package/types/src/disposable.d.ts +7 -0
- package/types/src/errors.d.ts +220 -2
- package/types/src/multisig/errors.d.ts +33 -0
- package/types/src/multisig/index.d.ts +15 -0
- package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
- package/types/src/multisig/multisig-message-signing.d.ts +40 -0
- package/types/src/multisig/multisig-owner-management.d.ts +65 -0
- package/types/src/multisig/wallet-account-multisig.d.ts +101 -0
- package/types/src/multisig/wallet-account-read-only-multisig.d.ts +83 -0
- package/types/src/protocols/bridge-protocol.d.ts +39 -3
- package/types/src/protocols/errors.d.ts +366 -0
- package/types/src/protocols/fiat-protocol.d.ts +409 -0
- package/types/src/protocols/index.d.ts +64 -0
- package/types/src/protocols/lending-protocol.d.ts +118 -4
- package/types/src/protocols/sda-protocol.d.ts +737 -0
- package/types/src/protocols/swap-protocol.d.ts +44 -4
- package/types/src/protocols/swidge-protocol.d.ts +483 -0
- package/types/src/signer.d.ts +53 -0
- package/types/src/wallet-account-read-only-simple.d.ts +144 -0
- package/types/src/wallet-account-read-only.d.ts +104 -27
- package/types/src/wallet-account.d.ts +55 -20
- package/types/src/wallet-manager.d.ts +109 -17
|
@@ -5,6 +5,13 @@ export interface ILendingProtocol {
|
|
|
5
5
|
*
|
|
6
6
|
* @param {SupplyOptions} options - The supply's options.
|
|
7
7
|
* @returns {Promise<SupplyResult>} The supply's result.
|
|
8
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
|
|
9
|
+
* @throws {ValueError} If the supply options are not valid.
|
|
10
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
11
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
12
|
+
* @throws {ProviderError} If the provider fails to perform the supply.
|
|
13
|
+
* @throws {SupplyError} If the supply fails with an error.
|
|
14
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the supply max. fee option.
|
|
8
15
|
*/
|
|
9
16
|
supply(options: SupplyOptions): Promise<SupplyResult>;
|
|
10
17
|
/**
|
|
@@ -12,6 +19,12 @@ export interface ILendingProtocol {
|
|
|
12
19
|
*
|
|
13
20
|
* @param {SupplyOptions} options - The supply's options.
|
|
14
21
|
* @returns {Promise<Omit<SupplyResult, 'hash'>>} The supply's costs.
|
|
22
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a supply.
|
|
23
|
+
* @throws {ValueError} If the supply options are not valid.
|
|
24
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
25
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
26
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the supply.
|
|
27
|
+
* @throws {SupplyError} If the supply fails with an error.
|
|
15
28
|
*/
|
|
16
29
|
quoteSupply(options: SupplyOptions): Promise<Omit<SupplyResult, "hash">>;
|
|
17
30
|
/**
|
|
@@ -19,6 +32,13 @@ export interface ILendingProtocol {
|
|
|
19
32
|
*
|
|
20
33
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
21
34
|
* @returns {Promise<WithdrawResult>} The withdraw's result.
|
|
35
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
|
|
36
|
+
* @throws {ValueError} If the withdraw options are not valid.
|
|
37
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
38
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
39
|
+
* @throws {ProviderError} If the provider fails to perform the withdraw.
|
|
40
|
+
* @throws {WithdrawError} If the withdraw fails with an error.
|
|
41
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the withdraw max. fee option.
|
|
22
42
|
*/
|
|
23
43
|
withdraw(options: WithdrawOptions): Promise<WithdrawResult>;
|
|
24
44
|
/**
|
|
@@ -26,6 +46,12 @@ export interface ILendingProtocol {
|
|
|
26
46
|
*
|
|
27
47
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
28
48
|
* @returns {Promise<Omit<WithdrawResult, 'hash'>>} The withdraw's costs.
|
|
49
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a supply.
|
|
50
|
+
* @throws {ValueError} If the withdraw options are not valid.
|
|
51
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
52
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
53
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the withdraw.
|
|
54
|
+
* @throws {WithdrawError} If the withdraw fails with an error.
|
|
29
55
|
*/
|
|
30
56
|
quoteWithdraw(options: WithdrawOptions): Promise<Omit<WithdrawResult, "hash">>;
|
|
31
57
|
/**
|
|
@@ -33,6 +59,13 @@ export interface ILendingProtocol {
|
|
|
33
59
|
*
|
|
34
60
|
* @param {BorrowOptions} options - The borrow's options.
|
|
35
61
|
* @returns {Promise<BorrowResult>} The borrow's result.
|
|
62
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
|
|
63
|
+
* @throws {ValueError} If the borrow options are not valid.
|
|
64
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
65
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
66
|
+
* @throws {ProviderError} If the provider fails to perform the borrow.
|
|
67
|
+
* @throws {BorrowError} If the borrow fails with an error.
|
|
68
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the borrow max. fee option.
|
|
36
69
|
*/
|
|
37
70
|
borrow(options: BorrowOptions): Promise<BorrowResult>;
|
|
38
71
|
/**
|
|
@@ -40,13 +73,26 @@ export interface ILendingProtocol {
|
|
|
40
73
|
*
|
|
41
74
|
* @param {BorrowOptions} options - The borrow's options.
|
|
42
75
|
* @returns {Promise<Omit<BorrowResult, 'hash'>>} The borrow's costs.
|
|
76
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a borrow.
|
|
77
|
+
* @throws {ValueError} If the borrow options are not valid.
|
|
78
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
79
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
80
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the borrow.
|
|
81
|
+
* @throws {BorrowError} If the borrow fails with an error.
|
|
43
82
|
*/
|
|
44
83
|
quoteBorrow(options: BorrowOptions): Promise<Omit<BorrowResult, "hash">>;
|
|
45
84
|
/**
|
|
46
85
|
* Repays a specific token amount.
|
|
47
86
|
*
|
|
48
|
-
* @param {RepayOptions} options - The
|
|
87
|
+
* @param {RepayOptions} options - The repay's options.
|
|
49
88
|
* @returns {Promise<RepayResult>} The repay's result.
|
|
89
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
|
|
90
|
+
* @throws {ValueError} If the repay options are not valid.
|
|
91
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
92
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
93
|
+
* @throws {ProviderError} If the provider fails to perform the repay.
|
|
94
|
+
* @throws {RepayError} If the repay fails with an error.
|
|
95
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the repay max. fee option.
|
|
50
96
|
*/
|
|
51
97
|
repay(options: RepayOptions): Promise<RepayResult>;
|
|
52
98
|
/**
|
|
@@ -54,10 +100,19 @@ export interface ILendingProtocol {
|
|
|
54
100
|
*
|
|
55
101
|
* @param {RepayOptions} options - The repay's options.
|
|
56
102
|
* @returns {Promise<Omit<RepayResult, 'hash'>>} The repay's costs.
|
|
103
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a repay.
|
|
104
|
+
* @throws {ValueError} If the repay options are not valid.
|
|
105
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
106
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
107
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the repay.
|
|
108
|
+
* @throws {RepayError} If the repay fails with an error.
|
|
57
109
|
*/
|
|
58
110
|
quoteRepay(options: RepayOptions): Promise<Omit<RepayResult, "hash">>;
|
|
59
111
|
}
|
|
60
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* @abstract
|
|
114
|
+
* @implements {ILendingProtocol}
|
|
115
|
+
*/
|
|
61
116
|
export default abstract class LendingProtocol implements ILendingProtocol {
|
|
62
117
|
/**
|
|
63
118
|
* Creates a new read-only lending protocol.
|
|
@@ -77,15 +132,22 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
77
132
|
* The wallet account to use to interact with the protocol.
|
|
78
133
|
*
|
|
79
134
|
* @protected
|
|
80
|
-
* @type {IWalletAccount}
|
|
135
|
+
* @type {IWalletAccountReadOnly | IWalletAccount}
|
|
81
136
|
*/
|
|
82
|
-
protected _account: IWalletAccount;
|
|
137
|
+
protected _account: IWalletAccountReadOnly | IWalletAccount;
|
|
83
138
|
/**
|
|
84
139
|
* Supplies a specific token amount to the lending pool.
|
|
85
140
|
*
|
|
86
141
|
* @abstract
|
|
87
142
|
* @param {SupplyOptions} options - The supply's options.
|
|
88
143
|
* @returns {Promise<SupplyResult>} The supply's result.
|
|
144
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
|
|
145
|
+
* @throws {ValueError} If the supply options are not valid.
|
|
146
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
147
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
148
|
+
* @throws {ProviderError} If the provider fails to perform the supply.
|
|
149
|
+
* @throws {SupplyError} If the supply fails with an error.
|
|
150
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the supply max. fee option.
|
|
89
151
|
*/
|
|
90
152
|
abstract supply(options: SupplyOptions): Promise<SupplyResult>;
|
|
91
153
|
/**
|
|
@@ -94,6 +156,11 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
94
156
|
* @abstract
|
|
95
157
|
* @param {SupplyOptions} options - The supply's options.
|
|
96
158
|
* @returns {Promise<Omit<SupplyResult, 'hash'>>} The supply's costs.
|
|
159
|
+
* @throws {ValueError} If the supply options are not valid.
|
|
160
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
161
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
162
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the supply.
|
|
163
|
+
* @throws {SupplyError} If the supply fails with an error.
|
|
97
164
|
*/
|
|
98
165
|
abstract quoteSupply(options: SupplyOptions): Promise<Omit<SupplyResult, "hash">>;
|
|
99
166
|
/**
|
|
@@ -102,6 +169,13 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
102
169
|
* @abstract
|
|
103
170
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
104
171
|
* @returns {Promise<WithdrawResult>} The withdraw's result.
|
|
172
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
|
|
173
|
+
* @throws {ValueError} If the withdraw options are not valid.
|
|
174
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
175
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
176
|
+
* @throws {ProviderError} If the provider fails to perform the withdraw.
|
|
177
|
+
* @throws {WithdrawError} If the withdraw fails with an error.
|
|
178
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the withdraw max. fee option.
|
|
105
179
|
*/
|
|
106
180
|
abstract withdraw(options: WithdrawOptions): Promise<WithdrawResult>;
|
|
107
181
|
/**
|
|
@@ -110,6 +184,11 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
110
184
|
* @abstract
|
|
111
185
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
112
186
|
* @returns {Promise<Omit<WithdrawResult, 'hash'>>} The withdraw's costs.
|
|
187
|
+
* @throws {ValueError} If the withdraw options are not valid.
|
|
188
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
189
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
190
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the withdraw.
|
|
191
|
+
* @throws {WithdrawError} If the withdraw fails with an error.
|
|
113
192
|
*/
|
|
114
193
|
abstract quoteWithdraw(options: WithdrawOptions): Promise<Omit<WithdrawResult, "hash">>;
|
|
115
194
|
/**
|
|
@@ -118,6 +197,13 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
118
197
|
* @abstract
|
|
119
198
|
* @param {BorrowOptions} options - The borrow's options.
|
|
120
199
|
* @returns {Promise<BorrowResult>} The borrow's result.
|
|
200
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
|
|
201
|
+
* @throws {ValueError} If the borrow options are not valid.
|
|
202
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
203
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
204
|
+
* @throws {ProviderError} If the provider fails to perform the borrow.
|
|
205
|
+
* @throws {BorrowError} If the borrow fails with an error.
|
|
206
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the borrow max. fee option.
|
|
121
207
|
*/
|
|
122
208
|
abstract borrow(options: BorrowOptions): Promise<BorrowResult>;
|
|
123
209
|
/**
|
|
@@ -126,6 +212,11 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
126
212
|
* @abstract
|
|
127
213
|
* @param {BorrowOptions} options - The borrow's options.
|
|
128
214
|
* @returns {Promise<Omit<BorrowResult, 'hash'>>} The borrow's costs.
|
|
215
|
+
* @throws {ValueError} If the borrow options are not valid.
|
|
216
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
217
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
218
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the borrow.
|
|
219
|
+
* @throws {BorrowError} If the borrow fails with an error.
|
|
129
220
|
*/
|
|
130
221
|
abstract quoteBorrow(options: BorrowOptions): Promise<Omit<BorrowResult, "hash">>;
|
|
131
222
|
/**
|
|
@@ -134,6 +225,13 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
134
225
|
* @abstract
|
|
135
226
|
* @param {RepayOptions} options - The borrow's options.
|
|
136
227
|
* @returns {Promise<RepayResult>} The repay's result.
|
|
228
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
|
|
229
|
+
* @throws {ValueError} If the repay options are not valid.
|
|
230
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
231
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
232
|
+
* @throws {ProviderError} If the provider fails to perform the repay.
|
|
233
|
+
* @throws {RepayError} If the repay fails with an error.
|
|
234
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the repay max. fee option.
|
|
137
235
|
*/
|
|
138
236
|
abstract repay(options: RepayOptions): Promise<RepayResult>;
|
|
139
237
|
/**
|
|
@@ -142,11 +240,27 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
142
240
|
* @abstract
|
|
143
241
|
* @param {RepayOptions} options - The repay's options.
|
|
144
242
|
* @returns {Promise<Omit<RepayResult, 'hash'>>} The repay's costs.
|
|
243
|
+
* @throws {ValueError} If the repay options are not valid.
|
|
244
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
245
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
246
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the repay.
|
|
247
|
+
* @throws {RepayError} If the repay fails with an error.
|
|
145
248
|
*/
|
|
146
249
|
abstract quoteRepay(options: RepayOptions): Promise<Omit<RepayResult, "hash">>;
|
|
147
250
|
}
|
|
148
251
|
export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
|
|
149
252
|
export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
|
|
253
|
+
export type AccountRequiredError = import("./errors.js").AccountRequiredError;
|
|
254
|
+
export type BorrowError = import("./errors.js").BorrowError;
|
|
255
|
+
export type InvalidTokenError = import("./errors.js").InvalidTokenError;
|
|
256
|
+
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
257
|
+
export type ReadOnlyAccountRequiredError = import("./errors.js").ReadOnlyAccountRequiredError;
|
|
258
|
+
export type ProviderError = import("./errors.js").ProviderError;
|
|
259
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
260
|
+
export type RepayError = import("./errors.js").RepayError;
|
|
261
|
+
export type SupplyError = import("./errors.js").SupplyError;
|
|
262
|
+
export type ValueError = import("./errors.js").ValueError;
|
|
263
|
+
export type WithdrawError = import("./errors.js").WithdrawError;
|
|
150
264
|
export type SupplyOptions = {
|
|
151
265
|
/**
|
|
152
266
|
* - The address of the token to supply.
|