@esseyonsui/sui-sdk-v3 0.1.9 → 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 (50) 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 +177 -55
  8. package/dist/essey.d.ts.map +1 -1
  9. package/dist/essey.js +549 -233
  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/math.d.ts +6 -0
  17. package/dist/v3/collateral/math.d.ts.map +1 -1
  18. package/dist/v3/collateral/math.js +12 -0
  19. package/dist/v3/credential/membership.d.ts +2 -0
  20. package/dist/v3/credential/membership.d.ts.map +1 -1
  21. package/dist/v3/credential/membership.js +4 -0
  22. package/dist/v3/fees.d.ts +6 -0
  23. package/dist/v3/fees.d.ts.map +1 -1
  24. package/dist/v3/loans/offer-plan.d.ts +1 -1
  25. package/dist/v3/loans/offer-plan.d.ts.map +1 -1
  26. package/dist/v3/loans/offer-plan.js +5 -4
  27. package/dist/v3/loans/open-plan.d.ts +7 -3
  28. package/dist/v3/loans/open-plan.d.ts.map +1 -1
  29. package/dist/v3/loans/open-plan.js +11 -3
  30. package/dist/v3/notes/derive.d.ts +7 -0
  31. package/dist/v3/notes/derive.d.ts.map +1 -1
  32. package/dist/v3/notes/derive.js +10 -0
  33. package/dist/v3/notes/opening.d.ts +22 -1
  34. package/dist/v3/notes/opening.d.ts.map +1 -1
  35. package/dist/v3/notes/opening.js +55 -22
  36. package/dist/v3/notes/scan.d.ts +20 -3
  37. package/dist/v3/notes/scan.d.ts.map +1 -1
  38. package/dist/v3/notes/scan.js +59 -16
  39. package/dist/v3/notes/withdraw.d.ts +2 -0
  40. package/dist/v3/notes/withdraw.d.ts.map +1 -1
  41. package/dist/v3/notes/withdraw.js +9 -0
  42. package/dist/v3/pace.d.ts +1 -1
  43. package/dist/v3/pace.js +1 -1
  44. package/dist/v3/stage1.d.ts +5 -2
  45. package/dist/v3/stage1.d.ts.map +1 -1
  46. package/dist/v3/stage1.js +17 -6
  47. package/dist/v3/time-grid.d.ts +22 -2
  48. package/dist/v3/time-grid.d.ts.map +1 -1
  49. package/dist/v3/time-grid.js +44 -8
  50. 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;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAY9C,QAAA,MAAM,UAAU;;;;;;;;CAQN,CAAC;AACX,KAAK,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QACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;KACxC,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9E,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IAChD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AA4BF,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CAsElD;AAsDD,wFAAwF;AACxF,wBAAsB,UAAU,CAC9B,MAAM,EAAE,QAAQ,GAAG,MAAM,EACzB,KAAK,EAAE,KAAK,GACX,OAAO,CAAC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAOzD"}
package/dist/config.js CHANGED
@@ -136,7 +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,11 +105,11 @@ 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
115
  readLoans?: LoanReader;
@@ -142,7 +164,6 @@ export type EsseyIo = {
142
164
  } | null>;
143
165
  /** Signs and pays `membership::from_proof` then `sale_room::open` as the item's owner; this SDK does not sign. */
144
166
  submitSaleOpen?: (tx: SaleOpenTx) => Promise<{
145
- id: string;
146
167
  digest: string;
147
168
  ticket: string;
148
169
  }>;
@@ -160,9 +181,6 @@ export type EsseyIo = {
160
181
  digest: string;
161
182
  owner: string | null;
162
183
  }>;
163
- readSaleOpened?: (digest: string) => Promise<{
164
- room: string;
165
- }>;
166
184
  };
167
185
  /** The arguments of a seller-paid open. `item.type` is the struct tag of `T`, named by the package's original id. */
