@esseyonsui/sui-sdk-v3 0.1.8 → 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.
Files changed (53) hide show
  1. package/dist/config.d.ts +2 -0
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +8 -1
  4. package/dist/errors.d.ts +1 -1
  5. package/dist/errors.d.ts.map +1 -1
  6. package/dist/errors.js +1 -0
  7. package/dist/essey.d.ts +180 -54
  8. package/dist/essey.d.ts.map +1 -1
  9. package/dist/essey.js +580 -227
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -0
  13. package/dist/network.d.ts +8 -0
  14. package/dist/network.d.ts.map +1 -1
  15. package/dist/network.js +23 -0
  16. package/dist/v3/collateral/health.d.ts +2 -0
  17. package/dist/v3/collateral/health.d.ts.map +1 -1
  18. package/dist/v3/collateral/health.js +6 -0
  19. package/dist/v3/collateral/math.d.ts +6 -0
  20. package/dist/v3/collateral/math.d.ts.map +1 -1
  21. package/dist/v3/collateral/math.js +12 -0
  22. package/dist/v3/credential/membership.d.ts +2 -0
  23. package/dist/v3/credential/membership.d.ts.map +1 -1
  24. package/dist/v3/credential/membership.js +4 -0
  25. package/dist/v3/fees.d.ts +6 -0
  26. package/dist/v3/fees.d.ts.map +1 -1
  27. package/dist/v3/loans/offer-plan.d.ts +1 -1
  28. package/dist/v3/loans/offer-plan.d.ts.map +1 -1
  29. package/dist/v3/loans/offer-plan.js +5 -4
  30. package/dist/v3/loans/open-plan.d.ts +7 -3
  31. package/dist/v3/loans/open-plan.d.ts.map +1 -1
  32. package/dist/v3/loans/open-plan.js +11 -3
  33. package/dist/v3/notes/derive.d.ts +7 -0
  34. package/dist/v3/notes/derive.d.ts.map +1 -1
  35. package/dist/v3/notes/derive.js +10 -0
  36. package/dist/v3/notes/opening.d.ts +26 -2
  37. package/dist/v3/notes/opening.d.ts.map +1 -1
  38. package/dist/v3/notes/opening.js +61 -24
  39. package/dist/v3/notes/scan.d.ts +20 -3
  40. package/dist/v3/notes/scan.d.ts.map +1 -1
  41. package/dist/v3/notes/scan.js +59 -16
  42. package/dist/v3/notes/withdraw.d.ts +2 -0
  43. package/dist/v3/notes/withdraw.d.ts.map +1 -1
  44. package/dist/v3/notes/withdraw.js +9 -0
  45. package/dist/v3/pace.d.ts +1 -1
  46. package/dist/v3/pace.js +1 -1
  47. package/dist/v3/stage1.d.ts +5 -2
  48. package/dist/v3/stage1.d.ts.map +1 -1
  49. package/dist/v3/stage1.js +17 -6
  50. package/dist/v3/time-grid.d.ts +25 -0
  51. package/dist/v3/time-grid.d.ts.map +1 -0
  52. package/dist/v3/time-grid.js +51 -0
  53. package/package.json +1 -1
package/dist/config.d.ts CHANGED
@@ -36,6 +36,8 @@ export type V3Config = {
36
36
  feeConfig: null;
37
37
  /** One FeeConfig per coin, written by setup; absent only while every pool and market is null (BORIS-RULING 0310). */
38
38
  feeConfigs?: Record<CoinKey, string | null>;
39
+ /** PRV-02 O5: the rate-bearing config deposit and withdraw take once the pool names it; `feeConfigs` is then rate 0. */
40
+ edgeFeeConfigs?: Record<CoinKey, string | null>;
39
41
  vkPins: SharedRef | null;
40
42
  keyRegistry: SharedRef | null;
41
43
  marketRegistry: SharedRef | null;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAwD,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAEhG,eAAO,MAAM,KAAK,qCAAsC,CAAC;AACzD,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAG7C,2GAA2G;AAC3G,KAAK,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9D,KAAK,QAAQ,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IA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136,14 @@ function setupSlots(objects, packages) {
136
136
  refuse("objects.feeConfigs");
137
137
  return filled;
138
138
  }
139
- return [...filled, ...idMap(objects.feeConfigs, COINS, packages.config !== null, "objects.feeConfigs")];
139
+ const fees = idMap(objects.feeConfigs, COINS, packages.config !== null, "objects.feeConfigs");
140
+ if (!Object.hasOwn(objects, "edgeFeeConfigs"))
141
+ return [...filled, ...fees];
142
+ return [
143
+ ...filled,
144
+ ...fees,
145
+ ...idMap(objects.edgeFeeConfigs, COINS, packages.pool !== null, "objects.edgeFeeConfigs"),
146
+ ];
140
147
  }
