unrip/test/price-route-runtime-static.test.mjs
philipp 729d2ade0e
Some checks failed
deploy / deploy (push) Failing after 43s
Implement pair-native trade semantics
Proof: Pair-native trade semantics and multi-asset outcome truth; strategy, request preflight, outcome attribution, valuation visibility, dashboard labels, alerts, and ops watch paths now use DB pair/asset/route metadata with nBTC/EURe compatibility and nBTC/USDC regressions covered.

Assumptions: Postgres asset, pair, strategy config, and price route rows remain canonical; supported reference adapters remain BTC/EUR and BTC/USDC; deployment is push-driven through the existing Forgejo workflow.

Still fake: Arbitrary multi-hop valuation, new execution venues, fee-complete realized PnL, venue-native terminal fill ingestion, and autonomous optimization remain unbuilt.
2026-05-18 18:52:18 +02:00

23 lines
1.3 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const marketReferenceSource = readFileSync(new URL('../src/apps/market-reference-ingest.mjs', import.meta.url), 'utf8');
const strategyEngineSource = readFileSync(new URL('../src/apps/strategy-engine.mjs', import.meta.url), 'utf8');
test('market reference ingest publishes BTC/USDC route-specific prices', () => {
assert.match(marketReferenceSource, /XBTUSDC/);
assert.match(marketReferenceSource, /btc_usdc_reference/);
assert.match(marketReferenceSource, /usdc_per_btc/);
assert.match(marketReferenceSource, /quote_per_base/);
assert.match(marketReferenceSource, /base_per_quote/);
assert.match(marketReferenceSource, /buildPriceId\(now, referencePair\.priceRoute\.routeId\)/);
});
test('strategy engine stores and consumes latest prices by price route', () => {
assert.match(strategyEngineSource, /latest_price_events_by_route/);
assert.match(strategyEngineSource, /state\.latest_price_events_by_route\[routeId\] = event/);
assert.match(strategyEngineSource, /resolvePriceEventForDemand\(event, tradingConfig\)/);
assert.match(strategyEngineSource, /pair\?\.priceRoute\?\.routeId/);
assert.match(strategyEngineSource, /return state\.latest_price_events_by_route\[routeId\] \|\| null/);
});