@esseyonsui/sui-sdk-v3 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.
- package/README.md +45 -2
- package/dist/config.d.ts +82 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +180 -0
- package/dist/errors.d.ts +38 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +32 -0
- package/dist/essey.d.ts +866 -0
- package/dist/essey.d.ts.map +1 -0
- package/dist/essey.js +3592 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/keeper.d.ts +54 -0
- package/dist/keeper.d.ts.map +1 -0
- package/dist/keeper.js +44 -0
- package/dist/network.d.ts +17 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +62 -0
- package/dist/v3/addr-field.d.ts +3 -0
- package/dist/v3/addr-field.d.ts.map +1 -0
- package/dist/v3/addr-field.js +10 -0
- package/dist/v3/bodies.d.ts +54 -0
- package/dist/v3/bodies.d.ts.map +1 -0
- package/dist/v3/bodies.js +68 -0
- package/dist/v3/body-args.d.ts +29 -0
- package/dist/v3/body-args.d.ts.map +1 -0
- package/dist/v3/body-args.js +78 -0
- package/dist/v3/collateral/bodies.d.ts +78 -0
- package/dist/v3/collateral/bodies.d.ts.map +1 -0
- package/dist/v3/collateral/bodies.js +136 -0
- package/dist/v3/collateral/ext.d.ts +21 -0
- package/dist/v3/collateral/ext.d.ts.map +1 -0
- package/dist/v3/collateral/ext.js +19 -0
- package/dist/v3/collateral/health.d.ts +115 -0
- package/dist/v3/collateral/health.d.ts.map +1 -0
- package/dist/v3/collateral/health.js +255 -0
- package/dist/v3/collateral/index.d.ts +9 -0
- package/dist/v3/collateral/index.d.ts.map +1 -0
- package/dist/v3/collateral/index.js +8 -0
- package/dist/v3/collateral/local-health.d.ts +23 -0
- package/dist/v3/collateral/local-health.d.ts.map +1 -0
- package/dist/v3/collateral/local-health.js +27 -0
- package/dist/v3/collateral/math.d.ts +33 -0
- package/dist/v3/collateral/math.d.ts.map +1 -0
- package/dist/v3/collateral/math.js +38 -0
- package/dist/v3/collateral/openings.d.ts +27 -0
- package/dist/v3/collateral/openings.d.ts.map +1 -0
- package/dist/v3/collateral/openings.js +28 -0
- package/dist/v3/collateral/scan.d.ts +41 -0
- package/dist/v3/collateral/scan.d.ts.map +1 -0
- package/dist/v3/collateral/scan.js +76 -0
- package/dist/v3/collateral/seal.d.ts +31 -0
- package/dist/v3/collateral/seal.d.ts.map +1 -0
- package/dist/v3/collateral/seal.js +59 -0
- package/dist/v3/credential/issue.d.ts +27 -0
- package/dist/v3/credential/issue.d.ts.map +1 -0
- package/dist/v3/credential/issue.js +109 -0
- package/dist/v3/credential/membership.d.ts +37 -0
- package/dist/v3/credential/membership.d.ts.map +1 -0
- package/dist/v3/credential/membership.js +34 -0
- package/dist/v3/credential/pow.d.ts +10 -0
- package/dist/v3/credential/pow.d.ts.map +1 -0
- package/dist/v3/credential/pow.js +22 -0
- package/dist/v3/domains.d.ts +141 -0
- package/dist/v3/domains.d.ts.map +1 -0
- package/dist/v3/domains.js +158 -0
- package/dist/v3/ext.d.ts +29 -0
- package/dist/v3/ext.d.ts.map +1 -0
- package/dist/v3/ext.js +82 -0
- package/dist/v3/faucet.d.ts +66 -0
- package/dist/v3/faucet.d.ts.map +1 -0
- package/dist/v3/faucet.js +64 -0
- package/dist/v3/fee-witness.d.ts +5 -0
- package/dist/v3/fee-witness.d.ts.map +1 -0
- package/dist/v3/fee-witness.js +18 -0
- package/dist/v3/fees.d.ts +78 -0
- package/dist/v3/fees.d.ts.map +1 -0
- package/dist/v3/fees.js +190 -0
- package/dist/v3/index.d.ts +24 -0
- package/dist/v3/index.d.ts.map +1 -0
- package/dist/v3/index.js +23 -0
- package/dist/v3/inputs.d.ts +89 -0
- package/dist/v3/inputs.d.ts.map +1 -0
- package/dist/v3/inputs.js +152 -0
- package/dist/v3/keeper-badge.d.ts +48 -0
- package/dist/v3/keeper-badge.d.ts.map +1 -0
- package/dist/v3/keeper-badge.js +49 -0
- package/dist/v3/keeper-payload.d.ts +36 -0
- package/dist/v3/keeper-payload.d.ts.map +1 -0
- package/dist/v3/keeper-payload.js +116 -0
- package/dist/v3/kinds.d.ts +23 -0
- package/dist/v3/kinds.d.ts.map +1 -0
- package/dist/v3/kinds.js +50 -0
- package/dist/v3/loans/bodies.d.ts +215 -0
- package/dist/v3/loans/bodies.d.ts.map +1 -0
- package/dist/v3/loans/bodies.js +255 -0
- package/dist/v3/loans/offer-plan.d.ts +66 -0
- package/dist/v3/loans/offer-plan.d.ts.map +1 -0
- package/dist/v3/loans/offer-plan.js +141 -0
- package/dist/v3/loans/open-plan.d.ts +62 -0
- package/dist/v3/loans/open-plan.d.ts.map +1 -0
- package/dist/v3/loans/open-plan.js +92 -0
- package/dist/v3/loans/reclaim-plan.d.ts +65 -0
- package/dist/v3/loans/reclaim-plan.d.ts.map +1 -0
- package/dist/v3/loans/reclaim-plan.js +125 -0
- package/dist/v3/loans/refi-plan.d.ts +62 -0
- package/dist/v3/loans/refi-plan.d.ts.map +1 -0
- package/dist/v3/loans/refi-plan.js +157 -0
- package/dist/v3/loans/repay-plan.d.ts +40 -0
- package/dist/v3/loans/repay-plan.d.ts.map +1 -0
- package/dist/v3/loans/repay-plan.js +77 -0
- package/dist/v3/loans/settle-plan.d.ts +152 -0
- package/dist/v3/loans/settle-plan.d.ts.map +1 -0
- package/dist/v3/loans/settle-plan.js +210 -0
- package/dist/v3/market.d.ts +38 -0
- package/dist/v3/market.d.ts.map +1 -0
- package/dist/v3/market.js +30 -0
- package/dist/v3/notes/denominations.d.ts +13 -0
- package/dist/v3/notes/denominations.d.ts.map +1 -0
- package/dist/v3/notes/denominations.js +35 -0
- package/dist/v3/notes/deposit.d.ts +57 -0
- package/dist/v3/notes/deposit.d.ts.map +1 -0
- package/dist/v3/notes/deposit.js +103 -0
- package/dist/v3/notes/derive.d.ts +16 -0
- package/dist/v3/notes/derive.d.ts.map +1 -0
- package/dist/v3/notes/derive.js +34 -0
- package/dist/v3/notes/faucet.d.ts +3 -0
- package/dist/v3/notes/faucet.d.ts.map +1 -0
- package/dist/v3/notes/faucet.js +8 -0
- package/dist/v3/notes/index.d.ts +9 -0
- package/dist/v3/notes/index.d.ts.map +1 -0
- package/dist/v3/notes/index.js +8 -0
- package/dist/v3/notes/keys.d.ts +5 -0
- package/dist/v3/notes/keys.d.ts.map +1 -0
- package/dist/v3/notes/keys.js +11 -0
- package/dist/v3/notes/opening.d.ts +16 -0
- package/dist/v3/notes/opening.d.ts.map +1 -0
- package/dist/v3/notes/opening.js +62 -0
- package/dist/v3/notes/scan.d.ts +32 -0
- package/dist/v3/notes/scan.d.ts.map +1 -0
- package/dist/v3/notes/scan.js +71 -0
- package/dist/v3/notes/tree.d.ts +9 -0
- package/dist/v3/notes/tree.d.ts.map +1 -0
- package/dist/v3/notes/tree.js +31 -0
- package/dist/v3/notes/withdraw.d.ts +12 -0
- package/dist/v3/notes/withdraw.d.ts.map +1 -0
- package/dist/v3/notes/withdraw.js +27 -0
- package/dist/v3/proof-bytes.d.ts +4 -0
- package/dist/v3/proof-bytes.d.ts.map +1 -0
- package/dist/v3/proof-bytes.js +22 -0
- package/dist/v3/prover.d.ts +34 -0
- package/dist/v3/prover.d.ts.map +1 -0
- package/dist/v3/prover.js +76 -0
- package/dist/v3/relay/client.d.ts +57 -0
- package/dist/v3/relay/client.d.ts.map +1 -0
- package/dist/v3/relay/client.js +80 -0
- package/dist/v3/relay/possession.d.ts +21 -0
- package/dist/v3/relay/possession.d.ts.map +1 -0
- package/dist/v3/relay/possession.js +45 -0
- package/dist/v3/sales/auctioneer.d.ts +60 -0
- package/dist/v3/sales/auctioneer.d.ts.map +1 -0
- package/dist/v3/sales/auctioneer.js +130 -0
- package/dist/v3/sales/bcs.d.ts +4 -0
- package/dist/v3/sales/bcs.d.ts.map +1 -0
- package/dist/v3/sales/bcs.js +16 -0
- package/dist/v3/sales/bid.d.ts +51 -0
- package/dist/v3/sales/bid.d.ts.map +1 -0
- package/dist/v3/sales/bid.js +85 -0
- package/dist/v3/sales/bodies.d.ts +83 -0
- package/dist/v3/sales/bodies.d.ts.map +1 -0
- package/dist/v3/sales/bodies.js +78 -0
- package/dist/v3/sales/claim.d.ts +40 -0
- package/dist/v3/sales/claim.d.ts.map +1 -0
- package/dist/v3/sales/claim.js +44 -0
- package/dist/v3/sales/index.d.ts +10 -0
- package/dist/v3/sales/index.d.ts.map +1 -0
- package/dist/v3/sales/index.js +9 -0
- package/dist/v3/sales/open-kind.d.ts +42 -0
- package/dist/v3/sales/open-kind.d.ts.map +1 -0
- package/dist/v3/sales/open-kind.js +43 -0
- package/dist/v3/sales/outcome.d.ts +20 -0
- package/dist/v3/sales/outcome.d.ts.map +1 -0
- package/dist/v3/sales/outcome.js +21 -0
- package/dist/v3/sales/reclaim.d.ts +46 -0
- package/dist/v3/sales/reclaim.d.ts.map +1 -0
- package/dist/v3/sales/reclaim.js +57 -0
- package/dist/v3/sales/rows.d.ts +55 -0
- package/dist/v3/sales/rows.d.ts.map +1 -0
- package/dist/v3/sales/rows.js +98 -0
- package/dist/v3/sales/seller.d.ts +39 -0
- package/dist/v3/sales/seller.d.ts.map +1 -0
- package/dist/v3/sales/seller.js +67 -0
- package/dist/v3/stage1.d.ts +204 -0
- package/dist/v3/stage1.d.ts.map +1 -0
- package/dist/v3/stage1.js +575 -0
- package/package.json +33 -4
package/dist/essey.d.ts
ADDED
|
@@ -0,0 +1,866 @@
|
|
|
1
|
+
import type { Signer } from "@mysten/sui/cryptography";
|
|
2
|
+
import { type CoinKey, type V3Config } from "./config.ts";
|
|
3
|
+
import { type KeeperActions, type KeeperIo, type KeeperSection, type KeeperVia } from "./keeper.ts";
|
|
4
|
+
import { type Fetch } from "./network.ts";
|
|
5
|
+
import { type Role } from "./v3/credential/issue.ts";
|
|
6
|
+
import { type RelayBody } from "./v3/bodies.ts";
|
|
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
|
+
import { type KeeperTerms } from "./v3/keeper-payload.ts";
|
|
9
|
+
import { type FeeCommitInput } from "./v3/fees.ts";
|
|
10
|
+
import { type MarketFields, type MarketRates } from "./v3/market.ts";
|
|
11
|
+
import type { Reading } from "./v3/collateral/math.ts";
|
|
12
|
+
import type { LoanReader } from "./v3/collateral/scan.ts";
|
|
13
|
+
import { type LoanOpening, type LoanOpenParams, type MyLoanView, type MySaleView, type OpenRequest, type OpenSale, type PoolPosition, type PoolView, type SaleOpenParams } from "./v3/stage1.ts";
|
|
14
|
+
import { type NoteSummary, type PoolEvents } from "./v3/notes/scan.ts";
|
|
15
|
+
import type { Prover } from "./v3/prover.ts";
|
|
16
|
+
import { type Landed, type Queued, type RelayerInfo, type TicketState } from "./v3/relay/client.ts";
|
|
17
|
+
export type ConnectOptions = {
|
|
18
|
+
network: "testnet";
|
|
19
|
+
/** A mode 600 file this SDK creates. It holds the member secrets and the credential. */
|
|
20
|
+
statePath: string;
|
|
21
|
+
/** The deployment record, or the `GET /v3/config` URL of a v3api, which also names the v3api origin. */
|
|
22
|
+
config: V3Config | string;
|
|
23
|
+
/** 32 bytes the note keys and the deposit signers derive from. Absent, one is drawn and kept in the state file. */
|
|
24
|
+
seed?: Uint8Array;
|
|
25
|
+
relayer?: "clear" | "onion" | string;
|
|
26
|
+
submitDelayMs?: [number, number];
|
|
27
|
+
};
|
|
28
|
+
/** What the SDK cannot yet do alone: proving and reading the chain are supplied by the caller. */
|
|
29
|
+
export type EsseyIo = {
|
|
30
|
+
fetch?: Fetch;
|
|
31
|
+
/** Unix milliseconds; `Date.now` when absent. A credential's expiry is checked against it. */
|
|
32
|
+
now?: () => number;
|
|
33
|
+
prover?: Prover;
|
|
34
|
+
/** `fee_commit` of the coin's on-chain `FeeConfig`. */
|
|
35
|
+
readFeeCommit?: (coin: CoinKey) => Promise<bigint>;
|
|
36
|
+
readMarket?: (market: string) => Promise<MarketFields>;
|
|
37
|
+
/** Every `NewCommitment` and `NewNullifier` of the coin's pool. */
|
|
38
|
+
readPool?: (coin: CoinKey) => Promise<PoolEvents>;
|
|
39
|
+
/** `initialSharedVersion` of a shared object, as a decimal string. */
|
|
40
|
+
readSharedVersion?: (objectId: string) => Promise<string>;
|
|
41
|
+
/** Puts `value` of the coin in `sender`'s address balance. The SDK never holds the wallet that pays it. */
|
|
42
|
+
fundDeposit?: (p: {
|
|
43
|
+
coin: CoinKey;
|
|
44
|
+
value: bigint;
|
|
45
|
+
sender: string;
|
|
46
|
+
}) => Promise<void>;
|
|
47
|
+
/** NEEDS-BORIS: true once `address` has held a balance or sent a transaction. Required with a `seed` option. */
|
|
48
|
+
readAddressUsed?: (address: string) => Promise<boolean>;
|
|
49
|
+
keeper?: KeeperIo;
|
|
50
|
+
/** Proved `loan_open` fields. The SDK builds the envelope from them. Absent, the SDK plans the open itself. */
|
|
51
|
+
planLoanOpen?: (p: LoanOpenParams) => Promise<Parameters<typeof openLoan>[0]>;
|
|
52
|
+
/** Seals `data` under key id `id` to the deployment's Seal set, AAD `aad` (default `id`); returns the EncryptedObject. */
|
|
53
|
+
sealEncrypt?: (p: {
|
|
54
|
+
id: Uint8Array;
|
|
55
|
+
data: Uint8Array;
|
|
56
|
+
aad?: Uint8Array;
|
|
57
|
+
pkg?: SealPackage;
|
|
58
|
+
}) => Promise<Uint8Array>;
|
|
59
|
+
/**
|
|
60
|
+
* Opens `sealed` with a session key the io holds. `approve` takes that session's address and returns the
|
|
61
|
+
* `seal_approve*` call the key servers dry-run; the SDK proves the pass inside it. With `signer`, the session
|
|
62
|
+
* key must be made by it: a badge approve passes only for its holder (`keeper.move:172`).
|
|
63
|
+
*/
|
|
64
|
+
sealDecrypt?: (p: {
|
|
65
|
+
sealed: Uint8Array;
|
|
66
|
+
approve: (viewer: string) => Promise<SealApprove>;
|
|
67
|
+
pkg?: SealPackage;
|
|
68
|
+
signer?: Signer;
|
|
69
|
+
}) => Promise<Uint8Array>;
|
|
70
|
+
/** Seal's derived keys for `id` under `approve`, by key server object id (48-byte G1 each), threshold many at least. */
|
|
71
|
+
sealDerivedKeys?: (p: {
|
|
72
|
+
id: Uint8Array;
|
|
73
|
+
approve: (viewer: string) => Promise<SealApprove>;
|
|
74
|
+
pkg?: SealPackage;
|
|
75
|
+
signer?: Signer;
|
|
76
|
+
}) => Promise<Map<string, Uint8Array>>;
|
|
77
|
+
/** The `keeper::Badge` a digest created, its Move fields as JSON, or null when it created none. */
|
|
78
|
+
readBadge?: (digest: string) => Promise<{
|
|
79
|
+
id: string;
|
|
80
|
+
json: unknown;
|
|
81
|
+
} | null>;
|
|
82
|
+
/** The `priceUpdate` bytes a market's price kinds take: a Pyth update, or `[0]` for a stand-in market. */
|
|
83
|
+
priceUpdate?: (market: string) => Promise<Uint8Array>;
|
|
84
|
+
/** The loan id created by a digest, or null when the digest created none. */
|
|
85
|
+
readCreated?: (digest: string) => Promise<string | null>;
|
|
86
|
+
readLoans?: LoanReader;
|
|
87
|
+
/** `round` is the current `Round` dynamic field. The loan JSON does not inline it. */
|
|
88
|
+
readLoan?: (id: string) => Promise<{
|
|
89
|
+
json: unknown;
|
|
90
|
+
round?: unknown;
|
|
91
|
+
} | null>;
|
|
92
|
+
readPrice?: (marketId: string) => Promise<Reading>;
|
|
93
|
+
/** The `price::Reading` the market's oracle builds in the next transaction, field by field. */
|
|
94
|
+
readReading?: (marketId: string) => Promise<{
|
|
95
|
+
oracle: string;
|
|
96
|
+
feedId: string;
|
|
97
|
+
spot: bigint;
|
|
98
|
+
ema: bigint;
|
|
99
|
+
expo: bigint;
|
|
100
|
+
publishS: bigint;
|
|
101
|
+
}>;
|
|
102
|
+
/** The seizing call a LIQUIDATED or DEFAULTED loan ended with, and the `p_spot` it claimed. */
|
|
103
|
+
readSeizure?: (loanId: string) => Promise<{
|
|
104
|
+
mode: "liquidate" | "default" | "fault";
|
|
105
|
+
pSpot: bigint;
|
|
106
|
+
}>;
|
|
107
|
+
/** The lender rows `[lEx, lEy, lCt]` of the loan's latest TOPUP delivery, or null when it was never topped up. */
|
|
108
|
+
readTopupDelivery?: (loanId: string) => Promise<[bigint, bigint, bigint] | null>;
|
|
109
|
+
/** The sealed bytes of the loan's current keeper ciphertext, as the call that wrote it took them. */
|
|
110
|
+
readKeeperCt?: (loanId: string) => Promise<Uint8Array>;
|
|
111
|
+
/** The `now_s` the loan's settle call took, from which its maturity follows. */
|
|
112
|
+
readSettleTime?: (loanId: string) => Promise<bigint>;
|
|
113
|
+
/** Own terms already decrypted. Checked against the loan's commits; absent means a public view. */
|
|
114
|
+
loanOpening?: (id: string) => Promise<LoanOpening | null>;
|
|
115
|
+
readRooms?: (cursor: string | null) => Promise<{
|
|
116
|
+
rooms: {
|
|
117
|
+
id: string;
|
|
118
|
+
json: unknown;
|
|
119
|
+
}[];
|
|
120
|
+
next?: string | null;
|
|
121
|
+
}>;
|
|
122
|
+
/** The `SaleRoom` fields; each `bids[i].sealed` is the EncryptedObject's bytes in base64, as `readLoan` gives offers. */
|
|
123
|
+
readRoom?: (id: string) => Promise<{
|
|
124
|
+
json: unknown;
|
|
125
|
+
} | null>;
|
|
126
|
+
/** The `ItemVault` fields: `room_id`, `room_field` and `claim`. */
|
|
127
|
+
readVault?: (id: string) => Promise<{
|
|
128
|
+
json: unknown;
|
|
129
|
+
} | null>;
|
|
130
|
+
roomBounds?: (id: string) => Promise<{
|
|
131
|
+
lo: bigint;
|
|
132
|
+
hi: bigint;
|
|
133
|
+
salt: bigint;
|
|
134
|
+
} | null>;
|
|
135
|
+
/** Signs and pays `membership::from_proof` then `sale_room::open` as the item's owner; this SDK does not sign. */
|
|
136
|
+
submitSaleOpen?: (tx: SaleOpenTx) => Promise<{
|
|
137
|
+
id: string;
|
|
138
|
+
digest: string;
|
|
139
|
+
ticket: string;
|
|
140
|
+
}>;
|
|
141
|
+
/** Moves the item to the sponsored open's fresh sender, resolving once `readObjectRef` reads it there. */
|
|
142
|
+
deliverSaleItem?: (p: {
|
|
143
|
+
item: {
|
|
144
|
+
id: string;
|
|
145
|
+
type: string;
|
|
146
|
+
};
|
|
147
|
+
sender: string;
|
|
148
|
+
}) => Promise<void>;
|
|
149
|
+
/** An object's current version and digest, and its owner address, null unless an address owns it. */
|
|
150
|
+
readObjectRef?: (id: string) => Promise<{
|
|
151
|
+
version: string;
|
|
152
|
+
digest: string;
|
|
153
|
+
owner: string | null;
|
|
154
|
+
}>;
|
|
155
|
+
readSaleOpened?: (digest: string) => Promise<{
|
|
156
|
+
room: string;
|
|
157
|
+
}>;
|
|
158
|
+
};
|
|
159
|
+
/** The arguments of a seller-paid open. `item.type` is the struct tag of `T`, named by the package's original id. */
|
|
160
|
+
export type SaleOpenTx = {
|
|
161
|
+
coin: CoinKey;
|
|
162
|
+
item: {
|
|
163
|
+
id: string;
|
|
164
|
+
type: string;
|
|
165
|
+
};
|
|
166
|
+
saleKey: bigint;
|
|
167
|
+
sellerCommit: bigint;
|
|
168
|
+
sellerItemFallback: bigint;
|
|
169
|
+
boundsCommit: bigint;
|
|
170
|
+
closeMs: bigint;
|
|
171
|
+
finishByMs: bigint;
|
|
172
|
+
maxBids: number;
|
|
173
|
+
/** `membership::from_proof` at nonce 0 in the SPEND domain: `room` is `id_of_key(saleKey)`, `n0` the open action. */
|
|
174
|
+
pass: {
|
|
175
|
+
tag: bigint;
|
|
176
|
+
expiryMs: bigint;
|
|
177
|
+
proof: Uint8Array;
|
|
178
|
+
room: string;
|
|
179
|
+
n0: bigint;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
/** What a bidder keeps from `sales.bid`: the bid's secrets derive from the note key at `noteIndex`. */
|
|
183
|
+
export type BidRecord = {
|
|
184
|
+
room: string;
|
|
185
|
+
noteIndex: number;
|
|
186
|
+
v: bigint;
|
|
187
|
+
amount: bigint;
|
|
188
|
+
};
|
|
189
|
+
/** The seller's room secrets, chosen at open. `sellerSk` must be a note key of this seed so the sale's proceeds scan. */
|
|
190
|
+
export type SellerKeys = {
|
|
191
|
+
sellerSk: bigint;
|
|
192
|
+
sellerSecret: bigint;
|
|
193
|
+
};
|
|
194
|
+
/** What a seller keeps from `sales.open`: the keys and bounds opening derive from the note key at `noteIndex`. */
|
|
195
|
+
export type SaleRecord = {
|
|
196
|
+
room: string;
|
|
197
|
+
noteIndex: number;
|
|
198
|
+
seller: SellerKeys;
|
|
199
|
+
bounds: {
|
|
200
|
+
lo: bigint;
|
|
201
|
+
hi: bigint;
|
|
202
|
+
salt: bigint;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
/** The package whose original id names a Seal key id: `loan` (default) or `sale`, whose `pin_bid` checks it. */
|
|
206
|
+
export type SealPackage = "loan" | "sale";
|
|
207
|
+
export type SealArg = {
|
|
208
|
+
pure: "vector<u8>" | "u256" | "u64";
|
|
209
|
+
value: string;
|
|
210
|
+
} | {
|
|
211
|
+
object: string;
|
|
212
|
+
};
|
|
213
|
+
export type SealApprove = {
|
|
214
|
+
target: string;
|
|
215
|
+
typeArguments: string[];
|
|
216
|
+
args: SealArg[];
|
|
217
|
+
};
|
|
218
|
+
/** What a lender keeps from `lend` to collect after repay: no chain read gives these back once the loan settles. */
|
|
219
|
+
/** `borrowerPk` is the request's, kept because the request stops opening once bidding ends; a FAULT seizure needs it. */
|
|
220
|
+
export type OfferRecord = {
|
|
221
|
+
noteIndex: number;
|
|
222
|
+
principal: bigint;
|
|
223
|
+
rateBps: bigint;
|
|
224
|
+
termMs: bigint;
|
|
225
|
+
borrowerPk?: bigint;
|
|
226
|
+
};
|
|
227
|
+
/** A bidding loan's request as its sealed copy opens, checked against the loan's commits. */
|
|
228
|
+
export type LoanRequest = {
|
|
229
|
+
loan: string;
|
|
230
|
+
loanKey: bigint;
|
|
231
|
+
round: bigint;
|
|
232
|
+
seq: bigint;
|
|
233
|
+
pair: [CoinKey, CoinKey];
|
|
234
|
+
poolL: string;
|
|
235
|
+
principal: bigint;
|
|
236
|
+
maxRateBps: bigint;
|
|
237
|
+
termMs: bigint;
|
|
238
|
+
borrowerPk: bigint;
|
|
239
|
+
collAmt: bigint;
|
|
240
|
+
collBlind: bigint;
|
|
241
|
+
collNote: bigint;
|
|
242
|
+
salt: bigint;
|
|
243
|
+
closeMs: bigint;
|
|
244
|
+
};
|
|
245
|
+
/** Nothing has reached the relayer until `submit` is called. */
|
|
246
|
+
export type OpenQuote = {
|
|
247
|
+
rates: MarketRates;
|
|
248
|
+
submit(): Promise<Landed | Queued>;
|
|
249
|
+
};
|
|
250
|
+
export type CredentialInfo = {
|
|
251
|
+
role: Role;
|
|
252
|
+
expiryMs: bigint;
|
|
253
|
+
epoch: bigint;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* A deposit whose value may sit at its fresh sender's address: on disk before `fundDeposit`, gone once it lands.
|
|
257
|
+
* `signed` is every note it signed for. The ciphertext is drawn fresh, so the same seed depositing the same
|
|
258
|
+
* value at the same index elsewhere makes the same commitment but never the same `enc`.
|
|
259
|
+
*/
|
|
260
|
+
type Stranded = {
|
|
261
|
+
coin: CoinKey;
|
|
262
|
+
signer: number;
|
|
263
|
+
note: number;
|
|
264
|
+
value: bigint;
|
|
265
|
+
signed: SignedNote[];
|
|
266
|
+
};
|
|
267
|
+
type SignedNote = {
|
|
268
|
+
commitment: bigint;
|
|
269
|
+
enc: string;
|
|
270
|
+
};
|
|
271
|
+
type Outcome = {
|
|
272
|
+
outcome: "landed";
|
|
273
|
+
digest: string;
|
|
274
|
+
} | {
|
|
275
|
+
outcome: "unconfirmed";
|
|
276
|
+
digest: string;
|
|
277
|
+
} | {
|
|
278
|
+
outcome: "already landed";
|
|
279
|
+
} | {
|
|
280
|
+
outcome: "record gone";
|
|
281
|
+
} | {
|
|
282
|
+
outcome: "unfunded";
|
|
283
|
+
} | {
|
|
284
|
+
outcome: "retry_after";
|
|
285
|
+
atMs?: number;
|
|
286
|
+
error: unknown;
|
|
287
|
+
} | {
|
|
288
|
+
outcome: "failed";
|
|
289
|
+
error: unknown;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* What `recoverStranded` did with one record. Only "landed" and "already landed" take it off the list, and only
|
|
293
|
+
* once a note it signed is in the pool. "unconfirmed": the relayer answered `digest` but the pool does not hold
|
|
294
|
+
* the note, so the record stays and the next call finds it landed or sends it again.
|
|
295
|
+
* "retry_after": the relayer answered `RATE_LIMITED`, whose window has ended by `atMs`, or `SPONSOR_REFUSED`,
|
|
296
|
+
* which has no `atMs`: it remembers the sender for a time, or its sponsor rules refuse the deposit
|
|
297
|
+
* (`services/relayer-v3/src/sponsor.ts:55-68`), which no wait clears. The reply does not say which.
|
|
298
|
+
*/
|
|
299
|
+
export type Recovered = Stranded & Outcome;
|
|
300
|
+
/** A loan call takes the body builder's fields. `wait` defaults to true. A paid kind's fee comes from config. */
|
|
301
|
+
type LoanCall<T extends {
|
|
302
|
+
wait: boolean;
|
|
303
|
+
}> = Omit<T, "wait" | "relayerFee"> & {
|
|
304
|
+
wait?: boolean;
|
|
305
|
+
};
|
|
306
|
+
export declare class Essey {
|
|
307
|
+
readonly config: V3Config;
|
|
308
|
+
private readonly statePath;
|
|
309
|
+
private readonly apiOrigin;
|
|
310
|
+
private readonly fetch;
|
|
311
|
+
private readonly io;
|
|
312
|
+
private readonly relay;
|
|
313
|
+
private readonly relayerBase;
|
|
314
|
+
private readonly seedOption;
|
|
315
|
+
readonly credential: {
|
|
316
|
+
obtain(o?: {
|
|
317
|
+
invite?: string;
|
|
318
|
+
role?: Role;
|
|
319
|
+
}): Promise<CredentialInfo>;
|
|
320
|
+
status(): CredentialInfo | null;
|
|
321
|
+
/** D-SPEC §6.2:574. The stored credential, or nothing when none has been issued. */
|
|
322
|
+
list(): Promise<CredentialInfo[]>;
|
|
323
|
+
/** D-SPEC §6.2:574. Re-checks the issuer signature. A flipped field is tampered view data. */
|
|
324
|
+
view(): Promise<CredentialInfo>;
|
|
325
|
+
renew(): Promise<CredentialInfo>;
|
|
326
|
+
};
|
|
327
|
+
readonly fees: {
|
|
328
|
+
params(coin: CoinKey): Promise<FeeCommitInput>;
|
|
329
|
+
};
|
|
330
|
+
readonly relayer: {
|
|
331
|
+
info(): Promise<RelayerInfo>;
|
|
332
|
+
status(ticket: string): Promise<TicketState>;
|
|
333
|
+
};
|
|
334
|
+
readonly markets: {
|
|
335
|
+
rates(market: string): Promise<MarketRates>;
|
|
336
|
+
};
|
|
337
|
+
readonly loans: {
|
|
338
|
+
prepareOpen(body: RelayBody): Promise<OpenQuote>;
|
|
339
|
+
/**
|
|
340
|
+
* D-SPEC §6.2:588 when `loanCoin` is set: builds `v3.loans.open` and returns the new id.
|
|
341
|
+
* Otherwise the V3-050 envelope submit, which takes the proved body.
|
|
342
|
+
*/
|
|
343
|
+
open(p: LoanCall<OpenBody> | LoanOpenParams): Promise<Landed | ({
|
|
344
|
+
id: string;
|
|
345
|
+
} & Landed)>;
|
|
346
|
+
offer(p: LoanCall<OfferBody>): Promise<Landed>;
|
|
347
|
+
/** A-D7: a member's read of a bidding loan's sealed request, checked against its commits. */
|
|
348
|
+
request(id: string): Promise<LoanRequest>;
|
|
349
|
+
/** Offers the requested principal at `rateBps` from own notes of the loan coin. */
|
|
350
|
+
lend(p: {
|
|
351
|
+
loan: string;
|
|
352
|
+
rateBps: number;
|
|
353
|
+
}): Promise<Landed & {
|
|
354
|
+
offer: OfferRecord;
|
|
355
|
+
}>;
|
|
356
|
+
/** The lender, after repay: moves the repaid note, which no ciphertext names, into an ordinary own note. */
|
|
357
|
+
collect(p: {
|
|
358
|
+
loan: string;
|
|
359
|
+
offer: OfferRecord;
|
|
360
|
+
}): Promise<Landed & {
|
|
361
|
+
value: bigint;
|
|
362
|
+
}>;
|
|
363
|
+
/** The lender, after LIQUIDATE or DEFAULT: moves its share of the seized collateral into an ordinary own note. */
|
|
364
|
+
collectSeized(p: {
|
|
365
|
+
loan: string;
|
|
366
|
+
offer: OfferRecord;
|
|
367
|
+
}): Promise<Landed & {
|
|
368
|
+
value: bigint;
|
|
369
|
+
}>;
|
|
370
|
+
/** The borrower, after LIQUIDATE or DEFAULT: moves the collateral the seizure left over into an ordinary own note. */
|
|
371
|
+
collectSurplus(p: {
|
|
372
|
+
loan: string;
|
|
373
|
+
terms: KeeperTerms;
|
|
374
|
+
borrowerPk: bigint;
|
|
375
|
+
collAmt: bigint;
|
|
376
|
+
}): Promise<Landed & {
|
|
377
|
+
value: bigint;
|
|
378
|
+
}>;
|
|
379
|
+
/**
|
|
380
|
+
* The borrower, after close: opens every active offer and settles on the lowest eligible rate. The terms are
|
|
381
|
+
* what `payBack` needs; keep them private.
|
|
382
|
+
*/
|
|
383
|
+
accept(id: string): Promise<Landed & {
|
|
384
|
+
rateBps: bigint;
|
|
385
|
+
terms: KeeperTerms;
|
|
386
|
+
borrowerPk: bigint;
|
|
387
|
+
collAmt: bigint;
|
|
388
|
+
}>;
|
|
389
|
+
/** The lender takes back the principal its offer locked, once the round resolved without it (cancel, or another offer won). */
|
|
390
|
+
reclaimOffer(p: {
|
|
391
|
+
loan: string;
|
|
392
|
+
offer: OfferRecord;
|
|
393
|
+
round?: bigint;
|
|
394
|
+
}): Promise<Landed>;
|
|
395
|
+
/** Seizes an underwater loan; the caller holds the opening and terms, as a keeper does after its Seal read. */
|
|
396
|
+
liquidate(p: {
|
|
397
|
+
loan: string;
|
|
398
|
+
terms: KeeperTerms;
|
|
399
|
+
borrowerPk: bigint;
|
|
400
|
+
collAmt: bigint;
|
|
401
|
+
}): Promise<Landed>;
|
|
402
|
+
/** A keeper seizes an underwater loan from its Seal read of the keeper ciphertext (B §7.2-7.3). */
|
|
403
|
+
keeperLiquidate(p: {
|
|
404
|
+
loan: string;
|
|
405
|
+
via?: KeeperVia;
|
|
406
|
+
}): Promise<Landed>;
|
|
407
|
+
/** The lender seizes a loan a keeper marked FAULT (`liquidation::fault_liquidate`), from its offer and the settle delivery. */
|
|
408
|
+
faultLiquidate(p: {
|
|
409
|
+
loan: string;
|
|
410
|
+
offer: OfferRecord;
|
|
411
|
+
}): Promise<Landed>;
|
|
412
|
+
/** Seizes a loan past maturity plus grace (`liquidation::claim_default`), as `liquidate` otherwise. */
|
|
413
|
+
seizeDefault(p: {
|
|
414
|
+
loan: string;
|
|
415
|
+
terms: KeeperTerms;
|
|
416
|
+
borrowerPk: bigint;
|
|
417
|
+
collAmt: bigint;
|
|
418
|
+
}): Promise<Landed>;
|
|
419
|
+
/** The borrower re-locks its collateral and proves the loan healthy at bucket `k`'s floor until `expiryMs`. */
|
|
420
|
+
heartbeat(p: {
|
|
421
|
+
loan: string;
|
|
422
|
+
terms: KeeperTerms;
|
|
423
|
+
borrowerPk: bigint;
|
|
424
|
+
collAmt: bigint;
|
|
425
|
+
k?: number;
|
|
426
|
+
expiryMs?: bigint;
|
|
427
|
+
}): Promise<Landed>;
|
|
428
|
+
/** The borrower adds `add` from own notes of the collateral coin to the lock of its active loan. */
|
|
429
|
+
topup(p: {
|
|
430
|
+
loan: string;
|
|
431
|
+
terms: KeeperTerms;
|
|
432
|
+
borrowerPk: bigint;
|
|
433
|
+
collAmt: bigint;
|
|
434
|
+
add: bigint;
|
|
435
|
+
/** Through the borrower pass (`topup_by_borrower`): the new keeper ciphertext becomes the retained borrower one. */
|
|
436
|
+
asBorrower?: boolean;
|
|
437
|
+
}): Promise<Landed>;
|
|
438
|
+
/** The borrower of an active loan opens refi round r+1 for a new principal that pays the old `terms.owed`. */
|
|
439
|
+
openRefi(p: {
|
|
440
|
+
loan: string;
|
|
441
|
+
borrowerPk: bigint;
|
|
442
|
+
collAmt: bigint;
|
|
443
|
+
principal: bigint;
|
|
444
|
+
maxRateBps: number;
|
|
445
|
+
termMs: number;
|
|
446
|
+
offerWindowMs: number;
|
|
447
|
+
}): Promise<Landed & {
|
|
448
|
+
round: bigint;
|
|
449
|
+
closeMs: bigint;
|
|
450
|
+
}>;
|
|
451
|
+
/** The borrower takes the lowest eligible offer of its open refi round: the old lender is paid `terms.owed`. */
|
|
452
|
+
settleRefi(p: {
|
|
453
|
+
loan: string;
|
|
454
|
+
terms: KeeperTerms;
|
|
455
|
+
borrowerPk: bigint;
|
|
456
|
+
collAmt: bigint;
|
|
457
|
+
}): Promise<Landed & {
|
|
458
|
+
rateBps: bigint;
|
|
459
|
+
terms: KeeperTerms;
|
|
460
|
+
}>;
|
|
461
|
+
/** The borrower closes its open refi round; the loan stays active on its terms. */
|
|
462
|
+
cancelRefi(id: string): Promise<Landed>;
|
|
463
|
+
/** The borrower cancels its bidding loan (borrower pass over `request::cancel`). */
|
|
464
|
+
cancelOwn(id: string): Promise<Landed>;
|
|
465
|
+
/** The borrower, after close: marks offer `seq` inactive when its sealed plaintext does not open its commit. */
|
|
466
|
+
slash(p: {
|
|
467
|
+
loan: string;
|
|
468
|
+
seq: number;
|
|
469
|
+
}): Promise<Landed>;
|
|
470
|
+
/** A keeper: marks a loan whose retained borrower keeper ciphertext does not open its lock (`keeper::prove_ct_fault`). */
|
|
471
|
+
fault(p: {
|
|
472
|
+
loan: string;
|
|
473
|
+
via?: KeeperVia;
|
|
474
|
+
}): Promise<Landed>;
|
|
475
|
+
/** The borrower takes the collateral of its cancelled loan back to a fresh own note. */
|
|
476
|
+
reclaimCollateral(p: {
|
|
477
|
+
loan: string;
|
|
478
|
+
collAmt: bigint;
|
|
479
|
+
}): Promise<Landed>;
|
|
480
|
+
/** The borrower, after repay: the whole collateral back to its own key, and the loan closes. */
|
|
481
|
+
release(p: {
|
|
482
|
+
loan: string;
|
|
483
|
+
terms: KeeperTerms;
|
|
484
|
+
borrowerPk: bigint;
|
|
485
|
+
collAmt: bigint;
|
|
486
|
+
}): Promise<Landed>;
|
|
487
|
+
/** The borrower repays `terms.owed` from own notes of the loan coin into the lender's note. */
|
|
488
|
+
payBack(p: {
|
|
489
|
+
loan: string;
|
|
490
|
+
terms: KeeperTerms;
|
|
491
|
+
borrowerPk: bigint;
|
|
492
|
+
}): Promise<Landed>;
|
|
493
|
+
settle(p: LoanCall<SettleBody>): Promise<Landed>;
|
|
494
|
+
repay(p: LoanCall<RepayBody>): Promise<Landed>;
|
|
495
|
+
reclaim(p: LoanCall<ReclaimBody>): Promise<Landed>;
|
|
496
|
+
reclaimColl(p: LoanCall<ReclaimCollBody>): Promise<Landed>;
|
|
497
|
+
cancel(p: LoanCall<CancelBody>): Promise<Landed>;
|
|
498
|
+
claimDefault(p: LoanCall<ClaimDefaultBody>): Promise<Landed>;
|
|
499
|
+
/** D-SPEC §6.2:589. */
|
|
500
|
+
list(): Promise<OpenRequest[]>;
|
|
501
|
+
/** D-SPEC §6.2:589. Decrypts own terms when `loanOpening` has them. */
|
|
502
|
+
view(id: string): Promise<MyLoanView>;
|
|
503
|
+
};
|
|
504
|
+
readonly notes: {
|
|
505
|
+
faucet(coin: CoinKey): Promise<Landed>;
|
|
506
|
+
deposit(coin: CoinKey, amount: bigint, o?: {
|
|
507
|
+
denominations?: boolean;
|
|
508
|
+
}): Promise<Landed[]>;
|
|
509
|
+
scan(coin?: CoinKey): Promise<NoteSummary>;
|
|
510
|
+
/** D-SPEC §6.2:582. Opens one note ciphertext. */
|
|
511
|
+
open(coin: CoinKey, index: number): Promise<PoolPosition>;
|
|
512
|
+
/** D-SPEC §6.2:582. Unspent notes. One coin, or all three when omitted. */
|
|
513
|
+
list(coin?: CoinKey): Promise<PoolPosition[]>;
|
|
514
|
+
/** D-SPEC §6.2:582. One note, with the commitment it matched. */
|
|
515
|
+
view(coin: CoinKey, index: number): Promise<PoolView>;
|
|
516
|
+
withdraw(coin: CoinKey, amount: bigint, to: string): Promise<Landed>;
|
|
517
|
+
/** A one-use address another member pays with `transfer`: a fresh note key of this seed and its enc key. */
|
|
518
|
+
receiveAddress(): string;
|
|
519
|
+
/** Pays `amount` into a note only the holder of `to` (a `receiveAddress`) can open. No public amount moves. */
|
|
520
|
+
transfer(coin: CoinKey, amount: bigint, to: string): Promise<Landed>;
|
|
521
|
+
exit(coin: CoinKey, to: string): Promise<Landed>;
|
|
522
|
+
/** NEEDS-BORIS: tries every deposit whose value may sit at its fresh sender, one outcome per record. */
|
|
523
|
+
recoverStranded(): Promise<Recovered[]>;
|
|
524
|
+
};
|
|
525
|
+
/** D-SPEC §6.2:598-600. Sealed sale rooms. */
|
|
526
|
+
readonly sales: {
|
|
527
|
+
/** Proves the seller pass over the open and hands it to `submitSaleOpen`. Keep the record. */
|
|
528
|
+
open(p: SaleOpenParams): Promise<{
|
|
529
|
+
id: string;
|
|
530
|
+
sale: SaleRecord;
|
|
531
|
+
} & Landed>;
|
|
532
|
+
list(): Promise<OpenSale[]>;
|
|
533
|
+
view(id: string): Promise<MySaleView>;
|
|
534
|
+
/** Locks `amount` from own notes of the room's coin behind a sealed bid of `v`. Keep the record. */
|
|
535
|
+
bid(p: {
|
|
536
|
+
room: string;
|
|
537
|
+
v: bigint;
|
|
538
|
+
amount: bigint;
|
|
539
|
+
}): Promise<Landed & {
|
|
540
|
+
bid: BidRecord;
|
|
541
|
+
}>;
|
|
542
|
+
/** The seller, after close: opens every active bid and settles on the highest in its bounds. */
|
|
543
|
+
finish(p: {
|
|
544
|
+
room: string;
|
|
545
|
+
vault: string;
|
|
546
|
+
seller: SellerKeys;
|
|
547
|
+
bounds: {
|
|
548
|
+
lo: bigint;
|
|
549
|
+
hi: bigint;
|
|
550
|
+
salt: bigint;
|
|
551
|
+
};
|
|
552
|
+
}): Promise<Landed>;
|
|
553
|
+
/** The seller, after close: marks bid `seq` inactive when its sealed plaintext does not open its commit and lock. */
|
|
554
|
+
slash(p: {
|
|
555
|
+
room: string;
|
|
556
|
+
seq: number;
|
|
557
|
+
}): Promise<Landed>;
|
|
558
|
+
/** Anyone, once the finish window passed unsettled: the item returns to the seller's fallback claim. */
|
|
559
|
+
expire(p: {
|
|
560
|
+
room: string;
|
|
561
|
+
vault: string;
|
|
562
|
+
}): Promise<Landed>;
|
|
563
|
+
/** A bidder, once the room ended: its deposit back, or with `residual` the winner's change. */
|
|
564
|
+
reclaim(p: {
|
|
565
|
+
room: string;
|
|
566
|
+
bid: BidRecord;
|
|
567
|
+
what?: "lock" | "residual";
|
|
568
|
+
}): Promise<Landed & {
|
|
569
|
+
value: bigint;
|
|
570
|
+
}>;
|
|
571
|
+
/** The winner (its bid record) or the seller (its keys) sends the vault's item to `recipient`. */
|
|
572
|
+
claim(p: {
|
|
573
|
+
vault: string;
|
|
574
|
+
recipient: string;
|
|
575
|
+
bid?: BidRecord;
|
|
576
|
+
seller?: SellerKeys;
|
|
577
|
+
}): Promise<Landed>;
|
|
578
|
+
/** The seller, before any bid: its pass over the room's next "cancel" action. */
|
|
579
|
+
cancel(p: {
|
|
580
|
+
room: string;
|
|
581
|
+
vault: string;
|
|
582
|
+
}): Promise<Landed>;
|
|
583
|
+
};
|
|
584
|
+
readonly keeper: KeeperSection & KeeperActions;
|
|
585
|
+
private constructor();
|
|
586
|
+
static connect(o: ConnectOptions, io?: EsseyIo): Promise<Essey>;
|
|
587
|
+
private relayClient;
|
|
588
|
+
private relayerAddress;
|
|
589
|
+
private sponsoring;
|
|
590
|
+
private sponsorRelayer;
|
|
591
|
+
private api;
|
|
592
|
+
private info;
|
|
593
|
+
/** A seed option never works on a file that stores another seed. */
|
|
594
|
+
private ownSeed;
|
|
595
|
+
/**
|
|
596
|
+
* Every read-modify-write of the state file: re-read and written under the lock, with no await inside, so a
|
|
597
|
+
* change made by another call or process meanwhile is never written over. A seed stored meanwhile by a
|
|
598
|
+
* seedless open of the same file refuses a seed option's write here, before it changes anything.
|
|
599
|
+
*/
|
|
600
|
+
private update;
|
|
601
|
+
/** The secrets and the slot are on disk before the issuer sees the commitment, so a pinned slot is never lost. */
|
|
602
|
+
private obtain;
|
|
603
|
+
private renew;
|
|
604
|
+
private issue;
|
|
605
|
+
/** The opening for one coin, returned only after it matches the commit read from chain (D §5.4). */
|
|
606
|
+
private feeParams;
|
|
607
|
+
private rates;
|
|
608
|
+
/**
|
|
609
|
+
* A drawn seed is on disk before any key derived from it is used. A seed option is never stored, so a file
|
|
610
|
+
* that already holds counters or records but no seed was made by one: no new seed is drawn over it.
|
|
611
|
+
*/
|
|
612
|
+
private seed;
|
|
613
|
+
/**
|
|
614
|
+
* The seed may have made notes from another state file, or from this one before it was restored from a
|
|
615
|
+
* backup: the counter resumes past every index the seed has on chain before any is reserved.
|
|
616
|
+
*/
|
|
617
|
+
private keys;
|
|
618
|
+
private addressUsed;
|
|
619
|
+
/** A deposit sender the chain has never seen, so no two deposits share one. */
|
|
620
|
+
private freshSigner;
|
|
621
|
+
/** Write-ahead: a deposit is on disk as stranded before its value moves, and leaves once it has landed. */
|
|
622
|
+
private strand;
|
|
623
|
+
/**
|
|
624
|
+
* Appends to the record on disk, never over it (AUD-V3-124 R2d-1). A fresh deposit never takes over a record
|
|
625
|
+
* already at its sender (R2e-2). A recovery signs nothing once its record is gone, and is refused once another
|
|
626
|
+
* call moved it to another index.
|
|
627
|
+
*/
|
|
628
|
+
private addSigned;
|
|
629
|
+
/** Write-ahead: an index is on disk before anything derived from it leaves this process. */
|
|
630
|
+
private reserve;
|
|
631
|
+
private member;
|
|
632
|
+
private prover;
|
|
633
|
+
/** Pins in the config still need a prover. An empty `circuits` object is the pre-bring-up record. */
|
|
634
|
+
private missingProver;
|
|
635
|
+
private faucet;
|
|
636
|
+
private deposit;
|
|
637
|
+
private depositContext;
|
|
638
|
+
/**
|
|
639
|
+
* The sponsor accepts before any value moves, so a refusal strands nothing. The pass nonce is the sender's
|
|
640
|
+
* index, so a fresh deposit's tag is new to the relayer's per-tag limit. A recovery sends its record's tag
|
|
641
|
+
* again: the relayer refuses it `RATE_LIMITED` until one window after that tag's last sponsorship
|
|
642
|
+
* (`services/relayer-v3/src/server.ts:238,575,586`), and `SPONSOR_REFUSED` while it remembers the sender (`:559-560`).
|
|
643
|
+
*/
|
|
644
|
+
private depositPiece;
|
|
645
|
+
/**
|
|
646
|
+
* One record that cannot land never holds up the others. With no relayer set up, records already in the pool
|
|
647
|
+
* are still cleared; one that would need the relayer refuses the call once every record has been looked at.
|
|
648
|
+
*/
|
|
649
|
+
private recoverStranded;
|
|
650
|
+
/** The tag was last sponsored no later than now, so its window has ended one window from now. */
|
|
651
|
+
private unlanded;
|
|
652
|
+
/**
|
|
653
|
+
* A record leaves only once a note it signed is in the pool. Another note at its index (the same
|
|
654
|
+
* seed on another state file) moves it to a fresh index. An unused sender may still be funded late, or by a
|
|
655
|
+
* deposit running now, so its record stays for the next call.
|
|
656
|
+
*/
|
|
657
|
+
private recoverOne;
|
|
658
|
+
private record;
|
|
659
|
+
/** A state file that cannot be read may hold the record, so it counts as held. */
|
|
660
|
+
private strandedAt;
|
|
661
|
+
/** "already landed" only on a pool match of an entry this call knew; anything else removed the record (R2e-3). */
|
|
662
|
+
private gone;
|
|
663
|
+
/**
|
|
664
|
+
* Re-reads the record under the lock (R2e-1): one a landing removed is never written back, and one another
|
|
665
|
+
* call already moved is not moved again. The new index is on disk before anything derived from it leaves.
|
|
666
|
+
*/
|
|
667
|
+
private reindex;
|
|
668
|
+
private owned;
|
|
669
|
+
private scan;
|
|
670
|
+
private withdraw;
|
|
671
|
+
private receiveAddress;
|
|
672
|
+
private transfer;
|
|
673
|
+
private exit;
|
|
674
|
+
/** js4 with the withdraw field (`src/v3/inputs.ts:39`); the change note's index is on disk before the body leaves. */
|
|
675
|
+
private spend;
|
|
676
|
+
/** A 202 carries no digest (`src/v3/relay/client.ts:100`): the ticket is followed until it lands. */
|
|
677
|
+
private follow;
|
|
678
|
+
/** A kind in `FEE_FREE` sends "0". Every other loan kind sends this pool's configured constant. */
|
|
679
|
+
private coinFee;
|
|
680
|
+
private relayed;
|
|
681
|
+
private paidLoan;
|
|
682
|
+
private freeLoan;
|
|
683
|
+
/** D-SPEC §6.2:574. One credential, or none. A signature that no longer covers the commitment is tampered. */
|
|
684
|
+
private listCredentials;
|
|
685
|
+
/** D-SPEC §6.2:574. */
|
|
686
|
+
private viewCredential;
|
|
687
|
+
private checkedCredential;
|
|
688
|
+
private poolOf;
|
|
689
|
+
/** D-SPEC §6.2:582. */
|
|
690
|
+
private openNote;
|
|
691
|
+
/** D-SPEC §6.2:582. */
|
|
692
|
+
private listNotes;
|
|
693
|
+
/** D-SPEC §6.2:582. */
|
|
694
|
+
private viewNote;
|
|
695
|
+
/** D-SPEC §6.2:588. The envelope is `v3.loans.open`; the id is whatever the digest created. */
|
|
696
|
+
private openRequest;
|
|
697
|
+
/**
|
|
698
|
+
* The borrower's `loan_open`: a CollLock spend of up to two own notes into the lock, the Health OPEN rows, the
|
|
699
|
+
* sealed request and keeper ciphertexts, and the borrower pass. The loan key, the lock blinding and the request
|
|
700
|
+
* salt derive from one reserved note index, so the seed alone reopens the loan.
|
|
701
|
+
*/
|
|
702
|
+
private planOpen;
|
|
703
|
+
/** The coins of the market a loan names, as `C/L` in the deployment record. */
|
|
704
|
+
private pairOf;
|
|
705
|
+
private readRequest;
|
|
706
|
+
/** The lender's `loan_offer`: the principal locked to the round from up to two own notes, its sealed terms pinned. */
|
|
707
|
+
private planOffer;
|
|
708
|
+
/** `seal_policy::seal_approve_offer` for offer `seq`: the borrower's SEAL pass over `seal_offer` bound to the viewer. */
|
|
709
|
+
private offerApprove;
|
|
710
|
+
/**
|
|
711
|
+
* Offer `seq` of the current round, once closed, whose sealed plaintext does not open its commit (`offer::slash`):
|
|
712
|
+
* the borrower asks Seal for the offer key's derived keys under the same policy as its read, and the chain decrypts
|
|
713
|
+
* with them. An honest offer aborts 42_013. No penalty: the lock is reclaimed once the round resolves.
|
|
714
|
+
*/
|
|
715
|
+
private slashOffer;
|
|
716
|
+
/** Threshold many derived keys, each with its server's slot in `config.seal.servers` (`seal_servers::public_keys` order). */
|
|
717
|
+
private pinnedKeys;
|
|
718
|
+
/**
|
|
719
|
+
* B §7.5: the keeper asks Seal for the retained borrower ciphertext's derived keys under the keeper policy, and the
|
|
720
|
+
* chain decrypts with them (`keeper::prove_ct_fault`). A ciphertext that opens its lock and terms aborts 43_212.
|
|
721
|
+
*/
|
|
722
|
+
private ctFault;
|
|
723
|
+
private activeLoan;
|
|
724
|
+
/** Either policy entry for key id `id`; the badge one carries the signer its Seal session must be made by. */
|
|
725
|
+
private keeperApproval;
|
|
726
|
+
private heldBadge;
|
|
727
|
+
/**
|
|
728
|
+
* E-35: a KEEPER pass bound to a fresh deposit signer mints that signer a badge (`keeper.move:73-104`). The relayer
|
|
729
|
+
* sponsors each sender once (`services/relayer-v3/src/server.ts:679-680`), so every mint takes a new signer index.
|
|
730
|
+
*/
|
|
731
|
+
private mintBadge;
|
|
732
|
+
/** Sponsor, check the bytes are this kind from `signer` on the relayer's gas, sign, execute. */
|
|
733
|
+
private sponsoredSend;
|
|
734
|
+
/** `keeper::seal_approve_keeper_proof`: a KEEPER pass for the deployment's keeper registry, bound to the viewer. */
|
|
735
|
+
private keeperApprove;
|
|
736
|
+
/**
|
|
737
|
+
* The PriceInfoObject the keeper policy takes: the market's own feed on a Pyth market. On any other market only
|
|
738
|
+
* the expired-heartbeat and zero-floor branches can pass, and they read no price (`keeper.move` `check_loan`), so
|
|
739
|
+
* the feed of a Pyth market in the deployment stands in for the argument.
|
|
740
|
+
*/
|
|
741
|
+
private keeperPrice;
|
|
742
|
+
/** The borrower's read of offer `seq` after close (`seal_policy::seal_approve_offer`): pass nonce 0 is its open tag. */
|
|
743
|
+
private openOffer;
|
|
744
|
+
/** The borrower's `loan_settle` on round 0: the lowest eligible offer wins, keeper ciphertext v1 carries its terms. */
|
|
745
|
+
private planSettle;
|
|
746
|
+
/** The borrower's `loan_repay`: `owed` to the lender's note by ECDH on its enc key, change back to own key. */
|
|
747
|
+
private planRepay;
|
|
748
|
+
/**
|
|
749
|
+
* The repaid note is `Poseidon(owed, lenderPk, H(DOM_LBLIND, S.x))` with `S = encSk · repay_eph`
|
|
750
|
+
* (`loan_repay.circom`), and a refi payoff the same over a `payoff_eph` pair (`loan_refi.circom`); either ciphertext
|
|
751
|
+
* is filler, so the scan never sees it. It is spent into an own note.
|
|
752
|
+
*/
|
|
753
|
+
private collect;
|
|
754
|
+
/** Spends a note no ciphertext names, found by its commitment, to the receive address. */
|
|
755
|
+
private claimLeaf;
|
|
756
|
+
/** The lender's lock opening at nonce 1: the settle delivery, with the amount the latest TOPUP delivery re-states. */
|
|
757
|
+
private lenderLock;
|
|
758
|
+
/** B §5.5 out0 of a seizure, the lender's, from its lock opening; each heartbeat and TOPUP rolled the blinding one step. */
|
|
759
|
+
private collectSeized;
|
|
760
|
+
/** B §5.5 out1 of a seizure, the borrower's surplus `avail - seize`, from its own opening rolled to the seizing nonce. */
|
|
761
|
+
private collectSurplus;
|
|
762
|
+
/**
|
|
763
|
+
* A seizure leaves the lock's nonce one past the one it folded and `coll_note` as it was. `out` 0 pays
|
|
764
|
+
* `seize - pf - kf` to the lender, 1 pays `avail - seize` to the borrower, each at `outputBlind(blind, out, nonce)`.
|
|
765
|
+
* The split is recomputed from the `p_spot` the seizing call claimed (`io.readSeizure`).
|
|
766
|
+
*/
|
|
767
|
+
private collectFromSeizure;
|
|
768
|
+
/** The seed index whose key is `pk`: the borrower key of a loan this seed opened. */
|
|
769
|
+
private indexOfPk;
|
|
770
|
+
/**
|
|
771
|
+
* Health RELEASE (`liquidation::release`): out0 pays the whole collateral to the borrower key with blinding
|
|
772
|
+
* `outputBlind(collBlind, 0, nonce)`, sealed at that key's index so the scan finds it. No pass: the proof opens the lock.
|
|
773
|
+
*/
|
|
774
|
+
private releaseCollateral;
|
|
775
|
+
/** The seed index a loan this seed opened derives from: its loan key is `Poseidon(sk, blinding, 1)` of that index. */
|
|
776
|
+
private indexOfLoanKey;
|
|
777
|
+
private cancelOwn;
|
|
778
|
+
/** The borrower's pass over `kind` and its args, at the loan's next action nonce. */
|
|
779
|
+
private borrowerPass;
|
|
780
|
+
/**
|
|
781
|
+
* `refi::open_refi`: the request of round r+1 over the lock as it stands, sealed under the loan's request key. The salt
|
|
782
|
+
* derives from the lock's note index and the round, so the seed alone reopens it.
|
|
783
|
+
*/
|
|
784
|
+
private openRefi;
|
|
785
|
+
/**
|
|
786
|
+
* `refi::settle_refi`: the round's offers opened as `planSettle` opens them, the request read back through Seal, the
|
|
787
|
+
* payoff to the old lender's enc key, and a pass bound to the exact reading the market's oracle builds.
|
|
788
|
+
*/
|
|
789
|
+
private settleRefiOwn;
|
|
790
|
+
private cancelRefiOwn;
|
|
791
|
+
/** `reclaim_coll::reclaim_coll` on a CANCELLED loan: the lock's nullifier, the whole collateral to a fresh own note. */
|
|
792
|
+
private reclaimOwnCollateral;
|
|
793
|
+
/** `reclaim::reclaim`: the lender's Lock4 among the round's resolved locks, refunded to a fresh own note. */
|
|
794
|
+
private reclaimOffer;
|
|
795
|
+
/**
|
|
796
|
+
* The lock as it stands: the open blinding at nonce 1, rolled one re-lock per heartbeat (`rollTo` refuses an opening
|
|
797
|
+
* that does not reach the stored `coll_note`).
|
|
798
|
+
*/
|
|
799
|
+
private ownOpening;
|
|
800
|
+
private heartbeatOwn;
|
|
801
|
+
/**
|
|
802
|
+
* TOPUP (`liquidation::topup`, no pass): a CollLock spend of own collateral-coin notes into `add_note` under the
|
|
803
|
+
* loan's lock key, then Health TOPUP re-locks the stored lock and `add_note` into one note. The new keeper
|
|
804
|
+
* ciphertext opens that note at the next nonce.
|
|
805
|
+
*/
|
|
806
|
+
private topupOwn;
|
|
807
|
+
/**
|
|
808
|
+
* LIQUIDATE (`liquidation::liquidate`) by whoever holds the opening and terms: what a keeper reads out of the keeper
|
|
809
|
+
* ciphertext. Claims are the reading itself, inside the 0.5% up window. Outs: lender, borrower remainder, keeper
|
|
810
|
+
* fee to a fresh own note; ciphertexts in insert order `[lender, fee, borrower, keeper]`.
|
|
811
|
+
*/
|
|
812
|
+
private borrowerSeize;
|
|
813
|
+
/**
|
|
814
|
+
* B §7.5 FAULT, the lender: the terms rebuild from its offer keys, the settle `now_s` and the request's borrower key
|
|
815
|
+
* (`settle-plan.ts` terms), and the lock opens from the settle delivery rolled to the lock's nonce.
|
|
816
|
+
*/
|
|
817
|
+
private faultLiquidate;
|
|
818
|
+
/** The keeper reads the current keeper ciphertext under its pass or badge, rolls the opening to the lock's nonce and seizes. */
|
|
819
|
+
private keeperLiquidate;
|
|
820
|
+
/** Any read that does not open the lock and the terms commit throws CT_MISMATCH. */
|
|
821
|
+
private keeperOpening;
|
|
822
|
+
/**
|
|
823
|
+
* A keeper's read of an uncovered loan, sending nothing: LIQUIDATE when the opening is over the line at both prices
|
|
824
|
+
* (`health.circom:282-283`, the check `health()` refuses HEALTH_NOT_UNDERWATER on), FAULT when a read that does not
|
|
825
|
+
* open is of the retained borrower ciphertext, which `prove_ct_fault` judges (`keeper.move:203-243`).
|
|
826
|
+
*/
|
|
827
|
+
private judge;
|
|
828
|
+
/** A seizure by whoever holds the opening and the terms; its keeper fee is sealed to this seed. */
|
|
829
|
+
private seize;
|
|
830
|
+
/** D-SPEC §6.2:589. */
|
|
831
|
+
private listLoans;
|
|
832
|
+
/** D-SPEC §6.2:589. */
|
|
833
|
+
private viewLoan;
|
|
834
|
+
/** The seller keys and bounds salt of the sale opened at note index `index`, so the seed alone reopens them. */
|
|
835
|
+
private saleOpening;
|
|
836
|
+
/** D-SPEC §6.2:599. The seller pass over `sale_room::open_args`, at action nonce 0; the relayer or the callback pays. */
|
|
837
|
+
private openSale;
|
|
838
|
+
/**
|
|
839
|
+
* The sponsored open (E-34): a fresh seed-derived sender receives the item, then signs `from_proof` and `open`
|
|
840
|
+
* while the relayer pays gas. Every reader is checked here, before any proof, reserve or delivery. An open that
|
|
841
|
+
* stops after the delivery leaves the item at that sender, which only its seed can move.
|
|
842
|
+
*/
|
|
843
|
+
private saleSponsor;
|
|
844
|
+
/** D-SPEC §6.2:600. */
|
|
845
|
+
private listSales;
|
|
846
|
+
/** D-SPEC §6.2:600. */
|
|
847
|
+
private viewSale;
|
|
848
|
+
private saleRoom;
|
|
849
|
+
private bidSecrets;
|
|
850
|
+
private nowMs;
|
|
851
|
+
private placeBid;
|
|
852
|
+
/** `sale_room::seal_approve_bid`: the seller's SEAL pass over `seal_bid` of bid `seq`, bound to the viewer, nonce 0. */
|
|
853
|
+
private bidApprove;
|
|
854
|
+
/** `seal_approve_bid` releases keys from close until `finish_by_ms`, for an active bid (`sale_room.move:337-341`). */
|
|
855
|
+
private closedRoom;
|
|
856
|
+
private slashBid;
|
|
857
|
+
private finishSale;
|
|
858
|
+
private indexOfSellerKey;
|
|
859
|
+
private expireSale;
|
|
860
|
+
private cancelSale;
|
|
861
|
+
private reclaimBid;
|
|
862
|
+
private claimItem;
|
|
863
|
+
private prepareOpen;
|
|
864
|
+
}
|
|
865
|
+
export {};
|
|
866
|
+
//# sourceMappingURL=essey.d.ts.map
|