168
186
  export type SaleOpenTx = {
@@ -244,8 +262,6 @@ export type LoanRequest = {
244
262
  maxRateBps: bigint;
245
263
  termMs: bigint;
246
264
  borrowerPk: bigint;
247
- collAmt: bigint;
248
- collBlind: bigint;
249
265
  collNote: bigint;
250
266
  salt: bigint;
251
267
  closeMs: bigint;
@@ -267,9 +283,22 @@ export type Renewal = CredentialInfo & ({
267
283
  renewed: false;
268
284
  renewOpensMs: bigint;
269
285
  });
286
+ /** `allowReuse: true` pays an address this seed already paid, which links the two payouts on chain. */
270
287
  export type SpendOptions = {
271
288
  force?: boolean;
289
+ allowReuse?: boolean;
272
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
+ });
273
302
  /** One or more `0x` addresses; a split payout sends each piece to a different one. */
274
303
  export type Payees = string | string[];
275
304
  /** One `pool::withdraw`: the amount and the address are public on chain. */
@@ -282,6 +311,20 @@ export type ExitResult = {
282
311
  payouts: Payout[];
283
312
  kept: bigint;
284
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
+ };
285
328
  /**
286
329
  * A deposit whose value may sit at its fresh sender's address: on disk before `fundDeposit`, gone once it lands.
287
330
  * `signed` is every note it signed for. The ciphertext is drawn fresh, so the same seed depositing the same
@@ -343,6 +386,7 @@ export declare class Essey {
343
386
  private readonly relayerBase;
344
387
  private readonly seedOption;
345
388
  private readonly pacing;
389
+ private readonly stateKey;
346
390
  readonly credential: {
347
391
  obtain(o?: {
348
392
  invite?: string;
@@ -356,7 +400,7 @@ export declare class Essey {
356
400
  renew(): Promise<Renewal>;
357
401
  };
358
402
  readonly fees: {
359
- params(coin: CoinKey): Promise<FeeCommitInput>;
403
+ params(coin: CoinKey, lane?: FeeLane): Promise<FeeCommitInput>;
360
404
  };
361
405
  readonly relayer: {
362
406
  info(): Promise<RelayerInfo>;
@@ -384,38 +428,40 @@ export declare class Essey {
384
428
  }): Promise<Landed & {
385
429
  offer: OfferRecord;
386
430
  }>;
387
- /** 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. */
388
432
  collect(p: {
389
433
  loan: string;
390
434
  offer: OfferRecord;
391
- }): Promise<Landed & {
392
- value: bigint;
393
- }>;
394
- /** 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. */
395
438
  collectSeized(p: {
396
439
  loan: string;
397
440
  offer: OfferRecord;
398
- }): Promise<Landed & {
399
- value: bigint;
400
- }>;
401
- /** 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. */
402
444
  collectSurplus(p: {
403
445
  loan: string;
404
446
  terms: KeeperTerms;
405
447
  borrowerPk: bigint;
406
448
  collAmt: bigint;
407
- }): Promise<Landed & {
408
- value: bigint;
409
- }>;
449
+ sweep?: boolean;
450
+ }): Promise<Collected>;
410
451
  /**
411
452
  * The borrower, after close: opens every active offer and settles on the lowest eligible rate. The terms are
412
- * 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.
413
454
  */
414
- 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 & {
415
460
  rateBps: bigint;
416
461
  terms: KeeperTerms;
417
462
  borrowerPk: bigint;
418
463
  collAmt: bigint;
464
+ cover: Cover;
419
465
  }>;
420
466
  /** The lender takes back the principal its offer locked, once the round resolved without it (cancel, or another offer won). */
421
467
  reclaimOffer(p: {
@@ -455,7 +501,9 @@ export declare class Essey {
455
501
  collAmt: bigint;
456
502
  k?: number;
457
503
  expiryMs?: bigint;
458
- }): Promise<Landed>;
504
+ }): Promise<Landed & {
505
+ expiryMs: bigint;
506
+ }>;
459
507
  /** The borrower adds `add` from own notes of the collateral coin to the lock of its active loan. */
