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

lqt(dex): setup volume trackers #5016

Merged
merged 10 commits into from
Jan 30, 2025
Merged

Conversation

erwanor
Copy link
Member

@erwanor erwanor commented Jan 28, 2025

Describe your changes

This PR:

  • expose a component level api LqtRead
  • define two new DEX state key modules: lqt::v1::lp and lqt::v1::pair
  • implements a position_manager::volume_tracker
  • stubs out the inner position manager entrypoint, deferring implementation to later

Volume definition

We track the outflow of staking tokens from the position. This means that an attacker controlled asset must commit to a staking token inventory for at least a full block execution.

State key modeling

The lookup index maps an epoch index and a position id to a cumulative volume tally.

The full sorted index orders position ids by cumulative volume (keyed to the epoch).

Issue ticket number and link

Part of #5015

Checklist before requesting a review

  • I have added guiding text to explain how a reviewer should test these changes.
    N/A

  • 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:

    LQT branch

@erwanor erwanor marked this pull request as ready for review January 28, 2025 23:00
Copy link
Contributor

@cronokirby cronokirby left a comment

Choose a reason for hiding this comment

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

Suggested changes:

  • we should go ahead and stream out the volume as well, since we'll need it for correctly allocating rewards.

Suggested refactors:

  • use u16 for epochs,
  • rely on existing Position::reserves_for method to get the reserves for the staking token, and potentially removing the change for trading_pair.rs,
  • restrict the possible changes to the volume to just adding to the tally.

Co-authored-by: Lúcás Meier <lucas@cronokirby.com>
Signed-off-by: Erwan Or <erwan.ounn.84@gmail.com>
Copy link
Contributor

@cronokirby cronokirby left a comment

Choose a reason for hiding this comment

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

Ok, let's get this merged!

@cronokirby cronokirby merged commit 943a9a8 into protocol/lqt_branch Jan 30, 2025
13 checks passed
@cronokirby cronokirby deleted the erwan/lqt_dex_index branch January 30, 2025 05:23
conorsch pushed a commit that referenced this pull request Jan 31, 2025
## Describe your changes
This PR:
- expose a component level api `LqtRead`
- define two new DEX state key modules: `lqt::v1::lp` and
`lqt::v1::pair`
- implements a `position_manager::volume_tracker`
- stubs out the inner position manager entrypoint, deferring
implementation to later

## Volume definition

We track the **outflow** of staking tokens from the position. This means
that an attacker controlled asset must commit to a staking token
inventory for at least a full block execution.

## State key modeling

The lookup index maps an epoch index and a position id to a cumulative
volume tally.

The full sorted index orders position ids by cumulative volume (keyed to
the epoch).

## Issue ticket number and link
Part of #5015 

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.
N/A

- [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:

  > LQT branch

---------

Signed-off-by: Erwan Or <erwan.ounn.84@gmail.com>
Co-authored-by: Lúcás Meier <lucas@cronokirby.com>
conorsch pushed a commit that referenced this pull request Feb 4, 2025
## Describe your changes
This PR:
- expose a component level api `LqtRead`
- define two new DEX state key modules: `lqt::v1::lp` and
`lqt::v1::pair`
- implements a `position_manager::volume_tracker`
- stubs out the inner position manager entrypoint, deferring
implementation to later

## Volume definition

We track the **outflow** of staking tokens from the position. This means
that an attacker controlled asset must commit to a staking token
inventory for at least a full block execution.

## State key modeling

The lookup index maps an epoch index and a position id to a cumulative
volume tally.

The full sorted index orders position ids by cumulative volume (keyed to
the epoch).

## Issue ticket number and link
Part of #5015 

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.
N/A

- [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:

  > LQT branch

---------

Signed-off-by: Erwan Or <erwan.ounn.84@gmail.com>
Co-authored-by: Lúcás Meier <lucas@cronokirby.com>
conorsch pushed a commit that referenced this pull request Feb 5, 2025
## Describe your changes
This PR:
- expose a component level api `LqtRead`
- define two new DEX state key modules: `lqt::v1::lp` and
`lqt::v1::pair`
- implements a `position_manager::volume_tracker`
- stubs out the inner position manager entrypoint, deferring
implementation to later

## Volume definition

We track the **outflow** of staking tokens from the position. This means
that an attacker controlled asset must commit to a staking token
inventory for at least a full block execution.

## State key modeling

The lookup index maps an epoch index and a position id to a cumulative
volume tally.

The full sorted index orders position ids by cumulative volume (keyed to
the epoch).

## Issue ticket number and link
Part of #5015 

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.
N/A

- [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:

  > LQT branch

---------

Signed-off-by: Erwan Or <erwan.ounn.84@gmail.com>
Co-authored-by: Lúcás Meier <lucas@cronokirby.com>
conorsch pushed a commit that referenced this pull request Feb 5, 2025
## Describe your changes
This PR:
- expose a component level api `LqtRead`
- define two new DEX state key modules: `lqt::v1::lp` and
`lqt::v1::pair`
- implements a `position_manager::volume_tracker`
- stubs out the inner position manager entrypoint, deferring
implementation to later

## Volume definition

We track the **outflow** of staking tokens from the position. This means
that an attacker controlled asset must commit to a staking token
inventory for at least a full block execution.

## State key modeling

The lookup index maps an epoch index and a position id to a cumulative
volume tally.

The full sorted index orders position ids by cumulative volume (keyed to
the epoch).

## Issue ticket number and link
Part of #5015 

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.
N/A

- [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:

  > LQT branch

---------

Signed-off-by: Erwan Or <erwan.ounn.84@gmail.com>
Co-authored-by: Lúcás Meier <lucas@cronokirby.com>
conorsch pushed a commit that referenced this pull request Feb 14, 2025
## Describe your changes
This PR:
- expose a component level api `LqtRead`
- define two new DEX state key modules: `lqt::v1::lp` and
`lqt::v1::pair`
- implements a `position_manager::volume_tracker`
- stubs out the inner position manager entrypoint, deferring
implementation to later

## Volume definition

We track the **outflow** of staking tokens from the position. This means
that an attacker controlled asset must commit to a staking token
inventory for at least a full block execution.

## State key modeling

The lookup index maps an epoch index and a position id to a cumulative
volume tally.

The full sorted index orders position ids by cumulative volume (keyed to
the epoch).

## Issue ticket number and link
Part of #5015 

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.
N/A

- [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:

  > LQT branch

---------

Signed-off-by: Erwan Or <erwan.ounn.84@gmail.com>
Co-authored-by: Lúcás Meier <lucas@cronokirby.com>
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