From 0c853354eb57cffcc112e2a65f6ddc878e843cc5 Mon Sep 17 00:00:00 2001 From: u1 Date: Sat, 10 Jan 2026 00:42:46 +0000 Subject: [PATCH] feat(hasura): track DLOB tables and public permissions --- kustomize/base/hasura/hasura-bootstrap.mjs | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/kustomize/base/hasura/hasura-bootstrap.mjs b/kustomize/base/hasura/hasura-bootstrap.mjs index 329d79c..83d4cdd 100644 --- a/kustomize/base/hasura/hasura-bootstrap.mjs +++ b/kustomize/base/hasura/hasura-bootstrap.mjs @@ -93,6 +93,8 @@ async function main() { const source = 'default'; const baseTicks = { schema: 'public', name: 'drift_ticks' }; + const dlobL2LatestTable = { schema: 'public', name: 'dlob_l2_latest' }; + const dlobStatsLatestTable = { schema: 'public', name: 'dlob_stats_latest' }; const baseCandlesFn = { schema: 'public', name: 'get_drift_candles' }; const candlesReturnTable = { schema: 'public', name: 'drift_candles' }; @@ -161,8 +163,98 @@ async function main() { for (const t of tickTables) { await ensureTickTable(t); } + + const ensureDlobTable = async (table, columns) => { + await metadataIgnore({ type: 'pg_untrack_table', args: { source, table } }); + await metadata({ type: 'pg_track_table', args: { source, table } }); + + await metadataIgnore({ type: 'pg_drop_select_permission', args: { source, table, role: 'public' } }); + await metadata({ + type: 'pg_create_select_permission', + args: { + source, + table, + role: 'public', + permission: { + columns, + filter: {}, + }, + }, + }); + + await metadataIgnore({ type: 'pg_drop_insert_permission', args: { source, table, role: 'ingestor' } }); + await metadata({ + type: 'pg_create_insert_permission', + args: { + source, + table, + role: 'ingestor', + permission: { + check: {}, + set: {}, + columns, + }, + }, + }); + + await metadataIgnore({ type: 'pg_drop_update_permission', args: { source, table, role: 'ingestor' } }); + await metadata({ + type: 'pg_create_update_permission', + args: { + source, + table, + role: 'ingestor', + permission: { + filter: {}, + check: {}, + columns, + }, + }, + }); + }; + + await ensureDlobTable(dlobL2LatestTable, [ + 'market_name', + 'market_type', + 'market_index', + 'ts', + 'slot', + 'mark_price', + 'oracle_price', + 'best_bid_price', + 'best_ask_price', + 'bids', + 'asks', + 'raw', + 'updated_at', + ]); + + await ensureDlobTable(dlobStatsLatestTable, [ + 'market_name', + 'market_type', + 'market_index', + 'ts', + 'slot', + 'mark_price', + 'oracle_price', + 'best_bid_price', + 'best_ask_price', + 'mid_price', + 'spread_abs', + 'spread_bps', + 'depth_levels', + 'depth_bid_base', + 'depth_ask_base', + 'depth_bid_usd', + 'depth_ask_usd', + 'imbalance', + 'raw', + 'updated_at', + ]); + // Return table type for candle functions (needed for Hasura to track the function). await metadataIgnore({ type: 'pg_track_table', args: { source, table: candlesReturnTable } }); + try { await metadata({ type: 'pg_track_table', args: { source, table: apiTokensTable } }); } catch (err) {