141
148
  /** The optional keeper slot: both refs, and only once the loan package is published. */
142
149
  function keeperSlots(objects, packages) {
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const ESSEY_ERROR_CODES: readonly ["NETWORK_REFUSED", "INVALID_ARGUMENT", "CONFIG_REFUSED", "STATE_REFUSED", "NOT_SET_UP", "SERVICE_UNREACHABLE", "SERVICE_REFUSED", "CREDENTIAL_REFUSED", "POW_EXHAUSTED", "FEE_PARAMS_MISMATCH", "RELAY_REFUSED", "RELAY_FAILED", "RELAY_OUTCOME_UNKNOWN", "DEPOSIT_PARTIAL", "ONION_UNAVAILABLE", "ARTIFACT_MISMATCH", "HEALTH_NOT_UNDERWATER", "HEALTH_NO_BUCKET", "CT_MISMATCH", "KEEPER_NOT_ELIGIBLE"];
1
+ export declare const ESSEY_ERROR_CODES: readonly ["NETWORK_REFUSED", "INVALID_ARGUMENT", "CONFIG_REFUSED", "STATE_REFUSED", "NOT_SET_UP", "SERVICE_UNREACHABLE", "SERVICE_REFUSED", "CREDENTIAL_REFUSED", "POW_EXHAUSTED", "FEE_PARAMS_MISMATCH", "RELAY_REFUSED", "RELAY_FAILED", "RELAY_OUTCOME_UNKNOWN", "DEPOSIT_PARTIAL", "ONION_UNAVAILABLE", "ARTIFACT_MISMATCH", "HEALTH_NOT_UNDERWATER", "HEALTH_NO_BUCKET", "CT_MISMATCH", "KEEPER_NOT_ELIGIBLE", "REQUEST_STALE"];
2
2
  export type EsseyErrorCode = (typeof ESSEY_ERROR_CODES)[number];
3
3
  /**
4
4
  * What a service answered. `submitted: true` means the relayer sent a transaction: it failed on chain, or with
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,qZAqBpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,qBAAa,UAAW,SAAQ,KAAK;IAEjC,QAAQ,CAAC,IAAI,EAAE,cAAc;IAE7B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa;gBAFtB,IAAI,EAAE,cAAc,EAC7B,OAAO,EAAE,MAAM,EACN,MAAM,CAAC,EAAE,aAAa,YAAA;CAKlC;AAED,eAAO,MAAM,YAAY,GAAI,KAAK,OAAO,EAAE,OAAO,cAAc,KAAG,GAAG,IAAI,UACF,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,saAsBpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,qBAAa,UAAW,SAAQ,KAAK;IAEjC,QAAQ,CAAC,IAAI,EAAE,cAAc;IAE7B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa;gBAFtB,IAAI,EAAE,cAAc,EAC7B,OAAO,EAAE,MAAM,EACN,MAAM,CAAC,EAAE,aAAa,YAAA;CAKlC;AAED,eAAO,MAAM,YAAY,GAAI,KAAK,OAAO,EAAE,OAAO,cAAc,KAAG,GAAG,IAAI,UACF,CAAC"}
package/dist/errors.js CHANGED
@@ -19,6 +19,7 @@ export const ESSEY_ERROR_CODES = [
19
19
  "HEALTH_NO_BUCKET",
20
20
  "CT_MISMATCH",
21
21
  "KEEPER_NOT_ELIGIBLE",
22
+ "REQUEST_STALE",
22
23
  ];
23
24
  export class EsseyError extends Error {
24
25
  code;
package/dist/essey.d.ts CHANGED
@@ -6,7 +6,7 @@ import { type Role } from "./v3/credential/issue.ts";
6
6
  import { type RelayBody } from "./v3/bodies.ts";
7
7
  import { open as openLoan, type CancelBody, type ClaimDefaultBody, type OfferBody, type OpenBody, type ReclaimBody, type ReclaimCollBody, type RepayBody, type SettleBody } from "./v3/loans/bodies.ts";
8
8
  import { type KeeperTerms } from "./v3/keeper-payload.ts";
9
- import { type FeeCommitInput } from "./v3/fees.ts";
9
+ import { type FeeCommitInput, type FeeLane } from "./v3/fees.ts";
10
10
  import { type MarketFields, type MarketRates } from "./v3/market.ts";
11
11
  import type { Reading } from "./v3/collateral/math.ts";
12
12
  import type { LoanReader } from "./v3/collateral/scan.ts";
@@ -15,6 +15,17 @@ import { type NoteSummary, type PoolEvents } from "./v3/notes/scan.ts";
15
15
  import { type Pause } from "./v3/pace.ts";
16
16
  import type { Prover } from "./v3/prover.ts";
17
17
  import { type Landed, type Queued, type RelayerInfo, type TicketState } from "./v3/relay/client.ts";
18
+ /** The first heartbeat after a settle; a failed one leaves the landed settle standing. */
19
+ export type Cover = {
20
+ ok: true;
21
+ digest: string;
22
+ ticket: string;
23
+ expiryMs: bigint;
24
+ } | {
25
+ ok: false;
26
+ code: string;
27
+ error: string;
28
+ };
18
29
  export type ConnectOptions = {
19
30
  network: "testnet";
20
31
  /** A mode 600 file this SDK creates. It holds the member secrets and the credential. */
@@ -23,6 +34,11 @@ export type ConnectOptions = {
23
34
  config: V3Config | string;
24
35
  /** 32 bytes the note keys and the deposit signers derive from. Absent, one is drawn and kept in the state file. */
25
36
  seed?: Uint8Array;
37
+ /**
38
+ * PRV-36a: 32 bytes kept apart from the state file. Given, the whole file is sealed under it (a plain file is
39
+ * sealed at connect), so a copy of the state directory alone opens nothing.
40
+ */
41
+ stateKey?: Uint8Array;
26
42
  relayer?: "clear" | "onion" | string;
27
43
  /**
28
44
  * "default": each SDK-proved action waits a time drawn by its class (`src/v3/pace.ts`) before it reads the
@@ -30,6 +46,10 @@ export type ConnectOptions = {
30
46
  */
31
47
  delays?: "default" | "off";
32
48
  };
49
+ type Listed = {
50
+ id: string;
51
+ json: unknown;
52
+ };
33
53
  /** What the SDK cannot yet do alone: proving and reading the chain are supplied by the caller. */
34
54
  export type EsseyIo = {
35
55
  fetch?: Fetch;
@@ -40,8 +60,8 @@ export type EsseyIo = {
40
60
  /** Waits out one drawn pre-prove delay; `sleep(delayMs)` when absent. A throw stops the action unsent. */
41
61
  pace?: (p: Pause) => Promise<void>;
42
62
  prover?: Prover;
43
- /** `fee_commit` of the coin's on-chain `FeeConfig`. */
44
- readFeeCommit?: (coin: CoinKey) => Promise<bigint>;
63
+ /** `fee_commit` of the coin's on-chain `FeeConfig`: `objects.edgeFeeConfigs` for lane `edge`, else `objects.feeConfigs`. */
64
+ readFeeCommit?: (coin: CoinKey, lane: FeeLane) => Promise<bigint>;
45
65
  readMarket?: (market: string) => Promise<MarketFields>;
46
66
  /** Every `NewCommitment` and `NewNullifier` of the coin's pool. */
47
67
  readPool?: (coin: CoinKey) => Promise<PoolEvents>;
@@ -53,8 +73,10 @@ export type EsseyIo = {
53
73
  value: bigint;
54
74
  sender: string;
55
75
  }) => Promise<void>;
56
- /** NEEDS-BORIS: true once `address` has held a balance or sent a transaction. Required with a `seed` option. */
76
+ /** True once `address` has held a balance or sent a transaction. Recovery uses it to tell an unfunded sender. */
57
77
  readAddressUsed?: (address: string) => Promise<boolean>;
78
+ /** The first deposit-sender index of a fresh state; a random u48 when absent (PRV-07 b). Tests pass 0. */
79
+ signerStart?: () => number;
58
80
  keeper?: KeeperIo;
59
81
  /** Proved `loan_open` fields. The SDK builds the envelope from them. Absent, the SDK plans the open itself. */
60
82
  planLoanOpen?: (p: LoanOpenParams) => Promise<Parameters<typeof openLoan>[0]>;
@@ -83,15 +105,13 @@ export type EsseyIo = {
83
105
  pkg?: SealPackage;
84
106
  signer?: Signer;
85
107
  }) => Promise<Map<string, Uint8Array>>;
86
- /** The `keeper::Badge` a digest created, its Move fields as JSON, or null when it created none. */
87
- readBadge?: (digest: string) => Promise<{
88
- id: string;
89
- json: unknown;
90
- } | null>;
108
+ /** One page of every `keeper::Badge`, each with its Move fields as JSON. */
109
+ readBadges?: (cursor: string | null) => Promise<{
110
+ badges: Listed[];
111
+ next?: string | null;
112
+ }>;
91
113
  /** The `priceUpdate` bytes a market's price kinds take: a Pyth update, or `[0]` for a stand-in market. */
92
114
  priceUpdate?: (market: string) => Promise<Uint8Array>;
93
- /** The loan id created by a digest, or null when the digest created none. */
94
- readCreated?: (digest: string) => Promise<string | null>;
95
115
  readLoans?: LoanReader;
96
116
  /** `round` is the current `Round` dynamic field. The loan JSON does not inline it. */
97
117
  /** The loan and round `round` of its `rounds` table, the current round when `round` is omitted. */
@@ -144,7 +164,6 @@ export type EsseyIo = {
144
164
  } | null>;
145
165
  /** Signs and pays `membership::from_proof` then `sale_room::open` as the item's owner; this SDK does not sign. */
146
166
  submitSaleOpen?: (tx: SaleOpenTx) => Promise<{
147
- id: string;
148
167
  digest: string;
149
168
  ticket: string;
150
169
  }>;
@@ -162,9 +181,6 @@ export type EsseyIo = {
162
181
  digest: string;
163
182
  owner: string | null;
164
183
  }>;
165
- readSaleOpened?: (digest: string) => Promise<{
166
- room: string;
167
- }>;
168
184
  };
169
185
  /** The arguments of a seller-paid open. `item.type` is the struct tag of `T`, named by the package's original id. */
170
186
  export type SaleOpenTx = {
@@ -246,8 +262,6 @@ export type LoanRequest = {
246
262
  maxRateBps: bigint;
247
263
  termMs: bigint;
248
264
  borrowerPk: bigint;
249
- collAmt: bigint;
250
- collBlind: bigint;
251
265
  collNote: bigint;
252
266
  salt: bigint;
253
267
  closeMs: bigint;
@@ -269,9 +283,22 @@ export type Renewal = CredentialInfo & ({
269
283
  renewed: false;
270
284
  renewOpensMs: bigint;
271
285
  });
286
+ /** `allowReuse: true` pays an address this seed already paid, which links the two payouts on chain. */
272
287
  export type SpendOptions = {
273
288
  force?: boolean;
289
+ allowReuse?: boolean;
274
290
  };
291
+ /**
292
+ * `held`: nothing was sent; the note is in the state file and the next call that spends own notes of its coin
293
+ * takes it as an input. With `sweep: true` a paced self-transfer moved it now and landed.
294
+ */
295
+ export type Collected = {
296
+ held: true;
297
+ value: bigint;
298
+ } | (Landed & {
299
+ held: false;
300
+ value: bigint;
301
+ });
275
302
  /** One or more `0x` addresses; a split payout sends each piece to a different one. */
276
303
  export type Payees = string | string[];
277
304
  /** One `pool::withdraw`: the amount and the address are public on chain. */
@@ -284,6 +311,20 @@ export type ExitResult = {
284
311
  payouts: Payout[];
285
312
  kept: bigint;
286
313
  };
314
+ /** A split payout's unpaid pieces in order. `spent`: note indexes the last piece took, read as spent before the next. */
315
+ export type Pending = {
316
+ coin: CoinKey;
317
+ pieces: {
318
+ amount: bigint;
319
+ to: string;
320
+ }[];
321
+ notBeforeMs: number;
322
+ spent: number[];
323
+ };
324
+ export type Staged = {
325
+ paid: Payout;
326
+ pending: Pending | null;
327
+ };
287
328
  /**
288
329
  * A deposit whose value may sit at its fresh sender's address: on disk before `fundDeposit`, gone once it lands.
289
330
  * `signed` is every note it signed for. The ciphertext is drawn fresh, so the same seed depositing the same
@@ -345,6 +386,7 @@ export declare class Essey {
345
386
  private readonly relayerBase;
346
387
  private readonly seedOption;
347
388
  private readonly pacing;
389
+ private readonly stateKey;
348
390
  readonly credential: {
349
391
  obtain(o?: {
350
392
  invite?: string;
@@ -358,7 +400,7 @@ export declare class Essey {
358
400
  renew(): Promise<Renewal>;
359
401
  };
360
402
  readonly fees: {
361
- params(coin: CoinKey): Promise<FeeCommitInput>;
403
+ params(coin: CoinKey, lane?: FeeLane): Promise<FeeCommitInput>;
362
404
  };
363
405
  readonly relayer: {
364
406
  info(): Promise<RelayerInfo>;
@@ -386,38 +428,40 @@ export declare class Essey {
386
428
  }): Promise<Landed & {
387
429
  offer: OfferRecord;
388
430
  }>;
389
- /** The lender, after repay: moves the repaid note, which no ciphertext names, into an ordinary own note. */
431
+ /** The lender, after repay: holds the repaid note, which no ciphertext names, as an own note. */
390
432
  collect(p: {
391
433
  loan: string;
392
434
  offer: OfferRecord;
393
- }): Promise<Landed & {
394
- value: bigint;
395
- }>;
396
- /** The lender, after LIQUIDATE or DEFAULT: moves its share of the seized collateral into an ordinary own note. */
435
+ sweep?: boolean;
436
+ }): Promise<Collected>;
437
+ /** The lender, after LIQUIDATE or DEFAULT: holds its share of the seized collateral as an own note. */
397
438
  collectSeized(p: {
398
439
  loan: string;
399
440
  offer: OfferRecord;
400
- }): Promise<Landed & {
401
- value: bigint;
402
- }>;
403
- /** The borrower, after LIQUIDATE or DEFAULT: moves the collateral the seizure left over into an ordinary own note. */
441
+ sweep?: boolean;
442
+ }): Promise<Collected>;
443
+ /** The borrower, after LIQUIDATE or DEFAULT: holds the collateral the seizure left over as an own note. */
404
444
  collectSurplus(p: {
405
445
  loan: string;
406
446
  terms: KeeperTerms;
407
447
  borrowerPk: bigint;
408
448
  collAmt: bigint;
409
- }): Promise<Landed & {
410
- value: bigint;
411
- }>;
449
+ sweep?: boolean;
450
+ }): Promise<Collected>;
412
451
  /**
413
452
  * The borrower, after close: opens every active offer and settles on the lowest eligible rate. The terms are
414
- * what `payBack` needs; keep them private.
453
+ * what `payBack` needs; keep them private. `cover` is the first heartbeat, sent as soon as the settle lands.
415
454
  */
