@lumenwipe/verify 0.0.0-stage → 0.1.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.
@@ -0,0 +1,651 @@
1
+ /**
2
+ * `@lumenwipe/verify`: the verifier the LumenWipe web app runs before every signature, compiled
3
+ * from the web's own modules rather than copied. There is one implementation; this file only
4
+ * gives it explicit, documented types. `tests/types.test.ts` pins every type below to the web
5
+ * signature in both directions, so a change on either side fails the build.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+
10
+ export declare interface AccountSigner {
11
+ key: string;
12
+ weight: number;
13
+ type: "ed25519_public_key" | "hash_x" | "preauth_tx" | "ed25519_signed_payload";
14
+ }
15
+
16
+ export declare interface AccountState {
17
+ address: string;
18
+ network: Network_2;
19
+ sequence: string;
20
+ nativeBalanceLumens: string;
21
+ dataEntries: DataEntry[];
22
+ signers: AccountSigner[];
23
+ thresholds: AccountThresholds;
24
+ numSubEntries: number;
25
+ numSponsoring: number;
26
+ /** Reserves another account pays for this one: its own base reserve when its creation was
27
+ * sponsored, and each sponsored subentry. Lowers the minimum balance. Absent when the read
28
+ * did not report it, which is treated as none. */
29
+ numSponsored?: number;
30
+ /** Ledger entries this account currently sponsors (on other accounts, or itself via a
31
+ * fully-sponsored account creation). Populated by replaying sponsorship-relevant
32
+ * operations and re-verifying each candidate's live sponsor - see sponsorship.ts. */
33
+ sponsoredEntries: SponsoredEntry[];
34
+ /** True when sponsoredEntries could not be enumerated completely (pagination cut off,
35
+ * a live re-verification fetch failed, or the enumerated count doesn't match
36
+ * numSponsoring). Mirrors subEntryMismatch: an incomplete read must never be treated
37
+ * as "sponsors nothing" downstream. */
38
+ sponsorshipEnumerationIncomplete: boolean;
39
+ /** Account whose reserve covers this account's base reserve, or null. Populated by the
40
+ * Horizon-based scan path only; the RPC getLedgerEntries response strips the outer
41
+ * LedgerEntry extension where sponsoringID lives, so it remains null on that path. */
42
+ sponsoredBy: string | null;
43
+ /** AUTH_IMMUTABLE flag is set - ACCOUNT_MERGE is permanently blocked. */
44
+ authImmutable: boolean;
45
+ trustlines: Trustline[];
46
+ openOffers: OpenOffer[];
47
+ poolShares: PoolShareEntry[];
48
+ /** Claimable balances where this account is listed as a claimant. Does not affect
49
+ * numSubEntries on this account; populated via the Horizon adapter. */
50
+ claimableBalances: ClaimableBalance[];
51
+ /** True when the account holds more claimable balances than one read returns, so
52
+ * `claimableBalances` is a bounded part of them. Set only by the account reader. While it is
53
+ * set the merge is never built: the rest would be stranded. */
54
+ claimableBalancesMore?: boolean;
55
+ subEntryMismatch: boolean;
56
+ /** Close time of the latest ledger (epoch seconds) when the claim predicates were judged.
57
+ * Absent means it could not be read, and only unconditional claims count as claimable. */
58
+ ledgerCloseTime?: number;
59
+ /** The latest ledger the enumeration's reads reflect, for debugging. Absent when the provider
60
+ * reports none. */
61
+ snapshotLedger?: number;
62
+ /** Detected DeFi positions (Blend, Aquarius, Soroswap, Phoenix, FxDAO), resolved via OctoPos on
63
+ * mainnet or a direct contract read on testnet / mainnet degraded mode - architecture.md §7.1.
64
+ * Never absent: an unconfigured deployment or provider outage still returns a result, stamped
65
+ * with a null `timestamp` and reflected in `defiPositionsWarnings` rather than being omitted. */
66
+ defiPositions: DefiPositionsResult;
67
+ /** Plain-language notices from `assessDefiPositionsGate` (issue #147) - stale/unconfirmed data
68
+ * or an unrecognized position - reusing the exact same typed-blocker signal close/plan already
69
+ * gates on, so the analysis view and the plan never disagree about what's trustworthy. Empty
70
+ * when nothing needs flagging. */
71
+ defiPositionsWarnings: PlanBlocker[];
72
+ /** Soroban token balances held directly, best effort (see `SorobanTokensResult`). Absent on
73
+ * account reads produced before this field existed; a consumer treats absence as "nothing
74
+ * known", never as "nothing held". */
75
+ sorobanTokens?: SorobanTokensResult;
76
+ }
77
+
78
+ export declare interface AccountThresholds {
79
+ low: number;
80
+ med: number;
81
+ high: number;
82
+ }
83
+
84
+ declare interface AquariusLpPosition extends DefiPositionBase {
85
+ protocol: "aquarius";
86
+ positionType: "lp";
87
+ shareAmount: string;
88
+ /** Reported by OctoPos alongside the LP position rather than as its own position. */
89
+ claimableAquaAmount?: string;
90
+ /** The pool's tokens in the pool's own order - the order `withdraw` pays them out and
91
+ * `min_amounts` is given in. Read from the pool when detection can. */
92
+ tokens?: string[];
93
+ /** The pool's LP share token: a separate contract in Aquarius, where the account's shares live. */
94
+ shareToken?: string;
95
+ /** Which pool code the pool runs, from the registry. */
96
+ poolType?: AquariusPoolType;
97
+ }
98
+
99
+ /** Aquarius deploys three pool codes; only the share-based ones can be exited by shares. */
100
+ declare type AquariusPoolType = "constant_product" | "stable" | "concentrated";
101
+
102
+ declare interface BlendBorrowPosition extends DefiPositionBase {
103
+ protocol: "blend";
104
+ positionType: "borrow";
105
+ assetAddress: string;
106
+ dTokenAmount: string;
107
+ healthFactor?: string;
108
+ }
109
+
110
+ declare interface BlendSupplyPosition extends DefiPositionBase {
111
+ protocol: "blend";
112
+ positionType: "supply";
113
+ assetAddress: string;
114
+ bTokenAmount: string;
115
+ /** True when this supply is also posted as backstop collateral. */
116
+ isBackstop?: boolean;
117
+ }
118
+
119
+ declare interface ClaimableBalance {
120
+ /** Full 72-char hex balance ID as returned by Horizon ("00000000" + 64-char hash). */
121
+ id: string;
122
+ /** "CODE:ISSUER" or "native" */
123
+ asset: string;
124
+ amount: string;
125
+ /** One entry per claimant on the balance, each with its own predicate. */
126
+ claimants: {
127
+ destination: string;
128
+ predicate: ClaimPredicate;
129
+ }[];
130
+ /** Account sponsoring this balance's reserve, or null if unsponsored. */
131
+ sponsor: string | null;
132
+ }
133
+
134
+ declare type ClaimPredicate = {
135
+ type: "unconditional";
136
+ } | {
137
+ type: "and";
138
+ predicates: ClaimPredicate[];
139
+ } | {
140
+ type: "or";
141
+ predicates: ClaimPredicate[];
142
+ } | {
143
+ type: "not";
144
+ predicate: ClaimPredicate;
145
+ } | {
146
+ type: "before_absolute_time";
147
+ absBeforeEpoch: string;
148
+ } | {
149
+ type: "before_relative_time";
150
+ relBeforeSeconds: string;
151
+ deadlineEpoch: string;
152
+ };
153
+
154
+ /** A classic conversion the user chose. */
155
+ export declare interface ClassicConversionChoice {
156
+ /** The least XLM, in stroops, the plan showed it delivering, or null for an asset only a DeFi
157
+ * exit pays in (no amount to quote; only the choice and a positive minimum are held). */
158
+ minAmountOut: string | null;
159
+ }
160
+
161
+ /**
162
+ * What the integrator independently knows a close transaction should do. Three sources, never
163
+ * the transaction under verification:
164
+ *
165
+ * - the user's own inputs: `destination`, `memo`, `memoType` and every per-asset choice;
166
+ * - the account read the user reviewed (`client.getAccount` or the plan's `sourceAccount`):
167
+ * `source`, `nativeBalance`, `accountSigners`, `accountThresholds`, and the exit half;
168
+ * - this package's bundled registries, through {@link exitExpectations}.
169
+ *
170
+ * The memo policy for a listed exchange (whether a memo is required, its type, whether the merge
171
+ * must go through the shared intermediary) is not an input: the verifier derives it from the
172
+ * exchange registry bundled in this package, tightened by a served snapshot when one is passed
173
+ * ({@link VerifyCloseInput.servedRegistry}).
174
+ */
175
+ export declare interface CloseExpectationInput extends ExitExpectations {
176
+ /** The account being closed. */
177
+ source: string;
178
+ /** The final destination the user typed. */
179
+ destination: string;
180
+ /** The account's native balance in XLM as last read (`"100.0000000"`). The floor under the
181
+ * intermediary's forward on an exchange close. `"0"` when unknown fails closed. */
182
+ nativeBalance: string;
183
+ /** The memo the user confirmed, or null. */
184
+ memo: string | null;
185
+ /** The type the user confirmed for `memo`, or null with no memo. A listed exchange's registry
186
+ * type replaces it. */
187
+ memoType: "text" | "id" | "hash" | null;
188
+ /** Canonical `CODE:ISSUER` of each trustline a claimable balance claim may add and remove. */
189
+ claimTrustlineAssets: string[];
190
+ /** The account's signers from the read. A transaction may never add one. Empty fails closed. */
191
+ accountSigners: AccountSigner[];
192
+ /** The account's thresholds from the read. A transaction may never raise one. */
193
+ accountThresholds: AccountThresholds;
194
+ /** The per-asset transfers the user chose, keyed by canonical `CODE:ISSUER`. Required: pass
195
+ * `{}` to allow none. */
196
+ transfers: Record<string, TransferChoice>;
197
+ /** The Soroban token transfers the user chose, keyed by token contract, amounts in base units. */
198
+ tokenTransfers: Record<string, TransferChoice>;
199
+ /** The classic conversions the user chose, keyed by `CODE:ISSUER`. Only these may be sold. */
200
+ classicConversions: Record<string, ClassicConversionChoice>;
201
+ /** The Soroban token conversions the user chose, keyed by token contract. */
202
+ tokenConversions: Record<string, TokenConversionChoice>;
203
+ }
204
+
205
+ declare interface DataEntry {
206
+ key: string;
207
+ value: string;
208
+ }
209
+
210
+ /** Keyed by asset/contract address. Built from OctoPos's queryKeys.tokenInfos. */
211
+ declare interface DefiEnrichmentEntry {
212
+ symbol: string;
213
+ decimals: number;
214
+ usdPrice: string | null;
215
+ priceSource: string | null;
216
+ }
217
+
218
+ declare type DefiPosition = BlendSupplyPosition | BlendBorrowPosition | AquariusLpPosition | SoroswapLpPosition | PhoenixLpPosition | PhoenixStakePosition | FxdaoCdpPosition;
219
+
220
+ declare interface DefiPositionBase {
221
+ protocol: DefiProtocol;
222
+ /** Pool, market, or vault contract this position lives in. */
223
+ contractAddress: string;
224
+ /** Human-readable view of the position, when the analysis could resolve one. */
225
+ display?: DefiPositionDisplay;
226
+ /** Left as an optional hook: the wasmHash -\> protocol-version contract registry
227
+ * architecture.md describes does not exist in code yet (a later contribution). */
228
+ wasmHash?: string;
229
+ usdValue: string | null;
230
+ }
231
+
232
+ /**
233
+ * What a person should read about a position, in the protocol's own terms, resolved by the API
234
+ * from a live read at analysis time (issue #197). Presentation only: every field is nullable, a
235
+ * failed read leaves the whole object absent, and nothing here feeds the plan, the gate, or an
236
+ * exit - those re-read the ledger themselves.
237
+ */
238
+ declare interface DefiPositionDisplay {
239
+ /** The pool, pair, or vault by name (the protocol's own metadata or the registry label). */
240
+ pool: string | null;
241
+ /** Symbol of the position's asset; for an LP position the pair, e.g. "XLM/USDC". */
242
+ asset: string | null;
243
+ /** Underlying amount in the asset's own units as a decimal string - not shares or bTokens. */
244
+ amount: string | null;
245
+ /** The part of `amount` posted as collateral (lending protocols), decimal string; null when
246
+ * the protocol has no such distinction. */
247
+ collateralAmount: string | null;
248
+ /** Current yield as a percentage with two decimals ("3.99"): earned on a supply, paid on debt. */
249
+ yieldPct: string | null;
250
+ yieldKind: "earned" | "paid" | null;
251
+ /** One protocol-specific clause the line ends with, e.g. what an LP share is worth in its two
252
+ * tokens ("9.95 XLM + 19.90 USDC"). Null when there is nothing to add. */
253
+ detail?: string | null;
254
+ }
255
+
256
+ /**
257
+ * The normalized DeFi position model every downstream consumer (exit adapters, plan preview)
258
+ * depends on - no OctoPos-specific field names beyond this boundary (architecture.md §7.1).
259
+ */
260
+ declare interface DefiPositionsResult {
261
+ address: string;
262
+ network: Network_2;
263
+ positions: DefiPosition[];
264
+ unrecognizedPositions: UnrecognizedDefiPosition[];
265
+ enrichment: Record<string, DefiEnrichmentEntry>;
266
+ /** OctoPos's own freshness/provenance signal ("snapshot" | "empty" | "cache" | "not-tracked").
267
+ * Passed through verbatim rather than architecture.md's described (but not actually shipped)
268
+ * partial_result/attribution_confidence fields - see issue #147 for the gating that consumes
269
+ * this. */
270
+ source: string;
271
+ timestamp: string | null;
272
+ queryKeys: DefiQueryKeys;
273
+ }
274
+
275
+ /**
276
+ * Protocols LumenWipe knows how to act on: most are DeFi positions it knows how to exit
277
+ * (architecture.md §9's table); `xbull` is the one exception, a swap router with no position to
278
+ * exit, registered here only so it can share the contract registry's protocol-keyed lookups.
279
+ * OctoPos itself indexes more than this (e.g. "untangled-vault", "stellar-wallet") - those are
280
+ * dropped by the adapter rather than represented here, since the type system should not claim
281
+ * LumenWipe can act on a protocol it has no exit path for.
282
+ */
283
+ declare type DefiProtocol = "blend" | "aquarius" | "soroswap" | "phoenix" | "fxdao" | "xbull";
284
+
285
+ declare interface DefiQueryKeys {
286
+ rpcEndpoints: DefiRpcEndpoint[];
287
+ rpcPolicy: DefiRpcPolicy;
288
+ slices: Partial<Record<DefiProtocol, DefiQueryKeysSlice>>;
289
+ }
290
+
291
+ /**
292
+ * Ready-made ledger keys plus pool/vault metadata for one protocol, letting a caller read
293
+ * positions directly over RPC without OctoPos storing anything server-side (architecture.md
294
+ * §7.1). Passed through typed rather than discarded, since issue #148's RPC fallback needs
295
+ * exactly this and would otherwise have to refetch it.
296
+ */
297
+ declare interface DefiQueryKeysSlice {
298
+ protocol: string;
299
+ ledgerKeys: string[];
300
+ poolAddresses: string[];
301
+ }
302
+
303
+ /** A public Soroban RPC endpoint OctoPos suggests for a direct getLedgerEntries read. */
304
+ declare interface DefiRpcEndpoint {
305
+ url: string;
306
+ health: string;
307
+ avgLatencyMs: number;
308
+ }
309
+
310
+ declare interface DefiRpcPolicy {
311
+ maxKeysPerCall: number;
312
+ recommendedConcurrency: number;
313
+ backoffOn429Ms: number[];
314
+ timeoutMs: number;
315
+ }
316
+
317
+ /** One exchange in the registry: whether a close into it needs the mediator, and its memo rule. */
318
+ export declare interface ExchangeRegistryEntry {
319
+ address: string;
320
+ name: string;
321
+ domain: string;
322
+ requiresMediator: boolean;
323
+ requiresMemo: boolean;
324
+ /** The required memo type, if `requiresMemo` is true. */
325
+ memoType: "text" | "id" | "hash";
326
+ }
327
+
328
+ /**
329
+ * The DeFi half of the expectation. Build it with {@link exitExpectations} from the account read
330
+ * the user reviewed, never by hand from a plan: it combines that read with the registries bundled
331
+ * in this package. Empty lists fail closed (every exit is refused).
332
+ */
333
+ export declare interface ExitExpectations {
334
+ /** Pools, pairs or vaults the account holds a position in, plus the bundled registry's routers,
335
+ * backstops and stakes for those protocols. An exit may invoke only one of these. */
336
+ exitContracts: string[];
337
+ /** The Stellar Asset Contract of every asset the account holds (XLM and each trustline) and
338
+ * the Soroban tokens the read confirmed with a positive balance. */
339
+ heldTokenContracts: string[];
340
+ /** Each position's tokens, share token and debt token: what a withdrawal pays out or spends. */
341
+ positionTokenContracts: string[];
342
+ /** Per exit contract, the functions that leave that protocol. */
343
+ exitFunctions: Record<string, string[]>;
344
+ /** The bundled registry's Soroswap aggregator and router and xBull's router: the only contracts
345
+ * a token conversion may be entered through. */
346
+ conversionContracts: string[];
347
+ /** XLM's contract on this network: the one asset a token conversion may buy. */
348
+ xlmContract: string;
349
+ /** Every contract the bundled contract registry names on this network. */
350
+ registryContracts: string[];
351
+ /** XLM's contract and the contract of every classic asset the account holds. Only a registry
352
+ * contract may receive or spend these in an exit. */
353
+ protectedTokenContracts: string[];
354
+ /** xBull's router asset table, index to token contract; empty off mainnet. */
355
+ xbullAssets: Record<string, string>;
356
+ /** Per position contract, the tokens the account read names as that position's own. */
357
+ ownTokensByContract: Record<string, string[]>;
358
+ /** Per Blend pool, the tokens of the account's `borrow` positions in that pool. */
359
+ repayTokensByPool: Record<string, string[]>;
360
+ /** Every position's share token (Aquarius, Phoenix). */
361
+ shareTokenContracts: string[];
362
+ /** Every position's debt token (FxDAO). */
363
+ debtTokenContracts: string[];
364
+ }
365
+
366
+ /**
367
+ * The DeFi half of a close expectation, derived from the account read the user reviewed and the
368
+ * contract registry bundled in this package. With no read, every list is empty and every exit is
369
+ * refused.
370
+ */
371
+ export declare function exitExpectations(accountState: AccountState | null | undefined, network: Network): ExitExpectations;
372
+
373
+ declare interface FxdaoCdpPosition extends DefiPositionBase {
374
+ protocol: "fxdao";
375
+ positionType: "cdp";
376
+ denomination: string;
377
+ collateralAmount: string;
378
+ debtAmount: string;
379
+ /** The denomination's registered stablecoin (`Currency(denomination).contract`), the token a
380
+ * repay burns. Read from the vault. */
381
+ debtToken?: string;
382
+ }
383
+
384
+ /** The Stellar network a transaction is verified for. Selects the network passphrase the XDR is
385
+ * decoded with and the bundled registry entries that apply. */
386
+ export declare type Network = "mainnet" | "testnet";
387
+
388
+ declare type Network_2 = "mainnet" | "testnet";
389
+
390
+ declare interface OpenOffer {
391
+ id: string;
392
+ selling: string;
393
+ buying: string;
394
+ amount: string;
395
+ price: string;
396
+ }
397
+
398
+ declare interface PhoenixLpPosition extends DefiPositionBase {
399
+ protocol: "phoenix";
400
+ positionType: "lp";
401
+ shareAmount: string;
402
+ /** The pool's LP share token (`CONFIG.share_token`): a separate contract in Phoenix, where the
403
+ * account's shares live and what a withdrawal transfers back to the pool. Read from the pool. */
404
+ shareToken?: string;
405
+ }
406
+
407
+ declare interface PhoenixStakePosition extends DefiPositionBase {
408
+ protocol: "phoenix";
409
+ positionType: "stake";
410
+ stakedAmount: string;
411
+ /** Unix seconds; unbonding requires the original stake's timestamp (architecture.md §9.6). */
412
+ stakedAtEpoch: string;
413
+ }
414
+
415
+ declare interface PlanBlocker {
416
+ message: string;
417
+ helpUrl?: string;
418
+ /** Distinguishes an acknowledged, non-trapping warning (e.g. a chosen forfeit) from a hard
419
+ * blocker. Absent means the generic hard-blocking case. */
420
+ code?: string;
421
+ }
422
+
423
+ declare interface PoolShareEntry {
424
+ poolId: string;
425
+ }
426
+
427
+ /**
428
+ * Whether a close to `address` goes through the shared intermediary: true only for an exchange
429
+ * the registry bundled in this package lists as unable to receive an account merge. The same
430
+ * rule `verifyCloseTransaction` applies, so an integrator decides from it, never from the API's
431
+ * response, whether a transaction needs the intermediary's co-signature. A served snapshot never
432
+ * changes this answer, so it takes none.
433
+ */
434
+ export declare function requiresMediator(address: string): boolean;
435
+
436
+ /**
437
+ * A served exchange registry: the body of `GET /v1/config/exchange-registry` (the SDK's
438
+ * `client.getExchangeRegistry()`), passed as is. Only these three fields are read.
439
+ *
440
+ * It is not authenticated, and it does not need to be for what it can do: it is merged over the
441
+ * registry bundled in this package and can only make verification stricter.
442
+ *
443
+ * - A bundled exchange is never removed, and its memo requirement and its refusal of a direct
444
+ * merge are never turned off.
445
+ * - An address it adds is checked as an exchange: a direct merge into it is refused when it
446
+ * needs the intermediary, a memo is required when it needs one, and a transfer to it is refused.
447
+ * - It never enables the mediated hand-off. That stays limited to the exchanges the bundled
448
+ * registry lists ({@link requiresMediator}), so an address only the snapshot lists as needing
449
+ * the intermediary refuses both shapes until this package is updated.
450
+ * - Its `validUntil` may move the bundled expiry later, by at most 120 days, never earlier.
451
+ *
452
+ * Two fields are taken from it rather than tightened: an entry's `memoType` (exchanges do change
453
+ * text to id) and `name` (only used in refusal messages). A wrong memo type can make a deposit
454
+ * uncreditable, but it cannot change where funds go.
455
+ */
456
+ export declare interface ServedRegistry {
457
+ /** The listed exchanges. An entry that is not well formed is dropped. */
458
+ entries: ExchangeRegistryEntry[];
459
+ /** When the entries were last checked (YYYY-MM-DD). Not used to decide anything. */
460
+ lastVerified: string;
461
+ /** The date (YYYY-MM-DD) after which the registry is not relied on. */
462
+ validUntil: string;
463
+ }
464
+
465
+ /** A SEP-41 token balance the account holds in a contract's storage - not a classic trustline. */
466
+ declare interface SorobanTokenBalance {
467
+ /** The token contract, `C...`. */
468
+ contract: string;
469
+ /** Base units, integer string, as `balance(account)` reports it on the ledger. "0" only for a
470
+ * token the account does not hold yet but a detected position's exit will pay out. */
471
+ balance: string;
472
+ /** From the contract's own `symbol()` / `decimals()`, null when it does not answer them. */
473
+ symbol: string | null;
474
+ decimals: number | null;
475
+ /** Every source that proposed this contract; the balance itself always comes from the ledger. */
476
+ sources: SorobanTokenSource[];
477
+ }
478
+
479
+ /** How one candidate source fared, so the interface can say exactly what was consulted. */
480
+ declare interface SorobanTokenCoverage {
481
+ source: SorobanTokenSource;
482
+ status: "ok" | "failed" | "skipped";
483
+ detail?: string;
484
+ }
485
+
486
+ /** Where a Soroban token candidate came from before its balance was confirmed on the ledger. */
487
+ declare type SorobanTokenSource = "explorer" | "positions" | "list" | "events" | "manual";
488
+
489
+ /**
490
+ * Soroban token balances the account holds directly. Soroban has no per-account token index, so
491
+ * this is a best-effort union of candidate sources - an explorer, the tokens named by detected
492
+ * positions, bundled lists, recent on-chain `transfer`/`mint` events, and contracts the user added
493
+ * by hand - each confirmed by reading `balance(account)` on the ledger. What could not be read is
494
+ * listed, never dropped; classic assets' contracts are excluded (their balance is the trustline).
495
+ */
496
+ declare interface SorobanTokensResult {
497
+ tokens: SorobanTokenBalance[];
498
+ /** Candidate contracts whose balance could not be read (a hostile, broken, or archived token). */
499
+ unreadable: string[];
500
+ coverage: SorobanTokenCoverage[];
501
+ /** The ledger range the event scan covered, or null when it ran out of budget before starting. */
502
+ eventsScanned: {
503
+ fromLedger: number;
504
+ toLedger: number;
505
+ } | null;
506
+ /** Plain-language warnings for the plan: a source that failed, contracts that could not be read. */
507
+ warnings: PlanBlocker[];
508
+ }
509
+
510
+ declare interface SoroswapLpPosition extends DefiPositionBase {
511
+ protocol: "soroswap";
512
+ positionType: "lp";
513
+ shareAmount: string;
514
+ /** The pair's two token contracts (token_0, token_1), read from the pair when detection can;
515
+ * what a withdrawal receives and the exit's arguments name. */
516
+ tokens?: [string, string];
517
+ }
518
+
519
+ /**
520
+ * A ledger entry this account currently sponsors, on another account (or itself, for
521
+ * "account" - a fully-sponsored account creation). Mirrors the ledger-key kinds
522
+ * RevokeSponsorship supports. Claimable balances have no owning-account concept in
523
+ * their ledger key (unlike the other five kinds), so they carry only balanceId.
524
+ */
525
+ declare type SponsoredEntry = {
526
+ kind: "account";
527
+ owner: string;
528
+ } | {
529
+ kind: "trustline";
530
+ owner: string;
531
+ asset: string;
532
+ } | {
533
+ kind: "offer";
534
+ owner: string;
535
+ offerId: string;
536
+ } | {
537
+ kind: "data_entry";
538
+ owner: string;
539
+ name: string;
540
+ } | {
541
+ kind: "signer";
542
+ owner: string;
543
+ signerKey: string;
544
+ } | {
545
+ kind: "claimable_balance";
546
+ balanceId: string;
547
+ };
548
+
549
+ /** A Soroban token conversion the user chose, with the quote they accepted. */
550
+ export declare interface TokenConversionChoice {
551
+ /** The least XLM, in stroops, the plan quoted and the user accepted. The built swap's own
552
+ * minimum must be at least this. */
553
+ minAmountOut: string;
554
+ /** The quoted XLM out, in stroops, when the plan reported one. */
555
+ amountOut?: string;
556
+ /** The token balance sold, in base units. */
557
+ amountIn: string;
558
+ /** An xBull route as the API resolved it at plan time. Not relied on: the verifier reads xBull
559
+ * routes through the bundled asset table. */
560
+ resolvedPath?: string[];
561
+ }
562
+
563
+ /** A per-asset transfer the user chose: the account the balance goes to and the floor it is
564
+ * held to. */
565
+ export declare interface TransferChoice {
566
+ /** The account the user typed for this asset. */
567
+ destination: string;
568
+ /** The balance the account read showed, in the asset's display units for a classic asset
569
+ * (`"12.5000000"`) or base units for a Soroban token. A floor, not an exact figure. */
570
+ amount: string;
571
+ }
572
+
573
+ declare interface Trustline {
574
+ asset: string;
575
+ balance: string;
576
+ limit?: string;
577
+ /** True only when `authorization` is `authorized`. */
578
+ authorized: boolean;
579
+ authorization: TrustlineAuthorization;
580
+ /** The issuer can reclaim this balance at any time. */
581
+ clawbackEnabled: boolean;
582
+ issuer: string;
583
+ code: string;
584
+ }
585
+
586
+ /** The issuer's authorization of a trustline. Only `authorized` can send or receive payments;
587
+ * `maintain_liabilities` keeps existing offers alive and nothing else. */
588
+ declare type TrustlineAuthorization = "authorized" | "maintain_liabilities" | "unauthorized";
589
+
590
+ /**
591
+ * A position tagged with a supported protocol whose shape the adapter could not validate. Kept
592
+ * distinct from "no position" so a caller (issue #147's gating) can surface it rather than treat
593
+ * a parse failure as an account with nothing to unwind - the "no silent skips" invariant applied
594
+ * to a provider field OctoPos does not formally type.
595
+ */
596
+ declare interface UnrecognizedDefiPosition {
597
+ protocol: DefiProtocol;
598
+ /** OctoPos's raw type tag (e.g. "SUPPLY"), kept for diagnostics even though it didn't parse. */
599
+ rawType: string;
600
+ reason: string;
601
+ }
602
+
603
+ /**
604
+ * Every reason the verifier refuses a transaction, one stable code each. The code is the contract
605
+ * an integrator branches on; the message is the current English wording and may change. A check
606
+ * that applies to several operation kinds (the fee cap, the operation source) shares one code,
607
+ * since the kind is visible in the transaction itself.
608
+ */
609
+ declare const VERIFICATION_ERROR_CODES: readonly ["registry_expired", "registry_snapshot_invalid", "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_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"];
610
+
611
+ /** Thrown when a server-built close transaction fails verification. Never sign past this. */
612
+ export declare class VerificationError extends Error {
613
+ /** Why the transaction was refused. Stable across releases, unlike the message. */
614
+ readonly code: VerificationErrorCode;
615
+ constructor(code: VerificationErrorCode, message: string);
616
+ }
617
+
618
+ /** The reason a {@link VerificationError} was thrown. */
619
+ export declare type VerificationErrorCode = (typeof VERIFICATION_ERROR_CODES)[number];
620
+
621
+ /** The input to {@link verifyCloseTransaction}. */
622
+ export declare interface VerifyCloseInput {
623
+ /** The unsigned transaction envelope as returned by the API (`CloseTransaction.xdr`), base64. */
624
+ unsignedXdr: string;
625
+ /** The network the close runs on. */
626
+ network: Network;
627
+ /** True only for a pre-authorized transaction the account's own signers set up earlier. */
628
+ preAuthorized?: boolean;
629
+ /** What the transaction must do, from the user's inputs and the reviewed account read. */
630
+ expected: CloseExpectationInput;
631
+ /** A served exchange registry to apply over the bundled one, stricter-only. Omit it to use the
632
+ * bundled registry alone. A value that is not a registry (no `entries` list, no
633
+ * `lastVerified` or `validUntil` string) is refused with `registry_snapshot_invalid` rather
634
+ * than ignored. */
635
+ servedRegistry?: ServedRegistry;
636
+ }
637
+
638
+ /**
639
+ * Decodes an API-built, unsigned close transaction and asserts it does exactly what `expected`
640
+ * says, using the exchange and contract registries bundled in this package. Returns only when the
641
+ * transaction may be signed; throws {@link VerificationError} on any mismatch.
642
+ *
643
+ * Synchronous and offline: it reads no network and no page state, and keeps no state between
644
+ * calls. It reads the system clock twice: for the transaction's expiry (at most 900 seconds
645
+ * ahead) and for the exchange registry's `validUntil`, past which an exchange close is refused
646
+ * until this package is updated or a served snapshot extends it.
647
+ * Run it once per transaction, immediately before each signature.
648
+ */
649
+ export declare function verifyCloseTransaction(input: VerifyCloseInput): void;
650
+
651
+ export { }