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

dex: create epoch-based cumulative volume indices #5015

Closed
Tracked by #5010
erwanor opened this issue Jan 28, 2025 · 0 comments
Closed
Tracked by #5010

dex: create epoch-based cumulative volume indices #5015

erwanor opened this issue Jan 28, 2025 · 0 comments
Assignees

Comments

@erwanor
Copy link
Member

erwanor commented Jan 28, 2025

We want to track the staking token denominated "outbound" volume that goes through a liquidity position. We use a sorted volume index, equipped with a lookup table to update entries.

State keys

  1. dex/lqt/v1/lp/lookup/ || asset || position_id ** is a cumulative volume lookup table
  2. dex/lqt/v1/lp/by_asset/ || asset || BE(!volume) || position_id is a sorted index that tracks best performing LPs
@erwanor erwanor mentioned this issue Jan 28, 2025
28 tasks
@erwanor erwanor self-assigned this Jan 28, 2025
cronokirby added a commit that referenced this issue Jan 30, 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 <[email protected]>
Co-authored-by: Lúcás Meier <[email protected]>
@erwanor erwanor closed this as completed Jan 30, 2025
conorsch pushed a commit that referenced this issue 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 <[email protected]>
Co-authored-by: Lúcás Meier <[email protected]>
conorsch pushed a commit that referenced this issue 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 <[email protected]>
Co-authored-by: Lúcás Meier <[email protected]>
conorsch pushed a commit that referenced this issue 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 <[email protected]>
Co-authored-by: Lúcás Meier <[email protected]>
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

No branches or pull requests

1 participant