candle-launch-bot 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.
Potentially problematic release.
This version of candle-launch-bot might be problematic. Click here for more details.
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +400 -2
- package/bin/candle-launch-bot +7 -0
- package/dist/alerts.d.ts +28 -0
- package/dist/alerts.js +82 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +321 -0
- package/dist/config.d.ts +88 -0
- package/dist/config.js +244 -0
- package/dist/detect/detector.d.ts +111 -0
- package/dist/detect/detector.js +348 -0
- package/dist/engine.d.ts +103 -0
- package/dist/engine.js +585 -0
- package/dist/exec/executor.d.ts +149 -0
- package/dist/exec/executor.js +859 -0
- package/dist/exec/fills.d.ts +25 -0
- package/dist/exec/fills.js +53 -0
- package/dist/exec/trader.d.ts +109 -0
- package/dist/exec/trader.js +310 -0
- package/dist/filters.d.ts +26 -0
- package/dist/filters.js +92 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -0
- package/dist/init.d.ts +23 -0
- package/dist/init.js +192 -0
- package/dist/ledger.d.ts +189 -0
- package/dist/ledger.js +243 -0
- package/dist/log.d.ts +22 -0
- package/dist/log.js +40 -0
- package/dist/market/curve.d.ts +80 -0
- package/dist/market/curve.js +168 -0
- package/dist/market/reader.d.ts +37 -0
- package/dist/market/reader.js +106 -0
- package/dist/redact.d.ts +20 -0
- package/dist/redact.js +111 -0
- package/dist/solana/base58.d.ts +4 -0
- package/dist/solana/base58.js +45 -0
- package/dist/solana/logs-ws.d.ts +25 -0
- package/dist/solana/logs-ws.js +116 -0
- package/dist/solana/pda.d.ts +12 -0
- package/dist/solana/pda.js +70 -0
- package/dist/solana/rpc.d.ts +29 -0
- package/dist/solana/rpc.js +96 -0
- package/dist/strategies/hold.d.ts +3 -0
- package/dist/strategies/hold.js +6 -0
- package/dist/strategies/ladder.d.ts +8 -0
- package/dist/strategies/ladder.js +51 -0
- package/dist/strategies/load.d.ts +5 -0
- package/dist/strategies/load.js +44 -0
- package/dist/strategies/preGrad.d.ts +10 -0
- package/dist/strategies/preGrad.js +32 -0
- package/dist/strategies/time.d.ts +6 -0
- package/dist/strategies/time.js +16 -0
- package/dist/strategies/tpsl.d.ts +8 -0
- package/dist/strategies/tpsl.js +30 -0
- package/dist/strategies/types.d.ts +55 -0
- package/dist/strategies/types.js +31 -0
- package/examples/dry.json +32 -0
- package/examples/live-embedded.json +14 -0
- package/examples/live-linked.json +15 -0
- package/examples/strategies/breakeven-stop.js +22 -0
- package/examples/strategies/stale-coin.js +18 -0
- package/examples/strategies/timeboxed-tp.js +18 -0
- package/package.json +60 -4
- package/skills/candle-launch-bot/SKILL.md +71 -0
package/dist/init.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `candle-launch-bot init`: write a validated config. Interactive in a terminal; fully driven by flags with `--yes`
|
|
3
|
+
* (for scripts and agents). The config it writes is in dry mode unless `--mode live` is given.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { dirname, resolve } from "node:path";
|
|
7
|
+
import { createInterface } from "node:readline/promises";
|
|
8
|
+
import { LAUNCH_MODES, parseConfig, ConfigError } from "./config.js";
|
|
9
|
+
import { loadStrategy } from "./strategies/load.js";
|
|
10
|
+
const DEFAULT_API = "https://api.alpha.candle.tv";
|
|
11
|
+
/** A valid address that is nobody's wallet: lets a dry run start before a wallet is chosen. */
|
|
12
|
+
export const PLACEHOLDER_WALLET = "11111111111111111111111111111111";
|
|
13
|
+
const num = (v, what) => {
|
|
14
|
+
const n = Number(v);
|
|
15
|
+
if (!Number.isFinite(n))
|
|
16
|
+
throw new ConfigError(`init: ${what} must be a number (got "${v}")`);
|
|
17
|
+
return n;
|
|
18
|
+
};
|
|
19
|
+
async function embeddedAddress(apiUrl, key, f) {
|
|
20
|
+
const r = await f(apiUrl + "/api/v1/agent/wallets/embedded", { headers: { "x-api-key": key, accept: "application/json" }, signal: AbortSignal.timeout(20_000) });
|
|
21
|
+
if (!r.ok)
|
|
22
|
+
return null;
|
|
23
|
+
const b = (await r.json());
|
|
24
|
+
return typeof b?.wallets?.solana?.address === "string" ? b.wallets.solana.address : null;
|
|
25
|
+
}
|
|
26
|
+
async function linkedAddresses(apiUrl, key, f) {
|
|
27
|
+
const r = await f(apiUrl + "/api/v1/agent/wallets/trading", { headers: { "x-api-key": key, accept: "application/json" }, signal: AbortSignal.timeout(20_000) });
|
|
28
|
+
if (!r.ok)
|
|
29
|
+
return [];
|
|
30
|
+
const b = (await r.json());
|
|
31
|
+
return (b?.page ?? []).filter((w) => w?.chain === "solana" && typeof w?.address === "string").map((w) => w.address);
|
|
32
|
+
}
|
|
33
|
+
/** Exit block from flags: --exit <name> plus that strategy's parameters, or --exit-module <file>. */
|
|
34
|
+
function exitFrom(opt) {
|
|
35
|
+
if (opt["exit-module"]) {
|
|
36
|
+
// Your own file: its params come from --exit-params (JSON), nothing is assumed.
|
|
37
|
+
let params = {};
|
|
38
|
+
if (opt["exit-params"]) {
|
|
39
|
+
try {
|
|
40
|
+
params = JSON.parse(opt["exit-params"]);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new ConfigError("init: --exit-params must be a JSON object, e.g. '{\"arm\":1.5}'");
|
|
44
|
+
}
|
|
45
|
+
if (!params || typeof params !== "object" || Array.isArray(params))
|
|
46
|
+
throw new ConfigError("init: --exit-params must be a JSON object");
|
|
47
|
+
}
|
|
48
|
+
return { ...params, strategy: opt.exit ?? "custom", module: opt["exit-module"] };
|
|
49
|
+
}
|
|
50
|
+
const name = opt.exit ?? "tpsl";
|
|
51
|
+
const e = { strategy: name };
|
|
52
|
+
const put = (flag, key) => {
|
|
53
|
+
if (opt[flag] !== undefined)
|
|
54
|
+
e[key] = num(opt[flag], `--${flag}`);
|
|
55
|
+
};
|
|
56
|
+
if (name === "tpsl") {
|
|
57
|
+
put("take-profit", "takeProfit");
|
|
58
|
+
put("stop-loss", "stopLoss");
|
|
59
|
+
put("trailing", "trailing");
|
|
60
|
+
if (e.takeProfit === undefined && e.stopLoss === undefined && e.trailing === undefined)
|
|
61
|
+
Object.assign(e, { takeProfit: 2, stopLoss: 0.5 });
|
|
62
|
+
}
|
|
63
|
+
else if (name === "time") {
|
|
64
|
+
put("after-sec", "afterSec");
|
|
65
|
+
if (e.afterSec === undefined)
|
|
66
|
+
e.afterSec = 900;
|
|
67
|
+
}
|
|
68
|
+
else if (name === "preGrad") {
|
|
69
|
+
put("progress", "progress");
|
|
70
|
+
put("fraction", "fraction");
|
|
71
|
+
put("stop-loss", "stopLoss");
|
|
72
|
+
if (e.progress === undefined)
|
|
73
|
+
e.progress = 0.8;
|
|
74
|
+
}
|
|
75
|
+
else if (name === "ladder") {
|
|
76
|
+
// --rungs "2:0.3,5:0.3,10:0.2" (at multiple : sell this share of the original size)
|
|
77
|
+
const rungs = (opt.rungs ?? "2:0.3,5:0.3,10:0.2").split(",").map((r) => {
|
|
78
|
+
const [at, sell] = r.split(":");
|
|
79
|
+
return { at: num(at, "--rungs at"), sell: num(sell, "--rungs sell") };
|
|
80
|
+
});
|
|
81
|
+
e.rungs = rungs;
|
|
82
|
+
put("stop-loss", "stopLoss");
|
|
83
|
+
}
|
|
84
|
+
else if (name !== "hold") {
|
|
85
|
+
throw new ConfigError(`init: --exit "${name}" is not a built-in (hold, tpsl, time, ladder, preGrad); use --exit-module <file> for your own`);
|
|
86
|
+
}
|
|
87
|
+
return e;
|
|
88
|
+
}
|
|
89
|
+
/** Build the config object from flags (and answers), validate it, and return it with notes for the user. */
|
|
90
|
+
export async function buildInitConfig(opt, io) {
|
|
91
|
+
const notes = [];
|
|
92
|
+
const ask = async (key, q, def) => (opt[key] !== undefined ? opt[key] : io.ask ? (await io.ask(q, def)).trim() || def : def);
|
|
93
|
+
const mode = await ask("mode", "Mode (dry = decide and log only, live = trade)", "dry");
|
|
94
|
+
const payer = await ask("payer", "Payer: embedded (Candle signs, API key only) or linked (TEE wallet, local key signer)", "embedded");
|
|
95
|
+
if (payer !== "embedded" && payer !== "linked")
|
|
96
|
+
throw new ConfigError('init: --payer must be "embedded" or "linked"');
|
|
97
|
+
const apiKeyEnv = await ask("key-env", "Name of the env var holding your Candle API key", "CANDLE_API_KEY");
|
|
98
|
+
const apiUrl = opt["api-url"] ?? DEFAULT_API;
|
|
99
|
+
let wallet = opt.wallet;
|
|
100
|
+
const key = io.env[apiKeyEnv];
|
|
101
|
+
if (!wallet && key) {
|
|
102
|
+
try {
|
|
103
|
+
if (payer === "embedded") {
|
|
104
|
+
const a = await embeddedAddress(apiUrl, key, io.fetch);
|
|
105
|
+
if (a) {
|
|
106
|
+
wallet = await ask("wallet", `Wallet (the key's embedded wallet is ${a})`, a);
|
|
107
|
+
notes.push(`wallet: fetched the key's embedded wallet ${a}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const list = await linkedAddresses(apiUrl, key, io.fetch);
|
|
112
|
+
if (list.length) {
|
|
113
|
+
wallet = await ask("wallet", `Wallet (the key's TEE wallets: ${list.join(", ")})`, list[0]);
|
|
114
|
+
notes.push(`wallet: the key has ${list.length} Solana TEE wallet(s)`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
notes.push("wallet: could not reach Candle to look it up");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!wallet)
|
|
123
|
+
wallet = await ask("wallet", "Wallet address (Solana)", mode === "dry" ? PLACEHOLDER_WALLET : "");
|
|
124
|
+
if (wallet === PLACEHOLDER_WALLET) {
|
|
125
|
+
if (mode === "live")
|
|
126
|
+
throw new ConfigError("init: live mode needs your real wallet (--wallet, or set the API key so init can look it up)");
|
|
127
|
+
notes.push("wallet: a placeholder for the dry run; set your wallet before going live");
|
|
128
|
+
}
|
|
129
|
+
const sol = num(await ask("sol", "SOL per launch (ticket)", "0.01"), "--sol");
|
|
130
|
+
const maxOpen = num(await ask("max-open", "Most positions open at once", "3"), "--max-open");
|
|
131
|
+
const lifetimeSol = num(await ask("lifetime-sol", "Most SOL ever spent on buys (lifetime cap)", String(Math.round(sol * 10 * 1e6) / 1e6)), "--lifetime-sol");
|
|
132
|
+
const modes = (await ask("modes", `Launch modes, comma separated (${LAUNCH_MODES.filter((m) => !m.startsWith("test-")).join(", ")})`, "open,exp-custom")).split(",").map((s) => s.trim()).filter(Boolean);
|
|
133
|
+
const maxAgeSec = num(await ask("max-age", "Skip launches older than (seconds)", "60"), "--max-age");
|
|
134
|
+
const maxImpactBps = num(await ask("max-impact", "Skip when your buy moves the price more than (bps)", "300"), "--max-impact");
|
|
135
|
+
const slippage = num(opt.slippage ?? "500", "--slippage");
|
|
136
|
+
if (io.ask && opt.exit === undefined && opt["exit-module"] === undefined) {
|
|
137
|
+
opt = { ...opt, exit: await io.ask("Exit strategy (hold, tpsl, time, ladder, preGrad)", "tpsl") };
|
|
138
|
+
if (opt.exit === "tpsl")
|
|
139
|
+
opt = { ...opt, "take-profit": await io.ask("Take profit at multiple", "2"), "stop-loss": await io.ask("Stop loss at multiple (0 = none)", "0.5") };
|
|
140
|
+
else if (opt.exit === "time")
|
|
141
|
+
opt = { ...opt, "after-sec": await io.ask("Sell after (seconds)", "900") };
|
|
142
|
+
else if (opt.exit === "preGrad")
|
|
143
|
+
opt = { ...opt, progress: await io.ask("Sell at curve progress (0-1)", "0.8") };
|
|
144
|
+
else if (opt.exit === "ladder")
|
|
145
|
+
opt = { ...opt, rungs: await io.ask("Rungs multiple:fraction, comma separated", "2:0.3,5:0.3,10:0.2") };
|
|
146
|
+
}
|
|
147
|
+
const exit = exitFrom(opt);
|
|
148
|
+
const config = {
|
|
149
|
+
mode,
|
|
150
|
+
payer,
|
|
151
|
+
apiKeyEnv,
|
|
152
|
+
...(opt["api-url"] ? { apiUrl } : {}),
|
|
153
|
+
...(opt["rpc-env"] ? { rpcUrlEnv: opt["rpc-env"] } : {}),
|
|
154
|
+
...(opt["rpc-ws-env"] ? { rpcWsUrlEnv: opt["rpc-ws-env"] } : {}),
|
|
155
|
+
wallet,
|
|
156
|
+
stateDir: opt["state-dir"] ?? (mode === "live" ? "./state-live" : "./state-dry"),
|
|
157
|
+
buy: { sol, maxSlippageBps: slippage, maxOpen, lifetimeSol },
|
|
158
|
+
filters: { launchModes: modes, maxAgeSec, maxImpactBps },
|
|
159
|
+
exit,
|
|
160
|
+
};
|
|
161
|
+
if (payer === "linked") {
|
|
162
|
+
const store = opt.signer ?? "keychain";
|
|
163
|
+
config.signer = store === "keychain" ? { store } : store === "env" ? { store, pemEnv: opt["signer-env"] ?? "CANDLE_SIGNER_PEM" } : { store: "file", path: opt["signer-path"] ?? "./signer.pem.enc", passphraseEnv: opt["signer-pass-env"] ?? "CANDLE_SIGNER_PASSPHRASE" };
|
|
164
|
+
notes.push(`signer: ${store} (see "Pick a payer" in the README)`);
|
|
165
|
+
}
|
|
166
|
+
if (opt.webhook)
|
|
167
|
+
config.alerts = { webhookEnv: opt.webhook };
|
|
168
|
+
return { config, notes };
|
|
169
|
+
}
|
|
170
|
+
/** The `init` command. Returns a process exit code. */
|
|
171
|
+
export async function init(opt, io) {
|
|
172
|
+
const out = resolve(opt.out ?? "bot.json");
|
|
173
|
+
if (existsSync(out) && opt.force === undefined) {
|
|
174
|
+
io.out(`${out} exists; pass --force to overwrite\n`);
|
|
175
|
+
return 2;
|
|
176
|
+
}
|
|
177
|
+
const { config, notes } = await buildInitConfig(opt, io);
|
|
178
|
+
// Validate exactly as `run` will: the config and its exit strategy.
|
|
179
|
+
const cfg = parseConfig(config, dirname(out));
|
|
180
|
+
await loadStrategy(cfg.exit, cfg.configDir);
|
|
181
|
+
writeFileSync(out, JSON.stringify(config, null, 2) + "\n");
|
|
182
|
+
io.out(`wrote ${out} (mode ${cfg.mode}, payer ${cfg.payer})\n`);
|
|
183
|
+
for (const n of notes)
|
|
184
|
+
io.out(` ${n}\n`);
|
|
185
|
+
io.out(`next: candle-launch-bot scan --config ${opt.out ?? "bot.json"} --for 600\n`);
|
|
186
|
+
return 0;
|
|
187
|
+
}
|
|
188
|
+
/** Terminal prompts for `init` (only when stdin is a TTY and --yes is not given). */
|
|
189
|
+
export function terminalAsk() {
|
|
190
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
191
|
+
return { ask: (q, def) => rl.question(`${q}${def ? ` [${def}]` : ""}: `), close: () => rl.close() };
|
|
192
|
+
}
|
package/dist/ledger.d.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local SQLite ledger (node:sqlite, no native addon). Raw token and lamport amounts are stored as decimal TEXT
|
|
3
|
+
* and handled as bigint. One process owns a state dir (a lock file guards it); claims are still single
|
|
4
|
+
* statements so a second sweeper could never take the same order.
|
|
5
|
+
*/
|
|
6
|
+
import { DatabaseSync } from "node:sqlite";
|
|
7
|
+
export type PositionStatus = "opening" | "open" | "closed" | "failed" | "exit_stuck";
|
|
8
|
+
export type OrderStatus = "pending" | "inflight" | "filled" | "rejected" | "reverted" | "failed";
|
|
9
|
+
export type Side = "buy" | "sell";
|
|
10
|
+
export type QtySource = "onchain" | "server" | "minout" | "wallet" | "dry";
|
|
11
|
+
export interface PositionRow {
|
|
12
|
+
id: number;
|
|
13
|
+
mint: string;
|
|
14
|
+
chain: string;
|
|
15
|
+
status: PositionStatus;
|
|
16
|
+
dry: number;
|
|
17
|
+
opened_at: number;
|
|
18
|
+
closed_at: number | null;
|
|
19
|
+
decimals: number;
|
|
20
|
+
qty_raw: string;
|
|
21
|
+
qty_source: QtySource | null;
|
|
22
|
+
remaining_raw: string;
|
|
23
|
+
cost_lamports: string;
|
|
24
|
+
proceeds_lamports: string;
|
|
25
|
+
network_fees_lamports: string;
|
|
26
|
+
peak_price: number;
|
|
27
|
+
last_price: number | null;
|
|
28
|
+
exit_orders_failed: number;
|
|
29
|
+
strategy: string;
|
|
30
|
+
launch_json: string;
|
|
31
|
+
note: string | null;
|
|
32
|
+
/** Lamports moved into (or back out of) token accounts by this position's fills: rent, a cost until reclaimed. */
|
|
33
|
+
rent_lamports: string;
|
|
34
|
+
/** Tokens written off because the wallet held less than booked (not sold; excluded from soldFraction). */
|
|
35
|
+
written_down_raw: string;
|
|
36
|
+
}
|
|
37
|
+
export interface OrderRow {
|
|
38
|
+
id: number;
|
|
39
|
+
position_id: number;
|
|
40
|
+
side: Side;
|
|
41
|
+
client_trade_id: string;
|
|
42
|
+
amount_raw: string;
|
|
43
|
+
slippage_bps: number;
|
|
44
|
+
status: OrderStatus;
|
|
45
|
+
attempts: number;
|
|
46
|
+
max_attempts: number;
|
|
47
|
+
next_attempt_at: number;
|
|
48
|
+
lease_until: number;
|
|
49
|
+
created_at: number;
|
|
50
|
+
updated_at: number;
|
|
51
|
+
reason: string;
|
|
52
|
+
signature: string | null;
|
|
53
|
+
signed_at: number | null;
|
|
54
|
+
last_error_code: string | null;
|
|
55
|
+
last_error: string | null;
|
|
56
|
+
fill_json: string | null;
|
|
57
|
+
qty_source: QtySource | null;
|
|
58
|
+
manual: number;
|
|
59
|
+
/** Buys only: past this time no new attempt is built (the filter's decision is stale). */
|
|
60
|
+
deadline_at: number | null;
|
|
61
|
+
expected_out_raw: string | null;
|
|
62
|
+
min_out_raw: string | null;
|
|
63
|
+
/** Status / job reads that failed for this order (no attempt spent; alerted in buckets). */
|
|
64
|
+
read_failures: number;
|
|
65
|
+
/** Reads of a landed transaction that failed (capped by TX_READ_CAP before booking from Candle's numbers). */
|
|
66
|
+
tx_read_failures: number;
|
|
67
|
+
/** 1 once any attempt of this order produced a signed transaction: it can no longer be assumed unspent. */
|
|
68
|
+
ever_signed: number;
|
|
69
|
+
/** The recent blockhash of the persisted signature's transaction (its death is judged on chain from it). */
|
|
70
|
+
blockhash: string | null;
|
|
71
|
+
/** Candle's platform fee rate on this order's build. */
|
|
72
|
+
fee_bps: number | null;
|
|
73
|
+
/** 1 when Candle's job reported this order's signature confirmed: it is never cleared. */
|
|
74
|
+
candle_confirmed: number;
|
|
75
|
+
/** 1 once the one same-id check build at the attempt cap has been used (payer main, failed job). */
|
|
76
|
+
final_check: number;
|
|
77
|
+
/** When Candle's job was first seen `built` for this order (payer main), and whether the one probe ran. */
|
|
78
|
+
built_seen_at: number | null;
|
|
79
|
+
probed: number;
|
|
80
|
+
/** A buy that is ending (JSON {status, code, detail}): from then on only the wallet/tx scan runs, never a build. */
|
|
81
|
+
ending: string | null;
|
|
82
|
+
/** Re-scans of the wallet for this ending buy's tokens (RPC lag), bounded by ADOPT_SCAN_CAP. */
|
|
83
|
+
adopt_scans: number;
|
|
84
|
+
/** More signatures booked to this order (a double execution), JSON list. */
|
|
85
|
+
extra_signatures: string | null;
|
|
86
|
+
/** Attempts that threw inside the executor (alerted in buckets). */
|
|
87
|
+
internal_errors: number;
|
|
88
|
+
}
|
|
89
|
+
export interface LaunchRow {
|
|
90
|
+
mint: string;
|
|
91
|
+
chain: string;
|
|
92
|
+
first_source: string;
|
|
93
|
+
first_seen_at: number;
|
|
94
|
+
launched_at: number | null;
|
|
95
|
+
api_seen_at: number | null;
|
|
96
|
+
chain_seen_at: number | null;
|
|
97
|
+
api_latency_ms: number | null;
|
|
98
|
+
chain_latency_ms: number | null;
|
|
99
|
+
symbol: string | null;
|
|
100
|
+
name: string | null;
|
|
101
|
+
creator: string | null;
|
|
102
|
+
launch_mode: string | null;
|
|
103
|
+
decision: string | null;
|
|
104
|
+
reason: string | null;
|
|
105
|
+
}
|
|
106
|
+
export declare class Ledger {
|
|
107
|
+
readonly db: DatabaseSync;
|
|
108
|
+
private depth;
|
|
109
|
+
constructor(path: string);
|
|
110
|
+
/** The modes (dry / live) this ledger already holds positions for. */
|
|
111
|
+
modes(): {
|
|
112
|
+
dry: boolean;
|
|
113
|
+
live: boolean;
|
|
114
|
+
};
|
|
115
|
+
close(): void;
|
|
116
|
+
/** A transaction; nested calls join the outer one. */
|
|
117
|
+
tx<T>(fn: () => T): T;
|
|
118
|
+
createPosition(p: {
|
|
119
|
+
mint: string;
|
|
120
|
+
chain: string;
|
|
121
|
+
dry: boolean;
|
|
122
|
+
now: number;
|
|
123
|
+
decimals: number;
|
|
124
|
+
strategy: string;
|
|
125
|
+
launch: unknown;
|
|
126
|
+
note?: string;
|
|
127
|
+
}): number;
|
|
128
|
+
position(id: number): PositionRow | undefined;
|
|
129
|
+
positionsByStatus(...statuses: PositionStatus[]): PositionRow[];
|
|
130
|
+
allPositions(): PositionRow[];
|
|
131
|
+
/** Entries in a coin that may hold or have held tokens: every position except a buy that definitely never landed. */
|
|
132
|
+
entriesForMint(mint: string, dry: boolean): number;
|
|
133
|
+
updatePosition(id: number, fields: Partial<Omit<PositionRow, "id">>): void;
|
|
134
|
+
createOrder(o: {
|
|
135
|
+
positionId: number;
|
|
136
|
+
side: Side;
|
|
137
|
+
clientTradeId: string;
|
|
138
|
+
amountRaw: bigint;
|
|
139
|
+
slippageBps: number;
|
|
140
|
+
maxAttempts: number;
|
|
141
|
+
now: number;
|
|
142
|
+
reason: string;
|
|
143
|
+
manual?: boolean;
|
|
144
|
+
deadlineAt?: number | null;
|
|
145
|
+
expectedOutRaw?: bigint | null;
|
|
146
|
+
}): number;
|
|
147
|
+
order(id: number): OrderRow | undefined;
|
|
148
|
+
ordersFor(positionId: number): OrderRow[];
|
|
149
|
+
openOrderFor(positionId: number): OrderRow | undefined;
|
|
150
|
+
/** Claim due orders in one statement: lease them so no other sweep (or a restart) re-runs them mid-attempt. */
|
|
151
|
+
claimDue(now: number, leaseMs: number, limit?: number, opts?: {
|
|
152
|
+
dryOnly?: boolean;
|
|
153
|
+
onlyIds?: number[];
|
|
154
|
+
excludeIds?: number[];
|
|
155
|
+
side?: "buy" | "sell";
|
|
156
|
+
reconcileOnly?: boolean;
|
|
157
|
+
}): OrderRow[];
|
|
158
|
+
updateOrder(id: number, fields: Partial<Omit<OrderRow, "id">>): void;
|
|
159
|
+
startAttempt(orderId: number, n: number, now: number): number;
|
|
160
|
+
endAttempt(id: number, now: number, outcome: string, code: string | null, errorJson: string | null): void;
|
|
161
|
+
attemptsFor(orderId: number): Array<{
|
|
162
|
+
n: number;
|
|
163
|
+
started_at: number;
|
|
164
|
+
ended_at: number | null;
|
|
165
|
+
outcome: string | null;
|
|
166
|
+
error_code: string | null;
|
|
167
|
+
error_json: string | null;
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* Lamports committed to buys (tickets; Candle's platform fee comes on top): every buy order except a revert (fees
|
|
171
|
+
* only) and a rejection proven unspent (never signed). A rejection after something was signed still counts.
|
|
172
|
+
*/
|
|
173
|
+
lifetimeBuyLamports(dry: boolean): bigint;
|
|
174
|
+
queueHealth(now: number, dry: boolean): {
|
|
175
|
+
pending: number;
|
|
176
|
+
inflight: number;
|
|
177
|
+
oldestAgeMs: number | null;
|
|
178
|
+
maxAttempts: number;
|
|
179
|
+
terminalFailed: number;
|
|
180
|
+
stuckPositions: number;
|
|
181
|
+
};
|
|
182
|
+
/** Every signature already booked to an order (so a found transaction is never booked twice). */
|
|
183
|
+
bookedSignatures(): string[];
|
|
184
|
+
recordLaunch(l: LaunchRow): void;
|
|
185
|
+
launch(mint: string): LaunchRow | undefined;
|
|
186
|
+
recentLaunches(limit?: number): LaunchRow[];
|
|
187
|
+
/** Count an alert under a key that carries the worsening dimension; returns true when it should be announced. */
|
|
188
|
+
alert(key: string, message: string, now: number, renotifyMs?: number): boolean;
|
|
189
|
+
}
|
package/dist/ledger.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local SQLite ledger (node:sqlite, no native addon). Raw token and lamport amounts are stored as decimal TEXT
|
|
3
|
+
* and handled as bigint. One process owns a state dir (a lock file guards it); claims are still single
|
|
4
|
+
* statements so a second sweeper could never take the same order.
|
|
5
|
+
*/
|
|
6
|
+
import { DatabaseSync } from "node:sqlite";
|
|
7
|
+
const SCHEMA = `
|
|
8
|
+
create table if not exists positions (
|
|
9
|
+
id integer primary key,
|
|
10
|
+
mint text not null, chain text not null, status text not null, dry integer not null,
|
|
11
|
+
opened_at integer not null, closed_at integer, decimals integer not null,
|
|
12
|
+
qty_raw text not null default '0', qty_source text, remaining_raw text not null default '0',
|
|
13
|
+
cost_lamports text not null default '0', proceeds_lamports text not null default '0', network_fees_lamports text not null default '0',
|
|
14
|
+
peak_price real not null default 0, last_price real, exit_orders_failed integer not null default 0,
|
|
15
|
+
strategy text not null, launch_json text not null, note text
|
|
16
|
+
);
|
|
17
|
+
create index if not exists positions_status on positions(status);
|
|
18
|
+
create index if not exists positions_mint on positions(mint);
|
|
19
|
+
create table if not exists orders (
|
|
20
|
+
id integer primary key,
|
|
21
|
+
position_id integer not null references positions(id), side text not null,
|
|
22
|
+
client_trade_id text not null unique, amount_raw text not null, slippage_bps integer not null,
|
|
23
|
+
status text not null, attempts integer not null default 0, max_attempts integer not null,
|
|
24
|
+
next_attempt_at integer not null, lease_until integer not null default 0,
|
|
25
|
+
created_at integer not null, updated_at integer not null, reason text not null,
|
|
26
|
+
signature text, signed_at integer, last_error_code text, last_error text, fill_json text, qty_source text,
|
|
27
|
+
manual integer not null default 0
|
|
28
|
+
);
|
|
29
|
+
create index if not exists orders_status on orders(status, next_attempt_at);
|
|
30
|
+
create table if not exists attempts (
|
|
31
|
+
id integer primary key, order_id integer not null references orders(id), n integer not null,
|
|
32
|
+
started_at integer not null, ended_at integer, outcome text, error_code text, error_json text
|
|
33
|
+
);
|
|
34
|
+
create table if not exists launches (
|
|
35
|
+
mint text primary key, chain text not null, first_source text not null, first_seen_at integer not null,
|
|
36
|
+
launched_at integer, api_seen_at integer, chain_seen_at integer, api_latency_ms integer, chain_latency_ms integer,
|
|
37
|
+
symbol text, name text, creator text, launch_mode text, decision text, reason text
|
|
38
|
+
);
|
|
39
|
+
create table if not exists alerts (
|
|
40
|
+
key text primary key, first_at integer not null, last_at integer not null, count integer not null, message text not null
|
|
41
|
+
);
|
|
42
|
+
`;
|
|
43
|
+
export class Ledger {
|
|
44
|
+
db;
|
|
45
|
+
depth = 0;
|
|
46
|
+
constructor(path) {
|
|
47
|
+
this.db = new DatabaseSync(path);
|
|
48
|
+
this.db.exec("pragma journal_mode = wal; pragma synchronous = full; pragma busy_timeout = 5000;");
|
|
49
|
+
this.db.exec(SCHEMA);
|
|
50
|
+
const cols = new Set(this.db.prepare("pragma table_info(orders)").all().map((c) => c.name));
|
|
51
|
+
for (const [c, ddl] of [["deadline_at", "integer"], ["expected_out_raw", "text"], ["min_out_raw", "text"], ["read_failures", "integer not null default 0"],
|
|
52
|
+
["tx_read_failures", "integer not null default 0"], ["ever_signed", "integer not null default 0"], ["blockhash", "text"], ["fee_bps", "integer"],
|
|
53
|
+
["candle_confirmed", "integer not null default 0"], ["final_check", "integer not null default 0"], ["built_seen_at", "integer"], ["probed", "integer not null default 0"],
|
|
54
|
+
["ending", "text"], ["adopt_scans", "integer not null default 0"], ["extra_signatures", "text"], ["internal_errors", "integer not null default 0"]])
|
|
55
|
+
if (!cols.has(c))
|
|
56
|
+
this.db.exec(`alter table orders add column ${c} ${ddl}`);
|
|
57
|
+
const pcols = new Set(this.db.prepare("pragma table_info(positions)").all().map((c) => c.name));
|
|
58
|
+
for (const [c, ddl] of [["rent_lamports", "text not null default '0'"], ["written_down_raw", "text not null default '0'"]])
|
|
59
|
+
if (!pcols.has(c))
|
|
60
|
+
this.db.exec(`alter table positions add column ${c} ${ddl}`);
|
|
61
|
+
}
|
|
62
|
+
/** The modes (dry / live) this ledger already holds positions for. */
|
|
63
|
+
modes() {
|
|
64
|
+
const r = this.db.prepare("select sum(dry = 1) d, sum(dry = 0) l from positions").get();
|
|
65
|
+
return { dry: Number(r.d ?? 0) > 0, live: Number(r.l ?? 0) > 0 };
|
|
66
|
+
}
|
|
67
|
+
close() {
|
|
68
|
+
this.db.close();
|
|
69
|
+
}
|
|
70
|
+
/** A transaction; nested calls join the outer one. */
|
|
71
|
+
tx(fn) {
|
|
72
|
+
if (this.depth > 0) {
|
|
73
|
+
this.depth++;
|
|
74
|
+
try {
|
|
75
|
+
return fn();
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
this.depth--;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.db.exec("begin immediate");
|
|
82
|
+
this.depth = 1;
|
|
83
|
+
try {
|
|
84
|
+
const r = fn();
|
|
85
|
+
this.db.exec("commit");
|
|
86
|
+
return r;
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
this.db.exec("rollback");
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
this.depth = 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// ---------------------------------------------------------------- positions
|
|
97
|
+
createPosition(p) {
|
|
98
|
+
const r = this.db
|
|
99
|
+
.prepare("insert into positions (mint, chain, status, dry, opened_at, decimals, strategy, launch_json, note) values (?, ?, 'opening', ?, ?, ?, ?, ?, ?)")
|
|
100
|
+
.run(p.mint, p.chain, p.dry ? 1 : 0, p.now, p.decimals, p.strategy, JSON.stringify(p.launch ?? null), p.note ?? null);
|
|
101
|
+
return Number(r.lastInsertRowid);
|
|
102
|
+
}
|
|
103
|
+
position(id) {
|
|
104
|
+
return this.db.prepare("select * from positions where id = ?").get(id);
|
|
105
|
+
}
|
|
106
|
+
positionsByStatus(...statuses) {
|
|
107
|
+
const q = `select * from positions where status in (${statuses.map(() => "?").join(",")}) order by id`;
|
|
108
|
+
return this.db.prepare(q).all(...statuses);
|
|
109
|
+
}
|
|
110
|
+
allPositions() {
|
|
111
|
+
return this.db.prepare("select * from positions order by id").all();
|
|
112
|
+
}
|
|
113
|
+
/** Entries in a coin that may hold or have held tokens: every position except a buy that definitely never landed. */
|
|
114
|
+
entriesForMint(mint, dry) {
|
|
115
|
+
const r = this.db
|
|
116
|
+
.prepare(`select count(*) n from positions p where p.mint = ? and p.dry = ?
|
|
117
|
+
and not (p.status = 'failed' and not exists (select 1 from orders o where o.position_id = p.id and o.side = 'buy'
|
|
118
|
+
and not (o.status = 'reverted' or (o.status = 'rejected' and o.ever_signed = 0))))`)
|
|
119
|
+
.get(mint, dry ? 1 : 0);
|
|
120
|
+
return Number(r.n);
|
|
121
|
+
}
|
|
122
|
+
updatePosition(id, fields) {
|
|
123
|
+
const keys = Object.keys(fields);
|
|
124
|
+
if (!keys.length)
|
|
125
|
+
return;
|
|
126
|
+
this.db.prepare(`update positions set ${keys.map((k) => `${k} = ?`).join(", ")} where id = ?`).run(...keys.map((k) => fields[k]), id);
|
|
127
|
+
}
|
|
128
|
+
// ---------------------------------------------------------------- orders
|
|
129
|
+
createOrder(o) {
|
|
130
|
+
const r = this.db
|
|
131
|
+
.prepare("insert into orders (position_id, side, client_trade_id, amount_raw, slippage_bps, status, max_attempts, next_attempt_at, created_at, updated_at, reason, manual, deadline_at, expected_out_raw) values (?, ?, ?, ?, ?, 'pending', ?, ?, ?, ?, ?, ?, ?, ?)")
|
|
132
|
+
.run(o.positionId, o.side, o.clientTradeId, o.amountRaw.toString(), o.slippageBps, o.maxAttempts, o.now, o.now, o.now, o.reason, o.manual ? 1 : 0, o.deadlineAt ?? null, o.expectedOutRaw == null ? null : o.expectedOutRaw.toString());
|
|
133
|
+
return Number(r.lastInsertRowid);
|
|
134
|
+
}
|
|
135
|
+
order(id) {
|
|
136
|
+
return this.db.prepare("select * from orders where id = ?").get(id);
|
|
137
|
+
}
|
|
138
|
+
ordersFor(positionId) {
|
|
139
|
+
return this.db.prepare("select * from orders where position_id = ? order by id").all(positionId);
|
|
140
|
+
}
|
|
141
|
+
openOrderFor(positionId) {
|
|
142
|
+
return this.db.prepare("select * from orders where position_id = ? and status in ('pending','inflight') order by id limit 1").get(positionId);
|
|
143
|
+
}
|
|
144
|
+
/** Claim due orders in one statement: lease them so no other sweep (or a restart) re-runs them mid-attempt. */
|
|
145
|
+
claimDue(now, leaseMs, limit = 5, opts = {}) {
|
|
146
|
+
const ex = opts.excludeIds?.length ? `and o.id not in (${opts.excludeIds.map((i) => Number(i)).join(",")})` : "";
|
|
147
|
+
const rec = opts.reconcileOnly ? "and (o.signature is not null or o.ever_signed = 1)" : "";
|
|
148
|
+
const ids = opts.onlyIds?.length ? `and o.id in (${opts.onlyIds.map((i) => Number(i)).join(",")})` : "";
|
|
149
|
+
const side = opts.side === "buy" ? "and o.side = 'buy'" : opts.side === "sell" ? "and o.side = 'sell'" : "";
|
|
150
|
+
return this.db
|
|
151
|
+
.prepare(`update orders set status = 'inflight', lease_until = ?, updated_at = ?
|
|
152
|
+
where id in (select o.id from orders o join positions p on p.id = o.position_id
|
|
153
|
+
where ((o.status = 'pending' and o.next_attempt_at <= ?) or (o.status = 'inflight' and o.lease_until <= ?))
|
|
154
|
+
and (? = 0 or p.dry = 1) ${ids} ${ex} ${side} ${rec}
|
|
155
|
+
order by (o.side = 'sell') desc, o.next_attempt_at limit ?)
|
|
156
|
+
returning *`)
|
|
157
|
+
.all(now + leaseMs, now, now, now, opts.dryOnly ? 1 : 0, limit);
|
|
158
|
+
}
|
|
159
|
+
updateOrder(id, fields) {
|
|
160
|
+
const keys = Object.keys(fields);
|
|
161
|
+
if (!keys.length)
|
|
162
|
+
return;
|
|
163
|
+
this.db.prepare(`update orders set ${keys.map((k) => `${k} = ?`).join(", ")} where id = ?`).run(...keys.map((k) => fields[k]), id);
|
|
164
|
+
}
|
|
165
|
+
startAttempt(orderId, n, now) {
|
|
166
|
+
const r = this.db.prepare("insert into attempts (order_id, n, started_at) values (?, ?, ?)").run(orderId, n, now);
|
|
167
|
+
return Number(r.lastInsertRowid);
|
|
168
|
+
}
|
|
169
|
+
endAttempt(id, now, outcome, code, errorJson) {
|
|
170
|
+
this.db.prepare("update attempts set ended_at = ?, outcome = ?, error_code = ?, error_json = ? where id = ?").run(now, outcome, code, errorJson, id);
|
|
171
|
+
}
|
|
172
|
+
attemptsFor(orderId) {
|
|
173
|
+
return this.db.prepare("select n, started_at, ended_at, outcome, error_code, error_json from attempts where order_id = ? order by id").all(orderId);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Lamports committed to buys (tickets; Candle's platform fee comes on top): every buy order except a revert (fees
|
|
177
|
+
* only) and a rejection proven unspent (never signed). A rejection after something was signed still counts.
|
|
178
|
+
*/
|
|
179
|
+
lifetimeBuyLamports(dry) {
|
|
180
|
+
const rows = this.db
|
|
181
|
+
.prepare("select o.amount_raw a, o.extra_signatures x from orders o join positions p on p.id = o.position_id where o.side = 'buy' and o.status != 'reverted' and not (o.status = 'rejected' and o.ever_signed = 0) and p.dry = ?")
|
|
182
|
+
.all(dry ? 1 : 0);
|
|
183
|
+
// A double execution spent one ticket per transaction.
|
|
184
|
+
return rows.reduce((s, r) => s + BigInt(r.a) * BigInt(1 + (r.x ? JSON.parse(r.x).length : 0)), 0n);
|
|
185
|
+
}
|
|
186
|
+
queueHealth(now, dry) {
|
|
187
|
+
const d = dry ? 1 : 0;
|
|
188
|
+
const q = this.db.prepare("select o.status status, count(*) n, min(o.created_at) oldest, max(o.attempts) att from orders o join positions p on p.id = o.position_id where o.status in ('pending','inflight') and p.dry = ? group by o.status").all(d);
|
|
189
|
+
const pending = Number(q.find((r) => r.status === "pending")?.n ?? 0);
|
|
190
|
+
const inflight = Number(q.find((r) => r.status === "inflight")?.n ?? 0);
|
|
191
|
+
const oldest = q.reduce((m, r) => (r.oldest !== null && (m === null || r.oldest < m) ? r.oldest : m), null);
|
|
192
|
+
const att = q.reduce((m, r) => Math.max(m, Number(r.att ?? 0)), 0);
|
|
193
|
+
const failed = Number(this.db.prepare("select count(*) n from orders o join positions p on p.id = o.position_id where o.status = 'failed' and p.dry = ?").get(d).n);
|
|
194
|
+
const stuck = Number(this.db.prepare("select count(*) n from positions where status = 'exit_stuck' and dry = ?").get(d).n);
|
|
195
|
+
return { pending, inflight, oldestAgeMs: oldest === null ? null : now - oldest, maxAttempts: att, terminalFailed: failed, stuckPositions: stuck };
|
|
196
|
+
}
|
|
197
|
+
/** Every signature already booked to an order (so a found transaction is never booked twice). */
|
|
198
|
+
bookedSignatures() {
|
|
199
|
+
const rows = this.db.prepare("select signature s, extra_signatures x from orders where signature is not null and status in ('filled','reverted')").all();
|
|
200
|
+
const out = [];
|
|
201
|
+
for (const r of rows) {
|
|
202
|
+
out.push(r.s);
|
|
203
|
+
if (r.x)
|
|
204
|
+
for (const e of JSON.parse(r.x))
|
|
205
|
+
out.push(e);
|
|
206
|
+
}
|
|
207
|
+
return out;
|
|
208
|
+
}
|
|
209
|
+
// ---------------------------------------------------------------- launches
|
|
210
|
+
recordLaunch(l) {
|
|
211
|
+
this.db
|
|
212
|
+
.prepare(`insert into launches (mint, chain, first_source, first_seen_at, launched_at, api_seen_at, chain_seen_at, api_latency_ms, chain_latency_ms, symbol, name, creator, launch_mode, decision, reason)
|
|
213
|
+
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
214
|
+
on conflict(mint) do update set
|
|
215
|
+
launched_at = coalesce(excluded.launched_at, launches.launched_at),
|
|
216
|
+
api_seen_at = coalesce(launches.api_seen_at, excluded.api_seen_at),
|
|
217
|
+
chain_seen_at = coalesce(launches.chain_seen_at, excluded.chain_seen_at),
|
|
218
|
+
api_latency_ms = coalesce(excluded.api_latency_ms, launches.api_latency_ms),
|
|
219
|
+
chain_latency_ms = coalesce(excluded.chain_latency_ms, launches.chain_latency_ms),
|
|
220
|
+
symbol = coalesce(excluded.symbol, launches.symbol), name = coalesce(excluded.name, launches.name),
|
|
221
|
+
creator = coalesce(excluded.creator, launches.creator), launch_mode = coalesce(excluded.launch_mode, launches.launch_mode),
|
|
222
|
+
decision = coalesce(excluded.decision, launches.decision), reason = coalesce(excluded.reason, launches.reason)`)
|
|
223
|
+
.run(l.mint, l.chain, l.first_source, l.first_seen_at, l.launched_at, l.api_seen_at, l.chain_seen_at, l.api_latency_ms, l.chain_latency_ms, l.symbol, l.name, l.creator, l.launch_mode, l.decision, l.reason);
|
|
224
|
+
}
|
|
225
|
+
launch(mint) {
|
|
226
|
+
return this.db.prepare("select * from launches where mint = ?").get(mint);
|
|
227
|
+
}
|
|
228
|
+
recentLaunches(limit = 20) {
|
|
229
|
+
return this.db.prepare("select * from launches order by first_seen_at desc limit ?").all(limit);
|
|
230
|
+
}
|
|
231
|
+
// ---------------------------------------------------------------- alerts
|
|
232
|
+
/** Count an alert under a key that carries the worsening dimension; returns true when it should be announced. */
|
|
233
|
+
alert(key, message, now, renotifyMs = 86_400_000) {
|
|
234
|
+
const r = this.db.prepare("select * from alerts where key = ?").get(key);
|
|
235
|
+
if (!r) {
|
|
236
|
+
this.db.prepare("insert into alerts (key, first_at, last_at, count, message) values (?, ?, ?, 1, ?)").run(key, now, now, message);
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
const due = now - r.last_at >= renotifyMs;
|
|
240
|
+
this.db.prepare("update alerts set count = count + 1, message = ?, last_at = case when ? then ? else last_at end where key = ?").run(message, due ? 1 : 0, now, key);
|
|
241
|
+
return due;
|
|
242
|
+
}
|
|
243
|
+
}
|
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type Level = "debug" | "info" | "warn" | "error";
|
|
2
|
+
export interface Logger {
|
|
3
|
+
log(level: Level, event: string, fields?: Record<string, unknown>): void;
|
|
4
|
+
info(event: string, fields?: Record<string, unknown>): void;
|
|
5
|
+
warn(event: string, fields?: Record<string, unknown>): void;
|
|
6
|
+
error(event: string, fields?: Record<string, unknown>): void;
|
|
7
|
+
}
|
|
8
|
+
/** JSON lines to stdout and (optionally) a file; every line is redacted before it leaves the process. */
|
|
9
|
+
export declare function makeLogger(opts?: {
|
|
10
|
+
file?: string;
|
|
11
|
+
level?: Level;
|
|
12
|
+
stdout?: boolean;
|
|
13
|
+
now?: () => number;
|
|
14
|
+
}): Logger;
|
|
15
|
+
/** A logger that keeps lines in memory (tests). */
|
|
16
|
+
export declare function memoryLogger(): Logger & {
|
|
17
|
+
lines: Array<{
|
|
18
|
+
level: Level;
|
|
19
|
+
event: string;
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
};
|