416
- accept(id: string): Promise<Landed & {
455
+ accept(p: {
456
+ loan: string;
457
+ /** The amount this borrower locked; the request no longer carries it (PRV-03). */
458
+ collAmt: bigint;
459
+ }): Promise<Landed & {
417
460
  rateBps: bigint;
418
461
  terms: KeeperTerms;
419
462
  borrowerPk: bigint;
420
463
  collAmt: bigint;
464
+ cover: Cover;
421
465
  }>;
422
466
  /** The lender takes back the principal its offer locked, once the round resolved without it (cancel, or another offer won). */
423
467
  reclaimOffer(p: {
@@ -457,7 +501,9 @@ export declare class Essey {
457
501
  collAmt: bigint;
458
502
  k?: number;
459
503
  expiryMs?: bigint;
460
- }): Promise<Landed>;
504
+ }): Promise<Landed & {
505
+ expiryMs: bigint;
506
+ }>;
461
507
  /** The borrower adds `add` from own notes of the collateral coin to the lock of its active loan. */
462
508
  topup(p: {
463
509
  loan: string;
@@ -481,7 +527,10 @@ export declare class Essey {
481
527
  round: bigint;
482
528
  closeMs: bigint;
483
529
  }>;
484
- /** The borrower takes the lowest eligible offer of its open refi round: the old lender is paid `terms.owed`. */
530
+ /**
531
+ * The borrower takes the lowest eligible offer of its open refi round: the old lender is paid `terms.owed`. The
532
+ * settle clears the cover (`refi.move:168`), so `cover` is the heartbeat sent as soon as it lands.
533
+ */
485
534
  settleRefi(p: {
486
535
  loan: string;
487
536
  terms: KeeperTerms;
@@ -490,6 +539,7 @@ export declare class Essey {
490
539
  }): Promise<Landed & {
491
540
  rateBps: bigint;
492
541
  terms: KeeperTerms;
542
+ cover: Cover;
493
543
  }>;
494
544
  /** The borrower closes its open refi round; the loan stays active on its terms. */
495
545
  cancelRefi(id: string): Promise<Landed>;
@@ -560,10 +610,18 @@ export declare class Essey {
560
610
  * A coin with denominations pays `amount` as denomination pieces, largest first, each to the next address of
561
611
  * `to`; an amount that is not such a sum is refused with the largest one below it. `force: true`, or a coin
562
612
  * without denominations, pays it exactly to one address. Refused when the amount equals a faucet grant or an
563
- * own note's exact value or deposit, unless `force` is true.
613
+ * own note's exact value or deposit, unless `force` is true. Each piece after the first waits a long-class
614
+ * time. Refused before the wait when `to` lists an address this seed paid before, unless `allowReuse` is true.
564
615
  */
565
616
  withdraw(coin: CoinKey, amount: bigint, to: Payees, o?: SpendOptions): Promise<Payout[]>;
566
- /** A one-use address another member pays with `transfer`: a fresh note key of this seed and its enc key. */
617
+ /** `withdraw`'s checks and wait, then the first piece only; `pending` holds the rest for `payNext`. */
618
+ withdrawFirst(coin: CoinKey, amount: bigint, to: Payees, o?: SpendOptions): Promise<Staged>;
619
+ /** Pays `pending`'s next piece now. It does not wait: the caller holds it until `notBeforeMs`. */
620
+ payNext(pending: Pending): Promise<Staged>;
621
+ /**
622
+ * A one-use `v3note2:` address another member pays with `transfer`: a fresh note key and enc key pair of this
623
+ * seed. Two addresses share nothing but the prefix, and none names its index (SCOPE-PRV34).
624
+ */
567
625
  receiveAddress(): string;
568
626
  /** Pays `amount` into a note only the holder of `to` (a `receiveAddress`) can open. No public amount moves. */
569
627
  transfer(coin: CoinKey, amount: bigint, to: string): Promise<Landed>;
@@ -573,6 +631,10 @@ export declare class Essey {
573
631
  * Refused as `withdraw` is when the payout is such an amount, unless `force` is true.
574
632
  */
575
633
  exit(coin: CoinKey, to: Payees, o?: SpendOptions): Promise<ExitResult>;
634
+ /** `exit`'s checks and wait, then the first piece only, as `withdrawFirst`. */
635
+ exitFirst(coin: CoinKey, to: Payees, o?: SpendOptions): Promise<Staged & {
636
+ kept: bigint;
637
+ }>;
576
638
  /** NEEDS-BORIS: tries every deposit whose value may sit at its fresh sender, one outcome per record. */
577
639
  recoverStranded(): Promise<Recovered[]>;
578
640
  };
@@ -622,36 +684,56 @@ export declare class Essey {
622
684
  }): Promise<Landed & {
623
685
  value: bigint;
624
686
  }>;
625
- /** The winner (its bid record) or the seller (its keys) sends the vault's item to `recipient`. */
687
+ /** The winner (its bid record) or the seller (its keys) sends the vault's item to `recipient`, or to `itemAddress()`. */
626
688
  claim(p: {
627
689
  vault: string;
628
- recipient: string;
690
+ recipient?: string;
629
691
  bid?: BidRecord;
630
692
  seller?: SellerKeys;
631
- }): Promise<Landed>;
693
+ }): Promise<Landed & {
694
+ to: string;
695
+ }>;
696
+ /** PRV-35: a fresh single-use address of this seed; an item there opens a sale from it with no hand-over. */
697
+ itemAddress(): string;
632
698
  /** The seller, before any bid: its pass over the room's next "cancel" action. */
633
699
  cancel(p: {
634
700
  room: string;
635
701
  vault: string;
636
702
  }): Promise<Landed>;
637
703
  /**
638
- * Testnet: v3api mints one demo Badge, the sale item the KeyRegistry allows, to `to` with a little gas SUI.
639
- * One per credential per UTC day. `to` is public on chain, and v3api sees it beside this credential's day-tag.
704
+ * Testnet: v3api mints one demo Badge, the sale item the KeyRegistry allows, to `to` (default `itemAddress()`)
705
+ * with a little gas SUI. One per credential per UTC day. `to` is public on chain, and v3api sees it beside this
706
+ * credential's day-tag.
640
707
  */
641
- badgeGrant(to: string): Promise<{
708
+ badgeGrant(to?: string): Promise<{
642
709
  digest: string;
643
710
  badge: string;
644
711
  }>;
645
712
  };
646
713
  readonly keeper: KeeperSection & KeeperActions;
714
+ /** Each pass over the fee room carries the same tag, so one fetch per coin, lane and commit is all v3api sees. */
715
+ private readonly feeOpenings;
716
+ /** Loan snapshot openings by `coin:commit`, apart from `feeOpenings`, which follows the config as it stands. */
717
+ private readonly snapshotOpenings;
647
718
  private constructor();
648
719
  static connect(o: ConnectOptions, io?: EsseyIo): Promise<Essey>;
649
720
  private paced;
650
721
  /** Runs before the action reads anything its proof binds, so a long wait never stales a Merkle root or `now_s`. */
651
722
  private pause;
723
+ private waitOut;
724
+ /** PRV-11: when the next piece of a split payout may go, a long-class draw after this one. */
725
+ private pieceAt;
652
726
  private sleep;
727
+ /** PRV-08: only a sweep sends a transaction, so only a sweep waits; a held note waits for the spend that takes it. */
728
+ private collecting;
653
729
  /** The current round's `close_ms` (offers, `loan.move:339`) or `settle_by_ms` (settles, `settle.move:132`). */
654
730
  private roundDeadline;
731
+ /**
732
+ * PRV-03 stopgap (Erik, Nov 30): a request hides its collateral, and round-0 settle does not re-check the LTV
733
+ * (`loan_settle.circom` has no OverLine), so an offer on bidding that opened over 24 h ago is refused up front.
734
+ */
735
+ private refuseStaleRequest;
736
+ private refuseOffGridClose;
655
737
  /** The stored heartbeat expiry, past which a keeper may liquidate (`keeper.move:204`); none before a first heartbeat. */
656
738
  private coverDeadline;
657
739
  private relayClient;
@@ -674,6 +756,16 @@ export declare class Essey {
674
756
  private issue;
675
757
  /** The opening for one coin, returned only after it matches the commit read from chain (D §5.4). */
676
758
  private feeParams;
759
+ /**
760
+ * PRV-02: a loan step folds the loan's own snapshot (`loan.move:141-143`), not the config as it stands, so its
761
+ * opening is fetched by that commit (v3api's archive) and must hash to it.
762
+ */
763
+ private loanFee;
764
+ /** One fee-params pass (`FEE_PARAMS_ROOM`, bound to a fresh challenge) carrying `fields`; the reply body. */
765
+ private feePass;
766
+ /** The edge lane only once the record names the coin's edge config; before that the pool takes its pinned one. */
767
+ private feeLane;
768
+ private feeConfigId;
677
769
  private rates;
678
770
  /**
679
771
  * A drawn seed is on disk before any key derived from it is used. A seed option is never stored, so a file
@@ -685,8 +777,10 @@ export declare class Essey {
685
777
  * backup: the counter resumes past every index the seed has on chain before any is reserved.
686
778
  */
687
779
  private keys;
688
- private addressUsed;
689
- /** A deposit sender the chain has never seen, so no two deposits share one. */
780
+ /**
781
+ * PRV-07 b (decided Nov 30): a sender index no lookup has to vouch for. A fresh state starts at a random u48, so a
782
+ * restored seed lands far from the indexes it used before; the next index is on disk before this one is used.
783
+ */
690
784
  private freshSigner;
691
785
  /** Write-ahead: a deposit is on disk as stranded before its value moves, and leaves once it has landed. */
692
786
  private strand;
@@ -737,20 +831,37 @@ export declare class Essey {
737
831
  */
738
832
  private reindex;
739
833
  private owned;
834
+ /** The scan's notes, then each held note of `coin` whose leaf is in `events` unspent. */
835
+ private ownedIn;
836
+ /** Records a found note for the next spend; held notes of `coin` the read pool shows spent are dropped. */
837
+ private hold;
740
838
  private scan;
741
- private withdraw;
839
+ /** Every refusal that needs no chain read, so a bad call is refused before its wait rather than after it. */
840
+ private withdrawPlan;
841
+ private withdrawStart;
742
842
  private withdrawExact;
843
+ /** PRV-11: a reused payee joins two payouts on chain. With no tag on disk this reads no seed and writes nothing. */
844
+ private refusePaid;
845
+ private paidTo;
743
846
  /** The same reads and set-up checks `spend` makes, once for every piece of a split payout. */
744
847
  private payoutPlan;
745
- /** The one loop over a payout's pieces, where a wait between them belongs. Each reads the pool after the last is seen spent. */
746
- private payPieces;
848
+ /** Pays `pieces[0]`; the rest come back as `pending`, due a long-class time from now. */
849
+ private payPiece;
850
+ private payNext;
851
+ /** The in-process schedule: each pending piece waits out its `notBeforeMs` through `io.pace`, then goes. */
852
+ private drain;
747
853
  private awaitSpent;
748
854
  private receiveAddress;
855
+ private noteNext;
856
+ private itemAddress;
857
+ private holderOf;
749
858
  private transfer;
750
- private exit;
859
+ private exitStart;
751
860
  private exitExact;
752
861
  /** js4 with the withdraw field (`src/v3/inputs.ts:39`); the change note's index is on disk before the body leaves. */
753
862
  private spend;
863
+ /** PRV-34 write-ahead: an address is marked paid before the body leaves, so a second payment to it never does. */
864
+ private markPaid;
754
865
  /** A 202 carries no digest (`src/v3/relay/client.ts:100`): the ticket is followed until it lands. */
755
866
  private follow;
756
867
  /** A kind in `FEE_FREE` sends "0". Every other loan kind sends this pool's configured constant. */
@@ -772,6 +883,11 @@ export declare class Essey {
772
883
  private viewNote;
773
884
  /** D-SPEC §6.2:588. The envelope is `v3.loans.open`; the id is whatever the digest created. */
774
885
  private openRequest;
886
+ /**
887
+ * PRV-07: what an open created is found among every listed object of its kind by the key its opener chose
888
+ * (`field`), never by the opener's own digest.
889
+ */
890
+ private listedByKey;
775
891
  /**
776
892
  * The borrower's `loan_open`: a CollLock spend of up to two own notes into the lock, the Health OPEN rows, the
777
893
  * sealed request and keeper ciphertexts, and the borrower pass. The loan key, the lock blinding and the request
@@ -840,9 +956,11 @@ export declare class Essey {
840
956
  /**
841
957
  * The repaid note is `Poseidon(owed, lenderPk, H(DOM_LBLIND, S.x))` with `S = encSk · repay_eph`
842
958
  * (`loan_repay.circom`), and a refi payoff the same over a `payoff_eph` pair (`loan_refi.circom`); either ciphertext
843
- * is filler, so the scan never sees it. It is spent into an own note.
959
+ * is filler, so the scan never sees it; `owned` finds it through the state file's `held` list.
844
960
  */
845
961
  private collect;
962
+ /** Refuses a spent note. `sweep` moves it to the receive address now; otherwise it is held for the next spend. */
963
+ private take;
846
964
  /** Spends a note no ciphertext names, found by its commitment, to the receive address. */
847
965
  private claimLeaf;
848
966
  /** The lender's lock opening at nonce 1: the settle delivery, with the amount the latest TOPUP delivery re-states. */
@@ -896,11 +1014,18 @@ export declare class Essey {
896
1014
  */
897
1015
  private ownOpening;
898
1016
  private heartbeatOwn;
1017
+ /**
1018
+ * PRV-15: until a loan's first heartbeat every keeper may read its terms (`keeper.move:204`), so this follows the
1019
+ * settle at once and unpaced. A heartbeat may follow a settle at once: `hb_at_ms` is 0 (`liquidation.move:199`).
1020
+ */
1021
+ private firstCover;
1022
+ /** The loan reader is an indexer that may trail the landed settle. */
1023
+ private untilSettled;
899
1024
  /**
900
1025
  * `liquidation::heartbeat`'s clock rules, checked before proving: one heartbeat per gap (43_015), an expiry at
901
1026
  * least one gap and at most `H_MAX_MS` ahead (43_005) and not before the stored one (43_019). The gap is
902
- * `liquidation::hb_gap_ms`: 2 minutes on a stand-in market, 50 on any other. No expiry given takes an hour, or the
903
- * stored expiry when that is later.
1027
+ * `liquidation::hb_gap_ms`: 2 minutes on a stand-in market, 50 on any other. No expiry given takes `coverExpiry`,
1028
+ * or the stored expiry when that is later.
904
1029
  */
905
1030
  private heartbeatExpiry;
906
1031
  /**
@@ -941,9 +1066,10 @@ export declare class Essey {
941
1066
  /** D-SPEC §6.2:599. The seller pass over `sale_room::open_args`, at action nonce 0; the relayer or the callback pays. */
942
1067
  private openSale;
943
1068
  /**
944
- * The sponsored open (E-34): a fresh seed-derived sender receives the item, then signs `from_proof` and `open`
945
- * while the relayer pays gas. Every reader is checked here, before any proof, reserve or delivery. An open that
946
- * stops after the delivery leaves the item at that sender, which only its seed can move.
1069
+ * The sponsored open (E-34): a fresh seed-derived sender signs `from_proof` and `open` while the relayer pays gas.
1070
+ * PRV-35: an item at one of this seed's `itemAddress()` holders opens from that holder with no hand-over; any other
1071
+ * item is first delivered to a fresh deposit signer. Every reader is checked here, before any proof, reserve or
1072
+ * delivery. An open that stops after the delivery leaves the item at that sender, which only its seed can move.
947
1073
  */
948
1074
  private saleSponsor;
949
1075
  /** D-SPEC §6.2:600. */