chore(snapshot): sync workspace state
This commit is contained in:
@@ -92,25 +92,33 @@ async function main() {
|
||||
const PUBLIC_DLOB_SOURCE_HEADER = 'X-Hasura-Dlob-Source';
|
||||
|
||||
const apiTokensTable = { schema: 'public', name: 'api_tokens' };
|
||||
const botConfigTable = { schema: 'public', name: 'bot_config' };
|
||||
const botStateTable = { schema: 'public', name: 'bot_state' };
|
||||
const botEventsTable = { schema: 'public', name: 'bot_events' };
|
||||
const source = 'default';
|
||||
|
||||
const baseTicks = { schema: 'public', name: 'drift_ticks' };
|
||||
const dlobL2LatestTable = { schema: 'public', name: 'dlob_l2_latest' };
|
||||
const dlobL2LatestProjectionView = { schema: 'public', name: 'dlob_l2_latest_projection' };
|
||||
const dlobL3LatestProjectionView = { schema: 'public', name: 'dlob_l3_latest_projection' };
|
||||
const dlobBestMakersLatestProjectionView = { schema: 'public', name: 'dlob_best_makers_latest_projection' };
|
||||
const dlobStatsLatestTable = { schema: 'public', name: 'dlob_stats_latest' };
|
||||
const dlobStatsLatestProjectionView = { schema: 'public', name: 'dlob_stats_latest_projection' };
|
||||
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 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 candlesCacheTable = { schema: 'public', name: 'drift_candles_cache' };
|
||||
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 dlobSlippageTsV2Table = { schema: 'public', name: 'dlob_slippage_ts_v2' };
|
||||
const dlobHotDerivedTsTable = { schema: 'public', name: 'dlob_hot_derived_ts' };
|
||||
const dlobAllDerivedTsTable = { schema: 'public', name: 'dlob_all_derived_ts' };
|
||||
const baseCandlesFn = { schema: 'public', name: 'get_drift_candles' };
|
||||
const candlesReturnTable = { schema: 'public', name: 'drift_candles' };
|
||||
const legacyDlobRelations = [
|
||||
{ schema: 'public', name: 'dlob_l2_latest' },
|
||||
{ schema: 'public', name: 'dlob_l2_latest_projection' },
|
||||
{ schema: 'public', name: 'dlob_stats_latest' },
|
||||
{ schema: 'public', name: 'dlob_stats_latest_projection' },
|
||||
{ schema: 'public', name: 'dlob_depth_bps_latest' },
|
||||
{ schema: 'public', name: 'dlob_slippage_latest' },
|
||||
{ schema: 'public', name: 'dlob_slippage_latest_v2' },
|
||||
{ schema: 'public', name: 'dlob_stats_ts' },
|
||||
{ schema: 'public', name: 'dlob_depth_bps_ts' },
|
||||
{ schema: 'public', name: 'dlob_slippage_ts' },
|
||||
{ schema: 'public', name: 'dlob_slippage_ts_v2' },
|
||||
];
|
||||
|
||||
const extraTicksName = normalizeName(TARGET_TICKS_TABLE);
|
||||
const extraCandlesName = normalizeName(TARGET_CANDLES_FUNCTION);
|
||||
@@ -293,139 +301,174 @@ async function main() {
|
||||
|
||||
const dlobPublicFilter = { source: { _eq: PUBLIC_DLOB_SOURCE_HEADER } };
|
||||
|
||||
await metadataIgnore({ type: 'pg_untrack_table', args: { source, table: dlobL2LatestTable, cascade: true } });
|
||||
await ensureProjectedPublicSelectTable(dlobL2LatestProjectionView, [
|
||||
for (const table of legacyDlobRelations) {
|
||||
await metadataIgnore({ type: 'pg_untrack_table', args: { source, table, cascade: true } });
|
||||
}
|
||||
|
||||
await ensurePublicSelectTable(dlobHotSnapshotLatestTable, [
|
||||
'source',
|
||||
'market_name',
|
||||
'redis_key',
|
||||
'snapshot_kind',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'ts',
|
||||
'market_name',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'mark_price',
|
||||
'oracle_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'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',
|
||||
'raw',
|
||||
'payload',
|
||||
'updated_at',
|
||||
], { publicFilter: dlobPublicFilter, customName: 'dlob_l2_latest' });
|
||||
]);
|
||||
|
||||
await metadataIgnore({ type: 'pg_untrack_table', args: { source, table: dlobStatsLatestTable, cascade: true } });
|
||||
await ensureProjectedPublicSelectTable(dlobStatsLatestProjectionView, [
|
||||
await ensurePublicSelectTable(dlobHotDerivedLatestTable, [
|
||||
'source',
|
||||
'market_name',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'ts',
|
||||
'market_name',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'market_slot',
|
||||
'mark_price',
|
||||
'oracle_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'mid_price',
|
||||
'spread_abs',
|
||||
'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_usd',
|
||||
'depth_ask_usd',
|
||||
'depth_bid_quote',
|
||||
'depth_ask_quote',
|
||||
'imbalance',
|
||||
'raw',
|
||||
'bids_norm',
|
||||
'asks_norm',
|
||||
'raw_payload_hash',
|
||||
'updated_at',
|
||||
], { publicFilter: dlobPublicFilter, customName: 'dlob_stats_latest' });
|
||||
]);
|
||||
|
||||
await ensureProjectedPublicSelectTable(dlobL3LatestProjectionView, [
|
||||
await ensurePublicSelectTable(dlobAllDerivedLatestTable, [
|
||||
'source',
|
||||
'market_name',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'ts',
|
||||
'slot',
|
||||
'bids',
|
||||
'asks',
|
||||
'raw',
|
||||
'updated_at',
|
||||
], { publicFilter: dlobPublicFilter });
|
||||
|
||||
await ensureProjectedPublicSelectTable(dlobBestMakersLatestProjectionView, [
|
||||
'source',
|
||||
'market_name',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'bids',
|
||||
'asks',
|
||||
'raw',
|
||||
'updated_at',
|
||||
], { publicFilter: dlobPublicFilter });
|
||||
|
||||
await ensurePublicSelectTable(dlobDepthBpsLatestTable, [
|
||||
'source',
|
||||
'market_name',
|
||||
'band_bps',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'ts',
|
||||
'slot',
|
||||
'mid_price',
|
||||
'market_slot',
|
||||
'mark_price',
|
||||
'oracle_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'bid_base',
|
||||
'ask_base',
|
||||
'bid_usd',
|
||||
'ask_usd',
|
||||
'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',
|
||||
'raw',
|
||||
'bids_norm',
|
||||
'asks_norm',
|
||||
'raw_payload_hash',
|
||||
'updated_at',
|
||||
], { publicFilter: dlobPublicFilter });
|
||||
]);
|
||||
|
||||
await ensurePublicSelectTable(dlobSlippageLatestTable, [
|
||||
await ensurePublicSelectTable(dlobHotDerivedTsTable, [
|
||||
'event_ts',
|
||||
'id',
|
||||
'source',
|
||||
'market_name',
|
||||
'side',
|
||||
'size_usd',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'ts',
|
||||
'market_name',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'mid_price',
|
||||
'market_slot',
|
||||
'mark_price',
|
||||
'oracle_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'vwap_price',
|
||||
'worst_price',
|
||||
'filled_usd',
|
||||
'filled_base',
|
||||
'impact_bps',
|
||||
'levels_consumed',
|
||||
'fill_pct',
|
||||
'raw',
|
||||
'updated_at',
|
||||
], { publicFilter: dlobPublicFilter });
|
||||
'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(dlobSlippageLatestV2Table, [
|
||||
await ensurePublicSelectTable(dlobAllDerivedTsTable, [
|
||||
'event_ts',
|
||||
'id',
|
||||
'source',
|
||||
'market_name',
|
||||
'side',
|
||||
'size_usd',
|
||||
'market_type',
|
||||
'market_index',
|
||||
'ts',
|
||||
'market_name',
|
||||
'is_indicative',
|
||||
'ts_ms',
|
||||
'slot',
|
||||
'mid_price',
|
||||
'market_slot',
|
||||
'mark_price',
|
||||
'oracle_price',
|
||||
'best_bid_price',
|
||||
'best_ask_price',
|
||||
'vwap_price',
|
||||
'worst_price',
|
||||
'filled_usd',
|
||||
'filled_base',
|
||||
'impact_bps',
|
||||
'levels_consumed',
|
||||
'fill_pct',
|
||||
'raw',
|
||||
'updated_at',
|
||||
], { publicFilter: dlobPublicFilter });
|
||||
'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',
|
||||
@@ -517,6 +560,12 @@ async function main() {
|
||||
'raw',
|
||||
], { publicFilter: dlobPublicFilter });
|
||||
|
||||
// Bot control-plane tables (tracked; permissions are intentionally not created here by default).
|
||||
for (const t of [botConfigTable, botStateTable, botEventsTable]) {
|
||||
await metadataIgnore({ type: 'pg_untrack_table', args: { source, table: t } });
|
||||
await metadata({ type: 'pg_track_table', args: { source, table: t } });
|
||||
}
|
||||
|
||||
// Return table type for candle functions (needed for Hasura to track the function).
|
||||
await metadataIgnore({ type: 'pg_track_table', args: { source, table: candlesReturnTable } });
|
||||
|
||||
@@ -532,7 +581,7 @@ async function main() {
|
||||
}
|
||||
|
||||
for (const fn of candleFns) {
|
||||
// Function for aggregated candle queries (used by trade-api).
|
||||
// Function for aggregated candle queries and indicator reads over Hasura.
|
||||
await metadataIgnore({ type: 'pg_untrack_function', args: { source, function: fn } });
|
||||
await metadata({ type: 'pg_track_function', args: { source, function: fn } });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user