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

PERP-4088 | Display estimated shares amount to be bought #34

Merged
merged 2 commits into from
Sep 20, 2024

Conversation

lvn-alduin
Copy link
Contributor

@lvn-alduin lvn-alduin commented Sep 19, 2024

This uses the new shares precision implementation so this PR is daisy-chained onto PERP-4099.

The formula in the doc uses just two outcomes, but I tried to implement this for an arbitrary number of outcomes. The estimated amounts seem to be close to the actual amount received after a purchase, but they don't match exactly. Let me know if I missed something in the formulas.

Base automatically changed from perp-4099/shares-precision to main September 20, 2024 02:02
Copy link

cloudflare-workers-and-pages bot commented Sep 20, 2024

Deploying levana-predict with  Cloudflare Pages  Cloudflare Pages

Latest commit: 305754c
Status: ✅  Deploy successful!
Preview URL: https://4e53b1fa.levana-predict.pages.dev
Branch Preview URL: https://perp-4088-display-amount-of.levana-predict.pages.dev

View logs

Copy link
Contributor

@lvn-rusty-dragon lvn-rusty-dragon left a comment

Choose a reason for hiding this comment

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

Implementation looks right to me.

): Shares => {
const selectedPool =
market.possibleOutcomes.find((outcome) => outcome.id === selectedOutcome)
?.poolShares.units ?? BigNumber(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: I'd probably throw an exception if we can't find this outcome instead of returning 0.

@lvn-rusty-dragon lvn-rusty-dragon merged commit d977530 into main Sep 20, 2024
4 checks passed
@lvn-rusty-dragon lvn-rusty-dragon deleted the perp-4088/display-amount-of-shares branch September 20, 2024 02:07
@lvn-rusty-dragon
Copy link
Contributor

I figured out why the numbers don't match up, it's because of fees and the liquidity portion. I'll put together a PR.

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