460
508
  topup(p: {
461
509
  loan: string;
@@ -479,7 +527,10 @@ export declare class Essey {
479
527
  round: bigint;
480
528
  closeMs: bigint;
481
529
  }>;
482
- /** 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
+ */
483
534
  settleRefi(p: {
484
535
  loan: string;
485
536
  terms: KeeperTerms;
@@ -488,6 +539,7 @@ export declare class Essey {
488
539
  }): Promise<Landed & {
489
540
  rateBps: bigint;
490
541
  terms: KeeperTerms;
542
+ cover: Cover;
491
543
  }>;
492
544
  /** The borrower closes its open refi round; the loan stays active on its terms. */
493
545
  cancelRefi(id: string): Promise<Landed>;
@@ -558,10 +610,18 @@ export declare class Essey {
558
610
  * A coin with denominations pays `amount` as denomination pieces, largest first, each to the next address of
559
611
  * `to`; an amount that is not such a sum is refused with the largest one below it. `force: true`, or a coin
560
612
  * without denominations, pays it exactly to one address. Refused when the amount equals a faucet grant or an
561
- * 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.
562
615
  */
563
616
  withdraw(coin: CoinKey, amount: bigint, to: Payees, o?: SpendOptions): Promise<Payout[]>;
564
- /** 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
+ */
565
625
  receiveAddress(): string;
566
626
  /** Pays `amount` into a note only the holder of `to` (a `receiveAddress`) can open. No public amount moves. */
567
627
  transfer(coin: CoinKey, amount: bigint, to: string): Promise<Landed>;
@@ -571,6 +631,10 @@ export declare class Essey {
571
631
  * Refused as `withdraw` is when the payout is such an amount, unless `force` is true.
572
632
  */
573
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
+ }>;
574
638
  /** NEEDS-BORIS: tries every deposit whose value may sit at its fresh sender, one outcome per record. */
575
639
  recoverStranded(): Promise<Recovered[]>;
576
640
  };
@@ -620,38 +684,56 @@ export declare class Essey {
620
684
  }): Promise<Landed & {
621
685
  value: bigint;
622
686
  }>;
623
- /** 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()`. */
624
688
  claim(p: {
625
689
  vault: string;
626
- recipient: string;
690
+ recipient?: string;
627
691
  bid?: BidRecord;
628
692
  seller?: SellerKeys;
629
- }): 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;
630
698
  /** The seller, before any bid: its pass over the room's next "cancel" action. */
631
699
  cancel(p: {
632
700
  room: string;
633
701
  vault: string;
634
702
  }): Promise<Landed>;
635
703
  /**
636
- * Testnet: v3api mints one demo Badge, the sale item the KeyRegistry allows, to `to` with a little gas SUI.
637
- * 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.
638
707
  */
639
- badgeGrant(to: string): Promise<{
708
+ badgeGrant(to?: string): Promise<{
640
709
  digest: string;
641
710
  badge: string;
642
711
  }>;
643
712
  };
644
713
  readonly keeper: KeeperSection & KeeperActions;
645
- /** Each pass over the fee room carries the same tag, so one fetch per coin per commit is all v3api sees. */
714
+ /** Each pass over the fee room carries the same tag, so one fetch per coin, lane and commit is all v3api sees. */
646
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,22 +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
839
  /** Every refusal that needs no chain read, so a bad call is refused before its wait rather than after it. */
742
840
  private withdrawPlan;
743
- private withdraw;
841
+ private withdrawStart;
744
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;
745
846
  /** The same reads and set-up checks `spend` makes, once for every piece of a split payout. */
746
847
  private payoutPlan;
747
- /** The one loop over a payout's pieces, where a wait between them belongs. Each reads the pool after the last is seen spent. */
748
- 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;
749
853
  private awaitSpent;
750
854
  private receiveAddress;
855
+ private noteNext;
856
+ private itemAddress;
857
+ private holderOf;
751
858
  private transfer;
752
- private exit;
859
+ private exitStart;
753
860
  private exitExact;
754
861
  /** js4 with the withdraw field (`src/v3/inputs.ts:39`); the change note's index is on disk before the body leaves. */
755
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;
756
865
  /** A 202 carries no digest (`src/v3/relay/client.ts:100`): the ticket is followed until it lands. */
757
866
  private follow;
758
867
  /** A kind in `FEE_FREE` sends "0". Every other loan kind sends this pool's configured constant. */
@@ -774,8 +883,11 @@ export declare class Essey {
774
883
  private viewNote;
775
884
  /** D-SPEC §6.2:588. The envelope is `v3.loans.open`; the id is whatever the digest created. */
776
885
  private openRequest;
777
- /** PRV-07: the new loan is found among all loans by the key the borrower chose, not by its own digest. */
778
- private loanByKey;
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;
779
891
  /**
780
892
  * The borrower's `loan_open`: a CollLock spend of up to two own notes into the lock, the Health OPEN rows, the
781
893
  * sealed request and keeper ciphertexts, and the borrower pass. The loan key, the lock blinding and the request
@@ -844,9 +956,11 @@ export declare class Essey {
844
956
  /**
845
957
  * The repaid note is `Poseidon(owed, lenderPk, H(DOM_LBLIND, S.x))` with `S = encSk · repay_eph`
846
958
  * (`loan_repay.circom`), and a refi payoff the same over a `payoff_eph` pair (`loan_refi.circom`); either ciphertext
847
- * 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.
848
960
  */
849
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;
850
964
  /** Spends a note no ciphertext names, found by its commitment, to the receive address. */
851
965
  private claimLeaf;
852
966
  /** The lender's lock opening at nonce 1: the settle delivery, with the amount the latest TOPUP delivery re-states. */
@@ -900,11 +1014,18 @@ export declare class Essey {
900
1014
  */
901
1015
  private ownOpening;
902
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;
903
1024
  /**
904
1025
  * `liquidation::heartbeat`'s clock rules, checked before proving: one heartbeat per gap (43_015), an expiry at
905
1026
  * least one gap and at most `H_MAX_MS` ahead (43_005) and not before the stored one (43_019). The gap is
906
- * `liquidation::hb_gap_ms`: 2 minutes on a stand-in market, 50 on any other. No expiry given takes an hour, or the
907
- * 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.
908
1029
  */
909
1030
  private heartbeatExpiry;
910
1031
  /**
@@ -945,9 +1066,10 @@ export declare class Essey {
945
1066
  /** D-SPEC §6.2:599. The seller pass over `sale_room::open_args`, at action nonce 0; the relayer or the callback pays. */
946
1067
  private openSale;
947
1068
  /**
948
- * The sponsored open (E-34): a fresh seed-derived sender receives the item, then signs `from_proof` and `open`
949
- * while the relayer pays gas. Every reader is checked here, before any proof, reserve or delivery. An open that
950
- * 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.
951
1073
  */
952
1074
  private saleSponsor;
953
1075
  /** D-SPEC §6.2:600. */