-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pindexer(dex_ex): index batch swap execution traces (#4990)
## Describe your changes This PR adds a `dex_ex_batch_swap_traces` table that tracks batch swap execution traces. We do not (yet) track individual position ids for each subtrace hops, so this is left empty. Notably, the schema contains a price float, but no input/output amount floats for now. This is good to have, but we can add it later and it's not immediately useful to the intended consumer of this data. The schema: ```sql -- This table tracks individual execution traces for a directed batch swap. CREATE TABLE IF NOT EXISTS dex_ex_batch_swap_traces ( -- Primary key rowid SERIAL PRIMARY KEY, -- The height of the block the batch swap was included in. height INTEGER NOT NULL, -- The time the batch swap was included in a block. time TIMESTAMPTZ NOT NULL, -- The amount of asset 1 consumed by the micro execution in raw denom. input NUMERIC(39) NOT NULL, -- The amount of asset 2 produced by the micro execution in raw denom. output NUMERIC(39) NOT NULL, -- The amount of asset 1 consumed by the macro execution. batch_input NUMERIC(39) NOT NULL, -- The amount of asset 2 produced by the macro execution. batch_output NUMERIC(39) NOT NULL, -- The price (output/input) as a float price_float DOUBLE PRECISION NOT NULL, -- The directed start asset of the batch swap. asset_start BYTEA NOT NULL, -- The directed end asset of the batch swap. asset_end BYTEA NOT NULL, -- Each hop in the list contains an asset id. asset_hops BYTEA[] NOT NULL, -- Each hop in the list contains an amount. amount_hops NUMERIC(39)[] NOT NULL, -- Each hop in the list contains a position ID. position_id_hops BYTEA[] NOT NULL ); CREATE INDEX ON dex_ex_batch_swap_traces (time, height); CREATE INDEX ON dex_ex_batch_swap_traces (asset_start, asset_end); ``` ## 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: > pindexer changes
- Loading branch information
Showing
2 changed files
with
156 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters