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

pcli tx lp order sell gives a mispriced position when used with delegation tokens #2579

Closed
Tracked by #1724
hdevalence opened this issue May 16, 2023 · 3 comments
Closed
Tracked by #1724

Comments

@hdevalence
Copy link
Member

To Reproduce

Create a position selling one delegation token for another at a 1:1 price:

cargo run --release --bin pcli -- tx lp order sell 49925.817225delegation_penumbravalid14mznnxs03r0sqkwrq7mvnjwdwufn7cu29gu4hpnwcn4u7mgqqcpsvhe7h9@1delegation_penumbravalid1cqwaxsxjmj4hl78t906gtf5gcfhkpu80ju3zjtkdppelx8g5qcxqgas4lg/25bps

The position has a price off by a factor of 1,000,000:

 ID          plpid1ta9emmcxq9gvdfs299mk8gjc03rlwkxv4jme2f46uamaee294khszramt7
 State       opened
 Reserves 1  0delegation_penumbravalid1cqwaxsxjmj4hl78t906gtf5gcfhkpu80ju3zjtkdppelx8g5qcxqgas4lg
 Reserves 2  49925.817225delegation_penumbravalid14mznnxs03r0sqkwrq7mvnjwdwufn7cu29gu4hpnwcn4u7mgqqcpsvhe7h9
 Fee         25bps
 p           49925817225
 q           49925817225000000
 Nonce       de3282fdaedcb9760a77bdf786e5072b67845183b95a3684316abb98907fdcd0

Expected behavior
p and q should be identical, since the price is supposed to be 1.

@hdevalence
Copy link
Member Author

I think this is probably related to denom metadata issues?

@hdevalence
Copy link
Member Author

Added some debug statements:

2023-05-18T19:22:35.693161Z DEBUG penumbra_crypto::dex::lp::order: parsed sell order offered_unit=delegation_penumbravalid offered=Value { amount: 1234000000, asset_id: passet1tg55dqdtvwhcmfmr7jk0sjzaqfhxwxv6juhp6zlf74djdp34vczq7pwtn9 } price=Value { amount: 1000000, asset_id: passet1jg66mgvzdafh0v5dulhtj4p23a5xklw43zaarl6plyyv5vepxqrs5y79vh }
2023-05-18T19:22:35.693192Z DEBUG penumbra_crypto::dex::lp::order: computed desired amount price_amount=1000000 offered_amount=1234000000 offered_unit_amount=1 desired_amount=1234000000000000
2023-05-18T19:22:35.693197Z DEBUG penumbra_crypto::dex::lp::order: computed p and q p=1234000000000000 q=1234000000

Looks like the desired_amount is wrong.

@hdevalence
Copy link
Member Author

The offered_unit was truncated because of a bad regex, which discarded the validator ID part of the delegation token denom. The bad denom was not noticed because our asset registry silently invents new assets on unknown denoms; fixing that would have prevented the bug.

hdevalence added a commit that referenced this issue May 18, 2023
This causes #2579, in combination with our (bad) behavior of the asset registry
silently inventing new assets: the denom got truncated, and interpreted as a
new and unknown asset.
erwanor pushed a commit that referenced this issue May 19, 2023
This causes #2579, in combination with our (bad) behavior of the asset registry
silently inventing new assets: the denom got truncated, and interpreted as a
new and unknown asset.
@github-project-automation github-project-automation bot moved this to Testnet 53: Himalia in Testnets May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Testnet 53: Himalia
Development

No branches or pull requests

1 participant