@lumenwipe/verify 0.0.0-stage → 0.2.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/dist/index.cjs ADDED
@@ -0,0 +1,2372 @@
1
+ 'use strict';
2
+
3
+ var stellarSdk = require('@stellar/stellar-sdk');
4
+
5
+ // ../../apps/web/config/networks.ts
6
+ var NETWORK_PASSPHRASES = {
7
+ mainnet: "Public Global Stellar Network ; September 2015",
8
+ testnet: "Test SDF Network ; September 2015"
9
+ };
10
+
11
+ // ../../apps/api/src/config/exchange-registry.json
12
+ var exchange_registry_default = {
13
+ lastVerified: "2026-10-10",
14
+ validUntil: "2027-01-08",
15
+ entries: [
16
+ {
17
+ address: "GB5CLRWUCBQ6DFK2LR5ZMWJ7QCVEB3XKMPTQUYCDIYB4DRZJBEW6M26D",
18
+ name: "Coinbase",
19
+ domain: "coinbase.com",
20
+ requiresMediator: true,
21
+ requiresMemo: true,
22
+ memoType: "text"
23
+ },
24
+ {
25
+ address: "GBOYDKMW7MKSXV3UAPTEWVF3IX2EIJ4YOCEH6MOO5XTYOJKIH73YESVB",
26
+ name: "Coinbase",
27
+ domain: "coinbase.com",
28
+ requiresMediator: true,
29
+ requiresMemo: true,
30
+ memoType: "text"
31
+ },
32
+ {
33
+ address: "GABFQIK63R2NETJM7T673EAMZN4RJLLGP3OFUEJU5SZVTGWUKULZJNL6",
34
+ name: "Binance",
35
+ domain: "binance.com",
36
+ requiresMediator: true,
37
+ requiresMemo: true,
38
+ memoType: "text"
39
+ },
40
+ {
41
+ address: "GAHK7EEG2WWHVKDNT4CEQFZGKF2LGDSW2IVM4S5DP42RBW3K6BTODB4A",
42
+ name: "Binance",
43
+ domain: "binance.com",
44
+ requiresMediator: true,
45
+ requiresMemo: true,
46
+ memoType: "text"
47
+ },
48
+ {
49
+ address: "GA5XIGA5C7QTPTWXQHY6MCJRMTRZDOSHR6EFIBNDQTCQHG262N4GGKTM",
50
+ name: "Kraken",
51
+ domain: "kraken.com",
52
+ requiresMediator: true,
53
+ requiresMemo: true,
54
+ memoType: "id"
55
+ },
56
+ {
57
+ address: "GAQZU7Y7GB3E4XOA3ZXEZDOTIEIWQRYOAIVJ6STY2YTUQAGZL3GYJCXG",
58
+ name: "Kraken",
59
+ domain: "kraken.com",
60
+ requiresMediator: true,
61
+ requiresMemo: true,
62
+ memoType: "id"
63
+ },
64
+ {
65
+ address: "GBBALM76B5OUPOZCMFCNT5PVIFV3WTUYX3VVGC7FMN4ZPQLGCG2C4X3D",
66
+ name: "Kraken",
67
+ domain: "kraken.com",
68
+ requiresMediator: true,
69
+ requiresMemo: true,
70
+ memoType: "id"
71
+ },
72
+ {
73
+ address: "GAWPTHY6233GRWZZ7JXDMVXDUDCVQVVQ2SXCSTG3R3CNP5LQPDAHNBKL",
74
+ name: "Bitfinex",
75
+ domain: "bitfinex.com",
76
+ requiresMediator: true,
77
+ requiresMemo: true,
78
+ memoType: "text"
79
+ },
80
+ {
81
+ address: "GBGII2C7M4TOEC2MVAZYG3TRFM3ATCCEWANSN4Q3AHEX3NRKXJCVZDEV",
82
+ name: "OKX",
83
+ domain: "okx.com",
84
+ requiresMediator: true,
85
+ requiresMemo: true,
86
+ memoType: "text"
87
+ },
88
+ {
89
+ address: "GA3NTBDIKQVDDM6ZDKJLGXJFESWJ636AGRIW34RH5WL24LUMX3YASKX2",
90
+ name: "Bitstamp",
91
+ domain: "bitstamp.net",
92
+ requiresMediator: true,
93
+ requiresMemo: true,
94
+ memoType: "id"
95
+ },
96
+ {
97
+ address: "GAJ4BSGJE6UQHZAZ5U5IUOABPDCYPKPS3RFS2NVNGFGFXGVQDLBQJW2P",
98
+ name: "KuCoin",
99
+ domain: "kucoin.com",
100
+ requiresMediator: true,
101
+ requiresMemo: true,
102
+ memoType: "text"
103
+ },
104
+ {
105
+ address: "GBJNV2MQA7M5GNBRDFW46JLXIN7ZLYVVM4UW4CWDZO4KZKXIXCRYHMH2",
106
+ name: "KuCoin",
107
+ domain: "kucoin.com",
108
+ requiresMediator: true,
109
+ requiresMemo: true,
110
+ memoType: "text"
111
+ },
112
+ {
113
+ address: "GB67TJFJO3GUA432EJ4JTODHFYSBTM44P4XQCDOFTXJNNPV2UKUJYVBF",
114
+ name: "Crypto.com",
115
+ domain: "crypto.com",
116
+ requiresMediator: true,
117
+ requiresMemo: true,
118
+ memoType: "text"
119
+ },
120
+ {
121
+ address: "GBC6NRTTQLRCABQHIR5J4R4YDJWFWRAO4ZRQIM2SVI5GSIZ2HZ42RINW",
122
+ name: "Gate.io",
123
+ domain: "gate.io",
124
+ requiresMediator: true,
125
+ requiresMemo: true,
126
+ memoType: "text"
127
+ },
128
+ {
129
+ address: "GB2ES2N326MZK4EGJBKN3ZARCQ5RTFQSAWIJAAKFVIIIJSCC35TXIMLB",
130
+ name: "Robinhood",
131
+ domain: "robinhood.com",
132
+ requiresMediator: true,
133
+ requiresMemo: true,
134
+ memoType: "id"
135
+ },
136
+ {
137
+ address: "GAW4E6NGM4NPNX2LO2BKDPCCTUX3FJLKWHPU4VQPGBIBQGD6JTVF5C7C",
138
+ name: "Upbit",
139
+ domain: "upbit.com",
140
+ requiresMediator: true,
141
+ requiresMemo: true,
142
+ memoType: "text"
143
+ },
144
+ {
145
+ address: "GABRNO3RCFT5VS3JZ5K6A5PBVI47BKKNO6SH3XFQQHIPCW5AWIU3F4SL",
146
+ name: "Bitpanda",
147
+ domain: "bitpanda.com",
148
+ requiresMediator: true,
149
+ requiresMemo: true,
150
+ memoType: "text"
151
+ },
152
+ {
153
+ address: "GB3RMPTL47E4ULVANHBNCXSXM2ZA5JFY5ISDRERPCXNJUDEO73QFZUNK",
154
+ name: "CEX.IO",
155
+ domain: "cex.io",
156
+ requiresMediator: true,
157
+ requiresMemo: true,
158
+ memoType: "text"
159
+ },
160
+ {
161
+ address: "GBF6SZEZ4AJY7BCBUV3ZYJ3Q27YMO4NJU6IZQP7ODY47MPVFWCO24SNW",
162
+ name: "Blockchain.com",
163
+ domain: "blockchain.com",
164
+ requiresMediator: true,
165
+ requiresMemo: true,
166
+ memoType: "text"
167
+ },
168
+ {
169
+ address: "GARAR5QR7WRL24MQMSO4INWV7C5SE4EE2YVXTLD6ORONYFHSUAGZYSLN",
170
+ name: "Blockchain.com",
171
+ domain: "blockchain.com",
172
+ requiresMediator: true,
173
+ requiresMemo: true,
174
+ memoType: "text"
175
+ }
176
+ ]
177
+ };
178
+
179
+ // ../../apps/web/lib/exchange-registry/merge.ts
180
+ function isUsableEntry(e) {
181
+ if (typeof e !== "object" || e === null) return false;
182
+ const r = e;
183
+ return typeof r.address === "string" && r.address.startsWith("G") && r.address.length === 56 && typeof r.name === "string" && typeof r.requiresMediator === "boolean" && typeof r.requiresMemo === "boolean" && (r.memoType === "text" || r.memoType === "id" || r.memoType === "hash");
184
+ }
185
+ function tightenedOver(embeddedEntry, servedEntry) {
186
+ return {
187
+ ...servedEntry,
188
+ requiresMemo: embeddedEntry.requiresMemo || servedEntry.requiresMemo,
189
+ requiresMediator: embeddedEntry.requiresMediator || servedEntry.requiresMediator,
190
+ // Never taken from the served copy. A memo sent under the wrong type reaches the right
191
+ // address and is credited to nobody, so a served type that differs is recorded as a dispute
192
+ // (`mergeServedRegistry`) and the close is refused until the bundled copy is updated.
193
+ memoType: embeddedEntry.memoType
194
+ };
195
+ }
196
+ var MAX_EXTENSION_DAYS = 120;
197
+ function boundedValidUntil(embeddedUntil, servedUntil) {
198
+ const embedded = Date.parse(`${embeddedUntil}T23:59:59Z`);
199
+ const served = Date.parse(`${servedUntil}T23:59:59Z`);
200
+ if (!Number.isFinite(served)) return embeddedUntil;
201
+ const cap = embedded + MAX_EXTENSION_DAYS * 864e5;
202
+ if (served < embedded) return embeddedUntil;
203
+ return served <= cap ? servedUntil : embeddedUntil;
204
+ }
205
+ function mergeServedRegistry(floor, body) {
206
+ if (typeof body !== "object" || body === null) return null;
207
+ const served = body;
208
+ if (!Array.isArray(served.entries) || typeof served.lastVerified !== "string" || typeof served.validUntil !== "string") {
209
+ return null;
210
+ }
211
+ const embeddedByAddress = new Map(floor.entries.map((e) => [e.address, e]));
212
+ const merged = new Map(embeddedByAddress);
213
+ const disputes = /* @__PURE__ */ new Set();
214
+ for (const servedEntry of served.entries.filter(isUsableEntry)) {
215
+ const embeddedEntry = embeddedByAddress.get(servedEntry.address);
216
+ if (embeddedEntry && embeddedEntry.memoType !== servedEntry.memoType) {
217
+ disputes.add(servedEntry.address);
218
+ }
219
+ merged.set(
220
+ servedEntry.address,
221
+ embeddedEntry ? tightenedOver(embeddedEntry, servedEntry) : servedEntry
222
+ );
223
+ }
224
+ return {
225
+ entries: [...merged.values()],
226
+ lastVerified: served.lastVerified,
227
+ validUntil: boundedValidUntil(floor.validUntil, served.validUntil),
228
+ memoTypeDisputes: [...disputes]
229
+ };
230
+ }
231
+ function isUsableAt(validUntil, now) {
232
+ const until = Date.parse(`${validUntil}T23:59:59Z`);
233
+ return Number.isFinite(until) && now.getTime() <= until;
234
+ }
235
+
236
+ // ../../apps/web/lib/exchange-registry/index.ts
237
+ function snapshotFrom(data, served) {
238
+ return {
239
+ entries: data.entries,
240
+ lastVerified: data.lastVerified,
241
+ validUntil: data.validUntil,
242
+ served
243
+ };
244
+ }
245
+ var EMBEDDED = snapshotFrom(exchange_registry_default, false);
246
+ var current = EMBEDDED;
247
+ function bundledRegistry() {
248
+ return EMBEDDED;
249
+ }
250
+ function isRegistryUsable(now = /* @__PURE__ */ new Date()) {
251
+ return isUsableAt(current.validUntil, now);
252
+ }
253
+ function byAddress() {
254
+ return new Map(current.entries.map((e) => [e.address, e]));
255
+ }
256
+ function lookupExchange(address) {
257
+ return byAddress().get(address) ?? null;
258
+ }
259
+ function mediatorAllowedFor(address) {
260
+ return EMBEDDED.entries.find((e) => e.address === address)?.requiresMediator === true;
261
+ }
262
+ function memoTypeInDispute(address) {
263
+ return current.memoTypeDisputes?.includes(address) ?? false;
264
+ }
265
+ function collectAddress(address, into) {
266
+ switch (address.type) {
267
+ case "scAddressTypeAccount":
268
+ into.accounts.add(stellarSdk.Address.fromScAddress(address).toString());
269
+ return;
270
+ case "scAddressTypeContract":
271
+ into.contracts.add(stellarSdk.Address.fromScAddress(address).toString());
272
+ return;
273
+ default:
274
+ into.unsupported += 1;
275
+ }
276
+ }
277
+ function collectFromValue(value, into) {
278
+ switch (value.type) {
279
+ case "scvAddress":
280
+ collectAddress(value.address, into);
281
+ return;
282
+ case "scvVec":
283
+ for (const item of value.vec ?? []) collectFromValue(item, into);
284
+ return;
285
+ case "scvMap":
286
+ for (const entry of value.map ?? []) {
287
+ collectFromValue(entry.key, into);
288
+ collectFromValue(entry.val, into);
289
+ }
290
+ return;
291
+ default:
292
+ return;
293
+ }
294
+ }
295
+ function sameValues(a, b) {
296
+ return a.length === b.length && a.every((v, i) => v.toXdr("base64") === b[i].toXdr("base64"));
297
+ }
298
+ function collectFromInvocation(node, into, subInvocations, topLevel, isEntryRoot) {
299
+ const fn = node.function;
300
+ if (fn.type !== "sorobanAuthorizedFunctionTypeContractFn") {
301
+ return false;
302
+ }
303
+ const call = fn.contractFn;
304
+ const contract = stellarSdk.Address.fromScAddress(call.contractAddress).toString();
305
+ const functionName = call.functionName.toString();
306
+ collectAddress(call.contractAddress, into);
307
+ for (const arg of call.args) collectFromValue(arg, into);
308
+ const isTopLevelCall = isEntryRoot && contract === topLevel.contract && functionName === topLevel.function && sameValues(call.args, topLevel.args);
309
+ if (!isTopLevelCall) {
310
+ subInvocations.push({ contract, function: functionName, args: call.args.map(render) });
311
+ }
312
+ let plain = true;
313
+ for (const sub of node.subInvocations) {
314
+ plain = collectFromInvocation(sub, into, subInvocations, topLevel, false) && plain;
315
+ }
316
+ return plain;
317
+ }
318
+ function invocationDepth(node) {
319
+ let deepest = 0;
320
+ for (const sub of node.subInvocations) deepest = Math.max(deepest, 1 + invocationDepth(sub));
321
+ return deepest;
322
+ }
323
+ function render(value) {
324
+ try {
325
+ const native = stellarSdk.scValToNative(value);
326
+ if (typeof native === "string") return native;
327
+ if (typeof native === "bigint" || typeof native === "number") return native.toString();
328
+ return JSON.stringify(native, (_k, v) => typeof v === "bigint" ? v.toString() : v);
329
+ } catch {
330
+ return value.toXdr("base64");
331
+ }
332
+ }
333
+ function describeInvocation(op) {
334
+ const func = op.func;
335
+ if (func.type !== "hostFunctionTypeInvokeContract") {
336
+ return { type: "unknown" };
337
+ }
338
+ const invocation = func.invokeContract;
339
+ const referenced = { accounts: /* @__PURE__ */ new Set(), contracts: /* @__PURE__ */ new Set(), unsupported: 0 };
340
+ const args = invocation.args;
341
+ for (const arg of args) collectFromValue(arg, referenced);
342
+ const topLevel = {
343
+ contract: stellarSdk.Address.fromScAddress(invocation.contractAddress).toString(),
344
+ function: invocation.functionName.toString(),
345
+ args
346
+ };
347
+ let authorizesBeyondSelf = false;
348
+ let authDepth = 0;
349
+ const subInvocations = [];
350
+ for (const entry of op.auth ?? []) {
351
+ authDepth = Math.max(authDepth, invocationDepth(entry.rootInvocation));
352
+ if (entry.credentials.type !== "sorobanCredentialsSourceAccount") {
353
+ authorizesBeyondSelf = true;
354
+ }
355
+ if (!collectFromInvocation(entry.rootInvocation, referenced, subInvocations, topLevel, true)) {
356
+ authorizesBeyondSelf = true;
357
+ }
358
+ }
359
+ const described = {
360
+ type: "invoke_host_function",
361
+ contract: topLevel.contract,
362
+ function: topLevel.function,
363
+ args: args.map(render),
364
+ accountsReferenced: [...referenced.accounts].sort(),
365
+ contractsReferenced: [...referenced.contracts].sort(),
366
+ unsupportedAddressCount: referenced.unsupported,
367
+ subInvocations,
368
+ authorizesBeyondSelf,
369
+ authDepth
370
+ };
371
+ return described;
372
+ }
373
+
374
+ // ../../apps/web/lib/stellar/hex.ts
375
+ function toHex(bytes) {
376
+ return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
377
+ }
378
+ function toBase64(bytes) {
379
+ return btoa(String.fromCharCode(...bytes));
380
+ }
381
+
382
+ // ../../apps/web/lib/stellar/verification-error.ts
383
+ var VerificationError = class extends Error {
384
+ constructor(code, message) {
385
+ super(message);
386
+ this.name = "VerificationError";
387
+ this.code = code;
388
+ }
389
+ };
390
+
391
+ // ../../apps/web/lib/stellar/intent/serialize.ts
392
+ function signerBytes(value) {
393
+ if (!(value instanceof Uint8Array)) throw new Error("Signer key was not decoded to raw bytes.");
394
+ return value;
395
+ }
396
+ var STRICT_UTF8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
397
+ function memoToString(value, type) {
398
+ if (value == null || value === "") return null;
399
+ if (typeof value === "string") return value;
400
+ if (type !== "text") return toHex(value);
401
+ try {
402
+ return STRICT_UTF8.decode(value);
403
+ } catch {
404
+ throw new VerificationError(
405
+ "memo_invalid_text",
406
+ "The transaction carries a memo that is not valid text."
407
+ );
408
+ }
409
+ }
410
+ function assetToString(asset) {
411
+ return asset.isNative() ? "native" : `${asset.getCode()}:${asset.getIssuer()}`;
412
+ }
413
+ function decodeSigner(signer) {
414
+ if ("ed25519PublicKey" in signer) {
415
+ return {
416
+ type: "ed25519_public_key",
417
+ key: signer.ed25519PublicKey,
418
+ weight: Number(signer.weight)
419
+ };
420
+ }
421
+ if ("sha256Hash" in signer) {
422
+ return {
423
+ type: "hash_x",
424
+ key: stellarSdk.StrKey.encodeSha256Hash(signerBytes(signer.sha256Hash)),
425
+ weight: Number(signer.weight)
426
+ };
427
+ }
428
+ if ("preAuthTx" in signer) {
429
+ return {
430
+ type: "preauth_tx",
431
+ key: stellarSdk.StrKey.encodePreAuthTx(signerBytes(signer.preAuthTx)),
432
+ weight: Number(signer.weight)
433
+ };
434
+ }
435
+ if ("ed25519SignedPayload" in signer) {
436
+ return {
437
+ type: "ed25519_signed_payload",
438
+ key: signer.ed25519SignedPayload,
439
+ weight: Number(signer.weight)
440
+ };
441
+ }
442
+ return null;
443
+ }
444
+ function normalizeOp(op) {
445
+ switch (op.type) {
446
+ case "pathPaymentStrictSend":
447
+ return {
448
+ type: "path_payment_strict_send",
449
+ sendAsset: assetToString(op.sendAsset),
450
+ sendAmount: op.sendAmount,
451
+ destination: op.destination,
452
+ destAsset: assetToString(op.destAsset),
453
+ destMin: op.destMin,
454
+ path: op.path.map(assetToString)
455
+ };
456
+ case "payment":
457
+ return {
458
+ type: "payment",
459
+ destination: op.destination,
460
+ asset: assetToString(op.asset),
461
+ amount: op.amount
462
+ };
463
+ case "changeTrust": {
464
+ const line = op.line;
465
+ const asset = "getCode" in line ? assetToString(line) : `pool:${line.toString()}`;
466
+ return { type: "change_trust", asset, limit: op.limit };
467
+ }
468
+ case "accountMerge":
469
+ return { type: "account_merge", destination: op.destination };
470
+ case "manageSellOffer":
471
+ return { type: "manage_sell_offer", offerId: op.offerId, amount: op.amount };
472
+ case "manageData":
473
+ return {
474
+ type: "manage_data",
475
+ name: op.name,
476
+ value: op.value ? toBase64(op.value) : null
477
+ };
478
+ case "setOptions":
479
+ return {
480
+ type: "set_options",
481
+ signer: op.signer ? decodeSigner(op.signer) : null,
482
+ masterWeight: op.masterWeight == null ? null : Number(op.masterWeight),
483
+ lowThreshold: op.lowThreshold == null ? null : Number(op.lowThreshold),
484
+ medThreshold: op.medThreshold == null ? null : Number(op.medThreshold),
485
+ highThreshold: op.highThreshold == null ? null : Number(op.highThreshold),
486
+ homeDomain: op.homeDomain ?? null,
487
+ setFlags: op.setFlags == null ? null : Number(op.setFlags),
488
+ clearFlags: op.clearFlags == null ? null : Number(op.clearFlags),
489
+ inflationDest: op.inflationDest ?? null
490
+ };
491
+ case "claimClaimableBalance":
492
+ return { type: "claim_claimable_balance", balanceId: op.balanceId };
493
+ // CAP-33 revoke transitions. Deliberately absent from this list, and required to stay
494
+ // absent: "beginSponsoringFutureReserves" and "endSponsoringFutureReserves". They fall
495
+ // through to `unknown`, which verify.ts rejects outright - and a sponsorship-transfer
496
+ // bracket is the only construct that can point a revoked entry's reserve at an account
497
+ // other than the entry's own owner. Recognizing either would silently unlock that.
498
+ case "revokeAccountSponsorship":
499
+ return { type: "revoke_sponsorship", entryKind: "account", owner: op.account };
500
+ case "revokeTrustlineSponsorship":
501
+ return { type: "revoke_sponsorship", entryKind: "trustline", owner: op.account };
502
+ case "revokeOfferSponsorship":
503
+ return { type: "revoke_sponsorship", entryKind: "offer", owner: op.seller };
504
+ case "revokeDataSponsorship":
505
+ return { type: "revoke_sponsorship", entryKind: "data_entry", owner: op.account };
506
+ case "revokeSignerSponsorship":
507
+ return { type: "revoke_sponsorship", entryKind: "signer", owner: op.account };
508
+ case "invokeHostFunction":
509
+ return describeInvocation(op);
510
+ default:
511
+ return { type: "unknown" };
512
+ }
513
+ }
514
+ function sumAmounts(a, b) {
515
+ return (Number(a) + Number(b)).toString();
516
+ }
517
+ function intentFromXdr(xdr2, networkPassphrase) {
518
+ const tx = stellarSdk.TransactionBuilder.fromXdr(xdr2, networkPassphrase);
519
+ const operations = tx.operations.map((op) => ({
520
+ ...normalizeOp(op),
521
+ source: op.source ?? tx.source
522
+ }));
523
+ const merge = operations.find(
524
+ (o) => o.type === "account_merge"
525
+ );
526
+ const paymentsOnlyTo = [
527
+ ...new Set(
528
+ operations.flatMap(
529
+ (o) => o.type === "payment" || o.type === "path_payment_strict_send" ? [o.destination] : []
530
+ )
531
+ )
532
+ ];
533
+ const minXlmFromConversions = operations.filter(
534
+ (o) => o.type === "path_payment_strict_send"
535
+ ).reduce(
536
+ (acc, o) => acc === null ? o.destMin : sumAmounts(acc, o.destMin),
537
+ null
538
+ );
539
+ const memoValue = tx.memo?.value;
540
+ const memoTypeRaw = tx.memo?.type;
541
+ const memoType = memoTypeRaw === "text" || memoTypeRaw === "id" || memoTypeRaw === "hash" ? memoTypeRaw : null;
542
+ return {
543
+ summary: "",
544
+ source: tx.source,
545
+ fee: tx.fee,
546
+ maxTime: tx.timeBounds && tx.timeBounds.maxTime !== "0" ? tx.timeBounds.maxTime : null,
547
+ memo: memoToString(memoValue, memoType),
548
+ memoType,
549
+ guarantees: {
550
+ mergeDestination: merge ? merge.destination : null,
551
+ paymentsOnlyTo,
552
+ minXlmFromConversions
553
+ },
554
+ operations
555
+ };
556
+ }
557
+
558
+ // ../../apps/web/config/constants.ts
559
+ var STROOPS_PER_XLM = 1e7;
560
+
561
+ // ../../apps/web/lib/utils/amounts.ts
562
+ function xlmToStroops(xlm) {
563
+ const [whole, frac = ""] = xlm.split(".");
564
+ const fracPadded = frac.padEnd(7, "0").slice(0, 7);
565
+ return (BigInt(whole) * BigInt(STROOPS_PER_XLM) + BigInt(fracPadded)).toString();
566
+ }
567
+
568
+ // ../../apps/web/lib/stellar/verify.ts
569
+ var MAX_EXIT_FEE_STROOPS = BigInt(1e7);
570
+ var MAX_CLASSIC_FEE_PER_OPERATION_STROOPS = BigInt(1e3);
571
+ var MAX_VALIDITY_SECONDS = 900;
572
+ function assertMergeShape(intent, expected) {
573
+ const merges = intent.operations.filter((o) => o.type === "account_merge");
574
+ if (merges.length === 0) return null;
575
+ if (merges.length > 1) {
576
+ throw new VerificationError(
577
+ "merge_multiple",
578
+ "The transaction would merge more than one account."
579
+ );
580
+ }
581
+ const merge = merges[0];
582
+ if (merge.source !== expected.source) {
583
+ throw new VerificationError(
584
+ "operation_source_mismatch",
585
+ "The account merge is not sent by the account being closed."
586
+ );
587
+ }
588
+ if (merge.destination === expected.destination) {
589
+ if (expected.directMergeRefused) {
590
+ throw new VerificationError(
591
+ "merge_direct_refused",
592
+ "This exchange cannot credit an account merge, so the balance has to reach it as a payment. This transaction would merge your account straight into it."
593
+ );
594
+ }
595
+ return null;
596
+ }
597
+ if (!expected.mediatorRequired) {
598
+ throw new VerificationError(
599
+ "merge_destination_mismatch",
600
+ "The account would be merged to an address you did not choose."
601
+ );
602
+ }
603
+ const ops = intent.operations;
604
+ if (ops.length !== 2 || ops[0].type !== "account_merge" || ops[1].type !== "payment") {
605
+ throw new VerificationError(
606
+ "mediator_handoff_shape",
607
+ "The account would be merged to an address you did not choose, and this transaction does not hand the balance straight on to your destination."
608
+ );
609
+ }
610
+ const forward = ops[1];
611
+ if (forward.source !== merge.destination) {
612
+ throw new VerificationError(
613
+ "mediator_forward_source_mismatch",
614
+ "The balance would be handed to one account and forwarded by another. Nothing guarantees the account receiving your funds is the one passing them on."
615
+ );
616
+ }
617
+ if (forward.destination !== expected.destination) {
618
+ throw new VerificationError(
619
+ "mediator_forward_destination_mismatch",
620
+ `The transaction would pay funds to an unexpected address (${forward.destination}).`
621
+ );
622
+ }
623
+ if (forward.asset !== "native") {
624
+ throw new VerificationError(
625
+ "mediator_forward_not_native",
626
+ "The forwarded balance would not be XLM."
627
+ );
628
+ }
629
+ assertForwardCarriesTheBalance(forward.amount, expected.nativeBalance);
630
+ return forward;
631
+ }
632
+ var SWAP_FUNCTION = "swap_exact_tokens_for_tokens";
633
+ var AGGREGATOR_SWAP_FUNCTION = "swap_exact_in";
634
+ var CONTRACT_ID = /^C[A-Z2-7]{55}$/;
635
+ var TOKEN_SUB_INVOCATION_FUNCTIONS = {
636
+ transfer: { argCount: 3, recipientArg: 1 },
637
+ // transfer(from, to, amount)
638
+ transfer_from: { argCount: 4, recipientArg: 2 },
639
+ // transfer_from(spender, from, to, amount)
640
+ approve: { argCount: 4, recipientArg: 1 },
641
+ // approve(from, spender, amount, expiration_ledger)
642
+ burn: { argCount: 2, recipientArg: -1 },
643
+ // burn(from, amount)
644
+ burn_from: { argCount: 3, recipientArg: -1 }
645
+ // burn_from(spender, from, amount)
646
+ };
647
+ var BLEND_EXIT_REQUEST_TYPES = [1, 3, 5];
648
+ function isBlendExitRequest(value) {
649
+ if (typeof value !== "object" || value === null) return false;
650
+ const { address, amount, request_type: type } = value;
651
+ return Object.keys(value).length === 3 && typeof address === "string" && CONTRACT_ID.test(address) && typeof amount === "string" && /^[1-9]\d*$/.test(amount) && typeof type === "number" && BLEND_EXIT_REQUEST_TYPES.includes(type);
652
+ }
653
+ function assertBlendSubmitArguments(args, source) {
654
+ if (args.length !== 4 || args.slice(0, 3).some((party) => party !== source)) {
655
+ throw new VerificationError(
656
+ "exit_argument_party_mismatch",
657
+ "A DeFi exit would act for, or pay, an address other than the account being closed."
658
+ );
659
+ }
660
+ let requests;
661
+ try {
662
+ requests = JSON.parse(args[3]);
663
+ } catch {
664
+ requests = null;
665
+ }
666
+ if (!Array.isArray(requests) || requests.length === 0 || !requests.every(isBlendExitRequest)) {
667
+ throw new VerificationError(
668
+ "exit_request_not_allowed",
669
+ "A DeFi exit would make a request of a lending pool that LumenWipe does not use to leave it."
670
+ );
671
+ }
672
+ }
673
+ function assertSoroswapRemovalArguments(args, source) {
674
+ if (args.length !== 7 || args[5] !== source) {
675
+ throw new VerificationError(
676
+ "exit_argument_party_mismatch",
677
+ "A DeFi exit would act for, or pay, an address other than the account being closed."
678
+ );
679
+ }
680
+ }
681
+ function readSwapArgs(fn, args) {
682
+ const integer = (value) => typeof value === "string" && /^\d+$/.test(value) ? BigInt(value) : null;
683
+ if (fn === SWAP_FUNCTION && args.length === 5) {
684
+ let path;
685
+ try {
686
+ path = JSON.parse(args[2] ?? "");
687
+ } catch {
688
+ return null;
689
+ }
690
+ if (!Array.isArray(path) || path.length < 2) return null;
691
+ if (!path.every((hop) => typeof hop === "string" && CONTRACT_ID.test(hop))) return null;
692
+ const amountIn = integer(args[0]);
693
+ const min = integer(args[1]);
694
+ if (amountIn === null || min === null) return null;
695
+ return {
696
+ token: path[0],
697
+ assetOut: path[path.length - 1],
698
+ amountIn,
699
+ destination: args[3] ?? "",
700
+ minAmountOut: min
701
+ };
702
+ }
703
+ if (fn === AGGREGATOR_SWAP_FUNCTION && args.length === 7) {
704
+ const token = args[1] ?? "";
705
+ const assetOut = args[3] ?? "";
706
+ const amountIn = integer(args[2]);
707
+ const min = integer(args[4]);
708
+ if (!CONTRACT_ID.test(token) || !CONTRACT_ID.test(assetOut)) return null;
709
+ if (amountIn === null || min === null) return null;
710
+ if (args[6] !== "null") return null;
711
+ return { token, assetOut, amountIn, destination: args[0] ?? "", minAmountOut: min };
712
+ }
713
+ return null;
714
+ }
715
+ var XBULL_SWAP_FUNCTION = "strict_send";
716
+ function readXBullSwapArgs(args) {
717
+ if (args.length !== 6) return null;
718
+ const [from, to, amount, minToGet, path, refs] = args;
719
+ const amt = /^\d+$/.test(amount ?? "") ? BigInt(amount) : null;
720
+ const min = /^\d+$/.test(minToGet ?? "") ? BigInt(minToGet) : null;
721
+ if (amt === null || min === null || !from || !to) return null;
722
+ let parsedPath;
723
+ let parsedRefs;
724
+ try {
725
+ parsedPath = JSON.parse(path ?? "");
726
+ parsedRefs = JSON.parse(refs ?? "");
727
+ } catch {
728
+ return null;
729
+ }
730
+ if (!Array.isArray(parsedPath) || !Array.isArray(parsedRefs)) return null;
731
+ const isTuple = (hop) => Array.isArray(hop) && hop.length === 4 && hop.every((n) => Number.isSafeInteger(n) && n >= 0);
732
+ if (parsedPath.length === 0 || !parsedPath.every(isTuple)) return null;
733
+ return {
734
+ from,
735
+ to,
736
+ amount: amt,
737
+ minToGet: min,
738
+ path: parsedPath,
739
+ refsCount: parsedRefs.length
740
+ };
741
+ }
742
+ var MAX_SWAP_SLIPPAGE_BPS = BigInt(100);
743
+ function swapFloor(chosen) {
744
+ const quoted = chosen.amountOut ?? "";
745
+ if (!/^\d+$/.test(chosen.minAmountOut) || !/^[1-9]\d*$/.test(quoted)) {
746
+ throw new VerificationError(
747
+ "swap_quote_missing",
748
+ "A swap cannot be checked against the quote you were shown. Run the analysis again."
749
+ );
750
+ }
751
+ const fromQuote = BigInt(quoted) * (BigInt(1e4) - MAX_SWAP_SLIPPAGE_BPS) / BigInt(1e4);
752
+ const pinned = BigInt(chosen.minAmountOut);
753
+ return pinned > fromQuote ? pinned : fromQuote;
754
+ }
755
+ function readXBullRoute(path, assets) {
756
+ const IN = 1;
757
+ const OUT = 3;
758
+ for (let i = 1; i < path.length; i++) {
759
+ if (path[i][IN] !== path[i - 1][OUT]) return null;
760
+ }
761
+ const lookup = (index) => Object.prototype.hasOwnProperty.call(assets, String(index)) ? assets[String(index)] : void 0;
762
+ for (const hop of path) {
763
+ if (lookup(hop[IN]) === void 0 || lookup(hop[OUT]) === void 0) return null;
764
+ }
765
+ return { spends: lookup(path[0][IN]), buys: lookup(path[path.length - 1][OUT]) };
766
+ }
767
+ function assertSwapAuthorizesOnlyItsInput(subInvocations, token, amountIn, expected) {
768
+ const ownTokens = /* @__PURE__ */ new Set([
769
+ ...expected.heldTokenContracts,
770
+ ...expected.protectedTokenContracts,
771
+ ...expected.positionTokenContracts,
772
+ expected.xlmContract
773
+ ]);
774
+ let moved = BigInt(0);
775
+ for (const sub of subInvocations) {
776
+ if (sub.contract !== token) {
777
+ if (ownTokens.has(sub.contract) || !sub.function.startsWith("swap")) {
778
+ throw new VerificationError(
779
+ "swap_auth_unexpected_call",
780
+ "A swap would authorize something other than paying in the token you chose to convert."
781
+ );
782
+ }
783
+ continue;
784
+ }
785
+ if (sub.function !== "transfer" || sub.args.length !== 3 || sub.args[0] !== expected.source || !CONTRACT_ID.test(sub.args[1] ?? "") || !/^\d+$/.test(sub.args[2] ?? "")) {
786
+ throw new VerificationError(
787
+ "swap_auth_unexpected_call",
788
+ "A swap would authorize something other than paying in the token you chose to convert."
789
+ );
790
+ }
791
+ moved += BigInt(sub.args[2]);
792
+ }
793
+ if (moved > amountIn) {
794
+ throw new VerificationError(
795
+ "swap_auth_exceeds_amount",
796
+ "A swap would authorize spending more than the balance it sells."
797
+ );
798
+ }
799
+ }
800
+ function assertUserChoseThisTransfer(op, expected, seen) {
801
+ const chosen = expected.transfers[op.asset];
802
+ if (!chosen) {
803
+ throw new VerificationError(
804
+ "transfer_not_chosen",
805
+ `The transaction would pay funds to an unexpected address (${op.destination}).`
806
+ );
807
+ }
808
+ if (op.destination !== chosen.destination) {
809
+ throw new VerificationError(
810
+ "transfer_destination_mismatch",
811
+ `The transaction would send ${assetCode(op.asset)} to an address you did not choose.`
812
+ );
813
+ }
814
+ const exchange = expected.depositAddresses[op.destination];
815
+ if (exchange !== void 0 && op.destination !== op.asset.split(":")[1]) {
816
+ throw new VerificationError(
817
+ "transfer_to_deposit_address",
818
+ `The transaction would send ${assetCode(op.asset)} to a ${exchange} deposit address. A transfer in a close carries no deposit memo, so ${exchange} could not credit it. Go back to the plan and choose a wallet you control.`
819
+ );
820
+ }
821
+ if (seen.has(op.asset)) {
822
+ throw new VerificationError(
823
+ "transfer_duplicate",
824
+ `The transaction would send ${assetCode(op.asset)} more than once.`
825
+ );
826
+ }
827
+ seen.add(op.asset);
828
+ if (BigInt(xlmToStroops(op.amount)) < BigInt(xlmToStroops(chosen.amount))) {
829
+ throw new VerificationError(
830
+ "transfer_amount_short",
831
+ `The transaction would send less ${assetCode(op.asset)} than you approved.`
832
+ );
833
+ }
834
+ }
835
+ function assetCode(asset) {
836
+ return asset.split(":")[0];
837
+ }
838
+ function assertForwardCarriesTheBalance(forwardAmount, nativeBalance) {
839
+ const forwarded = BigInt(xlmToStroops(forwardAmount));
840
+ const observed = BigInt(xlmToStroops(nativeBalance));
841
+ const floor = observed - FORWARD_SHORTFALL_TOLERANCE_STROOPS;
842
+ if (forwarded < floor) {
843
+ throw new VerificationError(
844
+ "mediator_forward_short",
845
+ "This transaction would hand your balance to an intermediary and pass on only part of it."
846
+ );
847
+ }
848
+ }
849
+ var FORWARD_SHORTFALL_TOLERANCE_STROOPS = BigInt("100000");
850
+ function assertExpiresSoon(intent, nowSeconds) {
851
+ const maxTime = intent.maxTime ?? null;
852
+ if (maxTime === null || !/^\d+$/.test(maxTime) || BigInt(maxTime) === BigInt(0)) {
853
+ throw new VerificationError(
854
+ "expiry_missing",
855
+ "This transaction never expires, so it could be submitted long after you approved it."
856
+ );
857
+ }
858
+ if (BigInt(maxTime) > BigInt(Math.floor(nowSeconds)) + BigInt(MAX_VALIDITY_SECONDS)) {
859
+ throw new VerificationError(
860
+ "expiry_too_far",
861
+ "This transaction stays valid for far longer than a close needs. If your device clock is wrong, correct it and try again."
862
+ );
863
+ }
864
+ }
865
+ function assertClassicFee(intent) {
866
+ if (!/^\d+$/.test(intent.fee)) {
867
+ throw new VerificationError(
868
+ "fee_unreadable",
869
+ "The transaction's network fee could not be read."
870
+ );
871
+ }
872
+ if (intent.operations.some((op) => op.type === "invoke_host_function")) return;
873
+ const cap = BigInt(intent.operations.length) * MAX_CLASSIC_FEE_PER_OPERATION_STROOPS;
874
+ if (BigInt(intent.fee) > cap) {
875
+ throw new VerificationError(
876
+ "fee_above_cap",
877
+ "This transaction would pay a network fee far above what its operations need."
878
+ );
879
+ }
880
+ }
881
+ function assertCloseIntent(intent, expected) {
882
+ if (intent.source !== expected.source) {
883
+ throw new VerificationError(
884
+ "transaction_source_mismatch",
885
+ "The transaction is not for your account."
886
+ );
887
+ }
888
+ if (!expected.preAuthorized) {
889
+ assertExpiresSoon(intent, expected.nowSeconds);
890
+ assertClassicFee(intent);
891
+ }
892
+ const forward = assertMergeShape(intent, expected);
893
+ const seenTransfers = /* @__PURE__ */ new Set();
894
+ const seenConversions = /* @__PURE__ */ new Set();
895
+ for (const op of intent.operations) {
896
+ switch (op.type) {
897
+ case "payment": {
898
+ if (op !== forward && op.source !== expected.source) {
899
+ throw new VerificationError(
900
+ "operation_source_mismatch",
901
+ "The transaction would pay funds from an account other than the one being closed."
902
+ );
903
+ }
904
+ if (op !== forward) {
905
+ assertUserChoseThisTransfer(op, expected, seenTransfers);
906
+ }
907
+ break;
908
+ }
909
+ case "path_payment_strict_send": {
910
+ if (op.destination !== expected.source) {
911
+ throw new VerificationError(
912
+ "conversion_recipient_mismatch",
913
+ "A conversion would send funds out of your account."
914
+ );
915
+ }
916
+ if (op.destAsset !== "native") {
917
+ throw new VerificationError(
918
+ "conversion_not_to_xlm",
919
+ "A conversion would not settle in XLM."
920
+ );
921
+ }
922
+ if (!(Number(op.destMin) > 0)) {
923
+ throw new VerificationError(
924
+ "conversion_min_out_missing",
925
+ "A conversion has no minimum-received floor."
926
+ );
927
+ }
928
+ const chosen = expected.classicConversions[op.sendAsset];
929
+ if (!chosen) {
930
+ throw new VerificationError(
931
+ "conversion_asset_not_chosen",
932
+ "A conversion would sell an asset you did not choose to convert. If a balance arrived since the analysis, run it again."
933
+ );
934
+ }
935
+ if (seenConversions.has(op.sendAsset)) {
936
+ throw new VerificationError(
937
+ "conversion_duplicate",
938
+ `The transaction would convert ${assetCode(op.sendAsset)} more than once.`
939
+ );
940
+ }
941
+ seenConversions.add(op.sendAsset);
942
+ if (chosen.minAmountOut !== null && BigInt(xlmToStroops(op.destMin)) < BigInt(chosen.minAmountOut)) {
943
+ throw new VerificationError(
944
+ "conversion_min_out_below_floor",
945
+ `A conversion of ${assetCode(op.sendAsset)} would accept less XLM than the minimum you were shown.`
946
+ );
947
+ }
948
+ break;
949
+ }
950
+ case "change_trust":
951
+ if (Number(op.limit) !== 0 && !expected.claimTrustlineAssets.includes(op.asset)) {
952
+ throw new VerificationError(
953
+ "trustline_not_removal",
954
+ "A trustline would be created or raised, not removed."
955
+ );
956
+ }
957
+ break;
958
+ case "manage_data":
959
+ if (op.value !== null) {
960
+ throw new VerificationError(
961
+ "data_entry_not_removal",
962
+ "A data entry would be written, not removed."
963
+ );
964
+ }
965
+ break;
966
+ case "manage_sell_offer":
967
+ if (Number(op.amount) !== 0) {
968
+ throw new VerificationError(
969
+ "offer_not_cancellation",
970
+ "An offer would be created, not cancelled."
971
+ );
972
+ }
973
+ break;
974
+ case "set_options":
975
+ if (op.signer !== null) {
976
+ const signer = op.signer;
977
+ if (signer.weight !== 0) {
978
+ throw new VerificationError("signer_added", "A signer would be added or empowered.");
979
+ }
980
+ const touchesKnownSigner = expected.accountSigners.some(
981
+ (s) => s.key === signer.key && s.type === signer.type
982
+ );
983
+ if (!touchesKnownSigner) {
984
+ throw new VerificationError(
985
+ "signer_unknown",
986
+ "This transaction touches a signer that wasn't on your account when we last read it. Re-run the analysis and try again."
987
+ );
988
+ }
989
+ }
990
+ if (op.masterWeight !== null) {
991
+ throw new VerificationError(
992
+ "master_weight_changed",
993
+ "The master key's weight would be changed."
994
+ );
995
+ }
996
+ if ((op.lowThreshold ?? 0) > 1 || (op.medThreshold ?? 0) > 1 || (op.highThreshold ?? 0) > 1) {
997
+ throw new VerificationError("thresholds_raised", "Account thresholds would be raised.");
998
+ }
999
+ if (op.homeDomain !== null || op.setFlags !== null || op.clearFlags !== null || op.inflationDest !== null) {
1000
+ throw new VerificationError(
1001
+ "account_settings_changed",
1002
+ "This transaction would change account flags, the home domain, or the inflation destination, which a close never legitimately needs to touch."
1003
+ );
1004
+ }
1005
+ break;
1006
+ case "invoke_host_function": {
1007
+ if (expected.conversionContracts.includes(op.contract) && (op.function === SWAP_FUNCTION || op.function === AGGREGATOR_SWAP_FUNCTION || op.function === XBULL_SWAP_FUNCTION)) {
1008
+ if (intent.operations.length !== 1) {
1009
+ throw new VerificationError(
1010
+ "invocation_not_alone",
1011
+ "A swap must be the only operation in its transaction."
1012
+ );
1013
+ }
1014
+ if (BigInt(intent.fee) > MAX_EXIT_FEE_STROOPS) {
1015
+ throw new VerificationError(
1016
+ "fee_above_cap",
1017
+ "A swap would pay a network fee far above what any swap needs."
1018
+ );
1019
+ }
1020
+ if (op.source !== expected.source) {
1021
+ throw new VerificationError(
1022
+ "operation_source_mismatch",
1023
+ "A swap would act for an account other than the one being closed."
1024
+ );
1025
+ }
1026
+ if (op.function === SWAP_FUNCTION || op.function === AGGREGATOR_SWAP_FUNCTION) {
1027
+ const swap = readSwapArgs(op.function, op.args);
1028
+ if (!swap) {
1029
+ throw new VerificationError(
1030
+ "swap_args_unreadable",
1031
+ "A swap's arguments could not be read."
1032
+ );
1033
+ }
1034
+ const chosen = expected.tokenConversions[swap.token];
1035
+ if (!chosen) {
1036
+ throw new VerificationError(
1037
+ "conversion_asset_not_chosen",
1038
+ "A swap would exchange a token you did not choose to convert."
1039
+ );
1040
+ }
1041
+ if (swap.assetOut !== expected.xlmContract) {
1042
+ throw new VerificationError(
1043
+ "conversion_not_to_xlm",
1044
+ "A swap would buy something other than XLM."
1045
+ );
1046
+ }
1047
+ if (swap.amountIn < BigInt(chosen.amountIn)) {
1048
+ throw new VerificationError(
1049
+ "conversion_amount_short",
1050
+ "A swap would exchange less of the token than the balance you were shown. If you moved some of it since, run the analysis again."
1051
+ );
1052
+ }
1053
+ if (swap.destination !== expected.source) {
1054
+ throw new VerificationError(
1055
+ "conversion_recipient_mismatch",
1056
+ "A swap would pay the proceeds to an address other than the account being closed."
1057
+ );
1058
+ }
1059
+ if (swap.minAmountOut < swapFloor(chosen)) {
1060
+ throw new VerificationError(
1061
+ "conversion_min_out_below_floor",
1062
+ "A swap would accept less XLM than the minimum you were shown."
1063
+ );
1064
+ }
1065
+ assertSwapAuthorizesOnlyItsInput(
1066
+ op.subInvocations,
1067
+ swap.token,
1068
+ swap.amountIn,
1069
+ expected
1070
+ );
1071
+ } else {
1072
+ const swap = readXBullSwapArgs(op.args);
1073
+ if (!swap) {
1074
+ throw new VerificationError(
1075
+ "swap_args_unreadable",
1076
+ "A swap's arguments could not be read."
1077
+ );
1078
+ }
1079
+ if (swap.refsCount !== 0) {
1080
+ throw new VerificationError(
1081
+ "swap_referral_recipient",
1082
+ "A swap would pay a referral fee to an address you never agreed to."
1083
+ );
1084
+ }
1085
+ const route = readXBullRoute(swap.path, expected.xbullAssets);
1086
+ if (!route) {
1087
+ throw new VerificationError(
1088
+ "swap_route_asset_unknown",
1089
+ "A swap's route names an asset LumenWipe cannot identify. Run the analysis again."
1090
+ );
1091
+ }
1092
+ const chosen = expected.tokenConversions[route.spends];
1093
+ if (!chosen) {
1094
+ throw new VerificationError(
1095
+ "conversion_asset_not_chosen",
1096
+ "A swap would exchange a token you did not choose to convert."
1097
+ );
1098
+ }
1099
+ if (route.buys !== expected.xlmContract) {
1100
+ throw new VerificationError(
1101
+ "conversion_not_to_xlm",
1102
+ "A swap would buy something other than XLM."
1103
+ );
1104
+ }
1105
+ if (swap.amount < BigInt(chosen.amountIn)) {
1106
+ throw new VerificationError(
1107
+ "conversion_amount_short",
1108
+ "A swap would exchange less of the token than the balance you were shown. If you moved some of it since, run the analysis again."
1109
+ );
1110
+ }
1111
+ if (swap.to !== expected.source) {
1112
+ throw new VerificationError(
1113
+ "conversion_recipient_mismatch",
1114
+ "A swap would pay the proceeds to an address other than the account being closed."
1115
+ );
1116
+ }
1117
+ if (swap.minToGet < swapFloor(chosen)) {
1118
+ throw new VerificationError(
1119
+ "conversion_min_out_below_floor",
1120
+ "A swap would accept less XLM than the minimum you were shown."
1121
+ );
1122
+ }
1123
+ assertSwapAuthorizesOnlyItsInput(
1124
+ op.subInvocations,
1125
+ route.spends,
1126
+ swap.amount,
1127
+ expected
1128
+ );
1129
+ }
1130
+ if (op.authorizesBeyondSelf) {
1131
+ throw new VerificationError(
1132
+ "invocation_auth_beyond_self",
1133
+ "A swap would authorize actions beyond this account's own contract calls."
1134
+ );
1135
+ }
1136
+ if (op.unsupportedAddressCount > 0) {
1137
+ throw new VerificationError(
1138
+ "invocation_address_unsupported",
1139
+ "A swap names an address form that cannot be verified."
1140
+ );
1141
+ }
1142
+ for (const account of op.accountsReferenced) {
1143
+ if (account !== expected.source) {
1144
+ throw new VerificationError(
1145
+ "invocation_foreign_account",
1146
+ "A swap would send funds to, or act for, an account other than the one being closed."
1147
+ );
1148
+ }
1149
+ }
1150
+ break;
1151
+ }
1152
+ const tokenTransfer = expected.tokenTransfers[op.contract];
1153
+ if (tokenTransfer) {
1154
+ if (intent.operations.length !== 1) {
1155
+ throw new VerificationError(
1156
+ "invocation_not_alone",
1157
+ "A token transfer must be the only operation in its transaction."
1158
+ );
1159
+ }
1160
+ if (BigInt(intent.fee) > MAX_EXIT_FEE_STROOPS) {
1161
+ throw new VerificationError(
1162
+ "fee_above_cap",
1163
+ "A token transfer would pay a network fee far above what any transfer needs."
1164
+ );
1165
+ }
1166
+ if (op.source !== expected.source) {
1167
+ throw new VerificationError(
1168
+ "operation_source_mismatch",
1169
+ "A token transfer would act for an account other than the one being closed."
1170
+ );
1171
+ }
1172
+ if (op.function !== "transfer" || op.args.length !== 3) {
1173
+ throw new VerificationError(
1174
+ "token_transfer_function_invalid",
1175
+ "A token transaction would call something other than a plain transfer."
1176
+ );
1177
+ }
1178
+ if (op.args[0] !== expected.source) {
1179
+ throw new VerificationError(
1180
+ "token_transfer_from_mismatch",
1181
+ "A token transfer would move a balance other than this account's own."
1182
+ );
1183
+ }
1184
+ if (op.args[1] !== tokenTransfer.destination) {
1185
+ throw new VerificationError(
1186
+ "transfer_destination_mismatch",
1187
+ "A token transfer would send the balance to an address you did not choose."
1188
+ );
1189
+ }
1190
+ const exchange = expected.depositAddresses[tokenTransfer.destination];
1191
+ if (exchange !== void 0) {
1192
+ throw new VerificationError(
1193
+ "transfer_to_deposit_address",
1194
+ `A token transfer would send the balance to a ${exchange} deposit address. A token transfer carries no deposit memo, so ${exchange} could not credit it. Go back to the plan and choose a wallet you control.`
1195
+ );
1196
+ }
1197
+ const amount = op.args[2] ?? "";
1198
+ if (!/^\d+$/.test(amount) || !/^\d+$/.test(tokenTransfer.amount) || BigInt(amount) < BigInt(tokenTransfer.amount)) {
1199
+ throw new VerificationError(
1200
+ "transfer_amount_short",
1201
+ "A token transfer would send less than the balance you were shown. If you moved some of this token since, run the analysis again."
1202
+ );
1203
+ }
1204
+ if (op.authorizesBeyondSelf || op.authDepth !== 0) {
1205
+ throw new VerificationError(
1206
+ "invocation_auth_beyond_self",
1207
+ "A token transfer would authorize actions beyond the transfer itself."
1208
+ );
1209
+ }
1210
+ if (op.unsupportedAddressCount > 0) {
1211
+ throw new VerificationError(
1212
+ "invocation_address_unsupported",
1213
+ "A token transfer names an address form that cannot be verified."
1214
+ );
1215
+ }
1216
+ for (const account of op.accountsReferenced) {
1217
+ if (account !== expected.source && account !== tokenTransfer.destination) {
1218
+ throw new VerificationError(
1219
+ "invocation_foreign_account",
1220
+ "A token transfer names an account other than this one and your chosen destination."
1221
+ );
1222
+ }
1223
+ }
1224
+ for (const contract of op.contractsReferenced) {
1225
+ if (contract !== op.contract) {
1226
+ throw new VerificationError(
1227
+ "token_transfer_foreign_contract",
1228
+ "A token transfer would reach a contract other than the token itself."
1229
+ );
1230
+ }
1231
+ }
1232
+ break;
1233
+ }
1234
+ if (intent.operations.length !== 1) {
1235
+ throw new VerificationError(
1236
+ "invocation_not_alone",
1237
+ "A DeFi exit must be the only operation in its transaction."
1238
+ );
1239
+ }
1240
+ if (BigInt(intent.fee) > MAX_EXIT_FEE_STROOPS) {
1241
+ throw new VerificationError(
1242
+ "fee_above_cap",
1243
+ "A DeFi exit would pay a network fee far above what any exit needs."
1244
+ );
1245
+ }
1246
+ if (op.source !== expected.source) {
1247
+ throw new VerificationError(
1248
+ "operation_source_mismatch",
1249
+ "A DeFi exit would act for an account other than the one being closed."
1250
+ );
1251
+ }
1252
+ if (!expected.exitContracts.includes(op.contract)) {
1253
+ throw new VerificationError(
1254
+ "exit_contract_not_position",
1255
+ "A DeFi exit would call a contract that is not one of this account's detected positions."
1256
+ );
1257
+ }
1258
+ if (expected.shareTokenContracts.some((t) => expected.heldTokenContracts.includes(t)) || expected.debtTokenContracts.some((t) => expected.protectedTokenContracts.includes(t))) {
1259
+ throw new VerificationError(
1260
+ "exit_expectation_inconsistent",
1261
+ "Your analysis names XLM, a classic asset or another token you hold as a DeFi position's own share or debt token, which it never is. Run the analysis again."
1262
+ );
1263
+ }
1264
+ if (!(expected.exitFunctions[op.contract] ?? []).includes(op.function)) {
1265
+ throw new VerificationError(
1266
+ "exit_function_not_allowed",
1267
+ "A DeFi exit would call a function LumenWipe does not use to leave this protocol."
1268
+ );
1269
+ }
1270
+ if (op.authorizesBeyondSelf) {
1271
+ throw new VerificationError(
1272
+ "invocation_auth_beyond_self",
1273
+ "A DeFi exit would authorize actions beyond this account's own contract call."
1274
+ );
1275
+ }
1276
+ if (op.unsupportedAddressCount > 0) {
1277
+ throw new VerificationError(
1278
+ "invocation_address_unsupported",
1279
+ "A DeFi exit names an address form that cannot be verified."
1280
+ );
1281
+ }
1282
+ for (const account of op.accountsReferenced) {
1283
+ if (account !== expected.source) {
1284
+ throw new VerificationError(
1285
+ "invocation_foreign_account",
1286
+ "A DeFi exit would send funds to, or act for, an account other than the one being closed."
1287
+ );
1288
+ }
1289
+ }
1290
+ for (const contract of op.contractsReferenced) {
1291
+ if (!expected.exitContracts.includes(contract) && !expected.heldTokenContracts.includes(contract) && !expected.positionTokenContracts.includes(contract)) {
1292
+ throw new VerificationError(
1293
+ "exit_foreign_contract",
1294
+ "A DeFi exit would send funds to, or call, a contract this account has no position, balance, or pool token in."
1295
+ );
1296
+ }
1297
+ }
1298
+ if (op.function === "submit") assertBlendSubmitArguments(op.args, expected.source);
1299
+ if (op.function === "remove_liquidity") {
1300
+ assertSoroswapRemovalArguments(op.args, expected.source);
1301
+ }
1302
+ if (op.function === "claim" && (op.args[0] !== expected.source || op.args[op.args.length - 1] !== expected.source)) {
1303
+ throw new VerificationError(
1304
+ "exit_argument_party_mismatch",
1305
+ "A DeFi exit would act for, or pay, an address other than the account being closed."
1306
+ );
1307
+ }
1308
+ if (!expected.registryContracts.includes(op.contract)) {
1309
+ const own = expected.ownTokensByContract[op.contract] ?? [];
1310
+ for (const sub of op.subInvocations) {
1311
+ const isAccountToken = expected.protectedTokenContracts.includes(sub.contract) || expected.heldTokenContracts.includes(sub.contract) || expected.positionTokenContracts.includes(sub.contract);
1312
+ if (expected.protectedTokenContracts.includes(sub.contract) || isAccountToken && !own.includes(sub.contract)) {
1313
+ throw new VerificationError(
1314
+ "exit_unverified_spend",
1315
+ "A DeFi exit would spend your XLM, a classic asset or another token through a contract LumenWipe has not verified."
1316
+ );
1317
+ }
1318
+ }
1319
+ } else {
1320
+ const repayable = expected.repayTokensByPool[op.contract] ?? [];
1321
+ for (const sub of op.subInvocations) {
1322
+ if (!expected.protectedTokenContracts.includes(sub.contract)) continue;
1323
+ const repaysThisPool = repayable.includes(sub.contract) && sub.function === "transfer" && sub.args.length === 3 && sub.args[0] === expected.source && sub.args[1] === op.contract;
1324
+ if (!repaysThisPool) {
1325
+ throw new VerificationError(
1326
+ "exit_spend_not_repay",
1327
+ "This exit would spend your XLM or a classic asset other than to repay a debt in your analysis. If this position changed since, run the analysis again."
1328
+ );
1329
+ }
1330
+ }
1331
+ }
1332
+ for (const sub of op.subInvocations) {
1333
+ if (op.function === "remove_liquidity") {
1334
+ const paysShareIntoPair = op.subInvocations.length === 1 && expected.exitFunctions[sub.contract]?.length === 0 && sub.function === "transfer" && sub.args.length === 3 && sub.args[0] === expected.source && sub.args[1] === sub.contract && sub.args[2] === op.args[2];
1335
+ if (!paysShareIntoPair) {
1336
+ throw new VerificationError(
1337
+ "exit_liquidity_auth_invalid",
1338
+ "A DeFi exit would authorize something other than paying its liquidity share into its pair."
1339
+ );
1340
+ }
1341
+ continue;
1342
+ }
1343
+ const isToken = expected.heldTokenContracts.includes(sub.contract) || expected.positionTokenContracts.includes(sub.contract);
1344
+ if (!isToken) {
1345
+ throw new VerificationError(
1346
+ "exit_auth_foreign_contract",
1347
+ "A DeFi exit would authorize a call on a contract that is not one of this account's tokens."
1348
+ );
1349
+ }
1350
+ const shape = TOKEN_SUB_INVOCATION_FUNCTIONS[sub.function];
1351
+ if (shape === void 0) {
1352
+ throw new VerificationError(
1353
+ "exit_token_function_not_allowed",
1354
+ "A DeFi exit would call a function on a token that LumenWipe does not use to leave a protocol."
1355
+ );
1356
+ }
1357
+ if (sub.args.length !== shape.argCount) {
1358
+ throw new VerificationError(
1359
+ "exit_token_argument_count",
1360
+ "A DeFi exit would call a token function with an argument count that does not match its real signature."
1361
+ );
1362
+ }
1363
+ if (shape.recipientArg >= 0 && sub.args[shape.recipientArg] !== expected.source && sub.args[shape.recipientArg] !== op.contract) {
1364
+ throw new VerificationError(
1365
+ "exit_token_recipient_mismatch",
1366
+ "A DeFi exit would move a token balance to an address other than this account or the protocol it is exiting."
1367
+ );
1368
+ }
1369
+ }
1370
+ break;
1371
+ }
1372
+ // Stryker disable next-line StringLiteral: disabling this case label sends an "unknown"
1373
+ // op to the exhaustiveness-guard `default` below, which throws the exact same message -
1374
+ // the two branches are textually identical on purpose (see that guard's comment), so this
1375
+ // mutation is unobservable by design, not a gap.
1376
+ case "unknown":
1377
+ throw new VerificationError(
1378
+ "operation_unknown",
1379
+ "The transaction contains an unrecognized operation."
1380
+ );
1381
+ // Stryker disable next-line ConditionalExpression: this case's entire body is a no-op
1382
+ // `break` (see the comment below for why revoke_sponsorship needs no check). Collapsing it
1383
+ // just falls through to the next case, which is also a no-op `break` - unobservable either
1384
+ // way.
1385
+ case "revoke_sponsorship":
1386
+ break;
1387
+ case "account_merge":
1388
+ case "claim_claimable_balance":
1389
+ break;
1390
+ default: {
1391
+ throw new VerificationError(
1392
+ "operation_unknown",
1393
+ "The transaction contains an unrecognized operation."
1394
+ );
1395
+ }
1396
+ }
1397
+ if (op !== forward && op.source !== expected.source) {
1398
+ throw new VerificationError(
1399
+ "operation_source_mismatch",
1400
+ "The transaction would act for an account other than the one being closed."
1401
+ );
1402
+ }
1403
+ }
1404
+ assertMemo(intent, expected);
1405
+ }
1406
+ var MEMO_TYPE_WITH_ARTICLE = {
1407
+ text: "a text",
1408
+ id: "an id",
1409
+ hash: "a hash"
1410
+ };
1411
+ function assertMemo(intent, expected) {
1412
+ const carriesMemo = intent.memo !== null || intent.memoType !== null;
1413
+ const deliversBalance = intent.guarantees.mergeDestination !== null;
1414
+ if (!deliversBalance || expected.memo === null) {
1415
+ if (carriesMemo) {
1416
+ throw new VerificationError(
1417
+ "memo_unexpected",
1418
+ "The transaction carries a memo you did not set."
1419
+ );
1420
+ }
1421
+ } else {
1422
+ if (expected.memoType === null) {
1423
+ throw new VerificationError(
1424
+ "memo_type_unreadable",
1425
+ "The memo type you confirmed could not be read, so this close cannot be checked."
1426
+ );
1427
+ }
1428
+ if (!carriesMemo) {
1429
+ throw new VerificationError("memo_missing", "The transaction is missing the memo you set.");
1430
+ }
1431
+ if (intent.memo !== expected.memo) {
1432
+ throw new VerificationError(
1433
+ "memo_value_mismatch",
1434
+ "The transaction carries a memo you did not set."
1435
+ );
1436
+ }
1437
+ if (intent.memoType !== expected.memoType) {
1438
+ const sent = intent.memoType === null ? "an unreadable" : MEMO_TYPE_WITH_ARTICLE[intent.memoType];
1439
+ throw new VerificationError(
1440
+ "memo_type_mismatch",
1441
+ `The transaction would send your memo as ${sent} memo, not the ${expected.memoType} memo you confirmed.`
1442
+ );
1443
+ }
1444
+ }
1445
+ const paysDestination = intent.guarantees.mergeDestination === expected.destination || intent.guarantees.paymentsOnlyTo.includes(expected.destination);
1446
+ if (paysDestination && expected.memoRequired && (!deliversBalance || expected.memo === null)) {
1447
+ throw new VerificationError("memo_required", "This destination requires a deposit memo.");
1448
+ }
1449
+ }
1450
+ function depositAddressesOf(transfers, lookup) {
1451
+ const listed = {};
1452
+ for (const { destination } of transfers) {
1453
+ const exchange = lookup(destination);
1454
+ if (exchange) listed[destination] = exchange.name;
1455
+ }
1456
+ return listed;
1457
+ }
1458
+ function registryView(served) {
1459
+ if (served === void 0) {
1460
+ return { lookup: lookupExchange, usable: () => isRegistryUsable(), memoTypeInDispute };
1461
+ }
1462
+ const merged = mergeServedRegistry(bundledRegistry(), served);
1463
+ if (merged === null) {
1464
+ throw new VerificationError(
1465
+ "registry_snapshot_invalid",
1466
+ "The exchange registry passed to the verifier is not a registry (it needs an entries list, lastVerified and validUntil), so this close cannot be checked against it."
1467
+ );
1468
+ }
1469
+ const byAddress2 = new Map(merged.entries.map((e) => [e.address, e]));
1470
+ const disputes = new Set(merged.memoTypeDisputes);
1471
+ return {
1472
+ lookup: (address) => byAddress2.get(address) ?? null,
1473
+ usable: () => isUsableAt(merged.validUntil, /* @__PURE__ */ new Date()),
1474
+ memoTypeInDispute: (address) => disputes.has(address)
1475
+ };
1476
+ }
1477
+ function listedMemoType(exchange, registry, expected) {
1478
+ if (registry.memoTypeInDispute(expected.destination)) {
1479
+ throw new VerificationError(
1480
+ "registry_memo_type_conflict",
1481
+ `The served exchange registry gives ${exchange.name} a different memo type than the bundled one, so the memo this close needs cannot be checked.`
1482
+ );
1483
+ }
1484
+ const bundled = bundledRegistry().entries.some((e) => e.address === expected.destination);
1485
+ if (bundled) return exchange.memoType;
1486
+ if (expected.memo !== null && expected.memoType !== null && expected.memoType !== exchange.memoType) {
1487
+ throw new VerificationError(
1488
+ "registry_memo_type_unconfirmed",
1489
+ `The served exchange registry lists ${exchange.name} with ${MEMO_TYPE_WITH_ARTICLE[exchange.memoType]} memo, not the ${expected.memoType} memo you confirmed.`
1490
+ );
1491
+ }
1492
+ return expected.memoType;
1493
+ }
1494
+ function verifyCloseTransaction(opts) {
1495
+ const intent = intentFromXdr(opts.unsignedXdr, NETWORK_PASSPHRASES[opts.network]);
1496
+ const registry = registryView(opts.servedRegistry);
1497
+ const exchange = registry.lookup(opts.expected.destination);
1498
+ if (exchange !== null && !registry.usable()) {
1499
+ throw new VerificationError(
1500
+ "registry_expired",
1501
+ "The exchange deposit rules have expired and have not been re-verified, so this close cannot be checked. Refresh the page; if it persists, the registry needs updating."
1502
+ );
1503
+ }
1504
+ assertCloseIntent(intent, {
1505
+ ...opts.expected,
1506
+ depositAddresses: depositAddressesOf(
1507
+ [...Object.values(opts.expected.transfers), ...Object.values(opts.expected.tokenTransfers)],
1508
+ registry.lookup
1509
+ ),
1510
+ // From the bundled copy alone, whatever was served: see `registryView`.
1511
+ mediatorRequired: mediatorAllowedFor(opts.expected.destination),
1512
+ directMergeRefused: exchange?.requiresMediator ?? false,
1513
+ memoRequired: exchange?.requiresMemo ?? false,
1514
+ memoType: exchange === null ? opts.expected.memoType : listedMemoType(exchange, registry, opts.expected),
1515
+ nowSeconds: Math.floor(Date.now() / 1e3),
1516
+ preAuthorized: opts.preAuthorized === true
1517
+ });
1518
+ }
1519
+
1520
+ // ../../apps/api/src/config/contract-registry.json
1521
+ var contract_registry_default = {
1522
+ validUntil: "2027-01-08",
1523
+ noExitVersions: { fxdao: ["wind-down"] },
1524
+ entries: [
1525
+ {
1526
+ network: "testnet",
1527
+ protocol: "blend",
1528
+ kind: "factory",
1529
+ address: "CDV6RX4CGPCOKGTBFS52V3LMWQGZN3LCQTXF5RVPOOCG4XVMHXQ4NTF6",
1530
+ wasmHash: "31328050548831f63d2b72e37bcfd0bb7371b7907135755dbe09ed434d755ca9",
1531
+ version: "v2",
1532
+ label: "Blend V2 pool factory (testnet) - reference only, not probed for balances",
1533
+ verifiedLive: true
1534
+ },
1535
+ {
1536
+ network: "testnet",
1537
+ protocol: "blend",
1538
+ kind: "backstop",
1539
+ address: "CBDVWXT433PRVTUNM56C3JREF3HIZHRBA64NB2C3B2UNCKIS65ZYCLZA",
1540
+ wasmHash: "c1f4502a757e25c611f5a159bc1ab0eef64085adac6c68123dca66e87faffbc2",
1541
+ version: "v2",
1542
+ label: "Blend V2 backstop (testnet) - read for the account's deposit per pool; the exit withdraws unlocked queued shares from it",
1543
+ verifiedLive: true
1544
+ },
1545
+ {
1546
+ network: "testnet",
1547
+ protocol: "blend",
1548
+ kind: "pool",
1549
+ address: "CCEBVDYM32YNYCVNRXQKDFFPISJJCV557CDZEIRBEE4NCV4KHPQ44HGF",
1550
+ wasmHash: "a41fc53d6753b6c04eb15b021c55052366a4c8e0e21bc72700f461264ec1350e",
1551
+ version: "v2",
1552
+ label: "Blend V2 official testnet test pool",
1553
+ verifiedLive: true
1554
+ },
1555
+ {
1556
+ network: "testnet",
1557
+ protocol: "aquarius",
1558
+ kind: "router",
1559
+ address: "CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD",
1560
+ wasmHash: "d34668cd0b957f4e549719032951503495310a4d1c401ddce591c0f152834254",
1561
+ version: "v1",
1562
+ label: "Aquarius testnet router - reference only; no specific pool instance is publicly documented yet; hash re-verified 2026-11-06 after an in-place upstream upgrade (interface unchanged, swap_split added)",
1563
+ verifiedLive: true
1564
+ },
1565
+ {
1566
+ network: "testnet",
1567
+ protocol: "aquarius",
1568
+ kind: "pool",
1569
+ address: "CDLYWB5CCSNOEXPGHSKYO4FW3R4XFQVI2HR2QC735YDVCSEQJABQDFXI",
1570
+ wasmHash: "d691135aade93ff0f7c229e009cde042130a05124cf7202b03d11246b4f9b473",
1571
+ version: "constant_product",
1572
+ label: "Aquarius testnet constant-product pool (router ConstantPoolHash) - stands for the code every standard pool shares; pools are enumerated from the router",
1573
+ verifiedLive: true
1574
+ },
1575
+ {
1576
+ network: "testnet",
1577
+ protocol: "aquarius",
1578
+ kind: "pool",
1579
+ address: "CDDLEQE6CPQGIK3RU4MK5CX2IAWN6CXWNJ2C3VOXV4FOVF3BBQFVZDIC",
1580
+ wasmHash: "22dff7242d2bc0ea4a4727b4b2cac33b188304d5945740ad24d8a33a5d22741e",
1581
+ version: "stable",
1582
+ label: "Aquarius testnet stableswap pool (router StableSwapPoolHash) - stands for the code every stableswap pool shares",
1583
+ verifiedLive: true
1584
+ },
1585
+ {
1586
+ network: "testnet",
1587
+ protocol: "aquarius",
1588
+ kind: "pool",
1589
+ address: "CCS6EFFKPQWG5SKMMYL4UQIXVYVDNIXAPHKHUM7IGJVN7QIAWXD2L7TO",
1590
+ wasmHash: "155a17b9929ffb1f9e84bd6ef5c00a4d613c1ab5f4ad4c502d84515250cc2907",
1591
+ version: "concentrated",
1592
+ label: "Aquarius testnet concentrated-liquidity pool (router ConcentratedPoolHash) - positions are tick ranges, not shares; recognized so they are never mistaken for a share pool, not exited",
1593
+ verifiedLive: true
1594
+ },
1595
+ {
1596
+ network: "testnet",
1597
+ protocol: "soroswap",
1598
+ kind: "factory",
1599
+ address: "CDP3HMUH6SMS3S7NPGNDJLULCOXXEPSHY4JKUKMBNQMATHDHWXRRJTBY",
1600
+ wasmHash: "86285a9234d3f0d687eaf88efe8d5d72172b38c9a86624c9934c0cbf2aff2993",
1601
+ version: "v1",
1602
+ label: "Soroswap testnet factory - reference only, not probed for balances",
1603
+ verifiedLive: true
1604
+ },
1605
+ {
1606
+ network: "testnet",
1607
+ protocol: "soroswap",
1608
+ kind: "router",
1609
+ address: "CCJUD55AG6W5HAI5LRVNKAE5WDP5XGZBUDS5WNTIVDU7O264UZZE7BRD",
1610
+ wasmHash: "4b95bbf9caec2c6e00c786f53c5f392c2fcdb8435ac0a862ab5e0645eb65824c",
1611
+ version: "v1",
1612
+ label: "Soroswap testnet router - reference only; no specific pair instance is publicly documented yet",
1613
+ verifiedLive: true
1614
+ },
1615
+ {
1616
+ network: "testnet",
1617
+ protocol: "soroswap",
1618
+ kind: "pair",
1619
+ address: "CAAZMNZDUPXEPLLJOGVQYQOJPXFYDZRYX2AMSXFYNP7Q5IKY7WCH2ZV4",
1620
+ wasmHash: "8447525edd62f72ffaf52136358034657ea0511a8fec1cd0ebde649f86cca464",
1621
+ version: "v1",
1622
+ label: "Soroswap testnet pair ARST/XTAR (factory index 1) - stands for the pair code every factory-deployed pair shares; pairs are enumerated from the factory, not listed here",
1623
+ verifiedLive: true
1624
+ },
1625
+ {
1626
+ network: "testnet",
1627
+ protocol: "fxdao",
1628
+ kind: "vault",
1629
+ address: "CBETTPAGB46UYACPNU7MFH4D26TTNCDZXOKJ5N3C7PYKU22AIC4C573N",
1630
+ wasmHash: "e269f0cd2436f38b559bd67de1a658929a7c610c9e72a9e9ee3ae7c5cb4d732d",
1631
+ version: "v1",
1632
+ label: "FxDAO Vaults (testnet) - own build of FxDAO's real open-source vaults contract (FxDAO/FxDAO-SC v0.6.0, not a stub), fully owned with its own oracle and usd stablecoin so the integration suite can self-provision a fresh vault position every run; FxDAO's own testnet and mainnet vaults are both confirmed unusable (see verifiedBy)",
1633
+ verifiedLive: true,
1634
+ verifiedBy: "2026-09-28: built github.com/FxDAO/FxDAO-SC (main, vaults v0.6.0) via stellar contract build, deployed to testnet with a fresh admin-controlled oracle and usd stablecoin; a real vault opened and closed end to end via this adapter's pay_debt call, collateral returned atomically on full repayment. FxDAO's own testnet vault still has no ledger entry; its mainnet vault still exposes only evict/upgrade; founder confirmed the protocol stopped, matching DeFiLlama's Stellar TVL at $0 since 2026-05-20"
1635
+ },
1636
+ {
1637
+ network: "testnet",
1638
+ protocol: "phoenix",
1639
+ kind: "factory",
1640
+ address: "CB7UHVINMUGNHPEFSJYTIIF67ETZAOCVHTBY7XFN5TVKNAWOMVNYIIWW",
1641
+ wasmHash: "721badb85470a81d9d0a1c72dd0debb37f5f268419d4b94d125e546cc32d350e",
1642
+ version: "v1",
1643
+ label: "Phoenix pool factory (testnet) - own redeploy of Phoenix-Protocol-Group/phoenix-contracts' live_factory.wasm mainnet binary; the previously known testnet factory had gone unresolvable, a testnet-reset staleness case; reference only, not probed for balances",
1644
+ verifiedLive: true,
1645
+ verifiedBy: "2026-09-26: stellar contract deploy of .wasm_binaries_mainnet/live_factory.wasm to testnet, then stellar contract info hash over RPC (soroban-testnet.stellar.org) confirmed against the file's own sha256"
1646
+ },
1647
+ {
1648
+ network: "testnet",
1649
+ protocol: "phoenix",
1650
+ kind: "router",
1651
+ address: "CDQM2A7B5ZJIR5DEQF7Q63PWU2EWEJ2KXU5IPN5GY3DR67M2SLQMO7B3",
1652
+ wasmHash: "18336805466bbd05bc388610d36de73994f5b9061bb199c02418a073fcf4b281",
1653
+ version: "v1",
1654
+ label: "Phoenix multihop router (testnet) - own redeploy of live_multihop.wasm; enumerates/routes swaps, never a call target of this codebase's exit",
1655
+ verifiedLive: true,
1656
+ verifiedBy: "2026-09-26: stellar contract deploy of .wasm_binaries_mainnet/live_multihop.wasm to testnet, then stellar contract info hash over RPC (soroban-testnet.stellar.org) confirmed against the file's own sha256"
1657
+ },
1658
+ {
1659
+ network: "testnet",
1660
+ protocol: "phoenix",
1661
+ kind: "pool",
1662
+ address: "CCVEHSVGFYL5SKLO3BSRZCWRHDWKVB5KX6LYT66GX6QNCRJEPYHF6FIV",
1663
+ wasmHash: "14ed2bb1a025c22bcc730ffc9da3f5aa9f7c653f4be402812c32f249e20dee01",
1664
+ version: "v1",
1665
+ label: "Phoenix XYK pool (testnet) - own redeploy of live_xlm_usdc_pool.wasm, genuinely initialized (not just a bytecode reference) with a custom SEP-41 test token so the integration suite can provide and withdraw real liquidity every run; interface confirmed to still expose withdraw_liquidity via stellar contract info interface",
1666
+ verifiedLive: true,
1667
+ verifiedBy: "2026-09-28: initialize()'d directly with native XLM and a fresh admin-mintable token as token_a/token_b, using the real Phoenix LP share-token wasm fetched from a live mainnet pool's own query_share_token_address (the v2.0.0 GitHub release's generic soroban_token_contract.wasm has an incompatible constructor); a real LP position provided and fully withdrawn end to end via withdraw_liquidity"
1668
+ },
1669
+ {
1670
+ network: "testnet",
1671
+ protocol: "phoenix",
1672
+ kind: "stake",
1673
+ address: "CCELNFRXYUDJ5545AM7KIMHDHII5PQEGDVYHA3HSR7HXWUNH67EWBFXP",
1674
+ wasmHash: "a27578aaeb9c1d1686b42d48c211436e977d7bf4f57dafca00c03af58984eee1",
1675
+ version: "v1",
1676
+ label: "Phoenix stake (testnet) - deployed internally by the pool's own initialize() call (the same wasmHash as the previously standalone, unwired redeploy), read from the pool's own query_config stake_contract field; the exit's unbond call target",
1677
+ verifiedLive: true,
1678
+ verifiedBy: "2026-09-28: query_config simulated live against CCVEHSVGFYL5SKLO3BSRZCWRHDWKVB5KX6LYT66GX6QNCRJEPYHF6FIV returned this as stake_contract right after the pool's initialize(); interface confirmed to still expose bond/unbond via stellar contract info interface"
1679
+ },
1680
+ {
1681
+ network: "mainnet",
1682
+ protocol: "blend",
1683
+ kind: "factory",
1684
+ address: "CCZD6ESMOGMPWH2KRO4O7RGTAPGTUPFWFQBELQSS7ZUK63V3TZWETGAG",
1685
+ wasmHash: "0287f4ad7350935b83d94e046c0bcabc960b233dbce1531008c021b71d406a1d",
1686
+ version: "v1",
1687
+ label: "Blend V1 pool factory (mainnet, blend-utils poolFactory) - reference only, not probed for balances; not in the stellar.expert directory",
1688
+ verifiedLive: true
1689
+ },
1690
+ {
1691
+ network: "mainnet",
1692
+ protocol: "blend",
1693
+ kind: "backstop",
1694
+ address: "CAO3AGAMZVRMHITL36EJ2VZQWKYRPWMQAPDQD5YEOF3GIF7T44U4JAL3",
1695
+ wasmHash: "62f61b32fff99f7eec052a8e573c367759f161c481a5caf0e76a10ae4617c3b4",
1696
+ version: "v1",
1697
+ label: "Blend V1 backstop (mainnet, blend-utils backstop) - read for the account's deposit per V1 pool; 21-day withdrawal queue; not in the stellar.expert directory",
1698
+ verifiedLive: true
1699
+ },
1700
+ {
1701
+ network: "mainnet",
1702
+ protocol: "blend",
1703
+ kind: "pool",
1704
+ address: "CDVQVKOY2YSXS2IC7KN6MNASSHPAO7UN2UR2ON4OI2SKMFJNVAMDX6DP",
1705
+ wasmHash: "baf978f10efdbcd85747868bef8832845ea6809f7643b67a4ac0cd669327fc2c",
1706
+ version: "v1",
1707
+ label: "Blend V1 'Fixed' pool (mainnet; stellar.expert: 'Blend Pool') - stands for the V1 lendingPool code every V1 pool shares (YieldBlox CBP7NO6F\u2026 runs the same hash); positions come from OctoPos, not from this list",
1708
+ verifiedLive: true
1709
+ },
1710
+ {
1711
+ network: "mainnet",
1712
+ protocol: "blend",
1713
+ kind: "pool",
1714
+ address: "CBP7NO6F7FRDHSOFQBT2L2UWYIZ2PU76JKVRYAQTG3KZSQLYAOKIF2WB",
1715
+ wasmHash: "baf978f10efdbcd85747868bef8832845ea6809f7643b67a4ac0cd669327fc2c",
1716
+ version: "v1",
1717
+ label: "Blend V1 'YieldBlox' pool (mainnet; blend-utils YieldBlox; stellar.expert: 'Blend Pool'; in the V1 backstop's reward zone) - listed by address so an exit that repays into it is verified like the Fixed pool; its backstop is the registered V1 backstop",
1718
+ verifiedLive: true,
1719
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the V1 pool hash; simulated is_pool on the V1 factory (CCZD6ESMOG...) returned true; instance Name 'YieldBlox'"
1720
+ },
1721
+ {
1722
+ network: "mainnet",
1723
+ protocol: "blend",
1724
+ kind: "pool",
1725
+ address: "CDE65QK2ROZ32V2LVLBOKYPX47TYMYO37Z6ASQTBRTBNK53C7C6QF4Y7",
1726
+ wasmHash: "baf978f10efdbcd85747868bef8832845ea6809f7643b67a4ac0cd669327fc2c",
1727
+ version: "v1",
1728
+ label: "Blend V1 'FxDAO' pool (mainnet; stellar.expert: 'Blend Pool'; in the V1 backstop's reward zone) - listed by address so an exit that repays into it is verified like the Fixed pool; its backstop is the registered V1 backstop",
1729
+ verifiedLive: true,
1730
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the V1 pool hash; simulated is_pool on the V1 factory (CCZD6ESMOG...) returned true; instance Name 'FxDAO'"
1731
+ },
1732
+ {
1733
+ network: "mainnet",
1734
+ protocol: "blend",
1735
+ kind: "pool",
1736
+ address: "CAQF5KNOFIGRI24NQRRGUPD46Q45MGMXZMRTQFXS25Y4NZVNPT34GM6S",
1737
+ wasmHash: "baf978f10efdbcd85747868bef8832845ea6809f7643b67a4ac0cd669327fc2c",
1738
+ version: "v1",
1739
+ label: "Blend V1 'ReflectorFusion' pool (mainnet; not in the stellar.expert directory; in the V1 backstop's reward zone) - listed by address so an exit that repays into it is verified like the Fixed pool; its backstop is the registered V1 backstop",
1740
+ verifiedLive: true,
1741
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the V1 pool hash; simulated is_pool on the V1 factory (CCZD6ESMOG...) returned true; instance Name 'ReflectorFusion'"
1742
+ },
1743
+ {
1744
+ network: "mainnet",
1745
+ protocol: "blend",
1746
+ kind: "pool",
1747
+ address: "CBVOPI6QC6OWVCOEZDCFELAGQNAOHUS4CWOKAVADKQZXVSWR2R5IAKO7",
1748
+ wasmHash: "baf978f10efdbcd85747868bef8832845ea6809f7643b67a4ac0cd669327fc2c",
1749
+ version: "v1",
1750
+ label: "Blend V1 'ClickPesa DebtFund Managed' pool (mainnet; not in the stellar.expert directory; in the V1 backstop's reward zone) - listed by address so an exit that repays into it is verified like the Fixed pool; its backstop is the registered V1 backstop",
1751
+ verifiedLive: true,
1752
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the V1 pool hash; simulated is_pool on the V1 factory (CCZD6ESMOG...) returned true; instance Name 'ClickPesa DebtFund Managed'"
1753
+ },
1754
+ {
1755
+ network: "mainnet",
1756
+ protocol: "blend",
1757
+ kind: "factory",
1758
+ address: "CDSYOAVXFY7SM5S64IZPPPYB4GVGGLMQVFREPSQQEZVIWXX5R23G4QSU",
1759
+ wasmHash: "31328050548831f63d2b72e37bcfd0bb7371b7907135755dbe09ed434d755ca9",
1760
+ version: "v2",
1761
+ label: "Blend V2 pool factory (mainnet; stellar.expert: 'Blend Pool Factory', verified build of blend-contracts-v2) - reference only, not probed for balances; same code hash as the testnet factory",
1762
+ verifiedLive: true
1763
+ },
1764
+ {
1765
+ network: "mainnet",
1766
+ protocol: "blend",
1767
+ kind: "backstop",
1768
+ address: "CAQQR5SWBXKIGZKPBZDH3KM5GQ5GUTPKB7JAFCINLZBC5WXPJKRG3IM7",
1769
+ wasmHash: "c1f4502a757e25c611f5a159bc1ab0eef64085adac6c68123dca66e87faffbc2",
1770
+ version: "v2",
1771
+ label: "Blend V2 backstop (mainnet; stellar.expert: 'Blend Backstop') - read for the account's deposit per V2 pool; the exit withdraws unlocked queued shares from it; same code hash as the testnet backstop",
1772
+ verifiedLive: true
1773
+ },
1774
+ {
1775
+ network: "mainnet",
1776
+ protocol: "blend",
1777
+ kind: "pool",
1778
+ address: "CAJJZSGMMM3PD7N33TAPHGBUGTB43OC73HVIK2L2G6BNGGGYOSSYBXBD",
1779
+ wasmHash: "a41fc53d6753b6c04eb15b021c55052366a4c8e0e21bc72700f461264ec1350e",
1780
+ version: "v2",
1781
+ label: "Blend V2 'Fixed' pool (mainnet; stellar.expert: 'Blend Pool') - stands for the V2 pool code the factory's PoolMeta.pool_hash deploys (YieldBlox V2 CCCCIQSD\u2026 runs the same hash, as does the testnet pool); positions come from OctoPos, not from this list",
1782
+ verifiedLive: true
1783
+ },
1784
+ {
1785
+ network: "mainnet",
1786
+ protocol: "blend",
1787
+ kind: "pool",
1788
+ address: "CCCCIQSDILITHMM7PBSLVDT5MISSY7R26MNZXCX4H7J5JQ5FPIYOGYFS",
1789
+ wasmHash: "a41fc53d6753b6c04eb15b021c55052366a4c8e0e21bc72700f461264ec1350e",
1790
+ version: "v2",
1791
+ label: "Blend V2 'YieldBlox' pool (mainnet; blend-utils YieldBloxV2; stellar.expert: 'Blend Pool') - listed by address so an exit that repays into it is verified like the Fixed pool; its backstop is the registered V2 backstop",
1792
+ verifiedLive: true,
1793
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the V2 pool hash; simulated is_pool on the V2 factory (CDSYOAVXFY...) returned true; instance Name 'YieldBlox'"
1794
+ },
1795
+ {
1796
+ network: "mainnet",
1797
+ protocol: "blend",
1798
+ kind: "pool",
1799
+ address: "CAE7QVOMBLZ53CDRGK3UNRRHG5EZ5NQA7HHTFASEMYBWHG6MDFZTYHXC",
1800
+ wasmHash: "a41fc53d6753b6c04eb15b021c55052366a4c8e0e21bc72700f461264ec1350e",
1801
+ version: "v2",
1802
+ label: "Blend V2 'Orbit' pool (mainnet; stellar.expert: 'Blend Pool') - listed by address so an exit that repays into it is verified like the Fixed pool; its backstop is the registered V2 backstop",
1803
+ verifiedLive: true,
1804
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the V2 pool hash; simulated is_pool on the V2 factory (CDSYOAVXFY...) returned true; instance Name 'Orbit'"
1805
+ },
1806
+ {
1807
+ network: "mainnet",
1808
+ protocol: "blend",
1809
+ kind: "pool",
1810
+ address: "CBYOBT7ZCCLQCBUYYIABZLSEGDPEUWXCUXQTZYOG3YBDR7U357D5ZIRF",
1811
+ wasmHash: "a41fc53d6753b6c04eb15b021c55052366a4c8e0e21bc72700f461264ec1350e",
1812
+ version: "v2",
1813
+ label: "Blend V2 'Forex' pool (mainnet; stellar.expert: 'Blend Pool') - listed by address so an exit that repays into it is verified like the Fixed pool; its backstop is the registered V2 backstop",
1814
+ verifiedLive: true,
1815
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the V2 pool hash; simulated is_pool on the V2 factory (CDSYOAVXFY...) returned true; instance Name 'Forex'"
1816
+ },
1817
+ {
1818
+ network: "mainnet",
1819
+ protocol: "blend",
1820
+ kind: "pool",
1821
+ address: "CDMAVJPFXPADND3YRL4BSM3AKZWCTFMX27GLLXCML3PD62HEQS5FPVAI",
1822
+ wasmHash: "a41fc53d6753b6c04eb15b021c55052366a4c8e0e21bc72700f461264ec1350e",
1823
+ version: "v2",
1824
+ label: "Blend V2 'Etherfuse' pool (mainnet; stellar.expert: 'Blend Pool') - listed by address so an exit that repays into it is verified like the Fixed pool; its backstop is the registered V2 backstop",
1825
+ verifiedLive: true,
1826
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the V2 pool hash; simulated is_pool on the V2 factory (CDSYOAVXFY...) returned true; instance Name 'Etherfuse'"
1827
+ },
1828
+ {
1829
+ network: "mainnet",
1830
+ protocol: "aquarius",
1831
+ kind: "router",
1832
+ address: "CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK",
1833
+ wasmHash: "c99539b023df4a28d7857d33ca4c915c2e20fec04f12b125132b84fbdf94dad3",
1834
+ version: "v1",
1835
+ label: "Aquarius AMM router (mainnet, docs.aqua.network; stellar.expert: 'Aquarius Router') - enumerates the pools; never a call target of an exit; hash re-verified 2026-10-02 after an upstream upgrade (interface unchanged)",
1836
+ verifiedLive: true
1837
+ },
1838
+ {
1839
+ network: "mainnet",
1840
+ protocol: "aquarius",
1841
+ kind: "pool",
1842
+ address: "CCSY43EHJAHT3NQDYKAMJXRFBEEH7OXDL3J3VNGO33UUSEXWNN27GBIZ",
1843
+ wasmHash: "d691135aade93ff0f7c229e009cde042130a05124cf7202b03d11246b4f9b473",
1844
+ version: "constant_product",
1845
+ label: "Aquarius mainnet constant-product pool XLM/AQUA (router ConstantPoolHash; stellar.expert: 'Aquarius Pool') - stands for the code 273 of the router's 346 pools shared on lastVerified; hash re-verified 2026-10-02 after an upstream upgrade (the router's own pool hash, interface only gained view functions)",
1846
+ verifiedLive: true
1847
+ },
1848
+ {
1849
+ network: "mainnet",
1850
+ protocol: "aquarius",
1851
+ kind: "pool",
1852
+ address: "CDKVJYMN34ZIEXSLNFYHVAFF6M6FM5E2U6OHXOTBKH2WLBULXOE53YDP",
1853
+ wasmHash: "22dff7242d2bc0ea4a4727b4b2cac33b188304d5945740ad24d8a33a5d22741e",
1854
+ version: "stable",
1855
+ label: "Aquarius mainnet stableswap pool (router StableSwapPoolHash; stellar.expert: 'Aquarius Pool') - stands for the code 42 of the router's pools shared on lastVerified; hash re-verified 2026-10-02 after an upstream upgrade (the router's own pool hash, interface only gained view functions)",
1856
+ verifiedLive: true
1857
+ },
1858
+ {
1859
+ network: "mainnet",
1860
+ protocol: "aquarius",
1861
+ kind: "pool",
1862
+ address: "CB3ZWHICKIYJOSQ7W2GFN2U2CVSGTFBQ6GCDVGQ354BQYJCKX6L22CNH",
1863
+ wasmHash: "155a17b9929ffb1f9e84bd6ef5c00a4d613c1ab5f4ad4c502d84515250cc2907",
1864
+ version: "concentrated",
1865
+ label: "Aquarius mainnet concentrated-liquidity pool, current router ConcentratedPoolHash (stellar.expert: 'Aquarius Pool') - positions are tick ranges, not shares; recognized so they are never mistaken for a share pool, not exited; added 2026-10-02, and since 2026-10-07 the only concentrated code: all 43 of the router's concentrated pools run it after the older pools were upgraded in place",
1866
+ verifiedLive: true
1867
+ },
1868
+ {
1869
+ network: "mainnet",
1870
+ protocol: "soroswap",
1871
+ kind: "factory",
1872
+ address: "CA4HEQTL2WPEUYKYKCDOHCDNIV4QHNJ7EL4J4NQ6VADP7SYHVRYZ7AW2",
1873
+ wasmHash: "5db738b05d9148128a240b0e2c1cb935c2805192bf98a579421aacda364c8dae",
1874
+ version: "v1",
1875
+ label: "Soroswap factory (mainnet, soroswap/core mainnet.contracts.json; stellar.expert: 'SoroSwap') - 214 pairs on lastVerified; reference only, not probed for balances",
1876
+ verifiedLive: true
1877
+ },
1878
+ {
1879
+ network: "mainnet",
1880
+ protocol: "soroswap",
1881
+ kind: "router",
1882
+ address: "CAG5LRYQ5JVEUI5TEID72EYOVX44TTUJT5BQR2J6J77FH65PCCFAJDDH",
1883
+ wasmHash: "4c3db3ebd2d6a2ab23de1f622eaabb39501539b4611b68622ec4e47f76c4ba07",
1884
+ version: "v1",
1885
+ label: "Soroswap router (mainnet, soroswap/core mainnet.contracts.json; stellar.expert: 'SoroSwap Router') - the exit's remove_liquidity call target",
1886
+ verifiedLive: true
1887
+ },
1888
+ {
1889
+ network: "mainnet",
1890
+ protocol: "soroswap",
1891
+ kind: "pair",
1892
+ address: "CB46LMGJC7SYSH4C7SBNLV635OX5BSNQDGRR32NRXAV7N2AVNZMQUJ3A",
1893
+ wasmHash: "18051456816b66f12e773a56f77c5794fac1b1fb7ab6e22d4fad5a412770f73e",
1894
+ version: "v1",
1895
+ label: "Soroswap mainnet pair BLAH/YAWN (factory index 0) - stands for the pair code soroswap/core publishes as 'pair' and every factory-deployed pair shares; pairs are enumerated from the factory, not listed here; not in the stellar.expert directory",
1896
+ verifiedLive: true
1897
+ },
1898
+ {
1899
+ network: "mainnet",
1900
+ protocol: "soroswap",
1901
+ kind: "aggregator",
1902
+ address: "CARVQXFP4JF5ELLXUMQ6DALR346YVGBMQOHB4ENA7SSVXAYABXLBDDC4",
1903
+ wasmHash: "437653282e9c93b0b4d736d8fde01bf002adefb61bfb75917e609f5336ee3190",
1904
+ version: "v2",
1905
+ label: "Soroswap aggregator v2 (mainnet, deployed 2026-09-14) - the contract a multi-protocol token conversion invokes; swap_exact_in only, partner None",
1906
+ verifiedLive: true,
1907
+ verifiedBy: "2026-09-29: readLiveWasmHash over RPC (mainnet.sorobanrpc.com); the Soroswap API's own swap builds call it; confirmed as the current aggregator by the Soroswap team; its config() names the registry's Soroswap and Aquarius routers. Not yet in soroswap/aggregator public/mainnet.contracts.json"
1908
+ },
1909
+ {
1910
+ network: "mainnet",
1911
+ protocol: "xbull",
1912
+ kind: "router",
1913
+ address: "CCKXBE5GKJOCE7IKL64HLYKW3IJSUPVOLC4CS77GQT5QQHDZLDYV3DFT",
1914
+ wasmHash: "c2b3ec57fbd45d5bade9df2ad30c464d1588cead18495a5ce327a98c45c02219",
1915
+ version: "v1",
1916
+ label: "xBull PathPayment swap router (mainnet, swap-api.xbull.io), strict_send only",
1917
+ verifiedLive: true,
1918
+ verifiedBy: "2026-09-17: readLiveWasmHash over RPC (mainnet.sorobanrpc.com) against CCKXBE5GKJOCE7IKL64HLYKW3IJSUPVOLC4CS77GQT5QQHDZLDYV3DFT (xBullCorp/swap-kit SwapContract.MAINNET)"
1919
+ },
1920
+ {
1921
+ network: "mainnet",
1922
+ protocol: "phoenix",
1923
+ kind: "pool",
1924
+ address: "CB5QUVK5GS3IU23TMFZQ3P5J24YBBZP5PHUQAEJ2SP5K55PFTJRUQG2L",
1925
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
1926
+ version: "v1",
1927
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - stands for the v1 pool code that 10 of the 11 listed Phoenix pools run; positions come from OctoPos, not from this list",
1928
+ verifiedLive: true,
1929
+ verifiedBy: "2026-09-26: stellar contract info hash over RPC (mainnet.sorobanrpc.com) against CB5QUVK5GS3IU23TMFZQ3P5J24YBBZP5PHUQAEJ2SP5K55PFTJRUQG2L, one of the stellar.expert directory's 'Phoenix Pool' entries (domain phoenix-hub.io); stellar contract info interface confirms it still exposes withdraw_liquidity"
1930
+ },
1931
+ {
1932
+ network: "mainnet",
1933
+ protocol: "phoenix",
1934
+ kind: "pool",
1935
+ address: "CBCZGGNOEUZG4CAAE7TGTQQHETZMKUT4OIPFHHPKEUX46U4KXBBZ3GLH",
1936
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
1937
+ version: "v1",
1938
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - runs the v1 pool code; listed by address so its withdraw_liquidity is verified like the representative pool's",
1939
+ verifiedLive: true,
1940
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the v1 pool hash; its persistent CONFIG entry names its share token and stake contract"
1941
+ },
1942
+ {
1943
+ network: "mainnet",
1944
+ protocol: "phoenix",
1945
+ kind: "pool",
1946
+ address: "CBHCRSVX3ZZ7EGTSYMKPEFGZNWRVCSESQR3UABET4MIW52N4EVU6BIZX",
1947
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
1948
+ version: "v1",
1949
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - runs the v1 pool code; listed by address so its withdraw_liquidity is verified like the representative pool's",
1950
+ verifiedLive: true,
1951
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the v1 pool hash; its persistent CONFIG entry names its share token and stake contract"
1952
+ },
1953
+ {
1954
+ network: "mainnet",
1955
+ protocol: "phoenix",
1956
+ kind: "pool",
1957
+ address: "CBISULYO5ZGS32WTNCBMEFCNKNSLFXCQ4Z3XHVDP4X4FLPSEALGSY3PS",
1958
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
1959
+ version: "v1",
1960
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - runs the v1 pool code; listed by address so its withdraw_liquidity is verified like the representative pool's",
1961
+ verifiedLive: true,
1962
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the v1 pool hash; its persistent CONFIG entry names its share token and stake contract"
1963
+ },
1964
+ {
1965
+ network: "mainnet",
1966
+ protocol: "phoenix",
1967
+ kind: "pool",
1968
+ address: "CBW5G5SO5SDYUGQVU7RMZ2KJ34POM3AMODOBIV2RQYG4KJDUUBVC3P2T",
1969
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
1970
+ version: "v1",
1971
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - runs the v1 pool code; listed by address so its withdraw_liquidity is verified like the representative pool's",
1972
+ verifiedLive: true,
1973
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the v1 pool hash; its persistent CONFIG entry names its share token and stake contract"
1974
+ },
1975
+ {
1976
+ network: "mainnet",
1977
+ protocol: "phoenix",
1978
+ kind: "pool",
1979
+ address: "CC6MJZN3HFOJKXN42ANTSCLRFOMHLFXHWPNAX64DQNUEBDMUYMPHASAV",
1980
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
1981
+ version: "v1",
1982
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - runs the v1 pool code; listed by address so its withdraw_liquidity is verified like the representative pool's",
1983
+ verifiedLive: true,
1984
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the v1 pool hash; its persistent CONFIG entry names its share token and stake contract"
1985
+ },
1986
+ {
1987
+ network: "mainnet",
1988
+ protocol: "phoenix",
1989
+ kind: "pool",
1990
+ address: "CCKOC2LJTPDBKDHTL3M5UO7HFZ2WFIHSOKCELMKQP3TLCIVUBKOQL4HB",
1991
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
1992
+ version: "v1",
1993
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - runs the v1 pool code; listed by address so its withdraw_liquidity is verified like the representative pool's",
1994
+ verifiedLive: true,
1995
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the v1 pool hash; its persistent CONFIG entry names its share token and stake contract"
1996
+ },
1997
+ {
1998
+ network: "mainnet",
1999
+ protocol: "phoenix",
2000
+ kind: "pool",
2001
+ address: "CCUCE5H5CKW3S7JBESGCES6ZGDMWLNRY3HOFET3OH33MXZWKXNJTKSM3",
2002
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
2003
+ version: "v1",
2004
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - runs the v1 pool code; listed by address so its withdraw_liquidity is verified like the representative pool's",
2005
+ verifiedLive: true,
2006
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the v1 pool hash; its persistent CONFIG entry names its share token and stake contract"
2007
+ },
2008
+ {
2009
+ network: "mainnet",
2010
+ protocol: "phoenix",
2011
+ kind: "pool",
2012
+ address: "CDMXKSLG5GITGFYERUW2MRYOBUQCMRT2QE5Y4PU3QZ53EBFWUXAXUTBC",
2013
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
2014
+ version: "v1",
2015
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - runs the v1 pool code; listed by address so its withdraw_liquidity is verified like the representative pool's",
2016
+ verifiedLive: true,
2017
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the v1 pool hash; its persistent CONFIG entry names its share token and stake contract"
2018
+ },
2019
+ {
2020
+ network: "mainnet",
2021
+ protocol: "phoenix",
2022
+ kind: "pool",
2023
+ address: "CDQLKNH3725BUP4HPKQKMM7OO62FDVXVTO7RCYPID527MZHJG2F3QBJW",
2024
+ wasmHash: "167ab414a226427de34c19947ef9c5cf38c6c0ed91ecf9392f7cef3278ff506c",
2025
+ version: "v1",
2026
+ label: "Phoenix XYK pool (mainnet; stellar.expert: 'Phoenix Pool') - runs the v1 pool code; listed by address so its withdraw_liquidity is verified like the representative pool's",
2027
+ verifiedLive: true,
2028
+ verifiedBy: "2026-10-15: getLedgerEntries on the instance returned the v1 pool hash; its persistent CONFIG entry names its share token and stake contract"
2029
+ },
2030
+ {
2031
+ network: "mainnet",
2032
+ protocol: "phoenix",
2033
+ kind: "stake",
2034
+ address: "CDBMVFP7KJXW3YEFSLOU5GYUQHHJJI7QPZJPCSPDK6HHBCBZAMCHS2QY",
2035
+ wasmHash: "649715de2b14df3c34a560d9ffb01deeefe029404cd3e9ab184ba22702cbed79",
2036
+ version: "v1",
2037
+ label: "Phoenix stake (mainnet) - the exit's unbond call target for the v1 pool family, read from that pool's own query_config stake_contract field; not listed under its own name in the stellar.expert directory",
2038
+ verifiedLive: true,
2039
+ verifiedBy: "2026-09-26: query_config simulated live against CB5QUVK5GS3IU23TMFZQ3P5J24YBBZP5PHUQAEJ2SP5K55PFTJRUQG2L returned this as stake_contract; stellar contract info hash over RPC (mainnet.sorobanrpc.com) confirmed the hash, and stellar contract info interface confirms it still exposes bond/unbond"
2040
+ },
2041
+ {
2042
+ network: "mainnet",
2043
+ protocol: "phoenix",
2044
+ kind: "stake",
2045
+ address: "CBRGNWGAC25CPLMOAMR7WBPOF5QTFA5RYXQH4DEJ4K65G2QFLTLMW7RO",
2046
+ wasmHash: "57ba0367fd7f5edd8e01a3a1c432a441d49440fdb229fb3dd835528dfc7a41fd",
2047
+ version: "v1",
2048
+ label: "Phoenix stake (mainnet) - the unbond call target for pool CBCZGGNOEUZG4CAAE7TGTQQHETZMKUT4OIPFHHPKEUX46U4KXBBZ3GLH, read from that pool's own CONFIG stake_contract field; an earlier build of the v1 stake code, same unbond signature and BondingInfo layout",
2049
+ verifiedLive: true,
2050
+ verifiedBy: "2026-10-16: the pool's persistent CONFIG entry names this stake_contract; getLedgerEntries on the instance returned this hash; stellar contract info interface shows the same unbond(sender, stake_amount, stake_timestamp) and BondingInfo as the registered v1 stake code, and a staker's entry is keyed by the bare account address"
2051
+ },
2052
+ {
2053
+ network: "mainnet",
2054
+ protocol: "phoenix",
2055
+ kind: "stake",
2056
+ address: "CAF3UJ45ZQJP6USFUIMVMGOUETUTXEC35R2247VJYIVQBGKTKBZKNBJ3",
2057
+ wasmHash: "57ba0367fd7f5edd8e01a3a1c432a441d49440fdb229fb3dd835528dfc7a41fd",
2058
+ version: "v1",
2059
+ label: "Phoenix stake (mainnet) - the unbond call target for pool CBHCRSVX3ZZ7EGTSYMKPEFGZNWRVCSESQR3UABET4MIW52N4EVU6BIZX, read from that pool's own CONFIG stake_contract field; an earlier build of the v1 stake code, same unbond signature and BondingInfo layout",
2060
+ verifiedLive: true,
2061
+ verifiedBy: "2026-10-16: the pool's persistent CONFIG entry names this stake_contract; getLedgerEntries on the instance returned this hash; stellar contract info interface shows the same unbond(sender, stake_amount, stake_timestamp) and BondingInfo as the registered v1 stake code, and a staker's entry is keyed by the bare account address"
2062
+ },
2063
+ {
2064
+ network: "mainnet",
2065
+ protocol: "phoenix",
2066
+ kind: "stake",
2067
+ address: "CDEQYRWFU3IHPRR6H6VOQRUU3JFS6DTUYUL4YAQSD3ALB5IPBTEOZUFM",
2068
+ wasmHash: "649715de2b14df3c34a560d9ffb01deeefe029404cd3e9ab184ba22702cbed79",
2069
+ version: "v1",
2070
+ label: "Phoenix stake (mainnet) - the unbond call target for pool CBISULYO5ZGS32WTNCBMEFCNKNSLFXCQ4Z3XHVDP4X4FLPSEALGSY3PS, read from that pool's own CONFIG stake_contract field",
2071
+ verifiedLive: true,
2072
+ verifiedBy: "2026-10-16: the pool's persistent CONFIG entry names this stake_contract; getLedgerEntries on the instance returned this hash"
2073
+ },
2074
+ {
2075
+ network: "mainnet",
2076
+ protocol: "phoenix",
2077
+ kind: "stake",
2078
+ address: "CCIWIW6ESCCCFMEI5QOSUHDKTMBEMRJ22F7GPYNRKM2UI2FH6WYUKOUU",
2079
+ wasmHash: "57ba0367fd7f5edd8e01a3a1c432a441d49440fdb229fb3dd835528dfc7a41fd",
2080
+ version: "v1",
2081
+ label: "Phoenix stake (mainnet) - the unbond call target for pool CBW5G5SO5SDYUGQVU7RMZ2KJ34POM3AMODOBIV2RQYG4KJDUUBVC3P2T, read from that pool's own CONFIG stake_contract field; an earlier build of the v1 stake code, same unbond signature and BondingInfo layout",
2082
+ verifiedLive: true,
2083
+ verifiedBy: "2026-10-16: the pool's persistent CONFIG entry names this stake_contract; getLedgerEntries on the instance returned this hash; stellar contract info interface shows the same unbond(sender, stake_amount, stake_timestamp) and BondingInfo as the registered v1 stake code, and a staker's entry is keyed by the bare account address"
2084
+ },
2085
+ {
2086
+ network: "mainnet",
2087
+ protocol: "phoenix",
2088
+ kind: "stake",
2089
+ address: "CD2YKNPX3JPTGDANJRPEJS42MPQLEVUVVRZKJYLLUSPJKQJA7LUANBO4",
2090
+ wasmHash: "649715de2b14df3c34a560d9ffb01deeefe029404cd3e9ab184ba22702cbed79",
2091
+ version: "v1",
2092
+ label: "Phoenix stake (mainnet) - the unbond call target for pool CC6MJZN3HFOJKXN42ANTSCLRFOMHLFXHWPNAX64DQNUEBDMUYMPHASAV, read from that pool's own CONFIG stake_contract field",
2093
+ verifiedLive: true,
2094
+ verifiedBy: "2026-10-16: the pool's persistent CONFIG entry names this stake_contract; getLedgerEntries on the instance returned this hash"
2095
+ },
2096
+ {
2097
+ network: "mainnet",
2098
+ protocol: "phoenix",
2099
+ kind: "stake",
2100
+ address: "CDH6JILIADIC5SKE6OZJAYV3GM62RTR4O54OMVNP4ZOK4HH4J2JWJPVW",
2101
+ wasmHash: "649715de2b14df3c34a560d9ffb01deeefe029404cd3e9ab184ba22702cbed79",
2102
+ version: "v1",
2103
+ label: "Phoenix stake (mainnet) - the unbond call target for pool CCKOC2LJTPDBKDHTL3M5UO7HFZ2WFIHSOKCELMKQP3TLCIVUBKOQL4HB, read from that pool's own CONFIG stake_contract field",
2104
+ verifiedLive: true,
2105
+ verifiedBy: "2026-10-16: the pool's persistent CONFIG entry names this stake_contract; getLedgerEntries on the instance returned this hash"
2106
+ },
2107
+ {
2108
+ network: "mainnet",
2109
+ protocol: "phoenix",
2110
+ kind: "stake",
2111
+ address: "CBDCTYZSZIOWCK5IGCQZNFUOJ53KMPYG2MG7GMVGE3A2LEYCFTDYYZ3S",
2112
+ wasmHash: "649715de2b14df3c34a560d9ffb01deeefe029404cd3e9ab184ba22702cbed79",
2113
+ version: "v1",
2114
+ label: "Phoenix stake (mainnet) - the unbond call target for pool CCUCE5H5CKW3S7JBESGCES6ZGDMWLNRY3HOFET3OH33MXZWKXNJTKSM3, read from that pool's own CONFIG stake_contract field",
2115
+ verifiedLive: true,
2116
+ verifiedBy: "2026-10-16: the pool's persistent CONFIG entry names this stake_contract; getLedgerEntries on the instance returned this hash"
2117
+ },
2118
+ {
2119
+ network: "mainnet",
2120
+ protocol: "phoenix",
2121
+ kind: "stake",
2122
+ address: "CBULEXIMZ5C4CSUPZ4E5LXATWDZNS6MDM2A57DAUD5GXSUG4IWKLOSOC",
2123
+ wasmHash: "649715de2b14df3c34a560d9ffb01deeefe029404cd3e9ab184ba22702cbed79",
2124
+ version: "v1",
2125
+ label: "Phoenix stake (mainnet) - the unbond call target for pool CDMXKSLG5GITGFYERUW2MRYOBUQCMRT2QE5Y4PU3QZ53EBFWUXAXUTBC, read from that pool's own CONFIG stake_contract field",
2126
+ verifiedLive: true,
2127
+ verifiedBy: "2026-10-16: the pool's persistent CONFIG entry names this stake_contract; getLedgerEntries on the instance returned this hash"
2128
+ },
2129
+ {
2130
+ network: "mainnet",
2131
+ protocol: "phoenix",
2132
+ kind: "stake",
2133
+ address: "CCP653KENMYCAYQ3PHJDT6PITMG4XYKVWV3OEDDCOAOS6Z4GOMXGYH3Z",
2134
+ wasmHash: "57ba0367fd7f5edd8e01a3a1c432a441d49440fdb229fb3dd835528dfc7a41fd",
2135
+ version: "v1",
2136
+ label: "Phoenix stake (mainnet) - the unbond call target for pool CDQLKNH3725BUP4HPKQKMM7OO62FDVXVTO7RCYPID527MZHJG2F3QBJW, read from that pool's own CONFIG stake_contract field; an earlier build of the v1 stake code, same unbond signature and BondingInfo layout",
2137
+ verifiedLive: true,
2138
+ verifiedBy: "2026-10-16: the pool's persistent CONFIG entry names this stake_contract; getLedgerEntries on the instance returned this hash; stellar contract info interface shows the same unbond(sender, stake_amount, stake_timestamp) and BondingInfo as the registered v1 stake code, and a staker's entry is keyed by the bare account address"
2139
+ },
2140
+ {
2141
+ network: "mainnet",
2142
+ protocol: "phoenix",
2143
+ kind: "pool",
2144
+ address: "CD5XNKK3B6BEF2N7ULNHHGAMOKZ7P6456BFNIHRF4WNTEDKBRWAE7IAA",
2145
+ wasmHash: "13b158655e40396957537bf1c528c6542b315930c1c9e0df640f57293c8af2ca",
2146
+ version: "v2",
2147
+ label: "Phoenix XYK pool, a second live code family (mainnet; stellar.expert: 'Phoenix Pool') - the remaining 1 of 10 directory-listed pools runs this hash instead of the v1 entry's",
2148
+ verifiedLive: true,
2149
+ verifiedBy: "2026-09-26: stellar contract info hash over RPC (mainnet.sorobanrpc.com) against CD5XNKK3B6BEF2N7ULNHHGAMOKZ7P6456BFNIHRF4WNTEDKBRWAE7IAA, one of the stellar.expert directory's 'Phoenix Pool' entries (domain phoenix-hub.io); stellar contract info interface confirms it still exposes withdraw_liquidity"
2150
+ },
2151
+ {
2152
+ network: "mainnet",
2153
+ protocol: "phoenix",
2154
+ kind: "stake",
2155
+ address: "CDOXQONPND365K6MHR3QBSVVTC3MKR44ORK6TI2GQXUXGGAS5SNDAYRI",
2156
+ wasmHash: "3cda0d78dfcd8f3b7aab36a8002e887146e17ae982e9553a3f55b4ce61ec17ae",
2157
+ version: "v2",
2158
+ label: "Phoenix stake (mainnet) - the exit's unbond call target for the v2 pool family, read from that pool's own query_config stake_contract field",
2159
+ verifiedLive: true,
2160
+ verifiedBy: "2026-09-26: query_config simulated live against CD5XNKK3B6BEF2N7ULNHHGAMOKZ7P6456BFNIHRF4WNTEDKBRWAE7IAA returned this as stake_contract; stellar contract info hash over RPC (mainnet.sorobanrpc.com) confirmed the hash, and stellar contract info interface confirms it still exposes bond/unbond"
2161
+ },
2162
+ {
2163
+ network: "mainnet",
2164
+ protocol: "fxdao",
2165
+ kind: "vault",
2166
+ address: "CCUN4RXU5VNDHSF4S4RKV4ZJYMX2YWKOH6L4AKEKVNVDQ7HY5QIAO4UB",
2167
+ wasmHash: "0245bac3d0ada657e247346273316c22b106c113f2085dbbc2c46faa0c28d498",
2168
+ version: "wind-down",
2169
+ label: "FxDAO Vaults (mainnet, per fxdao.io/docs/addresses) - registered so its code is recognized and refused: the deployed code exposes no repay entry point (only evict and upgrade) and the protocol reports panic mode, so no exit is built and no exit may touch it (noExitVersions)",
2170
+ verifiedLive: true,
2171
+ verifiedBy: "2026-11-08: stellar contract fetch --id CCUN4RXU5VNDHSF4S4RKV4ZJYMX2YWKOH6L4AKEKVNVDQ7HY5QIAO4UB over mainnet.sorobanrpc.com, sha256 0245bac3...d498, matching the instance executable from stellar ledger entry fetch contract-data --instance (last modified ledger 62645363); stellar contract info interface lists only evict(prev_key, vault_key) and upgrade(hash); instance CoreState.panic_mode true, VaultsInfo(USD/EUR/GBP) total_vaults 0 with lowest_key None"
2172
+ }
2173
+ ]
2174
+ };
2175
+
2176
+ // ../../apps/web/lib/contract-registry/index.ts
2177
+ var REGISTRY = contract_registry_default;
2178
+ function isExitCapable(entry) {
2179
+ return entry.verifiedLive && entry.wasmHash !== null && !(REGISTRY.noExitVersions?.[entry.protocol] ?? []).includes(entry.version);
2180
+ }
2181
+ var EXIT_FUNCTIONS = {
2182
+ blend: { position: ["submit", "claim"], router: [], backstop: ["withdraw"], stake: [] },
2183
+ soroswap: { position: [], router: ["remove_liquidity"], backstop: [], stake: [] },
2184
+ aquarius: { position: ["withdraw", "claim"], router: [], backstop: [], stake: [] },
2185
+ phoenix: { position: ["withdraw_liquidity"], router: [], backstop: [], stake: ["unbond"] },
2186
+ fxdao: { position: ["pay_debt"], router: [], backstop: [], stake: [] }
2187
+ };
2188
+ function isContractRegistryUsable(now = /* @__PURE__ */ new Date()) {
2189
+ const until = Date.parse(`${REGISTRY.validUntil}T23:59:59Z`);
2190
+ return Number.isFinite(until) && now.getTime() <= until;
2191
+ }
2192
+ function conversionContractsFor(network, now = /* @__PURE__ */ new Date()) {
2193
+ if (!isContractRegistryUsable(now)) return [];
2194
+ return REGISTRY.entries.filter(
2195
+ (e) => e.network === network && (e.protocol === "soroswap" || e.protocol === "xbull") && // A hash-less entry is one nobody resolved on-chain; the API refuses those too.
2196
+ isExitCapable(e) && (e.kind === "aggregator" || e.kind === "router")
2197
+ ).map((e) => e.address);
2198
+ }
2199
+ function exitContractsFor(network, protocols, kind, now = /* @__PURE__ */ new Date()) {
2200
+ if (!isContractRegistryUsable(now)) return [];
2201
+ const wanted = new Set(protocols);
2202
+ return REGISTRY.entries.filter(
2203
+ (e) => e.network === network && e.kind === kind && isExitCapable(e) && wanted.has(e.protocol) && EXIT_FUNCTIONS[e.protocol][kind].length > 0
2204
+ ).map((e) => ({ address: e.address, protocol: e.protocol }));
2205
+ }
2206
+ function registryContractsFor(network, now = /* @__PURE__ */ new Date()) {
2207
+ if (!isContractRegistryUsable(now)) return [];
2208
+ return REGISTRY.entries.filter((e) => e.network === network && isExitCapable(e)).map((e) => e.address);
2209
+ }
2210
+
2211
+ // ../../apps/web/config/xbull-asset-map.json
2212
+ var xbull_asset_map_default = {
2213
+ network: "mainnet",
2214
+ assets: {
2215
+ "0": "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
2216
+ "1": "CCG27OZ5AV4WUXS6XTECWAXEY5UOMEFI2CWFA3LHZGBTLYZWTJF3MJYQ",
2217
+ "2": "CAUIKL3IYGMERDRUN6YSCLWVAKIFG5Q4YJHUKM4S4NJZQIA3BAS6OJPK",
2218
+ "3": "CCYYYCTVCTWCOSE262VEMA6U4LZ3HWAUL245XVR3IKR75TSPYSQAOMNX",
2219
+ "4": "CD25MNVTZDL4Y3XBCPCJXGXATV5WUHHOWMYFF4YBEGU5FCPGMYTVG5JY",
2220
+ "5": "CAO7DDJNGMOYQPRYDY5JVZ5YEK4UQBSMGLAEWRCUOTRMDSBMGWSAATDZ",
2221
+ "6": "CAL6ER2TI6CTRAY6BFXWNWA7WTYXUXTQCHUBCIBU5O6KM3HJFG6Z6VXV",
2222
+ "7": "CBH4M45TQBLDPXOK6L7VYKMEJWFITBOL64BN3WDAIIDT4LNUTWTTOCKF",
2223
+ "8": "CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV",
2224
+ "9": "CBVDRT5474OBUEXF5MJB3UGQ5CG7CKGCAH5M4RV5NBCDJUBZ5OXHJLOU",
2225
+ "10": "CBEOWRDE3GBMF6XF5LPIST3E4FUSXW4LYTOSQPVBJXGDVNWR6IK3GIYI",
2226
+ "11": "CBN3NCJSMOQTC6SPEYK3A44NU4VS3IPKTARJLI3Y77OH27EWBY36TP7U",
2227
+ "12": "CANIDMEFQAKFECKVZ7GIIXQWTY35BPIBPBPUWNMUMR7VGBMVVLRCFLMT",
2228
+ "13": "CCHBWUYVW4QAXQ2KVKSCXT37SWLQOCTAYG2QRQDMLAZXVJJPUO2ZAGXS",
2229
+ "14": "CBCO65UOWXY2GR66GOCMCN6IU3Y45TXCPBY3FLUNL4AOUMOCKVIVV6JC",
2230
+ "15": "CB23WRDQWGSP6YPMY4UV5C4OW5CBTXKYN3XEATG7KJEZCXMJBYEHOUOV",
2231
+ "16": "CAB7CSQK7TNVYGVMYEMOAPM56S6WZSZD3MPJCZ5KFPCUVQ4X2VLQOQDT",
2232
+ "17": "CDWGJD5R37BQIU23LBNUQXIW45WS3CIJPJSP3I4FG5OYDX5MZDTP2RZ6",
2233
+ "18": "CBXE6V454EUYWVQCI4TCSOG4CSNPQ2BLYOTKAKXYFHO3KNVX4CXYCY2T",
2234
+ "19": "CBLK4KSE3CZNQNSVVJMD3VMF4AKF4XG7Y2JCIGEC6Q5XAMGN2WAALGJ5",
2235
+ "20": "CCCRWH6Q3FNP3I2I57BDLM5AFAT7O6OF6GKQOC6SSJNDAVRZ57SPHGU2",
2236
+ "21": "CCKCKCPHYVXQD4NECBFJTFSCU2AMSJGCNG4O6K4JVRE2BLPR7WNDBQIQ",
2237
+ "22": "CBIJBDNZNF4X35BJ4FFZWCDBSCKOP5NB4PLG4SNENRMLAPYG4P5FM6VN",
2238
+ "23": "CD6M4R2322BYCY2LNWM74PEBQAQ63SA3DUJLI3L4225U4ZVCLMSCBCIS",
2239
+ "24": "CDTSZ2VWVPLNCTHVFK7Y2KKOYDH32NAZ5KMPZIMP3BJ2WBAVPH6SWECE",
2240
+ "25": "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75",
2241
+ "26": "CB226ZOEYXTBPD3QEGABTJYSKZVBP2PASEISLG3SBMTN5CE4QZUVZ3CE",
2242
+ "27": "CAC743NYRBMS76L2DCPAXZTOEF6EJPKPVEC5OX2SXY7HOWNXISSLUE2C",
2243
+ "28": "CCOB35AE6UJQPEUCSJYYX42NAEHQD2FHRQSQYGLJAWJL7STGES7BNVYR",
2244
+ "29": "CB3YA656OYIHU57657I5KGSBRHE5I3OZU4VFC22PYAOANFZHEWNYGAGP",
2245
+ "30": "CDIKURWHYS4FFTR5KOQK6MBFZA2K3E26WGBQI6PXBYWZ4XIOPJHDFJKP",
2246
+ "31": "CBLV4ATSIWU67CFSQU2NVRKINQIKUZ2ODSZBUJTJ43VJVRSBTZYOPNUR",
2247
+ "32": "CAESLMGW5LYTIEJI7FJHK6SFSWRELLNVX5Q4WR4UZEALMTRWQDBKDPAG",
2248
+ "33": "CBLLEW7HD2RWATVSMLAGWM4G3WCHSHDJ25ALP4DI6LULV5TU35N2CIZA",
2249
+ "34": "CAAV3AE3VKD2P4TY7LWTQMMJHIJ4WOCZ5ANCIJPC3NRSERKVXNHBU2W7",
2250
+ "35": "CDCKFBZYF2AQCSM3JOF2ZM27O3Y6AJAI4OTCQKAFNZ3FHBYUTFOKICIY",
2251
+ "36": "CBRP2VD3CZLEQIQZ4JMBXGA5AC2U6JE26YU5CCIOICIZCVWPGBO2QRUB",
2252
+ "37": "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
2253
+ "38": "CDFZUVS5YNLXU7VENKOUDEOHCJGKQNVUBWD7KMN6E7ZROKPYPFLRUJFG",
2254
+ "39": "CAUP7NFABXE5TJRL3FKTPMWRLC7IAXYDCTHQRFSCLR5TMGKHOOQO772J",
2255
+ "40": "CB2XMFB6BDIHFOSFB5IXHDOYV3SI3IXMNIZLPDZHC7ENDCXSBEBZAO2Y",
2256
+ "41": "CDYEOOVL6WV4JRY45CXQKOBJFFAPOM5KNQCCDNM333L6RM2L4RO3LKYG",
2257
+ "42": "CDOFW7HNKLUZRLFZST4EW7V3AV4JI5IHMT6BPXXSY2IEFZ4NE5TWU2P4",
2258
+ "43": "CBZVSNVB55ANF24QVJL2K5QCLOAB6XITGTGXYEAF6NPTXYKEJUYQOHFC",
2259
+ "44": "CBI7UCH5KGSVQRO5H4SUCZUTZABCITZLRHQQZTWL2TK4RZ72TAR6IHRV",
2260
+ "45": "CC64WBDGS6QQP22QTTIACYIXT3WF7BBQEYOQPLTP7GTKYY7PZ74QYGSL",
2261
+ "46": "CBSJZEIO5C7KC2SF3MKSNXXJSW5G3VTNBX4ATMKUI3B2MR4JKM4R26YF"
2262
+ }
2263
+ };
2264
+
2265
+ // ../../apps/web/lib/stellar/exit-expectations.ts
2266
+ function xbullAssetsFor(network) {
2267
+ return xbull_asset_map_default.network === network ? { ...xbull_asset_map_default.assets } : {};
2268
+ }
2269
+ function exitExpectations(accountState, network) {
2270
+ if (!accountState) {
2271
+ return {
2272
+ exitContracts: [],
2273
+ conversionContracts: [],
2274
+ xlmContract: stellarSdk.Asset.native().contractId(NETWORK_PASSPHRASES[network]),
2275
+ heldTokenContracts: [],
2276
+ positionTokenContracts: [],
2277
+ exitFunctions: {},
2278
+ registryContracts: registryContractsFor(network),
2279
+ protectedTokenContracts: [stellarSdk.Asset.native().contractId(NETWORK_PASSPHRASES[network])],
2280
+ xbullAssets: xbullAssetsFor(network),
2281
+ ownTokensByContract: {},
2282
+ repayTokensByPool: {},
2283
+ shareTokenContracts: [],
2284
+ debtTokenContracts: []
2285
+ };
2286
+ }
2287
+ const passphrase = NETWORK_PASSPHRASES[network];
2288
+ const positions = accountState.defiPositions?.positions ?? [];
2289
+ const trustlines = accountState.trustlines ?? [];
2290
+ const protocols = positions.map((p) => p.protocol);
2291
+ const routers = exitContractsFor(network, protocols, "router");
2292
+ const backstops = exitContractsFor(network, protocols, "backstop");
2293
+ const stakes = exitContractsFor(network, protocols, "stake");
2294
+ const exitContracts = [
2295
+ .../* @__PURE__ */ new Set([
2296
+ ...positions.map((p) => p.contractAddress),
2297
+ ...routers.map((r) => r.address),
2298
+ ...backstops.map((b) => b.address),
2299
+ ...stakes.map((s) => s.address)
2300
+ ])
2301
+ ];
2302
+ const exitFunctions = {};
2303
+ for (const p of positions) {
2304
+ exitFunctions[p.contractAddress] = [...EXIT_FUNCTIONS[p.protocol].position];
2305
+ }
2306
+ for (const r of routers) exitFunctions[r.address] = [...EXIT_FUNCTIONS[r.protocol].router];
2307
+ for (const b of backstops) exitFunctions[b.address] = [...EXIT_FUNCTIONS[b.protocol].backstop];
2308
+ for (const s of stakes) exitFunctions[s.address] = [...EXIT_FUNCTIONS[s.protocol].stake];
2309
+ const ownTokens = (p) => [
2310
+ ..."tokens" in p && p.tokens ? p.tokens : [],
2311
+ ..."shareToken" in p && p.shareToken ? [p.shareToken] : [],
2312
+ ..."debtToken" in p && p.debtToken ? [p.debtToken] : []
2313
+ ];
2314
+ const positionTokenContracts = [...new Set(positions.flatMap(ownTokens))];
2315
+ const heldTokenContracts = [
2316
+ .../* @__PURE__ */ new Set([
2317
+ stellarSdk.Asset.native().contractId(passphrase),
2318
+ ...trustlines.map((tl) => new stellarSdk.Asset(tl.code, tl.issuer).contractId(passphrase)),
2319
+ ...(accountState.sorobanTokens?.tokens ?? []).filter((t) => /^C[A-Z2-7]{55}$/.test(t.contract) && /^[1-9]\d*$/.test(t.balance)).map((t) => t.contract)
2320
+ ])
2321
+ ];
2322
+ const borrows = positions.filter((p) => p.protocol === "blend" && p.positionType === "borrow");
2323
+ return {
2324
+ exitContracts,
2325
+ heldTokenContracts,
2326
+ positionTokenContracts,
2327
+ exitFunctions,
2328
+ conversionContracts: conversionContractsFor(network),
2329
+ xlmContract: stellarSdk.Asset.native().contractId(passphrase),
2330
+ registryContracts: registryContractsFor(network),
2331
+ protectedTokenContracts: [
2332
+ .../* @__PURE__ */ new Set([
2333
+ stellarSdk.Asset.native().contractId(passphrase),
2334
+ ...trustlines.map((tl) => new stellarSdk.Asset(tl.code, tl.issuer).contractId(passphrase))
2335
+ ])
2336
+ ],
2337
+ xbullAssets: xbullAssetsFor(network),
2338
+ ownTokensByContract: Object.fromEntries(
2339
+ positions.map((p) => [p.contractAddress, ownTokens(p)])
2340
+ ),
2341
+ repayTokensByPool: Object.fromEntries(
2342
+ borrows.map(({ contractAddress: pool }) => [
2343
+ pool,
2344
+ borrows.filter((b) => b.contractAddress === pool).map((b) => b.assetAddress)
2345
+ ])
2346
+ ),
2347
+ shareTokenContracts: [
2348
+ ...new Set(
2349
+ positions.flatMap((p) => "shareToken" in p && p.shareToken ? [p.shareToken] : [])
2350
+ )
2351
+ ],
2352
+ debtTokenContracts: [
2353
+ ...new Set(positions.flatMap((p) => "debtToken" in p && p.debtToken ? [p.debtToken] : []))
2354
+ ]
2355
+ };
2356
+ }
2357
+
2358
+ // src/index.ts
2359
+ function verifyCloseTransaction2(input) {
2360
+ verifyCloseTransaction(input);
2361
+ }
2362
+ function exitExpectations2(accountState, network) {
2363
+ return exitExpectations(accountState, network);
2364
+ }
2365
+ function requiresMediator(address) {
2366
+ return mediatorAllowedFor(address);
2367
+ }
2368
+
2369
+ exports.VerificationError = VerificationError;
2370
+ exports.exitExpectations = exitExpectations2;
2371
+ exports.requiresMediator = requiresMediator;
2372
+ exports.verifyCloseTransaction = verifyCloseTransaction2;