Skip to content

Commit

Permalink
pindexer: dex-explorer: implement low high in summary (#4931)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
cronokirby authored Nov 18, 2024
1 parent a22ee1c commit 744e253
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/bin/pindexer/src/dex_ex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions crates/bin/pindexer/src/dex_ex/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 744e253

Please sign in to comment.