/**
 * MockExchange — deterministic in-memory exchange used by tests and dev mode.
 *
 * Implements the same `ExchangeClient` contract a real adapter would, so the
 * agent flow can be verified end-to-end without hitting a network or placing
 * real orders. Fills land at the requested price (no slippage) with a
 * configured taker fee in basis points; no latency is simulated.
 *
 * When a real Coinbase/Kraken adapter lands (follow-up PR), it replaces
 * MockExchange at the ExchangeClient seam — no Portfolio or RiskEngine
 * changes required.
 */
export class MockExchange {
    prices;
    feeBps;
    constructor(opts) {
        this.prices = { ...opts.prices };
        this.feeBps = opts.feeBps;
    }
    /** Update the synthetic price book (e.g. to simulate a move in tests). */
    setPrice(symbol, priceUsd) {
        this.prices[symbol] = priceUsd;
    }
    async placeOrder(order) {
        if (!(order.symbol in this.prices)) {
            throw new Error(`MockExchange has no quote for ${order.symbol}`);
        }
        const notional = order.qty * order.priceUsd;
        const feeUsd = (notional * this.feeBps) / 10_000;
        return {
            symbol: order.symbol,
            side: order.side,
            qty: order.qty,
            priceUsd: order.priceUsd,
            feeUsd,
        };
    }
    async getPrice(symbol) {
        return this.prices[symbol] ?? null;
    }
}
