@esseyonsui/sui-sdk-v3 0.3.2 → 0.4.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/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -0
- package/dist/essey.d.ts +157 -131
- package/dist/essey.d.ts.map +1 -1
- package/dist/essey.js +641 -823
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/network.d.ts +2 -0
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +17 -3
- package/dist/v3/collateral/bodies.d.ts +23 -14
- package/dist/v3/collateral/bodies.d.ts.map +1 -1
- package/dist/v3/collateral/bodies.js +42 -35
- package/dist/v3/collateral/ext.d.ts +18 -13
- package/dist/v3/collateral/ext.d.ts.map +1 -1
- package/dist/v3/collateral/ext.js +5 -6
- package/dist/v3/collateral/health.d.ts +16 -10
- package/dist/v3/collateral/health.d.ts.map +1 -1
- package/dist/v3/collateral/health.js +55 -30
- package/dist/v3/collateral/math.d.ts +0 -2
- package/dist/v3/collateral/math.d.ts.map +1 -1
- package/dist/v3/collateral/math.js +0 -5
- package/dist/v3/collateral/openings.d.ts +5 -1
- package/dist/v3/collateral/openings.d.ts.map +1 -1
- package/dist/v3/collateral/openings.js +7 -12
- package/dist/v3/credential/membership.d.ts +16 -2
- package/dist/v3/credential/membership.d.ts.map +1 -1
- package/dist/v3/credential/membership.js +36 -3
- package/dist/v3/domains.d.ts +9 -0
- package/dist/v3/domains.d.ts.map +1 -1
- package/dist/v3/domains.js +5 -0
- package/dist/v3/fees.d.ts +13 -1
- package/dist/v3/fees.d.ts.map +1 -1
- package/dist/v3/fees.js +32 -2
- package/dist/v3/funds.d.ts +34 -0
- package/dist/v3/funds.d.ts.map +1 -0
- package/dist/v3/funds.js +60 -0
- package/dist/v3/keeper-payload.d.ts +29 -7
- package/dist/v3/keeper-payload.d.ts.map +1 -1
- package/dist/v3/keeper-payload.js +33 -22
- package/dist/v3/kinds.d.ts +6 -6
- package/dist/v3/kinds.d.ts.map +1 -1
- package/dist/v3/kinds.js +5 -13
- package/dist/v3/loans/bodies.d.ts +40 -68
- package/dist/v3/loans/bodies.d.ts.map +1 -1
- package/dist/v3/loans/bodies.js +50 -73
- package/dist/v3/loans/offer-payload.d.ts +109 -0
- package/dist/v3/loans/offer-payload.d.ts.map +1 -0
- package/dist/v3/loans/offer-payload.js +207 -0
- package/dist/v3/loans/offer-plan.d.ts +8 -60
- package/dist/v3/loans/offer-plan.d.ts.map +1 -1
- package/dist/v3/loans/offer-plan.js +19 -95
- package/dist/v3/loans/open-plan.d.ts +15 -5
- package/dist/v3/loans/open-plan.d.ts.map +1 -1
- package/dist/v3/loans/open-plan.js +18 -7
- package/dist/v3/loans/reclaim-plan.d.ts +31 -15
- package/dist/v3/loans/reclaim-plan.d.ts.map +1 -1
- package/dist/v3/loans/reclaim-plan.js +63 -32
- package/dist/v3/loans/refi-plan.d.ts +8 -34
- package/dist/v3/loans/refi-plan.d.ts.map +1 -1
- package/dist/v3/loans/refi-plan.js +30 -111
- package/dist/v3/loans/repay-plan.d.ts.map +1 -1
- package/dist/v3/loans/repay-plan.js +2 -2
- package/dist/v3/loans/settle-plan.d.ts +88 -53
- package/dist/v3/loans/settle-plan.d.ts.map +1 -1
- package/dist/v3/loans/settle-plan.js +141 -150
- package/dist/v3/locks.d.ts +21 -0
- package/dist/v3/locks.d.ts.map +1 -0
- package/dist/v3/locks.js +15 -0
- package/dist/v3/memo.d.ts +14 -4
- package/dist/v3/memo.d.ts.map +1 -1
- package/dist/v3/memo.js +14 -7
- package/dist/v3/notes/derive.d.ts +5 -0
- package/dist/v3/notes/derive.d.ts.map +1 -1
- package/dist/v3/notes/derive.js +5 -0
- package/dist/v3/pace.d.ts +0 -1
- package/dist/v3/pace.d.ts.map +1 -1
- package/dist/v3/pace.js +0 -1
- package/dist/v3/pads.d.ts +15 -0
- package/dist/v3/pads.d.ts.map +1 -0
- package/dist/v3/pads.js +25 -0
- package/dist/v3/prover.d.ts +1 -1
- package/dist/v3/prover.d.ts.map +1 -1
- package/dist/v3/prover.js +1 -0
- package/dist/v3/relay/client.d.ts.map +1 -1
- package/dist/v3/relay/client.js +2 -2
- package/dist/v3/sales/auctioneer.d.ts +32 -27
- package/dist/v3/sales/auctioneer.d.ts.map +1 -1
- package/dist/v3/sales/auctioneer.js +67 -108
- package/dist/v3/sales/bid.d.ts +20 -49
- package/dist/v3/sales/bid.d.ts.map +1 -1
- package/dist/v3/sales/bid.js +28 -83
- package/dist/v3/sales/bodies.d.ts +4 -54
- package/dist/v3/sales/bodies.d.ts.map +1 -1
- package/dist/v3/sales/bodies.js +10 -52
- package/dist/v3/sales/claim.d.ts +0 -2
- package/dist/v3/sales/claim.d.ts.map +1 -1
- package/dist/v3/sales/claim.js +6 -8
- package/dist/v3/sales/index.d.ts +0 -1
- package/dist/v3/sales/index.d.ts.map +1 -1
- package/dist/v3/sales/index.js +0 -1
- package/dist/v3/sales/listing.d.ts +8 -6
- package/dist/v3/sales/listing.d.ts.map +1 -1
- package/dist/v3/sales/listing.js +27 -9
- package/dist/v3/sales/open-kind.d.ts +1 -3
- package/dist/v3/sales/open-kind.d.ts.map +1 -1
- package/dist/v3/sales/open-kind.js +2 -3
- package/dist/v3/sales/outcome.d.ts +5 -8
- package/dist/v3/sales/outcome.d.ts.map +1 -1
- package/dist/v3/sales/outcome.js +5 -9
- package/dist/v3/sales/package-gate.d.ts +3 -4
- package/dist/v3/sales/package-gate.d.ts.map +1 -1
- package/dist/v3/sales/package-gate.js +9 -7
- package/dist/v3/sales/rows.d.ts +9 -49
- package/dist/v3/sales/rows.d.ts.map +1 -1
- package/dist/v3/sales/rows.js +17 -91
- package/dist/v3/sales/seller.d.ts +2 -6
- package/dist/v3/sales/seller.d.ts.map +1 -1
- package/dist/v3/sales/seller.js +4 -11
- package/dist/v3/stage1.d.ts +8 -21
- package/dist/v3/stage1.d.ts.map +1 -1
- package/dist/v3/stage1.js +8 -76
- package/package.json +1 -1
- package/dist/v3/loans/lock-round.d.ts +0 -22
- package/dist/v3/loans/lock-round.d.ts.map +0 -1
- package/dist/v3/loans/lock-round.js +0 -20
- package/dist/v3/sales/reclaim.d.ts +0 -46
- package/dist/v3/sales/reclaim.d.ts.map +0 -1
- package/dist/v3/sales/reclaim.js +0 -57
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { COINS, parseConfig, type CoinKey, type V3Config } from "./config.ts";
|
|
2
|
-
export { ESSEY_ERROR_CODES, EsseyError, isEsseyError, type EsseyErrorCode } from "./errors.ts";
|
|
2
|
+
export { ESSEY_ERROR_CODES, EsseyError, isEsseyError, RETIRED_GENERATION_PEERS, type EsseyErrorCode, } from "./errors.ts";
|
|
3
3
|
export { FIXED_HEADERS, fixedHeaders } from "./network.ts";
|
|
4
4
|
export { Essey, type Collected, type ConnectOptions, type Cover, type CredentialInfo, type EsseyIo, type ExitResult, type OpenQuote, type Payees, type Payout, type Pending, type Recovered, type RecoveredRecords, type Renewal, type SaleOpenTx, type SaleRecord, type SpendOptions, type Staged, } from "./essey.ts";
|
|
5
5
|
export type { KeeperActions, KeeperBadge, KeeperIo, KeeperQueue, KeeperSection, KeeperVerdict, KeeperVia, Unjudged, } from "./keeper.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAA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ERROR_CODES, EsseyError, isEsseyError } from "./errors.js";
|
|
2
|
+
export { ESSEY_ERROR_CODES, EsseyError, isEsseyError, RETIRED_GENERATION_PEERS, } from "./errors.js";
|
|
3
3
|
export { FIXED_HEADERS, fixedHeaders } from "./network.js";
|
|
4
4
|
export { Essey, } from "./essey.js";
|
|
5
5
|
export * as v3 from "./v3/index.js";
|
package/dist/network.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export declare function assertTestnet(network: unknown): asserts network is "tes
|
|
|
20
20
|
export declare function serviceUrl(raw: string, what: string): URL;
|
|
21
21
|
export declare const getJson: (fetch: Fetch, url: string) => Promise<JsonReply>;
|
|
22
22
|
export declare const postJson: (fetch: Fetch, url: string, body: unknown) => Promise<JsonReply>;
|
|
23
|
+
/** A POST that may spend: past the connect phase, a failure is RELAY_OUTCOME_UNKNOWN, never SERVICE_UNREACHABLE. */
|
|
24
|
+
export declare const submitJson: (fetch: Fetch, url: string, body: unknown) => Promise<JsonReply>;
|
|
23
25
|
export declare function decimal(value: unknown, what: string): bigint;
|
|
24
26
|
export declare function address(raw: string, what: string): string;
|
|
25
27
|
//# sourceMappingURL=network.d.ts.map
|
package/dist/network.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;;;CAGV,CAAC;AAEX,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE3E,qEAAqE;AACrE,eAAO,MAAM,aAAa;;;;CAA4E,CAAC;AAWvG,iHAAiH;AACjH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAUhD;AAED,MAAM,MAAM,SAAS,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE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OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIzD"}
|
package/dist/network.js
CHANGED
|
@@ -46,12 +46,21 @@ export function serviceUrl(raw, what) {
|
|
|
46
46
|
throw new EsseyError("INVALID_ARGUMENT", `${what} must be https`);
|
|
47
47
|
return url;
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
/** Codes Node's fetch puts on `cause` only before a connection exists (undici lib/core/connect.js, util.js onConnectTimeout). */
|
|
50
|
+
const NOT_SENT = new Set(["ECONNREFUSED", "ENOTFOUND", "EAI_AGAIN", "UND_ERR_CONNECT_TIMEOUT"]);
|
|
51
|
+
const neverSent = (err) => {
|
|
52
|
+
const code = err?.cause?.code;
|
|
53
|
+
return typeof code === "string" && NOT_SENT.has(code);
|
|
54
|
+
};
|
|
55
|
+
const outcomeUnknown = (detail) => new EsseyError("RELAY_OUTCOME_UNKNOWN", "transaction may still land: reconcile it before any new spend", detail);
|
|
56
|
+
async function call(fetch, url, init, spends = false) {
|
|
50
57
|
let res;
|
|
51
58
|
try {
|
|
52
59
|
res = await fetch(url, init);
|
|
53
60
|
}
|
|
54
|
-
catch {
|
|
61
|
+
catch (err) {
|
|
62
|
+
if (spends && !neverSent(err))
|
|
63
|
+
throw outcomeUnknown();
|
|
55
64
|
throw new EsseyError("SERVICE_UNREACHABLE", "service did not answer");
|
|
56
65
|
}
|
|
57
66
|
try {
|
|
@@ -61,17 +70,22 @@ async function call(fetch, url, init) {
|
|
|
61
70
|
return { status: res.status, body: body };
|
|
62
71
|
}
|
|
63
72
|
catch {
|
|
73
|
+
if (spends)
|
|
74
|
+
throw outcomeUnknown({ status: res.status });
|
|
64
75
|
throw new EsseyError("SERVICE_UNREACHABLE", "service answer is not a JSON object", {
|
|
65
76
|
status: res.status,
|
|
66
77
|
});
|
|
67
78
|
}
|
|
68
79
|
}
|
|
69
80
|
export const getJson = (fetch, url) => call(fetch, url, { method: "GET" });
|
|
70
|
-
|
|
81
|
+
const post = (body) => ({
|
|
71
82
|
method: "POST",
|
|
72
83
|
headers: { "content-type": "application/json" },
|
|
73
84
|
body: JSON.stringify(body),
|
|
74
85
|
});
|
|
86
|
+
export const postJson = (fetch, url, body) => call(fetch, url, post(body));
|
|
87
|
+
/** A POST that may spend: past the connect phase, a failure is RELAY_OUTCOME_UNKNOWN, never SERVICE_UNREACHABLE. */
|
|
88
|
+
export const submitJson = (fetch, url, body) => call(fetch, url, post(body), true);
|
|
75
89
|
export function decimal(value, what) {
|
|
76
90
|
if (typeof value !== "string" || !/^(0|[1-9][0-9]*)$/.test(value))
|
|
77
91
|
throw new EsseyError("INVALID_ARGUMENT", `${what} is not a canonical decimal string`);
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { CoinKey } from "../../config.ts";
|
|
2
2
|
import { type Proved, type RelayBody } from "../bodies.ts";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Encs4 } from "./ext.ts";
|
|
4
4
|
import type { HealthStatement } from "./health.ts";
|
|
5
5
|
type Args = Record<string, string>;
|
|
6
|
-
|
|
6
|
+
type Rename = (name: string) => string;
|
|
7
|
+
/** `pads.ts` assertDistinctPads, as the body refusal every hidden entry shares. */
|
|
8
|
+
export declare function distinctPads(...pads: bigint[]): void;
|
|
9
|
+
/**
|
|
10
|
+
* What a CollLock proof spends and makes: `note` is the collateral note at open and the added note in a top-up.
|
|
11
|
+
* `pad0`, `pad1` are the padded circuit's two zero notes (freeze ruling Q1).
|
|
12
|
+
*/
|
|
7
13
|
export type CollLockSpend = {
|
|
8
14
|
root: bigint;
|
|
9
15
|
n0: bigint;
|
|
@@ -11,6 +17,8 @@ export type CollLockSpend = {
|
|
|
11
17
|
note: bigint;
|
|
12
18
|
change: bigint;
|
|
13
19
|
feeNote: bigint;
|
|
20
|
+
pad0: bigint;
|
|
21
|
+
pad1: bigint;
|
|
14
22
|
ephX: bigint;
|
|
15
23
|
ephY: bigint;
|
|
16
24
|
feeCt: bigint;
|
|
@@ -24,36 +32,37 @@ export type HealthBody = {
|
|
|
24
32
|
statement: HealthStatement;
|
|
25
33
|
wait: boolean;
|
|
26
34
|
};
|
|
35
|
+
/** Z1-LEAF-MAP.md: every collateral entry hands `pool::room_apply` four ciphertexts, `enc0..enc3` in leaf order. */
|
|
36
|
+
export declare function encArgs(encs: Encs4): Args;
|
|
37
|
+
export declare function healthArgs(s: HealthStatement, key?: Rename): Args;
|
|
27
38
|
/**
|
|
28
|
-
* The `liquidation::lock_collateral` slice of a `loan_open` envelope
|
|
29
|
-
*
|
|
39
|
+
* The `liquidation::lock_collateral` slice of a `loan_open` envelope: the padded CollLock spend, the four inserted
|
|
40
|
+
* ciphertexts `[change, fee_note, pad0, pad1]`, the keeper ciphertext, the claimed price and the Health OPEN rows.
|
|
41
|
+
* The request half is the loans module's.
|
|
30
42
|
*/
|
|
31
43
|
export declare function openLockArgs(p: {
|
|
32
44
|
lock: CollLockSpend;
|
|
33
|
-
encs:
|
|
45
|
+
encs: Encs4;
|
|
34
46
|
keeperCt: Uint8Array;
|
|
35
47
|
pClaim: bigint;
|
|
36
48
|
statement: HealthStatement;
|
|
37
49
|
priceUpdate: Uint8Array;
|
|
38
50
|
}): Args;
|
|
39
|
-
/** `encs` pairs with `[out0, fee_note]`. */
|
|
51
|
+
/** `encs` pairs with `[out0, fee_note, out1, out2]`. */
|
|
40
52
|
export declare function release(p: HealthBody & {
|
|
41
|
-
encs:
|
|
53
|
+
encs: Encs4;
|
|
42
54
|
}): RelayBody;
|
|
43
55
|
export declare function heartbeat(p: HealthBody & {
|
|
44
|
-
encs:
|
|
56
|
+
encs: Encs4;
|
|
45
57
|
expiryMs: bigint;
|
|
46
58
|
priceUpdate: Uint8Array;
|
|
47
|
-
/** DECISION-R1-MIGRATION A: a retired-package loan, whose pre-R1 `heartbeat` still takes bucket `k` 1. */
|
|
48
|
-
retired?: boolean;
|
|
49
59
|
}): RelayBody;
|
|
50
|
-
/** `
|
|
60
|
+
/** `encs` pairs with the top-up's inserted `[change, out0, pad0, pad1]` (Z1-LEAF-MAP.md, top-up row). */
|
|
51
61
|
export declare function topup(p: HealthBody & {
|
|
52
62
|
lock: CollLockSpend;
|
|
53
63
|
lockProved: Proved;
|
|
54
|
-
lockEncs: [Uint8Array, Uint8Array];
|
|
55
64
|
keeperCt: Uint8Array;
|
|
56
|
-
encs:
|
|
65
|
+
encs: Encs4;
|
|
57
66
|
}): RelayBody;
|
|
58
67
|
/** `loan_topup_borrower`: the borrower pass (proof 0, `tag`, `expiryMs`, `passN0`), then `topup` unchanged. */
|
|
59
68
|
export declare function topupBorrower(p: Parameters<typeof topup>[0] & {
|
|
@@ -65,7 +74,7 @@ export declare function topupBorrower(p: Parameters<typeof topup>[0] & {
|
|
|
65
74
|
};
|
|
66
75
|
}): RelayBody;
|
|
67
76
|
type SeizeBody = HealthBody & {
|
|
68
|
-
encs:
|
|
77
|
+
encs: Encs4;
|
|
69
78
|
pSpot: bigint;
|
|
70
79
|
pEma: bigint;
|
|
71
80
|
priceUpdate: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bodies.d.ts","sourceRoot":"","sources":["../../../src/v3/collateral/bodies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAa,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"bodies.d.ts","sourceRoot":"","sources":["../../../src/v3/collateral/bodies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAa,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAKtE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE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|
@@ -3,18 +3,23 @@ import { address } from "../../network.js";
|
|
|
3
3
|
import { wireProof } from "../bodies.js";
|
|
4
4
|
import { assertU64 } from "../fees.js";
|
|
5
5
|
import { ENC_BYTES, VK } from "../kinds.js";
|
|
6
|
+
import { assertDistinctPads } from "../pads.js";
|
|
6
7
|
import { COVER_STEP_MS } from "./math.js";
|
|
7
8
|
const OUTS = ["out0", "out1", "out2", "feeNote"];
|
|
8
|
-
const DELIVERY = ["ephX", "ephY", "feeCt", "lEx", "lEy", "lCt"];
|
|
9
|
+
const DELIVERY = ["ephX", "ephY", "feeCt", "lEx", "lEy", "lCt", "nDummy0", "nDummy1"];
|
|
10
|
+
/** `pads.ts` assertDistinctPads, as the body refusal every hidden entry shares. */
|
|
11
|
+
export function distinctPads(...pads) {
|
|
12
|
+
try {
|
|
13
|
+
assertDistinctPads(...pads);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
throw new EsseyError("INVALID_ARGUMENT", err.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
9
19
|
const invalid = (what) => {
|
|
10
20
|
throw new EsseyError("INVALID_ARGUMENT", what);
|
|
11
21
|
};
|
|
12
22
|
const hex = (bytes) => `0x${Buffer.from(bytes).toString("hex")}`;
|
|
13
|
-
function enc(bytes, what) {
|
|
14
|
-
if (bytes.length !== ENC_BYTES)
|
|
15
|
-
invalid(`${what} is not a 128-byte note ciphertext`);
|
|
16
|
-
return hex(bytes);
|
|
17
|
-
}
|
|
18
23
|
function u64(value, what) {
|
|
19
24
|
try {
|
|
20
25
|
assertU64(what, value);
|
|
@@ -25,15 +30,26 @@ function u64(value, what) {
|
|
|
25
30
|
return value.toString();
|
|
26
31
|
}
|
|
27
32
|
const prefixed = (prefix) => (name) => `${prefix}${name[0].toUpperCase()}${name.slice(1)}`;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
/** Z1-LEAF-MAP.md: every collateral entry hands `pool::room_apply` four ciphertexts, `enc0..enc3` in leaf order. */
|
|
34
|
+
export function encArgs(encs) {
|
|
35
|
+
if (encs?.length !== 4)
|
|
36
|
+
invalid("a collateral entry carries 4 note ciphertexts");
|
|
37
|
+
return Object.fromEntries(encs.map((e, i) => {
|
|
38
|
+
if (e.length !== ENC_BYTES)
|
|
39
|
+
invalid(`enc${i} is not a 128-byte note ciphertext`);
|
|
40
|
+
return [`enc${i}`, hex(e)];
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
export function healthArgs(s, key = (name) => name) {
|
|
44
|
+
if (s.outs?.length !== OUTS.length || s.delivery?.length !== DELIVERY.length)
|
|
45
|
+
invalid("a health statement has 4 outs and 8 delivery rows");
|
|
31
46
|
return Object.fromEntries([
|
|
32
47
|
...OUTS.map((name, i) => [key(name), s.outs[i].toString()]),
|
|
33
48
|
...DELIVERY.map((name, i) => [key(name), s.delivery[i].toString()]),
|
|
34
49
|
]);
|
|
35
50
|
}
|
|
36
|
-
function lockArgs(lock, noteKey
|
|
51
|
+
function lockArgs(lock, noteKey) {
|
|
52
|
+
distinctPads(lock.pad0, lock.pad1);
|
|
37
53
|
return {
|
|
38
54
|
root: lock.root.toString(),
|
|
39
55
|
nullifier0: lock.n0.toString(),
|
|
@@ -41,11 +57,11 @@ function lockArgs(lock, noteKey, encs) {
|
|
|
41
57
|
[noteKey]: lock.note.toString(),
|
|
42
58
|
change: lock.change.toString(),
|
|
43
59
|
feeNote: lock.feeNote.toString(),
|
|
60
|
+
pad0: lock.pad0.toString(),
|
|
61
|
+
pad1: lock.pad1.toString(),
|
|
44
62
|
ephX: lock.ephX.toString(),
|
|
45
63
|
ephY: lock.ephY.toString(),
|
|
46
64
|
feeCt: lock.feeCt.toString(),
|
|
47
|
-
encChange: enc(encs[0], "encChange"),
|
|
48
|
-
encFee: enc(encs[1], "encFee"),
|
|
49
65
|
};
|
|
50
66
|
}
|
|
51
67
|
function body(kind, p, proofs, args) {
|
|
@@ -61,47 +77,41 @@ function body(kind, p, proofs, args) {
|
|
|
61
77
|
}
|
|
62
78
|
const healthProof = (p) => wireProof(VK.health, p.proved);
|
|
63
79
|
/**
|
|
64
|
-
* The `liquidation::lock_collateral` slice of a `loan_open` envelope
|
|
65
|
-
*
|
|
80
|
+
* The `liquidation::lock_collateral` slice of a `loan_open` envelope: the padded CollLock spend, the four inserted
|
|
81
|
+
* ciphertexts `[change, fee_note, pad0, pad1]`, the keeper ciphertext, the claimed price and the Health OPEN rows.
|
|
82
|
+
* The request half is the loans module's.
|
|
66
83
|
*/
|
|
67
84
|
export function openLockArgs(p) {
|
|
68
85
|
return {
|
|
69
|
-
...lockArgs(p.lock, "collNote"
|
|
86
|
+
...lockArgs(p.lock, "collNote"),
|
|
87
|
+
...encArgs(p.encs),
|
|
70
88
|
keeperCt: hex(p.keeperCt),
|
|
71
89
|
pClaim: u64(p.pClaim, "pClaim"),
|
|
72
90
|
...healthArgs(p.statement, prefixed("open")),
|
|
73
91
|
priceUpdate: hex(p.priceUpdate),
|
|
74
92
|
};
|
|
75
93
|
}
|
|
76
|
-
/** `encs` pairs with `[out0, fee_note]`. */
|
|
94
|
+
/** `encs` pairs with `[out0, fee_note, out1, out2]`. */
|
|
77
95
|
export function release(p) {
|
|
78
|
-
return body("loan_release", p, [healthProof(p)], {
|
|
79
|
-
...healthArgs(p.statement),
|
|
80
|
-
encOut: enc(p.encs[0], "encOut"),
|
|
81
|
-
encFee: enc(p.encs[1], "encFee"),
|
|
82
|
-
});
|
|
96
|
+
return body("loan_release", p, [healthProof(p)], { ...healthArgs(p.statement), ...encArgs(p.encs) });
|
|
83
97
|
}
|
|
84
98
|
export function heartbeat(p) {
|
|
85
99
|
if (p.expiryMs % COVER_STEP_MS !== 0n)
|
|
86
100
|
invalid("expiryMs is not on the 5-minute cover step");
|
|
87
|
-
return body(
|
|
101
|
+
return body("loan_heartbeat", p, [healthProof(p)], {
|
|
88
102
|
...healthArgs(p.statement),
|
|
89
|
-
|
|
90
|
-
encFee: enc(p.encs[1], "encFee"),
|
|
91
|
-
...(p.retired ? { k: "1" } : {}),
|
|
103
|
+
...encArgs(p.encs),
|
|
92
104
|
expiryMs: u64(p.expiryMs, "expiryMs"),
|
|
93
105
|
priceUpdate: hex(p.priceUpdate),
|
|
94
106
|
});
|
|
95
107
|
}
|
|
96
|
-
/** `
|
|
108
|
+
/** `encs` pairs with the top-up's inserted `[change, out0, pad0, pad1]` (Z1-LEAF-MAP.md, top-up row). */
|
|
97
109
|
export function topup(p) {
|
|
98
|
-
const toppedUp = prefixed("topup");
|
|
99
110
|
return body("loan_topup", p, [wireProof(VK.collLock, p.lockProved), healthProof(p)], {
|
|
100
|
-
...lockArgs(p.lock, "addNote"
|
|
111
|
+
...lockArgs(p.lock, "addNote"),
|
|
101
112
|
keeperCt: hex(p.keeperCt),
|
|
102
|
-
...healthArgs(p.statement,
|
|
103
|
-
|
|
104
|
-
[toppedUp("encFee")]: enc(p.encs[1], "encFee"),
|
|
113
|
+
...healthArgs(p.statement, prefixed("topup")),
|
|
114
|
+
...encArgs(p.encs),
|
|
105
115
|
});
|
|
106
116
|
}
|
|
107
117
|
/** `loan_topup_borrower`: the borrower pass (proof 0, `tag`, `expiryMs`, `passN0`), then `topup` unchanged. */
|
|
@@ -122,10 +132,7 @@ export function topupBorrower(p) {
|
|
|
122
132
|
function seizeArgs(p) {
|
|
123
133
|
return {
|
|
124
134
|
...healthArgs(p.statement),
|
|
125
|
-
|
|
126
|
-
encFee: enc(p.encs[1], "encFee"),
|
|
127
|
-
encBorrower: enc(p.encs[2], "encBorrower"),
|
|
128
|
-
encKeeper: enc(p.encs[3], "encKeeper"),
|
|
135
|
+
...encArgs(p.encs),
|
|
129
136
|
pSpot: u64(p.pSpot, "pSpot"),
|
|
130
137
|
pEma: u64(p.pEma, "pEma"),
|
|
131
138
|
priceUpdate: hex(p.priceUpdate),
|
|
@@ -4,18 +4,23 @@ export type LoanIds = {
|
|
|
4
4
|
poolC: string;
|
|
5
5
|
market: string;
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The four note ciphertexts of one collateral entry, in the leaf order `pool::room_apply` takes them
|
|
9
|
+
* (`/root/scopes/V3-PRIVACY-CYCLE3/Z1-LEAF-MAP.md`): open `[change, fee_note, pad0, pad1]`, top-up
|
|
10
|
+
* `[change, out0, pad0, pad1]`, every Health-only entry `[out0, fee_note, out1, out2]`.
|
|
11
|
+
*/
|
|
12
|
+
export type Encs4 = [Uint8Array, Uint8Array, Uint8Array, Uint8Array];
|
|
13
|
+
/** Kept for the seizure callers: a seizure's four are lender, fee, borrower, keeper. */
|
|
14
|
+
export type SeizeEncs = Encs4;
|
|
15
|
+
/** `liquidation::open_ext`: the keeper ciphertext, then the four inserted ciphertexts. */
|
|
16
|
+
export declare const openExt: (ids: LoanIds, keeperCt: Uint8Array, encs: Encs4) => bigint;
|
|
17
|
+
export declare const releaseExt: (ids: LoanIds, encs: Encs4) => bigint;
|
|
18
|
+
export declare const heartbeatExt: (ids: LoanIds, encs: Encs4) => bigint;
|
|
19
|
+
/** `liquidation::topup_ext`: the new keeper ciphertext, then the four inserted ciphertexts. */
|
|
20
|
+
export declare const topupExt: (ids: LoanIds, keeperCt: Uint8Array, encs: Encs4) => bigint;
|
|
14
21
|
/** `liquidation::topup_by_borrower_ext`: `topupExt`'s preimage under `HEXT_TOPUP_BY_BORROWER`. */
|
|
15
|
-
export declare const topupByBorrowerExt: (ids: LoanIds, keeperCt: Uint8Array,
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const defaultExt: (ids: LoanIds, encs: SeizeEncs) => bigint;
|
|
20
|
-
export declare const faultExt: (ids: LoanIds, encs: SeizeEncs) => bigint;
|
|
22
|
+
export declare const topupByBorrowerExt: (ids: LoanIds, keeperCt: Uint8Array, encs: Encs4) => bigint;
|
|
23
|
+
export declare const liquidateExt: (ids: LoanIds, encs: Encs4) => bigint;
|
|
24
|
+
export declare const defaultExt: (ids: LoanIds, encs: Encs4) => bigint;
|
|
25
|
+
export declare const faultExt: (ids: LoanIds, encs: Encs4) => bigint;
|
|
21
26
|
//# sourceMappingURL=ext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ext.d.ts","sourceRoot":"","sources":["../../../src/v3/collateral/ext.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"ext.d.ts","sourceRoot":"","sources":["../../../src/v3/collateral/ext.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAErE,wFAAwF;AACxF,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC;AAW9B,0FAA0F;AAC1F,eAAO,MAAM,OAAO,GAAI,KAAK,OAAO,EAAE,UAAU,UAAU,EAAE,MAAM,KAAK,WAC7B,CAAC;AAE3C,eAAO,MAAM,UAAU,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,WAAiC,CAAC;AAEtF,eAAO,MAAM,YAAY,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,WAAmC,CAAC;AAE1F,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,GAAI,KAAK,OAAO,EAAE,UAAU,UAAU,EAAE,MAAM,KAAK,WAC7B,CAAC;AAE5C,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,GAAI,KAAK,OAAO,EAAE,UAAU,UAAU,EAAE,MAAM,KAAK,WAC3B,CAAC;AAExD,eAAO,MAAM,YAAY,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,WAAmC,CAAC;AAE1F,eAAO,MAAM,UAAU,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,WAAiC,CAAC;AAEtF,eAAO,MAAM,QAAQ,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,WAA+B,CAAC"}
|
|
@@ -5,15 +5,14 @@ const MODE_DEFAULT = 5;
|
|
|
5
5
|
const MODE_RELEASE = 6;
|
|
6
6
|
const MODE_FAULT = 7;
|
|
7
7
|
const ext = (mode, ids, cts) => healthExt(mode, ids.loan, ids.poolC, ids.market, cts);
|
|
8
|
-
/** `liquidation::open_ext`: the keeper ciphertext, then the
|
|
9
|
-
export const openExt = (ids, keeperCt,
|
|
10
|
-
/** `encs` pairs with `[out0, fee_note]`, the order `room_insert` takes them. */
|
|
8
|
+
/** `liquidation::open_ext`: the keeper ciphertext, then the four inserted ciphertexts. */
|
|
9
|
+
export const openExt = (ids, keeperCt, encs) => ext(MODE_OPEN, ids, [keeperCt, ...encs]);
|
|
11
10
|
export const releaseExt = (ids, encs) => ext(MODE_RELEASE, ids, encs);
|
|
12
11
|
export const heartbeatExt = (ids, encs) => ext(MODE_HEARTBEAT, ids, encs);
|
|
13
|
-
/** `liquidation::topup_ext`: the new keeper ciphertext,
|
|
14
|
-
export const topupExt = (ids, keeperCt,
|
|
12
|
+
/** `liquidation::topup_ext`: the new keeper ciphertext, then the four inserted ciphertexts. */
|
|
13
|
+
export const topupExt = (ids, keeperCt, encs) => ext(MODE_TOPUP, ids, [keeperCt, ...encs]);
|
|
15
14
|
/** `liquidation::topup_by_borrower_ext`: `topupExt`'s preimage under `HEXT_TOPUP_BY_BORROWER`. */
|
|
16
|
-
export const topupByBorrowerExt = (ids, keeperCt,
|
|
15
|
+
export const topupByBorrowerExt = (ids, keeperCt, encs) => ext(HEXT_TOPUP_BY_BORROWER, ids, [keeperCt, ...encs]);
|
|
17
16
|
export const liquidateExt = (ids, encs) => ext(MODE_LIQUIDATE, ids, encs);
|
|
18
17
|
export const defaultExt = (ids, encs) => ext(MODE_DEFAULT, ids, encs);
|
|
19
18
|
export const faultExt = (ids, encs) => ext(MODE_FAULT, ids, encs);
|
|
@@ -13,7 +13,7 @@ export declare const MODE: {
|
|
|
13
13
|
readonly RELEASE: 6;
|
|
14
14
|
readonly FAULT: 7;
|
|
15
15
|
};
|
|
16
|
-
export declare const HEALTH_VERSION =
|
|
16
|
+
export declare const HEALTH_VERSION = 2n;
|
|
17
17
|
/** What `health::rows` folds for the loan: its market's decimals, its stored rates, and `loan::keeper_bps(mode)`. */
|
|
18
18
|
export type HealthRisk = {
|
|
19
19
|
cDec: bigint;
|
|
@@ -23,6 +23,10 @@ export type HealthRisk = {
|
|
|
23
23
|
bonusBps: bigint;
|
|
24
24
|
keeperBps: bigint;
|
|
25
25
|
};
|
|
26
|
+
export type PadKey = {
|
|
27
|
+
pk: bigint;
|
|
28
|
+
blinding: bigint;
|
|
29
|
+
};
|
|
26
30
|
type Common = {
|
|
27
31
|
opening: CollOpening;
|
|
28
32
|
risk: HealthRisk;
|
|
@@ -33,6 +37,12 @@ type Common = {
|
|
|
33
37
|
extHash: bigint;
|
|
34
38
|
fee: FeeCommitInput;
|
|
35
39
|
eph: bigint;
|
|
40
|
+
/** Freeze §3.4 item 3: out1 and out2 outside a seizure are zero notes under these keys (never a constant leaf). */
|
|
41
|
+
pads: readonly [PadKey, PadKey];
|
|
42
|
+
/** Random per proof: their `DummyNull`s are `delivery[6..8]`, nullifiers the pool stores. */
|
|
43
|
+
dummySeeds: readonly [bigint, bigint];
|
|
44
|
+
/** Terms2's inner hash, for a prover holding only the outer terms (a keeper). TOPUP opens it from the terms. */
|
|
45
|
+
hRest?: bigint;
|
|
36
46
|
};
|
|
37
47
|
export type HealthParams = Common & ({
|
|
38
48
|
mode: typeof MODE.OPEN;
|
|
@@ -51,10 +61,7 @@ export type HealthParams = Common & ({
|
|
|
51
61
|
} | {
|
|
52
62
|
mode: typeof MODE.LIQUIDATE | typeof MODE.DEFAULT | typeof MODE.FAULT;
|
|
53
63
|
terms: KeeperTerms;
|
|
54
|
-
keeper:
|
|
55
|
-
pk: bigint;
|
|
56
|
-
blinding: bigint;
|
|
57
|
-
};
|
|
64
|
+
keeper: PadKey;
|
|
58
65
|
});
|
|
59
66
|
export type HealthStatement = {
|
|
60
67
|
rows: {
|
|
@@ -64,8 +71,8 @@ export type HealthStatement = {
|
|
|
64
71
|
};
|
|
65
72
|
/** The entry's `outs`: out0, out1, out2, fee_note. */
|
|
66
73
|
outs: [bigint, bigint, bigint, bigint];
|
|
67
|
-
/** The entry's `delivery`: ephX, ephY, fee_ct, lEx, lEy, lCt. */
|
|
68
|
-
delivery: [bigint, bigint, bigint, bigint, bigint, bigint];
|
|
74
|
+
/** The entry's `delivery`: ephX, ephY, fee_ct, lEx, lEy, lCt, nDummy0, nDummy1. */
|
|
75
|
+
delivery: [bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint];
|
|
69
76
|
};
|
|
70
77
|
/** `notes` are the openings of out0, out1 and out2. They never go on the wire. */
|
|
71
78
|
export type Health = {
|
|
@@ -83,7 +90,8 @@ export declare function seizeIsLast(leafCount: bigint, index: bigint, out: 0 | 1
|
|
|
83
90
|
/**
|
|
84
91
|
* A seizure's split of the lock (B §5.5, `health.circom:303-346`): what the seizer proves, and what the lender and the
|
|
85
92
|
* borrower recompute afterwards from the claimed `p_spot` the seizing call took. FAULT seizes the whole lock and runs
|
|
86
|
-
* the price chain on (debt 0, price 1), so pass `owed` 0 and `pSpot` 1 with it.
|
|
93
|
+
* the price chain on (debt 0, price 1), so pass `owed` 0 and `pSpot` 1 with it. Seizures pay no protocol fee (Erik
|
|
94
|
+
* FLAT-FEE row; `health.circom` `lane.base <== 0`).
|
|
87
95
|
*/
|
|
88
96
|
export declare function seizeSplit(p: {
|
|
89
97
|
owed: bigint;
|
|
@@ -91,7 +99,6 @@ export declare function seizeSplit(p: {
|
|
|
91
99
|
pSpot: bigint;
|
|
92
100
|
expo: bigint;
|
|
93
101
|
risk: HealthRisk;
|
|
94
|
-
fee: Pick<FeeCommitInput, "bps" | "min" | "max">;
|
|
95
102
|
fault?: boolean;
|
|
96
103
|
}): {
|
|
97
104
|
prodT: bigint;
|
|
@@ -101,7 +108,6 @@ export declare function seizeSplit(p: {
|
|
|
101
108
|
r: bigint;
|
|
102
109
|
};
|
|
103
110
|
seize: bigint;
|
|
104
|
-
pf: bigint;
|
|
105
111
|
prodK: bigint;
|
|
106
112
|
kf: bigint;
|
|
107
113
|
toLender: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/v3/collateral/health.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/v3/collateral/health.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsD,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AACrG,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAuC,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,IAAI;;;;;;;;CAQP,CAAC;AAEX,eAAO,MAAM,cAAc,KAAK,CAAC;AAUjC,qHAAqH;AACrH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,E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