@esseyonsui/sui-mcp-v3 0.1.6 → 0.1.8
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 +14 -0
- package/dist/args.d.ts +2 -1
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +14 -4
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/failure.d.ts +7 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +30 -1
- package/dist/loan-view.d.ts +1 -1
- package/dist/loan-view.d.ts.map +1 -1
- package/dist/main.js +11 -2
- package/dist/pace.d.ts +21 -0
- package/dist/pace.d.ts.map +1 -0
- package/dist/pace.js +38 -0
- package/dist/tools-more.d.ts +12 -0
- package/dist/tools-more.d.ts.map +1 -1
- package/dist/tools-more.js +25 -11
- package/dist/tools-sales.d.ts.map +1 -1
- package/dist/tools-sales.js +4 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +23 -19
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -92,6 +92,19 @@ and `covered` on the public fields in its arguments and reads nothing.
|
|
|
92
92
|
|
|
93
93
|
Amounts are whole-number strings in the coin's smallest unit.
|
|
94
94
|
|
|
95
|
+
## Waits
|
|
96
|
+
|
|
97
|
+
So a loan's closing steps do not land seconds apart, each proved action first waits a random time drawn by its
|
|
98
|
+
class, before it reads the chain (`@esseyonsui/sui-sdk-v3` `src/v3/pace.ts`): 2 to 30 min for withdraw, exit,
|
|
99
|
+
transfer, every collect and every reclaim; 20 s to 3 min for repay, release, offer, settle and bid; 0 to 30 s for
|
|
100
|
+
heartbeat, topup, liquidate and fault. A wait is capped 2 min before the action's deadline (offer close,
|
|
101
|
+
settle-by, bid close, heartbeat expiry, maturity plus grace for a repay). An offer, settle or bid already inside
|
|
102
|
+
those 2 min is refused unsent; a heartbeat, topup or repay there goes without a wait. A wait of
|
|
103
|
+
30 s or less runs inside the call. A longer one returns `{ ok: false, error: "NOT_BEFORE", notBeforeMs }` with
|
|
104
|
+
nothing sent; the same call before `notBeforeMs` returns the same time, and at or after it runs. A seizure's
|
|
105
|
+
collect waits again while nothing has landed in the pool since the seizure. The times are kept in memory, so a
|
|
106
|
+
restart draws new ones. `ESSEY_SUBMIT_DELAY=off` sends at once.
|
|
107
|
+
|
|
95
108
|
## Configuration
|
|
96
109
|
|
|
97
110
|
| variable | |
|
|
@@ -104,6 +117,7 @@ Amounts are whole-number strings in the coin's smallest unit.
|
|
|
104
117
|
| `ESSEY_INVITE` | optional invite token, 1..256 characters without whitespace |
|
|
105
118
|
| `ESSEY_RELAYER` | `clear` (default) or `onion` |
|
|
106
119
|
| `ESSEY_GRAPHQL` | Sui GraphQL URL, `https` or `http` on localhost (default `https://graphql.testnet.sui.io/graphql`) |
|
|
120
|
+
| `ESSEY_SUBMIT_DELAY` | `default` (default) or `off`: the SDK's `delays` option, a random wait before each proved action (see Waits) |
|
|
107
121
|
|
|
108
122
|
Any other `ESSEY_*` variable stops the server, and so does a name containing `OWNER` or a value holding a private key.
|
|
109
123
|
|
package/dist/args.d.ts
CHANGED
|
@@ -20,7 +20,8 @@ export declare function parseRole(args: Rec): "member" | "keeper" | undefined;
|
|
|
20
20
|
export declare function parseCoin(args: Rec, k?: string): CoinKey;
|
|
21
21
|
export declare function parseAmount(args: Rec, k?: string): bigint;
|
|
22
22
|
export declare function parseDenominations(args: Rec): boolean | undefined;
|
|
23
|
-
export declare
|
|
23
|
+
export declare const PAYEES: JsonSchema;
|
|
24
|
+
export declare function parsePayees(args: Rec): string[];
|
|
24
25
|
export declare const parseLoanId: (args: Rec) => string;
|
|
25
26
|
export declare const LOAN_SCHEMA: JsonSchema;
|
|
26
27
|
export declare const TRANSFER_SCHEMA: JsonSchema;
|
package/dist/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAA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E,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAKtE;AAED,eAAO,MAAM,YAAY,YAOxB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,GAAG,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAKzF;AAED,eAAO,MAAM,WAAW,YAGvB,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,MAAM,GAAG,KAAG,OAAwC,CAAC;AA2BlF,eAAO,MAAM,WAAW,YAmBvB,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,UAAU,CAmB/C"}
|
package/dist/args.js
CHANGED
|
@@ -18,7 +18,7 @@ export const AMOUNT = {
|
|
|
18
18
|
};
|
|
19
19
|
export const FORCE = {
|
|
20
20
|
type: "boolean",
|
|
21
|
-
description: "
|
|
21
|
+
description: "one exact withdraw to one address, not split into denominations, sent even when the amount equals a faucet grant or an own note's exact value or deposit, which links them on chain; default false",
|
|
22
22
|
};
|
|
23
23
|
export const COIN = { type: "string", enum: [...COINS], description: "tusdsui, usdc or sui" };
|
|
24
24
|
export const ADDRESS = {
|
|
@@ -114,8 +114,18 @@ export function parseAmount(args, k = "amount") {
|
|
|
114
114
|
export function parseDenominations(args) {
|
|
115
115
|
return optBool(args, "denominations");
|
|
116
116
|
}
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
const PAYEE = { type: "string", pattern: "^0x[0-9a-fA-F]{64}$" };
|
|
118
|
+
export const PAYEES = {
|
|
119
|
+
anyOf: [PAYEE, { type: "array", items: PAYEE, minItems: 1, maxItems: v3.notes.MAX_SPLIT_PIECES }],
|
|
120
|
+
description: "0x addresses of 64 hex digits, all different, one per denomination piece; force: true or a coin without denominations takes one",
|
|
121
|
+
};
|
|
122
|
+
export function parsePayees(args) {
|
|
123
|
+
const v = args.to;
|
|
124
|
+
if (!Array.isArray(v))
|
|
125
|
+
return [payee(args, "to")];
|
|
126
|
+
if (v.length === 0 || v.length > v3.notes.MAX_SPLIT_PIECES)
|
|
127
|
+
bad(`to must list 1 to ${v3.notes.MAX_SPLIT_PIECES} addresses`);
|
|
128
|
+
return v.map((to) => payee({ to }, "to"));
|
|
119
129
|
}
|
|
120
130
|
export const parseLoanId = (args) => address(args, "loan");
|
|
121
131
|
export const LOAN_SCHEMA = objectSchema({ loan: LOAN }, ["loan"]);
|
|
@@ -143,7 +153,7 @@ export const OPEN_SCHEMA = objectSchema({
|
|
|
143
153
|
termMs: { ...MS, description: "loan term after settle, milliseconds" },
|
|
144
154
|
offerWindowMs: {
|
|
145
155
|
...MS,
|
|
146
|
-
description: "how long lenders may offer, milliseconds; the close rounds up to the
|
|
156
|
+
description: "how long lenders may offer, milliseconds; the close rounds up to the deployment's close step (an hour unless the deployment sets closeStepMs)",
|
|
147
157
|
},
|
|
148
158
|
}, ["collateralCoin", "collateral", "loanCoin", "principal", "maxRateBps", "termMs", "offerWindowMs"]);
|
|
149
159
|
export function parseOpen(args) {
|
package/dist/config.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export type McpConfig = {
|
|
|
19
19
|
/** Invite gate token. Unset: credential obtain uses the proof-of-work challenge. Never a tool argument. */
|
|
20
20
|
invite: string | null;
|
|
21
21
|
relayer: "clear" | "onion";
|
|
22
|
+
/** The SDK's `delays` option: "default" waits a drawn time before each proved action, "off" sends at once. */
|
|
23
|
+
delays: "default" | "off";
|
|
22
24
|
};
|
|
23
25
|
export declare const TESTNET_GRAPHQL = "https://graphql.testnet.sui.io/graphql";
|
|
24
26
|
export declare class ConfigError extends Error {
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,SAAS,CAAC;IAC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AAWD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CA6B7D"}
|
package/dist/config.js
CHANGED
|
@@ -8,6 +8,7 @@ const KNOWN = [
|
|
|
8
8
|
"ESSEY_INVITE",
|
|
9
9
|
"ESSEY_RELAYER",
|
|
10
10
|
"ESSEY_GRAPHQL",
|
|
11
|
+
"ESSEY_SUBMIT_DELAY",
|
|
11
12
|
];
|
|
12
13
|
export class ConfigError extends Error {
|
|
13
14
|
code = "INVALID_CONFIG";
|
|
@@ -41,6 +42,9 @@ export function parseConfig(env) {
|
|
|
41
42
|
const relayer = env.ESSEY_RELAYER ?? "clear";
|
|
42
43
|
if (relayer !== "clear" && relayer !== "onion")
|
|
43
44
|
fail("ESSEY_RELAYER must be clear or onion");
|
|
45
|
+
const delays = env.ESSEY_SUBMIT_DELAY || "default";
|
|
46
|
+
if (delays !== "default" && delays !== "off")
|
|
47
|
+
fail("ESSEY_SUBMIT_DELAY must be default or off");
|
|
44
48
|
const noteKeyFile = need("ESSEY_NOTE_KEY_FILE");
|
|
45
49
|
const agentKeyFile = need("ESSEY_AGENT_KEY_FILE");
|
|
46
50
|
if (/^[0-9a-fA-F]{64}$/.test(noteKeyFile) || /^[0-9a-fA-F]{64}$/.test(agentKeyFile))
|
|
@@ -54,6 +58,7 @@ export function parseConfig(env) {
|
|
|
54
58
|
agentKeyFile,
|
|
55
59
|
invite: inviteOf(env.ESSEY_INVITE),
|
|
56
60
|
relayer,
|
|
61
|
+
delays,
|
|
57
62
|
};
|
|
58
63
|
}
|
|
59
64
|
function configOf(v) {
|
package/dist/failure.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export type Failure = {
|
|
|
10
10
|
module: string;
|
|
11
11
|
code: number;
|
|
12
12
|
};
|
|
13
|
+
/** UNEXPECTED only: a fixed label for the kind of library failure, and the error's class name. Never its text. */
|
|
14
|
+
cause?: {
|
|
15
|
+
kind?: string;
|
|
16
|
+
class?: string;
|
|
17
|
+
};
|
|
18
|
+
/** NOT_BEFORE only: unix ms from which the same call runs. Nothing was proved or sent. */
|
|
19
|
+
notBeforeMs?: number;
|
|
13
20
|
};
|
|
14
21
|
/**
|
|
15
22
|
* A refusal this server words itself. The hint is a rule, never a value the caller sent.
|
package/dist/failure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,UAAU,EAAgB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,UAAU,EAAgB,MAAM,wBAAwB,CAAC;AAKrF,eAAO,MAAM,QAAQ,6DAA6D,CAAC;AAEnF,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,kHAAkH;IAClH,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,0FAA0F;IAC1F,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAkEF;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IAExB,QAAQ,CAAC,IAAI,EAAE,MAAM;IADjC,QAAQ,CAAC,IAAI,sBAAsB;gBACd,IAAI,EAAE,MAAM;CAGlC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,SAAS,MAAM,EAAO,GAAG,OAAO,CAUhF;AAED,eAAO,MAAM,SAAS,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,UACkC,CAAC;AAEnF,4FAA4F;AAC5F,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAcpD"}
|
package/dist/failure.js
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { ESSEY_ERROR_CODES, isEsseyError } from "@esseyonsui/sui-sdk-v3";
|
|
2
|
+
import { NotBefore } from "./pace.js";
|
|
2
3
|
import { redactText, secretArgument } from "./redact.js";
|
|
3
4
|
export const WITHHELD = "The tool failed inside a library; its error is withheld.";
|
|
5
|
+
const NOT_BEFORE_HINT = "Nothing was sent. Call the same tool with the same arguments at or after notBeforeMs.";
|
|
6
|
+
/** First match wins. Each label is a fixed word; the message it was read from is never returned. */
|
|
7
|
+
const CAUSES = [
|
|
8
|
+
["seal_access", /does not have access/i],
|
|
9
|
+
[
|
|
10
|
+
"object_version",
|
|
11
|
+
/not available for consumption|object version|ObjectVersionUnavailable|equivocat|already locked/i,
|
|
12
|
+
],
|
|
13
|
+
["gas", /gas/i],
|
|
14
|
+
["timeout", /timed? ?out|deadline/i],
|
|
15
|
+
["network", /fetch failed|ECONNRESET|ECONNREFUSED|ENOTFOUND|EAI_AGAIN|socket hang up|network/i],
|
|
16
|
+
["prover", /witness|snarkjs|groth16|zkey|wasm|constraint/i],
|
|
17
|
+
["graphql", /graphql/i],
|
|
18
|
+
];
|
|
19
|
+
const CLASS = /^[A-Z][A-Za-z]{2,40}$/;
|
|
20
|
+
function causeOf(err) {
|
|
21
|
+
if (!(err instanceof Error))
|
|
22
|
+
return undefined;
|
|
23
|
+
const kind = CAUSES.find(([, re]) => re.test(err.message))?.[0];
|
|
24
|
+
const name = err.constructor?.name;
|
|
25
|
+
const cls = typeof name === "string" && CLASS.test(name) && name !== "Error" ? name : undefined;
|
|
26
|
+
if (!kind && !cls)
|
|
27
|
+
return undefined;
|
|
28
|
+
return { ...(kind ? { kind } : {}), ...(cls ? { class: cls } : {}) };
|
|
29
|
+
}
|
|
4
30
|
/** Only an all-capitals code is passed on (RATE_LIMITED, E_INSOLVENT): no digits, so no key text fits it. */
|
|
5
31
|
const SERVICE_CODE = /^(?:v3api|relayer) refused: ([A-Z_]{3,40})$/;
|
|
6
32
|
const CODE = /^[A-Z_]{3,40}$/;
|
|
@@ -55,11 +81,14 @@ export class ToolRefusal extends Error {
|
|
|
55
81
|
export function failureOf(err, secrets = []) {
|
|
56
82
|
if (err instanceof ToolRefusal)
|
|
57
83
|
return { ok: false, error: err.code, hint: redactText(err.hint, secrets) };
|
|
84
|
+
if (err instanceof NotBefore)
|
|
85
|
+
return { ok: false, error: err.code, hint: NOT_BEFORE_HINT, notBeforeMs: err.notBeforeMs };
|
|
58
86
|
if (isEsseyError(err) && ESSEY_ERROR_CODES.includes(err.code)) {
|
|
59
87
|
const hint = `Look up ${err.code} in the sdk/errors reference.`;
|
|
60
88
|
return { ok: false, error: err.code, hint, ...reasonOf(err), ...messageOf(err, secrets) };
|
|
61
89
|
}
|
|
62
|
-
|
|
90
|
+
const cause = causeOf(err);
|
|
91
|
+
return { ok: false, error: "UNEXPECTED", hint: WITHHELD, ...(cause ? { cause } : {}) };
|
|
63
92
|
}
|
|
64
93
|
export const isSdkCode = (err) => isEsseyError(err) && ESSEY_ERROR_CODES.includes(err.code);
|
|
65
94
|
/** Refuses key material in arguments. The hint names neither the value nor the property. */
|
package/dist/loan-view.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type LoanStatus = {
|
|
|
9
9
|
ltvBps: string | null;
|
|
10
10
|
underwater: boolean;
|
|
11
11
|
liquidationPrice: string | null;
|
|
12
|
-
|
|
12
|
+
coveredAtDefaultK: boolean;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Read-only health. The SDK's `publicLoanStatus` (D-SPEC §6.2:589) takes the public numbers
|
package/dist/loan-view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loan-view.d.ts","sourceRoot":"","sources":["../src/loan-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEjE,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,IAAI,CAAC;IACT,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,
|
|
1
|
+
{"version":3,"file":"loan-view.d.ts","sourceRoot":"","sources":["../src/loan-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEjE,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,IAAI,CAAC;IACT,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAErD"}
|
package/dist/main.js
CHANGED
|
@@ -8,6 +8,7 @@ import { ConfigError, parseConfig } from "./config.js";
|
|
|
8
8
|
import { agentDepositIo } from "./fund.js";
|
|
9
9
|
import { chainIo } from "./io.js";
|
|
10
10
|
import { loadAgentKey, loadNoteSeed } from "./keys.js";
|
|
11
|
+
import { toolPace } from "./pace.js";
|
|
11
12
|
import { serve } from "./protocol.js";
|
|
12
13
|
import { fileRecords, recordKey } from "./records.js";
|
|
13
14
|
import { bind } from "./tools.js";
|
|
@@ -25,7 +26,8 @@ const INSTRUCTIONS = "Essey V3 private testnet tools. Note and agent keys are fi
|
|
|
25
26
|
"essey_agent_address, essey_sale_open, after close essey_sale_finish (essey_sale_slash each bid it names " +
|
|
26
27
|
"first); or essey_sale_cancel before any bid, or essey_sale_expire after the finish window, then " +
|
|
27
28
|
"essey_sale_claim as seller. Buy: essey_sale_list, essey_sale_bid, and once the room ended essey_sale_claim as " +
|
|
28
|
-
"bidder if won and essey_sale_reclaim (residual if won, else the deposit)."
|
|
29
|
+
"bidder if won and essey_sale_reclaim (residual if won, else the deposit). A proved call may answer NOT_BEFORE " +
|
|
30
|
+
"with notBeforeMs: nothing was sent; make the same call again at or after that time.";
|
|
29
31
|
/**
|
|
30
32
|
* `source` is what `Essey.connect` takes: the URL, which names the v3api, or the parsed file. The io reads the
|
|
31
33
|
* same record as JSON (Seal set, pools, circuit pins).
|
|
@@ -82,7 +84,14 @@ async function start() {
|
|
|
82
84
|
execute: graphqlExecute(cfg.graphql, agent),
|
|
83
85
|
readObjectRef: io.readObjectRef,
|
|
84
86
|
});
|
|
85
|
-
const essey = await Essey.connect({
|
|
87
|
+
const essey = await Essey.connect({
|
|
88
|
+
network: "testnet",
|
|
89
|
+
statePath: cfg.stateFile,
|
|
90
|
+
config: source,
|
|
91
|
+
seed,
|
|
92
|
+
relayer: cfg.relayer,
|
|
93
|
+
delays: cfg.delays,
|
|
94
|
+
}, { ...io, ...agentDepositIo(raw, cfg.agentKeyFile, cfg.graphql), deliverSaleItem, pace: toolPace() });
|
|
86
95
|
const sale = { agentAddress: agent.toSuiAddress(), vaultOf: io.readVaultOf };
|
|
87
96
|
const client = withInvite(clientOf(essey, sale), cfg.invite);
|
|
88
97
|
const tools = bind({
|
package/dist/pace.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Pause } from "@esseyonsui/sui-sdk-v3";
|
|
2
|
+
/** A tool call may wait this long inline; a longer drawn wait is answered with the time it ends. */
|
|
3
|
+
export declare const INLINE_MAX_MS = 30000;
|
|
4
|
+
export declare const WAITS_LONG = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 2 to 30 min: the call answers NOT_BEFORE with notBeforeMs, and the same call at or after that time runs.";
|
|
5
|
+
export declare const WAITS_SEIZED = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 2 to 30 min: the call answers NOT_BEFORE with notBeforeMs, and the same call at or after that time runs. While nothing has landed in the pool since the seizure it waits again.";
|
|
6
|
+
export declare const WAITS_MEDIUM = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 20 s to 3 min, capped by the action's deadline; a wait over 30 s answers NOT_BEFORE with notBeforeMs, and the same call at or after that time runs.";
|
|
7
|
+
export declare const WAITS_SHORT = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 0 to 30 s inside the call.";
|
|
8
|
+
export declare class NotBefore extends Error {
|
|
9
|
+
readonly notBeforeMs: number;
|
|
10
|
+
readonly code = "NOT_BEFORE";
|
|
11
|
+
constructor(notBeforeMs: number);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The SDK's `io.pace` for a tool server. A drawn wait over `INLINE_MAX_MS` throws `NotBefore` and is kept in
|
|
15
|
+
* memory per action and subject, so a repeat call before that time gets the same time and one at or after it runs.
|
|
16
|
+
*/
|
|
17
|
+
export declare function toolPace(o?: {
|
|
18
|
+
now?: () => number;
|
|
19
|
+
sleep?: (ms: number) => Promise<void>;
|
|
20
|
+
}): (p: Pause) => Promise<void>;
|
|
21
|
+
//# sourceMappingURL=pace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pace.d.ts","sourceRoot":"","sources":["../src/pace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,oGAAoG;AACpG,eAAO,MAAM,aAAa,QAAS,CAAC;AAGpC,eAAO,MAAM,UAAU,uKAA8F,CAAC;AACtH,eAAO,MAAM,YAAY,8OAAyF,CAAC;AACnH,eAAO,MAAM,YAAY,kNAAyI,CAAC;AACnK,eAAO,MAAM,WAAW,yFACgE,CAAC;AAEzF,qBAAa,SAAU,SAAQ,KAAK;IAEtB,QAAQ,CAAC,WAAW,EAAE,MAAM;IADxC,QAAQ,CAAC,IAAI,gBAAgB;gBACR,WAAW,EAAE,MAAM;CAGzC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAAO,IAI9E,GAAG,KAAK,KAAG,OAAO,CAAC,IAAI,CAAC,CAYvC"}
|
package/dist/pace.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** A tool call may wait this long inline; a longer drawn wait is answered with the time it ends. */
|
|
2
|
+
export const INLINE_MAX_MS = 30_000;
|
|
3
|
+
const AGAIN = "answers NOT_BEFORE with notBeforeMs, and the same call at or after that time runs";
|
|
4
|
+
export const WAITS_LONG = ` Unless ESSEY_SUBMIT_DELAY is off it first waits a random 2 to 30 min: the call ${AGAIN}.`;
|
|
5
|
+
export const WAITS_SEIZED = `${WAITS_LONG} While nothing has landed in the pool since the seizure it waits again.`;
|
|
6
|
+
export const WAITS_MEDIUM = ` Unless ESSEY_SUBMIT_DELAY is off it first waits a random 20 s to 3 min, capped by the action's deadline; a wait over 30 s ${AGAIN}.`;
|
|
7
|
+
export const WAITS_SHORT = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 0 to 30 s inside the call.";
|
|
8
|
+
export class NotBefore extends Error {
|
|
9
|
+
notBeforeMs;
|
|
10
|
+
code = "NOT_BEFORE";
|
|
11
|
+
constructor(notBeforeMs) {
|
|
12
|
+
super("not before");
|
|
13
|
+
this.notBeforeMs = notBeforeMs;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The SDK's `io.pace` for a tool server. A drawn wait over `INLINE_MAX_MS` throws `NotBefore` and is kept in
|
|
18
|
+
* memory per action and subject, so a repeat call before that time gets the same time and one at or after it runs.
|
|
19
|
+
*/
|
|
20
|
+
export function toolPace(o = {}) {
|
|
21
|
+
const now = o.now ?? Date.now;
|
|
22
|
+
const sleep = o.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
23
|
+
const due = new Map();
|
|
24
|
+
return async (p) => {
|
|
25
|
+
const key = `${p.action} ${p.subject}`;
|
|
26
|
+
const held = due.get(key);
|
|
27
|
+
if (held !== undefined && now() < held)
|
|
28
|
+
throw new NotBefore(held);
|
|
29
|
+
if (held !== undefined) {
|
|
30
|
+
due.delete(key);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (p.delayMs <= INLINE_MAX_MS)
|
|
34
|
+
return sleep(p.delayMs);
|
|
35
|
+
due.set(key, p.notBeforeMs);
|
|
36
|
+
throw new NotBefore(p.notBeforeMs);
|
|
37
|
+
};
|
|
38
|
+
}
|
package/dist/tools-more.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
import { type Payout } from "@esseyonsui/sui-sdk-v3";
|
|
1
2
|
import type { Tool } from "./tools.ts";
|
|
3
|
+
/** The top-level digest is the last piece's, the one `bind` waits to see indexed. */
|
|
4
|
+
export declare function paidOut(rows: Payout[]): {
|
|
5
|
+
ok: true;
|
|
6
|
+
digest: string;
|
|
7
|
+
payouts: {
|
|
8
|
+
digest: string;
|
|
9
|
+
ticket: string;
|
|
10
|
+
amount: string;
|
|
11
|
+
to: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
2
14
|
/** No SDK call behind either, so they sit outside `MORE`. */
|
|
3
15
|
export declare const RECORD_TOOLS: Tool[];
|
|
4
16
|
export declare const MORE: Tool[];
|
package/dist/tools-more.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-more.d.ts","sourceRoot":"","sources":["../src/tools-more.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools-more.d.ts","sourceRoot":"","sources":["../src/tools-more.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,MAAM,EAAkB,MAAM,wBAAwB,CAAC;AAgB5F,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAsCpD,qFAAqF;AACrF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE;;;;;;;;;EAMrC;AAiPD,6DAA6D;AAC7D,eAAO,MAAM,YAAY,EAAE,IAAI,EAoB9B,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IAAI,EAA6C,CAAC"}
|
package/dist/tools-more.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { COINS } from "@esseyonsui/sui-sdk-v3";
|
|
2
|
-
import { FORCE, LOAN_SCHEMA, OPEN_SCHEMA, int, parseAmount, parseCoin, parseForce, parseLoanId,
|
|
2
|
+
import { FORCE, LOAN_SCHEMA, OPEN_SCHEMA, PAYEES, int, parseAmount, parseCoin, parseForce, parseLoanId, parsePayees, } from "./args.js";
|
|
3
3
|
import { isSdkCode, ToolRefusal } from "./failure.js";
|
|
4
|
+
import { WAITS_LONG, WAITS_MEDIUM, WAITS_SHORT } from "./pace.js";
|
|
4
5
|
/** `move/v3/loan/sources/loan.move:40` MAX_OFFERS = 16. */
|
|
5
6
|
const MAX_SEQ = 15;
|
|
6
7
|
const MAX_MS = Number.MAX_SAFE_INTEGER;
|
|
@@ -26,6 +27,14 @@ function bad(msg) {
|
|
|
26
27
|
function landed(row) {
|
|
27
28
|
return { ok: true, digest: row.digest, ticket: row.ticket };
|
|
28
29
|
}
|
|
30
|
+
/** The top-level digest is the last piece's, the one `bind` waits to see indexed. */
|
|
31
|
+
export function paidOut(rows) {
|
|
32
|
+
return {
|
|
33
|
+
ok: true,
|
|
34
|
+
digest: rows[rows.length - 1].digest,
|
|
35
|
+
payouts: rows.map((r) => ({ digest: r.digest, ticket: r.ticket, amount: r.amount.toString(), to: r.to })),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
29
38
|
function keeperArgs(args) {
|
|
30
39
|
const loan = parseLoanId(args);
|
|
31
40
|
if (args.via === undefined)
|
|
@@ -88,7 +97,7 @@ const REFI = [
|
|
|
88
97
|
name: "essey_loan_refi_settle",
|
|
89
98
|
kind: "call",
|
|
90
99
|
description: "Borrower, after the refinance window: take the lowest eligible offer. The old lender is paid and collects with " +
|
|
91
|
-
|
|
100
|
+
`essey_loan_collect; this server keeps the new terms. Returns the digest, ticket, rate, amount owed and maturity.${WAITS_MEDIUM}`,
|
|
92
101
|
inputSchema: LOAN_SCHEMA,
|
|
93
102
|
run: async (ctx, args) => {
|
|
94
103
|
const settled = own(ctx, parseLoanId(args));
|
|
@@ -122,7 +131,7 @@ const SEIZE = [
|
|
|
122
131
|
name: "essey_loan_liquidate",
|
|
123
132
|
kind: "call",
|
|
124
133
|
description: "Borrower of a loan settled from this server: seize it while it is underwater, from this server's own terms. " +
|
|
125
|
-
|
|
134
|
+
`The lender takes its share with essey_loan_collect_seized, the borrower the rest with essey_loan_collect_surplus.${WAITS_SHORT}`,
|
|
126
135
|
inputSchema: LOAN_SCHEMA,
|
|
127
136
|
run: async (ctx, args) => landed(await ctx.client.loans.liquidate(own(ctx, parseLoanId(args)))),
|
|
128
137
|
},
|
|
@@ -130,7 +139,7 @@ const SEIZE = [
|
|
|
130
139
|
name: "essey_loan_seize_default",
|
|
131
140
|
kind: "call",
|
|
132
141
|
description: "Borrower of a loan settled from this server: seize it once it is past maturity plus grace, from this server's " +
|
|
133
|
-
|
|
142
|
+
`own terms. Then essey_loan_collect_seized (lender) and essey_loan_collect_surplus (borrower).${WAITS_SHORT}`,
|
|
134
143
|
inputSchema: LOAN_SCHEMA,
|
|
135
144
|
run: async (ctx, args) => landed(await ctx.client.loans.seizeDefault(own(ctx, parseLoanId(args)))),
|
|
136
145
|
},
|
|
@@ -138,7 +147,7 @@ const SEIZE = [
|
|
|
138
147
|
name: "essey_loan_fault_liquidate",
|
|
139
148
|
kind: "call",
|
|
140
149
|
description: "Lender, from the offer this server made, of a loan a keeper marked FAULT with essey_keeper_fault: seize it. " +
|
|
141
|
-
|
|
150
|
+
`Then essey_loan_collect_seized.${WAITS_SHORT}`,
|
|
142
151
|
inputSchema: LOAN_SCHEMA,
|
|
143
152
|
run: async (ctx, args) => {
|
|
144
153
|
const loan = parseLoanId(args);
|
|
@@ -193,7 +202,7 @@ const KEEPER = [
|
|
|
193
202
|
name: "essey_keeper_fault",
|
|
194
203
|
kind: "call",
|
|
195
204
|
description: "Keeper: mark an active loan FAULT when its retained borrower keeper ciphertext does not open its lock. The " +
|
|
196
|
-
|
|
205
|
+
`chain refuses an honest ciphertext. The lender then calls essey_loan_fault_liquidate.${WAITS_SHORT}`,
|
|
197
206
|
inputSchema: KEEPER_SCHEMA,
|
|
198
207
|
run: async (ctx, args) => landed(await ctx.client.loans.fault(keeperArgs(args))),
|
|
199
208
|
},
|
|
@@ -201,7 +210,7 @@ const KEEPER = [
|
|
|
201
210
|
name: "essey_keeper_liquidate",
|
|
202
211
|
kind: "call",
|
|
203
212
|
description: "Keeper: seize an underwater loan from its Seal read of the keeper ciphertext. The keeper fee arrives as an own " +
|
|
204
|
-
|
|
213
|
+
`note; the lender and borrower collect with essey_loan_collect_seized and essey_loan_collect_surplus.${WAITS_SHORT}`,
|
|
205
214
|
inputSchema: KEEPER_SCHEMA,
|
|
206
215
|
run: async (ctx, args) => landed(await ctx.client.loans.keeperLiquidate(keeperArgs(args))),
|
|
207
216
|
},
|
|
@@ -210,14 +219,19 @@ const NOTES = [
|
|
|
210
219
|
{
|
|
211
220
|
name: "essey_notes_exit",
|
|
212
221
|
kind: "call",
|
|
213
|
-
description: "Withdraw
|
|
214
|
-
"and
|
|
222
|
+
description: "Withdraw the notes of a coin, at most two. With denominations, the largest denomination sum they cover with " +
|
|
223
|
+
"every piece's fees goes out as pieces, each to its own address in to, and kept stays in a note; a refusal " +
|
|
224
|
+
"names how many addresses it needs. force: true, or a coin without denominations: everything less fees to " +
|
|
225
|
+
`one address. Returns each piece's digest, ticket, amount and address.${WAITS_LONG}`,
|
|
215
226
|
inputSchema: obj({
|
|
216
227
|
coin: { type: "string", enum: [...COINS] },
|
|
217
|
-
to:
|
|
228
|
+
to: PAYEES,
|
|
218
229
|
force: FORCE,
|
|
219
230
|
}, ["coin", "to"]),
|
|
220
|
-
run: async (ctx, args) =>
|
|
231
|
+
run: async (ctx, args) => {
|
|
232
|
+
const out = await ctx.client.notes.exit(parseCoin(args), parsePayees(args), parseForce(args));
|
|
233
|
+
return { ...paidOut(out.payouts), kept: out.kept.toString() };
|
|
234
|
+
},
|
|
221
235
|
},
|
|
222
236
|
{
|
|
223
237
|
name: "essey_notes_recover",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-sales.d.ts","sourceRoot":"","sources":["../src/tools-sales.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools-sales.d.ts","sourceRoot":"","sources":["../src/tools-sales.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAwQpD,eAAO,MAAM,UAAU,EAAE,IAAI,EAA2B,CAAC"}
|
package/dist/tools-sales.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isEsseyError, v3 } from "@esseyonsui/sui-sdk-v3";
|
|
2
2
|
import { ADDRESS, AMOUNT, COIN, MS, address, int, objectSchema, optBool, parseAmount, parseCoin, payee, } from "./args.js";
|
|
3
3
|
import { ToolRefusal } from "./failure.js";
|
|
4
|
+
import { WAITS_LONG, WAITS_MEDIUM } from "./pace.js";
|
|
4
5
|
const SLOTS = v3.sales.SLOTS;
|
|
5
6
|
/** `sale_room.move:30-33`. */
|
|
6
7
|
const ROOM_STATES = ["open", "settled", "expired", "cancelled"];
|
|
@@ -103,7 +104,7 @@ const SELLER = [
|
|
|
103
104
|
maxPrice: { ...AMOUNT, description: "highest price settled at; sealed, never shown to bidders" },
|
|
104
105
|
bidWindowMs: {
|
|
105
106
|
...MS,
|
|
106
|
-
description: "how long bids are taken from now, milliseconds; the close rounds up to the
|
|
107
|
+
description: "how long bids are taken from now, milliseconds; the close rounds up to the deployment's close step (an hour unless the deployment sets closeStepMs)",
|
|
107
108
|
},
|
|
108
109
|
finishWindowMs: { ...MS, description: "how long after close the seller may finish, milliseconds" },
|
|
109
110
|
maxBids: { type: "integer", minimum: 1, maximum: SLOTS, description: `1 to ${SLOTS}` },
|
|
@@ -172,7 +173,7 @@ const BIDDER = [
|
|
|
172
173
|
name: "essey_sale_bid",
|
|
173
174
|
kind: "call",
|
|
174
175
|
description: "Bidder: lock deposit from own notes of the room's coin behind a sealed bid of price. Only the seller opens " +
|
|
175
|
-
|
|
176
|
+
`it, after close. The bid record stays in a mode-600 file. Returns the digest and ticket.${WAITS_MEDIUM}`,
|
|
176
177
|
inputSchema: objectSchema({
|
|
177
178
|
room: ROOM,
|
|
178
179
|
price: { ...AMOUNT, description: "the sealed bid, in the room coin's smallest unit" },
|
|
@@ -192,7 +193,7 @@ const BIDDER = [
|
|
|
192
193
|
name: "essey_sale_reclaim",
|
|
193
194
|
kind: "call",
|
|
194
195
|
description: "Bidder, once the room settled or expired: a losing bid's deposit back to an own note, or with residual true " +
|
|
195
|
-
|
|
196
|
+
`the winner's change. Returns the value.${WAITS_LONG}`,
|
|
196
197
|
inputSchema: objectSchema({
|
|
197
198
|
room: ROOM,
|
|
198
199
|
residual: { type: "boolean", description: "the winner's change instead of the deposit" },
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,gGAAgG;IAChG,OAAO,EAAE,OAAO,CAAC;IACjB,8FAA8F;IAC9F,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,yFAAyF;IACzF,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpD,CAAC;AAEF,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpC,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG;IACzC,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD,CAAC;AA4bF,eAAO,MAAM,KAAK,EAAE,IAAI,EAUvB,CAAC;AAUF,+GAA+G;AAC/G,wBAAgB,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,GAAE,IAAI,EAAU,GAAG,OAAO,EAAE,CA0BvE"}
|
package/dist/tools.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { COINS, v3 } from "@esseyonsui/sui-sdk-v3";
|
|
2
|
-
import { FORCE, HEARTBEAT_SCHEMA, LIST_SCHEMA, LOAN_SCHEMA, OFFER_SCHEMA, OPEN_SCHEMA, TOPUP_SCHEMA, TRANSFER_SCHEMA, VIEW_SCHEMA, parseAmount, parseCoin, parseDenominations, parseForce, parseHeartbeat, parseListAll, parseLoanId, parseOfferArgs, parseOpen,
|
|
2
|
+
import { FORCE, HEARTBEAT_SCHEMA, LIST_SCHEMA, LOAN_SCHEMA, OFFER_SCHEMA, OPEN_SCHEMA, PAYEES, TOPUP_SCHEMA, TRANSFER_SCHEMA, VIEW_SCHEMA, parseAmount, parseCoin, parseDenominations, parseForce, parseHeartbeat, parseListAll, parseLoanId, parseOfferArgs, parseOpen, parsePayees, parseReceiver, parseRole, parseTopup, parseView, } from "./args.js";
|
|
3
3
|
import { assertNoSecrets, failureOf, ToolRefusal } from "./failure.js";
|
|
4
|
+
import { WAITS_LONG, WAITS_MEDIUM, WAITS_SEIZED, WAITS_SHORT } from "./pace.js";
|
|
4
5
|
import { redact } from "./redact.js";
|
|
5
6
|
import { BADGE_TOOLS } from "./tools-badge.js";
|
|
6
|
-
import { MORE, RECORD_TOOLS } from "./tools-more.js";
|
|
7
|
+
import { MORE, paidOut, RECORD_TOOLS } from "./tools-more.js";
|
|
7
8
|
import { SALE_TOOLS } from "./tools-sales.js";
|
|
8
9
|
const UNITS = "whole-number string in the coin's smallest unit";
|
|
9
10
|
const BIDDING = v3.LOAN_LIFECYCLE.indexOf("bidding");
|
|
@@ -121,14 +122,17 @@ const NOTES = [
|
|
|
121
122
|
{
|
|
122
123
|
name: "essey_notes_withdraw",
|
|
123
124
|
kind: "call",
|
|
124
|
-
description: `Withdraw ${UNITS} of a coin
|
|
125
|
+
description: `Withdraw ${UNITS} of a coin. Amount and address are public on chain, so with denominations the amount goes ` +
|
|
126
|
+
"out as denomination pieces, each to its own address in to; an amount that is not such a sum is refused with " +
|
|
127
|
+
"the largest one below it. force: true, or a coin without denominations: one exact withdraw to one address. " +
|
|
128
|
+
`Returns each piece's digest, ticket, amount and address.${WAITS_LONG}`,
|
|
125
129
|
inputSchema: obj({
|
|
126
130
|
coin: { type: "string", enum: [...COINS] },
|
|
127
131
|
amount: { type: "string", pattern: "^[1-9][0-9]*$", description: UNITS },
|
|
128
|
-
to:
|
|
132
|
+
to: PAYEES,
|
|
129
133
|
force: FORCE,
|
|
130
134
|
}, ["coin", "amount", "to"]),
|
|
131
|
-
run: async (ctx, args) =>
|
|
135
|
+
run: async (ctx, args) => paidOut(await ctx.client.notes.withdraw(parseCoin(args), parseAmount(args), parsePayees(args), parseForce(args))),
|
|
132
136
|
},
|
|
133
137
|
{
|
|
134
138
|
name: "essey_notes_receive_address",
|
|
@@ -140,7 +144,7 @@ const NOTES = [
|
|
|
140
144
|
{
|
|
141
145
|
name: "essey_notes_transfer",
|
|
142
146
|
kind: "call",
|
|
143
|
-
description: `Pay ${UNITS} into a note only the holder of a v3note address can open. No public amount moves
|
|
147
|
+
description: `Pay ${UNITS} into a note only the holder of a v3note address can open. No public amount moves.${WAITS_LONG}`,
|
|
144
148
|
inputSchema: TRANSFER_SCHEMA,
|
|
145
149
|
run: async (ctx, args) => landed(await ctx.client.notes.transfer(parseCoin(args), parseAmount(args), parseReceiver(args))),
|
|
146
150
|
},
|
|
@@ -164,7 +168,7 @@ const BORROWER = [
|
|
|
164
168
|
name: "essey_loan_settle",
|
|
165
169
|
kind: "call",
|
|
166
170
|
description: "Borrower, after the offer window: open every sealed offer and settle on the lowest eligible rate; the principal " +
|
|
167
|
-
|
|
171
|
+
`arrives as an own note. Returns the digest, ticket, rate, amount owed and maturity.${WAITS_MEDIUM}`,
|
|
168
172
|
inputSchema: LOAN_SCHEMA,
|
|
169
173
|
run: async (ctx, args) => {
|
|
170
174
|
const loan = parseLoanId(args);
|
|
@@ -181,7 +185,7 @@ const BORROWER = [
|
|
|
181
185
|
{
|
|
182
186
|
name: "essey_loan_repay",
|
|
183
187
|
kind: "call",
|
|
184
|
-
description:
|
|
188
|
+
description: `Borrower: repay the amount owed from own notes of the loan coin. Then call essey_loan_release.${WAITS_MEDIUM}`,
|
|
185
189
|
inputSchema: LOAN_SCHEMA,
|
|
186
190
|
run: async (ctx, args) => {
|
|
187
191
|
const { loan, terms, borrowerPk } = settled(ctx, parseLoanId(args));
|
|
@@ -191,7 +195,7 @@ const BORROWER = [
|
|
|
191
195
|
{
|
|
192
196
|
name: "essey_loan_release",
|
|
193
197
|
kind: "call",
|
|
194
|
-
description:
|
|
198
|
+
description: `Borrower, after repay: the whole collateral back to an own note, and the loan closes.${WAITS_MEDIUM}`,
|
|
195
199
|
inputSchema: LOAN_SCHEMA,
|
|
196
200
|
run: async (ctx, args) => landed(await ctx.client.loans.release(settled(ctx, parseLoanId(args)))),
|
|
197
201
|
},
|
|
@@ -205,7 +209,7 @@ const BORROWER = [
|
|
|
205
209
|
{
|
|
206
210
|
name: "essey_loan_reclaim_coll",
|
|
207
211
|
kind: "call",
|
|
208
|
-
description:
|
|
212
|
+
description: `Borrower, after cancel: the collateral of the cancelled loan back to an own note.${WAITS_LONG}`,
|
|
209
213
|
inputSchema: LOAN_SCHEMA,
|
|
210
214
|
run: async (ctx, args) => {
|
|
211
215
|
const loan = parseLoanId(args);
|
|
@@ -229,7 +233,8 @@ const BORROWER = [
|
|
|
229
233
|
{
|
|
230
234
|
name: "essey_loan_heartbeat",
|
|
231
235
|
kind: "call",
|
|
232
|
-
description: "Borrower: re-prove an active loan healthy at a heartbeat bucket's price floor."
|
|
236
|
+
description: "Borrower: re-prove an active loan healthy at a heartbeat bucket's price floor. k is 1, 4 or 8 (default 1); " +
|
|
237
|
+
`the floor is public and a deeper k shows a lower LTV, so the coarser k 1 leaks the least.${WAITS_SHORT}`,
|
|
233
238
|
inputSchema: HEARTBEAT_SCHEMA,
|
|
234
239
|
run: async (ctx, args) => {
|
|
235
240
|
const { loan, k } = parseHeartbeat(args);
|
|
@@ -239,7 +244,7 @@ const BORROWER = [
|
|
|
239
244
|
{
|
|
240
245
|
name: "essey_loan_topup",
|
|
241
246
|
kind: "call",
|
|
242
|
-
description:
|
|
247
|
+
description: `Borrower: add collateral from own notes to an active loan. Returns the digest, ticket and the new locked amount.${WAITS_SHORT}`,
|
|
243
248
|
inputSchema: TOPUP_SCHEMA,
|
|
244
249
|
run: async (ctx, args) => {
|
|
245
250
|
const { loan, add, asBorrower } = parseTopup(args);
|
|
@@ -257,7 +262,7 @@ const BORROWER = [
|
|
|
257
262
|
{
|
|
258
263
|
name: "essey_loan_collect_surplus",
|
|
259
264
|
kind: "call",
|
|
260
|
-
description:
|
|
265
|
+
description: `Borrower, after a liquidation or default: the collateral the seizure left over to an own note. Returns the value.${WAITS_SEIZED}`,
|
|
261
266
|
inputSchema: LOAN_SCHEMA,
|
|
262
267
|
run: async (ctx, args) => {
|
|
263
268
|
const r = await ctx.client.loans.collectSurplus(settled(ctx, parseLoanId(args)));
|
|
@@ -308,7 +313,7 @@ const LENDER = [
|
|
|
308
313
|
name: "essey_loan_offer",
|
|
309
314
|
kind: "call",
|
|
310
315
|
description: `Lender: offer the requested principal at rateBps from own notes of the loan coin, sealed to the borrower. ${PLANNED} ` +
|
|
311
|
-
|
|
316
|
+
`Returns the digest, ticket, and the principal and rate offered.${WAITS_MEDIUM}`,
|
|
312
317
|
inputSchema: OFFER_SCHEMA,
|
|
313
318
|
run: async (ctx, args) => {
|
|
314
319
|
const p = parseOfferArgs(args);
|
|
@@ -320,7 +325,7 @@ const LENDER = [
|
|
|
320
325
|
{
|
|
321
326
|
name: "essey_loan_collect",
|
|
322
327
|
kind: "call",
|
|
323
|
-
description:
|
|
328
|
+
description: `Lender, after the borrower repaid: the repayment to an own note. Returns the value.${WAITS_LONG}`,
|
|
324
329
|
inputSchema: LOAN_SCHEMA,
|
|
325
330
|
run: async (ctx, args) => {
|
|
326
331
|
const loan = parseLoanId(args);
|
|
@@ -331,7 +336,7 @@ const LENDER = [
|
|
|
331
336
|
{
|
|
332
337
|
name: "essey_loan_reclaim",
|
|
333
338
|
kind: "call",
|
|
334
|
-
description:
|
|
339
|
+
description: `Lender: take back the principal an offer locked once the round resolved without it.${WAITS_LONG}`,
|
|
335
340
|
inputSchema: LOAN_SCHEMA,
|
|
336
341
|
run: async (ctx, args) => {
|
|
337
342
|
const loan = parseLoanId(args);
|
|
@@ -341,7 +346,7 @@ const LENDER = [
|
|
|
341
346
|
{
|
|
342
347
|
name: "essey_loan_collect_seized",
|
|
343
348
|
kind: "call",
|
|
344
|
-
description:
|
|
349
|
+
description: `Lender, after a liquidation or default: its share of the seized collateral to an own note.${WAITS_SEIZED}`,
|
|
345
350
|
inputSchema: LOAN_SCHEMA,
|
|
346
351
|
run: async (ctx, args) => {
|
|
347
352
|
const loan = parseLoanId(args);
|
|
@@ -388,8 +393,7 @@ const VIEWS = [
|
|
|
388
393
|
ltvBps: status.ltvBps,
|
|
389
394
|
underwater: status.underwater,
|
|
390
395
|
liquidationPrice: status.liquidationPrice,
|
|
391
|
-
|
|
392
|
-
coveredAtDefaultK: status.bestBucketK !== null,
|
|
396
|
+
coveredAtDefaultK: status.coveredAtDefaultK,
|
|
393
397
|
};
|
|
394
398
|
},
|
|
395
399
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esseyonsui/sui-mcp-v3",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@esseyonsui/sui-sdk-v3": "0.1.
|
|
32
|
+
"@esseyonsui/sui-sdk-v3": "0.1.8",
|
|
33
33
|
"@mysten/seal": "1.5.1",
|
|
34
34
|
"@mysten/sui": "2.37.0",
|
|
35
35
|
"@noble/ciphers": "2.4.0",
|