repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import { buildPerpsFrontendStatus } from "./frontend.js"; |
| #2 | export const TELEGRAM_PERPS_COMMANDS = [ |
| #3 | { command: "/perps", description: "Show runtime status and safety mode" }, |
| #4 | { command: "/perps_vulcan", description: "Show integrated Vulcan CLI and MCP status" }, |
| #5 | { command: "/perps_markets", description: "List tracked Phoenix perp markets" }, |
| #6 | { command: "/perps_positions", description: "Show current perp positions" }, |
| #7 | { command: "/perps_paper_long", description: "Preview a paper long route" }, |
| #8 | { command: "/perps_paper_short", description: "Preview a paper short route" }, |
| #9 | { command: "/perps_live_long", description: "Preview a blocked/allowed live long route" }, |
| #10 | { command: "/perps_live_short", description: "Preview a blocked/allowed live short route" }, |
| #11 | ]; |
| #12 | function parseArgs(text) { |
| #13 | return text |
| #14 | .trim() |
| #15 | .split(/\s+/) |
| #16 | .filter(Boolean); |
| #17 | } |
| #18 | function readSymbol(args, fallback = "SOL") { |
| #19 | return (args[1] ?? fallback).toUpperCase(); |
| #20 | } |
| #21 | function readNotional(args, fallback = 100) { |
| #22 | const value = Number(args[2] ?? fallback); |
| #23 | return Number.isFinite(value) && value > 0 ? value : fallback; |
| #24 | } |
| #25 | function joinLines(lines) { |
| #26 | return lines.filter(Boolean).join("\n"); |
| #27 | } |
| #28 | function formatBlocking(blocking) { |
| #29 | return blocking.length > 0 ? blocking.join(" | ") : "no blocking conditions"; |
| #30 | } |
| #31 | export async function handleTelegramPerpsCommand(runtime, text) { |
| #32 | const args = parseArgs(text); |
| #33 | const command = args[0] ?? "/perps"; |
| #34 | switch (command) { |
| #35 | case "/perps": { |
| #36 | const [status, frontend] = await Promise.all([ |
| #37 | runtime.getRuntimeHealth(), |
| #38 | buildPerpsFrontendStatus(runtime), |
| #39 | ]); |
| #40 | return { |
| #41 | ok: true, |
| #42 | text: joinLines([ |
| #43 | `${frontend.modeLabel} | ${status.trackedMarkets} markets in view`, |
| #44 | frontend.headline, |
| #45 | frontend.subheadline, |
| #46 | `wallet=${status.walletConfigured ? "wired" : "missing"} | symbols=${status.allowedSymbols.join(", ")}`, |
| #47 | ]), |
| #48 | data: { ...status, frontend }, |
| #49 | }; |
| #50 | } |
| #51 | case "/perps_vulcan": { |
| #52 | const catalog = await runtime.getVulcanCatalogSummary(); |
| #53 | return { |
| #54 | ok: true, |
| #55 | text: joinLines([ |
| #56 | "Vulcan bridge is mounted and readable.", |
| #57 | `cli=${catalog.cliVersion} | groups=${catalog.groupCount} | commands=${catalog.commandCount}`, |
| #58 | `dangerous routes=${catalog.dangerousCommands} | MCP=${catalog.mcpServer ? "present" : "missing"}`, |
| #59 | ]), |
| #60 | data: catalog, |
| #61 | }; |
| #62 | } |
| #63 | case "/perps_markets": { |
| #64 | const markets = await runtime.listMarkets(); |
| #65 | return { |
| #66 | ok: true, |
| #67 | text: joinLines([ |
| #68 | "Market tape is live.", |
| #69 | `${markets.length} tracked symbols: ${markets.map((market) => market.symbol).join(", ")}`, |
| #70 | ]), |
| #71 | data: markets, |
| #72 | }; |
| #73 | } |
| #74 | case "/perps_positions": { |
| #75 | const positions = await runtime.getPositions(); |
| #76 | return { |
| #77 | ok: true, |
| #78 | text: joinLines([ |
| #79 | "Current position snapshot loaded.", |
| #80 | Array.isArray(positions) && positions.length > 0 |
| #81 | ? `${positions.length} position rows returned from the read plane.` |
| #82 | : "No active position rows returned.", |
| #83 | ]), |
| #84 | data: positions, |
| #85 | }; |
| #86 | } |
| #87 | case "/perps_paper_long": { |
| #88 | const preview = runtime.previewPaperTrade(readSymbol(args), "buy", readNotional(args)); |
| #89 | return { |
| #90 | ok: preview.preflight.ok, |
| #91 | text: preview.preflight.ok |
| #92 | ? joinLines([ |
| #93 | `Paper long route staged for ${preview.symbol}.`, |
| #94 | `${preview.notionalUsd} USDC notional | adapter=${preview.route.adapter} | execution=${preview.execution}`, |
| #95 | "This is rehearsal flow only. No real funds should move.", |
| #96 | ]) |
| #97 | : joinLines([ |
| #98 | `Paper long route blocked for ${preview.symbol}.`, |
| #99 | formatBlocking(preview.preflight.blocking), |
| #100 | ]), |
| #101 | data: preview, |
| #102 | }; |
| #103 | } |
| #104 | case "/perps_paper_short": { |
| #105 | const preview = runtime.previewPaperTrade(readSymbol(args), "sell", readNotional(args)); |
| #106 | return { |
| #107 | ok: preview.preflight.ok, |
| #108 | text: preview.preflight.ok |
| #109 | ? joinLines([ |
| #110 | `Paper short route staged for ${preview.symbol}.`, |
| #111 | `${preview.notionalUsd} USDC notional | adapter=${preview.route.adapter} | execution=${preview.execution}`, |
| #112 | "The engine can rehearse the move without opening live exposure.", |
| #113 | ]) |
| #114 | : joinLines([ |
| #115 | `Paper short route blocked for ${preview.symbol}.`, |
| #116 | formatBlocking(preview.preflight.blocking), |
| #117 | ]), |
| #118 | data: preview, |
| #119 | }; |
| #120 | } |
| #121 | case "/perps_live_long": { |
| #122 | const preview = runtime.previewLiveTrade(readSymbol(args), "buy", readNotional(args)); |
| #123 | return { |
| #124 | ok: preview.preflight.ok, |
| #125 | text: preview.preflight.ok |
| #126 | ? joinLines([ |
| #127 | `Live long preview is open for ${preview.symbol}.`, |
| #128 | `${preview.notionalUsd} USDC notional cleared the current gate set.`, |
| #129 | "This is still a preview path until signing and submission are wired.", |
| #130 | ]) |
| #131 | : joinLines([ |
| #132 | `Live long remains blocked for ${preview.symbol}.`, |
| #133 | formatBlocking(preview.preflight.blocking), |
| #134 | ]), |
| #135 | data: preview, |
| #136 | }; |
| #137 | } |
| #138 | case "/perps_live_short": { |
| #139 | const preview = runtime.previewLiveTrade(readSymbol(args), "sell", readNotional(args)); |
| #140 | return { |
| #141 | ok: preview.preflight.ok, |
| #142 | text: preview.preflight.ok |
| #143 | ? joinLines([ |
| #144 | `Live short preview is open for ${preview.symbol}.`, |
| #145 | `${preview.notionalUsd} USDC notional cleared the current gate set.`, |
| #146 | "Execution is described here, not blindly triggered here.", |
| #147 | ]) |
| #148 | : joinLines([ |
| #149 | `Live short remains blocked for ${preview.symbol}.`, |
| #150 | formatBlocking(preview.preflight.blocking), |
| #151 | ]), |
| #152 | data: preview, |
| #153 | }; |
| #154 | } |
| #155 | default: |
| #156 | return { |
| #157 | ok: false, |
| #158 | text: `Unknown command ${command}. Supported: ${TELEGRAM_PERPS_COMMANDS.map((item) => item.command).join(", ")}`, |
| #159 | }; |
| #160 | } |
| #161 | } |
| #162 | //# sourceMappingURL=telegram.js.map |