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

fix: trade impact is including protocol fees for chainflip #8556

Merged
merged 5 commits into from
Jan 14, 2025

Conversation

NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Jan 13, 2025

Description

Chainflip price impact was wrong because amount out was excluding fees

I used a shortcut by calculating the inAmount with the rate chainflip send to us, so the price impact is nearer from the right one now

If you want to verify other price impacts, keep in mind that we do with what we have, some quotes provide great data to have an accurate price impact, some others are pretty hard to provide an accurate price impact and it's more an estimation than a precise price impact

For chainflip it's pretty close to the true now

Issue (if applicable)

closes #8514

Risk

Low

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Testing

  • Try a quote for chainflip (ETH for BTC for example)
  • Price impact should be around 1% instead of 12

Engineering

n/a

Operations

n/a

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

image

@NeOMakinG NeOMakinG changed the title [WIP] fix: trade impact is including protocol fees fix: trade impact is including protocol fees for chainflip Jan 14, 2025
@NeOMakinG NeOMakinG marked this pull request as ready for review January 14, 2025 10:28
@NeOMakinG NeOMakinG requested a review from a team as a code owner January 14, 2025 10:28
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

Math does look sane/r than before (i.e use the input/output fiat rate to calculate a pseudo amount before fees as a prorate of sorts) for smolish amounts, tested against develop (right):

image image image

Added some suggested changes re: dependency-injecting the fiat rate between sell/buy ourselves so we don't rely on upstream with market-data discrepancies which could cause issues in calculations (either being off at best, or having a negative number at worst), though happy to have that as a follow-up 🙏🏽

@NeOMakinG NeOMakinG enabled auto-merge (squash) January 14, 2025 14:15
@NeOMakinG NeOMakinG merged commit a26d13f into develop Jan 14, 2025
3 checks passed
@NeOMakinG NeOMakinG deleted the trade-price-impact branch January 14, 2025 14:22
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.

Trade price impact incorrect
2 participants