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: Add XYK pool existence check before conversion (#1027) #1028

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Arsalaan-Alam
Copy link

Description

Added a check to verify if the XYK pool exists before performing conversion calculations in calculate_in_given_out. This prevents arithmetic errors and improves error handling with descriptive messages.

Related Issue

Fixes: #1027

Motivation and Context

This change ensures transactions do not fail due to missing XYK liquidity pools. Instead of encountering an arithmetic error, users will receive a clear DispatchError message indicating that the pool does not exist.

##How Has This Been Tested?

  • Built the runtime successfully using cargo build
  • Ran unit tests with cargo test --all
  • Verified transactions involving non-existent XYK pools return a proper error instead of failing with ArithmeticError::Overflow.

Checklist:

  • I have updated the documentation if necessary.
  • I have added tests to cover my changes, including regression tests for missing XYK pools.
  • This is a breaking change.

@Arsalaan-Alam Arsalaan-Alam changed the title Fix: Add XYK pool existence check before conversion (#1027) fix: Add XYK pool existence check before conversion (#1027) Feb 16, 2025
@dmoka
Copy link
Contributor

dmoka commented Feb 17, 2025

Nice, please also add an integration test to verify the change and document this behaviour.

And also don't forget to bump runtime version.

@Arsalaan-Alam
Copy link
Author

on it

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.

Bug: No xyk pool existence check
2 participants