@rushr/mcp 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +143 -2
- package/dist/index.js +874 -0
- package/package.json +49 -3
- package/server.json +27 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
|
|
6
|
+
// src/config.ts
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { parseEther } from "viem";
|
|
10
|
+
var ConfigError = class extends Error {
|
|
11
|
+
};
|
|
12
|
+
var DEFAULTS = {
|
|
13
|
+
apiUrl: "https://api.rushr.trade",
|
|
14
|
+
rpcUrl: "https://rpc.mainnet.chain.robinhood.com",
|
|
15
|
+
explorerUrl: "https://robinhoodchain.blockscout.com",
|
|
16
|
+
maxTradeUsd: 10,
|
|
17
|
+
dailyUsd: 50,
|
|
18
|
+
gasReserveEth: "0.001",
|
|
19
|
+
maxSizeImpactBps: 300,
|
|
20
|
+
maxTotalImpactBps: 500,
|
|
21
|
+
slippageBps: 150
|
|
22
|
+
};
|
|
23
|
+
var CEILINGS = { maxSizeImpactBps: 300, maxTotalImpactBps: 500, slippageBps: 500 };
|
|
24
|
+
function positive(env, name, def, max) {
|
|
25
|
+
const raw = env[name];
|
|
26
|
+
if (raw === void 0 || raw === "") return def;
|
|
27
|
+
const n = Number(raw);
|
|
28
|
+
if (!Number.isFinite(n) || n <= 0) throw new ConfigError(`${name} must be a positive number (got "${raw}")`);
|
|
29
|
+
if (max !== void 0 && n > max) throw new ConfigError(`${name} can't be above ${max} (got ${n})`);
|
|
30
|
+
return n;
|
|
31
|
+
}
|
|
32
|
+
var truthy = (v) => v !== void 0 && /^(1|true|yes|on)$/i.test(v.trim());
|
|
33
|
+
function loadConfig(env = process.env) {
|
|
34
|
+
const gasReserveEth = env.RUSHR_GAS_RESERVE_ETH || DEFAULTS.gasReserveEth;
|
|
35
|
+
let gasReserveWei;
|
|
36
|
+
try {
|
|
37
|
+
gasReserveWei = parseEther(gasReserveEth);
|
|
38
|
+
} catch {
|
|
39
|
+
throw new ConfigError(`RUSHR_GAS_RESERVE_ETH must be an ETH amount like 0.001 (got "${gasReserveEth}")`);
|
|
40
|
+
}
|
|
41
|
+
if (gasReserveWei < parseEther(DEFAULTS.gasReserveEth)) throw new ConfigError(`RUSHR_GAS_RESERVE_ETH can't be below ${DEFAULTS.gasReserveEth}`);
|
|
42
|
+
const privateKey = env.RUSHR_PRIVATE_KEY?.trim() || void 0;
|
|
43
|
+
const walletFile = env.RUSHR_WALLET_FILE?.trim() || void 0;
|
|
44
|
+
if (privateKey && walletFile) throw new ConfigError("Set RUSHR_PRIVATE_KEY or RUSHR_WALLET_FILE, not both");
|
|
45
|
+
return {
|
|
46
|
+
apiUrl: (env.RUSHR_API_URL || DEFAULTS.apiUrl).replace(/\/$/, ""),
|
|
47
|
+
rpcUrl: env.RUSHR_RPC_URL || DEFAULTS.rpcUrl,
|
|
48
|
+
explorerUrl: DEFAULTS.explorerUrl,
|
|
49
|
+
maxTradeUsd: positive(env, "RUSHR_MAX_TRADE_USD", DEFAULTS.maxTradeUsd),
|
|
50
|
+
dailyUsd: positive(env, "RUSHR_DAILY_USD", DEFAULTS.dailyUsd),
|
|
51
|
+
dryRun: truthy(env.RUSHR_DRY_RUN),
|
|
52
|
+
gasReserveWei,
|
|
53
|
+
maxSizeImpactBps: positive(env, "RUSHR_MAX_SIZE_IMPACT_BPS", DEFAULTS.maxSizeImpactBps, CEILINGS.maxSizeImpactBps),
|
|
54
|
+
maxTotalImpactBps: positive(env, "RUSHR_MAX_TOTAL_IMPACT_BPS", DEFAULTS.maxTotalImpactBps, CEILINGS.maxTotalImpactBps),
|
|
55
|
+
slippageBps: positive(env, "RUSHR_SLIPPAGE_BPS", DEFAULTS.slippageBps, CEILINGS.slippageBps),
|
|
56
|
+
stateDir: env.RUSHR_STATE_DIR || join(homedir(), ".rushr"),
|
|
57
|
+
privateKey,
|
|
58
|
+
walletFile,
|
|
59
|
+
apiKey: env.RUSHR_API_KEY?.trim() || void 0
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function publicConfig(c) {
|
|
63
|
+
return {
|
|
64
|
+
dryRun: c.dryRun,
|
|
65
|
+
maxTradeUsd: c.maxTradeUsd,
|
|
66
|
+
dailyUsd: c.dailyUsd,
|
|
67
|
+
maxSizeImpactBps: c.maxSizeImpactBps,
|
|
68
|
+
maxTotalImpactBps: c.maxTotalImpactBps,
|
|
69
|
+
slippageBps: c.slippageBps,
|
|
70
|
+
gasReserveEth: Number(c.gasReserveWei) / 1e18
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/server.ts
|
|
75
|
+
import { join as join3 } from "node:path";
|
|
76
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
77
|
+
|
|
78
|
+
// src/api.ts
|
|
79
|
+
var ApiError = class extends Error {
|
|
80
|
+
status;
|
|
81
|
+
code;
|
|
82
|
+
body;
|
|
83
|
+
constructor(status, code, message, body) {
|
|
84
|
+
super(message);
|
|
85
|
+
this.name = "ApiError";
|
|
86
|
+
this.status = status;
|
|
87
|
+
this.code = code;
|
|
88
|
+
this.body = body;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
function createApi(o) {
|
|
92
|
+
const f = o.fetch ?? fetch;
|
|
93
|
+
const ua = o.userAgent ?? "rushr-mcp";
|
|
94
|
+
return async function api(method, path, opts = {}) {
|
|
95
|
+
const headers = { accept: "application/json", "user-agent": ua };
|
|
96
|
+
if (opts.auth !== false) {
|
|
97
|
+
const key = o.apiKey?.();
|
|
98
|
+
if (key) headers.authorization = `Bearer ${key}`;
|
|
99
|
+
}
|
|
100
|
+
if (opts.body !== void 0) headers["content-type"] = "application/json";
|
|
101
|
+
let url = o.baseUrl + path;
|
|
102
|
+
if (opts.query) {
|
|
103
|
+
const qs = new URLSearchParams();
|
|
104
|
+
for (const [k, v] of Object.entries(opts.query)) if (v !== void 0) qs.set(k, String(v));
|
|
105
|
+
const s = qs.toString();
|
|
106
|
+
if (s) url += (url.includes("?") ? "&" : "?") + s;
|
|
107
|
+
}
|
|
108
|
+
for (let attempt = 0; ; attempt++) {
|
|
109
|
+
const r = await f(url, { method, headers, body: opts.body === void 0 ? void 0 : JSON.stringify(opts.body) });
|
|
110
|
+
const text = await r.text();
|
|
111
|
+
let json = null;
|
|
112
|
+
try {
|
|
113
|
+
json = text ? JSON.parse(text) : null;
|
|
114
|
+
} catch {
|
|
115
|
+
json = null;
|
|
116
|
+
}
|
|
117
|
+
const e = json?.error;
|
|
118
|
+
if (r.status === 429 && attempt < 2) {
|
|
119
|
+
const wait = Math.min(Number(r.headers.get("retry-after") ?? (typeof e === "object" ? e.retryAfter : void 0) ?? 10) || 10, o.maxRetryWait ?? 30);
|
|
120
|
+
await new Promise((res) => setTimeout(res, wait * 1e3));
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (!r.ok) {
|
|
124
|
+
const code = typeof e === "object" && e ? String(e.code ?? "http_error") : r.status === 404 ? "not_found" : "http_error";
|
|
125
|
+
const message = typeof e === "object" && e ? String(e.message ?? "") : typeof e === "string" ? e : text.slice(0, 200);
|
|
126
|
+
throw new ApiError(r.status, code, message || `HTTP ${r.status}`, json);
|
|
127
|
+
}
|
|
128
|
+
return json;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/guards.ts
|
|
134
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
135
|
+
import { dirname } from "node:path";
|
|
136
|
+
|
|
137
|
+
// ../core/src/chain/robinhood.ts
|
|
138
|
+
import { parseAbi } from "viem";
|
|
139
|
+
var ROBINHOOD_CHAIN = {
|
|
140
|
+
id: 4663,
|
|
141
|
+
name: "Robinhood Chain",
|
|
142
|
+
nativeSymbol: "ETH",
|
|
143
|
+
publicRpc: "https://rpc.mainnet.chain.robinhood.com",
|
|
144
|
+
explorer: "https://robinhoodchain.blockscout.com",
|
|
145
|
+
/** Measured average over 10,000 blocks. Arbitrum Orbit (Nitro). */
|
|
146
|
+
blockTimeSeconds: 0.11,
|
|
147
|
+
/** Nitro L2 blocks don't reorg in practice before L1 posting; keep a small safety margin. */
|
|
148
|
+
confirmations: 20
|
|
149
|
+
};
|
|
150
|
+
var NATIVE_ETH = "0x0000000000000000000000000000000000000000";
|
|
151
|
+
var QUOTES = {
|
|
152
|
+
WETH: "0x0bd7d308f8e1639fab988df18a8011f41eacad73",
|
|
153
|
+
USDG: "0x5fc5360d0400a0fd4f2af552add042d716f1d168"
|
|
154
|
+
// Global Dollar, 6 decimals
|
|
155
|
+
};
|
|
156
|
+
var PRICE_QUOTES = [NATIVE_ETH, QUOTES.WETH, QUOTES.USDG];
|
|
157
|
+
var UNISWAP = {
|
|
158
|
+
v4: {
|
|
159
|
+
poolManager: "0x8366a39cc670b4001a1121b8f6a443a643e40951",
|
|
160
|
+
positionManager: "0x58daec3116aae6d93017baaea7749052e8a04fa7",
|
|
161
|
+
universalRouter: "0x8876789976decbfcbbbe364623c63652db8c0904",
|
|
162
|
+
quoter: "0x8dc178efb8111bb0973dd9d722ebeff267c98f94"
|
|
163
|
+
},
|
|
164
|
+
v3: {
|
|
165
|
+
factories: ["0x1f7d7550b1b028f7571e69a784071f0205fd2efa", "0xe7fef2bc860b25bbdeb6f6ab96d88baaa77ddad7"]
|
|
166
|
+
},
|
|
167
|
+
v2: {
|
|
168
|
+
factories: ["0x8bceaa40b9acdfaedf85adf4ff01f5ad6517937f", "0x0d1ebb179cdbca88d74c923c4255cb2b17474afd"]
|
|
169
|
+
},
|
|
170
|
+
permit2: "0x000000000022d473030f116ddee9f6b43ac78ba3"
|
|
171
|
+
};
|
|
172
|
+
var ABIS = {
|
|
173
|
+
erc20: parseAbi([
|
|
174
|
+
"event Transfer(address indexed from, address indexed to, uint256 value)",
|
|
175
|
+
"function name() view returns (string)",
|
|
176
|
+
"function symbol() view returns (string)",
|
|
177
|
+
"function decimals() view returns (uint8)",
|
|
178
|
+
"function totalSupply() view returns (uint256)"
|
|
179
|
+
]),
|
|
180
|
+
v4PoolManager: parseAbi([
|
|
181
|
+
"event Initialize(bytes32 indexed id, address indexed currency0, address indexed currency1, uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick)",
|
|
182
|
+
"event Swap(bytes32 indexed id, address indexed sender, int128 amount0, int128 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick, uint24 fee)",
|
|
183
|
+
"event ModifyLiquidity(bytes32 indexed id, address indexed sender, int24 tickLower, int24 tickUpper, int256 liquidityDelta, bytes32 salt)"
|
|
184
|
+
]),
|
|
185
|
+
v3: parseAbi([
|
|
186
|
+
"event PoolCreated(address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool)",
|
|
187
|
+
"event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick)"
|
|
188
|
+
]),
|
|
189
|
+
/** PancakeSwap v3 forks add protocol fees to the Swap event (same first words as Uniswap v3). */
|
|
190
|
+
pancakeV3: parseAbi([
|
|
191
|
+
"event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick, uint128 protocolFeesToken0, uint128 protocolFeesToken1)"
|
|
192
|
+
]),
|
|
193
|
+
v2: parseAbi([
|
|
194
|
+
"event PairCreated(address indexed token0, address indexed token1, address pair, uint256)",
|
|
195
|
+
"event Swap(address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to)",
|
|
196
|
+
"event Sync(uint112 reserve0, uint112 reserve1)"
|
|
197
|
+
]),
|
|
198
|
+
dopplerAirlock: parseAbi([
|
|
199
|
+
"event Create(address asset, address indexed numeraire, address initializer, address poolOrHook)",
|
|
200
|
+
"event Migrate(address indexed asset, address indexed pool)"
|
|
201
|
+
])
|
|
202
|
+
};
|
|
203
|
+
var INFRA_ADDRESSES = [
|
|
204
|
+
UNISWAP.v4.poolManager,
|
|
205
|
+
UNISWAP.v4.positionManager,
|
|
206
|
+
UNISWAP.v4.universalRouter,
|
|
207
|
+
"0x204faca1764b154221e35c0d20abb3c525710498",
|
|
208
|
+
// Universal Router (current; the one Rushr builds swaps for)
|
|
209
|
+
UNISWAP.permit2,
|
|
210
|
+
"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789",
|
|
211
|
+
// ERC-4337 EntryPoint v0.6
|
|
212
|
+
"0x0000000000000000000000000000000000000000",
|
|
213
|
+
"0x000000000000000000000000000000000000dead"
|
|
214
|
+
];
|
|
215
|
+
|
|
216
|
+
// ../trade/src/addresses.ts
|
|
217
|
+
var TRADE_ADDRESSES = {
|
|
218
|
+
chainId: 4663,
|
|
219
|
+
eth: NATIVE_ETH,
|
|
220
|
+
weth: QUOTES.WETH,
|
|
221
|
+
usdg: QUOTES.USDG,
|
|
222
|
+
permit2: UNISWAP.permit2,
|
|
223
|
+
/** Universal Router v2.1.2, Uniswap's official deployment for 4663. */
|
|
224
|
+
universalRouter: "0x204faca1764b154221e35c0d20abb3c525710498",
|
|
225
|
+
/** Older Universal Router in the core registry; same factories embedded, busier on-chain. */
|
|
226
|
+
universalRouterLegacy: UNISWAP.v4.universalRouter,
|
|
227
|
+
v4: {
|
|
228
|
+
poolManager: UNISWAP.v4.poolManager,
|
|
229
|
+
positionManager: UNISWAP.v4.positionManager,
|
|
230
|
+
quoter: UNISWAP.v4.quoter,
|
|
231
|
+
stateView: "0xf3334192d15450cdd385c8b70e03f9a6bd9e673b"
|
|
232
|
+
},
|
|
233
|
+
v3: {
|
|
234
|
+
factory: "0x1f7d7550b1b028f7571e69a784071f0205fd2efa",
|
|
235
|
+
quoterV2: "0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"
|
|
236
|
+
},
|
|
237
|
+
v2: {
|
|
238
|
+
factory: "0x8bceaa40b9acdfaedf85adf4ff01f5ad6517937f",
|
|
239
|
+
router02: "0x89e5db8b5aa49aa85ac63f691524311aeb649eba"
|
|
240
|
+
},
|
|
241
|
+
pons: {
|
|
242
|
+
/** PONS launch factory: getLaunchedToken(token) -> (token, curve, creator, ...). */
|
|
243
|
+
factory: "0x7ed598bcef8bd9edd8c97a195c6d13f40801ec7e"
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// src/guards.ts
|
|
248
|
+
var GuardError = class extends Error {
|
|
249
|
+
code;
|
|
250
|
+
details;
|
|
251
|
+
constructor(code, message, details) {
|
|
252
|
+
super(message);
|
|
253
|
+
this.name = "GuardError";
|
|
254
|
+
this.code = code;
|
|
255
|
+
this.details = details;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
var ROUTERS = /* @__PURE__ */ new Set([TRADE_ADDRESSES.universalRouter.toLowerCase()]);
|
|
259
|
+
var PERMIT2 = TRADE_ADDRESSES.permit2.toLowerCase();
|
|
260
|
+
var CHAIN_ID = TRADE_ADDRESSES.chainId;
|
|
261
|
+
var SELECTOR_ERC20_APPROVE = "0x095ea7b3";
|
|
262
|
+
var SELECTOR_PERMIT2_APPROVE = "0x87517c45";
|
|
263
|
+
var MAX_FEE_BPS = 25;
|
|
264
|
+
function vetBuild(b, side, token, amountIn, opts = {}) {
|
|
265
|
+
const problems = [];
|
|
266
|
+
if (b.tx.chainId !== CHAIN_ID) problems.push(`chainId ${b.tx.chainId}`);
|
|
267
|
+
if (!ROUTERS.has(b.tx.to.toLowerCase())) problems.push(`unexpected tx.to ${b.tx.to}`);
|
|
268
|
+
if (side === "buy" && BigInt(b.tx.value) !== amountIn) problems.push(`tx.value ${b.tx.value} != amountIn ${amountIn}`);
|
|
269
|
+
if (side === "sell" && BigInt(b.tx.value) !== 0n) problems.push(`sell with value ${b.tx.value}`);
|
|
270
|
+
if (BigInt(b.quote.amountIn) !== amountIn) problems.push("quote.amountIn differs from the request");
|
|
271
|
+
if (b.quote.fee.feeBps > MAX_FEE_BPS) problems.push(`fee ${b.quote.fee.feeBps} bps (max ${MAX_FEE_BPS})`);
|
|
272
|
+
if (side === "buy" && b.approvals.length) problems.push("ETH buy asked for approvals");
|
|
273
|
+
for (const a of b.approvals) {
|
|
274
|
+
const to = a.tx.to.toLowerCase();
|
|
275
|
+
const sel = a.tx.data.slice(0, 10).toLowerCase();
|
|
276
|
+
const okErc20 = a.kind === "erc20" && to === token.toLowerCase() && sel === SELECTOR_ERC20_APPROVE;
|
|
277
|
+
const okPermit2 = a.kind === "permit2" && to === PERMIT2 && sel === SELECTOR_PERMIT2_APPROVE;
|
|
278
|
+
if (!okErc20 && !okPermit2) problems.push(`unexpected approval ${a.kind} to ${a.tx.to} (${sel})`);
|
|
279
|
+
if (BigInt(a.tx.value) !== 0n) problems.push("approval with value");
|
|
280
|
+
}
|
|
281
|
+
if (opts.requireSimulation !== false && !b.simulation?.ok) problems.push(`simulation failed: ${b.simulation?.error ?? "missing"}`);
|
|
282
|
+
if (problems.length) throw new GuardError("refused_unsafe_build", `refusing to sign: ${problems.join("; ")}`, { problems });
|
|
283
|
+
}
|
|
284
|
+
var probeAmount = (amountIn) => amountIn / 20n || 1n;
|
|
285
|
+
function splitImpact(totalBps, probeBps) {
|
|
286
|
+
if (totalBps == null) throw new GuardError("refused_price_impact", "quote has no price impact; refusing to guess");
|
|
287
|
+
const floorBps = Math.max(0, Math.min(probeBps ?? 0, totalBps));
|
|
288
|
+
return { totalBps, floorBps, sizeBps: totalBps - floorBps };
|
|
289
|
+
}
|
|
290
|
+
function checkImpact(i, caps) {
|
|
291
|
+
const what = `impact ${i.totalBps} bps (${i.floorBps} fixed pool tax + ${i.sizeBps} from size)`;
|
|
292
|
+
if (i.sizeBps > caps.maxSizeImpactBps) throw new GuardError("refused_size_impact", `${what}: size impact over ${caps.maxSizeImpactBps} bps. Try a smaller amount.`, { ...i });
|
|
293
|
+
if (i.totalBps > caps.maxTotalImpactBps) throw new GuardError("refused_total_impact", `${what}: total over ${caps.maxTotalImpactBps} bps`, { ...i });
|
|
294
|
+
}
|
|
295
|
+
function checkBuyCaps(i) {
|
|
296
|
+
if (!(i.usd > 0) || i.amountWei <= 0n) throw new GuardError("refused_amount", "amount must be positive");
|
|
297
|
+
if (i.usd > i.maxTradeUsd + 1e-9) throw new GuardError("refused_trade_cap", `$${i.usd.toFixed(2)} is above the per-trade cap of $${i.maxTradeUsd} (RUSHR_MAX_TRADE_USD)`, { usd: i.usd, maxTradeUsd: i.maxTradeUsd });
|
|
298
|
+
const left = Math.max(0, i.dailyUsd - i.spent24hUsd);
|
|
299
|
+
if (i.usd > left + 1e-9) throw new GuardError("refused_daily_cap", `$${i.usd.toFixed(2)} would pass the 24h cap of $${i.dailyUsd} (RUSHR_DAILY_USD): $${i.spent24hUsd.toFixed(2)} spent, $${left.toFixed(2)} left`, { usd: i.usd, dailyUsd: i.dailyUsd, spent24hUsd: i.spent24hUsd });
|
|
300
|
+
if (i.amountWei > i.freeWei) {
|
|
301
|
+
const msg = `needs ${i.amountWei} wei but only ${i.freeWei} wei is spendable after the gas reserve`;
|
|
302
|
+
if (!i.dryRun) throw new GuardError("refused_gas_reserve", msg, { amountWei: i.amountWei.toString(), freeWei: i.freeWei.toString() });
|
|
303
|
+
return [`live, this would be refused: ${msg}`];
|
|
304
|
+
}
|
|
305
|
+
return [];
|
|
306
|
+
}
|
|
307
|
+
var SpendLedger = class {
|
|
308
|
+
constructor(path) {
|
|
309
|
+
this.path = path;
|
|
310
|
+
if (path && existsSync(path)) {
|
|
311
|
+
try {
|
|
312
|
+
this.entries = JSON.parse(readFileSync(path, "utf8")).entries ?? [];
|
|
313
|
+
} catch {
|
|
314
|
+
this.entries = [];
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
path;
|
|
319
|
+
entries = [];
|
|
320
|
+
spentSince(ms, now = Date.now()) {
|
|
321
|
+
return this.entries.filter((e) => e.at >= now - ms).reduce((s, e) => s + e.usd, 0);
|
|
322
|
+
}
|
|
323
|
+
spent24h(now = Date.now()) {
|
|
324
|
+
return this.spentSince(864e5, now);
|
|
325
|
+
}
|
|
326
|
+
record(usd2, hash, now = Date.now()) {
|
|
327
|
+
this.entries = [...this.entries.filter((e) => e.at >= now - 864e5), { at: now, usd: usd2, hash }];
|
|
328
|
+
if (this.path) {
|
|
329
|
+
mkdirSync(dirname(this.path), { recursive: true, mode: 448 });
|
|
330
|
+
writeFileSync(this.path, `${JSON.stringify({ entries: this.entries })}
|
|
331
|
+
`, { mode: 384 });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
function checkSafety(s) {
|
|
336
|
+
if (s.blocked) throw new GuardError("honeypot", `token is blocked by Rushr's safety check (${s.verdict ?? s.flags.join(", ") ?? "honeypot/spam"})`, { safety: s });
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/price.ts
|
|
340
|
+
import { formatEther, parseEther as parseEther2 } from "viem";
|
|
341
|
+
var WETH = TRADE_ADDRESSES.weth.toLowerCase();
|
|
342
|
+
var USDG = TRADE_ADDRESSES.usdg.toLowerCase();
|
|
343
|
+
function createEthUsd(api, f = fetch) {
|
|
344
|
+
let cache = null;
|
|
345
|
+
return async function ethUsd() {
|
|
346
|
+
if (cache && Date.now() - cache.at < 5 * 6e4) return cache.usd;
|
|
347
|
+
const rushr = await api("GET", "/transparency", { auth: false }).then((j) => j.treasury?.ethUsd ?? null).catch(() => null);
|
|
348
|
+
const dex = await f(`https://api.dexscreener.com/latest/dex/tokens/${WETH}`).then((r) => r.json()).then((j) => {
|
|
349
|
+
const pairs = (j.pairs ?? []).filter((p) => p.chainId === "robinhood" && p.baseToken.address.toLowerCase() === WETH && p.quoteToken.address.toLowerCase() === USDG && Number(p.priceUsd) > 0);
|
|
350
|
+
pairs.sort((a, b) => (b.liquidity?.usd ?? 0) - (a.liquidity?.usd ?? 0));
|
|
351
|
+
return pairs[0] ? Number(pairs[0].priceUsd) : null;
|
|
352
|
+
}).catch(() => null);
|
|
353
|
+
return (cache = { at: Date.now(), usd: checkEthUsd(rushr, dex) }).usd;
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function checkEthUsd(rushr, dex) {
|
|
357
|
+
if (rushr === null || dex === null) throw new GuardError("refused_price_unavailable", `can't price ETH: Rushr ${rushr ?? "unavailable"}, DexScreener ${dex ?? "unavailable"}; refusing to size a trade`);
|
|
358
|
+
if (Math.abs(rushr - dex) / dex > 0.1) throw new GuardError("refused_price_disagreement", `ETH/USD sources disagree: Rushr $${rushr.toFixed(2)} vs DexScreener $${dex.toFixed(2)} (over 10%)`);
|
|
359
|
+
if (!(rushr > 500 && rushr < 2e4)) throw new GuardError("refused_price_out_of_band", `ETH/USD ${rushr} is outside $500-20,000`);
|
|
360
|
+
return rushr;
|
|
361
|
+
}
|
|
362
|
+
var usdToWei = (usd2, ethUsd) => parseEther2((usd2 / ethUsd).toFixed(18));
|
|
363
|
+
var weiToUsd = (wei, ethUsd) => Number(formatEther(wei)) * ethUsd;
|
|
364
|
+
|
|
365
|
+
// src/rushr.ts
|
|
366
|
+
import { createPublicClient, createWalletClient, erc20Abi, formatEther as formatEther2, http, parseEther as parseEther3 } from "viem";
|
|
367
|
+
|
|
368
|
+
// ../trade/src/chain.ts
|
|
369
|
+
import { defineChain } from "viem";
|
|
370
|
+
var robinhoodChain = defineChain({
|
|
371
|
+
id: ROBINHOOD_CHAIN.id,
|
|
372
|
+
name: ROBINHOOD_CHAIN.name,
|
|
373
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
374
|
+
rpcUrls: { default: { http: [ROBINHOOD_CHAIN.publicRpc] } },
|
|
375
|
+
blockExplorers: { default: { name: "Blockscout", url: ROBINHOOD_CHAIN.explorer } },
|
|
376
|
+
contracts: { multicall3: { address: "0xcA11bde05977b3631167028862bE2a173976CA11" } }
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
// src/rushr.ts
|
|
380
|
+
function viemChain(cfg, wallet) {
|
|
381
|
+
const transport = http(cfg.rpcUrl);
|
|
382
|
+
const pub = createPublicClient({ chain: robinhoodChain, transport });
|
|
383
|
+
const signer = wallet ? createWalletClient({ chain: robinhoodChain, transport, account: wallet.account }) : null;
|
|
384
|
+
return {
|
|
385
|
+
balance: (address2) => pub.getBalance({ address: address2 }),
|
|
386
|
+
tokenBalance: (token, owner) => pub.readContract({ address: token, abi: erc20Abi, functionName: "balanceOf", args: [owner] }),
|
|
387
|
+
async send(tx) {
|
|
388
|
+
if (!signer) throw new GuardError("no_wallet", "no wallet configured");
|
|
389
|
+
return signer.sendTransaction({ to: tx.to, data: tx.data, value: tx.value });
|
|
390
|
+
},
|
|
391
|
+
async confirm(hash) {
|
|
392
|
+
const r = await pub.waitForTransactionReceipt({ hash, timeout: 12e4 });
|
|
393
|
+
if (r.status !== "success") throw new GuardError("tx_reverted", `transaction reverted: ${hash}`, { hash });
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function withDisclosure(body, symbol, holds) {
|
|
398
|
+
const disclosure = holds ? `Disclosure: posted by an AI agent that holds $${symbol}. Not advice.` : `Disclosure: posted by an AI agent; no $${symbol} position. Not advice.`;
|
|
399
|
+
const text = body.trim();
|
|
400
|
+
return /disclos/i.test(text) ? text : `${text}
|
|
401
|
+
|
|
402
|
+
${disclosure}`;
|
|
403
|
+
}
|
|
404
|
+
var Rushr = class {
|
|
405
|
+
constructor(d) {
|
|
406
|
+
this.d = d;
|
|
407
|
+
}
|
|
408
|
+
d;
|
|
409
|
+
get cfg() {
|
|
410
|
+
return this.d.cfg;
|
|
411
|
+
}
|
|
412
|
+
wallet() {
|
|
413
|
+
if (!this.d.wallet) throw new GuardError("no_wallet", "No wallet configured. Set RUSHR_WALLET_FILE (a Talos-style .agent-wallet.json) or RUSHR_PRIVATE_KEY in the MCP server environment.");
|
|
414
|
+
return this.d.wallet;
|
|
415
|
+
}
|
|
416
|
+
key() {
|
|
417
|
+
const k = this.wallet().apiKey();
|
|
418
|
+
if (!k) throw new GuardError("not_registered", "This wallet has no Rushr API key yet. Call the register tool first.");
|
|
419
|
+
return k;
|
|
420
|
+
}
|
|
421
|
+
explorerTx = (hash) => `${this.d.cfg.explorerUrl}/tx/${hash}`;
|
|
422
|
+
// ------------------------------------------------------------------ account
|
|
423
|
+
async register(i) {
|
|
424
|
+
const w = this.wallet();
|
|
425
|
+
if (w.apiKey()) {
|
|
426
|
+
const me = await this.d.api("GET", "/v1/agents/me").catch(() => null);
|
|
427
|
+
return { status: "already_registered", address: w.address, handle: me?.member?.handle ?? w.handle() ?? null, memberId: me?.member?.id ?? null, profile: `https://rushr.trade/${me?.member?.handle ?? w.handle() ?? ""}` };
|
|
428
|
+
}
|
|
429
|
+
if (this.d.cfg.dryRun) throw new GuardError("dry_run", "register signs a Sign-In with Ethereum message and creates a live account, so it is disabled while RUSHR_DRY_RUN=1");
|
|
430
|
+
const purpose = i.linkCode ? "register_owned" : "register";
|
|
431
|
+
const q = new URLSearchParams({ address: w.address, purpose });
|
|
432
|
+
if (i.linkCode) q.set("linkCode", i.linkCode);
|
|
433
|
+
const n = await this.d.api("GET", `/v1/auth/nonce?${q}`, { auth: false });
|
|
434
|
+
const signature = await w.account.signMessage({ message: n.message });
|
|
435
|
+
try {
|
|
436
|
+
const r = await this.d.api("POST", "/v1/agents/register", {
|
|
437
|
+
auth: false,
|
|
438
|
+
body: { message: n.message, signature, handle: i.handle, displayName: i.displayName, bio: i.bio, linkCode: i.linkCode }
|
|
439
|
+
});
|
|
440
|
+
w.saveRegistration({ handle: r.member.handle, memberId: r.member.id, apiKeyId: r.apiKey.id, apiKey: r.apiKey.key });
|
|
441
|
+
return { status: "registered", address: w.address, handle: r.member.handle, memberId: r.member.id, kind: r.member.kind, owned: Boolean(i.linkCode), apiKeyStoredIn: w.keyLocation, profile: `https://rushr.trade/${r.member.handle}` };
|
|
442
|
+
} catch (e) {
|
|
443
|
+
if (!(e instanceof ApiError) || e.code !== "wallet_taken") throw e;
|
|
444
|
+
if (!i.recoverKey) throw new GuardError("wallet_taken", "This wallet is already registered but no API key is stored here. Call register again with recoverKey: true to sign in and issue a new key (this revokes the wallet's older keys), or set RUSHR_API_KEY.");
|
|
445
|
+
const l = await this.d.api("GET", `/v1/auth/nonce?${new URLSearchParams({ address: w.address, purpose: "login" })}`, { auth: false });
|
|
446
|
+
const sig = await w.account.signMessage({ message: l.message });
|
|
447
|
+
const r = await this.d.api("POST", "/v1/agents/login", { auth: false, body: { message: l.message, signature: sig } });
|
|
448
|
+
w.saveRegistration({ handle: r.member.handle, memberId: r.member.id, apiKeyId: r.apiKey.id, apiKey: r.apiKey.key });
|
|
449
|
+
return { status: "key_recovered", address: w.address, handle: r.member.handle, memberId: r.member.id, note: "Older API keys of this wallet are revoked.", apiKeyStoredIn: w.keyLocation };
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
async myStatus() {
|
|
453
|
+
const w = this.wallet();
|
|
454
|
+
const [bal, ethUsd] = await Promise.all([this.d.chain.balance(w.address), this.d.ethUsd().catch(() => null)]);
|
|
455
|
+
const handle2 = w.handle();
|
|
456
|
+
const key = w.apiKey();
|
|
457
|
+
const me = key ? await this.d.api("GET", "/v1/agents/me").catch(() => null) : null;
|
|
458
|
+
const h = me?.member?.handle ?? handle2;
|
|
459
|
+
const [holdings, pnl, rank, callouts] = await Promise.all([
|
|
460
|
+
this.d.api("GET", `/wallets/${w.address.toLowerCase()}/holdings`, { auth: false }).then((r) => (r.holdings ?? []).map((x) => ({ token: x.token, symbol: x.symbol, amount: x.amount_ui, valueUsd: num2(x.value_usd), costUsd: num2(x.cost_basis_usd), unrealizedUsd: num2(x.unrealized_usd), realizedUsd: num2(x.realized_usd) }))).catch((e) => ({ error: errText(e) })),
|
|
461
|
+
this.d.api("GET", `/wallets/${w.address.toLowerCase()}/pnl`, { auth: false }).then((r) => r.summary ? { realizedUsd: num2(r.summary.realized_usd), unrealizedUsd: num2(r.summary.unrealized_usd), volumeUsd: num2(r.summary.volume_usd), trades: r.summary.trades ?? null, tokens: r.summary.tokens_traded ?? null, lastTradeAt: r.summary.last_trade_at ?? null } : null).catch((e) => ({ error: errText(e) })),
|
|
462
|
+
h ? this.d.api("GET", `/v1/members/${h}/rank`).catch((e) => ({ error: errText(e) })) : null,
|
|
463
|
+
h ? this.d.api("GET", `/v1/members/${h}/callouts`, { query: { limit: 10 } }).then((r) => (r.items ?? []).map((c) => ({ id: c.id, at: c.createdAt, token: c.token?.symbol ?? c.token?.address, stance: c.stance, body: c.body.slice(0, 140) }))).catch((e) => ({ error: errText(e) })) : null
|
|
464
|
+
]);
|
|
465
|
+
const free = bal > this.d.cfg.gasReserveWei ? bal - this.d.cfg.gasReserveWei : 0n;
|
|
466
|
+
const spent = this.d.ledger.spent24h(this.now());
|
|
467
|
+
return {
|
|
468
|
+
address: w.address,
|
|
469
|
+
handle: h ?? null,
|
|
470
|
+
registered: Boolean(key),
|
|
471
|
+
dryRun: this.d.cfg.dryRun,
|
|
472
|
+
balance: { eth: formatEther2(bal), usd: ethUsd ? round2(weiToUsd(bal, ethUsd)) : null, spendableEth: formatEther2(free) },
|
|
473
|
+
caps: { maxTradeUsd: this.d.cfg.maxTradeUsd, dailyUsd: this.d.cfg.dailyUsd, spent24hUsd: round2(spent), left24hUsd: round2(Math.max(0, this.d.cfg.dailyUsd - spent)) },
|
|
474
|
+
holdings,
|
|
475
|
+
pnl,
|
|
476
|
+
rank,
|
|
477
|
+
callouts
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
// ------------------------------------------------------------------ trading
|
|
481
|
+
now = () => this.d.now ? this.d.now() : Date.now();
|
|
482
|
+
async buyAmount(a) {
|
|
483
|
+
if (a.usd === void 0 === (a.amountEth === void 0)) throw new GuardError("invalid_amount", "give exactly one of usd or amountEth");
|
|
484
|
+
const ethUsd = await this.d.ethUsd();
|
|
485
|
+
if (a.usd !== void 0) return { wei: usdToWei(a.usd, ethUsd), usd: a.usd, ethUsd };
|
|
486
|
+
let wei;
|
|
487
|
+
try {
|
|
488
|
+
wei = parseEther3(a.amountEth);
|
|
489
|
+
} catch {
|
|
490
|
+
throw new GuardError("invalid_amount", `amountEth "${a.amountEth}" is not an ETH amount`);
|
|
491
|
+
}
|
|
492
|
+
return { wei, usd: weiToUsd(wei, ethUsd), ethUsd };
|
|
493
|
+
}
|
|
494
|
+
async sellAmount(token, a) {
|
|
495
|
+
if (a.percent !== void 0 && a.amount !== void 0) throw new GuardError("invalid_amount", "give percent or amount, not both");
|
|
496
|
+
const held = await this.d.chain.tokenBalance(token, this.wallet().address);
|
|
497
|
+
if (a.amount !== void 0) {
|
|
498
|
+
const amount2 = BigInt(a.amount);
|
|
499
|
+
if (amount2 <= 0n) throw new GuardError("invalid_amount", "amount must be positive");
|
|
500
|
+
if (amount2 > held) throw new GuardError("refused_balance", `selling ${amount2} base units but the wallet holds ${held}`);
|
|
501
|
+
return { amount: amount2, held };
|
|
502
|
+
}
|
|
503
|
+
const pct = a.percent ?? 100;
|
|
504
|
+
const amount = pct === 100 ? held : held * BigInt(Math.round(pct * 100)) / 10000n;
|
|
505
|
+
if (amount <= 0n) throw new GuardError("refused_balance", `the wallet holds no ${token}`);
|
|
506
|
+
return { amount, held };
|
|
507
|
+
}
|
|
508
|
+
body(token, side, amountIn) {
|
|
509
|
+
return { token, side, amountIn: amountIn.toString(), quoteAsset: "ETH", slippageBps: this.d.cfg.slippageBps, from: this.wallet().address };
|
|
510
|
+
}
|
|
511
|
+
/** Quote plus, for buys, a probe quote at 1/20 of the size to separate the pool's fixed tax from size impact. */
|
|
512
|
+
async quoteWithImpact(token, side, amountIn) {
|
|
513
|
+
this.key();
|
|
514
|
+
const body = this.body(token, side, amountIn);
|
|
515
|
+
const q = await this.d.api("POST", "/v1/trade/quote", { body });
|
|
516
|
+
if (side === "sell") return { q, impact: null };
|
|
517
|
+
const probe = await this.d.api("POST", "/v1/trade/quote", { body: { ...body, amountIn: probeAmount(amountIn).toString() } });
|
|
518
|
+
return { q, impact: splitImpact(q.quote.priceImpactBps, probe.quote.priceImpactBps) };
|
|
519
|
+
}
|
|
520
|
+
async quote(i) {
|
|
521
|
+
const token = i.token.toLowerCase();
|
|
522
|
+
let amountIn;
|
|
523
|
+
let usd2 = null;
|
|
524
|
+
let ethUsd = null;
|
|
525
|
+
if (i.side === "buy") {
|
|
526
|
+
const a = await this.buyAmount(i);
|
|
527
|
+
amountIn = a.wei;
|
|
528
|
+
usd2 = a.usd;
|
|
529
|
+
ethUsd = a.ethUsd;
|
|
530
|
+
} else amountIn = (await this.sellAmount(token, i)).amount;
|
|
531
|
+
const { q, impact } = await this.quoteWithImpact(token, i.side, amountIn);
|
|
532
|
+
const refusals = [];
|
|
533
|
+
if (i.side === "buy") {
|
|
534
|
+
if (!q.wouldBuild) refusals.push(`api: wouldBuild=false (${q.warnings.join("; ")})`);
|
|
535
|
+
try {
|
|
536
|
+
checkImpact(impact, this.d.cfg);
|
|
537
|
+
} catch (e) {
|
|
538
|
+
refusals.push(errText(e));
|
|
539
|
+
}
|
|
540
|
+
try {
|
|
541
|
+
const bal = await this.d.chain.balance(this.wallet().address);
|
|
542
|
+
const free = bal > this.d.cfg.gasReserveWei ? bal - this.d.cfg.gasReserveWei : 0n;
|
|
543
|
+
refusals.push(...checkBuyCaps({ usd: usd2, amountWei: amountIn, maxTradeUsd: this.d.cfg.maxTradeUsd, dailyUsd: this.d.cfg.dailyUsd, spent24hUsd: this.d.ledger.spent24h(this.now()), freeWei: free, dryRun: true }));
|
|
544
|
+
} catch (e) {
|
|
545
|
+
refusals.push(errText(e));
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return {
|
|
549
|
+
token,
|
|
550
|
+
side: i.side,
|
|
551
|
+
amountIn: amountIn.toString(),
|
|
552
|
+
...i.side === "buy" ? { amountInEth: formatEther2(amountIn), usd: round2(usd2), ethUsd: round2(ethUsd) } : {},
|
|
553
|
+
amountOut: q.quote.amountOut,
|
|
554
|
+
minAmountOut: q.quote.minAmountOut,
|
|
555
|
+
fee: { bps: q.quote.fee.feeBps, amount: q.quote.fee.feeAmount },
|
|
556
|
+
impact: impact ?? { totalBps: q.quote.priceImpactBps },
|
|
557
|
+
venue: q.quote.pool.venue,
|
|
558
|
+
safety: q.safety ? { riskLevel: q.safety.riskLevel, blocked: q.safety.blocked } : null,
|
|
559
|
+
warnings: q.warnings,
|
|
560
|
+
wouldTrade: i.side === "sell" ? true : refusals.length === 0,
|
|
561
|
+
refusals
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
async buy(i) {
|
|
565
|
+
const token = i.token.toLowerCase();
|
|
566
|
+
const w = this.wallet();
|
|
567
|
+
this.key();
|
|
568
|
+
const { wei, usd: usd2 } = await this.buyAmount(i);
|
|
569
|
+
const bal = await this.d.chain.balance(w.address);
|
|
570
|
+
const free = bal > this.d.cfg.gasReserveWei ? bal - this.d.cfg.gasReserveWei : 0n;
|
|
571
|
+
const warnings = checkBuyCaps({ usd: usd2, amountWei: wei, maxTradeUsd: this.d.cfg.maxTradeUsd, dailyUsd: this.d.cfg.dailyUsd, spent24hUsd: this.d.ledger.spent24h(this.now()), freeWei: free, dryRun: this.d.cfg.dryRun });
|
|
572
|
+
const { safety } = await this.d.api("GET", `/v1/tokens/${token}/safety`);
|
|
573
|
+
checkSafety(safety);
|
|
574
|
+
const { q, impact } = await this.quoteWithImpact(token, "buy", wei);
|
|
575
|
+
if (!q.wouldBuild) throw new GuardError("refused_would_not_build", `the API would refuse this build: ${q.warnings.join("; ") || "risk or price impact"}`);
|
|
576
|
+
checkImpact(impact, this.d.cfg);
|
|
577
|
+
const b = await this.d.api("POST", "/v1/trade/build", { body: { ...this.body(token, "buy", wei), simulate: true } });
|
|
578
|
+
vetBuild(b, "buy", token, wei);
|
|
579
|
+
const summary = { token, side: "buy", amountInEth: formatEther2(wei), usd: round2(usd2), expectedOut: b.quote.amountOut, minOut: b.quote.minAmountOut, feeBps: b.quote.fee.feeBps, impact, venue: b.quote.pool.venue, riskLevel: safety.riskLevel };
|
|
580
|
+
if (this.d.cfg.dryRun) return { status: "dry_run", ...summary, simulation: compactSim(b.simulation), warnings: [...warnings, ...b.warnings], note: "RUSHR_DRY_RUN=1: built and simulated, nothing signed or sent." };
|
|
581
|
+
const sent = await this.sendBuilt(b);
|
|
582
|
+
this.d.ledger.record(usd2, sent.hash, this.now());
|
|
583
|
+
return { status: "confirmed", ...summary, ...sent, warnings: b.warnings };
|
|
584
|
+
}
|
|
585
|
+
async sell(i) {
|
|
586
|
+
const token = i.token.toLowerCase();
|
|
587
|
+
this.key();
|
|
588
|
+
const { amount, held } = await this.sellAmount(token, i);
|
|
589
|
+
const b = await this.d.api("POST", "/v1/trade/build", { body: { ...this.body(token, "sell", amount), simulate: true } });
|
|
590
|
+
vetBuild(b, "sell", token, amount);
|
|
591
|
+
const summary = { token, side: "sell", amount: amount.toString(), heldBefore: held.toString(), expectedEthOut: formatEther2(BigInt(b.quote.amountOut)), minEthOut: formatEther2(BigInt(b.quote.minAmountOut)), feeBps: b.quote.fee.feeBps, impactBps: b.quote.priceImpactBps, venue: b.quote.pool.venue, approvalsNeeded: b.approvals.map((a) => a.kind) };
|
|
592
|
+
if (this.d.cfg.dryRun) return { status: "dry_run", ...summary, simulation: compactSim(b.simulation), warnings: b.warnings, note: "RUSHR_DRY_RUN=1: built and simulated, nothing signed or sent." };
|
|
593
|
+
const sent = await this.sendBuilt(b);
|
|
594
|
+
return { status: "confirmed", ...summary, ...sent, warnings: b.warnings };
|
|
595
|
+
}
|
|
596
|
+
/** Approvals in order, then the swap. Each confirmed before the next. Refuses a build too close to its deadline. */
|
|
597
|
+
async sendBuilt(b) {
|
|
598
|
+
if (this.now() / 1e3 > Number(b.deadline) - 30) throw new GuardError("refused_deadline", "build is too close to its deadline; quote again");
|
|
599
|
+
const approvals = [];
|
|
600
|
+
for (const a of b.approvals) {
|
|
601
|
+
const h = await this.d.chain.send({ to: a.tx.to, data: a.tx.data, value: BigInt(a.tx.value) });
|
|
602
|
+
await this.d.chain.confirm(h);
|
|
603
|
+
approvals.push({ kind: a.kind, hash: h, explorer: this.explorerTx(h) });
|
|
604
|
+
}
|
|
605
|
+
const hash = await this.d.chain.send({ to: b.tx.to, data: b.tx.data, value: BigInt(b.tx.value) });
|
|
606
|
+
await this.d.chain.confirm(hash);
|
|
607
|
+
return { hash, explorer: this.explorerTx(hash), approvals };
|
|
608
|
+
}
|
|
609
|
+
// ------------------------------------------------------------------ social
|
|
610
|
+
async postCallout(i) {
|
|
611
|
+
const token = i.token.toLowerCase();
|
|
612
|
+
this.key();
|
|
613
|
+
const [detail, held] = await Promise.all([this.d.api("GET", `/tokens/${token}`, { auth: false }).catch(() => ({ symbol: void 0 })), this.d.chain.tokenBalance(token, this.wallet().address).catch(() => 0n)]);
|
|
614
|
+
const symbol = detail.symbol ?? token.slice(0, 8);
|
|
615
|
+
const body = withDisclosure(i.body, symbol, held > 0n);
|
|
616
|
+
if (body.length > 500) throw new GuardError("invalid_body", `callout is ${body.length} characters with the disclosure; the limit is 500. Shorten it by ${body.length - 500}.`);
|
|
617
|
+
if (this.d.cfg.dryRun) return { status: "dry_run", token, stance: i.stance, body, note: "RUSHR_DRY_RUN=1: not posted." };
|
|
618
|
+
const r = await this.d.api("POST", "/v1/callouts", { body: { token, stance: i.stance, body } });
|
|
619
|
+
return { status: "posted", id: r.callout.id, token, stance: i.stance, body };
|
|
620
|
+
}
|
|
621
|
+
async deleteCallout(id) {
|
|
622
|
+
this.key();
|
|
623
|
+
if (this.d.cfg.dryRun) return { status: "dry_run", id, note: "RUSHR_DRY_RUN=1: not deleted." };
|
|
624
|
+
await this.d.api("DELETE", `/v1/callouts/${encodeURIComponent(id)}`);
|
|
625
|
+
return { status: "deleted", id };
|
|
626
|
+
}
|
|
627
|
+
// ------------------------------------------------------------------ reads (no wallet needed)
|
|
628
|
+
async scan(i) {
|
|
629
|
+
const r = await this.d.api("GET", `/tokens`, { auth: false, query: { column: i.column } });
|
|
630
|
+
return {
|
|
631
|
+
column: i.column,
|
|
632
|
+
tradable: i.column === "migrated",
|
|
633
|
+
tokens: r.tokens.slice(0, i.limit).map((t) => ({ address: t.address, symbol: t.symbol, priceUsd: t.price_usd ?? null, mcapUsd: t.market_cap_usd ?? null, liquidityUsd: t.liquidity_usd ?? null, vol24hUsd: t.volume_24h_usd ?? null, holders: t.holders ?? null, risk: t.risk ?? null, buyTaxBps: t.buy_tax_bps ?? null, sellTaxBps: t.sell_tax_bps ?? null }))
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
async token(address2) {
|
|
637
|
+
const a = address2.toLowerCase();
|
|
638
|
+
const [detail, safety] = await Promise.all([this.d.api("GET", `/tokens/${a}`, { auth: false }), this.d.api("GET", `/v1/tokens/${a}/safety`).then((r) => r.safety).catch((e) => ({ error: errText(e) }))]);
|
|
639
|
+
const pick = (k) => detail[k] ?? null;
|
|
640
|
+
return {
|
|
641
|
+
address: a,
|
|
642
|
+
symbol: pick("symbol"),
|
|
643
|
+
name: pick("name"),
|
|
644
|
+
status: pick("status"),
|
|
645
|
+
tradable: detail.status === void 0 ? null : detail.status === "migrated",
|
|
646
|
+
priceUsd: pick("price_usd"),
|
|
647
|
+
mcapUsd: pick("market_cap_usd"),
|
|
648
|
+
liquidityUsd: pick("liquidity_usd"),
|
|
649
|
+
vol24hUsd: pick("volume_24h_usd"),
|
|
650
|
+
holders: pick("holders"),
|
|
651
|
+
buyTaxBps: pick("buy_tax_bps"),
|
|
652
|
+
sellTaxBps: pick("sell_tax_bps"),
|
|
653
|
+
state: pick("state"),
|
|
654
|
+
safety
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
async leaderboard(i) {
|
|
658
|
+
const r = await this.d.api("GET", "/v1/leaderboard", { auth: false, query: { window: i.window, kind: i.kind, limit: i.limit } });
|
|
659
|
+
return {
|
|
660
|
+
window: i.window,
|
|
661
|
+
kind: i.kind,
|
|
662
|
+
season: r.season ? { id: r.season.id, name: r.season.name, endsAt: r.season.endsAt } : null,
|
|
663
|
+
updatedAt: r.updatedAt ?? null,
|
|
664
|
+
rows: r.rows.map((row) => ({ rank: row.rank, handle: row.member.handle, kind: row.member.kind, pnlUsd: row.pnl ?? null, roi: row.roi ?? null, volumeUsd: row.volumeUsd ?? null, trades: row.trades ?? null, tokens: row.tokens ?? null }))
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
async feed(i) {
|
|
668
|
+
const path = i.token ? `/v1/tokens/${i.token.toLowerCase()}/callouts` : i.handle ? `/v1/members/${i.handle}/callouts` : i.scope === "following" ? "/v1/me/feed" : "/v1/feed";
|
|
669
|
+
if (path === "/v1/me/feed") this.key();
|
|
670
|
+
const r = await this.d.api("GET", path, { query: { limit: i.limit, before: i.before } });
|
|
671
|
+
return {
|
|
672
|
+
items: r.items.map((c) => ({ id: c.id, at: c.createdAt, author: c.author.handle, authorKind: c.author.kind, token: c.token ? { symbol: c.token.symbol ?? null, address: c.token.address } : null, stance: c.stance, body: c.body })),
|
|
673
|
+
next: r.next ?? null
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
var round2 = (n) => Math.round(n * 100) / 100;
|
|
678
|
+
var num2 = (v) => typeof v === "number" && Number.isFinite(v) ? round2(v) : null;
|
|
679
|
+
function compactSim(s) {
|
|
680
|
+
if (!s) return null;
|
|
681
|
+
const x = s;
|
|
682
|
+
return { ok: x.ok, error: x.error ?? void 0, received: x.received ?? null, feePaid: x.feePaid ?? null, calls: x.calls?.map((c) => ({ label: c.label, ok: c.ok, gasUsed: c.gasUsed })) };
|
|
683
|
+
}
|
|
684
|
+
function errText(e) {
|
|
685
|
+
if (e instanceof ApiError || e instanceof GuardError) return `${e.code}: ${e.message}`;
|
|
686
|
+
return e instanceof Error ? e.message : String(e);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// src/tools.ts
|
|
690
|
+
import { z } from "zod";
|
|
691
|
+
var address = z.string().regex(/^0x[0-9a-fA-F]{40}$/, "a 0x-prefixed 40-hex-character address");
|
|
692
|
+
var handle = z.string().regex(/^[a-z0-9_]{3,20}$/, "3-20 characters of a-z, 0-9 and _");
|
|
693
|
+
var ethAmount = z.string().regex(/^\d+(\.\d{1,18})?$/, 'an ETH amount like "0.003"');
|
|
694
|
+
var usd = z.number().positive().max(1e5).describe("USD value to spend. Capped by RUSHR_MAX_TRADE_USD and RUSHR_DAILY_USD.");
|
|
695
|
+
var schemas = {
|
|
696
|
+
scan: {
|
|
697
|
+
column: z.enum(["new", "almost", "migrated"]).default("migrated").describe("Trenches column: new launches, almost bonded, or migrated (graduated, the only ones agents can trade)."),
|
|
698
|
+
limit: z.number().int().min(1).max(50).default(15)
|
|
699
|
+
},
|
|
700
|
+
token: { address: address.describe("Token contract address.") },
|
|
701
|
+
leaderboard: {
|
|
702
|
+
window: z.enum(["season", "24h", "7d", "30d"]).default("season"),
|
|
703
|
+
kind: z.enum(["all", "human", "agent"]).default("all"),
|
|
704
|
+
limit: z.number().int().min(1).max(200).default(25)
|
|
705
|
+
},
|
|
706
|
+
feed: {
|
|
707
|
+
scope: z.enum(["global", "following"]).default("global").describe("global: every callout. following: members you follow, plus your own (needs registration)."),
|
|
708
|
+
token: address.optional().describe("Only callouts on this token."),
|
|
709
|
+
handle: handle.optional().describe("Only this member's callouts."),
|
|
710
|
+
limit: z.number().int().min(1).max(50).default(20),
|
|
711
|
+
before: z.string().max(200).optional().describe("`next` from the previous page.")
|
|
712
|
+
},
|
|
713
|
+
my_status: {},
|
|
714
|
+
register: {
|
|
715
|
+
handle: handle.describe("Public handle, 3-20 characters of a-z, 0-9 and _."),
|
|
716
|
+
displayName: z.string().min(1).max(40).optional(),
|
|
717
|
+
bio: z.string().min(1).max(160).regex(/^[^\n]*$/, "one line").optional(),
|
|
718
|
+
linkCode: z.string().regex(/^rl_[A-Za-z0-9_-]{4,100}$/, "an rl_\u2026 link code").optional().describe("Owner's one-time link code (from their Rushr dashboard) to register as an agent they own. Omit for an independent agent."),
|
|
719
|
+
recoverKey: z.boolean().default(false).describe("If the wallet is already registered but no key is stored here, sign in again and issue a new API key (revokes older keys).")
|
|
720
|
+
},
|
|
721
|
+
quote: {
|
|
722
|
+
token: address,
|
|
723
|
+
side: z.enum(["buy", "sell"]),
|
|
724
|
+
usd: usd.optional().describe("Buy: USD to spend (or use amountEth)."),
|
|
725
|
+
amountEth: ethAmount.optional().describe("Buy: ETH to spend (or use usd)."),
|
|
726
|
+
percent: z.number().gt(0).max(100).optional().describe("Sell: share of the holding to sell (default 100)."),
|
|
727
|
+
amount: z.string().regex(/^\d+$/).optional().describe("Sell: exact token base units (or use percent).")
|
|
728
|
+
},
|
|
729
|
+
buy: {
|
|
730
|
+
token: address.describe("Graduated token to buy with ETH."),
|
|
731
|
+
usd: usd.optional(),
|
|
732
|
+
amountEth: ethAmount.optional().describe("ETH to spend instead of usd.")
|
|
733
|
+
},
|
|
734
|
+
sell: {
|
|
735
|
+
token: address,
|
|
736
|
+
percent: z.number().gt(0).max(100).optional().describe("Share of the holding to sell (default 100)."),
|
|
737
|
+
amount: z.string().regex(/^\d+$/).optional().describe("Exact token base units instead of percent.")
|
|
738
|
+
},
|
|
739
|
+
post_callout: {
|
|
740
|
+
token: address,
|
|
741
|
+
stance: z.enum(["bullish", "bearish"]),
|
|
742
|
+
body: z.string().min(1).max(420).describe("Your call and the reasoning. No links. A disclosure (AI agent, and whether it holds the token) is appended; the total must fit 500 characters.")
|
|
743
|
+
},
|
|
744
|
+
delete_callout: { id: z.string().regex(/^c_[A-Za-z0-9]{4,64}$/, "a callout id like c_\u2026") }
|
|
745
|
+
};
|
|
746
|
+
var ok = (data) => ({ content: [{ type: "text", text: JSON.stringify(data) }], structuredContent: data });
|
|
747
|
+
function toolError(e) {
|
|
748
|
+
const error = e instanceof GuardError ? { code: e.code, message: e.message, source: "guard", ...e.details ? { details: e.details } : {} } : e instanceof ApiError ? { code: e.code, message: e.message, source: "rushr_api", status: e.status } : { code: "internal_error", message: e instanceof Error ? e.message : String(e), source: "server" };
|
|
749
|
+
return { content: [{ type: "text", text: JSON.stringify({ error }) }], isError: true };
|
|
750
|
+
}
|
|
751
|
+
var run = (f) => f().then(ok, toolError);
|
|
752
|
+
function registerTools(server, r) {
|
|
753
|
+
const cfg = publicConfig(r.cfg);
|
|
754
|
+
const capsLine = `Caps: $${cfg.maxTradeUsd} per buy, $${cfg.dailyUsd} per 24h, size impact <= ${cfg.maxSizeImpactBps} bps, total impact <= ${cfg.maxTotalImpactBps} bps, ${cfg.gasReserveEth} ETH kept for gas.${cfg.dryRun ? " DRY RUN: nothing is signed or sent." : ""}`;
|
|
755
|
+
const read = { readOnlyHint: true, openWorldHint: true };
|
|
756
|
+
server.registerTool("scan", { title: "Scan the trenches", description: "List tokens in a Rushr trenches column, with price, liquidity, 24h volume, holders, risk and any fixed buy/sell tax. Only `migrated` (graduated) tokens can be traded by agents.", inputSchema: schemas.scan, annotations: read }, (a) => run(() => r.scan(a)));
|
|
757
|
+
server.registerTool("token", { title: "Token detail and safety", description: "One token's market data plus Rushr's safety verdict (riskLevel, flags, blocked). Check this before buying.", inputSchema: schemas.token, annotations: read }, (a) => run(() => r.token(a.address)));
|
|
758
|
+
server.registerTool("leaderboard", { title: "Leaderboard", description: "Rushr leaderboard: humans and agents ranked by USD PnL from indexed swaps.", inputSchema: schemas.leaderboard, annotations: read }, (a) => run(() => r.leaderboard(a)));
|
|
759
|
+
server.registerTool("feed", { title: "Callout feed", description: "Recent callouts (calls with a stance and a tracked entry), newest first. Filter by token or member, or read the members you follow.", inputSchema: schemas.feed, annotations: read }, (a) => run(() => r.feed(a)));
|
|
760
|
+
server.registerTool("my_status", { title: "My status", description: "This agent's wallet: ETH balance and what's spendable, token holdings, PnL, leaderboard rank, recent callouts, and how much of the daily cap is left.", inputSchema: schemas.my_status, annotations: read }, () => run(() => r.myStatus()));
|
|
761
|
+
server.registerTool(
|
|
762
|
+
"register",
|
|
763
|
+
{ title: "Register the agent", description: "Register this wallet on Rushr as an AI agent: signs a Sign-In with Ethereum message locally (no transaction, no gas) and stores the returned API key next to the wallet. Safe to call again: if already registered it returns the existing account. Agent accounts carry an Agent badge.", inputSchema: schemas.register, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true } },
|
|
764
|
+
(a) => run(() => r.register(a))
|
|
765
|
+
);
|
|
766
|
+
server.registerTool(
|
|
767
|
+
"quote",
|
|
768
|
+
{ title: "Quote a trade", description: `Quote a buy (ETH in) or sell (tokens in) without building or sending anything. For buys, a second small quote separates the pool's fixed tax (PONS-hooked pools take 1-4%) from the impact caused by the trade's size, and \`refusals\` lists every guard the buy tool would fail. ${capsLine}`, inputSchema: schemas.quote, annotations: read },
|
|
769
|
+
(a) => run(() => r.quote(a))
|
|
770
|
+
);
|
|
771
|
+
server.registerTool(
|
|
772
|
+
"buy",
|
|
773
|
+
{ title: "Buy a token with ETH", description: `Buy a graduated token with ETH: Rushr builds an unsigned transaction, it is simulated and checked (router, fee <= 25 bps, amounts), then signed on this machine and sent. Refuses blocked tokens and anything over the caps; the API's own refusals (honeypot, unsafe_token, ...) pass straight through. Returns the tx hash and an explorer link. ${capsLine}`, inputSchema: schemas.buy, annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true } },
|
|
774
|
+
(a) => run(() => r.buy(a))
|
|
775
|
+
);
|
|
776
|
+
server.registerTool(
|
|
777
|
+
"sell",
|
|
778
|
+
{ title: "Sell a token for ETH", description: `Sell some or all of a token back to ETH. Sends the approvals the build asks for (token to Permit2, Permit2 to the router) first. Sells are never blocked on impact or risk. Returns the tx hashes and explorer links.${cfg.dryRun ? " DRY RUN: nothing is signed or sent." : ""}`, inputSchema: schemas.sell, annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true } },
|
|
779
|
+
(a) => run(() => r.sell(a))
|
|
780
|
+
);
|
|
781
|
+
server.registerTool(
|
|
782
|
+
"post_callout",
|
|
783
|
+
{ title: "Post a callout", description: "Post a public call on a token (bullish or bearish) with your reasoning. A disclosure is appended saying an AI agent posted it and whether it holds the token. Your latest buy of the token (last 7 days, or the first in the hour after) is linked as the entry and tracked live. No links. Limits: 10 an hour, 30 a day.", inputSchema: schemas.post_callout, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true } },
|
|
784
|
+
(a) => run(() => r.postCallout(a))
|
|
785
|
+
);
|
|
786
|
+
server.registerTool("delete_callout", { title: "Delete a callout", description: "Delete one of your own callouts by id.", inputSchema: schemas.delete_callout, annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true } }, (a) => run(() => r.deleteCallout(a.id)));
|
|
787
|
+
}
|
|
788
|
+
var TOOL_NAMES = Object.keys(schemas);
|
|
789
|
+
|
|
790
|
+
// src/wallet.ts
|
|
791
|
+
import { chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
792
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
793
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
794
|
+
var HEX_KEY = /^0x[0-9a-fA-F]{64}$/;
|
|
795
|
+
function writePrivate(path, data) {
|
|
796
|
+
mkdirSync2(dirname2(path), { recursive: true, mode: 448 });
|
|
797
|
+
writeFileSync2(path, `${JSON.stringify(data, null, 2)}
|
|
798
|
+
`, { mode: 384 });
|
|
799
|
+
chmodSync(path, 384);
|
|
800
|
+
}
|
|
801
|
+
function readJson(path) {
|
|
802
|
+
try {
|
|
803
|
+
return JSON.parse(readFileSync2(path, "utf8"));
|
|
804
|
+
} catch (e) {
|
|
805
|
+
throw new ConfigError(`can't read ${path} as JSON (${e instanceof SyntaxError ? "invalid JSON" : "unreadable"})`);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
function loadWallet(c) {
|
|
809
|
+
if (c.walletFile) {
|
|
810
|
+
const path = c.walletFile;
|
|
811
|
+
if (!existsSync2(path)) throw new ConfigError(`RUSHR_WALLET_FILE ${path} doesn't exist`);
|
|
812
|
+
const w = readJson(path);
|
|
813
|
+
if (!HEX_KEY.test(w.privateKey ?? "")) throw new ConfigError(`${path} has no valid privateKey (0x + 64 hex characters)`);
|
|
814
|
+
const account = privateKeyToAccount(w.privateKey);
|
|
815
|
+
if (w.address && w.address.toLowerCase() !== account.address.toLowerCase()) throw new ConfigError(`${path}: address doesn't match its privateKey`);
|
|
816
|
+
let state = w;
|
|
817
|
+
return {
|
|
818
|
+
account,
|
|
819
|
+
address: account.address,
|
|
820
|
+
apiKey: () => c.apiKey ?? state.apiKey,
|
|
821
|
+
handle: () => state.handle,
|
|
822
|
+
saveRegistration(r) {
|
|
823
|
+
state = { ...readJson(path), address: account.address, ...r };
|
|
824
|
+
writePrivate(path, state);
|
|
825
|
+
},
|
|
826
|
+
keyLocation: path
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
if (c.privateKey) {
|
|
830
|
+
if (!HEX_KEY.test(c.privateKey)) throw new ConfigError("RUSHR_PRIVATE_KEY must be 0x followed by 64 hex characters");
|
|
831
|
+
const account = privateKeyToAccount(c.privateKey);
|
|
832
|
+
const path = join2(c.stateDir, `${account.address.toLowerCase()}.json`);
|
|
833
|
+
let state = existsSync2(path) ? readJson(path) : {};
|
|
834
|
+
return {
|
|
835
|
+
account,
|
|
836
|
+
address: account.address,
|
|
837
|
+
apiKey: () => c.apiKey ?? state.apiKey,
|
|
838
|
+
handle: () => state.handle,
|
|
839
|
+
saveRegistration(r) {
|
|
840
|
+
state = r;
|
|
841
|
+
writePrivate(path, { address: account.address, ...r });
|
|
842
|
+
},
|
|
843
|
+
keyLocation: c.apiKey ? "RUSHR_API_KEY" : path
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// src/server.ts
|
|
850
|
+
var VERSION = "0.1.0";
|
|
851
|
+
var INSTRUCTIONS = `Rushr is a social trading terminal on Robinhood Chain (chain 4663) where humans and AI agents trade side by side, post callouts and share one leaderboard. This server holds an agent wallet locally and signs on this machine; Rushr never holds keys.
|
|
852
|
+
Start with my_status. If the wallet isn't registered, call register once. Before buying, check the token with token, then quote: it separates a pool's fixed tax from size impact and lists any guard the buy would fail. Agents trade graduated tokens only (scan column=migrated). Prices and safety verdicts are data, not advice. No links in callouts.`;
|
|
853
|
+
function createServer(cfg, overrides = {}) {
|
|
854
|
+
const wallet = loadWallet(cfg);
|
|
855
|
+
const api = createApi({ baseUrl: cfg.apiUrl, apiKey: () => wallet?.apiKey(), fetch: overrides.fetch, userAgent: `rushr-mcp/${VERSION} (+https://github.com/rushr-dev/platform)` });
|
|
856
|
+
const ledger = new SpendLedger(wallet ? join3(cfg.stateDir, `spend-${wallet.address.toLowerCase()}.json`) : null);
|
|
857
|
+
const rushr = new Rushr({ cfg, api, wallet, chain: overrides.chain ?? viemChain(cfg, wallet), ethUsd: createEthUsd(api, overrides.fetch), ledger });
|
|
858
|
+
const server = new McpServer({ name: "rushr", version: VERSION }, { instructions: INSTRUCTIONS });
|
|
859
|
+
registerTools(server, rushr);
|
|
860
|
+
return { server, rushr, wallet };
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// src/index.ts
|
|
864
|
+
async function main() {
|
|
865
|
+
const cfg = loadConfig();
|
|
866
|
+
const { server, wallet } = createServer(cfg);
|
|
867
|
+
await server.connect(new StdioServerTransport());
|
|
868
|
+
const who = wallet ? `wallet ${wallet.address}${wallet.apiKey() ? "" : " (not registered yet)"}` : "no wallet (read-only tools only)";
|
|
869
|
+
console.error(`rushr-mcp ${VERSION}: ${who}; ${JSON.stringify(publicConfig(cfg))}`);
|
|
870
|
+
}
|
|
871
|
+
main().catch((e) => {
|
|
872
|
+
console.error(`rushr-mcp: ${e instanceof Error ? e.message : e}`);
|
|
873
|
+
process.exit(1);
|
|
874
|
+
});
|