@lendasat/lendaswap-sdk 0.1.8 → 0.1.67
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/README.md +200 -126
- package/dist/api.d.ts +206 -192
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +292 -132
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +23 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -21
- package/dist/index.js.map +1 -1
- package/dist/price-calculations.d.ts +135 -0
- package/dist/price-calculations.d.ts.map +1 -0
- package/dist/price-calculations.js +171 -0
- package/dist/price-calculations.js.map +1 -0
- package/dist/price-feed.d.ts +3 -0
- package/dist/price-feed.d.ts.map +1 -1
- package/dist/price-feed.js.map +1 -1
- package/dist/usd-price.d.ts.map +1 -1
- package/dist/usd-price.js +1 -0
- package/dist/usd-price.js.map +1 -1
- package/package.json +14 -15
- package/wasm/lendaswap_wasm_sdk.d.ts +442 -114
- package/wasm/lendaswap_wasm_sdk_bg.js +2946 -630
- package/wasm/lendaswap_wasm_sdk_bg.wasm +0 -0
- package/wasm/lendaswap_wasm_sdk_bg.wasm.d.ts +268 -64
- package/dist/storage/dexieSwapStorage.d.ts +0 -111
- package/dist/storage/dexieSwapStorage.d.ts.map +0 -1
- package/dist/storage/dexieSwapStorage.js +0 -139
- package/dist/storage/dexieSwapStorage.js.map +0 -1
- package/dist/storage/dexieWalletStorage.d.ts +0 -99
- package/dist/storage/dexieWalletStorage.d.ts.map +0 -1
- package/dist/storage/dexieWalletStorage.js +0 -139
- package/dist/storage/dexieWalletStorage.js.map +0 -1
- package/dist/storage/index.d.ts +0 -18
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js +0 -20
- package/dist/storage/index.js.map +0 -1
package/dist/api.d.ts
CHANGED
|
@@ -4,123 +4,35 @@
|
|
|
4
4
|
* This module provides a high-level TypeScript API that wraps the WASM-based
|
|
5
5
|
* API client for easier use in TypeScript/JavaScript applications.
|
|
6
6
|
*/
|
|
7
|
-
import { type CreateVtxoSwapResult, type EstimateVtxoSwapResponse, type SwapParams, type VtxoSwapResponse } from "../wasm/lendaswap_wasm_sdk.js";
|
|
8
|
-
|
|
9
|
-
export { CreateVtxoSwapResult, EstimateVtxoSwapResponse, QuoteResponse, SwapParams as VtxoSwapParams, TokenId, Version, VhtlcAmounts, VtxoSwapResponse, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
7
|
+
import { type AssetPair, type BtcToArkadeSwapResponse, type BtcToEvmSwapResponse, Client as WasmClient, type CreateVtxoSwapResult, type EstimateVtxoSwapResponse, type EvmToBtcSwapResponse, type ExtendedVtxoSwapStorageData, type IdbStorageHandle, type QuoteResponse, type SwapParams, type TokenInfo, type Version, type VhtlcAmounts, type VtxoSwapResponse } from "../wasm/lendaswap_wasm_sdk.js";
|
|
8
|
+
export { AssetPair, BtcToEvmSwapResponse, BtcToArkadeSwapResponse, Chain, CreateVtxoSwapResult, EstimateVtxoSwapResponse, EvmToBtcSwapResponse, ExtendedSwapStorageData as ExtendedSwapStorageDataWasm, ExtendedVtxoSwapStorageData, IdbStorageHandle, Network, openIdbDatabase, QuoteResponse, SwapParams as VtxoSwapParams, SwapStatus, SwapType, swapStatusToString, TokenId, TokenInfo, Version, VhtlcAmounts, VtxoSwapResponse, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
10
9
|
/**
|
|
11
10
|
* Known token identifiers.
|
|
12
11
|
* Add new tokens here as they become supported.
|
|
13
12
|
* Uses (string & {}) to allow unknown tokens while preserving autocomplete.
|
|
14
13
|
*/
|
|
15
|
-
export type TokenIdString = "btc_lightning" | "btc_arkade" | "usdc_pol" | "usdt0_pol" | "usdc_eth" | "usdt_eth" | "xaut_eth" | (string & {});
|
|
16
|
-
/**
|
|
17
|
-
* Blockchain network.
|
|
18
|
-
* Uses (string & {}) to allow unknown chains while preserving autocomplete.
|
|
19
|
-
*/
|
|
20
|
-
export type Chain = "Arkade" | "Lightning" | "Polygon" | "Ethereum" | (string & {});
|
|
21
|
-
/**
|
|
22
|
-
* Token information with typed token ID.
|
|
23
|
-
*/
|
|
24
|
-
export interface TokenInfo {
|
|
25
|
-
tokenId: TokenIdString;
|
|
26
|
-
symbol: string;
|
|
27
|
-
chain: Chain;
|
|
28
|
-
name: string;
|
|
29
|
-
decimals: number;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Asset pair with typed token info.
|
|
33
|
-
*/
|
|
34
|
-
export interface AssetPair {
|
|
35
|
-
source: TokenInfo;
|
|
36
|
-
target: TokenInfo;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Swap status enumeration.
|
|
40
|
-
* These match the server-side status values.
|
|
41
|
-
*/
|
|
42
|
-
export type SwapStatus = "pending" | "clientfunded" | "clientrefunded" | "serverfunded" | "clientredeeming" | "clientredeemed" | "serverredeemed" | "clientfundedserverrefunded" | "clientrefundedserverfunded" | "clientrefundedserverrefunded" | "expired" | "clientinvalidfunded" | "clientfundedtoolate";
|
|
43
|
-
/**
|
|
44
|
-
* Common fields shared across all swap directions.
|
|
45
|
-
* These fields are flattened into the response by serde.
|
|
46
|
-
*/
|
|
47
|
-
export interface SwapCommonFields {
|
|
48
|
-
id: string;
|
|
49
|
-
status: SwapStatus;
|
|
50
|
-
hash_lock: string;
|
|
51
|
-
fee_sats: number;
|
|
52
|
-
asset_amount: number;
|
|
53
|
-
sender_pk: string;
|
|
54
|
-
receiver_pk: string;
|
|
55
|
-
server_pk: string;
|
|
56
|
-
refund_locktime: number;
|
|
57
|
-
unilateral_claim_delay: number;
|
|
58
|
-
unilateral_refund_delay: number;
|
|
59
|
-
unilateral_refund_without_receiver_delay: number;
|
|
60
|
-
network: string;
|
|
61
|
-
created_at: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* BTC to EVM swap response.
|
|
65
|
-
* Note: direction field is added by the SDK, not returned by the server.
|
|
66
|
-
*/
|
|
67
|
-
export interface BtcToEvmSwapResponse extends SwapCommonFields {
|
|
68
|
-
direction: "btc_to_evm";
|
|
69
|
-
htlc_address_evm: string;
|
|
70
|
-
htlc_address_arkade: string;
|
|
71
|
-
user_address_evm: string;
|
|
72
|
-
ln_invoice: string;
|
|
73
|
-
sats_receive: number;
|
|
74
|
-
source_token: TokenIdString;
|
|
75
|
-
target_token: TokenIdString;
|
|
76
|
-
bitcoin_htlc_claim_txid: string | null;
|
|
77
|
-
bitcoin_htlc_fund_txid: string | null;
|
|
78
|
-
evm_htlc_claim_txid: string | null;
|
|
79
|
-
evm_htlc_fund_txid: string | null;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* EVM to BTC swap response.
|
|
83
|
-
* Note: direction field is added by the SDK, not returned by the server.
|
|
84
|
-
*/
|
|
85
|
-
export interface EvmToBtcSwapResponse extends SwapCommonFields {
|
|
86
|
-
direction: "evm_to_btc";
|
|
87
|
-
htlc_address_evm: string;
|
|
88
|
-
htlc_address_arkade: string;
|
|
89
|
-
user_address_evm: string;
|
|
90
|
-
user_address_arkade: string | null;
|
|
91
|
-
ln_invoice: string;
|
|
92
|
-
source_token: TokenIdString;
|
|
93
|
-
target_token: TokenIdString;
|
|
94
|
-
sats_receive: number;
|
|
95
|
-
bitcoin_htlc_fund_txid: string | null;
|
|
96
|
-
bitcoin_htlc_claim_txid: string | null;
|
|
97
|
-
evm_htlc_claim_txid: string | null;
|
|
98
|
-
evm_htlc_fund_txid: string | null;
|
|
99
|
-
create_swap_tx: string | null;
|
|
100
|
-
approve_tx: string | null;
|
|
101
|
-
gelato_forwarder_address: string | null;
|
|
102
|
-
gelato_user_nonce: string | null;
|
|
103
|
-
gelato_user_deadline: string | null;
|
|
104
|
-
source_token_address: string;
|
|
105
|
-
}
|
|
14
|
+
export type TokenIdString = "btc_lightning" | "btc_arkade" | "btc_onchain" | "usdc_pol" | "usdt0_pol" | "usdc_eth" | "usdt_eth" | "xaut_eth" | (string & {});
|
|
106
15
|
/**
|
|
107
16
|
* Union type for swap responses based on direction.
|
|
17
|
+
* Uses WASM types directly - BtcToEvmSwapResponse and EvmToBtcSwapResponse are
|
|
18
|
+
* exported from the WASM module.
|
|
108
19
|
*/
|
|
109
|
-
export type GetSwapResponse = BtcToEvmSwapResponse | EvmToBtcSwapResponse;
|
|
20
|
+
export type GetSwapResponse = BtcToEvmSwapResponse | EvmToBtcSwapResponse | BtcToArkadeSwapResponse;
|
|
110
21
|
/**
|
|
111
|
-
* Extended swap storage data
|
|
112
|
-
* Used for
|
|
22
|
+
* Extended swap storage data combining the API response with client-side swap parameters.
|
|
23
|
+
* Used for storage providers and as a common interface for swap data.
|
|
113
24
|
*/
|
|
114
25
|
export interface ExtendedSwapStorageData {
|
|
115
|
-
response:
|
|
26
|
+
response: BtcToEvmSwapResponse | EvmToBtcSwapResponse | BtcToArkadeSwapResponse;
|
|
116
27
|
swap_params: SwapParams;
|
|
117
28
|
}
|
|
118
29
|
/**
|
|
119
30
|
* Request to create an Arkade to EVM swap (BTC → Token).
|
|
120
31
|
*/
|
|
121
32
|
export interface SwapRequest {
|
|
33
|
+
source_amount?: bigint;
|
|
122
34
|
target_address: string;
|
|
123
|
-
target_amount
|
|
35
|
+
target_amount?: number;
|
|
124
36
|
target_token: TokenIdString;
|
|
125
37
|
referral_code?: string;
|
|
126
38
|
}
|
|
@@ -143,6 +55,17 @@ export interface EvmToLightningSwapRequest {
|
|
|
143
55
|
user_address: string;
|
|
144
56
|
referral_code?: string;
|
|
145
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Request to create an on-chain Bitcoin to Arkade swap.
|
|
60
|
+
*/
|
|
61
|
+
export interface BtcToArkadeSwapRequest {
|
|
62
|
+
/** User's target Arkade address to receive VTXOs */
|
|
63
|
+
target_arkade_address: string;
|
|
64
|
+
/** Amount user wants to receive on Arkade in satoshis */
|
|
65
|
+
sats_receive: number;
|
|
66
|
+
/** Optional referral code */
|
|
67
|
+
referral_code?: string;
|
|
68
|
+
}
|
|
146
69
|
/**
|
|
147
70
|
* Gelato relay submit request.
|
|
148
71
|
*/
|
|
@@ -180,111 +103,158 @@ export interface QuoteRequest {
|
|
|
180
103
|
base_amount: number;
|
|
181
104
|
}
|
|
182
105
|
/**
|
|
183
|
-
*
|
|
184
|
-
*/
|
|
185
|
-
export interface VersionInfo {
|
|
186
|
-
tag: string;
|
|
187
|
-
commit_hash: string;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Quote response (snake_case for consistency with other API types).
|
|
191
|
-
*/
|
|
192
|
-
export interface QuoteResponseInfo {
|
|
193
|
-
exchange_rate: string;
|
|
194
|
-
network_fee: number;
|
|
195
|
-
protocol_fee: number;
|
|
196
|
-
protocol_fee_rate: number;
|
|
197
|
-
min_amount: number;
|
|
198
|
-
max_amount: number;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* VTXO swap status values.
|
|
202
|
-
* Note: WASM returns status as lowercase string (e.g., "pending", "clientfunded")
|
|
203
|
-
*/
|
|
204
|
-
export type VtxoSwapStatus = "pending" | "clientfunded" | "serverfunded" | "clientredeemed" | "serverredeemed" | "clientrefunded" | "clientfundedserverrefunded" | "expired";
|
|
205
|
-
/**
|
|
206
|
-
* Typed storage provider interface for wallet data (mnemonic, key index).
|
|
207
|
-
* Provides typed async methods for wallet credential storage.
|
|
106
|
+
* Network input type for Bitcoin networks (string union for API convenience).
|
|
208
107
|
*/
|
|
209
|
-
export
|
|
210
|
-
/** Get the mnemonic phrase. Returns null if not stored. */
|
|
211
|
-
getMnemonic: () => Promise<string | null>;
|
|
212
|
-
/** Store the mnemonic phrase. Overwrites any existing mnemonic. */
|
|
213
|
-
setMnemonic: (mnemonic: string) => Promise<void>;
|
|
214
|
-
/** Get the current key derivation index. Returns 0 if not set. */
|
|
215
|
-
getKeyIndex: () => Promise<number>;
|
|
216
|
-
/** Set the key derivation index. */
|
|
217
|
-
setKeyIndex: (index: number) => Promise<void>;
|
|
218
|
-
}
|
|
108
|
+
export type NetworkInput = "bitcoin" | "testnet" | "regtest" | "mutinynet";
|
|
219
109
|
/**
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
110
|
+
* Builder for constructing a Client with a fluent API.
|
|
111
|
+
*
|
|
112
|
+
* Uses IndexedDB storage via `.withIdbStorage()` for browser applications.
|
|
113
|
+
* For Node.js server-side applications, use `@lendasat/lendaswap-sdk-native` instead.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* import { Client } from '@lendasat/lendaswap-sdk';
|
|
118
|
+
*
|
|
119
|
+
* const client = await Client.builder()
|
|
120
|
+
* .url('https://api.lendaswap.com')
|
|
121
|
+
* .withIdbStorage()
|
|
122
|
+
* .network('bitcoin')
|
|
123
|
+
* .arkadeUrl('https://arkade.computer')
|
|
124
|
+
* .esploraUrl('https://mempool.space/api')
|
|
125
|
+
* .build();
|
|
126
|
+
* ```
|
|
223
127
|
*/
|
|
224
|
-
export
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
128
|
+
export declare class ClientBuilder {
|
|
129
|
+
private _url?;
|
|
130
|
+
private _storage?;
|
|
131
|
+
private _network?;
|
|
132
|
+
private _arkadeUrl?;
|
|
133
|
+
private _esploraUrl?;
|
|
134
|
+
constructor();
|
|
135
|
+
/**
|
|
136
|
+
* Set the Lendaswap API URL.
|
|
137
|
+
*/
|
|
138
|
+
url(url: string): this;
|
|
139
|
+
/**
|
|
140
|
+
* Use IndexedDB storage.
|
|
141
|
+
*
|
|
142
|
+
* This will automatically open the IndexedDB database when `build()` is called.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const client = await Client.builder()
|
|
147
|
+
* .url('https://api.lendaswap.com')
|
|
148
|
+
* .withIdbStorage()
|
|
149
|
+
* .network('bitcoin')
|
|
150
|
+
* .arkadeUrl('...')
|
|
151
|
+
* .esploraUrl('...')
|
|
152
|
+
* .build();
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
withIdbStorage(): this;
|
|
156
|
+
/**
|
|
157
|
+
* Set the storage handle directly (for advanced use cases).
|
|
158
|
+
* @deprecated Use `.withIdbStorage()` instead.
|
|
159
|
+
*/
|
|
160
|
+
storage(storage: IdbStorageHandle): this;
|
|
161
|
+
/**
|
|
162
|
+
* Set the Bitcoin network.
|
|
163
|
+
*/
|
|
164
|
+
network(network: NetworkInput): this;
|
|
165
|
+
/**
|
|
166
|
+
* Set the Arkade server URL.
|
|
167
|
+
*/
|
|
168
|
+
arkadeUrl(url: string): this;
|
|
169
|
+
/**
|
|
170
|
+
* Set the Esplora API URL for on-chain Bitcoin operations.
|
|
171
|
+
*/
|
|
172
|
+
esploraUrl(url: string): this;
|
|
173
|
+
/**
|
|
174
|
+
* Build the client asynchronously.
|
|
175
|
+
*
|
|
176
|
+
* @returns A Promise that resolves to a new Client instance
|
|
177
|
+
* @throws Error if any required field is missing or storage initialization fails
|
|
178
|
+
*/
|
|
179
|
+
build(): Promise<Client>;
|
|
235
180
|
}
|
|
236
181
|
/**
|
|
237
|
-
*
|
|
182
|
+
* Lendaswap client using IndexedDB storage.
|
|
183
|
+
*
|
|
184
|
+
* This client uses native Rust IndexedDB storage via the `idb` crate,
|
|
185
|
+
* eliminating the need for JavaScript storage callbacks.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* import { openIdbDatabase, Client } from '@lendasat/lendaswap-sdk';
|
|
190
|
+
*
|
|
191
|
+
* // Open the IndexedDB database
|
|
192
|
+
* const storage = await openIdbDatabase();
|
|
193
|
+
*
|
|
194
|
+
* // Create the client
|
|
195
|
+
* const client = await Client.create(
|
|
196
|
+
* 'https://api.lendaswap.com',
|
|
197
|
+
* storage,
|
|
198
|
+
* 'bitcoin',
|
|
199
|
+
* 'https://arkade.computer',
|
|
200
|
+
* 'https://mempool.space/api'
|
|
201
|
+
* );
|
|
202
|
+
*
|
|
203
|
+
* // Initialize wallet (generates mnemonic if needed)
|
|
204
|
+
* await client.init();
|
|
205
|
+
*
|
|
206
|
+
* // Get all swaps
|
|
207
|
+
* const swaps = await client.listAllSwaps();
|
|
208
|
+
* ```
|
|
238
209
|
*/
|
|
239
|
-
export type Network = "bitcoin" | "testnet" | "regtest" | "mutinynet";
|
|
240
210
|
export declare class Client {
|
|
241
|
-
private
|
|
211
|
+
private wasmClient;
|
|
242
212
|
private constructor();
|
|
243
213
|
/**
|
|
244
|
-
* Create a new
|
|
214
|
+
* Create a new ClientBuilder for constructing a client.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* const client = Client.builder()
|
|
219
|
+
* .url('https://api.lendaswap.com')
|
|
220
|
+
* .withIdbStorage()
|
|
221
|
+
* .network('bitcoin')
|
|
222
|
+
* .arkadeUrl('https://arkade.computer')
|
|
223
|
+
* .esploraUrl('https://mempool.space/api')
|
|
224
|
+
* .build();
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
static builder(): ClientBuilder;
|
|
228
|
+
/**
|
|
229
|
+
* Create a Client from a WASM client instance.
|
|
230
|
+
* Used internally by ClientBuilder.
|
|
231
|
+
*/
|
|
232
|
+
static fromWasmClient(wasmClient: WasmClient): Client;
|
|
233
|
+
/**
|
|
234
|
+
* Create a new Client instance with IndexedDB storage.
|
|
245
235
|
*
|
|
246
236
|
* @param baseUrl - The base URL of the Lendaswap API
|
|
247
|
-
* @param
|
|
248
|
-
* @param swapStorage - Storage provider for persisting swap data (uses Dexie/IndexedDB)
|
|
237
|
+
* @param storage - Storage handle from `openIdbDatabase()`
|
|
249
238
|
* @param network - Bitcoin network ("bitcoin", "testnet", "regtest", "mutinynet")
|
|
250
239
|
* @param arkadeUrl - Arkade's server url
|
|
251
|
-
* @param
|
|
240
|
+
* @param esploraUrl - Esplora API URL for on-chain Bitcoin operations (e.g., "https://mempool.space/api")
|
|
252
241
|
* @returns A new Client instance
|
|
253
242
|
*
|
|
254
243
|
* @example
|
|
255
244
|
* ```typescript
|
|
256
|
-
* import
|
|
257
|
-
*
|
|
258
|
-
* // Wallet storage using localStorage with typed methods
|
|
259
|
-
* const walletStorage: WalletStorageProvider = {
|
|
260
|
-
* getMnemonic: async () => localStorage.getItem('mnemonic'),
|
|
261
|
-
* setMnemonic: async (mnemonic) => localStorage.setItem('mnemonic', mnemonic),
|
|
262
|
-
* getKeyIndex: async () => parseInt(localStorage.getItem('key_index') ?? '0'),
|
|
263
|
-
* setKeyIndex: async (index) => localStorage.setItem('key_index', index.toString()),
|
|
264
|
-
* };
|
|
265
|
-
*
|
|
266
|
-
* // Swap storage using Dexie (IndexedDB)
|
|
267
|
-
* const db = new Dexie('lendaswap');
|
|
268
|
-
* db.version(1).stores({ swaps: 'id' });
|
|
269
|
-
*
|
|
270
|
-
* const swapStorage: SwapStorageProvider = {
|
|
271
|
-
* get: async (swapId) => await db.table('swaps').get(swapId) ?? null,
|
|
272
|
-
* store: async (swapId, data) => await db.table('swaps').put({ id: swapId, ...data }),
|
|
273
|
-
* delete: async (swapId) => await db.table('swaps').delete(swapId),
|
|
274
|
-
* list: async () => await db.table('swaps').toCollection().primaryKeys() as string[],
|
|
275
|
-
* getAll: async () => await db.table('swaps').toArray(),
|
|
276
|
-
* };
|
|
245
|
+
* import { openIdbDatabase, Client } from '@lendasat/lendaswap-sdk';
|
|
277
246
|
*
|
|
247
|
+
* const storage = await openIdbDatabase();
|
|
278
248
|
* const client = await Client.create(
|
|
279
249
|
* 'https://apilendaswap.lendasat.com',
|
|
280
|
-
*
|
|
281
|
-
* swapStorage,
|
|
250
|
+
* storage,
|
|
282
251
|
* 'bitcoin',
|
|
283
|
-
* 'https://arkade.computer'
|
|
252
|
+
* 'https://arkade.computer',
|
|
253
|
+
* 'https://mempool.space/api'
|
|
284
254
|
* );
|
|
285
255
|
* ```
|
|
286
256
|
*/
|
|
287
|
-
static create(baseUrl: string,
|
|
257
|
+
static create(baseUrl: string, storage: IdbStorageHandle, network: NetworkInput, arkadeUrl: string, esploraUrl: string): Promise<Client>;
|
|
288
258
|
init(mnemonic?: string): Promise<void>;
|
|
289
259
|
/**
|
|
290
260
|
* Create an Arkade to EVM swap (BTC → Token).
|
|
@@ -294,6 +264,14 @@ export declare class Client {
|
|
|
294
264
|
* @returns The created swap response
|
|
295
265
|
*/
|
|
296
266
|
createArkadeToEvmSwap(request: SwapRequest, targetNetwork: "ethereum" | "polygon"): Promise<BtcToEvmSwapResponse>;
|
|
267
|
+
/**
|
|
268
|
+
* Create a Lightning to EVM swap (BTC → Token).
|
|
269
|
+
*
|
|
270
|
+
* @param request - The swap request parameters
|
|
271
|
+
* @param targetNetwork - Target EVM network (e.g., 'polygon', 'ethereum')
|
|
272
|
+
* @returns The created swap response
|
|
273
|
+
*/
|
|
274
|
+
createLightningToEvmSwap(request: SwapRequest, targetNetwork: "ethereum" | "polygon"): Promise<BtcToEvmSwapResponse>;
|
|
297
275
|
/**
|
|
298
276
|
* Create an EVM to Arkade swap (Token → BTC).
|
|
299
277
|
*
|
|
@@ -320,18 +298,18 @@ export declare class Client {
|
|
|
320
298
|
* @param baseAmount - Amount in base units (satoshis for BTC, wei for EVM)
|
|
321
299
|
* @returns Quote response with exchange rate and fees
|
|
322
300
|
*/
|
|
323
|
-
getQuote(from: TokenIdString, to: TokenIdString, baseAmount: bigint): Promise<
|
|
301
|
+
getQuote(from: TokenIdString, to: TokenIdString, baseAmount: bigint): Promise<QuoteResponse>;
|
|
324
302
|
/**
|
|
325
303
|
* Get a swap by its ID.
|
|
326
304
|
*
|
|
327
305
|
* @param id - The swap ID
|
|
328
|
-
* @returns The swap
|
|
306
|
+
* @returns The swap data, or undefined if the swap type is unknown
|
|
329
307
|
*/
|
|
330
|
-
getSwap(id: string): Promise<ExtendedSwapStorageData>;
|
|
308
|
+
getSwap(id: string): Promise<ExtendedSwapStorageData | undefined>;
|
|
331
309
|
/**
|
|
332
310
|
* Gets all stored swaps.
|
|
333
311
|
*
|
|
334
|
-
* @returns
|
|
312
|
+
* @returns Array of swaps (unknown types are filtered out)
|
|
335
313
|
*/
|
|
336
314
|
listAllSwaps(): Promise<ExtendedSwapStorageData[]>;
|
|
337
315
|
/**
|
|
@@ -355,9 +333,10 @@ export declare class Client {
|
|
|
355
333
|
*/
|
|
356
334
|
claimVhtlc(swapId: string): Promise<void>;
|
|
357
335
|
/**
|
|
358
|
-
*
|
|
336
|
+
* Refund a swap VHTLC
|
|
359
337
|
*
|
|
360
338
|
* @param swapId - The swap ID
|
|
339
|
+
* @param refundAddress - The address to receive the refund
|
|
361
340
|
* @returns The TXID of the Ark transaction which refunded the VHTLC.
|
|
362
341
|
*/
|
|
363
342
|
refundVhtlc(swapId: string, refundAddress: string): Promise<string>;
|
|
@@ -366,11 +345,11 @@ export declare class Client {
|
|
|
366
345
|
*
|
|
367
346
|
* @returns Version information
|
|
368
347
|
*/
|
|
369
|
-
getVersion(): Promise<
|
|
348
|
+
getVersion(): Promise<Version>;
|
|
370
349
|
/**
|
|
371
350
|
* Recover swaps for the currently loaded mnemonic.
|
|
372
351
|
*
|
|
373
|
-
* @returns
|
|
352
|
+
* @returns Array of recovered swaps (unknown types are filtered out)
|
|
374
353
|
*/
|
|
375
354
|
recoverSwaps(): Promise<ExtendedSwapStorageData[]>;
|
|
376
355
|
/**
|
|
@@ -413,9 +392,9 @@ export declare class Client {
|
|
|
413
392
|
* Get VTXO swap details by ID.
|
|
414
393
|
*
|
|
415
394
|
* @param id - The swap ID
|
|
416
|
-
* @returns The VTXO swap
|
|
395
|
+
* @returns The extended VTXO swap data
|
|
417
396
|
*/
|
|
418
|
-
getVtxoSwap(id: string): Promise<
|
|
397
|
+
getVtxoSwap(id: string): Promise<ExtendedVtxoSwapStorageData>;
|
|
419
398
|
/**
|
|
420
399
|
* Claim the server's VHTLC in a VTXO swap.
|
|
421
400
|
*
|
|
@@ -434,12 +413,47 @@ export declare class Client {
|
|
|
434
413
|
* This can be called if the swap fails (e.g., server doesn't fund)
|
|
435
414
|
* and the client's locktime has expired.
|
|
436
415
|
*
|
|
437
|
-
* @param
|
|
438
|
-
* @param swapParams - The client's swap parameters
|
|
416
|
+
* @param swapId - The swap ID
|
|
439
417
|
* @param refundAddress - The Arkade address to receive the refunded funds
|
|
440
418
|
* @returns The refund transaction ID
|
|
441
419
|
*/
|
|
442
|
-
refundVtxoSwap(
|
|
420
|
+
refundVtxoSwap(swapId: string, refundAddress: string): Promise<string>;
|
|
421
|
+
/**
|
|
422
|
+
* List all VTXO swaps from local storage.
|
|
423
|
+
*
|
|
424
|
+
* Returns all stored VTXO swaps without fetching from the API.
|
|
425
|
+
*
|
|
426
|
+
* @returns Array of all stored extended VTXO swap data
|
|
427
|
+
*/
|
|
428
|
+
listAllVtxoSwaps(): Promise<ExtendedVtxoSwapStorageData[]>;
|
|
429
|
+
/**
|
|
430
|
+
* Create an on-chain Bitcoin to Arkade swap.
|
|
431
|
+
*
|
|
432
|
+
* User sends on-chain BTC to a P2WSH HTLC address, and receives Arkade VTXOs.
|
|
433
|
+
*
|
|
434
|
+
* @param request - The swap request parameters
|
|
435
|
+
* @returns The created swap response with P2WSH address to fund
|
|
436
|
+
*/
|
|
437
|
+
createBitcoinToArkadeSwap(request: BtcToArkadeSwapRequest): Promise<BtcToArkadeSwapResponse>;
|
|
438
|
+
/**
|
|
439
|
+
* Claim the Arkade VHTLC for a BTC-to-Arkade swap.
|
|
440
|
+
*
|
|
441
|
+
* This reveals the preimage/secret to claim funds on Arkade.
|
|
442
|
+
*
|
|
443
|
+
* @param swapId - The swap ID
|
|
444
|
+
* @returns The Arkade claim transaction ID
|
|
445
|
+
*/
|
|
446
|
+
claimBtcToArkadeVhtlc(swapId: string): Promise<string>;
|
|
447
|
+
/**
|
|
448
|
+
* Refund from the on-chain Bitcoin HTLC after timeout.
|
|
449
|
+
*
|
|
450
|
+
* This spends from the P2WSH HTLC back to the user's address.
|
|
451
|
+
*
|
|
452
|
+
* @param swapId - The swap ID
|
|
453
|
+
* @param refundAddress - The Bitcoin address to receive the refund
|
|
454
|
+
* @returns The refund transaction ID
|
|
455
|
+
*/
|
|
456
|
+
refundOnchainHtlc(swapId: string, refundAddress: string): Promise<string>;
|
|
443
457
|
}
|
|
444
458
|
/**
|
|
445
459
|
* Log level type for SDK logging configuration.
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,MAAM,IAAI,UAAU,EAEpB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EAEzB,KAAK,2BAA2B,EAEhC,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAElB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,EACL,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,IAAI,2BAA2B,EACtD,2BAA2B,EAC3B,gBAAgB,EAChB,OAAO,EACP,eAAe,EACf,aAAa,EACb,UAAU,IAAI,cAAc,EAC5B,UAAU,EACV,QAAQ,EACR,kBAAkB,EAClB,OAAO,EACP,SAAS,EACT,OAAO,EACP,YAAY,EACZ,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AAsBvC;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,YAAY,GACZ,aAAa,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