feat(staging): add dlob ts history archiver
This commit is contained in:
@@ -97,6 +97,9 @@ async function main() {
|
||||
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 dlobStatsTsTable = { schema: 'public', name: 'dlob_stats_ts' };
|
||||
const dlobDepthBpsTsTable = { schema: 'public', name: 'dlob_depth_bps_ts' };
|
||||
const dlobSlippageTsTable = { schema: 'public', name: 'dlob_slippage_ts' };
|
||||
const baseCandlesFn = { schema: 'public', name: 'get_drift_candles' };
|
||||
const candlesReturnTable = { schema: 'public', name: 'drift_candles' };
|
||||
|
||||
@@ -215,6 +218,29 @@ async function main() {
|
||||
});
|
||||
};
|
||||
|
||||
const ensurePublicSelectTable = 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: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Computed/archived tables are written by workers using admin secret; keep ingestor off by default.
|
||||
await metadataIgnore({ type: 'pg_drop_insert_permission', args: { source, table, role: 'ingestor' } });
|
||||
await metadataIgnore({ type: 'pg_drop_update_permission', args: { source, table, role: 'ingestor' } });
|
||||
};
|
||||
|
||||
await ensureDlobTable(dlobL2LatestTable, [
|
||||
'market_name',
|
||||
'market_type',
|
||||
@@ -254,7 +280,7 @@ async function main() {
|
||||
'updated_at',
|
||||
]);
|
||||
|
||||
await ensureDlobTable(dlobDepthBpsLatestTable, [
|
||||
await ensurePublicSelectTable(dlobDepthBpsLatestTable, [
|
||||
'market_name',
|
||||
'band_bps',
|
||||
'market_type',
|
||||
@@ -273,7 +299,7 @@ async function main() {
|
||||
'updated_at',
|
||||
]);
|
||||
|
||||
await ensureDlobTable(dlobSlippageLatestTable, [
|
||||
await ensurePublicSelectTable(dlobSlippageLatestTable, [
|
||||
'market_name',
|
||||
'side',
|
||||
'size_usd',
|
||||
@@ -295,6 +321,71 @@ async function main() {
|
||||
'updated_at',
|
||||
]);
|
||||
|
||||
await ensurePublicSelectTable(dlobStatsTsTable, [
|
||||
'ts',
|
||||
'id',
|
||||
'market_name',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'source_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',
|
||||
]);
|
||||
|
||||
await ensurePublicSelectTable(dlobDepthBpsTsTable, [
|
||||
'ts',
|
||||
'id',
|
||||
'market_name',
|
||||
'band_bps',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'source_ts',
|
||||
'slot',
|
||||
'mid_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'bid_base',
|
||||
'ask_base',
|
||||
'bid_usd',
|
||||
'ask_usd',
|
||||
'imbalance',
|
||||
'raw',
|
||||
]);
|
||||
|
||||
await ensurePublicSelectTable(dlobSlippageTsTable, [
|
||||
'ts',
|
||||
'id',
|
||||
'market_name',
|
||||
'side',
|
||||
'size_usd',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'source_ts',
|
||||
'slot',
|
||||
'mid_price',
|
||||
'vwap_price',
|
||||
'worst_price',
|
||||
'filled_usd',
|
||||
'filled_base',
|
||||
'impact_bps',
|
||||
'levels_consumed',
|
||||
'fill_pct',
|
||||
'raw',
|
||||
]);
|
||||
|
||||
// Return table type for candle functions (needed for Hasura to track the function).
|
||||
await metadataIgnore({ type: 'pg_track_table', args: { source, table: candlesReturnTable } });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user