@lendasat/lendaswap-sdk 0.1.8 → 0.1.65
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/dist/api.d.ts +138 -160
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +174 -113
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- 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-calculations.test.d.ts +2 -0
- package/dist/price-calculations.test.d.ts.map +1 -0
- package/dist/price-calculations.test.js +173 -0
- package/dist/price-calculations.test.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/storage/dexieSwapStorage.d.ts +12 -10
- package/dist/storage/dexieSwapStorage.d.ts.map +1 -1
- package/dist/storage/dexieSwapStorage.js +63 -2
- package/dist/storage/dexieSwapStorage.js.map +1 -1
- package/dist/storage/dexieVtxoSwapStorage.d.ts +105 -0
- package/dist/storage/dexieVtxoSwapStorage.d.ts.map +1 -0
- package/dist/storage/dexieVtxoSwapStorage.js +149 -0
- package/dist/storage/dexieVtxoSwapStorage.js.map +1 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.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 +1 -1
- package/wasm/lendaswap_wasm_sdk.d.ts +361 -43
- package/wasm/lendaswap_wasm_sdk_bg.js +2499 -483
- package/wasm/lendaswap_wasm_sdk_bg.wasm +0 -0
- package/wasm/lendaswap_wasm_sdk_bg.wasm.d.ts +259 -65
package/dist/api.js
CHANGED
|
@@ -6,61 +6,33 @@
|
|
|
6
6
|
*/
|
|
7
7
|
// Import WASM types for internal use
|
|
8
8
|
// With --target bundler, WASM is automatically initialized via static import
|
|
9
|
-
import {
|
|
9
|
+
import { Client as WasmClient, getLogLevel as wasmGetLogLevel, JsSwapStorageProvider, JsVtxoSwapStorageProvider, JsWalletStorageProvider, setLogLevel as wasmSetLogLevel, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
10
10
|
// Re-export WASM types directly
|
|
11
|
-
export { CreateVtxoSwapResult, EstimateVtxoSwapResponse, QuoteResponse, SwapParams as VtxoSwapParams, TokenId, Version, VhtlcAmounts, VtxoSwapResponse, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
11
|
+
export { AssetPair, BtcToEvmSwapResponse, BtcToArkadeSwapResponse, Chain, CreateVtxoSwapResult, EstimateVtxoSwapResponse, EvmToBtcSwapResponse, ExtendedSwapStorageData as ExtendedSwapStorageDataWasm, ExtendedVtxoSwapStorageData, Network, QuoteResponse, SwapParams as VtxoSwapParams, SwapStatus, SwapType, swapStatusToString, TokenId, TokenInfo, Version, VhtlcAmounts, VtxoSwapResponse, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Convert WASM ExtendedSwapStorageData to plain TypeScript interface.
|
|
14
|
+
* Returns undefined if the swap response type is unknown.
|
|
14
15
|
*/
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
case WasmChain.Polygon:
|
|
22
|
-
return "Polygon";
|
|
23
|
-
case WasmChain.Ethereum:
|
|
24
|
-
return "Ethereum";
|
|
25
|
-
default:
|
|
26
|
-
return String(wasmChain);
|
|
16
|
+
function mapWasmSwapToInterface(wasmSwap) {
|
|
17
|
+
const response = wasmSwap.btcToEvmResponse ??
|
|
18
|
+
wasmSwap.evmToBtcResponse ??
|
|
19
|
+
wasmSwap.btcToArkadeResponse;
|
|
20
|
+
if (!response) {
|
|
21
|
+
return undefined;
|
|
27
22
|
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Map WASM TokenInfo to our typed TokenInfo.
|
|
31
|
-
*/
|
|
32
|
-
function mapTokenInfo(wasmToken) {
|
|
33
23
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
chain: mapChain(wasmToken.chain),
|
|
37
|
-
name: wasmToken.name,
|
|
38
|
-
decimals: wasmToken.decimals,
|
|
24
|
+
response,
|
|
25
|
+
swap_params: wasmSwap.swapParams,
|
|
39
26
|
};
|
|
40
27
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Map WASM AssetPair to our typed AssetPair.
|
|
43
|
-
*/
|
|
44
|
-
function mapAssetPair(wasmPair) {
|
|
45
|
-
return {
|
|
46
|
-
source: mapTokenInfo(wasmPair.source),
|
|
47
|
-
target: mapTokenInfo(wasmPair.target),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Convert a value from WASM (which may be a Map) to a plain object.
|
|
52
|
-
* serde_wasm_bindgen serializes structs as Maps by default.
|
|
53
|
-
*/
|
|
54
|
-
function fromWasm(value) {
|
|
55
|
-
if (value instanceof Map) {
|
|
56
|
-
return Object.fromEntries(value);
|
|
57
|
-
}
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
28
|
export class Client {
|
|
61
29
|
client;
|
|
62
|
-
|
|
30
|
+
baseUrl;
|
|
31
|
+
swapStorage;
|
|
32
|
+
constructor(client, baseUrl, swapStorage) {
|
|
63
33
|
this.client = client;
|
|
34
|
+
this.baseUrl = baseUrl;
|
|
35
|
+
this.swapStorage = swapStorage;
|
|
64
36
|
}
|
|
65
37
|
/**
|
|
66
38
|
* Create a new Client instance.
|
|
@@ -68,51 +40,45 @@ export class Client {
|
|
|
68
40
|
* @param baseUrl - The base URL of the Lendaswap API
|
|
69
41
|
* @param walletStorage - Storage provider for persisting wallet data (mnemonic, key index)
|
|
70
42
|
* @param swapStorage - Storage provider for persisting swap data (uses Dexie/IndexedDB)
|
|
43
|
+
* @param vtxoSwapStorage - Storage provider for persisting VTXO swap data (uses Dexie/IndexedDB)
|
|
71
44
|
* @param network - Bitcoin network ("bitcoin", "testnet", "regtest", "mutinynet")
|
|
72
45
|
* @param arkadeUrl - Arkade's server url
|
|
73
|
-
* @param
|
|
46
|
+
* @param esploraUrl - Esplora API URL for on-chain Bitcoin operations (e.g., "https://mempool.space/api")
|
|
74
47
|
* @returns A new Client instance
|
|
75
48
|
*
|
|
76
49
|
* @example
|
|
77
50
|
* ```typescript
|
|
78
|
-
* import
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* // Swap storage using Dexie (IndexedDB)
|
|
89
|
-
* const db = new Dexie('lendaswap');
|
|
90
|
-
* db.version(1).stores({ swaps: 'id' });
|
|
91
|
-
*
|
|
92
|
-
* const swapStorage: SwapStorageProvider = {
|
|
93
|
-
* get: async (swapId) => await db.table('swaps').get(swapId) ?? null,
|
|
94
|
-
* store: async (swapId, data) => await db.table('swaps').put({ id: swapId, ...data }),
|
|
95
|
-
* delete: async (swapId) => await db.table('swaps').delete(swapId),
|
|
96
|
-
* list: async () => await db.table('swaps').toCollection().primaryKeys() as string[],
|
|
97
|
-
* getAll: async () => await db.table('swaps').toArray(),
|
|
98
|
-
* };
|
|
51
|
+
* import {
|
|
52
|
+
* Client,
|
|
53
|
+
* createDexieWalletStorage,
|
|
54
|
+
* createDexieSwapStorage,
|
|
55
|
+
* createDexieVtxoSwapStorage
|
|
56
|
+
* } from '@lendasat/lendaswap-sdk';
|
|
57
|
+
*
|
|
58
|
+
* const walletStorage = createDexieWalletStorage();
|
|
59
|
+
* const swapStorage = createDexieSwapStorage();
|
|
60
|
+
* const vtxoSwapStorage = createDexieVtxoSwapStorage();
|
|
99
61
|
*
|
|
100
62
|
* const client = await Client.create(
|
|
101
63
|
* 'https://apilendaswap.lendasat.com',
|
|
102
64
|
* walletStorage,
|
|
103
65
|
* swapStorage,
|
|
66
|
+
* vtxoSwapStorage,
|
|
104
67
|
* 'bitcoin',
|
|
105
|
-
* 'https://arkade.computer'
|
|
68
|
+
* 'https://arkade.computer',
|
|
69
|
+
* 'https://mempool.space/api'
|
|
106
70
|
* );
|
|
107
71
|
* ```
|
|
108
72
|
*/
|
|
109
|
-
static async create(baseUrl, walletStorage, swapStorage, network, arkadeUrl) {
|
|
73
|
+
static async create(baseUrl, walletStorage, swapStorage, vtxoSwapStorage, network, arkadeUrl, esploraUrl) {
|
|
110
74
|
// Bind wallet storage methods to preserve 'this' context when called from WASM
|
|
111
75
|
const jsWalletStorageProvider = new JsWalletStorageProvider(walletStorage.getMnemonic.bind(walletStorage), walletStorage.setMnemonic.bind(walletStorage), walletStorage.getKeyIndex.bind(walletStorage), walletStorage.setKeyIndex.bind(walletStorage));
|
|
112
76
|
// Bind swap storage methods to preserve 'this' context when called from WASM
|
|
113
77
|
const jsSwapStorageProvider = new JsSwapStorageProvider(swapStorage.get.bind(swapStorage), swapStorage.store.bind(swapStorage), swapStorage.delete.bind(swapStorage), swapStorage.list.bind(swapStorage), swapStorage.getAll.bind(swapStorage));
|
|
114
|
-
|
|
115
|
-
|
|
78
|
+
// Bind VTXO swap storage methods to preserve 'this' context when called from WASM
|
|
79
|
+
const jsVtxoSwapStorageProvider = new JsVtxoSwapStorageProvider(vtxoSwapStorage.get.bind(vtxoSwapStorage), vtxoSwapStorage.store.bind(vtxoSwapStorage), vtxoSwapStorage.delete.bind(vtxoSwapStorage), vtxoSwapStorage.list.bind(vtxoSwapStorage), vtxoSwapStorage.getAll.bind(vtxoSwapStorage));
|
|
80
|
+
const wasmClient = new WasmClient(baseUrl, jsWalletStorageProvider, jsSwapStorageProvider, jsVtxoSwapStorageProvider, network, arkadeUrl, esploraUrl);
|
|
81
|
+
return new Client(wasmClient, baseUrl, swapStorage);
|
|
116
82
|
}
|
|
117
83
|
async init(mnemonic) {
|
|
118
84
|
await this.client.init(mnemonic);
|
|
@@ -125,10 +91,7 @@ export class Client {
|
|
|
125
91
|
* @returns The created swap response
|
|
126
92
|
*/
|
|
127
93
|
async createArkadeToEvmSwap(request, targetNetwork) {
|
|
128
|
-
|
|
129
|
-
// serde_wasm_bindgen returns a Map for complex structs, convert to plain object
|
|
130
|
-
const obj = fromWasm(response);
|
|
131
|
-
return { ...obj, direction: "btc_to_evm" };
|
|
94
|
+
return await this.client.createArkadeToEvmSwap(request.target_address, request.target_amount, request.target_token, targetNetwork, request.referral_code);
|
|
132
95
|
}
|
|
133
96
|
/**
|
|
134
97
|
* Create an EVM to Arkade swap (Token → BTC).
|
|
@@ -138,10 +101,7 @@ export class Client {
|
|
|
138
101
|
* @returns The created swap response
|
|
139
102
|
*/
|
|
140
103
|
async createEvmToArkadeSwap(request, sourceNetwork) {
|
|
141
|
-
|
|
142
|
-
// serde_wasm_bindgen returns a Map for complex structs, convert to plain object
|
|
143
|
-
const obj = fromWasm(response);
|
|
144
|
-
return { ...obj, direction: "evm_to_btc" };
|
|
104
|
+
return await this.client.createEvmToArkadeSwap(request.target_address, request.user_address, request.source_amount, request.source_token, sourceNetwork, request.referral_code);
|
|
145
105
|
}
|
|
146
106
|
/**
|
|
147
107
|
* Create an EVM to Lightning swap (Token → BTC).
|
|
@@ -151,18 +111,13 @@ export class Client {
|
|
|
151
111
|
* @returns The created swap response
|
|
152
112
|
*/
|
|
153
113
|
async createEvmToLightningSwap(request, sourceNetwork) {
|
|
154
|
-
|
|
155
|
-
// serde_wasm_bindgen returns a Map for complex structs, convert to plain object
|
|
156
|
-
const obj = fromWasm(response);
|
|
157
|
-
return { ...obj, direction: "evm_to_btc" };
|
|
114
|
+
return await this.client.createEvmToLightningSwap(request.bolt11_invoice, request.user_address, request.source_token, sourceNetwork, request.referral_code);
|
|
158
115
|
}
|
|
159
116
|
async getAssetPairs() {
|
|
160
|
-
|
|
161
|
-
return wasmPairs.map(mapAssetPair);
|
|
117
|
+
return await this.client.getAssetPairs();
|
|
162
118
|
}
|
|
163
119
|
async getTokens() {
|
|
164
|
-
|
|
165
|
-
return wasmTokens.map(mapTokenInfo);
|
|
120
|
+
return await this.client.getTokens();
|
|
166
121
|
}
|
|
167
122
|
/**
|
|
168
123
|
* Get a quote for a swap.
|
|
@@ -173,32 +128,25 @@ export class Client {
|
|
|
173
128
|
* @returns Quote response with exchange rate and fees
|
|
174
129
|
*/
|
|
175
130
|
async getQuote(from, to, baseAmount) {
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
exchange_rate: quote.exchangeRate,
|
|
179
|
-
network_fee: Number(quote.networkFee),
|
|
180
|
-
protocol_fee: Number(quote.protocolFee),
|
|
181
|
-
protocol_fee_rate: quote.protocolFeeRate,
|
|
182
|
-
min_amount: Number(quote.minAmount),
|
|
183
|
-
max_amount: Number(quote.maxAmount),
|
|
184
|
-
};
|
|
131
|
+
return await this.client.getQuote(from, to, baseAmount);
|
|
185
132
|
}
|
|
186
133
|
/**
|
|
187
134
|
* Get a swap by its ID.
|
|
188
135
|
*
|
|
189
136
|
* @param id - The swap ID
|
|
190
|
-
* @returns The swap
|
|
137
|
+
* @returns The swap data, or undefined if the swap type is unknown
|
|
191
138
|
*/
|
|
192
139
|
async getSwap(id) {
|
|
193
|
-
return (await this.client.getSwap(id));
|
|
140
|
+
return mapWasmSwapToInterface(await this.client.getSwap(id));
|
|
194
141
|
}
|
|
195
142
|
/**
|
|
196
143
|
* Gets all stored swaps.
|
|
197
144
|
*
|
|
198
|
-
* @returns
|
|
145
|
+
* @returns Array of swaps (unknown types are filtered out)
|
|
199
146
|
*/
|
|
200
147
|
async listAllSwaps() {
|
|
201
|
-
|
|
148
|
+
const wasmSwaps = await this.client.listAll();
|
|
149
|
+
return wasmSwaps.map(mapWasmSwapToInterface).filter((s) => s !== undefined);
|
|
202
150
|
}
|
|
203
151
|
/**
|
|
204
152
|
* Claim a swap via Gelato relay (gasless).
|
|
@@ -216,7 +164,7 @@ export class Client {
|
|
|
216
164
|
* @returns VhtlcAmounts
|
|
217
165
|
*/
|
|
218
166
|
async amountsForSwap(swapId) {
|
|
219
|
-
return
|
|
167
|
+
return await this.client.amountsForSwap(swapId);
|
|
220
168
|
}
|
|
221
169
|
/**
|
|
222
170
|
* Claim a swap VHTLC
|
|
@@ -241,19 +189,16 @@ export class Client {
|
|
|
241
189
|
* @returns Version information
|
|
242
190
|
*/
|
|
243
191
|
async getVersion() {
|
|
244
|
-
|
|
245
|
-
return {
|
|
246
|
-
tag: version.tag,
|
|
247
|
-
commit_hash: version.commitHash,
|
|
248
|
-
};
|
|
192
|
+
return await this.client.getVersion();
|
|
249
193
|
}
|
|
250
194
|
/**
|
|
251
195
|
* Recover swaps for the currently loaded mnemonic.
|
|
252
196
|
*
|
|
253
|
-
* @returns
|
|
197
|
+
* @returns Array of recovered swaps (unknown types are filtered out)
|
|
254
198
|
*/
|
|
255
199
|
async recoverSwaps() {
|
|
256
|
-
|
|
200
|
+
const wasmSwaps = await this.client.recoverSwaps();
|
|
201
|
+
return wasmSwaps.map(mapWasmSwapToInterface).filter((s) => s !== undefined);
|
|
257
202
|
}
|
|
258
203
|
/**
|
|
259
204
|
* Get current loaded mnemonic
|
|
@@ -281,6 +226,79 @@ export class Client {
|
|
|
281
226
|
async deleteSwap(id) {
|
|
282
227
|
return await this.client.deleteSwap(id);
|
|
283
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Get the list of swap IDs that failed to deserialize during the last listAllSwaps() call.
|
|
231
|
+
* These are "corrupted" entries that couldn't be loaded due to invalid or missing data.
|
|
232
|
+
*
|
|
233
|
+
* @returns Array of swap IDs that failed to load
|
|
234
|
+
*/
|
|
235
|
+
getCorruptedSwapIds() {
|
|
236
|
+
return this.client.getCorruptedSwapIds();
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Delete all corrupted swap entries from storage.
|
|
240
|
+
* Call this after listAllSwaps() to clean up entries that couldn't be deserialized.
|
|
241
|
+
*
|
|
242
|
+
* @returns The number of corrupted entries that were deleted
|
|
243
|
+
*/
|
|
244
|
+
async deleteCorruptedSwaps() {
|
|
245
|
+
return await this.client.deleteCorruptedSwaps();
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Attempt to repair corrupted swap entries by fetching missing data from the server.
|
|
249
|
+
*
|
|
250
|
+
* For each corrupted swap ID:
|
|
251
|
+
* 1. Reads the raw swap_params from local storage
|
|
252
|
+
* 2. Fetches the swap response from the server via GET /swap/:id
|
|
253
|
+
* 3. Combines them and stores the repaired entry
|
|
254
|
+
*
|
|
255
|
+
* @returns Object with repaired count and any failed IDs
|
|
256
|
+
*/
|
|
257
|
+
async repairCorruptedSwaps() {
|
|
258
|
+
const corruptedIds = this.getCorruptedSwapIds();
|
|
259
|
+
if (corruptedIds.length === 0) {
|
|
260
|
+
return { repaired: 0, failed: [] };
|
|
261
|
+
}
|
|
262
|
+
// Check if storage provider supports raw access
|
|
263
|
+
if (!this.swapStorage.getRawSwapParams) {
|
|
264
|
+
console.warn("Storage provider does not support getRawSwapParams - cannot repair corrupted entries");
|
|
265
|
+
return { repaired: 0, failed: corruptedIds };
|
|
266
|
+
}
|
|
267
|
+
const failed = [];
|
|
268
|
+
let repaired = 0;
|
|
269
|
+
for (const swapId of corruptedIds) {
|
|
270
|
+
try {
|
|
271
|
+
// Get raw swap_params from storage
|
|
272
|
+
const swapParams = await this.swapStorage.getRawSwapParams(swapId);
|
|
273
|
+
if (!swapParams) {
|
|
274
|
+
console.warn(`No swap_params found for corrupted swap ${swapId}`);
|
|
275
|
+
failed.push(swapId);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
// Fetch response from server
|
|
279
|
+
const response = await fetch(`${this.baseUrl}/swap/${swapId}`);
|
|
280
|
+
if (!response.ok) {
|
|
281
|
+
console.warn(`Failed to fetch swap ${swapId} from server: ${response.status}`);
|
|
282
|
+
failed.push(swapId);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
const serverResponse = await response.json();
|
|
286
|
+
// Combine and store
|
|
287
|
+
const repairedData = {
|
|
288
|
+
response: serverResponse,
|
|
289
|
+
swap_params: swapParams,
|
|
290
|
+
};
|
|
291
|
+
await this.swapStorage.store(swapId, repairedData);
|
|
292
|
+
repaired++;
|
|
293
|
+
console.log(`Repaired swap ${swapId}`);
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
console.error(`Error repairing swap ${swapId}:`, error);
|
|
297
|
+
failed.push(swapId);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return { repaired, failed };
|
|
301
|
+
}
|
|
284
302
|
// =========================================================================
|
|
285
303
|
// VTXO Swap Methods
|
|
286
304
|
// =========================================================================
|
|
@@ -310,7 +328,7 @@ export class Client {
|
|
|
310
328
|
* Get VTXO swap details by ID.
|
|
311
329
|
*
|
|
312
330
|
* @param id - The swap ID
|
|
313
|
-
* @returns The VTXO swap
|
|
331
|
+
* @returns The extended VTXO swap data
|
|
314
332
|
*/
|
|
315
333
|
async getVtxoSwap(id) {
|
|
316
334
|
return await this.client.getVtxoSwap(id);
|
|
@@ -335,13 +353,56 @@ export class Client {
|
|
|
335
353
|
* This can be called if the swap fails (e.g., server doesn't fund)
|
|
336
354
|
* and the client's locktime has expired.
|
|
337
355
|
*
|
|
338
|
-
* @param
|
|
339
|
-
* @param swapParams - The client's swap parameters
|
|
356
|
+
* @param swapId - The swap ID
|
|
340
357
|
* @param refundAddress - The Arkade address to receive the refunded funds
|
|
341
358
|
* @returns The refund transaction ID
|
|
342
359
|
*/
|
|
343
|
-
async refundVtxoSwap(
|
|
344
|
-
return await this.client.refundVtxoSwap(
|
|
360
|
+
async refundVtxoSwap(swapId, refundAddress) {
|
|
361
|
+
return await this.client.refundVtxoSwap(swapId, refundAddress);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* List all VTXO swaps from local storage.
|
|
365
|
+
*
|
|
366
|
+
* Returns all stored VTXO swaps without fetching from the API.
|
|
367
|
+
*
|
|
368
|
+
* @returns Array of all stored extended VTXO swap data
|
|
369
|
+
*/
|
|
370
|
+
async listAllVtxoSwaps() {
|
|
371
|
+
return await this.client.listAllVtxoSwaps();
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Create an on-chain Bitcoin to Arkade swap.
|
|
375
|
+
*
|
|
376
|
+
* User sends on-chain BTC to a P2WSH HTLC address, and receives Arkade VTXOs.
|
|
377
|
+
*
|
|
378
|
+
* @param request - The swap request parameters
|
|
379
|
+
* @returns The created swap response with P2WSH address to fund
|
|
380
|
+
*/
|
|
381
|
+
async createBitcoinToArkadeSwap(request) {
|
|
382
|
+
return await this.client.createBitcoinToArkadeSwap(request.target_arkade_address, BigInt(request.sats_receive), request.referral_code);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Claim the Arkade VHTLC for a BTC-to-Arkade swap.
|
|
386
|
+
*
|
|
387
|
+
* This reveals the preimage/secret to claim funds on Arkade.
|
|
388
|
+
*
|
|
389
|
+
* @param swapId - The swap ID
|
|
390
|
+
* @returns The Arkade claim transaction ID
|
|
391
|
+
*/
|
|
392
|
+
async claimBtcToArkadeVhtlc(swapId) {
|
|
393
|
+
return await this.client.claimBtcToArkadeVhtlc(swapId);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Refund from the on-chain Bitcoin HTLC after timeout.
|
|
397
|
+
*
|
|
398
|
+
* This spends from the P2WSH HTLC back to the user's address.
|
|
399
|
+
*
|
|
400
|
+
* @param swapId - The swap ID
|
|
401
|
+
* @param refundAddress - The Bitcoin address to receive the refund
|
|
402
|
+
* @returns The refund transaction ID
|
|
403
|
+
*/
|
|
404
|
+
async refundOnchainHtlc(swapId, refundAddress) {
|
|
405
|
+
return await this.client.refundOnchainHtlc(swapId, refundAddress);
|
|
345
406
|
}
|
|
346
407
|
}
|
|
347
408
|
/**
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qCAAqC;AACrC,6EAA6E;AAC7E,OAAO,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qCAAqC;AACrC,6EAA6E;AAC7E,OAAO,EAIL,MAAM,IAAI,UAAU,EAMpB,WAAW,IAAI,eAAe,EAC9B,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EAEvB,WAAW,IAAI,eAAe,GAM/B,MAAM,+BAA+B,CAAC;AAEvC,gCAAgC;AAChC,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,EACL,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,IAAI,2BAA2B,EACtD,2BAA2B,EAC3B,OAAO,EACP,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;AAEvC;;;GAGG;AACH,SAAS,sBAAsB,CAC7B,QAAqC;IAErC,MAAM,QAAQ,GACZ,QAAQ,CAAC,gBAAgB;QACzB,QAAQ,CAAC,gBAAgB;QACzB,QAAQ,CAAC,mBAAmB,CAAC;IAC/B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO;QACL,QAAQ;QACR,WAAW,EAAE,QAAQ,CAAC,UAAU;KACjC,CAAC;AACJ,CAAC;AAyLD,MAAM,OAAO,MAAM;IACT,MAAM,CAAa;IACnB,OAAO,CAAS;IAChB,WAAW,CAA8B;IAEjD,YACE,MAAkB,EAClB,OAAe,EACf,WAAwC;QAExC,IAAI,CAAC,MAAM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CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,yBAAyB,CAC7B,OAA+B;QAE/B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAChD,OAAO,CAAC,qBAAqB,EAC7B,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAC5B,OAAO,CAAC,aAAa,CACtB,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,qBAAqB,CAAC,MAAc;QACxC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,iBAAiB,CACrB,MAAc,EACd,aAAqB;QAErB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpE,CAAC;CACF;AAOD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,eAAe,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,eAAe,EAAc,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,17 +10,20 @@
|
|
|
10
10
|
* Client,
|
|
11
11
|
* createDexieWalletStorage,
|
|
12
12
|
* createDexieSwapStorage,
|
|
13
|
+
* createDexieVtxoSwapStorage,
|
|
13
14
|
* } from '@lendasat/lendaswap-sdk';
|
|
14
15
|
*
|
|
15
16
|
* // Create storage providers using Dexie (IndexedDB)
|
|
16
17
|
* const walletStorage = createDexieWalletStorage();
|
|
17
18
|
* const swapStorage = createDexieSwapStorage();
|
|
19
|
+
* const vtxoSwapStorage = createDexieVtxoSwapStorage();
|
|
18
20
|
*
|
|
19
21
|
* // Create client
|
|
20
22
|
* const client = await Client.create(
|
|
21
23
|
* 'https://apilendaswap.lendasat.com',
|
|
22
24
|
* walletStorage,
|
|
23
25
|
* swapStorage,
|
|
26
|
+
* vtxoSwapStorage,
|
|
24
27
|
* 'bitcoin',
|
|
25
28
|
* 'https://arkade.computer'
|
|
26
29
|
* );
|
|
@@ -34,10 +37,11 @@
|
|
|
34
37
|
*
|
|
35
38
|
* @packageDocumentation
|
|
36
39
|
*/
|
|
37
|
-
export type {
|
|
38
|
-
export { type AssetPair, type BtcToEvmSwapResponse, type Chain, Client, CreateVtxoSwapResult, EstimateVtxoSwapResponse, type EvmToArkadeSwapRequest, type EvmToBtcSwapResponse, type EvmToLightningSwapRequest, type ExtendedSwapStorageData, type GelatoSubmitRequest, type GelatoSubmitResponse, type GetSwapResponse, getLogLevel, type LogLevel, type QuoteRequest, type RecoveredSwap, type RecoverSwapsResponse, type
|
|
40
|
+
export type { NetworkInput } from "./api.js";
|
|
41
|
+
export { type AssetPair, type BtcToArkadeSwapRequest, type BtcToArkadeSwapResponse, type BtcToEvmSwapResponse, type Chain, Client, CreateVtxoSwapResult, EstimateVtxoSwapResponse, type EvmToArkadeSwapRequest, type EvmToBtcSwapResponse, type EvmToLightningSwapRequest, type ExtendedSwapStorageData, type ExtendedSwapStorageDataWasm, type ExtendedSwapStorageProvider, ExtendedVtxoSwapStorageData, type GelatoSubmitRequest, type GelatoSubmitResponse, type GetSwapResponse, getLogLevel, type LogLevel, type Network, type QuoteRequest, QuoteResponse, type RecoveredSwap, type RecoverSwapsResponse, type SwapRequest, SwapStatus, swapStatusToString, type SwapStorageProvider, type SwapType, setLogLevel, TokenId, type TokenIdString, type TokenInfo, Version, VhtlcAmounts, VtxoSwapParams, VtxoSwapResponse, type VtxoSwapStorageProvider, type WalletStorageProvider, } from "./api.js";
|
|
39
42
|
export { PriceFeedService, type PriceTiers, type PriceUpdateCallback, type PriceUpdateMessage, type TradingPairPrices, } from "./price-feed.js";
|
|
40
|
-
export {
|
|
41
|
-
export
|
|
43
|
+
export { calculateSourceAmount, calculateTargetAmount, computeExchangeRate, selectTierRate, } from "./price-calculations.js";
|
|
44
|
+
export { createDexieSwapStorage, createDexieVtxoSwapStorage, createDexieWalletStorage, DexieSwapStorageProvider, DexieVtxoSwapStorageProvider, DexieWalletStorageProvider, STORAGE_KEYS, } from "./storage/index.js";
|
|
45
|
+
export type { SwapData, SwapParams } from "./types.js";
|
|
42
46
|
export { type GetUsdPriceOptions, getCoinGeckoId, getSupportedTokensForUsdPrice, getUsdPrice, getUsdPrices, type UsdPriceResult, } from "./usd-price.js";
|
|
43
47
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK7C,OAAO,EACL,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,KAAK,EACV,MAAM,EACN,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,WAAW,EACX,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,UAAU,EACV,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,WAAW,EACX,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,OAAO,EACP,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,GACf,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,0BAA0B,EAC1B,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EACL,KAAK,kBAAkB,EACvB,cAAc,EACd,6BAA6B,EAC7B,WAAW,EACX,YAAY,EACZ,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,17 +10,20 @@
|
|
|
10
10
|
* Client,
|
|
11
11
|
* createDexieWalletStorage,
|
|
12
12
|
* createDexieSwapStorage,
|
|
13
|
+
* createDexieVtxoSwapStorage,
|
|
13
14
|
* } from '@lendasat/lendaswap-sdk';
|
|
14
15
|
*
|
|
15
16
|
* // Create storage providers using Dexie (IndexedDB)
|
|
16
17
|
* const walletStorage = createDexieWalletStorage();
|
|
17
18
|
* const swapStorage = createDexieSwapStorage();
|
|
19
|
+
* const vtxoSwapStorage = createDexieVtxoSwapStorage();
|
|
18
20
|
*
|
|
19
21
|
* // Create client
|
|
20
22
|
* const client = await Client.create(
|
|
21
23
|
* 'https://apilendaswap.lendasat.com',
|
|
22
24
|
* walletStorage,
|
|
23
25
|
* swapStorage,
|
|
26
|
+
* vtxoSwapStorage,
|
|
24
27
|
* 'bitcoin',
|
|
25
28
|
* 'https://arkade.computer'
|
|
26
29
|
* );
|
|
@@ -34,12 +37,17 @@
|
|
|
34
37
|
*
|
|
35
38
|
* @packageDocumentation
|
|
36
39
|
*/
|
|
40
|
+
// Re-export WASM types that are commonly used
|
|
41
|
+
// Storage provider types for Client.create()
|
|
37
42
|
// API client
|
|
38
|
-
export
|
|
43
|
+
// Re-export WASM types and API types
|
|
44
|
+
export { Client, CreateVtxoSwapResult, EstimateVtxoSwapResponse, ExtendedVtxoSwapStorageData, getLogLevel, QuoteResponse, SwapStatus, swapStatusToString, setLogLevel, TokenId, Version, VhtlcAmounts, VtxoSwapParams, VtxoSwapResponse, } from "./api.js";
|
|
39
45
|
export { PriceFeedService, } from "./price-feed.js";
|
|
46
|
+
export { calculateSourceAmount, calculateTargetAmount, computeExchangeRate, selectTierRate, } from "./price-calculations.js";
|
|
40
47
|
// Storage (wallet data)
|
|
41
48
|
// Swap storage (typed swap data using Dexie/IndexedDB)
|
|
49
|
+
// VTXO swap storage (typed VTXO swap data using Dexie/IndexedDB)
|
|
42
50
|
// Wallet storage (typed wallet data using Dexie/IndexedDB)
|
|
43
|
-
export { createDexieSwapStorage, createDexieWalletStorage, DexieSwapStorageProvider, DexieWalletStorageProvider, STORAGE_KEYS, } from "./storage/index.js";
|
|
51
|
+
export { createDexieSwapStorage, createDexieVtxoSwapStorage, createDexieWalletStorage, DexieSwapStorageProvider, DexieVtxoSwapStorageProvider, DexieWalletStorageProvider, STORAGE_KEYS, } from "./storage/index.js";
|
|
44
52
|
export { getCoinGeckoId, getSupportedTokensForUsdPrice, getUsdPrice, getUsdPrices, } from "./usd-price.js";
|
|
45
53
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAGH,8CAA8C;AAC9C,6CAA6C;AAC7C,aAAa;AACb,qCAAqC;AACrC,OAAO,EAML,MAAM,EACN,oBAAoB,EACpB,wBAAwB,EAOxB,2BAA2B,EAI3B,WAAW,EAIX,aAAa,EAIb,UAAU,EACV,kBAAkB,EAGlB,WAAW,EACX,OAAO,EAGP,OAAO,EACP,YAAY,EACZ,cAAc,EACd,gBAAgB,GAGjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,GAKjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,wBAAwB;AACxB,uDAAuD;AACvD,iEAAiE;AACjE,2DAA2D;AAC3D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,0BAA0B,EAC1B,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEL,cAAc,EACd,6BAA6B,EAC7B,WAAW,EACX,YAAY,GAEb,MAAM,gBAAgB,CAAC"}
|