Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
show markets before first state event
Browse files Browse the repository at this point in the history
  • Loading branch information
CRBl69 committed Jun 4, 2024
1 parent dee09ce commit cf5bdb2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sql_extensions/migrations/special-queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ CREATE INDEX inbox_latest_state_by_daily_volume ON inbox_volume (

CREATE VIEW market_data AS
SELECT
state.market_id,
(registration.data -> 'market_metadata' ->> 'market_id')::NUMERIC AS market_id,
(registration.data -> 'market_metadata' ->> 'emoji_bytes') AS emoji_bytes,
(registration.data -> 'market_metadata' ->> 'market_address') AS market_address,
state.transaction_version,
volume.all_time_volume,
volume.daily_volume,
Expand All @@ -182,12 +184,11 @@ SELECT
(state.data -> 'cumulative_stats' ->> 'n_chat_messages')::NUMERIC AS n_chat_messages,
(state.data -> 'last_swap' ->> 'avg_execution_price_q64')::NUMERIC AS avg_execution_price_q64,
(state.data ->> 'lp_coin_supply')::NUMERIC AS lp_coin_supply,
(state.data -> 'market_metadata' ->> 'emoji_bytes') AS emoji_bytes,
(state.data -> 'market_metadata' ->> 'market_address') AS market_address,
state.data -> 'clamm_virtual_reserves' AS clamm_virtual_reserves,
state.data -> 'cpamm_real_reserves' AS cpamm_real_reserves
FROM inbox_latest_state AS state, inbox_volume AS volume
WHERE state.market_id = volume.market_id;
FROM (SELECT data FROM inbox_events WHERE event_name = 'emojicoin_dot_fun::MarketRegistration') AS registration
LEFT JOIN inbox_latest_state AS state ON (registration.data -> 'market_metadata' ->> 'market_id')::NUMERIC = state.market_id
LEFT JOIN inbox_volume AS volume ON (registration.data -> 'market_metadata' ->> 'market_id')::NUMERIC = volume.market_id;

CREATE INDEX inbox_periodic_state ON inbox_events (
((data -> 'market_metadata' ->> 'market_id')::NUMERIC),
Expand Down

0 comments on commit cf5bdb2

Please sign in to comment.