Skip to content

Commit

Permalink
Fix duplicate events and duplicate lps
Browse files Browse the repository at this point in the history
  • Loading branch information
philipjames44 committed Jun 11, 2024
1 parent a0b2454 commit 44d3f56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/liquidityPositions/timelinePosition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface TimelinePositionProps {
}

export const POSITION_OPEN_EVENT = "EventPositionOpen";
export const POSITION_CLOSE_EVENT = "EventPositionClose";
export const POSITION_CLOSE_EVENT = "EventQueuePositionClose";
export const POSITION_WITHDRAW_EVENT = "EventPositionWithdraw";

const TimelinePosition = ({ nftId, lp_event }: TimelinePositionProps) => {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/indexer/connector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class IndexerQuerier {
INNER JOIN tx_results tr ON e.block_id = tr.block_id and te.index = tr.index
INNER JOIN block_events b ON e.block_id = b.block_id and b.key = 'height' and b.type = 'block'
LEFT JOIN attributes additional_attributes ON additional_attributes.event_id = a.event_id
WHERE a.value = $1 and a.composite_key not like '%EventPositionExecution%'
WHERE a.value = $1 and a.composite_key not like '%EventPositionExecution%'
GROUP BY a.event_id, e.block_id, e.tx_id, e.type, tr.tx_hash, tr.created_at, tr.index, b.height;
`;

Expand Down Expand Up @@ -115,7 +115,7 @@ export class IndexerQuerier {
INNER JOIN block_events b ON e.block_id = b.block_id AND b.key = 'height'
INNER JOIN tx_results tr ON tr.block_id = e.block_id
LEFT JOIN attributes additional_attributes ON additional_attributes.event_id = a.event_id
WHERE a.value = $1 AND a.composite_key LIKE '%EventPositionExecution%'
WHERE a.value = $1 AND a.composite_key LIKE '%EventPositionExecution%'
GROUP BY a.event_id, e.block_id, e.tx_id, e.type, tr.tx_hash, tr.created_at, tr.index, b.height
)
SELECT
Expand Down Expand Up @@ -160,7 +160,7 @@ export class IndexerQuerier {
LEFT JOIN attributes additional_attributes ON additional_attributes.event_id = a.event_id
INNER JOIN tx_events te ON a.value = te.value and te.composite_key = a.composite_key
INNER JOIN tx_results tr ON tr.block_id = e.block_id and te.index = tr.index
WHERE b.height >= $1 and b.height < $2 and (a.composite_key like '%PositionOpen%' or a.composite_key like '%PositionWithdraw%' or a.composite_key like '%PositionClose%s')
WHERE b.height >= $1 and b.height < $2 and (a.composite_key like '%PositionOpen.positionId%' or a.composite_key like '%PositionWithdraw.positionId%' or a.composite_key like '%PositionClose.positionId%')
GROUP BY a.event_id, e.block_id, e.tx_id, e.type, tr.tx_hash, tr.created_at, tr.index, b.height;
`;

Expand Down Expand Up @@ -208,7 +208,7 @@ export class IndexerQuerier {
block_height
FROM RankedTrades
WHERE
cnt = 1 OR rn > 1 AND type like '%EventPosition%'; -- Exclude the lowest tr.index when there are duplicates for an event_id
cnt = 1 OR rn > 1 AND type like '%EventPosition.positionId%' OR type like '%EventQueuePositionClose.positionId%'; -- Exclude the lowest tr.index when there are duplicates for an event_id
`;
// Use parameterized query to prevent SQL injection
const res = await this.query(queryText, [`${blockHeight}`]);
Expand Down

0 comments on commit 44d3f56

Please sign in to comment.