Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pindexer: Allow for multiple BatchSwaps in a single block #4853

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/bin/pindexer/src/dex/dex.sql
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ CREATE TABLE IF NOT EXISTS dex_lp_execution (

--- Represents instances where swap executions happened.
CREATE TABLE IF NOT EXISTS dex_batch_swap (
height BIGINT PRIMARY KEY,
id SERIAL PRIMARY KEY,
height BIGINT NOT NULL,
trace12_start INTEGER REFERENCES dex_trace (id),
trace12_end INTEGER REFERENCES dex_trace (id),
trace21_start INTEGER REFERENCES dex_trace (id),
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/pindexer/src/dex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl Event {
insert_swap_execution(dbtx, execution12.as_ref()).await?;
let (trace21_start, trace21_end) =
insert_swap_execution(dbtx, execution21.as_ref()).await?;
sqlx::query(r#"INSERT INTO dex_batch_swap VALUES ($1, $2, $3, $4, $5, $6, $7, CAST($8 AS Amount), CAST($9 AS Amount), CAST($10 AS Amount), CAST($11 AS Amount), CAST($12 AS Amount), CAST($13 AS Amount));"#)
sqlx::query(r#"INSERT INTO dex_batch_swap VALUES (DEFAULT, $1, $2, $3, $4, $5, $6, $7, CAST($8 AS Amount), CAST($9 AS Amount), CAST($10 AS Amount), CAST($11 AS Amount), CAST($12 AS Amount), CAST($13 AS Amount));"#)
.bind(i64::try_from(*height)?)
.bind(trace12_start)
.bind(trace12_end)
Expand Down
Loading