Skip to content

fix: lp position withdraw causes negative liquidity values #5204

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vacekj
Copy link
Member

@vacekj vacekj commented May 29, 2025

Describe your changes

Issue ticket number and link

Checklist before requesting a review

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

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

    REPLACE THIS TEXT WITH RATIONALE (CAN BE BRIEF)

@conorsch
Copy link
Contributor

conorsch commented Jun 9, 2025

Refs #5208. However, as discussion in that ticket shows, the motivation to fix this logic bug was to unblock tokenomics development, and we now believe devs should stay away from the total_unstaked_supply tables as deprecated.

Still, this is indeed a logic bug, and I think we should either fix it or else remove the relevant code, as @cronokirby suggested.

Also, any fixes to logic like this should be targeting the main branch, not the protocol/lqt_branch, because the fix applies to all historical events.

@conorsch conorsch changed the base branch from protocol/lqt_branch to main June 9, 2025 20:28
@conorsch conorsch force-pushed the 2412-explore-page-shows-value-proto-decoding-error-due-to-incorrect-pindexer-liquidity-value branch from cf06199 to 69b36b4 Compare June 9, 2025 20:29
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.

I'm not sure there's a difference in behavior here.

The relevant logic is:

            (true, None, new) => (-(new.r1.value() as f64), -(new.r2.value() as f64)),
            (_, None, new) => ((new.r1.value() as f64), (new.r2.value() as f64)),
            (_, Some(old), new) => (
                (new.r1.value() as f64) - (old.r1.value() as f64),
                (new.r2.value() as f64) - (old.r2.value() as f64),
            ),

So turning (true, None, Some(reserves)) into (false, Some(reserves), 0) should result in the same values, i.e. -reserves

@conorsch
Copy link
Contributor

conorsch commented Jun 9, 2025

I'm not sure there's a difference in behavior here.

Indeed, I'm still seeing negative values after running this changeset against mainnet event data:

penumbra_raw=# SELECT um, auction, dex, arb, fees
       FROM supply_total_unstaked
       ORDER BY height DESC
       LIMIT 1;
       um       |   auction   |     dex      |     arb     |   fees
----------------+-------------+--------------+-------------+-----------
 80982158646814 | 24571209329 | -34236022151 | 62870499597 | 353350630
(1 row)

N.B. although the database name in the output above is penumbra_raw, it's really a pindexer database.

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.

explore page shows Value proto decoding error due to incorrect pindexer liquidity value
3 participants