@lumenwipe/verify 0.6.0 → 0.7.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/CHANGELOG.md CHANGED
@@ -7,6 +7,51 @@ release is cut.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.7.0] - 2026-11-23
11
+
12
+ ### Added
13
+
14
+ - The `mediator_forward_balance_unknown` verification code.
15
+ - Classic liquidity pool withdrawals. `verify()` accepts a `liquidityPoolWithdraw` only for a pool
16
+ in the new optional `poolWithdrawals` expectation, for exactly the shares held, with each
17
+ minimum at least 98% and at most 101% of what the expected reserves give (exactly 0 for a side
18
+ they give nothing of). A pool share trustline removal is accepted only for one of those pools,
19
+ with the pool id derived from the asset pair and fee the operation carries. Without
20
+ `poolWithdrawals` both are refused. Build it with the new `poolWithdrawalExpectations` from the
21
+ account read. New codes: `pool_not_held`, `pool_withdraw_duplicate`,
22
+ `pool_withdraw_amount_mismatch`, `pool_withdraw_min_missing`, `pool_withdraw_min_below_floor`,
23
+ `pool_withdraw_min_above_reserves` and `pool_line_mismatch`. A new accepted vector withdraws
24
+ from a pool, with rejected mutations for a swapped pool, a changed share amount, a zero, a low
25
+ and an inflated minimum, and the removal of another pool's share line.
26
+ - Sponsorship revokes of a liquidity pool share trustline, alongside every other kind (see
27
+ Changed). A new accepted vector revokes one sponsorship of each kind before the merge: an
28
+ account, an asset trustline, a pool share trustline, an offer, a data entry, and an ed25519, a
29
+ pre-authorized transaction and a hash signer. Its rejected mutations name the same entry on
30
+ another account and the same entry twice, for each kind, then another asset, pool, offer, data
31
+ name and signer of the same account.
32
+ - `SponsoredEntry` is exported, the type of an account read's `sponsoredEntries`.
33
+
34
+ ### Changed
35
+
36
+ - **Breaking:** `verify()` accepts a sponsorship revoke of any kind only for an entry in the new
37
+ optional `sponsoredEntries` expectation, matched by kind, owner and key (the asset, the pool id,
38
+ the offer id, the data name, the signer's strkey), at most once per transaction. Without
39
+ `sponsoredEntries` every sponsorship revoke is refused, where 0.6.0 accepted every one. A data name that is not valid UTF-8 names no entry. New codes:
40
+ `sponsorship_revoke_unknown` and `sponsorship_revoke_duplicate`. To migrate, pass the account
41
+ read's list as is: `sponsoredEntries: account.sponsoredEntries`.
42
+ - `verify()` refuses the mediator hand-off when the observed native balance is not above the
43
+ 0.01 XLM tolerance (`mediator_forward_balance_unknown`). Below it the forward floor was zero or
44
+ negative, so a check run with no balance read (`nativeBalance: "0"`) accepted any forward. A new
45
+ accepted vector verifies a round ahead of the merge with no balance read, and its rejected
46
+ mutation adds the hand-off to it.
47
+ - The bundled list of networks now comes from one module that the web app's routing also reads.
48
+ The networks themselves (`mainnet`, `testnet`) and what `verify()` accepts are unchanged.
49
+ - The bundled contract registry (version `2026-11-23`) re-pins the mainnet Soroswap aggregator
50
+ (`CARVQXFP4JF5ELLXUMQ6DALR346YVGBMQOHB4ENA7SSVXAYABXLBDDC4`) to the code it runs since its
51
+ upstream upgrade on 2026-11-23. The previous code is no longer recognized. The aggregator's
52
+ address, its `swap_exact_in` interface and the contracts a close may call are unchanged, and so
53
+ is verification.
54
+
10
55
  ## [0.6.0] - 2026-11-19
11
56
 
12
57
  ### Added
@@ -172,7 +217,8 @@ The bundled exchange and contract registries are unchanged.
172
217
  is optional, and a rejection may mutate the snapshot instead of, or with, the transaction.
173
218
  - The package ships its `LICENSE` and this `CHANGELOG.md`.
174
219
 
175
- [Unreleased]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.6.0...HEAD
220
+ [Unreleased]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.7.0...HEAD
221
+ [0.7.0]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.6.0...verify-v0.7.0
176
222
  [0.6.0]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.5.0...verify-v0.6.0
177
223
  [0.5.0]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.4.0...verify-v0.5.0
178
224
  [0.4.0]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.3.0...verify-v0.4.0
package/README.md CHANGED
@@ -52,6 +52,7 @@ await runClose({
52
52
  tokenTransfers: {},
53
53
  classicConversions: {},
54
54
  tokenConversions: {},
55
+ sponsoredEntries: account.sponsoredEntries,
55
56
  ...exitExpectations(account, "testnet"),
56
57
  },
57
58
  servedRegistry,
@@ -70,6 +71,7 @@ Never from the transaction under verification, and never from the API's `intent`
70
71
  | `claimTrustlineAssets` | The `CODE:ISSUER` of each claimable balance the user chose to claim. |
71
72
  | `source`, `nativeBalance`, `accountSigners`, `accountThresholds` | The account read the user reviewed (`client.getAccount`, or a round's `sourceAccount`). Empty signers fail closed. |
72
73
  | The DeFi fields (`exitContracts` and the rest) | `exitExpectations(account, network)`: the same read plus the contract registry bundled here. |
74
+ | `sponsoredEntries` | The same read's `sponsoredEntries`, as is. Omitted, every sponsorship revoke is refused. |
73
75
 
74
76
  Whether a destination is a listed exchange, whether it needs a memo and of which type, and
75
77
  whether the merge must go through the shared intermediary are not inputs. The verifier derives
package/dist/index.cjs CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  var stellarSdk = require('@stellar/stellar-sdk');
4
4
 
5
+ // ../../apps/web/lib/stellar/verify.ts
6
+
5
7
  // ../../apps/web/config/networks.ts
6
8
  var NETWORK_PASSPHRASES = {
7
9
  mainnet: "Public Global Stellar Network ; September 2015",
@@ -396,6 +398,12 @@ function describeInvocation(op) {
396
398
  function toHex(bytes) {
397
399
  return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
398
400
  }
401
+ function fromHex(hex) {
402
+ const out = new Uint8Array(hex.length / 2);
403
+ for (let i = 0; i < out.length; i++)
404
+ out.set([Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16)], i);
405
+ return out;
406
+ }
399
407
  function toBase64(bytes) {
400
408
  return btoa(String.fromCharCode(...bytes));
401
409
  }
@@ -462,7 +470,30 @@ function decodeSigner(signer) {
462
470
  }
463
471
  return null;
464
472
  }
465
- function normalizeOp(op) {
473
+ var keyBytes = (value) => typeof value === "string" ? fromHex(value) : value;
474
+ function revokedSignerKey(signer) {
475
+ if ("ed25519PublicKey" in signer) return signer.ed25519PublicKey;
476
+ if ("ed25519SignedPayload" in signer) return signer.ed25519SignedPayload;
477
+ if ("preAuthTx" in signer) return stellarSdk.StrKey.encodePreAuthTx(keyBytes(signer.preAuthTx));
478
+ return stellarSdk.StrKey.encodeSha256Hash(keyBytes(signer.sha256Hash));
479
+ }
480
+ function revokedDataName(raw) {
481
+ const body = raw?.body;
482
+ const revoke = body?.type === "revokeSponsorship" ? body.revokeSponsorshipOp : void 0;
483
+ const key = revoke?.type === "revokeSponsorshipLedgerEntry" ? revoke.ledgerKey : void 0;
484
+ if (key?.type !== "data") return void 0;
485
+ try {
486
+ return STRICT_UTF8.decode(key.data.dataName.bytes);
487
+ } catch {
488
+ return void 0;
489
+ }
490
+ }
491
+ function rawOperations(tx) {
492
+ const envelope = tx.toEnvelope();
493
+ if (envelope.type === "envelopeTypeTxV0") return envelope.v0.tx.operations;
494
+ return envelope.type === "envelopeTypeTx" ? envelope.v1.tx.operations : [];
495
+ }
496
+ function normalizeOp(op, raw) {
466
497
  switch (op.type) {
467
498
  case "pathPaymentStrictSend":
468
499
  return {
@@ -483,9 +514,29 @@ function normalizeOp(op) {
483
514
  };
484
515
  case "changeTrust": {
485
516
  const line = op.line;
486
- const asset = "getCode" in line ? assetToString(line) : `pool:${line.toString()}`;
487
- return { type: "change_trust", asset, limit: op.limit };
517
+ if ("getCode" in line) {
518
+ return { type: "change_trust", asset: assetToString(line), limit: op.limit };
519
+ }
520
+ const params = line.getLiquidityPoolParameters();
521
+ return {
522
+ type: "change_trust",
523
+ asset: `pool:${line.toString()}`,
524
+ limit: op.limit,
525
+ pool: {
526
+ assetA: assetToString(params.assetA),
527
+ assetB: assetToString(params.assetB),
528
+ fee: params.fee
529
+ }
530
+ };
488
531
  }
532
+ case "liquidityPoolWithdraw":
533
+ return {
534
+ type: "liquidity_pool_withdraw",
535
+ poolId: op.liquidityPoolId,
536
+ amount: op.amount,
537
+ minAmountA: op.minAmountA,
538
+ minAmountB: op.minAmountB
539
+ };
489
540
  case "accountMerge":
490
541
  return { type: "account_merge", destination: op.destination };
491
542
  case "manageSellOffer":
@@ -519,13 +570,35 @@ function normalizeOp(op) {
519
570
  case "revokeAccountSponsorship":
520
571
  return { type: "revoke_sponsorship", entryKind: "account", owner: op.account };
521
572
  case "revokeTrustlineSponsorship":
522
- return { type: "revoke_sponsorship", entryKind: "trustline", owner: op.account };
573
+ return "getLiquidityPoolId" in op.asset ? {
574
+ type: "revoke_sponsorship",
575
+ entryKind: "trustline",
576
+ owner: op.account,
577
+ poolId: op.asset.getLiquidityPoolId()
578
+ } : {
579
+ type: "revoke_sponsorship",
580
+ entryKind: "trustline",
581
+ owner: op.account,
582
+ asset: assetToString(op.asset)
583
+ };
523
584
  case "revokeOfferSponsorship":
524
- return { type: "revoke_sponsorship", entryKind: "offer", owner: op.seller };
525
- case "revokeDataSponsorship":
526
- return { type: "revoke_sponsorship", entryKind: "data_entry", owner: op.account };
585
+ return {
586
+ type: "revoke_sponsorship",
587
+ entryKind: "offer",
588
+ owner: op.seller,
589
+ offerId: op.offerId
590
+ };
591
+ case "revokeDataSponsorship": {
592
+ const name = revokedDataName(raw);
593
+ return name === void 0 ? { type: "revoke_sponsorship", entryKind: "data_entry", owner: op.account } : { type: "revoke_sponsorship", entryKind: "data_entry", owner: op.account, name };
594
+ }
527
595
  case "revokeSignerSponsorship":
528
- return { type: "revoke_sponsorship", entryKind: "signer", owner: op.account };
596
+ return {
597
+ type: "revoke_sponsorship",
598
+ entryKind: "signer",
599
+ owner: op.account,
600
+ signerKey: revokedSignerKey(op.signer)
601
+ };
529
602
  case "invokeHostFunction":
530
603
  return describeInvocation(op);
531
604
  default:
@@ -537,8 +610,9 @@ function sumAmounts(a, b) {
537
610
  }
538
611
  function intentFromXdr(xdr2, networkPassphrase) {
539
612
  const tx = stellarSdk.TransactionBuilder.fromXdr(xdr2, networkPassphrase);
540
- const operations = tx.operations.map((op) => ({
541
- ...normalizeOp(op),
613
+ const raw = rawOperations(tx);
614
+ const operations = tx.operations.map((op, index) => ({
615
+ ...normalizeOp(op, raw[index]),
542
616
  source: op.source ?? tx.source
543
617
  }));
544
618
  const merge = operations.find(
@@ -590,6 +664,150 @@ function xlmToStroops(xlm) {
590
664
  var MAX_EXIT_FEE_STROOPS = BigInt(1e7);
591
665
  var MAX_CLASSIC_FEE_PER_OPERATION_STROOPS = BigInt(1e3);
592
666
  var MAX_VALIDITY_SECONDS = 900;
667
+ function poolWithdrawalExpectations(accountState) {
668
+ const pools = {};
669
+ for (const share of accountState?.poolShares ?? []) {
670
+ if (!share.pool) continue;
671
+ pools[share.poolId] = {
672
+ shares: xlmToStroops(share.balance),
673
+ reserveA: share.pool.reserveA,
674
+ reserveB: share.pool.reserveB,
675
+ totalShares: share.pool.totalShares
676
+ };
677
+ }
678
+ return pools;
679
+ }
680
+ var POOL_MIN_FLOOR_BPS = BigInt(9800);
681
+ var POOL_MIN_CEILING_BPS = BigInt(10100);
682
+ function assertPoolMinimum(min, shares, reserve, total) {
683
+ const given = total > BigInt(0) ? shares * reserve / total : BigInt(0);
684
+ if (given > BigInt(0) && min <= BigInt(0)) {
685
+ throw new VerificationError(
686
+ "pool_withdraw_min_missing",
687
+ "A pool withdrawal has no minimum for an asset the pool pays out."
688
+ );
689
+ }
690
+ if (min < given * POOL_MIN_FLOOR_BPS / BigInt(1e4)) {
691
+ throw new VerificationError(
692
+ "pool_withdraw_min_below_floor",
693
+ "A pool withdrawal would accept less than the pool's reserves give. If the pool moved since the analysis, run it again."
694
+ );
695
+ }
696
+ if (min > given * POOL_MIN_CEILING_BPS / BigInt(1e4)) {
697
+ throw new VerificationError(
698
+ "pool_withdraw_min_above_reserves",
699
+ "A pool withdrawal asks for more than the pool's reserves give. If the pool moved since the analysis, run it again."
700
+ );
701
+ }
702
+ }
703
+ function assertPoolWithdrawal(op, expected, seen) {
704
+ const held = expected.poolWithdrawals?.[op.poolId];
705
+ if (!held) {
706
+ throw new VerificationError(
707
+ "pool_not_held",
708
+ "A withdrawal names a liquidity pool your account holds no shares in."
709
+ );
710
+ }
711
+ if (seen.has(op.poolId)) {
712
+ throw new VerificationError(
713
+ "pool_withdraw_duplicate",
714
+ "The transaction would withdraw from the same liquidity pool more than once."
715
+ );
716
+ }
717
+ seen.add(op.poolId);
718
+ const shares = BigInt(held.shares);
719
+ if (BigInt(xlmToStroops(op.amount)) !== shares) {
720
+ throw new VerificationError(
721
+ "pool_withdraw_amount_mismatch",
722
+ "A pool withdrawal does not withdraw exactly the shares your account holds."
723
+ );
724
+ }
725
+ const total = BigInt(held.totalShares);
726
+ assertPoolMinimum(BigInt(xlmToStroops(op.minAmountA)), shares, BigInt(held.reserveA), total);
727
+ assertPoolMinimum(BigInt(xlmToStroops(op.minAmountB)), shares, BigInt(held.reserveB), total);
728
+ }
729
+ function sdkAsset(asset) {
730
+ if (asset === "native") return stellarSdk.Asset.native();
731
+ const [code, issuer] = asset.split(":");
732
+ return new stellarSdk.Asset(code ?? "", issuer);
733
+ }
734
+ var entryKey = (kind, owner, key) => JSON.stringify([kind, owner, key]);
735
+ function sponsoredEntryKey(entry) {
736
+ switch (entry.kind) {
737
+ case "account":
738
+ return entryKey(entry.kind, entry.owner, "");
739
+ case "trustline":
740
+ return entryKey(entry.kind, entry.owner, entry.asset);
741
+ case "pool_share_trustline":
742
+ return entryKey(entry.kind, entry.owner, entry.poolId);
743
+ case "offer":
744
+ return entryKey(entry.kind, entry.owner, entry.offerId);
745
+ case "data_entry":
746
+ return entryKey(entry.kind, entry.owner, entry.name);
747
+ case "signer":
748
+ return entryKey(entry.kind, entry.owner, entry.signerKey);
749
+ case "claimable_balance":
750
+ return null;
751
+ }
752
+ }
753
+ function revokedEntryKey(op) {
754
+ switch (op.entryKind) {
755
+ case "account":
756
+ return entryKey("account", op.owner, "");
757
+ case "trustline":
758
+ if (op.poolId !== void 0) return entryKey("pool_share_trustline", op.owner, op.poolId);
759
+ return op.asset === void 0 ? null : entryKey("trustline", op.owner, op.asset);
760
+ case "offer":
761
+ return op.offerId === void 0 ? null : entryKey("offer", op.owner, op.offerId);
762
+ case "data_entry":
763
+ return op.name === void 0 ? null : entryKey("data_entry", op.owner, op.name);
764
+ case "signer":
765
+ return op.signerKey === void 0 ? null : entryKey("signer", op.owner, op.signerKey);
766
+ }
767
+ }
768
+ function assertSponsoredEntryRevoke(op, expected, seen) {
769
+ const key = revokedEntryKey(op);
770
+ const listed = new Set((expected.sponsoredEntries ?? []).map(sponsoredEntryKey));
771
+ if (key === null || !listed.has(key)) {
772
+ throw new VerificationError(
773
+ "sponsorship_revoke_unknown",
774
+ "A sponsorship revoke names an entry your account is not known to sponsor."
775
+ );
776
+ }
777
+ if (seen.has(key)) {
778
+ throw new VerificationError(
779
+ "sponsorship_revoke_duplicate",
780
+ "The transaction would revoke the sponsorship of the same entry more than once."
781
+ );
782
+ }
783
+ seen.add(key);
784
+ }
785
+ function assertPoolLine(op, expected) {
786
+ const mismatch = new VerificationError(
787
+ "pool_line_mismatch",
788
+ "A pool share trustline change does not match the pool it names."
789
+ );
790
+ if (!op.pool) throw mismatch;
791
+ let poolId;
792
+ try {
793
+ poolId = toHex(
794
+ stellarSdk.getLiquidityPoolId("constant_product", {
795
+ assetA: sdkAsset(op.pool.assetA),
796
+ assetB: sdkAsset(op.pool.assetB),
797
+ fee: op.pool.fee
798
+ })
799
+ );
800
+ } catch {
801
+ throw mismatch;
802
+ }
803
+ if (op.asset !== `pool:liquidity_pool:${poolId}`) throw mismatch;
804
+ if (!expected.poolWithdrawals?.[poolId]) {
805
+ throw new VerificationError(
806
+ "pool_not_held",
807
+ "A trustline change names a liquidity pool your account holds no shares in."
808
+ );
809
+ }
810
+ }
593
811
  function assertMergeShape(intent, expected) {
594
812
  const merges = intent.operations.filter((o) => o.type === "account_merge");
595
813
  if (merges.length === 0) return null;
@@ -873,6 +1091,12 @@ function assetCode(asset) {
873
1091
  function assertForwardCarriesTheBalance(forwardAmount, nativeBalance) {
874
1092
  const forwarded = BigInt(xlmToStroops(forwardAmount));
875
1093
  const observed = BigInt(xlmToStroops(nativeBalance));
1094
+ if (observed <= FORWARD_SHORTFALL_TOLERANCE_STROOPS) {
1095
+ throw new VerificationError(
1096
+ "mediator_forward_balance_unknown",
1097
+ "The balance this close would pass on is unknown or too small to check, so the hand-off is refused. Run the analysis again, or close to a wallet you control."
1098
+ );
1099
+ }
876
1100
  const floor = observed - FORWARD_SHORTFALL_TOLERANCE_STROOPS;
877
1101
  if (forwarded < floor) {
878
1102
  throw new VerificationError(
@@ -927,6 +1151,8 @@ function assertCloseIntent(intent, expected) {
927
1151
  const forward = assertMergeShape(intent, expected);
928
1152
  const seenTransfers = /* @__PURE__ */ new Set();
929
1153
  const seenConversions = /* @__PURE__ */ new Set();
1154
+ const seenWithdrawals = /* @__PURE__ */ new Set();
1155
+ const seenSponsoredEntries = /* @__PURE__ */ new Set();
930
1156
  for (const op of intent.operations) {
931
1157
  switch (op.type) {
932
1158
  case "payment": {
@@ -982,7 +1208,11 @@ function assertCloseIntent(intent, expected) {
982
1208
  }
983
1209
  break;
984
1210
  }
1211
+ case "liquidity_pool_withdraw":
1212
+ assertPoolWithdrawal(op, expected, seenWithdrawals);
1213
+ break;
985
1214
  case "change_trust":
1215
+ if (op.pool || op.asset.startsWith("pool:")) assertPoolLine(op, expected);
986
1216
  if (Number(op.limit) !== 0 && !expected.claimTrustlineAssets.includes(op.asset)) {
987
1217
  throw new VerificationError(
988
1218
  "trustline_not_removal",
@@ -1416,11 +1646,8 @@ function assertCloseIntent(intent, expected) {
1416
1646
  "operation_unknown",
1417
1647
  "The transaction contains an unrecognized operation."
1418
1648
  );
1419
- // Stryker disable next-line ConditionalExpression: this case's entire body is a no-op
1420
- // `break` (see the comment below for why revoke_sponsorship needs no check). Collapsing it
1421
- // just falls through to the next case, which is also a no-op `break` - unobservable either
1422
- // way.
1423
1649
  case "revoke_sponsorship":
1650
+ assertSponsoredEntryRevoke(op, expected, seenSponsoredEntries);
1424
1651
  break;
1425
1652
  case "account_merge":
1426
1653
  case "claim_claimable_balance":
@@ -2045,13 +2272,13 @@ var contract_registry_default = {
2045
2272
  protocol: "soroswap",
2046
2273
  kind: "aggregator",
2047
2274
  address: "CARVQXFP4JF5ELLXUMQ6DALR346YVGBMQOHB4ENA7SSVXAYABXLBDDC4",
2048
- wasmHash: "437653282e9c93b0b4d736d8fde01bf002adefb61bfb75917e609f5336ee3190",
2275
+ wasmHash: "72138d720c2d89831906a5f6e88dcf832abda02125fa32e9f0ebf1714041901f",
2049
2276
  version: "v2",
2050
2277
  label: "Soroswap aggregator v2 (mainnet, deployed 2026-09-14) - the contract a multi-protocol token conversion invokes; swap_exact_in only, partner None",
2051
2278
  verifiedLive: true,
2052
- 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; 2026-10-10 (#581) and 2026-11-17 (#1008): live executable hash re-read over public RPC and matched wasmHash",
2279
+ verifiedBy: "2026-09-29: readLiveWasmHash over RPC; its config() names the registry's Soroswap and Aquarius routers; 2026-10-10 (#581) and 2026-11-17 (#1008): live hash re-read and matched; 2026-11-23 (#1112): re-pinned after the admin-signed upgrade tx a63e8e58a88623b4a22a0a4cab19c1514ebcc0d28702f04e384bc615e634ad33 (ledger 65628395), which the Soroswap SDK calls aggregator v3; no public source or SEP-55 metadata, so trusted by spec diff, on-chain swap_exact_in auth and a read-only simulation",
2053
2280
  source: "the Soroswap API's own swap builds and the Soroswap team's confirmation; not yet in soroswap/aggregator public/mainnet.contracts.json",
2054
- verifiedAt: "2026-11-17"
2281
+ verifiedAt: "2026-11-23"
2055
2282
  },
2056
2283
  {
2057
2284
  network: "mainnet",
@@ -2702,6 +2929,9 @@ function verifyCloseTransaction2(input) {
2702
2929
  function exitExpectations2(accountState, network) {
2703
2930
  return exitExpectations(accountState, network);
2704
2931
  }
2932
+ function poolWithdrawalExpectations2(accountState) {
2933
+ return poolWithdrawalExpectations(accountState);
2934
+ }
2705
2935
  function requiresMediator(address, network) {
2706
2936
  return mediatorAllowedFor(address, network);
2707
2937
  }
@@ -2712,6 +2942,7 @@ function verifyRevokeAllowanceTransaction2(unsignedXdr, networkPassphrase, expec
2712
2942
  exports.RevokeAllowanceVerificationError = RevokeAllowanceVerificationError;
2713
2943
  exports.VerificationError = VerificationError;
2714
2944
  exports.exitExpectations = exitExpectations2;
2945
+ exports.poolWithdrawalExpectations = poolWithdrawalExpectations2;
2715
2946
  exports.requiresMediator = requiresMediator;
2716
2947
  exports.verifyCloseTransaction = verifyCloseTransaction2;
2717
2948
  exports.verifyRevokeAllowanceTransaction = verifyRevokeAllowanceTransaction2;
package/dist/index.d.cts CHANGED
@@ -202,6 +202,22 @@ export declare interface CloseExpectationInput extends ExitExpectations {
202
202
  classicConversions: Record<string, ClassicConversionChoice>;
203
203
  /** The Soroban token conversions the user chose, keyed by token contract. */
204
204
  tokenConversions: Record<string, TokenConversionChoice>;
205
+ /**
206
+ * The classic liquidity pools the account holds shares in, by hex pool id. Build it with
207
+ * {@link poolWithdrawalExpectations} from the account read, never from a plan or a transactions
208
+ * response. A withdrawal must name one of these pools, for exactly its shares, with each minimum
209
+ * at least 98% and at most 101% of what these reserves give; a pool share line may be removed
210
+ * only for one of these pools, named by the asset pair and fee its operation carries. Omitted,
211
+ * every withdrawal and pool share line removal is refused.
212
+ */
213
+ poolWithdrawals?: Record<string, PoolWithdrawalExpectation>;
214
+ /**
215
+ * The entries this account sponsors, as the account read lists them: pass its
216
+ * `sponsoredEntries` as is, never a list from a plan or a transactions response. A sponsorship
217
+ * revoke must name one of these entries, by kind, owner and key, at most once per transaction.
218
+ * Omitted, every sponsorship revoke is refused.
219
+ */
220
+ sponsoredEntries?: SponsoredEntry[];
205
221
  }
206
222
 
207
223
  declare interface DataEntry {
@@ -385,6 +401,22 @@ declare interface FxdaoCdpPosition extends DefiPositionBase {
385
401
  debtToken?: string;
386
402
  }
387
403
 
404
+ /** A classic constant-product pool as the ledger holds it. Amounts in stroops, as integers. */
405
+ declare interface LiquidityPoolState {
406
+ /** "native" or "CODE:ISSUER", in the pool's own (lexicographic) order. */
407
+ assetA: string;
408
+ /** The pool's second asset, in the same form. */
409
+ assetB: string;
410
+ /** In basis points; 30 for every classic pool. */
411
+ fee: number;
412
+ /** The pool's reserve of `assetA`. */
413
+ reserveA: string;
414
+ /** The pool's reserve of `assetB`. */
415
+ reserveB: string;
416
+ /** Pool shares outstanding. */
417
+ totalShares: string;
418
+ }
419
+
388
420
  /** The Stellar network a transaction is verified for. Selects the network passphrase the XDR is
389
421
  * decoded with and the bundled registry entries that apply. */
390
422
  export declare type Network = "mainnet" | "testnet";
@@ -429,8 +461,31 @@ declare interface PlanBlocker {
429
461
 
430
462
  declare interface PoolShareEntry {
431
463
  poolId: string;
464
+ /** Pool shares held, in the 7-decimal units Horizon reports. */
465
+ balance: string;
466
+ /** The pool's ledger entry, read over RPC; null when it could not be read. */
467
+ pool: LiquidityPoolState | null;
468
+ }
469
+
470
+ /** A classic liquidity pool the account holds shares in, as the account read showed it. Every
471
+ * amount is in stroops. */
472
+ export declare interface PoolWithdrawalExpectation {
473
+ /** The pool shares the account holds. A withdrawal must name exactly these. */
474
+ shares: string;
475
+ /** The pool's reserve of its first asset. */
476
+ reserveA: string;
477
+ /** The pool's reserve of its second asset. */
478
+ reserveB: string;
479
+ /** The pool shares outstanding. */
480
+ totalShares: string;
432
481
  }
433
482
 
483
+ /**
484
+ * The pool half of a close expectation, from the account read the user reviewed. A pool the read
485
+ * could not see into is left out, so a withdrawal from it is refused.
486
+ */
487
+ export declare function poolWithdrawalExpectations(accountState: AccountState | null | undefined): Record<string, PoolWithdrawalExpectation>;
488
+
434
489
  /**
435
490
  * Whether a close to `address` on `network` goes through the shared intermediary: true only for
436
491
  * an exchange the registry bundled in this package lists, on that network, as unable to receive
@@ -569,15 +624,21 @@ declare interface SoroswapLpPosition extends DefiPositionBase {
569
624
  * A ledger entry this account currently sponsors, on another account (or itself, for
570
625
  * "account" - a fully-sponsored account creation). Mirrors the ledger-key kinds
571
626
  * RevokeSponsorship supports. Claimable balances have no owning-account concept in
572
- * their ledger key (unlike the other five kinds), so they carry only balanceId.
627
+ * their ledger key (unlike every other kind), so they carry only balanceId.
573
628
  */
574
- declare type SponsoredEntry = {
629
+ export declare type SponsoredEntry = {
575
630
  kind: "account";
576
631
  owner: string;
577
632
  } | {
578
633
  kind: "trustline";
579
634
  owner: string;
580
635
  asset: string;
636
+ }
637
+ /** A liquidity pool share trustline, named by its 64-character hex pool id. */
638
+ | {
639
+ kind: "pool_share_trustline";
640
+ owner: string;
641
+ poolId: string;
581
642
  } | {
582
643
  kind: "offer";
583
644
  owner: string;
@@ -623,6 +684,9 @@ declare interface Trustline {
623
684
  asset: string;
624
685
  balance: string;
625
686
  limit?: string;
687
+ /** What the account's open offers are buying of this asset; from the Horizon-compatible
688
+ * reader only. */
689
+ buyingLiabilities?: string;
626
690
  /** True only when `authorization` is `authorized`. */
627
691
  authorized: boolean;
628
692
  authorization: TrustlineAuthorization;
@@ -655,7 +719,7 @@ declare interface UnrecognizedDefiPosition {
655
719
  * that applies to several operation kinds (the fee cap, the operation source) shares one code,
656
720
  * since the kind is visible in the transaction itself.
657
721
  */
658
- declare const VERIFICATION_ERROR_CODES: readonly ["registry_expired", "registry_snapshot_invalid", "registry_memo_type_conflict", "registry_memo_type_unconfirmed", "transaction_source_mismatch", "expiry_missing", "expiry_too_far", "fee_unreadable", "fee_above_cap", "operation_unknown", "operation_source_mismatch", "merge_multiple", "merge_direct_refused", "merge_destination_mismatch", "mediator_handoff_shape", "mediator_forward_source_mismatch", "mediator_forward_destination_mismatch", "mediator_forward_not_native", "mediator_forward_short", "transfer_not_chosen", "transfer_destination_mismatch", "transfer_to_deposit_address", "transfer_duplicate", "transfer_amount_short", "token_transfer_function_invalid", "token_transfer_from_mismatch", "token_transfer_foreign_contract", "conversion_recipient_mismatch", "conversion_not_to_xlm", "conversion_min_out_missing", "conversion_asset_not_chosen", "conversion_duplicate", "conversion_min_out_below_floor", "conversion_amount_short", "swap_quote_missing", "swap_args_unreadable", "swap_referral_recipient", "swap_route_asset_unknown", "swap_auth_unexpected_call", "swap_auth_exceeds_amount", "trustline_not_removal", "data_entry_not_removal", "offer_not_cancellation", "signer_added", "signer_unknown", "master_weight_changed", "thresholds_raised", "account_settings_changed", "invocation_not_alone", "invocation_auth_beyond_self", "invocation_address_unsupported", "invocation_foreign_account", "exit_contract_not_position", "exit_expectation_inconsistent", "exit_function_not_allowed", "exit_foreign_contract", "exit_argument_party_mismatch", "exit_arguments_unexpected", "exit_request_not_allowed", "exit_unverified_spend", "exit_spend_not_repay", "exit_liquidity_auth_invalid", "exit_auth_foreign_contract", "exit_token_function_not_allowed", "exit_token_argument_count", "exit_token_recipient_mismatch", "memo_unexpected", "memo_type_unreadable", "memo_missing", "memo_value_mismatch", "memo_type_mismatch", "memo_required", "memo_invalid_text"];
722
+ declare const VERIFICATION_ERROR_CODES: readonly ["registry_expired", "registry_snapshot_invalid", "registry_memo_type_conflict", "registry_memo_type_unconfirmed", "transaction_source_mismatch", "expiry_missing", "expiry_too_far", "fee_unreadable", "fee_above_cap", "operation_unknown", "operation_source_mismatch", "merge_multiple", "merge_direct_refused", "merge_destination_mismatch", "mediator_handoff_shape", "mediator_forward_source_mismatch", "mediator_forward_destination_mismatch", "mediator_forward_not_native", "mediator_forward_balance_unknown", "mediator_forward_short", "transfer_not_chosen", "transfer_destination_mismatch", "transfer_to_deposit_address", "transfer_duplicate", "transfer_amount_short", "token_transfer_function_invalid", "token_transfer_from_mismatch", "token_transfer_foreign_contract", "conversion_recipient_mismatch", "conversion_not_to_xlm", "conversion_min_out_missing", "conversion_asset_not_chosen", "conversion_duplicate", "conversion_min_out_below_floor", "conversion_amount_short", "swap_quote_missing", "swap_args_unreadable", "swap_referral_recipient", "swap_route_asset_unknown", "swap_auth_unexpected_call", "swap_auth_exceeds_amount", "pool_not_held", "pool_withdraw_duplicate", "pool_withdraw_amount_mismatch", "pool_withdraw_min_missing", "pool_withdraw_min_below_floor", "pool_withdraw_min_above_reserves", "pool_line_mismatch", "sponsorship_revoke_unknown", "sponsorship_revoke_duplicate", "trustline_not_removal", "data_entry_not_removal", "offer_not_cancellation", "signer_added", "signer_unknown", "master_weight_changed", "thresholds_raised", "account_settings_changed", "invocation_not_alone", "invocation_auth_beyond_self", "invocation_address_unsupported", "invocation_foreign_account", "exit_contract_not_position", "exit_expectation_inconsistent", "exit_function_not_allowed", "exit_foreign_contract", "exit_argument_party_mismatch", "exit_arguments_unexpected", "exit_request_not_allowed", "exit_unverified_spend", "exit_spend_not_repay", "exit_liquidity_auth_invalid", "exit_auth_foreign_contract", "exit_token_function_not_allowed", "exit_token_argument_count", "exit_token_recipient_mismatch", "memo_unexpected", "memo_type_unreadable", "memo_missing", "memo_value_mismatch", "memo_type_mismatch", "memo_required", "memo_invalid_text"];
659
723
 
660
724
  /** Thrown when a server-built close transaction fails verification. Never sign past this. */
661
725
  export declare class VerificationError extends Error {