@tetherto/wdk-wallet 1.0.0-beta.13 → 1.0.0-beta.15
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/index.js +7 -1
- package/package.json +1 -1
- package/src/errors.js +41 -0
- package/src/protocols/index.js +21 -0
- package/src/protocols/sda-protocol.js +556 -0
- package/src/protocols/swap-protocol.js +1 -0
- package/src/protocols/swidge-protocol.js +5 -2
- package/types/index.d.ts +4 -4
- package/types/src/errors.d.ts +26 -0
- package/types/src/protocols/index.d.ts +19 -0
- package/types/src/protocols/sda-protocol.d.ts +640 -0
- package/types/src/protocols/swap-protocol.d.ts +4 -0
- package/types/src/protocols/swidge-protocol.d.ts +15 -0
|
@@ -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 }
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export { default } from "./src/wallet-manager.js";
|
|
2
|
+
export { IWalletAccount } from "./src/wallet-account.js";
|
|
3
|
+
export { ISigner } from "./src/signer.js";
|
|
1
4
|
export type FeeRates = import("./src/wallet-manager.js").FeeRates;
|
|
2
5
|
export type WalletConfig = import("./src/wallet-manager.js").WalletConfig;
|
|
3
6
|
export type Transaction = import("./src/wallet-account-read-only.js").Transaction;
|
|
@@ -5,8 +8,5 @@ export type TransactionResult = import("./src/wallet-account-read-only.js").Tran
|
|
|
5
8
|
export type TransferOptions = import("./src/wallet-account-read-only.js").TransferOptions;
|
|
6
9
|
export type TransferResult = import("./src/wallet-account-read-only.js").TransferResult;
|
|
7
10
|
export type KeyPair = import("./src/wallet-account.js").KeyPair;
|
|
8
|
-
export { default } from "./src/wallet-manager.js";
|
|
9
11
|
export { default as WalletAccountReadOnly, IWalletAccountReadOnly } from "./src/wallet-account-read-only.js";
|
|
10
|
-
export {
|
|
11
|
-
export { NotImplementedError, SignerError } from "./src/errors.js";
|
|
12
|
-
export { ISigner } from "./src/signer.js";
|
|
12
|
+
export { NotImplementedError, SignerError, UnsupportedOperationError, ValueError, NoSuchElementError } from "./src/errors.js";
|
package/types/src/errors.d.ts
CHANGED
|
@@ -14,3 +14,29 @@ export class SignerError extends Error {
|
|
|
14
14
|
*/
|
|
15
15
|
constructor(message: string);
|
|
16
16
|
}
|
|
17
|
+
export class UnsupportedOperationError extends Error {
|
|
18
|
+
/**
|
|
19
|
+
* Create a new unsupported operation error. Thrown by an optional operation
|
|
20
|
+
* that the concrete implementation deliberately does not support.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} operation - The name of the operation that is not supported.
|
|
23
|
+
*/
|
|
24
|
+
constructor(operation: string);
|
|
25
|
+
}
|
|
26
|
+
export class ValueError extends Error {
|
|
27
|
+
/**
|
|
28
|
+
* Create a new value error. Thrown when an argument fails validation.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} message - The error's message.
|
|
31
|
+
*/
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
export class NoSuchElementError extends Error {
|
|
35
|
+
/**
|
|
36
|
+
* Create a new no such element error. Thrown when a lookup finds no element for
|
|
37
|
+
* the given identifier.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} message - The error's message.
|
|
40
|
+
*/
|
|
41
|
+
constructor(message: string);
|
|
42
|
+
}
|
|
@@ -44,8 +44,27 @@ export type SwidgeStatusResult = import("./swidge-protocol.js").SwidgeStatusResu
|
|
|
44
44
|
export type SwidgeSupportedChain = import("./swidge-protocol.js").SwidgeSupportedChain;
|
|
45
45
|
export type SwidgeSupportedToken = import("./swidge-protocol.js").SwidgeSupportedToken;
|
|
46
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;
|
|
47
65
|
export { default as SwapProtocol, ISwapProtocol } from "./swap-protocol.js";
|
|
48
66
|
export { default as BridgeProtocol, IBridgeProtocol } from "./bridge-protocol.js";
|
|
49
67
|
export { default as LendingProtocol, ILendingProtocol } from "./lending-protocol.js";
|
|
50
68
|
export { default as FiatProtocol, IFiatProtocol } from "./fiat-protocol.js";
|
|
51
69
|
export { default as SwidgeProtocol, ISwidgeProtocol } from "./swidge-protocol.js";
|
|
70
|
+
export { default as SdaProtocol, ISdaProtocol } from "./sda-protocol.js";
|