Adds a local web console for running and managing the market maker, with built-in bridging. **Console** (`npm run ui`, http://127.0.0.1:5191) - Fleet overview with total value, PnL vs HODL, and a Pause all button - Per-bot pages: decisions, settings with validation, manual swap/add/withdraw, cash out to a saved payout address, dry-run to live checklist - New-bot flow: create or import a wallet (key or recovery phrase), back up the key, fund it, pick a pool - Bots are spawned as child processes with argv (no shell); key and phrase stay in the 0600 env file **Bridging** - BTC ↔ sBTC: deposit address per bot (sbtc library defaults), withdrawals via `initiate-withdrawal-request`, status from Emily - USDC ↔ USDCx: deposits from an Ethereum wallet (EIP-6963) through Circle xReserve, withdrawals via `usdcx-v1.burn`; payouts are followed on Ethereum window by window - Activity list with status and per-chain transaction links **Security** - Binds to 127.0.0.1 only; checks Host, Origin and Sec-Fetch-Site; JSON-only writes - Routes that reveal a key or send funds to a typed address answer only the page - Settings writes are allowlisted and validated; secrets are never returned Tested end to end on mainnet in every bridge direction. `npm run build`, `npm test` (215 passing) and the UI build all pass. Docs: README, AGENTS.md, docs/RECOVERY.md, ROADMAP.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from 'fs';
|
|
import { tmpdir } from 'os';
|
|
import { join } from 'path';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { clearPidFile, writePidFile } from '../src/pid';
|
|
|
|
describe('pid file', () => {
|
|
it('writes the process id and removes it only when it still matches', () => {
|
|
const file = join(mkdtempSync(join(tmpdir(), 'mm-pid-')), 'bot.pid');
|
|
writePidFile(file, 4242);
|
|
expect(readFileSync(file, 'utf8').trim()).toBe('4242');
|
|
|
|
clearPidFile(file, 1);
|
|
expect(existsSync(file)).toBe(true);
|
|
|
|
clearPidFile(file, 4242);
|
|
expect(existsSync(file)).toBe(false);
|
|
});
|
|
|
|
it('creates the parent directory', () => {
|
|
const file = join(mkdtempSync(join(tmpdir(), 'mm-pid-')), 'nested', 'bot.pid');
|
|
writePidFile(file, 7);
|
|
expect(existsSync(file)).toBe(true);
|
|
});
|
|
|
|
it('ignores a missing file on clear', () => {
|
|
const file = join(mkdtempSync(join(tmpdir(), 'mm-pid-')), 'missing.pid');
|
|
writeFileSync(join(file, '..', 'keep'), '');
|
|
expect(() => clearPidFile(file, 1)).not.toThrow();
|
|
});
|
|
});
|