@tetherto/wdk-wallet 1.0.0-beta.2 → 1.0.0-beta.20
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/bare.js +3 -3
- package/index.js +12 -2
- package/package.json +16 -3
- 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 +54 -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 +49 -2
- package/src/wallet-manager.js +153 -24
- package/types/index.d.ts +12 -4
- 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 +28 -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 +44 -4
- package/types/src/wallet-manager.d.ts +102 -15
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/** @interface */
|
|
2
|
+
export interface IFiatProtocol {
|
|
3
|
+
/**
|
|
4
|
+
* Gets a quote for a crypto asset purchase.
|
|
5
|
+
*
|
|
6
|
+
* @param {Omit<BuyOptions, 'recipient'>} options - The options for the buy operation.
|
|
7
|
+
* @returns {Promise<FiatQuote>} A quote for the transaction.
|
|
8
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a purchase.
|
|
9
|
+
* @throws {ValueError} If the buy options are not valid.
|
|
10
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
11
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the purchase.
|
|
12
|
+
* @throws {BuyError} If the purchase fails with an error.
|
|
13
|
+
*/
|
|
14
|
+
quoteBuy(options: Omit<BuyOptions, "recipient">): Promise<FiatQuote>;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a widget URL for a user to purchase a crypto asset with fiat currency.
|
|
17
|
+
*
|
|
18
|
+
* @param {BuyOptions} options - The options for the buy operation.
|
|
19
|
+
* @returns {Promise<BuyResult>} The operation's result.
|
|
20
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a purchase.
|
|
21
|
+
* @throws {ValueError} If the buy options are not valid.
|
|
22
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
23
|
+
* @throws {ProviderError} If the provider fails to perform the purchase.
|
|
24
|
+
* @throws {BuyError} If the purchase fails with an error.
|
|
25
|
+
* @throws {MaximumFeeExceededError} If the the costs of the purchase exceeds the buy max. fee option.
|
|
26
|
+
*/
|
|
27
|
+
buy(options: BuyOptions): Promise<BuyResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets a quote for a crypto asset sale.
|
|
30
|
+
*
|
|
31
|
+
* @param {Omit<SellOptions, 'refundAddress'>} options - The options for the sell operation.
|
|
32
|
+
* @returns {Promise<FiatQuote>} A quote for the transaction.
|
|
33
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a sale.
|
|
34
|
+
* @throws {ValueError} If the sell options are not valid.
|
|
35
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
36
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the sale.
|
|
37
|
+
* @throws {SellError} If the sale fails with an error.
|
|
38
|
+
*/
|
|
39
|
+
quoteSell(options: Omit<SellOptions, "refundAddress">): Promise<FiatQuote>;
|
|
40
|
+
/**
|
|
41
|
+
* Generates a widget URL for a user to sell a crypto asset for fiat currency.
|
|
42
|
+
*
|
|
43
|
+
* @param {SellOptions} options - The options for the sell operation.
|
|
44
|
+
* @returns {Promise<SellResult>} The operation's result.
|
|
45
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a sale.
|
|
46
|
+
* @throws {ValueError} If the buy options are not valid.
|
|
47
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
48
|
+
* @throws {ProviderError} If the provider fails to perform the sale.
|
|
49
|
+
* @throws {SellError} If the sale fails with an error.
|
|
50
|
+
* @throws {MaximumFeeExceededError} If the the costs of the sale exceeds the sell max. fee option.
|
|
51
|
+
*/
|
|
52
|
+
sell(options: SellOptions): Promise<SellResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves the details of a specific transaction from the provider.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} txId - The unique identifier of the transaction.
|
|
57
|
+
* @returns {Promise<FiatTransactionDetail>} The transaction details.
|
|
58
|
+
* @throws {ValueError} If the transaction's id is not valid.
|
|
59
|
+
* @throws {NoSuchElementError} If no transaction exists for the given id.
|
|
60
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
61
|
+
* @throws {ProviderError} If the provider fails to fetch the transaction's details.
|
|
62
|
+
*/
|
|
63
|
+
getTransactionDetail(txId: string): Promise<FiatTransactionDetail>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves a list of supported crypto assets from the provider.
|
|
66
|
+
*
|
|
67
|
+
* @returns {Promise<SupportedCryptoAsset[]>} An array of supported crypto assets.
|
|
68
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
69
|
+
* @throws {ProviderError} If the provider fails to fetch the available crypto assets.
|
|
70
|
+
*/
|
|
71
|
+
getSupportedCryptoAssets(): Promise<SupportedCryptoAsset[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves a list of supported fiat currencies from the provider.
|
|
74
|
+
*
|
|
75
|
+
* @returns {Promise<SupportedFiatCurrency[]>} An array of supported fiat currencies.
|
|
76
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
77
|
+
* @throws {ProviderError} If the provider fails to fetch the available fiat currencies.
|
|
78
|
+
*/
|
|
79
|
+
getSupportedFiatCurrencies(): Promise<SupportedFiatCurrency[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves a list of supported countries from the provider.
|
|
82
|
+
*
|
|
83
|
+
* @returns {Promise<SupportedCountry[]>} An array of supported countries.
|
|
84
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
85
|
+
* @throws {ProviderError} If the provider fails to fetch the available countries.
|
|
86
|
+
*/
|
|
87
|
+
getSupportedCountries(): Promise<SupportedCountry[]>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @abstract
|
|
91
|
+
* @implements {IFiatProtocol}
|
|
92
|
+
*/
|
|
93
|
+
export default abstract class FiatProtocol implements IFiatProtocol {
|
|
94
|
+
/**
|
|
95
|
+
* Creates a new interface to the protocol without binding it to a wallet account.
|
|
96
|
+
*
|
|
97
|
+
* @overload
|
|
98
|
+
* @param {undefined} [account] - The wallet account to use to interact with the protocol.
|
|
99
|
+
*/
|
|
100
|
+
constructor(account?: undefined);
|
|
101
|
+
/**
|
|
102
|
+
* Creates a new read-only interface to the protocol.
|
|
103
|
+
*
|
|
104
|
+
* @overload
|
|
105
|
+
* @param {IWalletAccountReadOnly} account - The wallet account to use to interact with the protocol.
|
|
106
|
+
*/
|
|
107
|
+
constructor(account: IWalletAccountReadOnly);
|
|
108
|
+
/**
|
|
109
|
+
* Creates a new interface to the protocol.
|
|
110
|
+
*
|
|
111
|
+
* @overload
|
|
112
|
+
* @param {IWalletAccount} account - The wallet account to use to interact with the protocol.
|
|
113
|
+
*/
|
|
114
|
+
constructor(account: IWalletAccount);
|
|
115
|
+
/**
|
|
116
|
+
* The wallet account to use to interact with the protocol.
|
|
117
|
+
*
|
|
118
|
+
* @protected
|
|
119
|
+
* @type {IWalletAccountReadOnly | IWalletAccount | undefined}
|
|
120
|
+
*/
|
|
121
|
+
protected _account: IWalletAccountReadOnly | IWalletAccount | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Gets a quote for a crypto asset purchase.
|
|
124
|
+
*
|
|
125
|
+
* @abstract
|
|
126
|
+
* @param {Omit<BuyOptions, 'recipient'>} options - The options for the buy operation.
|
|
127
|
+
* @returns {Promise<FiatQuote>} A quote for the transaction.
|
|
128
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a purchase.
|
|
129
|
+
* @throws {ValueError} If the buy options are not valid.
|
|
130
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
131
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the purchase.
|
|
132
|
+
* @throws {BuyError} If the purchase fails with an error.
|
|
133
|
+
*/
|
|
134
|
+
abstract quoteBuy(options: Omit<BuyOptions, "recipient">): Promise<FiatQuote>;
|
|
135
|
+
/**
|
|
136
|
+
* Generates a URL for a user to purchase a crypto asset with fiat currency.
|
|
137
|
+
*
|
|
138
|
+
* @abstract
|
|
139
|
+
* @param {BuyOptions} options - The options for the buy operation.
|
|
140
|
+
* @returns {Promise<BuyResult>} The URL for the user to complete the purchase.
|
|
141
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a purchase.
|
|
142
|
+
* @throws {ValueError} If the buy options are not valid.
|
|
143
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
144
|
+
* @throws {ProviderError} If the provider fails to perform the purchase.
|
|
145
|
+
* @throws {BuyError} If the purchase fails with an error.
|
|
146
|
+
* @throws {MaximumFeeExceededError} If the the costs of the purchase exceeds the buy max. fee option.
|
|
147
|
+
*/
|
|
148
|
+
abstract buy(options: BuyOptions): Promise<BuyResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Gets a quote for a crypto asset sale.
|
|
151
|
+
*
|
|
152
|
+
* @abstract
|
|
153
|
+
* @param {Omit<SellOptions, 'refundAddress'>} options - The options for the sell operation.
|
|
154
|
+
* @returns {Promise<FiatQuote>} A quote for the transaction.
|
|
155
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a sale.
|
|
156
|
+
* @throws {ValueError} If the sell options are not valid.
|
|
157
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
158
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the sale.
|
|
159
|
+
* @throws {SellError} If the sale fails with an error.
|
|
160
|
+
*/
|
|
161
|
+
abstract quoteSell(options: Omit<SellOptions, "refundAddress">): Promise<FiatQuote>;
|
|
162
|
+
/**
|
|
163
|
+
* Generates a URL for a user to sell a crypto asset for fiat currency.
|
|
164
|
+
*
|
|
165
|
+
* @abstract
|
|
166
|
+
* @param {SellOptions} options - The options for the sell operation.
|
|
167
|
+
* @returns {Promise<SellResult>} The URL for the user to complete the sale.
|
|
168
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a sale.
|
|
169
|
+
* @throws {ValueError} If the buy options are not valid.
|
|
170
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
171
|
+
* @throws {ProviderError} If the provider fails to perform the sale.
|
|
172
|
+
* @throws {SellError} If the sale fails with an error.
|
|
173
|
+
* @throws {MaximumFeeExceededError} If the the costs of the sale exceeds the sell max. fee option.
|
|
174
|
+
*/
|
|
175
|
+
abstract sell(options: SellOptions): Promise<SellResult>;
|
|
176
|
+
/**
|
|
177
|
+
* Retrieves the details of a specific transaction from the provider.
|
|
178
|
+
*
|
|
179
|
+
* @abstract
|
|
180
|
+
* @param {string} txId - The unique identifier of the transaction.
|
|
181
|
+
* @returns {Promise<FiatTransactionDetail>} The transaction details.
|
|
182
|
+
* @throws {ValueError} If the transaction's id is not valid.
|
|
183
|
+
* @throws {NoSuchElementError} If no transaction exists for the given id.
|
|
184
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
185
|
+
* @throws {ProviderError} If the provider fails to fetch the transaction's details.
|
|
186
|
+
*/
|
|
187
|
+
abstract getTransactionDetail(txId: string): Promise<FiatTransactionDetail>;
|
|
188
|
+
/**
|
|
189
|
+
* Retrieves a list of supported crypto assets from the provider.
|
|
190
|
+
*
|
|
191
|
+
* @abstract
|
|
192
|
+
* @returns {Promise<SupportedCryptoAsset[]>} An array of supported crypto assets.
|
|
193
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
194
|
+
* @throws {ProviderError} If the provider fails to fetch the available crypto assets.
|
|
195
|
+
*/
|
|
196
|
+
abstract getSupportedCryptoAssets(): Promise<SupportedCryptoAsset[]>;
|
|
197
|
+
/**
|
|
198
|
+
* Retrieves a list of supported fiat currencies from the provider.
|
|
199
|
+
*
|
|
200
|
+
* @abstract
|
|
201
|
+
* @returns {Promise<SupportedFiatCurrency[]>} An array of supported fiat currencies.
|
|
202
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
203
|
+
* @throws {ProviderError} If the provider fails to fetch the available fiat currencies.
|
|
204
|
+
*/
|
|
205
|
+
abstract getSupportedFiatCurrencies(): Promise<SupportedFiatCurrency[]>;
|
|
206
|
+
/**
|
|
207
|
+
* Retrieves a list of supported countries or regions from the provider.
|
|
208
|
+
*
|
|
209
|
+
* @abstract
|
|
210
|
+
* @returns {Promise<SupportedCountry[]>} An array of supported countries.
|
|
211
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
212
|
+
* @throws {ProviderError} If the provider fails to fetch the available countries.
|
|
213
|
+
*/
|
|
214
|
+
abstract getSupportedCountries(): Promise<SupportedCountry[]>;
|
|
215
|
+
}
|
|
216
|
+
export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
|
|
217
|
+
export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
|
|
218
|
+
export type AccountRequiredError = import("./errors.js").AccountRequiredError;
|
|
219
|
+
export type BuyError = import("./errors.js").BuyError;
|
|
220
|
+
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
221
|
+
export type NoSuchElementError = import("./errors.js").NoSuchElementError;
|
|
222
|
+
export type ReadOnlyAccountRequiredError = import("./errors.js").ReadOnlyAccountRequiredError;
|
|
223
|
+
export type ProviderError = import("./errors.js").ProviderError;
|
|
224
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
225
|
+
export type SellError = import("./errors.js").SellError;
|
|
226
|
+
export type ValueError = import("./errors.js").ValueError;
|
|
227
|
+
/**
|
|
228
|
+
* Standardized status for an on/off-ramp transaction.
|
|
229
|
+
*/
|
|
230
|
+
export type FiatTransactionStatus = "in_progress" | "failed" | "completed";
|
|
231
|
+
/**
|
|
232
|
+
* A protocol-agnostic, standardized object representing the details of an on/off-ramp transaction.
|
|
233
|
+
*/
|
|
234
|
+
export type FiatTransactionDetail = {
|
|
235
|
+
/**
|
|
236
|
+
* - The current status of the transaction.
|
|
237
|
+
*/
|
|
238
|
+
status: FiatTransactionStatus;
|
|
239
|
+
/**
|
|
240
|
+
* - The provider-specific code of the crypto asset (e.g., 'btc').
|
|
241
|
+
*/
|
|
242
|
+
cryptoAsset: string;
|
|
243
|
+
/**
|
|
244
|
+
* - The currency's ISO 4217 code (e.g., 'USD').
|
|
245
|
+
*/
|
|
246
|
+
fiatCurrency: string;
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* A protocol-agnostic, standardized object representing a supported crypto asset.
|
|
250
|
+
*/
|
|
251
|
+
export type SupportedCryptoAsset = {
|
|
252
|
+
/**
|
|
253
|
+
* - Provider-specific asset code for the crypto asset.
|
|
254
|
+
*/
|
|
255
|
+
code: string;
|
|
256
|
+
/**
|
|
257
|
+
* - The network code for the asset, if applicable (e.g., 'ethereum', 'tron').
|
|
258
|
+
*/
|
|
259
|
+
networkCode: string;
|
|
260
|
+
/**
|
|
261
|
+
* - The on-chain number of decimal places for the asset's base unit (e.g., 18 for ETH).
|
|
262
|
+
*/
|
|
263
|
+
decimals: number;
|
|
264
|
+
/**
|
|
265
|
+
* - The asset's full name (e.g., 'Bitcoin').
|
|
266
|
+
*/
|
|
267
|
+
name?: string;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* A protocol-agnostic, standardized object representing a supported fiat currency.
|
|
271
|
+
*/
|
|
272
|
+
export type SupportedFiatCurrency = {
|
|
273
|
+
/**
|
|
274
|
+
* - The currency's ISO 4217 code (e.g., 'USD').
|
|
275
|
+
*/
|
|
276
|
+
code: string;
|
|
277
|
+
/**
|
|
278
|
+
* - The number of decimal places for the currency's smallest unit (e.g., 2 for USD, 0 for JPY).
|
|
279
|
+
*/
|
|
280
|
+
decimals: number;
|
|
281
|
+
/**
|
|
282
|
+
* - The currency's full name (e.g., 'United States Dollar').
|
|
283
|
+
*/
|
|
284
|
+
name?: string;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* A protocol-agnostic, standardized object representing a supported country.
|
|
288
|
+
*/
|
|
289
|
+
export type SupportedCountry = {
|
|
290
|
+
/**
|
|
291
|
+
* - The country's ISO 3166-1 alpha-2 or alpha-3 code.
|
|
292
|
+
*/
|
|
293
|
+
code: string;
|
|
294
|
+
/**
|
|
295
|
+
* - Whether buying is supported in this country.
|
|
296
|
+
*/
|
|
297
|
+
isBuyAllowed: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* - Whether selling is supported in this country.
|
|
300
|
+
*/
|
|
301
|
+
isSellAllowed: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* - The country's common name.
|
|
304
|
+
*/
|
|
305
|
+
name?: string;
|
|
306
|
+
};
|
|
307
|
+
export type BuyOptions = BuyCommonOptions & (BuyExactCryptoAmountOptions | BuyWithFiatAmountOptions);
|
|
308
|
+
export type BuyCommonOptions = {
|
|
309
|
+
/**
|
|
310
|
+
* - The provider-specific code of the crypto asset to purchase.
|
|
311
|
+
*/
|
|
312
|
+
cryptoAsset: string;
|
|
313
|
+
/**
|
|
314
|
+
* - The currency's ISO 4217 code (e.g., 'USD').
|
|
315
|
+
*/
|
|
316
|
+
fiatCurrency: string;
|
|
317
|
+
/**
|
|
318
|
+
* - The wallet address to receive the purchased crypto asset. Defaults to the account's address.
|
|
319
|
+
*/
|
|
320
|
+
recipient?: string;
|
|
321
|
+
};
|
|
322
|
+
export type BuyExactCryptoAmountOptions = {
|
|
323
|
+
/**
|
|
324
|
+
* - The amount of crypto asset to buy, in its base unit (e.g., wei for ETH).
|
|
325
|
+
*/
|
|
326
|
+
cryptoAmount: number | bigint;
|
|
327
|
+
/**
|
|
328
|
+
* - The amount of fiat currency to spend, in its smallest unit (e.g., cents for USD).
|
|
329
|
+
*/
|
|
330
|
+
fiatAmount?: never;
|
|
331
|
+
};
|
|
332
|
+
export type BuyWithFiatAmountOptions = {
|
|
333
|
+
/**
|
|
334
|
+
* - The amount of fiat currency to spend, in its smallest unit (e.g., cents for USD).
|
|
335
|
+
*/
|
|
336
|
+
fiatAmount: number | bigint;
|
|
337
|
+
/**
|
|
338
|
+
* - The amount of crypto asset to buy, in its base unit (e.g., wei for ETH).
|
|
339
|
+
*/
|
|
340
|
+
cryptoAmount?: never;
|
|
341
|
+
};
|
|
342
|
+
export type BuyResult = {
|
|
343
|
+
/**
|
|
344
|
+
* - The URL for the user to complete the purchase.
|
|
345
|
+
*/
|
|
346
|
+
buyUrl: string;
|
|
347
|
+
};
|
|
348
|
+
export type SellOptions = SellCommonOptions & (SellExactCryptoAmountOptions | SellForFiatAmountOptions);
|
|
349
|
+
export type SellCommonOptions = {
|
|
350
|
+
/**
|
|
351
|
+
* - The provider-specific code of the crypto asset to sell.
|
|
352
|
+
*/
|
|
353
|
+
cryptoAsset: string;
|
|
354
|
+
/**
|
|
355
|
+
* - The currency's ISO 4217 code (e.g., 'USD').
|
|
356
|
+
*/
|
|
357
|
+
fiatCurrency: string;
|
|
358
|
+
/**
|
|
359
|
+
* - The wallet address to receive refunds in case of failure. Defaults to the account's address.
|
|
360
|
+
*/
|
|
361
|
+
refundAddress?: string;
|
|
362
|
+
};
|
|
363
|
+
export type SellExactCryptoAmountOptions = {
|
|
364
|
+
/**
|
|
365
|
+
* - The amount of crypto asset to sell, in its base unit (e.g., wei for ETH).
|
|
366
|
+
*/
|
|
367
|
+
cryptoAmount: number | bigint;
|
|
368
|
+
/**
|
|
369
|
+
* - The amount of fiat currency to receive, in its smallest unit (e.g., cents for USD).
|
|
370
|
+
*/
|
|
371
|
+
fiatAmount?: never;
|
|
372
|
+
};
|
|
373
|
+
export type SellForFiatAmountOptions = {
|
|
374
|
+
/**
|
|
375
|
+
* - The amount of fiat currency to receive, in its smallest unit (e.g., cents for USD).
|
|
376
|
+
*/
|
|
377
|
+
fiatAmount: number | bigint;
|
|
378
|
+
/**
|
|
379
|
+
* - The amount of crypto asset to sell, in its base unit (e.g., wei for ETH).
|
|
380
|
+
*/
|
|
381
|
+
cryptoAmount?: never;
|
|
382
|
+
};
|
|
383
|
+
export type SellResult = {
|
|
384
|
+
/**
|
|
385
|
+
* - The URL for the user to complete the sale.
|
|
386
|
+
*/
|
|
387
|
+
sellUrl: string;
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* A protocol-agnostic, standardized object representing a quote for an on/off-ramp transaction.
|
|
391
|
+
*/
|
|
392
|
+
export type FiatQuote = {
|
|
393
|
+
/**
|
|
394
|
+
* - The amount of the crypto asset, in its base unit (e.g., wei).
|
|
395
|
+
*/
|
|
396
|
+
cryptoAmount: bigint;
|
|
397
|
+
/**
|
|
398
|
+
* - The amount of the fiat currency, in its smallest unit (e.g., cents).
|
|
399
|
+
*/
|
|
400
|
+
fiatAmount: bigint;
|
|
401
|
+
/**
|
|
402
|
+
* - The fee charged for the transaction, denominated in the smallest unit of the fiat currency.
|
|
403
|
+
*/
|
|
404
|
+
fee: bigint;
|
|
405
|
+
/**
|
|
406
|
+
* - 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).
|
|
407
|
+
*/
|
|
408
|
+
rate: string;
|
|
409
|
+
};
|
|
@@ -12,6 +12,70 @@ export type BorrowOptions = import("./lending-protocol.js").BorrowOptions;
|
|
|
12
12
|
export type BorrowResult = import("./lending-protocol.js").BorrowResult;
|
|
13
13
|
export type RepayOptions = import("./lending-protocol.js").RepayOptions;
|
|
14
14
|
export type RepayResult = import("./lending-protocol.js").RepayResult;
|
|
15
|
+
export type BuyOptions = import("./fiat-protocol.js").BuyOptions;
|
|
16
|
+
export type BuyCommonOptions = import("./fiat-protocol.js").BuyCommonOptions;
|
|
17
|
+
export type BuyExactCryptoAmountOptions = import("./fiat-protocol.js").BuyExactCryptoAmountOptions;
|
|
18
|
+
export type BuyWithFiatAmountOptions = import("./fiat-protocol.js").BuyWithFiatAmountOptions;
|
|
19
|
+
export type BuyResult = import("./fiat-protocol.js").BuyResult;
|
|
20
|
+
export type SellOptions = import("./fiat-protocol.js").SellOptions;
|
|
21
|
+
export type SellCommonOptions = import("./fiat-protocol.js").SellCommonOptions;
|
|
22
|
+
export type SellExactCryptoAmountOptions = import("./fiat-protocol.js").SellExactCryptoAmountOptions;
|
|
23
|
+
export type SellForFiatAmountOptions = import("./fiat-protocol.js").SellForFiatAmountOptions;
|
|
24
|
+
export type SellResult = import("./fiat-protocol.js").SellResult;
|
|
25
|
+
export type FiatQuote = import("./fiat-protocol.js").FiatQuote;
|
|
26
|
+
export type FiatTransactionStatus = import("./fiat-protocol.js").FiatTransactionStatus;
|
|
27
|
+
export type FiatTransactionDetail = import("./fiat-protocol.js").FiatTransactionDetail;
|
|
28
|
+
export type SupportedCryptoAsset = import("./fiat-protocol.js").SupportedCryptoAsset;
|
|
29
|
+
export type SupportedFiatCurrency = import("./fiat-protocol.js").SupportedFiatCurrency;
|
|
30
|
+
export type SupportedCountry = import("./fiat-protocol.js").SupportedCountry;
|
|
31
|
+
export type SwidgeStatus = import("./swidge-protocol.js").SwidgeStatus;
|
|
32
|
+
export type SwidgeFeeType = import("./swidge-protocol.js").SwidgeFeeType;
|
|
33
|
+
export type SwidgeProtocolConfig = import("./swidge-protocol.js").SwidgeProtocolConfig;
|
|
34
|
+
export type SwidgeOptions = import("./swidge-protocol.js").SwidgeOptions;
|
|
35
|
+
export type SwidgeCommonOptions = import("./swidge-protocol.js").SwidgeCommonOptions;
|
|
36
|
+
export type SwidgeExactInOptions = import("./swidge-protocol.js").SwidgeExactInOptions;
|
|
37
|
+
export type SwidgeExactOutOptions = import("./swidge-protocol.js").SwidgeExactOutOptions;
|
|
38
|
+
export type SwidgeFee = import("./swidge-protocol.js").SwidgeFee;
|
|
39
|
+
export type SwidgeTransaction = import("./swidge-protocol.js").SwidgeTransaction;
|
|
40
|
+
export type SwidgeQuote = import("./swidge-protocol.js").SwidgeQuote;
|
|
41
|
+
export type SwidgeResult = import("./swidge-protocol.js").SwidgeResult;
|
|
42
|
+
export type SwidgeStatusOptions = import("./swidge-protocol.js").SwidgeStatusOptions;
|
|
43
|
+
export type SwidgeStatusResult = import("./swidge-protocol.js").SwidgeStatusResult;
|
|
44
|
+
export type SwidgeSupportedChain = import("./swidge-protocol.js").SwidgeSupportedChain;
|
|
45
|
+
export type SwidgeSupportedToken = import("./swidge-protocol.js").SwidgeSupportedToken;
|
|
46
|
+
export type SwidgeSupportedTokensOptions = import("./swidge-protocol.js").SwidgeSupportedTokensOptions;
|
|
47
|
+
export type Blockchain = import("./sda-protocol.js").Blockchain;
|
|
48
|
+
export type SdaToken = import("./sda-protocol.js").SdaToken;
|
|
49
|
+
export type SdaDepositAddressLimits = import("./sda-protocol.js").SdaDepositAddressLimits;
|
|
50
|
+
export type SdaRoutesOptions = import("./sda-protocol.js").SdaRoutesOptions;
|
|
51
|
+
export type SdaRoute = import("./sda-protocol.js").SdaRoute;
|
|
52
|
+
export type SdaDepositOptions = import("./sda-protocol.js").SdaDepositOptions;
|
|
53
|
+
export type SdaFeeType = import("./sda-protocol.js").SdaFeeType;
|
|
54
|
+
export type SdaFee = import("./sda-protocol.js").SdaFee;
|
|
55
|
+
export type SdaDepositQuote = import("./sda-protocol.js").SdaDepositQuote;
|
|
56
|
+
export type SdaCreateDepositAddressOptions = import("./sda-protocol.js").SdaCreateDepositAddressOptions;
|
|
57
|
+
export type SdaDepositAddress = import("./sda-protocol.js").SdaDepositAddress;
|
|
58
|
+
export type SdaTransferStatus = import("./sda-protocol.js").SdaTransferStatus;
|
|
59
|
+
export type SdaTransfer = import("./sda-protocol.js").SdaTransfer;
|
|
60
|
+
export type SdaTransfersOptions = import("./sda-protocol.js").SdaTransfersOptions;
|
|
61
|
+
export type SdaRecoverById = import("./sda-protocol.js").SdaRecoverById;
|
|
62
|
+
export type SdaRecoverByAddress = import("./sda-protocol.js").SdaRecoverByAddress;
|
|
63
|
+
export type SdaRecoveryOptions = import("./sda-protocol.js").SdaRecoveryOptions;
|
|
64
|
+
export type SdaRecoveryResult = import("./sda-protocol.js").SdaRecoveryResult;
|
|
65
|
+
export type SwapErrorOptions = import("./errors.js").SwapErrorOptions;
|
|
66
|
+
export type BridgeErrorOptions = import("./errors.js").BridgeErrorOptions;
|
|
67
|
+
export type SupplyErrorOptions = import("./errors.js").SupplyErrorOptions;
|
|
68
|
+
export type WithdrawErrorOptions = import("./errors.js").WithdrawErrorOptions;
|
|
69
|
+
export type BorrowErrorOptions = import("./errors.js").BorrowErrorOptions;
|
|
70
|
+
export type RepayErrorOptions = import("./errors.js").RepayErrorOptions;
|
|
71
|
+
export type BuyErrorOptions = import("./errors.js").BuyErrorOptions;
|
|
72
|
+
export type SellErrorOptions = import("./errors.js").SellErrorOptions;
|
|
73
|
+
export type SwidgeErrorOptions = import("./errors.js").SwidgeErrorOptions;
|
|
74
|
+
export type SdaErrorOptions = import("./errors.js").SdaErrorOptions;
|
|
15
75
|
export { default as SwapProtocol, ISwapProtocol } from "./swap-protocol.js";
|
|
16
76
|
export { default as BridgeProtocol, IBridgeProtocol } from "./bridge-protocol.js";
|
|
17
77
|
export { default as LendingProtocol, ILendingProtocol } from "./lending-protocol.js";
|
|
78
|
+
export { default as FiatProtocol, IFiatProtocol } from "./fiat-protocol.js";
|
|
79
|
+
export { default as SwidgeProtocol, ISwidgeProtocol } from "./swidge-protocol.js";
|
|
80
|
+
export { default as SdaProtocol, ISdaProtocol } from "./sda-protocol.js";
|
|
81
|
+
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";
|