@leather.io/models 0.49.0 → 0.50.1
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/.turbo/turbo-build.log +13 -14
- package/CHANGELOG.md +21 -0
- package/dist/index.d.ts +857 -805
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +605 -679
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/swap/swap.model.ts +7 -4
- package/tsconfig.json +3 -3
- package/tsdown.config.ts +7 -0
- package/tsup.config.ts +0 -9
package/dist/index.js
CHANGED
|
@@ -1,824 +1,750 @@
|
|
|
1
|
-
// src/account.model.ts
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
var stacksAddressInfoSchema = z.object({
|
|
14
|
-
stxAddress: z.string()
|
|
2
|
+
|
|
3
|
+
//#region src/account.model.ts
|
|
4
|
+
const walletIdSchema = z.object({ fingerprint: z.string() });
|
|
5
|
+
const accountIdSchema = walletIdSchema.and(z.object({ accountIndex: z.number() }));
|
|
6
|
+
const bitcoinAddressInfoSchema = z.object({
|
|
7
|
+
taprootDescriptor: z.string(),
|
|
8
|
+
nativeSegwitDescriptor: z.string(),
|
|
9
|
+
zeroIndexTaprootPayerAddress: z.string().optional(),
|
|
10
|
+
zeroIndexNativeSegwitPayerAddress: z.string().optional()
|
|
15
11
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
const stacksAddressInfoSchema = z.object({ stxAddress: z.string() });
|
|
13
|
+
const accountAddressesSchema = z.object({
|
|
14
|
+
id: accountIdSchema,
|
|
15
|
+
bitcoin: bitcoinAddressInfoSchema.optional(),
|
|
16
|
+
stacks: stacksAddressInfoSchema.optional()
|
|
20
17
|
});
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/activity/activity-level.model.ts
|
|
21
|
+
const ActivityLevels = {
|
|
22
|
+
account: "account",
|
|
23
|
+
app: "app"
|
|
26
24
|
};
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/activity/activity-status.model.ts
|
|
28
|
+
const OnChainActivityStatuses = {
|
|
29
|
+
pending: "pending",
|
|
30
|
+
success: "success",
|
|
31
|
+
failed: "failed"
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/activity/activity-type.model.ts
|
|
36
|
+
const OnChainActivityTypes = {
|
|
37
|
+
deploySmartContract: "deploySmartContract",
|
|
38
|
+
executeSmartContract: "executeSmartContract",
|
|
39
|
+
lockAsset: "lockAsset",
|
|
40
|
+
sendAsset: "sendAsset",
|
|
41
|
+
receiveAsset: "receiveAsset",
|
|
42
|
+
swapAssets: "swapAssets"
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const WalletActivityTypes = {
|
|
45
|
+
connectApp: "connectApp",
|
|
46
|
+
signMessage: "signMessage"
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const GeneralActivityTypes = {
|
|
49
|
+
walletAdded: "walletAdded",
|
|
50
|
+
receiveAnnouncement: "receiveAnnouncement",
|
|
51
|
+
featureWaitlistNotification: "featureWaitlistNotification"
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/assets/asset-type-guards.ts
|
|
55
56
|
function isFungibleAsset(asset) {
|
|
56
|
-
|
|
57
|
+
return asset.category === "fungible";
|
|
57
58
|
}
|
|
58
59
|
function isNonFungibleAsset(asset) {
|
|
59
|
-
|
|
60
|
+
return asset.category === "nft";
|
|
60
61
|
}
|
|
61
62
|
function isBtcAsset(asset) {
|
|
62
|
-
|
|
63
|
+
return asset.protocol === "nativeBtc";
|
|
63
64
|
}
|
|
64
65
|
function isStxAsset(asset) {
|
|
65
|
-
|
|
66
|
+
return asset.protocol === "nativeStx";
|
|
66
67
|
}
|
|
67
68
|
function isNativeAsset(asset) {
|
|
68
|
-
|
|
69
|
+
return isBtcAsset(asset) || isStxAsset(asset);
|
|
69
70
|
}
|
|
70
71
|
function isSip10Asset(asset) {
|
|
71
|
-
|
|
72
|
+
return asset.protocol === "sip10";
|
|
72
73
|
}
|
|
73
74
|
function isSwappableAsset(asset) {
|
|
74
|
-
|
|
75
|
+
return isNativeAsset(asset) || isSip10Asset(asset);
|
|
75
76
|
}
|
|
76
77
|
function isBrc20Asset(asset) {
|
|
77
|
-
|
|
78
|
+
return asset.protocol === "brc20";
|
|
78
79
|
}
|
|
79
80
|
function isSrc20Asset(asset) {
|
|
80
|
-
|
|
81
|
+
return asset.protocol === "src20";
|
|
81
82
|
}
|
|
82
83
|
function isStx20Asset(asset) {
|
|
83
|
-
|
|
84
|
+
return asset.protocol === "stx20";
|
|
84
85
|
}
|
|
85
86
|
function isRuneAsset(asset) {
|
|
86
|
-
|
|
87
|
+
return asset.protocol === "rune";
|
|
87
88
|
}
|
|
88
89
|
function isInscriptionAsset(asset) {
|
|
89
|
-
|
|
90
|
+
return asset.protocol === "inscription";
|
|
90
91
|
}
|
|
91
92
|
function isStampAsset(asset) {
|
|
92
|
-
|
|
93
|
+
return asset.protocol === "stamp";
|
|
93
94
|
}
|
|
94
95
|
function isSip9Asset(asset) {
|
|
95
|
-
|
|
96
|
+
return asset.protocol === "sip9";
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/assets/asset.model.ts
|
|
101
|
+
const CryptoAssetChains = {
|
|
102
|
+
bitcoin: "bitcoin",
|
|
103
|
+
stacks: "stacks"
|
|
102
104
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
const CryptoAssetCategories = {
|
|
106
|
+
fungible: "fungible",
|
|
107
|
+
nft: "nft"
|
|
106
108
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
const FungibleCryptoAssetProtocols = {
|
|
110
|
+
nativeBtc: "nativeBtc",
|
|
111
|
+
nativeStx: "nativeStx",
|
|
112
|
+
sip10: "sip10",
|
|
113
|
+
brc20: "brc20",
|
|
114
|
+
src20: "src20",
|
|
115
|
+
stx20: "stx20",
|
|
116
|
+
rune: "rune"
|
|
115
117
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
const NonFungibleCryptoAssetProtocols = {
|
|
119
|
+
stamp: "stamp",
|
|
120
|
+
sip9: "sip9",
|
|
121
|
+
inscription: "inscription"
|
|
120
122
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
const CryptoAssetProtocols = {
|
|
124
|
+
...FungibleCryptoAssetProtocols,
|
|
125
|
+
...NonFungibleCryptoAssetProtocols
|
|
124
126
|
};
|
|
125
127
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/assets/sip9-asset.model.ts
|
|
130
|
+
const sip9ContentTypes = [
|
|
131
|
+
"image/jpeg",
|
|
132
|
+
"image/jpg",
|
|
133
|
+
"image/png",
|
|
134
|
+
"image/gif",
|
|
135
|
+
"image/webp",
|
|
136
|
+
"image/svg+xml",
|
|
137
|
+
"image/bmp",
|
|
138
|
+
"image/tiff",
|
|
139
|
+
"image/avif",
|
|
140
|
+
"video/mp4",
|
|
141
|
+
"video/webm",
|
|
142
|
+
"video/mov",
|
|
143
|
+
"video/quicktime",
|
|
144
|
+
"video/avi",
|
|
145
|
+
"video/x-msvideo",
|
|
146
|
+
"video/ogg",
|
|
147
|
+
"audio/mpeg",
|
|
148
|
+
"audio/mp3",
|
|
149
|
+
"audio/wav",
|
|
150
|
+
"audio/x-wav",
|
|
151
|
+
"audio/ogg",
|
|
152
|
+
"audio/aac",
|
|
153
|
+
"audio/flac",
|
|
154
|
+
"audio/webm",
|
|
155
|
+
"model/gltf+json",
|
|
156
|
+
"model/gltf-binary",
|
|
157
|
+
"application/octet-stream",
|
|
158
|
+
"text/plain",
|
|
159
|
+
"text/html",
|
|
160
|
+
"text/markdown",
|
|
161
|
+
"application/pdf",
|
|
162
|
+
"application/json",
|
|
163
|
+
"text/javascript",
|
|
164
|
+
"application/javascript",
|
|
165
|
+
"application/zip",
|
|
166
|
+
"unknown",
|
|
167
|
+
""
|
|
165
168
|
];
|
|
166
169
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/bitcoin.model.ts
|
|
172
|
+
const bitcoinUnitSchema = z.enum(["bitcoin", "satoshi"]);
|
|
170
173
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/bns.model.ts
|
|
176
|
+
const bnsContractAddress = {
|
|
177
|
+
mainnet: "SP2QEZ06AGJ3RKJPBV14SY1V5BBFNAW33D96YPGZF",
|
|
178
|
+
testnet: "ST2QEZ06AGJ3RKJPBV14SY1V5BBFNAW33D9SZJQ0M"
|
|
175
179
|
};
|
|
176
|
-
|
|
180
|
+
const bnsContractName = "BNS-V2";
|
|
177
181
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/fees/bitcoin-fees.model.ts
|
|
184
|
+
const btcTxTimeMap = {
|
|
185
|
+
fastestFee: "~10 – 20min",
|
|
186
|
+
halfHourFee: "~30 min",
|
|
187
|
+
hourFee: "~1 hour+"
|
|
183
188
|
};
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
189
|
+
let BtcFeeType = /* @__PURE__ */ function(BtcFeeType$1) {
|
|
190
|
+
BtcFeeType$1["High"] = "High";
|
|
191
|
+
BtcFeeType$1["Standard"] = "Standard";
|
|
192
|
+
BtcFeeType$1["Low"] = "Low";
|
|
193
|
+
return BtcFeeType$1;
|
|
194
|
+
}({});
|
|
190
195
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/fees/fees.model.ts
|
|
198
|
+
let FeeTypes = /* @__PURE__ */ function(FeeTypes$1) {
|
|
199
|
+
FeeTypes$1[FeeTypes$1["Low"] = 0] = "Low";
|
|
200
|
+
FeeTypes$1[FeeTypes$1["Middle"] = 1] = "Middle";
|
|
201
|
+
FeeTypes$1[FeeTypes$1["High"] = 2] = "High";
|
|
202
|
+
FeeTypes$1[FeeTypes$1["Custom"] = 3] = "Custom";
|
|
203
|
+
FeeTypes$1[FeeTypes$1["Unknown"] = 4] = "Unknown";
|
|
204
|
+
return FeeTypes$1;
|
|
205
|
+
}({});
|
|
206
|
+
let FeeCalculationTypes = /* @__PURE__ */ function(FeeCalculationTypes$1) {
|
|
207
|
+
FeeCalculationTypes$1["Api"] = "api";
|
|
208
|
+
FeeCalculationTypes$1["Default"] = "default";
|
|
209
|
+
FeeCalculationTypes$1["DefaultSimulated"] = "default-simulated";
|
|
210
|
+
FeeCalculationTypes$1["FeesCapped"] = "fees-capped";
|
|
211
|
+
FeeCalculationTypes$1["TokenTransferSpecific"] = "token-transfer-specific";
|
|
212
|
+
return FeeCalculationTypes$1;
|
|
213
|
+
}({});
|
|
208
214
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/fees/transaction-fees.model.ts
|
|
217
|
+
const transactionFeeTiers = [
|
|
218
|
+
"low",
|
|
219
|
+
"standard",
|
|
220
|
+
"high"
|
|
221
|
+
];
|
|
222
|
+
const transactionFeeQuoteType = [
|
|
223
|
+
"flat",
|
|
224
|
+
"bitcoinFeeRate",
|
|
225
|
+
"stacksFeeRate",
|
|
226
|
+
"evm1559"
|
|
216
227
|
];
|
|
217
228
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/inscription-mime-type.model.ts
|
|
231
|
+
/**
|
|
232
|
+
* Inscriptions contain arbitrary data. When retrieving an inscription, it should be
|
|
233
|
+
* classified into one of the types below, indicating that the app can handle it
|
|
234
|
+
* appropriately and securely. Inscriptions of types not ready to be handled by the
|
|
235
|
+
* app should be classified as "other".
|
|
236
|
+
*/
|
|
237
|
+
const inscriptionMimeTypes = [
|
|
238
|
+
"audio",
|
|
239
|
+
"gltf",
|
|
240
|
+
"html",
|
|
241
|
+
"image",
|
|
242
|
+
"svg",
|
|
243
|
+
"text",
|
|
244
|
+
"video",
|
|
245
|
+
"other"
|
|
228
246
|
];
|
|
229
247
|
|
|
230
|
-
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/market.model.ts
|
|
231
250
|
function createMarketPair(base, quote) {
|
|
232
|
-
|
|
251
|
+
return Object.freeze({
|
|
252
|
+
base,
|
|
253
|
+
quote
|
|
254
|
+
});
|
|
233
255
|
}
|
|
234
256
|
function formatMarketPair({ base, quote }) {
|
|
235
|
-
|
|
257
|
+
return `${base}/${quote}`;
|
|
236
258
|
}
|
|
237
259
|
function createMarketData(pair, price) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
260
|
+
if (pair.quote !== price.symbol) throw new Error("Cannot create market data when price does not match quote");
|
|
261
|
+
return Object.freeze({
|
|
262
|
+
pair,
|
|
263
|
+
price
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
const historicalPeriods = [
|
|
267
|
+
"1d",
|
|
268
|
+
"1w",
|
|
269
|
+
"1m",
|
|
270
|
+
"3m",
|
|
271
|
+
"6m",
|
|
272
|
+
"1y"
|
|
273
|
+
];
|
|
243
274
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/network/network.model.ts
|
|
277
|
+
const HIRO_API_BASE_URL_MAINNET = "https://api.hiro.so";
|
|
278
|
+
const HIRO_API_BASE_URL_TESTNET = "https://api.testnet.hiro.so";
|
|
279
|
+
const HIRO_API_BASE_URL_NAKAMOTO_TESTNET = "https://api.nakamoto.testnet.hiro.so";
|
|
280
|
+
const HIRO_API_BASE_URL_MAINNET_EXTENDED = "https://api.hiro.so/extended/v1";
|
|
281
|
+
const HIRO_API_BASE_URL_TESTNET_EXTENDED = "https://api.testnet.hiro.so/extended";
|
|
282
|
+
const BITCOIN_API_BASE_URL_MAINNET = "https://leather.mempool.space/api";
|
|
283
|
+
const BITCOIN_API_BASE_URL_TESTNET3 = "https://leather.mempool.space/testnet/api";
|
|
284
|
+
const BITCOIN_API_BASE_URL_TESTNET4 = "https://leather.mempool.space/testnet4/api";
|
|
285
|
+
const BITCOIN_API_BASE_URL_SIGNET = "https://mempool.space/signet/api";
|
|
286
|
+
const BESTINSLOT_API_BASE_URL_MAINNET = "https://leatherapi.bestinslot.xyz/v3";
|
|
287
|
+
const BESTINSLOT_API_BASE_URL_TESTNET = "https://leatherapi_testnet.bestinslot.xyz/v3";
|
|
288
|
+
const STX20_API_BASE_URL_MAINNET = "https://api.stx20.com/api/v1";
|
|
289
|
+
const BNS_V2_API_BASE_URL = "https://api.bnsv2.com";
|
|
290
|
+
let ChainId = /* @__PURE__ */ function(ChainId$1) {
|
|
291
|
+
ChainId$1[ChainId$1["Testnet"] = 2147483648] = "Testnet";
|
|
292
|
+
ChainId$1[ChainId$1["Mainnet"] = 1] = "Mainnet";
|
|
293
|
+
return ChainId$1;
|
|
294
|
+
}({});
|
|
295
|
+
let WalletDefaultNetworkConfigurationIds = /* @__PURE__ */ function(WalletDefaultNetworkConfigurationIds$1) {
|
|
296
|
+
WalletDefaultNetworkConfigurationIds$1["mainnet"] = "mainnet";
|
|
297
|
+
WalletDefaultNetworkConfigurationIds$1["testnet"] = "testnet";
|
|
298
|
+
WalletDefaultNetworkConfigurationIds$1["testnet4"] = "testnet4";
|
|
299
|
+
WalletDefaultNetworkConfigurationIds$1["signet"] = "signet";
|
|
300
|
+
WalletDefaultNetworkConfigurationIds$1["sbtcTestnet"] = "sbtcTestnet";
|
|
301
|
+
WalletDefaultNetworkConfigurationIds$1["sbtcDevenv"] = "sbtcDevenv";
|
|
302
|
+
WalletDefaultNetworkConfigurationIds$1["devnet"] = "devnet";
|
|
303
|
+
return WalletDefaultNetworkConfigurationIds$1;
|
|
304
|
+
}({});
|
|
305
|
+
const defaultNetworkConfigurationsSchema = z.enum([
|
|
306
|
+
"mainnet",
|
|
307
|
+
"testnet",
|
|
308
|
+
"testnet4",
|
|
309
|
+
"signet",
|
|
310
|
+
"sbtcTestnet",
|
|
311
|
+
"sbtcDevenv",
|
|
312
|
+
"devnet"
|
|
282
313
|
]);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
314
|
+
const supportedBlockchains = ["stacks", "bitcoin"];
|
|
315
|
+
const networkModes = ["mainnet", "testnet"];
|
|
316
|
+
const testnetModes = [
|
|
317
|
+
"testnet",
|
|
318
|
+
"regtest",
|
|
319
|
+
"signet"
|
|
320
|
+
];
|
|
321
|
+
const bitcoinNetworks = [
|
|
322
|
+
"mainnet",
|
|
323
|
+
"testnet3",
|
|
324
|
+
"testnet4",
|
|
325
|
+
"regtest",
|
|
326
|
+
"signet"
|
|
327
|
+
];
|
|
287
328
|
function bitcoinNetworkToNetworkMode(network) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
blockchain: "bitcoin",
|
|
314
|
-
bitcoinNetwork: "mainnet",
|
|
315
|
-
mode: "mainnet",
|
|
316
|
-
bitcoinUrl: BITCOIN_API_BASE_URL_MAINNET
|
|
317
|
-
}
|
|
318
|
-
}
|
|
329
|
+
switch (network) {
|
|
330
|
+
case "mainnet": return "mainnet";
|
|
331
|
+
case "testnet3": return "testnet";
|
|
332
|
+
case "testnet4": return "testnet";
|
|
333
|
+
case "regtest": return "regtest";
|
|
334
|
+
case "signet": return "signet";
|
|
335
|
+
default: throw new Error(`Unhandled case: ${network}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const networkMainnet = {
|
|
339
|
+
id: WalletDefaultNetworkConfigurationIds.mainnet,
|
|
340
|
+
name: "Mainnet",
|
|
341
|
+
chain: {
|
|
342
|
+
stacks: {
|
|
343
|
+
blockchain: "stacks",
|
|
344
|
+
chainId: ChainId.Mainnet,
|
|
345
|
+
url: HIRO_API_BASE_URL_MAINNET
|
|
346
|
+
},
|
|
347
|
+
bitcoin: {
|
|
348
|
+
blockchain: "bitcoin",
|
|
349
|
+
bitcoinNetwork: "mainnet",
|
|
350
|
+
mode: "mainnet",
|
|
351
|
+
bitcoinUrl: BITCOIN_API_BASE_URL_MAINNET
|
|
352
|
+
}
|
|
353
|
+
}
|
|
319
354
|
};
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
355
|
+
const networkTestnet = {
|
|
356
|
+
id: WalletDefaultNetworkConfigurationIds.testnet,
|
|
357
|
+
name: "Testnet3",
|
|
358
|
+
chain: {
|
|
359
|
+
stacks: {
|
|
360
|
+
blockchain: "stacks",
|
|
361
|
+
chainId: ChainId.Testnet,
|
|
362
|
+
url: HIRO_API_BASE_URL_TESTNET
|
|
363
|
+
},
|
|
364
|
+
bitcoin: {
|
|
365
|
+
blockchain: "bitcoin",
|
|
366
|
+
bitcoinNetwork: "testnet3",
|
|
367
|
+
mode: "testnet",
|
|
368
|
+
bitcoinUrl: BITCOIN_API_BASE_URL_TESTNET3
|
|
369
|
+
}
|
|
370
|
+
}
|
|
336
371
|
};
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
372
|
+
const networkTestnet4 = {
|
|
373
|
+
id: WalletDefaultNetworkConfigurationIds.testnet4,
|
|
374
|
+
name: "Testnet4",
|
|
375
|
+
chain: {
|
|
376
|
+
stacks: {
|
|
377
|
+
blockchain: "stacks",
|
|
378
|
+
chainId: ChainId.Testnet,
|
|
379
|
+
url: HIRO_API_BASE_URL_TESTNET
|
|
380
|
+
},
|
|
381
|
+
bitcoin: {
|
|
382
|
+
blockchain: "bitcoin",
|
|
383
|
+
bitcoinNetwork: "testnet4",
|
|
384
|
+
mode: "testnet",
|
|
385
|
+
bitcoinUrl: BITCOIN_API_BASE_URL_TESTNET4
|
|
386
|
+
}
|
|
387
|
+
}
|
|
353
388
|
};
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
389
|
+
const networkSignet = {
|
|
390
|
+
id: WalletDefaultNetworkConfigurationIds.signet,
|
|
391
|
+
name: "Signet",
|
|
392
|
+
chain: {
|
|
393
|
+
stacks: {
|
|
394
|
+
blockchain: "stacks",
|
|
395
|
+
chainId: ChainId.Testnet,
|
|
396
|
+
url: HIRO_API_BASE_URL_TESTNET
|
|
397
|
+
},
|
|
398
|
+
bitcoin: {
|
|
399
|
+
blockchain: "bitcoin",
|
|
400
|
+
bitcoinNetwork: "signet",
|
|
401
|
+
mode: "signet",
|
|
402
|
+
bitcoinUrl: BITCOIN_API_BASE_URL_SIGNET
|
|
403
|
+
}
|
|
404
|
+
}
|
|
370
405
|
};
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
406
|
+
const networkSbtcTestnet = {
|
|
407
|
+
id: WalletDefaultNetworkConfigurationIds.sbtcTestnet,
|
|
408
|
+
name: "sBTC Testnet",
|
|
409
|
+
chain: {
|
|
410
|
+
stacks: {
|
|
411
|
+
blockchain: "stacks",
|
|
412
|
+
chainId: ChainId.Testnet,
|
|
413
|
+
url: HIRO_API_BASE_URL_TESTNET
|
|
414
|
+
},
|
|
415
|
+
bitcoin: {
|
|
416
|
+
blockchain: "bitcoin",
|
|
417
|
+
bitcoinNetwork: "regtest",
|
|
418
|
+
mode: "regtest",
|
|
419
|
+
bitcoinUrl: "https://beta.sbtc-mempool.tech/api/proxy"
|
|
420
|
+
}
|
|
421
|
+
}
|
|
387
422
|
};
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
423
|
+
const networkSbtcDevenv = {
|
|
424
|
+
id: WalletDefaultNetworkConfigurationIds.sbtcDevenv,
|
|
425
|
+
name: "sBTC Devenv",
|
|
426
|
+
chain: {
|
|
427
|
+
stacks: {
|
|
428
|
+
blockchain: "stacks",
|
|
429
|
+
chainId: ChainId.Testnet,
|
|
430
|
+
url: "http://localhost:3999"
|
|
431
|
+
},
|
|
432
|
+
bitcoin: {
|
|
433
|
+
blockchain: "bitcoin",
|
|
434
|
+
bitcoinNetwork: "regtest",
|
|
435
|
+
mode: "regtest",
|
|
436
|
+
bitcoinUrl: "http://localhost:3000/api/proxy"
|
|
437
|
+
}
|
|
438
|
+
}
|
|
404
439
|
};
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
440
|
+
const networkDevnet = {
|
|
441
|
+
id: WalletDefaultNetworkConfigurationIds.devnet,
|
|
442
|
+
name: "Devnet",
|
|
443
|
+
chain: {
|
|
444
|
+
stacks: {
|
|
445
|
+
blockchain: "stacks",
|
|
446
|
+
chainId: ChainId.Testnet,
|
|
447
|
+
url: "http://localhost:3999"
|
|
448
|
+
},
|
|
449
|
+
bitcoin: {
|
|
450
|
+
blockchain: "bitcoin",
|
|
451
|
+
bitcoinNetwork: "regtest",
|
|
452
|
+
mode: "regtest",
|
|
453
|
+
bitcoinUrl: "http://localhost:18443"
|
|
454
|
+
}
|
|
455
|
+
}
|
|
421
456
|
};
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
457
|
+
const defaultCurrentNetwork = networkMainnet;
|
|
458
|
+
const defaultNetworksKeyedById = {
|
|
459
|
+
[WalletDefaultNetworkConfigurationIds.mainnet]: networkMainnet,
|
|
460
|
+
[WalletDefaultNetworkConfigurationIds.testnet4]: networkTestnet4,
|
|
461
|
+
[WalletDefaultNetworkConfigurationIds.testnet]: networkTestnet,
|
|
462
|
+
[WalletDefaultNetworkConfigurationIds.signet]: networkSignet,
|
|
463
|
+
[WalletDefaultNetworkConfigurationIds.sbtcTestnet]: networkSbtcTestnet,
|
|
464
|
+
[WalletDefaultNetworkConfigurationIds.sbtcDevenv]: networkSbtcDevenv,
|
|
465
|
+
[WalletDefaultNetworkConfigurationIds.devnet]: networkDevnet
|
|
431
466
|
};
|
|
432
467
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/network/network.schema.ts
|
|
470
|
+
const bitcoinNetworkModesSchema = z.enum([...networkModes, ...testnetModes]);
|
|
471
|
+
const bitcoinNetworkSchema = z.enum([...bitcoinNetworks]);
|
|
472
|
+
const networkConfigurationSchema = z.object({
|
|
473
|
+
name: z.string(),
|
|
474
|
+
id: z.string(),
|
|
475
|
+
chain: z.object({
|
|
476
|
+
bitcoin: z.object({
|
|
477
|
+
blockchain: z.literal("bitcoin"),
|
|
478
|
+
bitcoinUrl: z.string(),
|
|
479
|
+
bitcoinNetwork: bitcoinNetworkSchema,
|
|
480
|
+
mode: bitcoinNetworkModesSchema
|
|
481
|
+
}),
|
|
482
|
+
stacks: z.object({
|
|
483
|
+
blockchain: z.literal("stacks"),
|
|
484
|
+
url: z.string(),
|
|
485
|
+
chainId: z.number(),
|
|
486
|
+
subnetChainId: z.number().optional()
|
|
487
|
+
})
|
|
488
|
+
})
|
|
454
489
|
});
|
|
455
490
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region src/settings.model.ts
|
|
493
|
+
const accountDisplayPreferenceSchema = z.enum([
|
|
494
|
+
"native-segwit",
|
|
495
|
+
"taproot",
|
|
496
|
+
"bns",
|
|
497
|
+
"stacks"
|
|
498
|
+
]);
|
|
499
|
+
const analyticsPreferenceSchema = z.enum(["consent-given", "rejects-tracking"]);
|
|
500
|
+
const emailAddressSchema = z.email({ error: "Invalid email address" });
|
|
461
501
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/swap/swap.model.ts
|
|
504
|
+
const swapProviderIds = [
|
|
505
|
+
"bitflow-sdk",
|
|
506
|
+
"sbtc-bridge",
|
|
507
|
+
"alex-sdk",
|
|
508
|
+
"velar-sdk"
|
|
509
|
+
];
|
|
510
|
+
const swapExecutionTypes = ["stacks-contract-call", "sbtc-bridge-transfer"];
|
|
465
511
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
512
|
+
//#endregion
|
|
513
|
+
//#region src/yield/yield-provider.model.ts
|
|
514
|
+
const YieldProviderKeys = {
|
|
515
|
+
bitflow: "bitflow",
|
|
516
|
+
zest: "zest",
|
|
517
|
+
granite: "granite",
|
|
518
|
+
stackingDao: "stackingdao",
|
|
519
|
+
lisa: "lisa",
|
|
520
|
+
hermetica: "hermetica",
|
|
521
|
+
fastPool: "fast-pool",
|
|
522
|
+
xverse: "xverse",
|
|
523
|
+
velar: "velar"
|
|
477
524
|
};
|
|
478
525
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/yield/yield-product.model.ts
|
|
528
|
+
const YieldProductKeys = {
|
|
529
|
+
bitflowAmmLp: "bitflow-amm-lp",
|
|
530
|
+
bitflowAmmStaking: "bitflow-amm-staking",
|
|
531
|
+
zestBorrowMarket: "zest-borrow-market",
|
|
532
|
+
graniteV1Earn: "granite-v1-earn",
|
|
533
|
+
graniteV1Borrow: "granite-v1-borrow",
|
|
534
|
+
stackingDaoStstx: "stackingdao-ststx",
|
|
535
|
+
stackingDaoStstxbtc: "stackingdao-ststxbtc",
|
|
536
|
+
stackingDaoPooledStacking: "stackingdao-pooled-stacking",
|
|
537
|
+
lisaListx: "lisa-listx",
|
|
538
|
+
lisaLiquidStaking: "lisa-liquid-staking",
|
|
539
|
+
hermeticaUsdhStaking: "hermetica-usdh-staking",
|
|
540
|
+
velarAmmLp: "velar-amm-lp",
|
|
541
|
+
velarPerps: "velar-perps",
|
|
542
|
+
velarAmmLpFarming: "velar-amm-lp-farming",
|
|
543
|
+
fastPoolPooledStacking: "fast-pool-pooled-stacking",
|
|
544
|
+
xversePooledStacking: "xverse-pooled-stacking"
|
|
497
545
|
};
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
546
|
+
const YieldProductCategories = {
|
|
547
|
+
AMM: "amm",
|
|
548
|
+
LENDING: "lending",
|
|
549
|
+
LIQUID_STACKING: "liquid-stacking",
|
|
550
|
+
POOLED_STACKING: "pooled-stacking",
|
|
551
|
+
STAKING: "staking",
|
|
552
|
+
PERPS: "perps"
|
|
505
553
|
};
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
554
|
+
const YieldProductToProviderMap = {
|
|
555
|
+
[YieldProductKeys.bitflowAmmLp]: YieldProviderKeys.bitflow,
|
|
556
|
+
[YieldProductKeys.bitflowAmmStaking]: YieldProviderKeys.bitflow,
|
|
557
|
+
[YieldProductKeys.zestBorrowMarket]: YieldProviderKeys.zest,
|
|
558
|
+
[YieldProductKeys.graniteV1Earn]: YieldProviderKeys.granite,
|
|
559
|
+
[YieldProductKeys.graniteV1Borrow]: YieldProviderKeys.granite,
|
|
560
|
+
[YieldProductKeys.stackingDaoStstx]: YieldProviderKeys.stackingDao,
|
|
561
|
+
[YieldProductKeys.stackingDaoStstxbtc]: YieldProviderKeys.stackingDao,
|
|
562
|
+
[YieldProductKeys.stackingDaoPooledStacking]: YieldProviderKeys.stackingDao,
|
|
563
|
+
[YieldProductKeys.lisaListx]: YieldProviderKeys.lisa,
|
|
564
|
+
[YieldProductKeys.lisaLiquidStaking]: YieldProviderKeys.lisa,
|
|
565
|
+
[YieldProductKeys.hermeticaUsdhStaking]: YieldProviderKeys.hermetica,
|
|
566
|
+
[YieldProductKeys.velarAmmLp]: YieldProviderKeys.velar,
|
|
567
|
+
[YieldProductKeys.velarPerps]: YieldProviderKeys.velar,
|
|
568
|
+
[YieldProductKeys.velarAmmLpFarming]: YieldProviderKeys.velar,
|
|
569
|
+
[YieldProductKeys.fastPoolPooledStacking]: YieldProviderKeys.fastPool,
|
|
570
|
+
[YieldProductKeys.xversePooledStacking]: YieldProviderKeys.xverse
|
|
523
571
|
};
|
|
524
572
|
|
|
525
|
-
|
|
573
|
+
//#endregion
|
|
574
|
+
//#region src/yield/helpers/yield.helpers.ts
|
|
526
575
|
function isBitflowAmmLpPosition(pos) {
|
|
527
|
-
|
|
576
|
+
return pos.product === YieldProductKeys.bitflowAmmLp;
|
|
528
577
|
}
|
|
529
578
|
function isBitflowAmmStakingPosition(pos) {
|
|
530
|
-
|
|
579
|
+
return pos.product === YieldProductKeys.bitflowAmmStaking;
|
|
531
580
|
}
|
|
532
581
|
function isZestPosition(pos) {
|
|
533
|
-
|
|
582
|
+
return pos.product === YieldProductKeys.zestBorrowMarket;
|
|
534
583
|
}
|
|
535
584
|
function isGraniteEarnPosition(pos) {
|
|
536
|
-
|
|
585
|
+
return pos.product === YieldProductKeys.graniteV1Earn;
|
|
537
586
|
}
|
|
538
587
|
function isGraniteBorrowPosition(pos) {
|
|
539
|
-
|
|
588
|
+
return pos.product === YieldProductKeys.graniteV1Borrow;
|
|
540
589
|
}
|
|
541
590
|
function isStackingDaoStStxPosition(pos) {
|
|
542
|
-
|
|
591
|
+
return pos.product === YieldProductKeys.stackingDaoStstx;
|
|
543
592
|
}
|
|
544
593
|
function isStackingDaoStStxBtcPosition(pos) {
|
|
545
|
-
|
|
594
|
+
return pos.product === YieldProductKeys.stackingDaoStstxbtc;
|
|
546
595
|
}
|
|
547
596
|
function isStackingDaoPooledPosition(pos) {
|
|
548
|
-
|
|
597
|
+
return pos.product === YieldProductKeys.stackingDaoPooledStacking;
|
|
549
598
|
}
|
|
550
599
|
function filterPositionsByProvider(positions, provider) {
|
|
551
|
-
|
|
600
|
+
return positions.filter((p) => p.provider === provider);
|
|
552
601
|
}
|
|
553
602
|
function filterPositionsByProduct(positions, product) {
|
|
554
|
-
|
|
603
|
+
return positions.filter((p) => p.product === product);
|
|
555
604
|
}
|
|
556
605
|
function filterPositionsByCategory(positions, products, category) {
|
|
557
|
-
|
|
558
|
-
|
|
606
|
+
const productMap = new Map(products.map((p) => [p.key, p]));
|
|
607
|
+
return positions.filter((pos) => productMap.get(pos.product)?.category === category);
|
|
559
608
|
}
|
|
560
609
|
function sortPositionsByBalance(positions, ascending = false) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
610
|
+
return [...positions].sort((a, b) => {
|
|
611
|
+
const diff = a.totalBalance.amount.comparedTo(b.totalBalance.amount);
|
|
612
|
+
return ascending ? diff : -diff;
|
|
613
|
+
});
|
|
565
614
|
}
|
|
566
615
|
function sortPositionsByApy(positions, ascending = false) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
616
|
+
return [...positions].sort((a, b) => {
|
|
617
|
+
const apyA = a.apy;
|
|
618
|
+
const apyB = b.apy;
|
|
619
|
+
return ascending ? apyA - apyB : apyB - apyA;
|
|
620
|
+
});
|
|
572
621
|
}
|
|
573
622
|
function sortPositionsByUpdateTime(positions, ascending = false) {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
623
|
+
return [...positions].sort((a, b) => {
|
|
624
|
+
const timeA = "updatedAt" in a && a.updatedAt instanceof Date ? a.updatedAt.getTime() : 0;
|
|
625
|
+
const timeB = "updatedAt" in b && b.updatedAt instanceof Date ? b.updatedAt.getTime() : 0;
|
|
626
|
+
return ascending ? timeA - timeB : timeB - timeA;
|
|
627
|
+
});
|
|
579
628
|
}
|
|
580
629
|
function getProviderForProduct(product) {
|
|
581
|
-
|
|
630
|
+
return YieldProductToProviderMap[product];
|
|
582
631
|
}
|
|
583
632
|
function getCategoryForProduct(product) {
|
|
584
|
-
|
|
633
|
+
return product.category;
|
|
585
634
|
}
|
|
586
635
|
function isProductInProvider(product, provider) {
|
|
587
|
-
|
|
636
|
+
return YieldProductToProviderMap[product] === provider;
|
|
588
637
|
}
|
|
589
638
|
function getProductsForProvider(provider) {
|
|
590
|
-
|
|
639
|
+
return Object.entries(YieldProductToProviderMap).filter(([_, p]) => p === provider).map(([product]) => product);
|
|
591
640
|
}
|
|
592
641
|
function getProductsInCategory(products, category) {
|
|
593
|
-
|
|
642
|
+
return products.filter((p) => p.category === category);
|
|
594
643
|
}
|
|
595
644
|
function groupPositionsByProvider(positions) {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}
|
|
604
|
-
return grouped;
|
|
645
|
+
const grouped = {};
|
|
646
|
+
for (const position of positions) {
|
|
647
|
+
const provider = position.provider;
|
|
648
|
+
if (!grouped[provider]) grouped[provider] = [];
|
|
649
|
+
grouped[provider].push(position);
|
|
650
|
+
}
|
|
651
|
+
return grouped;
|
|
605
652
|
}
|
|
606
653
|
function groupPositionsByCategory(positions, products) {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
return grouped;
|
|
654
|
+
const grouped = {};
|
|
655
|
+
const productMap = new Map(products.map((p) => [p.key, p]));
|
|
656
|
+
for (const position of positions) {
|
|
657
|
+
const product = productMap.get(position.product);
|
|
658
|
+
if (!product) continue;
|
|
659
|
+
const category = product.category;
|
|
660
|
+
if (!grouped[category]) grouped[category] = [];
|
|
661
|
+
grouped[category].push(position);
|
|
662
|
+
}
|
|
663
|
+
return grouped;
|
|
619
664
|
}
|
|
620
665
|
function getPositionsInCategories(positions, products, categories) {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
666
|
+
const categorySet = new Set(categories);
|
|
667
|
+
const productMap = new Map(products.map((p) => [p.key, p]));
|
|
668
|
+
return positions.filter((pos) => {
|
|
669
|
+
const product = productMap.get(pos.product);
|
|
670
|
+
return product && categorySet.has(product.category);
|
|
671
|
+
});
|
|
627
672
|
}
|
|
628
673
|
function hasPositionsInProvider(positions, provider) {
|
|
629
|
-
|
|
674
|
+
return positions.some((p) => p.provider === provider);
|
|
630
675
|
}
|
|
631
676
|
function hasPositionsInCategory(positions, products, category) {
|
|
632
|
-
|
|
633
|
-
|
|
677
|
+
const productMap = new Map(products.map((p) => [p.key, p]));
|
|
678
|
+
return positions.some((pos) => productMap.get(pos.product)?.category === category);
|
|
634
679
|
}
|
|
635
680
|
function enrichPositionWithProvider(position, provider) {
|
|
636
|
-
|
|
681
|
+
return {
|
|
682
|
+
...position,
|
|
683
|
+
providerData: provider
|
|
684
|
+
};
|
|
637
685
|
}
|
|
638
686
|
function enrichPositionWithProduct(position, product) {
|
|
639
|
-
|
|
687
|
+
return {
|
|
688
|
+
...position,
|
|
689
|
+
productData: product
|
|
690
|
+
};
|
|
640
691
|
}
|
|
641
692
|
function enrichPositionWithMetadata(position, provider, product) {
|
|
642
|
-
|
|
693
|
+
return {
|
|
694
|
+
...position,
|
|
695
|
+
providerData: provider,
|
|
696
|
+
productData: product
|
|
697
|
+
};
|
|
643
698
|
}
|
|
644
699
|
function getCategoryDisplayName(category) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
return displayNames[category] || category;
|
|
700
|
+
return {
|
|
701
|
+
[YieldProductCategories.AMM]: "Liquidity Pools",
|
|
702
|
+
[YieldProductCategories.LENDING]: "Lending & Borrowing",
|
|
703
|
+
[YieldProductCategories.LIQUID_STACKING]: "Liquid Stacking",
|
|
704
|
+
[YieldProductCategories.POOLED_STACKING]: "Pooled Stacking",
|
|
705
|
+
[YieldProductCategories.STAKING]: "Staking",
|
|
706
|
+
[YieldProductCategories.PERPS]: "Perpetuals"
|
|
707
|
+
}[category] || category;
|
|
654
708
|
}
|
|
655
709
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region src/activity/activity.utils.ts
|
|
712
|
+
const HIRO_EXPLORER_URL = "https://explorer.hiro.so";
|
|
713
|
+
const MEMPOOL_BASE_URL = "https://mempool.space";
|
|
659
714
|
function makeActivityLink({ txid, networkPreference, asset }) {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
return `${explorerUrl}/txid/${txid}?${searchParams.toString()}`;
|
|
696
|
-
}
|
|
697
|
-
function getMempoolExplorerLink({
|
|
698
|
-
id,
|
|
699
|
-
type,
|
|
700
|
-
networkPreference
|
|
701
|
-
}) {
|
|
702
|
-
switch (networkPreference) {
|
|
703
|
-
case "mainnet":
|
|
704
|
-
return `${MEMPOOL_BASE_URL}/${type}/${id}`;
|
|
705
|
-
case "testnet4":
|
|
706
|
-
return `${MEMPOOL_BASE_URL}/testnet4/${type}/${id}`;
|
|
707
|
-
case "signet":
|
|
708
|
-
return `${MEMPOOL_BASE_URL}/signet/${type}/${id}`;
|
|
709
|
-
default:
|
|
710
|
-
return null;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
export {
|
|
714
|
-
ActivityLevels,
|
|
715
|
-
BESTINSLOT_API_BASE_URL_MAINNET,
|
|
716
|
-
BESTINSLOT_API_BASE_URL_TESTNET,
|
|
717
|
-
BITCOIN_API_BASE_URL_MAINNET,
|
|
718
|
-
BITCOIN_API_BASE_URL_SIGNET,
|
|
719
|
-
BITCOIN_API_BASE_URL_TESTNET3,
|
|
720
|
-
BITCOIN_API_BASE_URL_TESTNET4,
|
|
721
|
-
BNS_V2_API_BASE_URL,
|
|
722
|
-
BtcFeeType,
|
|
723
|
-
ChainId,
|
|
724
|
-
CryptoAssetCategories,
|
|
725
|
-
CryptoAssetChains,
|
|
726
|
-
CryptoAssetProtocols,
|
|
727
|
-
FeeCalculationTypes,
|
|
728
|
-
FeeTypes,
|
|
729
|
-
FungibleCryptoAssetProtocols,
|
|
730
|
-
GeneralActivityTypes,
|
|
731
|
-
HIRO_API_BASE_URL_MAINNET,
|
|
732
|
-
HIRO_API_BASE_URL_MAINNET_EXTENDED,
|
|
733
|
-
HIRO_API_BASE_URL_NAKAMOTO_TESTNET,
|
|
734
|
-
HIRO_API_BASE_URL_TESTNET,
|
|
735
|
-
HIRO_API_BASE_URL_TESTNET_EXTENDED,
|
|
736
|
-
NonFungibleCryptoAssetProtocols,
|
|
737
|
-
OnChainActivityStatuses,
|
|
738
|
-
OnChainActivityTypes,
|
|
739
|
-
STX20_API_BASE_URL_MAINNET,
|
|
740
|
-
WalletActivityTypes,
|
|
741
|
-
WalletDefaultNetworkConfigurationIds,
|
|
742
|
-
YieldProductCategories,
|
|
743
|
-
YieldProductKeys,
|
|
744
|
-
YieldProductToProviderMap,
|
|
745
|
-
YieldProviderKeys,
|
|
746
|
-
accountAddressesSchema,
|
|
747
|
-
accountDisplayPreferenceSchema,
|
|
748
|
-
accountIdSchema,
|
|
749
|
-
analyticsPreferenceSchema,
|
|
750
|
-
bitcoinAddressInfoSchema,
|
|
751
|
-
bitcoinNetworkModesSchema,
|
|
752
|
-
bitcoinNetworkSchema,
|
|
753
|
-
bitcoinNetworkToNetworkMode,
|
|
754
|
-
bitcoinNetworks,
|
|
755
|
-
bitcoinUnitSchema,
|
|
756
|
-
bnsContractAddress,
|
|
757
|
-
bnsContractName,
|
|
758
|
-
btcTxTimeMap,
|
|
759
|
-
createMarketData,
|
|
760
|
-
createMarketPair,
|
|
761
|
-
defaultCurrentNetwork,
|
|
762
|
-
defaultNetworkConfigurationsSchema,
|
|
763
|
-
defaultNetworksKeyedById,
|
|
764
|
-
emailAddressSchema,
|
|
765
|
-
enrichPositionWithMetadata,
|
|
766
|
-
enrichPositionWithProduct,
|
|
767
|
-
enrichPositionWithProvider,
|
|
768
|
-
filterPositionsByCategory,
|
|
769
|
-
filterPositionsByProduct,
|
|
770
|
-
filterPositionsByProvider,
|
|
771
|
-
formatMarketPair,
|
|
772
|
-
getCategoryDisplayName,
|
|
773
|
-
getCategoryForProduct,
|
|
774
|
-
getMempoolExplorerLink,
|
|
775
|
-
getPositionsInCategories,
|
|
776
|
-
getProductsForProvider,
|
|
777
|
-
getProductsInCategory,
|
|
778
|
-
getProviderForProduct,
|
|
779
|
-
groupPositionsByCategory,
|
|
780
|
-
groupPositionsByProvider,
|
|
781
|
-
hasPositionsInCategory,
|
|
782
|
-
hasPositionsInProvider,
|
|
783
|
-
historicalPeriods,
|
|
784
|
-
inscriptionMimeTypes,
|
|
785
|
-
isBitflowAmmLpPosition,
|
|
786
|
-
isBitflowAmmStakingPosition,
|
|
787
|
-
isBrc20Asset,
|
|
788
|
-
isBtcAsset,
|
|
789
|
-
isFungibleAsset,
|
|
790
|
-
isGraniteBorrowPosition,
|
|
791
|
-
isGraniteEarnPosition,
|
|
792
|
-
isInscriptionAsset,
|
|
793
|
-
isNativeAsset,
|
|
794
|
-
isNonFungibleAsset,
|
|
795
|
-
isProductInProvider,
|
|
796
|
-
isRuneAsset,
|
|
797
|
-
isSip10Asset,
|
|
798
|
-
isSip9Asset,
|
|
799
|
-
isSrc20Asset,
|
|
800
|
-
isStackingDaoPooledPosition,
|
|
801
|
-
isStackingDaoStStxBtcPosition,
|
|
802
|
-
isStackingDaoStStxPosition,
|
|
803
|
-
isStampAsset,
|
|
804
|
-
isStx20Asset,
|
|
805
|
-
isStxAsset,
|
|
806
|
-
isSwappableAsset,
|
|
807
|
-
isZestPosition,
|
|
808
|
-
makeActivityLink,
|
|
809
|
-
networkConfigurationSchema,
|
|
810
|
-
networkModes,
|
|
811
|
-
sip9ContentTypes,
|
|
812
|
-
sortPositionsByApy,
|
|
813
|
-
sortPositionsByBalance,
|
|
814
|
-
sortPositionsByUpdateTime,
|
|
815
|
-
stacksAddressInfoSchema,
|
|
816
|
-
supportedBlockchains,
|
|
817
|
-
swapExecutionTypes,
|
|
818
|
-
swapProviderIds,
|
|
819
|
-
testnetModes,
|
|
820
|
-
transactionFeeQuoteType,
|
|
821
|
-
transactionFeeTiers,
|
|
822
|
-
walletIdSchema
|
|
823
|
-
};
|
|
715
|
+
if (txid && asset) return makeActivityExplorerLink({
|
|
716
|
+
asset,
|
|
717
|
+
txid,
|
|
718
|
+
networkPreference
|
|
719
|
+
});
|
|
720
|
+
return null;
|
|
721
|
+
}
|
|
722
|
+
function makeActivityExplorerLink({ asset, txid, networkPreference }) {
|
|
723
|
+
if (asset.chain === "bitcoin") return getMempoolExplorerLink({
|
|
724
|
+
networkPreference: networkPreference.chain.bitcoin.bitcoinNetwork,
|
|
725
|
+
id: txid,
|
|
726
|
+
type: "txid"
|
|
727
|
+
});
|
|
728
|
+
return makeStacksTxExplorerLink({
|
|
729
|
+
networkPreference: networkPreference.chain.stacks.chainId === ChainId.Testnet ? "testnet" : "mainnet",
|
|
730
|
+
searchParams: void 0,
|
|
731
|
+
txid,
|
|
732
|
+
explorerUrl: HIRO_EXPLORER_URL
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
function makeStacksTxExplorerLink({ networkPreference, searchParams = new URLSearchParams(), txid, explorerUrl }) {
|
|
736
|
+
searchParams.append("chain", networkPreference);
|
|
737
|
+
return `${explorerUrl}/txid/${txid}?${searchParams.toString()}`;
|
|
738
|
+
}
|
|
739
|
+
function getMempoolExplorerLink({ id, type, networkPreference }) {
|
|
740
|
+
switch (networkPreference) {
|
|
741
|
+
case "mainnet": return `${MEMPOOL_BASE_URL}/${type}/${id}`;
|
|
742
|
+
case "testnet4": return `${MEMPOOL_BASE_URL}/testnet4/${type}/${id}`;
|
|
743
|
+
case "signet": return `${MEMPOOL_BASE_URL}/signet/${type}/${id}`;
|
|
744
|
+
default: return null;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
//#endregion
|
|
749
|
+
export { ActivityLevels, BESTINSLOT_API_BASE_URL_MAINNET, BESTINSLOT_API_BASE_URL_TESTNET, BITCOIN_API_BASE_URL_MAINNET, BITCOIN_API_BASE_URL_SIGNET, BITCOIN_API_BASE_URL_TESTNET3, BITCOIN_API_BASE_URL_TESTNET4, BNS_V2_API_BASE_URL, BtcFeeType, ChainId, CryptoAssetCategories, CryptoAssetChains, CryptoAssetProtocols, FeeCalculationTypes, FeeTypes, FungibleCryptoAssetProtocols, GeneralActivityTypes, HIRO_API_BASE_URL_MAINNET, HIRO_API_BASE_URL_MAINNET_EXTENDED, HIRO_API_BASE_URL_NAKAMOTO_TESTNET, HIRO_API_BASE_URL_TESTNET, HIRO_API_BASE_URL_TESTNET_EXTENDED, NonFungibleCryptoAssetProtocols, OnChainActivityStatuses, OnChainActivityTypes, STX20_API_BASE_URL_MAINNET, WalletActivityTypes, WalletDefaultNetworkConfigurationIds, YieldProductCategories, YieldProductKeys, YieldProductToProviderMap, YieldProviderKeys, accountAddressesSchema, accountDisplayPreferenceSchema, accountIdSchema, analyticsPreferenceSchema, bitcoinAddressInfoSchema, bitcoinNetworkModesSchema, bitcoinNetworkSchema, bitcoinNetworkToNetworkMode, bitcoinNetworks, bitcoinUnitSchema, bnsContractAddress, bnsContractName, btcTxTimeMap, createMarketData, createMarketPair, defaultCurrentNetwork, defaultNetworkConfigurationsSchema, defaultNetworksKeyedById, emailAddressSchema, enrichPositionWithMetadata, enrichPositionWithProduct, enrichPositionWithProvider, filterPositionsByCategory, filterPositionsByProduct, filterPositionsByProvider, formatMarketPair, getCategoryDisplayName, getCategoryForProduct, getMempoolExplorerLink, getPositionsInCategories, getProductsForProvider, getProductsInCategory, getProviderForProduct, groupPositionsByCategory, groupPositionsByProvider, hasPositionsInCategory, hasPositionsInProvider, historicalPeriods, inscriptionMimeTypes, isBitflowAmmLpPosition, isBitflowAmmStakingPosition, isBrc20Asset, isBtcAsset, isFungibleAsset, isGraniteBorrowPosition, isGraniteEarnPosition, isInscriptionAsset, isNativeAsset, isNonFungibleAsset, isProductInProvider, isRuneAsset, isSip10Asset, isSip9Asset, isSrc20Asset, isStackingDaoPooledPosition, isStackingDaoStStxBtcPosition, isStackingDaoStStxPosition, isStampAsset, isStx20Asset, isStxAsset, isSwappableAsset, isZestPosition, makeActivityLink, networkConfigurationSchema, networkModes, sip9ContentTypes, sortPositionsByApy, sortPositionsByBalance, sortPositionsByUpdateTime, stacksAddressInfoSchema, supportedBlockchains, swapExecutionTypes, swapProviderIds, testnetModes, transactionFeeQuoteType, transactionFeeTiers, walletIdSchema };
|
|
824
750
|
//# sourceMappingURL=index.js.map
|