Skip to content

Feat: Add swapMetadata to TickUpdates #NTRN-440#808

Merged
pr0n00gler merged 4 commits intomainfrom
feat/swap_metadata
Feb 25, 2025
Merged

Feat: Add swapMetadata to TickUpdates #NTRN-440#808
pr0n00gler merged 4 commits intomainfrom
feat/swap_metadata

Conversation

@jcompagni10
Copy link
Contributor

Add SwapAmountIn and SwapAmountOut attributes to tick updates for easier indexing of swap events.

@jcompagni10 jcompagni10 changed the title Feat: Add swapMetadata to TickUpdates Feat: Add swapMetadata to TickUpdates #NTRN-440 Jan 24, 2025
@jcompagni10
Copy link
Contributor Author

dib542
dib542 previously approved these changes Jan 24, 2025
Copy link
Contributor

@dib542 dib542 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good 👍

This is all we need to enable very easy analysis and indexing of

  • pair price
  • swap volume
  • LP fees
    for timeseries or latest value / 24hr aggregation values.

Note: I previously thought a AmountIn/AmountOut or DepositIn/DepositOut like attribute would also be needed, but such an attribute would only be helpful to compute change in Dex liqudity volume easily, the aggregate of which can be fairly easily calculated (TVL diff over time) and the specific price changes of liquidity over time is not of current interest (and can also still be derived from current data).


tickUpdates := s.GetAllMatchingEvents(types.TickUpdateEventKey)

// LimitOrder TickUpdate has correct SwapMetadatrra
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// LimitOrder TickUpdate has correct SwapMetadatrra
// LimitOrder TickUpdate has correct SwapMetadata

Mistype 😅, is also on other added comment

lpSwapOut, _ := lpTickUpdate.GetAttribute(types.AttributeSwapAmountOut)
s.Equal("9000000", lpSwapIn.Value)
s.Equal("8999100", lpSwapOut.Value)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a negative test, that the regular deposits does not include any swap attributes

@pr0n00gler pr0n00gler merged commit d9e23d2 into main Feb 25, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants