@bestinslot/wallet-kit 0.10.0 → 0.12.0
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 +4 -6
- package/dist/{balances-BWhpck6N.js → balances-Ci1sYbGa.js} +1625 -1569
- package/dist/browser.js +7 -9
- package/dist/core.js +5 -5
- package/dist/{mint-CA_-62SJ.js → mint-Dm67SjcM.js} +103 -171
- package/dist/node.js +10 -14
- package/dist/react.js +1 -1
- package/dist/{register-browser-providers-_EU6DoLd.js → register-browser-providers-BTO9Kyf2.js} +38 -73
- package/dist/types/api/swap.d.ts +17 -4
- package/dist/types/api/wallet.node.d.ts +1 -1
- package/dist/types/core/bis_swap.d.ts +64 -17
- package/dist/types/lib/fee-policy.d.ts +41 -0
- package/dist/types/lib/swap-reporting.d.ts +22 -0
- package/dist/vue.js +1 -1
- package/package.json +10 -3
package/dist/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { x as fI, y as KA, B as f, z as eI, A as tI, C as RA, D as d, E as SI, F as ZA, G as e, H as UA, I as nI, J as pI, K as rI, L as FI, M as sI, N as KI, O as BA, d as zA, i as eA,
|
|
2
|
-
import { o as LQ, v as TQ, n as ZQ, r as zQ, p as mQ, q as XQ, t as WQ, w as _Q, u as $Q } from "./mint-
|
|
3
|
-
import { s as bI } from "./balances-
|
|
4
|
-
import { c as IC, b as gC, m as QC, a as CC } from "./balances-
|
|
1
|
+
import { x as fI, y as KA, B as f, z as eI, A as tI, C as RA, D as d, E as SI, F as ZA, G as e, H as UA, I as nI, J as pI, K as rI, L as FI, M as sI, N as KI, O as BA, d as zA, i as eA, P as RI, c as UI, Q as qI, W as VI, a as lI, b as dI, e as xI, f as YI, h as JI, s as PI, j as vI, k as OI, l as uI, m as jI } from "./mint-Dm67SjcM.js";
|
|
2
|
+
import { o as LQ, v as TQ, n as ZQ, r as zQ, p as mQ, q as XQ, t as WQ, w as _Q, u as $Q } from "./mint-Dm67SjcM.js";
|
|
3
|
+
import { s as bI } from "./balances-Ci1sYbGa.js";
|
|
4
|
+
import { c as IC, b as gC, m as QC, a as CC } from "./balances-Ci1sYbGa.js";
|
|
5
5
|
var LI = fI();
|
|
6
6
|
const qA = {
|
|
7
7
|
messagePrefix: `Bitcoin Signed Message:
|
|
@@ -1334,7 +1334,7 @@ async function MI(A, I, g = "p2wpkh", Q = "unisat") {
|
|
|
1334
1334
|
pubkey: e.from(C.keyPair.publicKey).toString("hex"),
|
|
1335
1335
|
purpose: "all"
|
|
1336
1336
|
};
|
|
1337
|
-
return
|
|
1337
|
+
return RI({
|
|
1338
1338
|
provider: "local",
|
|
1339
1339
|
wallets: [D],
|
|
1340
1340
|
signature: null
|
|
@@ -1398,8 +1398,7 @@ async function VQ() {
|
|
|
1398
1398
|
async function lQ() {
|
|
1399
1399
|
await gA();
|
|
1400
1400
|
const A = await z();
|
|
1401
|
-
if (!A)
|
|
1402
|
-
throw new Error("No private key found.");
|
|
1401
|
+
if (!A) throw new Error("No private key found.");
|
|
1403
1402
|
return [
|
|
1404
1403
|
{
|
|
1405
1404
|
address: A.address,
|
|
@@ -1412,8 +1411,7 @@ async function dQ(A) {
|
|
|
1412
1411
|
await gA();
|
|
1413
1412
|
try {
|
|
1414
1413
|
const I = await z();
|
|
1415
|
-
if (!I)
|
|
1416
|
-
throw new Error("No private key found.");
|
|
1414
|
+
if (!I) throw new Error("No private key found.");
|
|
1417
1415
|
if (I.walletType === "p2wpkh" || I.walletType === "p2tr")
|
|
1418
1416
|
return e.from(
|
|
1419
1417
|
sI.Signer.sign(I.keyPair.toWIF(), I.address, A),
|
|
@@ -1427,8 +1425,7 @@ async function dQ(A) {
|
|
|
1427
1425
|
async function xQ(A) {
|
|
1428
1426
|
await gA();
|
|
1429
1427
|
const I = await z();
|
|
1430
|
-
if (!I)
|
|
1431
|
-
throw new Error("No payment wallet found.");
|
|
1428
|
+
if (!I) throw new Error("No payment wallet found.");
|
|
1432
1429
|
const g = I.address;
|
|
1433
1430
|
try {
|
|
1434
1431
|
if (I.walletType === "p2wpkh" || I.walletType === "p2tr") {
|
|
@@ -1446,8 +1443,7 @@ async function xQ(A) {
|
|
|
1446
1443
|
async function fA(A, I, g) {
|
|
1447
1444
|
await gA();
|
|
1448
1445
|
const Q = await z();
|
|
1449
|
-
if (!Q)
|
|
1450
|
-
throw new Error("No private key found.");
|
|
1446
|
+
if (!Q) throw new Error("No private key found.");
|
|
1451
1447
|
const C = d.Psbt.fromBase64(A);
|
|
1452
1448
|
let D = null;
|
|
1453
1449
|
if (g.length === 0)
|
|
@@ -1532,7 +1528,7 @@ async function YQ(A, I, g) {
|
|
|
1532
1528
|
return y.txId;
|
|
1533
1529
|
}
|
|
1534
1530
|
function JQ() {
|
|
1535
|
-
S.remove(GA), S.remove(IA), S.remove(wA), S.remove(HI),
|
|
1531
|
+
S.remove(GA), S.remove(IA), S.remove(wA), S.remove(HI), UI();
|
|
1536
1532
|
}
|
|
1537
1533
|
const PQ = {
|
|
1538
1534
|
getWallets: lQ,
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useSyncExternalStore as u, useCallback as r, useState as w } from "react";
|
|
2
|
-
import { R as c, d as t, i as l, h as n } from "./mint-
|
|
2
|
+
import { R as c, d as t, i as l, h as n } from "./mint-Dm67SjcM.js";
|
|
3
3
|
function m() {
|
|
4
4
|
const e = u(c, t, t), s = r((o) => l(o), []);
|
|
5
5
|
return [e, s];
|
package/dist/{register-browser-providers-_EU6DoLd.js → register-browser-providers-BTO9Kyf2.js}
RENAMED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { D as l, C as x, E as b, d, S as B, G as p, f as S, T, Q as P } from "./mint-
|
|
1
|
+
import { D as l, C as x, E as b, d, S as B, G as p, f as S, T, Q as P } from "./mint-Dm67SjcM.js";
|
|
2
2
|
async function X() {
|
|
3
|
-
if (!window.LeatherProvider)
|
|
4
|
-
throw new Error("Leather extension not found.");
|
|
3
|
+
if (!window.LeatherProvider) throw new Error("Leather extension not found.");
|
|
5
4
|
const e = await window.LeatherProvider.request("getAddresses");
|
|
6
|
-
if (!e)
|
|
7
|
-
throw new Error("Failed to get wallets.");
|
|
5
|
+
if (!e) throw new Error("Failed to get wallets.");
|
|
8
6
|
return e.result.addresses.map((t) => ({
|
|
9
7
|
address: t.address,
|
|
10
8
|
pubkey: t.publicKey || null,
|
|
@@ -12,10 +10,8 @@ async function X() {
|
|
|
12
10
|
}));
|
|
13
11
|
}
|
|
14
12
|
async function $(e, n) {
|
|
15
|
-
if (!window.LeatherProvider)
|
|
16
|
-
|
|
17
|
-
if (!n)
|
|
18
|
-
throw new Error("Wallet type is required for signing messages with Leather.");
|
|
13
|
+
if (!window.LeatherProvider) throw new Error("Leather extension not found.");
|
|
14
|
+
if (!n) throw new Error("Wallet type is required for signing messages with Leather.");
|
|
19
15
|
try {
|
|
20
16
|
const t = await window.LeatherProvider.request("signMessage", {
|
|
21
17
|
message: e,
|
|
@@ -28,8 +24,7 @@ async function $(e, n) {
|
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
26
|
async function L(e) {
|
|
31
|
-
if (!window.LeatherProvider)
|
|
32
|
-
throw new Error("Leather extension not found.");
|
|
27
|
+
if (!window.LeatherProvider) throw new Error("Leather extension not found.");
|
|
33
28
|
try {
|
|
34
29
|
const n = await window.LeatherProvider.request("signMessage", {
|
|
35
30
|
message: e,
|
|
@@ -45,8 +40,7 @@ async function L(e) {
|
|
|
45
40
|
}
|
|
46
41
|
}
|
|
47
42
|
async function F(e, n) {
|
|
48
|
-
if (!window.LeatherProvider)
|
|
49
|
-
throw new Error("Leather extension not found.");
|
|
43
|
+
if (!window.LeatherProvider) throw new Error("Leather extension not found.");
|
|
50
44
|
try {
|
|
51
45
|
return (await window.LeatherProvider.request("sendTransfer", {
|
|
52
46
|
recipients: [
|
|
@@ -62,8 +56,7 @@ async function F(e, n) {
|
|
|
62
56
|
}
|
|
63
57
|
}
|
|
64
58
|
async function M(e, n, t) {
|
|
65
|
-
if (!window.LeatherProvider)
|
|
66
|
-
throw new Error("Leather extension not found.");
|
|
59
|
+
if (!window.LeatherProvider) throw new Error("Leather extension not found.");
|
|
67
60
|
const s = [];
|
|
68
61
|
for (let i = 0; i < t.length; i++)
|
|
69
62
|
for (let r = 0; r < t[i].signingIndexes.length; r++)
|
|
@@ -107,19 +100,14 @@ const A = {
|
|
|
107
100
|
sign: I
|
|
108
101
|
};
|
|
109
102
|
async function K() {
|
|
110
|
-
if (!window.okxwallet)
|
|
111
|
-
throw new Error("OKX extension not found.");
|
|
103
|
+
if (!window.okxwallet) throw new Error("OKX extension not found.");
|
|
112
104
|
const e = d();
|
|
113
105
|
let n;
|
|
114
|
-
if (e === "mainnet")
|
|
115
|
-
|
|
116
|
-
else if (e === "
|
|
117
|
-
n = await window.okxwallet.bitcoinTestnet.connect();
|
|
118
|
-
else if (e === "signet")
|
|
119
|
-
n = await window.okxwallet.bitcoinSignet.connect();
|
|
106
|
+
if (e === "mainnet") n = await window.okxwallet.bitcoin.connect();
|
|
107
|
+
else if (e === "testnet") n = await window.okxwallet.bitcoinTestnet.connect();
|
|
108
|
+
else if (e === "signet") n = await window.okxwallet.bitcoinSignet.connect();
|
|
120
109
|
else throw new Error("Unsupported network for OKX.");
|
|
121
|
-
if (!n)
|
|
122
|
-
throw new Error("Error fetching wallet data.");
|
|
110
|
+
if (!n) throw new Error("Error fetching wallet data.");
|
|
123
111
|
return [
|
|
124
112
|
{
|
|
125
113
|
address: n.address,
|
|
@@ -130,12 +118,9 @@ async function K() {
|
|
|
130
118
|
}
|
|
131
119
|
function C() {
|
|
132
120
|
const e = d();
|
|
133
|
-
if (e === "mainnet")
|
|
134
|
-
|
|
135
|
-
if (e === "
|
|
136
|
-
return window.okxwallet?.bitcoinTestnet;
|
|
137
|
-
if (e === "signet")
|
|
138
|
-
return window.okxwallet?.bitcoinSignet;
|
|
121
|
+
if (e === "mainnet") return window.okxwallet?.bitcoin;
|
|
122
|
+
if (e === "testnet") return window.okxwallet?.bitcoinTestnet;
|
|
123
|
+
if (e === "signet") return window.okxwallet?.bitcoinSignet;
|
|
139
124
|
}
|
|
140
125
|
async function U() {
|
|
141
126
|
const e = C();
|
|
@@ -143,15 +128,13 @@ async function U() {
|
|
|
143
128
|
}
|
|
144
129
|
function D(e) {
|
|
145
130
|
const n = C();
|
|
146
|
-
if (typeof n?.on != "function")
|
|
147
|
-
|
|
148
|
-
};
|
|
131
|
+
if (typeof n?.on != "function") return () => {
|
|
132
|
+
};
|
|
149
133
|
const t = (s) => e(s?.address ? [s.address] : []);
|
|
150
134
|
return n.on("accountChanged", t), () => n.removeListener?.("accountChanged", t);
|
|
151
135
|
}
|
|
152
136
|
async function N(e) {
|
|
153
|
-
if (!window.okxwallet)
|
|
154
|
-
throw new Error("OKX extension not found.");
|
|
137
|
+
if (!window.okxwallet) throw new Error("OKX extension not found.");
|
|
155
138
|
const n = d();
|
|
156
139
|
let t;
|
|
157
140
|
if (n === "mainnet")
|
|
@@ -164,11 +147,9 @@ async function N(e) {
|
|
|
164
147
|
return p.from(t, "base64").toString("hex");
|
|
165
148
|
}
|
|
166
149
|
async function q(e) {
|
|
167
|
-
if (!window.okxwallet)
|
|
168
|
-
throw new Error("OKX extension not found.");
|
|
150
|
+
if (!window.okxwallet) throw new Error("OKX extension not found.");
|
|
169
151
|
const n = S();
|
|
170
|
-
if (!n)
|
|
171
|
-
throw new Error("No payment wallet found.");
|
|
152
|
+
if (!n) throw new Error("No payment wallet found.");
|
|
172
153
|
const t = n.address, s = d();
|
|
173
154
|
let o;
|
|
174
155
|
if (s === "mainnet")
|
|
@@ -184,8 +165,7 @@ async function q(e) {
|
|
|
184
165
|
};
|
|
185
166
|
}
|
|
186
167
|
async function O(e, n) {
|
|
187
|
-
if (!window.okxwallet)
|
|
188
|
-
throw new Error("OKX extension not found.");
|
|
168
|
+
if (!window.okxwallet) throw new Error("OKX extension not found.");
|
|
189
169
|
const t = d();
|
|
190
170
|
let s;
|
|
191
171
|
if (t === "mainnet")
|
|
@@ -269,16 +249,14 @@ const _ = {
|
|
|
269
249
|
sign: W
|
|
270
250
|
};
|
|
271
251
|
async function k() {
|
|
272
|
-
if (!window.unisat)
|
|
273
|
-
throw new Error("UniSat not found.");
|
|
252
|
+
if (!window.unisat) throw new Error("UniSat not found.");
|
|
274
253
|
const e = await window.unisat.getNetwork(), n = d();
|
|
275
254
|
e !== "livenet" && n === "mainnet" ? await window.unisat.switchNetwork("livenet") : e === "livenet" && (n === "testnet" || n === "signet") && await window.unisat.switchNetwork("testnet");
|
|
276
255
|
}
|
|
277
256
|
async function G() {
|
|
278
257
|
await k();
|
|
279
258
|
const e = await window.unisat?.requestAccounts(), n = await window.unisat?.getPublicKey();
|
|
280
|
-
if (!e)
|
|
281
|
-
throw new Error("Failed to get wallets.");
|
|
259
|
+
if (!e) throw new Error("Failed to get wallets.");
|
|
282
260
|
return e.map((s) => ({
|
|
283
261
|
address: s,
|
|
284
262
|
pubkey: n,
|
|
@@ -290,9 +268,8 @@ async function z() {
|
|
|
290
268
|
}
|
|
291
269
|
function R(e) {
|
|
292
270
|
const n = window.unisat;
|
|
293
|
-
if (!n?.on)
|
|
294
|
-
|
|
295
|
-
};
|
|
271
|
+
if (!n?.on) return () => {
|
|
272
|
+
};
|
|
296
273
|
const t = (s) => e(s ?? []);
|
|
297
274
|
return n.on("accountsChanged", t), () => n.removeListener?.("accountsChanged", t);
|
|
298
275
|
}
|
|
@@ -308,8 +285,7 @@ async function j(e) {
|
|
|
308
285
|
async function Q(e) {
|
|
309
286
|
await k();
|
|
310
287
|
const n = S();
|
|
311
|
-
if (!n)
|
|
312
|
-
throw new Error("No payment wallet found.");
|
|
288
|
+
if (!n) throw new Error("No payment wallet found.");
|
|
313
289
|
const t = n.address;
|
|
314
290
|
try {
|
|
315
291
|
const s = await window.unisat.signMessage(e, "ecdsa");
|
|
@@ -330,8 +306,7 @@ async function V(e, n) {
|
|
|
330
306
|
}
|
|
331
307
|
}
|
|
332
308
|
async function E(e, n, t) {
|
|
333
|
-
if (await k(), !window.unisat)
|
|
334
|
-
throw new Error("UniSat not found.");
|
|
309
|
+
if (await k(), !window.unisat) throw new Error("UniSat not found.");
|
|
335
310
|
const s = B(e);
|
|
336
311
|
let o = null;
|
|
337
312
|
if (t.length === 0)
|
|
@@ -401,17 +376,13 @@ const Y = {
|
|
|
401
376
|
};
|
|
402
377
|
function y() {
|
|
403
378
|
const e = d();
|
|
404
|
-
if (e === "mainnet")
|
|
405
|
-
|
|
406
|
-
if (e === "
|
|
407
|
-
return "Testnet4";
|
|
408
|
-
if (e === "signet")
|
|
409
|
-
return "Signet";
|
|
379
|
+
if (e === "mainnet") return "Mainnet";
|
|
380
|
+
if (e === "testnet") return "Testnet4";
|
|
381
|
+
if (e === "signet") return "Signet";
|
|
410
382
|
throw new Error("Unknown BTC network type.");
|
|
411
383
|
}
|
|
412
384
|
async function Z() {
|
|
413
|
-
if (!window.XverseProviders?.BitcoinProvider)
|
|
414
|
-
throw new Error("Xverse extension not found.");
|
|
385
|
+
if (!window.XverseProviders?.BitcoinProvider) throw new Error("Xverse extension not found.");
|
|
415
386
|
const e = T({
|
|
416
387
|
purposes: ["ordinals", "payment"],
|
|
417
388
|
message: "[Best in Slot] wants to know your addresses!",
|
|
@@ -419,8 +390,7 @@ async function Z() {
|
|
|
419
390
|
type: y()
|
|
420
391
|
}
|
|
421
392
|
}), n = await window.XverseProviders.BitcoinProvider?.connect(e);
|
|
422
|
-
if (!n)
|
|
423
|
-
throw new Error("Error fetching wallet data.");
|
|
393
|
+
if (!n) throw new Error("Error fetching wallet data.");
|
|
424
394
|
return n.addresses.map((s) => ({
|
|
425
395
|
address: s.address,
|
|
426
396
|
pubkey: s.publicKey,
|
|
@@ -428,8 +398,7 @@ async function Z() {
|
|
|
428
398
|
}));
|
|
429
399
|
}
|
|
430
400
|
async function ee(e, n, t) {
|
|
431
|
-
if (!window.XverseProviders?.BitcoinProvider)
|
|
432
|
-
throw new Error("Xverse extension not found.");
|
|
401
|
+
if (!window.XverseProviders?.BitcoinProvider) throw new Error("Xverse extension not found.");
|
|
433
402
|
const s = T({
|
|
434
403
|
address: t,
|
|
435
404
|
message: e,
|
|
@@ -445,11 +414,9 @@ async function ee(e, n, t) {
|
|
|
445
414
|
return p.from(o, "base64").toString("hex");
|
|
446
415
|
}
|
|
447
416
|
async function ne(e) {
|
|
448
|
-
if (!window.XverseProviders?.BitcoinProvider)
|
|
449
|
-
throw new Error("Xverse extension not found.");
|
|
417
|
+
if (!window.XverseProviders?.BitcoinProvider) throw new Error("Xverse extension not found.");
|
|
450
418
|
const n = S();
|
|
451
|
-
if (!n)
|
|
452
|
-
throw new Error("No payment wallet found.");
|
|
419
|
+
if (!n) throw new Error("No payment wallet found.");
|
|
453
420
|
const t = n.address, s = T({
|
|
454
421
|
address: t,
|
|
455
422
|
message: e,
|
|
@@ -468,8 +435,7 @@ async function ne(e) {
|
|
|
468
435
|
};
|
|
469
436
|
}
|
|
470
437
|
async function te(e, n) {
|
|
471
|
-
if (!window.XverseProviders?.BitcoinProvider)
|
|
472
|
-
throw new Error("Xverse extension not found.");
|
|
438
|
+
if (!window.XverseProviders?.BitcoinProvider) throw new Error("Xverse extension not found.");
|
|
473
439
|
return (await window.XverseProviders.BitcoinProvider.request("sendTransfer", {
|
|
474
440
|
recipients: [
|
|
475
441
|
{
|
|
@@ -480,8 +446,7 @@ async function te(e, n) {
|
|
|
480
446
|
})).result.txid;
|
|
481
447
|
}
|
|
482
448
|
async function H(e, n, t, s) {
|
|
483
|
-
if (!window.XverseProviders?.BitcoinProvider)
|
|
484
|
-
throw new Error("Xverse extension not found.");
|
|
449
|
+
if (!window.XverseProviders?.BitcoinProvider) throw new Error("Xverse extension not found.");
|
|
485
450
|
const o = T({
|
|
486
451
|
network: {
|
|
487
452
|
type: y()
|
package/dist/types/api/swap.d.ts
CHANGED
|
@@ -2,17 +2,26 @@ export { generateAndStoreSwapWallet as createSwapWallet, ensureSwapWallet, getAd
|
|
|
2
2
|
export type { EnsureSwapWalletResult, GetActivityOfPairResponse, GetKlinesRequest, GetKlinesResponse, GetPairVolumeRequest, GetPairVolumeResponse, GetSwapStatusResponse, GetTvlHistoryRequest, GetTvlHistoryResponse, GetWalletActivitiesResponse, ImportSwapWalletOptions, Kline, ListPairsOrderBy, ListPairsRequest, ListPairsResponse, PairActivityEntry, PairInfo, PairReserves, SwapBalance, SwapInfo, TokenInfo, TvlPoint, WalletActivityEntry, } from '../core/bis_swap';
|
|
3
3
|
export type { AllBalanceDetails } from '../core/helpers';
|
|
4
4
|
export type { BISSwapWalletInfo } from '../core/store';
|
|
5
|
+
export type { FeePolicy } from '../lib/fee-policy';
|
|
5
6
|
export type { SwapFees } from '../lib/swap-reporting';
|
|
6
7
|
export { satsToBtc, satsToUsd, swapSide } from '../lib/swap-reporting';
|
|
7
8
|
export { calculatePairAddress as getPairAddress } from '../lib/uniswap_ops';
|
|
8
9
|
/**
|
|
9
10
|
* Retrieves the wallet activities for a given public key and pair address.
|
|
10
11
|
*
|
|
12
|
+
*
|
|
13
|
+
* Activities come back unconfirmed first, then newest first. Pass `limit` and `offset` to page
|
|
14
|
+
* through them and read `has_more` on the response to know whether another page exists. Backends
|
|
15
|
+
* that predate pagination ignore both parameters, return the full list, and omit `has_more`.
|
|
16
|
+
*
|
|
11
17
|
* @param pubkey - The public key of the wallet for which to retrieve activities.
|
|
12
18
|
* @param pairAddress - The address of the pair for which to retrieve activities.
|
|
13
|
-
* @
|
|
19
|
+
* @param limit - (Optional) Page size, an integer from 1 to 200. When omitted, the backend returns every activity.
|
|
20
|
+
* @param offset - (Optional) Number of activities to skip, a non-negative integer. The backend defaults to 0 when omitted.
|
|
21
|
+
* @returns A promise that resolves to the wallet's activities for the pair, with pagination fields when the backend supports them.
|
|
22
|
+
* @throws If `limit` or `offset` is out of range, before any request is sent.
|
|
14
23
|
*/
|
|
15
|
-
export declare function getWalletActivities(pubkey: string, pairAddress: string): Promise<import('./swap').GetWalletActivitiesResponse>;
|
|
24
|
+
export declare function getWalletActivities(pubkey: string, pairAddress: string, limit?: number, offset?: number): Promise<import('./swap').GetWalletActivitiesResponse>;
|
|
16
25
|
/**
|
|
17
26
|
* Retrieves activities for a pair.
|
|
18
27
|
*
|
|
@@ -24,7 +33,11 @@ export declare function getActivityOfPair(pairAddress: string, limit?: number, o
|
|
|
24
33
|
/**
|
|
25
34
|
* Adds liquidity to a specified token pair with the desired amounts and slippage tolerance.
|
|
26
35
|
*
|
|
27
|
-
*
|
|
36
|
+
* Either token may be WBTC or a BRC-20 token. Adding to a pair that doesn't exist
|
|
37
|
+
* yet creates it; the swap backend rejects a new pair unless each side is WBTC or
|
|
38
|
+
* a BRC-20 token. Beyond that, the swap backend decides which new pairs it
|
|
39
|
+
* accepts, and rejects a pair it does not allow with its own error message,
|
|
40
|
+
* which the kit passes through unchanged.
|
|
28
41
|
*
|
|
29
42
|
* @param token1Address - The address of the first token in the pair.
|
|
30
43
|
* @param token2Address - The address of the second token in the pair.
|
|
@@ -38,7 +51,7 @@ export declare function addLiquidity(token1Address: string, token2Address: strin
|
|
|
38
51
|
* Removes liquidity from a specified token pair, burning `liquidity` LP tokens and
|
|
39
52
|
* returning both underlying tokens.
|
|
40
53
|
*
|
|
41
|
-
*
|
|
54
|
+
* Works for any existing pair, including token/token pairs with no WBTC side.
|
|
42
55
|
*
|
|
43
56
|
* @param token1Address - The address of the first token in the pair.
|
|
44
57
|
* @param token2Address - The address of the second token in the pair.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { LocalWalletSource, LocalWalletType } from '../provider/local';
|
|
2
|
-
export {
|
|
2
|
+
export { saveWallet as connectLocalWallet, createWallet, lockLocalWallet } from '../provider/local';
|
|
3
3
|
export * from './wallet';
|
|
4
4
|
export type { LocalWalletSource, LocalWalletType };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FeePolicy } from '../lib/fee-policy';
|
|
1
2
|
import { SwapFees } from '../lib/swap-reporting';
|
|
2
3
|
import { BISSwapWalletInfo } from './store';
|
|
3
4
|
/**
|
|
@@ -100,13 +101,19 @@ export interface SwapInfo {
|
|
|
100
101
|
factory_address: string;
|
|
101
102
|
wbtc_address: string;
|
|
102
103
|
wbtc_handler_address: string;
|
|
104
|
+
fee_policy: FeePolicy | null;
|
|
105
|
+
allow_token_token_pairs: boolean;
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
105
|
-
* Fetches the swap's deployment info
|
|
108
|
+
* Fetches the swap's deployment info (the factory, WBTC and WBTC handler addresses, and the
|
|
109
|
+
* backend-owned swap fee policy) for the current network, by making an API call to the swap
|
|
110
|
+
* backend. The result is cached per network for 60 seconds; a response without a fee policy (an
|
|
111
|
+
* older backend) is returned but not cached, so the policy is picked up once the backend is
|
|
112
|
+
* upgraded.
|
|
106
113
|
*
|
|
107
114
|
* This does not require a connected wallet or a smart wallet.
|
|
108
115
|
*
|
|
109
|
-
* @returns {Promise<SwapInfo>} A promise that resolves to a SwapInfo object containing the factory address, the WBTC token address,
|
|
116
|
+
* @returns {Promise<SwapInfo>} A promise that resolves to a SwapInfo object containing the factory address, the WBTC token address, the WBTC handler address, the fee policy (`null` if the backend does not serve one), and whether the backend accepts new token/token pools.
|
|
110
117
|
*/
|
|
111
118
|
export declare function getSwapInfo(): Promise<SwapInfo>;
|
|
112
119
|
/**
|
|
@@ -122,11 +129,12 @@ export interface SwapBalance {
|
|
|
122
129
|
ticker: string;
|
|
123
130
|
decimals: number;
|
|
124
131
|
is_lp: boolean;
|
|
125
|
-
price_sats: number;
|
|
132
|
+
price_sats: number | null;
|
|
126
133
|
reserve_token_amt?: string;
|
|
127
134
|
token_decimals?: number;
|
|
128
135
|
reserve_btc_amt?: string;
|
|
129
136
|
btc_decimals?: number;
|
|
137
|
+
quote_token?: string;
|
|
130
138
|
lp_total_supply?: string;
|
|
131
139
|
}
|
|
132
140
|
/**
|
|
@@ -205,11 +213,13 @@ export interface PairInfo {
|
|
|
205
213
|
price: number;
|
|
206
214
|
price_change_24h: number;
|
|
207
215
|
price_change_7d: number;
|
|
208
|
-
volume_24h: bigint;
|
|
209
|
-
volume_7d: bigint;
|
|
216
|
+
volume_24h: bigint | null;
|
|
217
|
+
volume_7d: bigint | null;
|
|
210
218
|
lp_fee_tier: number;
|
|
211
|
-
tvl: bigint;
|
|
212
|
-
apr: number;
|
|
219
|
+
tvl: bigint | null;
|
|
220
|
+
apr: number | null;
|
|
221
|
+
price_quote_token: string;
|
|
222
|
+
exposure_sats: bigint;
|
|
213
223
|
}
|
|
214
224
|
export interface ListPairsResponse {
|
|
215
225
|
page: number;
|
|
@@ -223,7 +233,7 @@ export interface ListPairsResponse {
|
|
|
223
233
|
* This does not require a connected wallet or a smart wallet, so it can be used to populate a market table or pair selector before the user connects.
|
|
224
234
|
*
|
|
225
235
|
* @param params (Optional) An object containing the sort order (defaults to 'tvl_desc'), the page to fetch (defaults to 1), and the number of pairs per page (defaults to 20, max 100).
|
|
226
|
-
* @returns {Promise<ListPairsResponse>} A promise that resolves to an object containing the current page, page size, total number of pairs, and an array of PairInfo objects. Each pair includes both token addresses and symbols, price, 24h/7d price change, 24h/7d volume, LP fee tier, TVL, and
|
|
236
|
+
* @returns {Promise<ListPairsResponse>} A promise that resolves to an object containing the current page, page size, total number of pairs, and an array of PairInfo objects. Each pair includes both token addresses and symbols, price and the token it is quoted in, 24h/7d price change, 24h/7d volume, LP fee tier, TVL, APR, and BTC exposure. The volumes, TVL and exposure are returned as strings from the API and converted to bigint in this function; volume, TVL and APR are `null` for a token/token pair below the backend's BTC-exposure threshold.
|
|
227
237
|
*/
|
|
228
238
|
export declare function listPairs(params?: ListPairsRequest): Promise<ListPairsResponse>;
|
|
229
239
|
export interface GetPairVolumeRequest {
|
|
@@ -237,7 +247,7 @@ export interface GetPairVolumeResponse {
|
|
|
237
247
|
token_b_address: string;
|
|
238
248
|
token_b_symbol: string;
|
|
239
249
|
period_days: number;
|
|
240
|
-
total_volume_wbtc: string;
|
|
250
|
+
total_volume_wbtc: string | null;
|
|
241
251
|
total_trades: number;
|
|
242
252
|
start_time: string;
|
|
243
253
|
end_time: string;
|
|
@@ -246,7 +256,7 @@ export interface GetPairVolumeResponse {
|
|
|
246
256
|
* Fetches the trading volume and number of trades for a specific token pair over a given number of days by making an API call to the swap backend.
|
|
247
257
|
*
|
|
248
258
|
* @param params An object containing the pair address and the number of days to look back for volume data.
|
|
249
|
-
* @returns {Promise<GetPairVolumeResponse>} A promise that resolves to an object containing the pair address, token addresses and symbols, period in days, total volume in WBTC, total number of trades, and the start and end time of the period. The total volume is returned as a string from the API and can be converted to bigint if needed.
|
|
259
|
+
* @returns {Promise<GetPairVolumeResponse>} A promise that resolves to an object containing the pair address, token addresses and symbols, period in days, total volume in WBTC, total number of trades, and the start and end time of the period. The total volume is returned as a string from the API and can be converted to bigint if needed; it is `null` for a token/token pair below the backend's BTC-exposure threshold.
|
|
250
260
|
*/
|
|
251
261
|
export declare function getPairVolumeOverDays(params: GetPairVolumeRequest): Promise<GetPairVolumeResponse>;
|
|
252
262
|
export interface GetKlinesRequest {
|
|
@@ -272,6 +282,7 @@ export interface GetKlinesResponse {
|
|
|
272
282
|
token_a_symbol: string;
|
|
273
283
|
token_b_address: string;
|
|
274
284
|
token_b_symbol: string;
|
|
285
|
+
price_quote_token: string | null;
|
|
275
286
|
interval: string;
|
|
276
287
|
klines: Kline[];
|
|
277
288
|
}
|
|
@@ -279,7 +290,7 @@ export interface GetKlinesResponse {
|
|
|
279
290
|
* Fetches the historical price and volume data (klines) for a specific token pair and time interval by making an API call to the swap backend.
|
|
280
291
|
*
|
|
281
292
|
* @param params An object containing the pair address, desired time interval for the klines, limit on the number of klines to fetch (max 1000), and optional start and end timestamps to filter the klines.
|
|
282
|
-
* @returns {Promise<GetKlinesResponse>} A promise that resolves to an object containing the pair address, token addresses and symbols, interval, and an array of kline data. Each kline includes open time, close time, open price, high price, low price, close price, volume in WBTC, and number of trades. The volume is returned as a string from the API and can be converted to bigint if needed.
|
|
293
|
+
* @returns {Promise<GetKlinesResponse>} A promise that resolves to an object containing the pair address, token addresses and symbols, the token prices are quoted in (`price_quote_token`), interval, and an array of kline data. Each kline includes open time, close time, open price, high price, low price, close price, volume in WBTC, and number of trades. For a token/token pair the prices are the raw base/quote ratio (quote-token base units per whole base token), with no BTC conversion. The volume is returned as a string from the API and can be converted to bigint if needed.
|
|
283
294
|
*/
|
|
284
295
|
export declare function getKlines(params: GetKlinesRequest): Promise<GetKlinesResponse>;
|
|
285
296
|
export interface GetTvlHistoryRequest {
|
|
@@ -289,7 +300,7 @@ export interface GetTvlHistoryRequest {
|
|
|
289
300
|
export interface TvlPoint {
|
|
290
301
|
timestamp: number;
|
|
291
302
|
block_height: number;
|
|
292
|
-
tvl: string;
|
|
303
|
+
tvl: string | null;
|
|
293
304
|
}
|
|
294
305
|
export interface GetTvlHistoryResponse {
|
|
295
306
|
pair_address: string;
|
|
@@ -304,10 +315,10 @@ export interface GetTvlHistoryResponse {
|
|
|
304
315
|
/**
|
|
305
316
|
* Fetches a daily Total Value Locked (TVL) series for a token pair from the swap backend, for charting TVL over time.
|
|
306
317
|
*
|
|
307
|
-
* TVL is valued in WBTC sats
|
|
318
|
+
* TVL is valued in WBTC sats: 2 x the WBTC-side reserve for a WBTC pair. A token/token pair (`wbtc_side: ''`) is valued through each token's direct BTC pool as of that day, and its point is `tvl: null` on days its BTC exposure is below the backend's threshold. Points are one per day, oldest first, each carrying the pair's reserves as of that day (carried forward across days with no on-chain change).
|
|
308
319
|
*
|
|
309
320
|
* @param params An object with the pair address and the number of days to look back (max 365; the backend clamps out-of-range values).
|
|
310
|
-
* @returns {Promise<GetTvlHistoryResponse>} A promise that resolves to the pair address, token addresses and symbols, which side is WBTC, the period in days, and the ascending array of `{ timestamp, block_height, tvl }` points. Each `tvl` is a string of sats and can be converted to bigint if needed.
|
|
321
|
+
* @returns {Promise<GetTvlHistoryResponse>} A promise that resolves to the pair address, token addresses and symbols, which side is WBTC, the period in days, and the ascending array of `{ timestamp, block_height, tvl }` points. Each `tvl` is a string of sats (or `null`, see above) and can be converted to bigint if needed.
|
|
311
322
|
*/
|
|
312
323
|
export declare function getTvlHistory(params: GetTvlHistoryRequest): Promise<GetTvlHistoryResponse>;
|
|
313
324
|
export interface GetActivityOfPairRequest {
|
|
@@ -342,6 +353,12 @@ export interface GetActivityOfPairResponse {
|
|
|
342
353
|
decimals: number;
|
|
343
354
|
};
|
|
344
355
|
activities: PairActivityEntry[];
|
|
356
|
+
/** Page size the backend applied. Absent on older backends. */
|
|
357
|
+
limit?: number;
|
|
358
|
+
/** Offset the backend applied. Absent on older backends. */
|
|
359
|
+
offset?: number;
|
|
360
|
+
/** Whether more activities exist past this page. Absent on older backends. */
|
|
361
|
+
has_more?: boolean;
|
|
345
362
|
}
|
|
346
363
|
/**
|
|
347
364
|
* Fetches the recent swap activities for a specific token pair by making an API call to the swap backend.
|
|
@@ -353,6 +370,10 @@ export declare function getActivityOfPair(params: GetActivityOfPairRequest): Pro
|
|
|
353
370
|
interface GetWalletActivitiesRequest {
|
|
354
371
|
pubkey: string;
|
|
355
372
|
pairAddress: string;
|
|
373
|
+
/** Page size, 1-200. When omitted, the backend returns every activity. */
|
|
374
|
+
limit?: number;
|
|
375
|
+
/** Number of activities to skip. The backend defaults to 0 when omitted. */
|
|
376
|
+
offset?: number;
|
|
356
377
|
}
|
|
357
378
|
export interface WalletActivityEntry {
|
|
358
379
|
id: string;
|
|
@@ -382,12 +403,25 @@ export interface GetWalletActivitiesResponse {
|
|
|
382
403
|
btc_address: string;
|
|
383
404
|
pair_address: string;
|
|
384
405
|
activities: WalletActivityEntry[];
|
|
406
|
+
/** Page size the backend applied, or null when no `limit` was sent. Absent on older backends. */
|
|
407
|
+
limit?: number | null;
|
|
408
|
+
/** Offset the backend applied. Absent on older backends. */
|
|
409
|
+
offset?: number;
|
|
410
|
+
/** Whether more activities exist past this page. Absent on older backends. */
|
|
411
|
+
has_more?: boolean;
|
|
385
412
|
}
|
|
386
413
|
/**
|
|
387
414
|
* Fetches the swap activities associated with a specific wallet public key and pair address by making an API call to the swap backend.
|
|
388
415
|
*
|
|
389
|
-
*
|
|
416
|
+
* Activities come back unconfirmed first (null timestamp), then newest first. `limit` and
|
|
417
|
+
* `offset` page through them; each is sent only when given. Without `limit` the backend
|
|
418
|
+
* returns every activity from `offset` on, with `limit: null` and `has_more: false`.
|
|
419
|
+
* Backends that predate pagination ignore both and return the full list without `has_more`,
|
|
420
|
+
* `limit` or `offset`.
|
|
421
|
+
*
|
|
422
|
+
* @param params An object containing the wallet public key and pair address to query activities for, plus optional `limit` (1-200) and `offset` (>= 0).
|
|
390
423
|
* @returns {Promise<GetWalletActivitiesResponse>} A promise that resolves to an object containing the wallet public key, associated Bitcoin address, pair address, and a list of swap activities (deposits, swaps, liquidity changes, withdrawals) related to that wallet and pair.
|
|
424
|
+
* @throws If `limit` is not an integer from 1 to 200, or `offset` is not a non-negative integer.
|
|
391
425
|
*/
|
|
392
426
|
export declare function getWalletActivities(params: GetWalletActivitiesRequest): Promise<GetWalletActivitiesResponse>;
|
|
393
427
|
/**
|
|
@@ -517,6 +551,19 @@ interface RemoveLiquidityOrderResponse {
|
|
|
517
551
|
* @returns A promise that resolves to an object indicating the success of the remove liquidity order request.
|
|
518
552
|
*/
|
|
519
553
|
export declare function prepareAndSendRemoveLiquidityOrder(token1Addr: string, token2Addr: string, lpAmt: bigint, amt1: bigint, amt2: bigint, slippageBPS: bigint): Promise<RemoveLiquidityOrderResponse>;
|
|
554
|
+
/**
|
|
555
|
+
* The protocol-fee split the swap backend requires for a swap, from its
|
|
556
|
+
* `fee_policy` (see `swapFeeBps`). Exported for tests; not part of the public API.
|
|
557
|
+
*
|
|
558
|
+
* @param token1Addr The input token address (for both exact-input and exact-output swaps).
|
|
559
|
+
* @param token2Addr The output token address.
|
|
560
|
+
* @returns The fee bps on the input (`token1FeeBps`) and output (`token2FeeBps`) legs.
|
|
561
|
+
* @throws {Error} `MISSING_FEE_POLICY_ERROR` if the backend does not serve a fee policy.
|
|
562
|
+
*/
|
|
563
|
+
export declare function getSwapFeesBps(token1Addr: string, token2Addr: string): Promise<{
|
|
564
|
+
token1FeeBps: bigint;
|
|
565
|
+
token2FeeBps: bigint;
|
|
566
|
+
}>;
|
|
520
567
|
/**
|
|
521
568
|
* Calculates the expected output amount, quoted price, and price impact for a token swap operation. The function retrieves the necessary swap information and connected wallet details, then uses a proxy to check the current balances and reserves of the tokens in the liquidity pool. It also requests the miner fee for swapping and gets the fee basis points for the tokens involved in the swap. Finally, it calls the swapRequest function to get the expected results based on the input parameters.
|
|
522
569
|
*
|
|
@@ -524,7 +571,7 @@ export declare function prepareAndSendRemoveLiquidityOrder(token1Addr: string, t
|
|
|
524
571
|
* @param tokenOutAddr The address of the token being swapped to.
|
|
525
572
|
* @param amtIn The amount of the input token to be swapped, represented as a bigint.
|
|
526
573
|
*
|
|
527
|
-
* @returns A promise that resolves to an object containing the expected output amount of the token being swapped to, the quoted price for the swap, the price impact in basis points, and the fee breakdown (see `SwapFees
|
|
574
|
+
* @returns A promise that resolves to an object containing the expected output amount of the token being swapped to, the quoted price for the swap (sats per whole token when either side is WBTC; for a token/token swap, output-token base units per whole input token, see `quotedPrice`), the price impact in basis points, and the fee breakdown (see `SwapFees`: `amount_out` is net of the pool fee only, with the rest charged on top).
|
|
528
575
|
*/
|
|
529
576
|
export declare function getSwapResult(tokenInAddr: string, tokenOutAddr: string, amtIn: bigint): Promise<{
|
|
530
577
|
amount_out: bigint;
|
|
@@ -557,7 +604,7 @@ export declare function prepareAndSendSwapOrder(token1Addr: string, token2Addr:
|
|
|
557
604
|
* @param tokenOutAddr The address of the token being swapped to.
|
|
558
605
|
* @param amtOut The amount of the output token expected from the swap, represented as a bigint.
|
|
559
606
|
*
|
|
560
|
-
* @returns A promise that resolves to an object containing the expected input amount of the token being swapped from, the quoted price for the swap, the price impact in basis points, and the fee breakdown (see `SwapFees
|
|
607
|
+
* @returns A promise that resolves to an object containing the expected input amount of the token being swapped from, the quoted price for the swap (sats per whole token when either side is WBTC; for a token/token swap, output-token base units per whole input token, see `quotedPrice`), the price impact in basis points, and the fee breakdown (see `SwapFees`: `amount_in` covers the pool fee only, with the rest charged on top).
|
|
561
608
|
*/
|
|
562
609
|
export declare function getSwap2Result(tokenInAddr: string, tokenOutAddr: string, amtOut: bigint): Promise<{
|
|
563
610
|
amount_in: bigint;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The swap protocol-fee policy served by the swap backend (`/get_swap_info` →
|
|
3
|
+
* `fee_policy`).
|
|
4
|
+
*/
|
|
5
|
+
export interface FeePolicy {
|
|
6
|
+
/** Total protocol fee on a swap, in basis points. */
|
|
7
|
+
swap_fee_bps: number;
|
|
8
|
+
/** Lowercased token addresses that take the whole fee, highest priority first. WBTC is always first. */
|
|
9
|
+
priority_tokens: string[];
|
|
10
|
+
/** Minimum BTC exposure (sats) for a token/token pair's volume/TVL to be reported. A decimal string. */
|
|
11
|
+
min_btc_exposure_sats: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const MISSING_FEE_POLICY_ERROR: string;
|
|
14
|
+
/**
|
|
15
|
+
* Validates and normalises the raw `fee_policy` object from `/get_swap_info`.
|
|
16
|
+
* Priority addresses are lowercased.
|
|
17
|
+
*
|
|
18
|
+
* @param raw The `fee_policy` value exactly as the backend returned it.
|
|
19
|
+
* @returns The validated policy.
|
|
20
|
+
* @throws {Error} `MISSING_FEE_POLICY_ERROR` when `raw` is null/undefined (backend too old),
|
|
21
|
+
* or an `Invalid fee_policy…` error when a field is malformed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseFeePolicy(raw: unknown): FeePolicy;
|
|
24
|
+
/**
|
|
25
|
+
* The protocol-fee split for a swap. `token1` is always the input token, for both
|
|
26
|
+
* exact-input and exact-output swaps.
|
|
27
|
+
*
|
|
28
|
+
* If either side is a priority token, the higher-priority side (lower index in
|
|
29
|
+
* `priority_tokens`) pays the full rate and the other side pays 0. Otherwise the
|
|
30
|
+
* rate is split, with the odd bp on the input side: input `ceil(rate/2)`, output
|
|
31
|
+
* `floor(rate/2)`. Addresses are compared lowercased.
|
|
32
|
+
*
|
|
33
|
+
* @param tokenIn The input token address.
|
|
34
|
+
* @param tokenOut The output token address.
|
|
35
|
+
* @param policy The backend's fee policy.
|
|
36
|
+
* @returns The fee bps on the input (`token1FeeBps`) and output (`token2FeeBps`) legs.
|
|
37
|
+
*/
|
|
38
|
+
export declare function swapFeeBps(tokenIn: string, tokenOut: string, policy: FeePolicy): {
|
|
39
|
+
token1FeeBps: bigint;
|
|
40
|
+
token2FeeBps: bigint;
|
|
41
|
+
};
|