From 744e2535f2ca27d380d66f948bf4f0bacf61cdf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=BAc=C3=A1s=20Meier?= Date: Mon, 18 Nov 2024 13:40:35 -0800 Subject: [PATCH] pindexer: dex-explorer: implement low high in summary (#4931) ## Describe your changes Closes #4929. This was surprisingly simple, we were already doing an aggregate calculation over the window (summing values) so this was just a matter of adding a low and a high. To test, index against main and check that nothing else has changed besides the addition of two new fields. ## Checklist before requesting a review - [x] I have added guiding text to explain how a reviewer should test these changes. - [x] If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: > indexing --- crates/bin/pindexer/src/dex_ex/mod.rs | 5 ++++- crates/bin/pindexer/src/dex_ex/schema.sql | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/bin/pindexer/src/dex_ex/mod.rs b/crates/bin/pindexer/src/dex_ex/mod.rs index 5b9b736d0a..d430ef7150 100644 --- a/crates/bin/pindexer/src/dex_ex/mod.rs +++ b/crates/bin/pindexer/src/dex_ex/mod.rs @@ -443,7 +443,9 @@ mod summary { SELECT COALESCE(SUM(direct_volume), 0.0) AS direct_volume_over_window, COALESCE(SUM(swap_volume), 0.0) AS swap_volume_over_window, - COALESCE(SUM(trades), 0.0) AS trades_over_window + COALESCE(SUM(trades), 0.0) AS trades_over_window, + COALESCE(MIN(price), 0.0) AS low, + COALESCE(MAX(price), 0.0) AS high FROM snapshots WHERE time <= $3 AND time >= $4 @@ -452,6 +454,7 @@ mod summary { SELECT $1, $2, $5, price, price_then, + low, high, liquidity, liquidity_then, direct_volume_over_window, swap_volume_over_window, diff --git a/crates/bin/pindexer/src/dex_ex/schema.sql b/crates/bin/pindexer/src/dex_ex/schema.sql index 1e89821f3e..6de17b2be2 100644 --- a/crates/bin/pindexer/src/dex_ex/schema.sql +++ b/crates/bin/pindexer/src/dex_ex/schema.sql @@ -49,6 +49,8 @@ CREATE TABLE IF NOT EXISTS dex_ex_pairs_summary ( the_window TEXT NOT NULL, price FLOAT8 NOT NULL, price_then FLOAT8 NOT NULL, + low FLOAT8 NOT NULL, + high FLOAT8 NOT NULL, liquidity FLOAT8 NOT NULL, liquidity_then FLOAT8 NOT NULL, direct_volume_over_window FLOAT8 NOT NULL,