feat(sol): add agave-backed dlob hot path for canary
Some checks failed
deploy-trade-r001-canary / apply (push) Failing after 5m41s
Some checks failed
deploy-trade-r001-canary / apply (push) Failing after 5m41s
This commit is contained in:
@@ -98,12 +98,17 @@ async function main() {
|
||||
const source = 'default';
|
||||
|
||||
const baseTicks = { schema: 'public', name: 'drift_ticks' };
|
||||
const dlobHotSnapshotLatestTable = { schema: 'public', name: 'dlob_hot_snapshot_latest' };
|
||||
const dlobHotDerivedLatestTable = { schema: 'public', name: 'dlob_hot_derived_latest' };
|
||||
const dlobAllDerivedLatestTable = { schema: 'public', name: 'dlob_all_derived_latest' };
|
||||
const dlobL2LatestTable = { schema: 'public', name: 'dlob_l2_latest' };
|
||||
const dlobStatsLatestTable = { schema: 'public', name: 'dlob_stats_latest' };
|
||||
const dlobDepthBpsLatestTable = { schema: 'public', name: 'dlob_depth_bps_latest' };
|
||||
const dlobSlippageLatestTable = { schema: 'public', name: 'dlob_slippage_latest' };
|
||||
const dlobSlippageLatestV2Table = { schema: 'public', name: 'dlob_slippage_latest_v2' };
|
||||
const candlesCacheTable = { schema: 'public', name: 'drift_candles_cache' };
|
||||
const dlobHotDerivedTsTable = { schema: 'public', name: 'dlob_hot_derived_ts' };
|
||||
const dlobAllDerivedTsTable = { schema: 'public', name: 'dlob_all_derived_ts' };
|
||||
const dlobStatsTsTable = { schema: 'public', name: 'dlob_stats_ts' };
|
||||
const dlobDepthBpsTsTable = { schema: 'public', name: 'dlob_depth_bps_ts' };
|
||||
const dlobSlippageTsTable = { schema: 'public', name: 'dlob_slippage_ts' };
|
||||
@@ -373,6 +378,171 @@ async function main() {
|
||||
'updated_at',
|
||||
], { publicFilter: dlobPublicFilter });
|
||||
|
||||
await ensurePublicSelectTable(dlobHotSnapshotLatestTable, [
|
||||
'source',
|
||||
'redis_key',
|
||||
'snapshot_kind',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'market_name',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'market_slot',
|
||||
'payload_hash',
|
||||
'mark_price_raw',
|
||||
'oracle_price_raw',
|
||||
'best_bid_price_raw',
|
||||
'best_ask_price_raw',
|
||||
'spread_pct_raw',
|
||||
'spread_quote_raw',
|
||||
'oracle_data',
|
||||
'bids',
|
||||
'asks',
|
||||
'payload',
|
||||
'updated_at',
|
||||
]);
|
||||
|
||||
await ensurePublicSelectTable(dlobHotDerivedLatestTable, [
|
||||
'source',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'market_name',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'market_slot',
|
||||
'mark_price',
|
||||
'oracle_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'mid_price',
|
||||
'spread_quote',
|
||||
'spread_bps',
|
||||
'depth_levels',
|
||||
'bid_levels',
|
||||
'ask_levels',
|
||||
'top_bid_size',
|
||||
'top_ask_size',
|
||||
'top_bid_notional',
|
||||
'top_ask_notional',
|
||||
'depth_bid_base',
|
||||
'depth_ask_base',
|
||||
'depth_bid_quote',
|
||||
'depth_ask_quote',
|
||||
'imbalance',
|
||||
'bids_norm',
|
||||
'asks_norm',
|
||||
'raw_payload_hash',
|
||||
'updated_at',
|
||||
]);
|
||||
|
||||
await ensurePublicSelectTable(dlobAllDerivedLatestTable, [
|
||||
'source',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'market_name',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'market_slot',
|
||||
'mark_price',
|
||||
'oracle_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'mid_price',
|
||||
'spread_quote',
|
||||
'spread_bps',
|
||||
'depth_levels',
|
||||
'bid_levels',
|
||||
'ask_levels',
|
||||
'top_bid_size',
|
||||
'top_ask_size',
|
||||
'top_bid_notional',
|
||||
'top_ask_notional',
|
||||
'depth_bid_base',
|
||||
'depth_ask_base',
|
||||
'depth_bid_quote',
|
||||
'depth_ask_quote',
|
||||
'imbalance',
|
||||
'bids_norm',
|
||||
'asks_norm',
|
||||
'raw_payload_hash',
|
||||
'updated_at',
|
||||
]);
|
||||
|
||||
await ensurePublicSelectTable(dlobHotDerivedTsTable, [
|
||||
'event_ts',
|
||||
'id',
|
||||
'source',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'market_name',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'market_slot',
|
||||
'mark_price',
|
||||
'oracle_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'mid_price',
|
||||
'spread_quote',
|
||||
'spread_bps',
|
||||
'depth_levels',
|
||||
'bid_levels',
|
||||
'ask_levels',
|
||||
'top_bid_size',
|
||||
'top_ask_size',
|
||||
'top_bid_notional',
|
||||
'top_ask_notional',
|
||||
'depth_bid_base',
|
||||
'depth_ask_base',
|
||||
'depth_bid_quote',
|
||||
'depth_ask_quote',
|
||||
'imbalance',
|
||||
'bids_norm',
|
||||
'asks_norm',
|
||||
'raw_payload_hash',
|
||||
'inserted_at',
|
||||
]);
|
||||
|
||||
await ensurePublicSelectTable(dlobAllDerivedTsTable, [
|
||||
'event_ts',
|
||||
'id',
|
||||
'source',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'market_name',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'market_slot',
|
||||
'mark_price',
|
||||
'oracle_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'mid_price',
|
||||
'spread_quote',
|
||||
'spread_bps',
|
||||
'depth_levels',
|
||||
'bid_levels',
|
||||
'ask_levels',
|
||||
'top_bid_size',
|
||||
'top_ask_size',
|
||||
'top_bid_notional',
|
||||
'top_ask_notional',
|
||||
'depth_bid_base',
|
||||
'depth_ask_base',
|
||||
'depth_bid_quote',
|
||||
'depth_ask_quote',
|
||||
'imbalance',
|
||||
'bids_norm',
|
||||
'asks_norm',
|
||||
'raw_payload_hash',
|
||||
'inserted_at',
|
||||
]);
|
||||
|
||||
await ensurePublicSelectTable(dlobStatsTsTable, [
|
||||
'ts',
|
||||
'id',
|
||||
|
||||
@@ -858,3 +858,271 @@ BEGIN
|
||||
PERFORM add_retention_policy('dlob_slippage_ts_v2', INTERVAL '7 days');
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
END $$;
|
||||
|
||||
-- Canonical raw DLOB hot snapshots written from Redis to PostgreSQL.
|
||||
CREATE TABLE IF NOT EXISTS public.dlob_hot_snapshot_latest (
|
||||
source TEXT NOT NULL,
|
||||
redis_key TEXT NOT NULL,
|
||||
snapshot_kind TEXT NOT NULL CHECK (snapshot_kind IN ('orderbook_l2', 'orderbook_l3', 'best_makers')),
|
||||
market_type TEXT NOT NULL,
|
||||
market_index INTEGER NOT NULL,
|
||||
market_name TEXT NOT NULL,
|
||||
is_indicative BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
ts_ms BIGINT NOT NULL,
|
||||
slot BIGINT,
|
||||
market_slot BIGINT,
|
||||
payload_hash TEXT NOT NULL,
|
||||
mark_price_raw TEXT,
|
||||
oracle_price_raw TEXT,
|
||||
best_bid_price_raw TEXT,
|
||||
best_ask_price_raw TEXT,
|
||||
spread_pct_raw TEXT,
|
||||
spread_quote_raw TEXT,
|
||||
oracle_data JSONB,
|
||||
bids JSONB,
|
||||
asks JSONB,
|
||||
payload JSONB NOT NULL,
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (source, market_type, market_index, snapshot_kind, is_indicative)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_hot_snapshot_latest_updated_at_idx
|
||||
ON public.dlob_hot_snapshot_latest (updated_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_hot_snapshot_latest_source_market_idx
|
||||
ON public.dlob_hot_snapshot_latest (source, market_type, market_index, updated_at DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.dlob_hot_snapshot_ts (
|
||||
event_ts TIMESTAMPTZ NOT NULL,
|
||||
id BIGSERIAL NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
redis_key TEXT NOT NULL,
|
||||
snapshot_kind TEXT NOT NULL CHECK (snapshot_kind IN ('orderbook_l2', 'orderbook_l3', 'best_makers')),
|
||||
market_type TEXT NOT NULL,
|
||||
market_index INTEGER NOT NULL,
|
||||
market_name TEXT NOT NULL,
|
||||
is_indicative BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
ts_ms BIGINT NOT NULL,
|
||||
slot BIGINT,
|
||||
market_slot BIGINT,
|
||||
payload_hash TEXT NOT NULL,
|
||||
mark_price_raw TEXT,
|
||||
oracle_price_raw TEXT,
|
||||
best_bid_price_raw TEXT,
|
||||
best_ask_price_raw TEXT,
|
||||
spread_pct_raw TEXT,
|
||||
spread_quote_raw TEXT,
|
||||
oracle_data JSONB,
|
||||
bids JSONB,
|
||||
asks JSONB,
|
||||
payload JSONB NOT NULL,
|
||||
inserted_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (event_ts, id)
|
||||
);
|
||||
|
||||
SELECT create_hypertable('dlob_hot_snapshot_ts', 'event_ts', if_not_exists => TRUE, migrate_data => TRUE);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS dlob_hot_snapshot_ts_dedupe_idx
|
||||
ON public.dlob_hot_snapshot_ts (event_ts, source, redis_key, payload_hash);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_hot_snapshot_ts_market_ts_desc_idx
|
||||
ON public.dlob_hot_snapshot_ts (market_type, market_index, event_ts DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_hot_snapshot_ts_source_market_ts_desc_idx
|
||||
ON public.dlob_hot_snapshot_ts (source, market_type, market_index, event_ts DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.dlob_hot_derived_latest (
|
||||
source TEXT NOT NULL,
|
||||
market_type TEXT NOT NULL,
|
||||
market_index INTEGER NOT NULL,
|
||||
market_name TEXT NOT NULL,
|
||||
is_indicative BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
ts_ms BIGINT NOT NULL,
|
||||
slot BIGINT,
|
||||
market_slot BIGINT,
|
||||
mark_price NUMERIC,
|
||||
oracle_price NUMERIC,
|
||||
best_bid_price NUMERIC,
|
||||
best_ask_price NUMERIC,
|
||||
mid_price NUMERIC,
|
||||
spread_quote NUMERIC,
|
||||
spread_bps NUMERIC,
|
||||
depth_levels INTEGER NOT NULL,
|
||||
bid_levels INTEGER NOT NULL,
|
||||
ask_levels INTEGER NOT NULL,
|
||||
top_bid_size NUMERIC,
|
||||
top_ask_size NUMERIC,
|
||||
top_bid_notional NUMERIC,
|
||||
top_ask_notional NUMERIC,
|
||||
depth_bid_base NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_ask_base NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_bid_quote NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_ask_quote NUMERIC NOT NULL DEFAULT 0,
|
||||
imbalance NUMERIC,
|
||||
bids_norm JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
asks_norm JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
raw_payload_hash TEXT NOT NULL,
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (source, market_type, market_index, is_indicative)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_hot_derived_latest_updated_at_idx
|
||||
ON public.dlob_hot_derived_latest (updated_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_hot_derived_latest_source_market_idx
|
||||
ON public.dlob_hot_derived_latest (source, market_type, market_index, updated_at DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.dlob_hot_derived_ts (
|
||||
event_ts TIMESTAMPTZ NOT NULL,
|
||||
id BIGSERIAL NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
market_type TEXT NOT NULL,
|
||||
market_index INTEGER NOT NULL,
|
||||
market_name TEXT NOT NULL,
|
||||
is_indicative BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
ts_ms BIGINT NOT NULL,
|
||||
slot BIGINT,
|
||||
market_slot BIGINT,
|
||||
mark_price NUMERIC,
|
||||
oracle_price NUMERIC,
|
||||
best_bid_price NUMERIC,
|
||||
best_ask_price NUMERIC,
|
||||
mid_price NUMERIC,
|
||||
spread_quote NUMERIC,
|
||||
spread_bps NUMERIC,
|
||||
depth_levels INTEGER NOT NULL,
|
||||
bid_levels INTEGER NOT NULL,
|
||||
ask_levels INTEGER NOT NULL,
|
||||
top_bid_size NUMERIC,
|
||||
top_ask_size NUMERIC,
|
||||
top_bid_notional NUMERIC,
|
||||
top_ask_notional NUMERIC,
|
||||
depth_bid_base NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_ask_base NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_bid_quote NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_ask_quote NUMERIC NOT NULL DEFAULT 0,
|
||||
imbalance NUMERIC,
|
||||
bids_norm JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
asks_norm JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
raw_payload_hash TEXT NOT NULL,
|
||||
inserted_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (event_ts, id)
|
||||
);
|
||||
|
||||
SELECT create_hypertable('dlob_hot_derived_ts', 'event_ts', if_not_exists => TRUE, migrate_data => TRUE);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS dlob_hot_derived_ts_dedupe_idx
|
||||
ON public.dlob_hot_derived_ts (event_ts, source, market_type, market_index, is_indicative, raw_payload_hash);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_hot_derived_ts_market_ts_desc_idx
|
||||
ON public.dlob_hot_derived_ts (market_type, market_index, event_ts DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_hot_derived_ts_source_market_ts_desc_idx
|
||||
ON public.dlob_hot_derived_ts (source, market_type, market_index, event_ts DESC);
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
PERFORM add_retention_policy('dlob_hot_snapshot_ts', INTERVAL '30 days');
|
||||
EXCEPTION WHEN duplicate_object THEN NULL;
|
||||
END $$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
PERFORM add_retention_policy('dlob_hot_derived_ts', INTERVAL '180 days');
|
||||
EXCEPTION WHEN duplicate_object THEN NULL;
|
||||
END $$;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.dlob_all_derived_latest (
|
||||
source TEXT NOT NULL,
|
||||
market_type TEXT NOT NULL,
|
||||
market_index INTEGER NOT NULL,
|
||||
market_name TEXT NOT NULL,
|
||||
is_indicative BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
ts_ms BIGINT NOT NULL,
|
||||
slot BIGINT,
|
||||
market_slot BIGINT,
|
||||
mark_price NUMERIC,
|
||||
oracle_price NUMERIC,
|
||||
best_bid_price NUMERIC,
|
||||
best_ask_price NUMERIC,
|
||||
mid_price NUMERIC,
|
||||
spread_quote NUMERIC,
|
||||
spread_bps NUMERIC,
|
||||
depth_levels INTEGER NOT NULL,
|
||||
bid_levels INTEGER NOT NULL,
|
||||
ask_levels INTEGER NOT NULL,
|
||||
top_bid_size NUMERIC,
|
||||
top_ask_size NUMERIC,
|
||||
top_bid_notional NUMERIC,
|
||||
top_ask_notional NUMERIC,
|
||||
depth_bid_base NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_ask_base NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_bid_quote NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_ask_quote NUMERIC NOT NULL DEFAULT 0,
|
||||
imbalance NUMERIC,
|
||||
bids_norm JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
asks_norm JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
raw_payload_hash TEXT NOT NULL,
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (source, market_type, market_index, is_indicative)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_all_derived_latest_updated_at_idx
|
||||
ON public.dlob_all_derived_latest (updated_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_all_derived_latest_source_market_idx
|
||||
ON public.dlob_all_derived_latest (source, market_type, market_index, updated_at DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.dlob_all_derived_ts (
|
||||
event_ts TIMESTAMPTZ NOT NULL,
|
||||
id BIGSERIAL NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
market_type TEXT NOT NULL,
|
||||
market_index INTEGER NOT NULL,
|
||||
market_name TEXT NOT NULL,
|
||||
is_indicative BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
ts_ms BIGINT NOT NULL,
|
||||
slot BIGINT,
|
||||
market_slot BIGINT,
|
||||
mark_price NUMERIC,
|
||||
oracle_price NUMERIC,
|
||||
best_bid_price NUMERIC,
|
||||
best_ask_price NUMERIC,
|
||||
mid_price NUMERIC,
|
||||
spread_quote NUMERIC,
|
||||
spread_bps NUMERIC,
|
||||
depth_levels INTEGER NOT NULL,
|
||||
bid_levels INTEGER NOT NULL,
|
||||
ask_levels INTEGER NOT NULL,
|
||||
top_bid_size NUMERIC,
|
||||
top_ask_size NUMERIC,
|
||||
top_bid_notional NUMERIC,
|
||||
top_ask_notional NUMERIC,
|
||||
depth_bid_base NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_ask_base NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_bid_quote NUMERIC NOT NULL DEFAULT 0,
|
||||
depth_ask_quote NUMERIC NOT NULL DEFAULT 0,
|
||||
imbalance NUMERIC,
|
||||
bids_norm JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
asks_norm JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
raw_payload_hash TEXT NOT NULL,
|
||||
inserted_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (event_ts, id)
|
||||
);
|
||||
|
||||
SELECT create_hypertable('dlob_all_derived_ts', 'event_ts', if_not_exists => TRUE, migrate_data => TRUE);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS dlob_all_derived_ts_dedupe_idx
|
||||
ON public.dlob_all_derived_ts (event_ts, source, market_type, market_index, is_indicative, raw_payload_hash);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_all_derived_ts_market_ts_desc_idx
|
||||
ON public.dlob_all_derived_ts (market_type, market_index, event_ts DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS dlob_all_derived_ts_source_market_ts_desc_idx
|
||||
ON public.dlob_all_derived_ts (source, market_type, market_index, event_ts DESC);
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
PERFORM add_retention_policy('dlob_all_derived_ts', INTERVAL '30 days');
|
||||
EXCEPTION WHEN duplicate_object THEN NULL;
|
||||
END $$;
|
||||
|
||||
Reference in New Issue
Block a user