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

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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

x/dex/keeper/liquidity_test.go Outdated Show resolved Hide resolved
lpSwapIn, _ := lpTickUpdate.GetAttribute(types.AttributeSwapAmountIn)
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

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.

2 participants