Skip to content

Commit

Permalink
pindexer: flesh out dex-explorer indexer (#4917)
Browse files Browse the repository at this point in the history
## Describe your changes

Closes #4914.

The internal architecture of the app view tries to make use of batch
processing to the extent possible, which simplifies a lot of the logic.

The price charts remain unchanged, but I collapsed the two tables into
one for performance and simplicity.

I also **did not** implement insertion of empty candles ; if there are
gaps in the events, there will be gaps in the resulting database as
well.

The main addition and where I spent most of my time on this is the
addition of summaries of information over arbitrary windows. The idea
behind the architecture here is that any time a change to liquidity,
trade count, or a candle for a directed pair happens in a block, that
block then gets a "snapshot" inserted, with the current price,
liquidity, volume in that block, etc. At the end of this batch, the
current summary is then updated, for each window, using those timed
snapshots. And then an aggregate summary, across all pairs, is created
from these summaries, for each window.

In order to price values under a common denom, assets are filtered based
on having a current USDC price, backed by enough liquidity (the denom
and liquidity amount are parameters to the component).

For testing, I'd recommend trying to run the app view against mainnet
and testnet, and checking some sanity items like the price not seeming
crazy, and matching in the summary across all windows, etc.

I think for testing we'll notice potential issues relatively quickly
when dogfooding the explorer.

## 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 only
  • Loading branch information
cronokirby authored Nov 14, 2024
1 parent 7533cc6 commit 31fca7e
Show file tree
Hide file tree
Showing 3 changed files with 761 additions and 424 deletions.
Loading

0 comments on commit 31fca7e

Please sign in to comment.