@tetherto/wdk-wallet 1.0.0-beta.8 → 1.0.0-beta.9
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,12 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tetherto/wdk-wallet",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.9",
|
|
4
4
|
"description": "A simple package to manage BIP-32 wallets.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"wdk",
|
|
7
|
-
"wallet",
|
|
8
|
-
"bip-32"
|
|
9
|
-
],
|
|
5
|
+
"keywords": ["wdk", "wallet", "bip-32"],
|
|
10
6
|
"author": "Tether",
|
|
11
7
|
"license": "Apache-2.0",
|
|
12
8
|
"repository": {
|
package/src/protocols/index.js
CHANGED
|
@@ -51,6 +51,23 @@
|
|
|
51
51
|
/** @typedef {import('./fiat-protocol.js').SupportedFiatCurrency} SupportedFiatCurrency */
|
|
52
52
|
/** @typedef {import('./fiat-protocol.js').SupportedCountry} SupportedCountry */
|
|
53
53
|
|
|
54
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeStatus} SwidgeStatus */
|
|
55
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeFeeType} SwidgeFeeType */
|
|
56
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeProtocolConfig} SwidgeProtocolConfig */
|
|
57
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeOptions} SwidgeOptions */
|
|
58
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeCommonOptions} SwidgeCommonOptions */
|
|
59
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeExactInOptions} SwidgeExactInOptions */
|
|
60
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeExactOutOptions} SwidgeExactOutOptions */
|
|
61
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeFee} SwidgeFee */
|
|
62
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeTransaction} SwidgeTransaction */
|
|
63
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeQuote} SwidgeQuote */
|
|
64
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeResult} SwidgeResult */
|
|
65
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeStatusOptions} SwidgeStatusOptions */
|
|
66
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeStatusResult} SwidgeStatusResult */
|
|
67
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeSupportedChain} SwidgeSupportedChain */
|
|
68
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeSupportedToken} SwidgeSupportedToken */
|
|
69
|
+
/** @typedef {import('./swidge-protocol.js').SwidgeSupportedTokensOptions} SwidgeSupportedTokensOptions */
|
|
70
|
+
|
|
54
71
|
export { default as SwapProtocol, ISwapProtocol } from './swap-protocol.js'
|
|
55
72
|
|
|
56
73
|
export { default as BridgeProtocol, IBridgeProtocol } from './bridge-protocol.js'
|
|
@@ -58,3 +75,5 @@ export { default as BridgeProtocol, IBridgeProtocol } from './bridge-protocol.js
|
|
|
58
75
|
export { default as LendingProtocol, ILendingProtocol } from './lending-protocol.js'
|
|
59
76
|
|
|
60
77
|
export { default as FiatProtocol, IFiatProtocol } from './fiat-protocol.js'
|
|
78
|
+
|
|
79
|
+
export { default as SwidgeProtocol, ISwidgeProtocol } from './swidge-protocol.js'
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
// Copyright 2024 Tether Operations Limited
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
'use strict'
|
|
15
|
+
|
|
16
|
+
import { NotImplementedError } from '../errors.js'
|
|
17
|
+
|
|
18
|
+
/** @typedef {import('../wallet-account-read-only.js').IWalletAccountReadOnly} IWalletAccountReadOnly */
|
|
19
|
+
|
|
20
|
+
/** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
|
+
|
|
22
|
+
/** @typedef {import('./swap-protocol.js').ISwapProtocol} ISwapProtocol */
|
|
23
|
+
/** @typedef {import('./swap-protocol.js').SwapOptions} SwapOptions */
|
|
24
|
+
/** @typedef {import('./swap-protocol.js').SwapResult} SwapResult */
|
|
25
|
+
|
|
26
|
+
/** @typedef {import('./bridge-protocol.js').IBridgeProtocol} IBridgeProtocol */
|
|
27
|
+
/** @typedef {import('./bridge-protocol.js').BridgeOptions} BridgeOptions */
|
|
28
|
+
/** @typedef {import('./bridge-protocol.js').BridgeResult} BridgeResult */
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {'pending' | 'action-required' | 'completed' | 'failed'
|
|
32
|
+
* | 'refund-pending' | 'refunded' | 'cancelled' | 'expired' | 'partial'} SwidgeStatus
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {'network' | 'protocol' | 'affiliate' | 'other'} SwidgeFeeType
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {Object} SwidgeProtocolConfig
|
|
41
|
+
* @property {number | bigint} [maxNetworkFeeBps] - Maximum acceptable network fee in basis points of the input amount.
|
|
42
|
+
* @property {number | bigint} [maxProtocolFeeBps] - Maximum acceptable protocol fee in basis points of the input amount.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {SwidgeCommonOptions & (SwidgeExactInOptions | SwidgeExactOutOptions)} SwidgeOptions
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {Object} SwidgeCommonOptions
|
|
51
|
+
* @property {string} fromToken - The provider-specific identifier or address of the source token.
|
|
52
|
+
* @property {string} toToken - The provider-specific identifier or address of the destination token.
|
|
53
|
+
* @property {string | number} [toChain] - The identifier of the destination chain. If omitted, defaults to the source chain (same-chain swap).
|
|
54
|
+
* @property {string} [recipient] - The address that will receive the output tokens.
|
|
55
|
+
* @property {string} [refundAddress] - The address that will receive refunds if the tx cannot complete.
|
|
56
|
+
* @property {number} [slippage] - The maximum acceptable slippage as a decimal (e.g., 0.01 for 1%).
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @typedef {Object} SwidgeExactInOptions
|
|
61
|
+
* @property {number | bigint} fromTokenAmount - The exact amount of source tokens to spend (in base unit).
|
|
62
|
+
* @property {never} [toTokenAmount] - Not applicable for exact-in operations.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @typedef {Object} SwidgeExactOutOptions
|
|
67
|
+
* @property {never} [fromTokenAmount] - Not applicable for exact-out operations.
|
|
68
|
+
* @property {number | bigint} toTokenAmount - The exact amount of destination tokens to receive (in base unit).
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {Object} SwidgeFee
|
|
73
|
+
* @property {SwidgeFeeType} type - The category of the fee.
|
|
74
|
+
* @property {bigint} amount - The fee amount in base units.
|
|
75
|
+
* @property {string} token - The token in which the fee is denominated.
|
|
76
|
+
* @property {string | number} [chain] - The chain on which the fee is charged.
|
|
77
|
+
* @property {boolean} [included] - Whether the fee is already included in the quoted amounts.
|
|
78
|
+
* @property {string} [description] - A human-readable description of the fee.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @typedef {Object} SwidgeTransaction
|
|
83
|
+
* @property {string} hash - The transaction hash.
|
|
84
|
+
* @property {string | number} [chain] - The chain on which the transaction occurred.
|
|
85
|
+
* @property {'source' | 'destination' | 'approval' | 'refund' | 'other'} [type] - The role of the transaction within the swidge.
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Non-binding quote for a swidge operation.
|
|
90
|
+
* Providers that internally decompose the operation into multiple sequential transactions
|
|
91
|
+
* should encapsulate that decomposition behind a single quote.
|
|
92
|
+
*
|
|
93
|
+
* @typedef {Object} SwidgeQuote
|
|
94
|
+
* @property {bigint} fromTokenAmount - The amount of source tokens to spend.
|
|
95
|
+
* @property {bigint} toTokenAmount - The estimated amount of destination tokens to receive.
|
|
96
|
+
* @property {bigint} toTokenAmountMin - The minimum guaranteed amount after slippage.
|
|
97
|
+
* @property {SwidgeFee[]} fees - Itemised fee breakdown.
|
|
98
|
+
* @property {number} [estimatedDuration] - Estimated duration in seconds.
|
|
99
|
+
* @property {number} [expiry] - Unix timestamp (seconds) at which the quote expires.
|
|
100
|
+
* @property {number} [priceImpact] - Provider-reported estimated price impact as a decimal (e.g., 0.01 for 1%).
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @typedef {Object} SwidgeResult
|
|
105
|
+
* @property {string} id - The unique swidge execution identifier.
|
|
106
|
+
* @property {string} [hash] - The primary transaction hash (if available immediately).
|
|
107
|
+
* @property {SwidgeFee[]} fees - Itemised fee breakdown.
|
|
108
|
+
* @property {SwidgeTransaction[]} [transactions] - Transactions produced by the swidge execution.
|
|
109
|
+
* @property {bigint} fromTokenAmount - The actual amount of source tokens spent.
|
|
110
|
+
* @property {bigint} toTokenAmount - The actual or expected amount of destination tokens.
|
|
111
|
+
* @property {bigint} [toTokenAmountMin] - The minimum guaranteed amount after slippage.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @typedef {Object} SwidgeStatusOptions
|
|
116
|
+
* @property {string | number} [fromChain] - The source chain identifier.
|
|
117
|
+
* @property {string | number} [toChain] - The destination chain identifier.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @typedef {Object} SwidgeStatusResult
|
|
122
|
+
* @property {SwidgeStatus} status - The current status of the swidge.
|
|
123
|
+
* @property {SwidgeTransaction[]} [transactions] - Transactions associated with the swidge.
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @typedef {Object} SwidgeSupportedChain
|
|
128
|
+
* @property {string | number} id - The provider-specific chain identifier.
|
|
129
|
+
* @property {string} name - The human-readable chain name.
|
|
130
|
+
* @property {string} type - The chain or virtual machine type (e.g., 'evm', 'svm', 'utxo').
|
|
131
|
+
* @property {string} nativeToken - The symbol of the chain's native token.
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @typedef {Object} SwidgeSupportedToken
|
|
136
|
+
* @property {string} token - The provider-specific token identifier to use in swidge operations.
|
|
137
|
+
* @property {string | number} chain - The chain on which the token is available.
|
|
138
|
+
* @property {string} symbol - The token symbol.
|
|
139
|
+
* @property {number} decimals - The number of decimal places for the token's base unit.
|
|
140
|
+
* @property {string} [address] - The token contract address, if applicable.
|
|
141
|
+
* @property {string} [name] - The token's full name.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @typedef {Object} SwidgeSupportedTokensOptions
|
|
146
|
+
* @property {string | number} [fromChain] - The optional source chain for route-scoped discovery.
|
|
147
|
+
* @property {string} [fromToken] - The optional source token for route-scoped discovery.
|
|
148
|
+
* @property {string | number} [toChain] - The optional destination chain for route-scoped discovery.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @interface
|
|
153
|
+
* @implements {ISwapProtocol}
|
|
154
|
+
* @implements {IBridgeProtocol}
|
|
155
|
+
*/
|
|
156
|
+
export class ISwidgeProtocol {
|
|
157
|
+
/**
|
|
158
|
+
* Quotes the estimated costs and output of a cross-chain swap/bridge operation.
|
|
159
|
+
* Returns a non-binding quote; the actual execution is performed
|
|
160
|
+
* by {@link swidge}.
|
|
161
|
+
*
|
|
162
|
+
* @param {SwidgeOptions} options - The swidge options.
|
|
163
|
+
* @returns {Promise<SwidgeQuote>} The quoted swidge details.
|
|
164
|
+
*/
|
|
165
|
+
async quoteSwidge (options) {
|
|
166
|
+
throw new NotImplementedError('quoteSwidge(options)')
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Executes a swidge operation.
|
|
171
|
+
*
|
|
172
|
+
* @param {SwidgeOptions} options - The swidge options.
|
|
173
|
+
* @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
|
|
174
|
+
* @returns {Promise<SwidgeResult>} The swidge execution result.
|
|
175
|
+
*/
|
|
176
|
+
async swidge (options, config) {
|
|
177
|
+
throw new NotImplementedError('swidge(options, config)')
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Retrieves the current status of an in-flight swidge.
|
|
182
|
+
*
|
|
183
|
+
* @param {string} id - The swidge execution identifier returned by swidge.
|
|
184
|
+
* @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
|
|
185
|
+
* @returns {Promise<SwidgeStatusResult>} The current swidge status.
|
|
186
|
+
* @throws {Error} If the id is invalid, or no swidge exists with the given identifier.
|
|
187
|
+
*/
|
|
188
|
+
async getSwidgeStatus (id, options) {
|
|
189
|
+
throw new NotImplementedError('getSwidgeStatus(id, options)')
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Retrieves the chains supported by the provider for swidge operations.
|
|
194
|
+
*
|
|
195
|
+
* @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
|
|
196
|
+
*/
|
|
197
|
+
async getSupportedChains () {
|
|
198
|
+
throw new NotImplementedError('getSupportedChains()')
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Retrieves the tokens supported by the provider for swidge operations.
|
|
203
|
+
*
|
|
204
|
+
* @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
|
|
205
|
+
* @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
|
|
206
|
+
*/
|
|
207
|
+
async getSupportedTokens (options) {
|
|
208
|
+
throw new NotImplementedError('getSupportedTokens(options)')
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @abstract
|
|
214
|
+
* @implements {ISwidgeProtocol}
|
|
215
|
+
* @implements {ISwapProtocol}
|
|
216
|
+
* @implements {IBridgeProtocol}
|
|
217
|
+
*/
|
|
218
|
+
export default class SwidgeProtocol {
|
|
219
|
+
/**
|
|
220
|
+
* Creates a new swidge protocol without binding it to a wallet account.
|
|
221
|
+
*
|
|
222
|
+
* @overload
|
|
223
|
+
* @param {undefined} [account] - The wallet account to use to interact with the protocol.
|
|
224
|
+
* @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Creates a new read-only swidge protocol.
|
|
229
|
+
*
|
|
230
|
+
* @overload
|
|
231
|
+
* @param {IWalletAccountReadOnly} account - The wallet account to use to interact with the protocol.
|
|
232
|
+
* @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Creates a new swidge protocol.
|
|
237
|
+
*
|
|
238
|
+
* @overload
|
|
239
|
+
* @param {IWalletAccount} account - The wallet account to use to interact with the protocol.
|
|
240
|
+
* @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
|
|
241
|
+
*/
|
|
242
|
+
constructor (account, config = {}) {
|
|
243
|
+
/**
|
|
244
|
+
* The wallet account to use to interact with the protocol.
|
|
245
|
+
*
|
|
246
|
+
* @protected
|
|
247
|
+
* @type {IWalletAccountReadOnly | IWalletAccount | undefined}
|
|
248
|
+
*/
|
|
249
|
+
this._account = account
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The swidge protocol configuration.
|
|
253
|
+
*
|
|
254
|
+
* @protected
|
|
255
|
+
* @type {SwidgeProtocolConfig}
|
|
256
|
+
*/
|
|
257
|
+
this._config = config
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Swaps a pair of tokens by delegating to {@link swidge}.
|
|
262
|
+
*
|
|
263
|
+
* @param {SwapOptions} options - The swap's options.
|
|
264
|
+
* @returns {Promise<SwapResult>} The swap's result.
|
|
265
|
+
* @throws {Error} If no account, or a read-only account was given at construction.
|
|
266
|
+
*/
|
|
267
|
+
async swap (options) {
|
|
268
|
+
const result = await this.swidge({
|
|
269
|
+
fromToken: options.tokenIn,
|
|
270
|
+
toToken: options.tokenOut,
|
|
271
|
+
recipient: options.to,
|
|
272
|
+
fromTokenAmount: options.tokenInAmount,
|
|
273
|
+
toTokenAmount: options.tokenOutAmount
|
|
274
|
+
})
|
|
275
|
+
const fee = result.fees.reduce((acc, f) => acc + f.amount, 0n)
|
|
276
|
+
return { hash: result.id, fee, tokenInAmount: result.fromTokenAmount, tokenOutAmount: result.toTokenAmount }
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Quotes the costs of a swap operation by delegating to {@link quoteSwidge}.
|
|
281
|
+
*
|
|
282
|
+
* @param {SwapOptions} options - The swap's options.
|
|
283
|
+
* @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
|
|
284
|
+
* @throws {Error} If no account was given at construction.
|
|
285
|
+
*/
|
|
286
|
+
async quoteSwap (options) {
|
|
287
|
+
const result = await this.quoteSwidge({
|
|
288
|
+
fromToken: options.tokenIn,
|
|
289
|
+
toToken: options.tokenOut,
|
|
290
|
+
recipient: options.to,
|
|
291
|
+
fromTokenAmount: options.tokenInAmount,
|
|
292
|
+
toTokenAmount: options.tokenOutAmount
|
|
293
|
+
})
|
|
294
|
+
const fee = result.fees.reduce((acc, f) => acc + f.amount, 0n)
|
|
295
|
+
return { fee, tokenInAmount: result.fromTokenAmount, tokenOutAmount: result.toTokenAmount }
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Bridges a token to a different blockchain by delegating to {@link swidge}.
|
|
300
|
+
*
|
|
301
|
+
* @param {BridgeOptions} options - The bridge's options.
|
|
302
|
+
* @returns {Promise<BridgeResult>} The bridge's result.
|
|
303
|
+
* @throws {Error} If no account, or a read-only account was given at construction.
|
|
304
|
+
*/
|
|
305
|
+
async bridge (options) {
|
|
306
|
+
const { id: hash, fees } = await this.swidge({
|
|
307
|
+
fromToken: options.token,
|
|
308
|
+
toToken: options.token,
|
|
309
|
+
toChain: options.targetChain,
|
|
310
|
+
recipient: options.recipient,
|
|
311
|
+
fromTokenAmount: options.amount
|
|
312
|
+
})
|
|
313
|
+
const fee = fees.filter(f => f.type === 'network')
|
|
314
|
+
.reduce((acc, { amount }) => acc + amount, 0n)
|
|
315
|
+
const bridgeFee = fees.filter(f => f.type === 'protocol')
|
|
316
|
+
.reduce((acc, { amount }) => acc + amount, 0n)
|
|
317
|
+
return { hash, fee, bridgeFee }
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Quotes the costs of a bridge operation by delegating to {@link quoteSwidge}.
|
|
322
|
+
*
|
|
323
|
+
* @param {BridgeOptions} options - The bridge's options.
|
|
324
|
+
* @returns {Promise<Omit<BridgeResult, 'hash'>>} The bridge's quotes.
|
|
325
|
+
* @throws {Error} If no account was given at construction.
|
|
326
|
+
*/
|
|
327
|
+
async quoteBridge (options) {
|
|
328
|
+
const { fees } = await this.quoteSwidge({
|
|
329
|
+
fromToken: options.token,
|
|
330
|
+
toToken: options.token,
|
|
331
|
+
toChain: options.targetChain,
|
|
332
|
+
recipient: options.recipient,
|
|
333
|
+
fromTokenAmount: options.amount
|
|
334
|
+
})
|
|
335
|
+
const fee = fees.filter(f => f.type === 'network')
|
|
336
|
+
.reduce((acc, { amount }) => acc + amount, 0n)
|
|
337
|
+
const bridgeFee = fees.filter(f => f.type === 'protocol')
|
|
338
|
+
.reduce((acc, { amount }) => acc + amount, 0n)
|
|
339
|
+
return { fee, bridgeFee }
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Quotes the estimated costs and output of a swidge operation.
|
|
344
|
+
* Returns a non-binding quote; the actual execution is performed
|
|
345
|
+
* by {@link swidge}.
|
|
346
|
+
*
|
|
347
|
+
* @abstract
|
|
348
|
+
* @param {SwidgeOptions} options - The swidge options.
|
|
349
|
+
* @returns {Promise<SwidgeQuote>} The quoted swidge details.
|
|
350
|
+
* @throws {Error} If no account was given at construction.
|
|
351
|
+
*/
|
|
352
|
+
async quoteSwidge (options) {
|
|
353
|
+
throw new NotImplementedError('quoteSwidge(options)')
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Executes a swidge operation.
|
|
358
|
+
*
|
|
359
|
+
* @abstract
|
|
360
|
+
* @param {SwidgeOptions} options - The swidge options.
|
|
361
|
+
* @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
|
|
362
|
+
* @returns {Promise<SwidgeResult>} The swidge execution result.
|
|
363
|
+
* @throws {Error} If no account, or a read-only account was given at construction.
|
|
364
|
+
*/
|
|
365
|
+
async swidge (options, config) {
|
|
366
|
+
throw new NotImplementedError('swidge(options, config)')
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Retrieves the current status of an in-flight swidge.
|
|
371
|
+
*
|
|
372
|
+
* @abstract
|
|
373
|
+
* @param {string} id - The swidge execution identifier returned by swidge.
|
|
374
|
+
* @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
|
|
375
|
+
* @returns {Promise<SwidgeStatusResult>} The current swidge status.
|
|
376
|
+
* @throws {Error} If the id is invalid, or no swidge exists with the given identifier.
|
|
377
|
+
*/
|
|
378
|
+
async getSwidgeStatus (id, options) {
|
|
379
|
+
throw new NotImplementedError('getSwidgeStatus(id, options)')
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Retrieves the chains supported by the provider for swidge operations.
|
|
384
|
+
*
|
|
385
|
+
* @abstract
|
|
386
|
+
* @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
|
|
387
|
+
*/
|
|
388
|
+
async getSupportedChains () {
|
|
389
|
+
throw new NotImplementedError('getSupportedChains()')
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Retrieves the tokens supported by the provider for swidge operations.
|
|
394
|
+
*
|
|
395
|
+
* @abstract
|
|
396
|
+
* @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
|
|
397
|
+
* @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
|
|
398
|
+
*/
|
|
399
|
+
async getSupportedTokens (options) {
|
|
400
|
+
throw new NotImplementedError('getSupportedTokens(options)')
|
|
401
|
+
}
|
|
402
|
+
}
|
|
@@ -28,7 +28,24 @@ export type FiatTransactionDetail = import("./fiat-protocol.js").FiatTransaction
|
|
|
28
28
|
export type SupportedCryptoAsset = import("./fiat-protocol.js").SupportedCryptoAsset;
|
|
29
29
|
export type SupportedFiatCurrency = import("./fiat-protocol.js").SupportedFiatCurrency;
|
|
30
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;
|
|
31
47
|
export { default as SwapProtocol, ISwapProtocol } from "./swap-protocol.js";
|
|
32
48
|
export { default as BridgeProtocol, IBridgeProtocol } from "./bridge-protocol.js";
|
|
33
49
|
export { default as LendingProtocol, ILendingProtocol } from "./lending-protocol.js";
|
|
34
50
|
export { default as FiatProtocol, IFiatProtocol } from "./fiat-protocol.js";
|
|
51
|
+
export { default as SwidgeProtocol, ISwidgeProtocol } from "./swidge-protocol.js";
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
/** @interface */
|
|
2
|
+
export interface ISwidgeProtocol extends ISwapProtocol, IBridgeProtocol {
|
|
3
|
+
/**
|
|
4
|
+
* Quotes the estimated costs and output of a cross-chain swap/bridge operation.
|
|
5
|
+
* Returns a non-binding quote; the actual execution is performed
|
|
6
|
+
* by {@link swidge}.
|
|
7
|
+
*
|
|
8
|
+
* @param {SwidgeOptions} options - The swidge options.
|
|
9
|
+
* @returns {Promise<SwidgeQuote>} The quoted swidge details.
|
|
10
|
+
*/
|
|
11
|
+
quoteSwidge(options: SwidgeOptions): Promise<SwidgeQuote>;
|
|
12
|
+
/**
|
|
13
|
+
* Executes a swidge operation.
|
|
14
|
+
*
|
|
15
|
+
* @param {SwidgeOptions} options - The swidge options.
|
|
16
|
+
* @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
|
|
17
|
+
* @returns {Promise<SwidgeResult>} The swidge execution result.
|
|
18
|
+
*/
|
|
19
|
+
swidge(options: SwidgeOptions, config?: SwidgeProtocolConfig): Promise<SwidgeResult>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the current status of an in-flight swidge.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} id - The swidge execution identifier returned by swidge.
|
|
24
|
+
* @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
|
|
25
|
+
* @returns {Promise<SwidgeStatusResult>} The current swidge status.
|
|
26
|
+
* @throws {Error} If the id is invalid, or no swidge exists with the given identifier.
|
|
27
|
+
*/
|
|
28
|
+
getSwidgeStatus(id: string, options?: SwidgeStatusOptions): Promise<SwidgeStatusResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the chains supported by the provider for swidge operations.
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
|
|
33
|
+
*/
|
|
34
|
+
getSupportedChains(): Promise<SwidgeSupportedChain[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves the tokens supported by the provider for swidge operations.
|
|
37
|
+
*
|
|
38
|
+
* @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
|
|
39
|
+
* @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
|
|
40
|
+
*/
|
|
41
|
+
getSupportedTokens(options?: SwidgeSupportedTokensOptions): Promise<SwidgeSupportedToken[]>;
|
|
42
|
+
}
|
|
43
|
+
/** @abstract */
|
|
44
|
+
export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapProtocol, IBridgeProtocol {
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new swidge protocol without binding it to a wallet account.
|
|
47
|
+
*
|
|
48
|
+
* @overload
|
|
49
|
+
* @param {undefined} [account] - The wallet account to use to interact with the protocol.
|
|
50
|
+
* @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
|
|
51
|
+
*/
|
|
52
|
+
constructor(account?: undefined, config?: SwidgeProtocolConfig | undefined);
|
|
53
|
+
/**
|
|
54
|
+
* Creates a new read-only swidge protocol.
|
|
55
|
+
*
|
|
56
|
+
* @overload
|
|
57
|
+
* @param {IWalletAccountReadOnly} account - The wallet account to use to interact with the protocol.
|
|
58
|
+
* @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
|
|
59
|
+
*/
|
|
60
|
+
constructor(account: IWalletAccountReadOnly, config?: SwidgeProtocolConfig | undefined);
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new swidge protocol.
|
|
63
|
+
*
|
|
64
|
+
* @overload
|
|
65
|
+
* @param {IWalletAccount} account - The wallet account to use to interact with the protocol.
|
|
66
|
+
* @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
|
|
67
|
+
*/
|
|
68
|
+
constructor(account: IWalletAccount, config?: SwidgeProtocolConfig | undefined);
|
|
69
|
+
/**
|
|
70
|
+
* The wallet account to use to interact with the protocol.
|
|
71
|
+
*
|
|
72
|
+
* @protected
|
|
73
|
+
* @type {IWalletAccountReadOnly | IWalletAccount | undefined}
|
|
74
|
+
*/
|
|
75
|
+
protected _account: IWalletAccountReadOnly | IWalletAccount | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The swidge protocol configuration.
|
|
78
|
+
*
|
|
79
|
+
* @protected
|
|
80
|
+
* @type {SwidgeProtocolConfig}
|
|
81
|
+
*/
|
|
82
|
+
protected _config: SwidgeProtocolConfig;
|
|
83
|
+
/**
|
|
84
|
+
* Swaps a pair of tokens by delegating to {@link swidge}.
|
|
85
|
+
*
|
|
86
|
+
* @param {SwapOptions} options - The swap's options.
|
|
87
|
+
* @returns {Promise<SwapResult>} The swap's result.
|
|
88
|
+
*/
|
|
89
|
+
swap(options: SwapOptions): Promise<SwapResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Quotes the costs of a swap operation by delegating to {@link quoteSwidge}.
|
|
92
|
+
*
|
|
93
|
+
* @param {SwapOptions} options - The swap's options.
|
|
94
|
+
* @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
|
|
95
|
+
*/
|
|
96
|
+
quoteSwap(options: SwapOptions): Promise<Omit<SwapResult, "hash">>;
|
|
97
|
+
/**
|
|
98
|
+
* Bridges a token to a different blockchain by delegating to {@link swidge}.
|
|
99
|
+
*
|
|
100
|
+
* @param {BridgeOptions} options - The bridge's options.
|
|
101
|
+
* @returns {Promise<BridgeResult>} The bridge's result.
|
|
102
|
+
*/
|
|
103
|
+
bridge(options: BridgeOptions): Promise<BridgeResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Quotes the costs of a bridge operation by delegating to {@link quoteSwidge}.
|
|
106
|
+
*
|
|
107
|
+
* @param {BridgeOptions} options - The bridge's options.
|
|
108
|
+
* @returns {Promise<Omit<BridgeResult, 'hash'>>} The bridge's quotes.
|
|
109
|
+
*/
|
|
110
|
+
quoteBridge(options: BridgeOptions): Promise<Omit<BridgeResult, "hash">>;
|
|
111
|
+
/**
|
|
112
|
+
* Quotes the estimated costs and output of a swidge operation.
|
|
113
|
+
* Returns a non-binding quote; the actual execution is performed
|
|
114
|
+
* by {@link swidge}.
|
|
115
|
+
*
|
|
116
|
+
* @abstract
|
|
117
|
+
* @param {SwidgeOptions} options - The swidge options.
|
|
118
|
+
* @returns {Promise<SwidgeQuote>} The quoted swidge details.
|
|
119
|
+
*/
|
|
120
|
+
abstract quoteSwidge(options: SwidgeOptions): Promise<SwidgeQuote>;
|
|
121
|
+
/**
|
|
122
|
+
* Executes a swidge operation.
|
|
123
|
+
*
|
|
124
|
+
* @abstract
|
|
125
|
+
* @param {SwidgeOptions} options - The swidge options.
|
|
126
|
+
* @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
|
|
127
|
+
* @returns {Promise<SwidgeResult>} The swidge execution result.
|
|
128
|
+
*/
|
|
129
|
+
abstract swidge(options: SwidgeOptions, config?: SwidgeProtocolConfig): Promise<SwidgeResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Retrieves the current status of an in-flight swidge.
|
|
132
|
+
*
|
|
133
|
+
* @abstract
|
|
134
|
+
* @param {string} id - The swidge execution identifier returned by swidge.
|
|
135
|
+
* @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
|
|
136
|
+
* @returns {Promise<SwidgeStatusResult>} The current swidge status.
|
|
137
|
+
* @throws {Error} If the id is invalid, or no swidge exists with the given identifier.
|
|
138
|
+
*/
|
|
139
|
+
abstract getSwidgeStatus(id: string, options?: SwidgeStatusOptions): Promise<SwidgeStatusResult>;
|
|
140
|
+
/**
|
|
141
|
+
* Retrieves the chains supported by the provider for swidge operations.
|
|
142
|
+
*
|
|
143
|
+
* @abstract
|
|
144
|
+
* @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
|
|
145
|
+
*/
|
|
146
|
+
abstract getSupportedChains(): Promise<SwidgeSupportedChain[]>;
|
|
147
|
+
/**
|
|
148
|
+
* Retrieves the tokens supported by the provider for swidge operations.
|
|
149
|
+
*
|
|
150
|
+
* @abstract
|
|
151
|
+
* @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
|
|
152
|
+
* @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
|
|
153
|
+
*/
|
|
154
|
+
abstract getSupportedTokens(options?: SwidgeSupportedTokensOptions): Promise<SwidgeSupportedToken[]>;
|
|
155
|
+
}
|
|
156
|
+
export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
|
|
157
|
+
export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
|
|
158
|
+
export type ISwapProtocol = import("./swap-protocol.js").ISwapProtocol;
|
|
159
|
+
export type SwapOptions = import("./swap-protocol.js").SwapOptions;
|
|
160
|
+
export type SwapResult = import("./swap-protocol.js").SwapResult;
|
|
161
|
+
export type IBridgeProtocol = import("./bridge-protocol.js").IBridgeProtocol;
|
|
162
|
+
export type BridgeOptions = import("./bridge-protocol.js").BridgeOptions;
|
|
163
|
+
export type BridgeResult = import("./bridge-protocol.js").BridgeResult;
|
|
164
|
+
export type SwidgeStatus = "pending" | "action-required" | "completed" | "failed" | "refund-pending" | "refunded" | "cancelled" | "expired" | "partial";
|
|
165
|
+
export type SwidgeFeeType = "network" | "protocol" | "affiliate" | "other";
|
|
166
|
+
export type SwidgeProtocolConfig = {
|
|
167
|
+
/**
|
|
168
|
+
* - Maximum acceptable network fee in basis points of the input amount.
|
|
169
|
+
*/
|
|
170
|
+
maxNetworkFeeBps?: number | bigint | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* - Maximum acceptable protocol fee in basis points of the input amount.
|
|
173
|
+
*/
|
|
174
|
+
maxProtocolFeeBps?: number | bigint | undefined;
|
|
175
|
+
};
|
|
176
|
+
export type SwidgeOptions = SwidgeCommonOptions & (SwidgeExactInOptions | SwidgeExactOutOptions);
|
|
177
|
+
export type SwidgeCommonOptions = {
|
|
178
|
+
/**
|
|
179
|
+
* - The provider-specific identifier or address of the source token.
|
|
180
|
+
*/
|
|
181
|
+
fromToken: string;
|
|
182
|
+
/**
|
|
183
|
+
* - The provider-specific identifier or address of the destination token.
|
|
184
|
+
*/
|
|
185
|
+
toToken: string;
|
|
186
|
+
/**
|
|
187
|
+
* - The identifier of the destination chain. If omitted, defaults to the source chain (same-chain swap).
|
|
188
|
+
*/
|
|
189
|
+
toChain?: string | number | undefined;
|
|
190
|
+
/**
|
|
191
|
+
* - The address that will receive the output tokens.
|
|
192
|
+
*/
|
|
193
|
+
recipient?: string | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* - The address that will receive refunds if the tx cannot complete.
|
|
196
|
+
*/
|
|
197
|
+
refundAddress?: string | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* - The maximum acceptable slippage as a decimal (e.g., 0.01 for 1%).
|
|
200
|
+
*/
|
|
201
|
+
slippage?: number | undefined;
|
|
202
|
+
};
|
|
203
|
+
export type SwidgeExactInOptions = {
|
|
204
|
+
/**
|
|
205
|
+
* - The exact amount of source tokens to spend (in base unit).
|
|
206
|
+
*/
|
|
207
|
+
fromTokenAmount: number | bigint;
|
|
208
|
+
/**
|
|
209
|
+
* - Not applicable for exact-in operations.
|
|
210
|
+
*/
|
|
211
|
+
toTokenAmount?: undefined;
|
|
212
|
+
};
|
|
213
|
+
export type SwidgeExactOutOptions = {
|
|
214
|
+
/**
|
|
215
|
+
* - Not applicable for exact-out operations.
|
|
216
|
+
*/
|
|
217
|
+
fromTokenAmount?: undefined;
|
|
218
|
+
/**
|
|
219
|
+
* - The exact amount of destination tokens to receive (in base unit).
|
|
220
|
+
*/
|
|
221
|
+
toTokenAmount: number | bigint;
|
|
222
|
+
};
|
|
223
|
+
export type SwidgeFee = {
|
|
224
|
+
/**
|
|
225
|
+
* - The category of the fee.
|
|
226
|
+
*/
|
|
227
|
+
type: SwidgeFeeType;
|
|
228
|
+
/**
|
|
229
|
+
* - The fee amount in base units.
|
|
230
|
+
*/
|
|
231
|
+
amount: bigint;
|
|
232
|
+
/**
|
|
233
|
+
* - The token in which the fee is denominated.
|
|
234
|
+
*/
|
|
235
|
+
token: string;
|
|
236
|
+
/**
|
|
237
|
+
* - The chain on which the fee is charged.
|
|
238
|
+
*/
|
|
239
|
+
chain?: string | number | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* - Whether the fee is already included in the quoted amounts.
|
|
242
|
+
*/
|
|
243
|
+
included?: boolean | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* - A human-readable description of the fee.
|
|
246
|
+
*/
|
|
247
|
+
description?: string | undefined;
|
|
248
|
+
};
|
|
249
|
+
export type SwidgeTransaction = {
|
|
250
|
+
/**
|
|
251
|
+
* - The transaction hash.
|
|
252
|
+
*/
|
|
253
|
+
hash: string;
|
|
254
|
+
/**
|
|
255
|
+
* - The chain on which the transaction occurred.
|
|
256
|
+
*/
|
|
257
|
+
chain?: string | number | undefined;
|
|
258
|
+
/**
|
|
259
|
+
* - The role of the transaction within the swidge.
|
|
260
|
+
*/
|
|
261
|
+
type?: "other" | "source" | "destination" | "approval" | "refund" | undefined;
|
|
262
|
+
};
|
|
263
|
+
export type SwidgeQuote = {
|
|
264
|
+
/**
|
|
265
|
+
* - The amount of source tokens to spend.
|
|
266
|
+
*/
|
|
267
|
+
fromTokenAmount: bigint;
|
|
268
|
+
/**
|
|
269
|
+
* - The estimated amount of destination tokens to receive.
|
|
270
|
+
*/
|
|
271
|
+
toTokenAmount: bigint;
|
|
272
|
+
/**
|
|
273
|
+
* - The minimum guaranteed amount after slippage.
|
|
274
|
+
*/
|
|
275
|
+
toTokenAmountMin: bigint;
|
|
276
|
+
/**
|
|
277
|
+
* - Itemised fee breakdown.
|
|
278
|
+
*/
|
|
279
|
+
fees: SwidgeFee[];
|
|
280
|
+
/**
|
|
281
|
+
* - Estimated duration in seconds.
|
|
282
|
+
*/
|
|
283
|
+
estimatedDuration?: number | undefined;
|
|
284
|
+
/**
|
|
285
|
+
* - Unix timestamp (seconds) at which the quote expires.
|
|
286
|
+
*/
|
|
287
|
+
expiry?: number | undefined;
|
|
288
|
+
/**
|
|
289
|
+
* - Provider-reported estimated price impact as a decimal (e.g., 0.01 for 1%).
|
|
290
|
+
*/
|
|
291
|
+
priceImpact?: number | undefined;
|
|
292
|
+
};
|
|
293
|
+
export type SwidgeResult = {
|
|
294
|
+
/**
|
|
295
|
+
* - The unique swidge execution identifier.
|
|
296
|
+
*/
|
|
297
|
+
id: string;
|
|
298
|
+
/**
|
|
299
|
+
* - The primary transaction hash (if available immediately).
|
|
300
|
+
*/
|
|
301
|
+
hash?: string | undefined;
|
|
302
|
+
/**
|
|
303
|
+
* - Itemised fee breakdown.
|
|
304
|
+
*/
|
|
305
|
+
fees: SwidgeFee[];
|
|
306
|
+
/**
|
|
307
|
+
* - Transactions produced by the swidge execution.
|
|
308
|
+
*/
|
|
309
|
+
transactions?: SwidgeTransaction[] | undefined;
|
|
310
|
+
/**
|
|
311
|
+
* - The actual amount of source tokens spent.
|
|
312
|
+
*/
|
|
313
|
+
fromTokenAmount: bigint;
|
|
314
|
+
/**
|
|
315
|
+
* - The actual or expected amount of destination tokens.
|
|
316
|
+
*/
|
|
317
|
+
toTokenAmount: bigint;
|
|
318
|
+
/**
|
|
319
|
+
* - The minimum guaranteed amount after slippage.
|
|
320
|
+
*/
|
|
321
|
+
toTokenAmountMin?: bigint | undefined;
|
|
322
|
+
};
|
|
323
|
+
export type SwidgeStatusOptions = {
|
|
324
|
+
/**
|
|
325
|
+
* - The source chain identifier.
|
|
326
|
+
*/
|
|
327
|
+
fromChain?: string | number | undefined;
|
|
328
|
+
/**
|
|
329
|
+
* - The destination chain identifier.
|
|
330
|
+
*/
|
|
331
|
+
toChain?: string | number | undefined;
|
|
332
|
+
};
|
|
333
|
+
export type SwidgeStatusResult = {
|
|
334
|
+
/**
|
|
335
|
+
* - The current status of the swidge.
|
|
336
|
+
*/
|
|
337
|
+
status: SwidgeStatus;
|
|
338
|
+
/**
|
|
339
|
+
* - Transactions associated with the swidge.
|
|
340
|
+
*/
|
|
341
|
+
transactions?: SwidgeTransaction[] | undefined;
|
|
342
|
+
};
|
|
343
|
+
export type SwidgeSupportedChain = {
|
|
344
|
+
/**
|
|
345
|
+
* - The provider-specific chain identifier.
|
|
346
|
+
*/
|
|
347
|
+
id: string | number;
|
|
348
|
+
/**
|
|
349
|
+
* - The human-readable chain name.
|
|
350
|
+
*/
|
|
351
|
+
name: string;
|
|
352
|
+
/**
|
|
353
|
+
* - The chain or virtual machine type (e.g., 'evm', 'svm', 'utxo').
|
|
354
|
+
*/
|
|
355
|
+
type: string;
|
|
356
|
+
/**
|
|
357
|
+
* - The symbol of the chain's native token.
|
|
358
|
+
*/
|
|
359
|
+
nativeToken: string;
|
|
360
|
+
};
|
|
361
|
+
export type SwidgeSupportedToken = {
|
|
362
|
+
/**
|
|
363
|
+
* - The provider-specific token identifier to use in swidge operations.
|
|
364
|
+
*/
|
|
365
|
+
token: string;
|
|
366
|
+
/**
|
|
367
|
+
* - The chain on which the token is available.
|
|
368
|
+
*/
|
|
369
|
+
chain: string | number;
|
|
370
|
+
/**
|
|
371
|
+
* - The token symbol.
|
|
372
|
+
*/
|
|
373
|
+
symbol: string;
|
|
374
|
+
/**
|
|
375
|
+
* - The number of decimal places for the token's base unit.
|
|
376
|
+
*/
|
|
377
|
+
decimals: number;
|
|
378
|
+
/**
|
|
379
|
+
* - The token contract address, if applicable.
|
|
380
|
+
*/
|
|
381
|
+
address?: string | undefined;
|
|
382
|
+
/**
|
|
383
|
+
* - The token's full name.
|
|
384
|
+
*/
|
|
385
|
+
name?: string | undefined;
|
|
386
|
+
};
|
|
387
|
+
export type SwidgeSupportedTokensOptions = {
|
|
388
|
+
/**
|
|
389
|
+
* - The optional source chain for route-scoped discovery.
|
|
390
|
+
*/
|
|
391
|
+
fromChain?: string | number | undefined;
|
|
392
|
+
/**
|
|
393
|
+
* - The optional source token for route-scoped discovery.
|
|
394
|
+
*/
|
|
395
|
+
fromToken?: string | undefined;
|
|
396
|
+
/**
|
|
397
|
+
* - The optional destination chain for route-scoped discovery.
|
|
398
|
+
*/
|
|
399
|
+
toChain?: string | number | undefined;
|
|
400
|
+
};
|