Skip to content

feat: swap aborted event#6044

Merged
j4m1ef0rd merged 3 commits intomainfrom
feat/swap-aborted-event
Aug 25, 2025
Merged

feat: swap aborted event#6044
j4m1ef0rd merged 3 commits intomainfrom
feat/swap-aborted-event

Conversation

@j4m1ef0rd
Copy link
Contributor

@j4m1ef0rd j4m1ef0rd commented Aug 13, 2025

Pull Request

Closes: PRO-2453

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have written sufficient tests.
  • I have updated documentation where appropriate.

Summary

  • Changed the new swap canceled event to SwapAborted.
  • Emit the SwapAborted event both when a swap is canceled and when a swap fails.
  • Added a new enum SwapFailedReason
  • put the new reason enum in swap aborted event and swap rescheduled event.

@j4m1ef0rd j4m1ef0rd requested a review from zoheb391 August 13, 2025 04:57
@j4m1ef0rd j4m1ef0rd self-assigned this Aug 13, 2025
@j4m1ef0rd j4m1ef0rd requested a review from msgmaxim as a code owner August 13, 2025 04:57
@coderabbitai
Copy link

coderabbitai bot commented Aug 13, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/swap-aborted-event

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 92.07921% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
state-chain/pallets/cf-swapping/src/lib.rs 91% 7 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@j4m1ef0rd j4m1ef0rd marked this pull request as draft August 14, 2025 06:23
@j4m1ef0rd j4m1ef0rd force-pushed the feat/swap-aborted-event branch from 1f0dea4 to 9b3fcd3 Compare August 19, 2025 06:05
@j4m1ef0rd j4m1ef0rd marked this pull request as ready for review August 19, 2025 06:05
@j4m1ef0rd j4m1ef0rd requested a review from dandanlen as a code owner August 19, 2025 06:05
@j4m1ef0rd j4m1ef0rd requested a review from msgmaxim August 19, 2025 06:05
MAX_BASIS_POINTS,
);
// Use the oracle price to calculate the minimum output needed
let output_amount = output_amount_floor(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could rename this to min_output_amount as below?


#[derive(Debug, Decode, TypeInfo, Clone, PartialEq, Eq, Encode)]
pub enum SwapFailureReason {
// Batch swap failed due to price impact limit,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: why not /// doc comments ?

further nit: punctuation is a little weird/inconsistent... trailing comma makes the comments look incomplete.

Comment on lines +1695 to +1698
(None, _) | (_, None) => {
// Ignore the oracle price check if not supported/available
// for one of the assets.
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we allow oracle swaps for assets where the prices aren't available? ie. is it possible to submit an oracle swap for FLIP -> DOT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, This was one of the points I listed in #6039 to ask you about. I want to block swap requests that use the oracle without support. But was going to do it in another PR. Shall I create an issue?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes I think we should do this. PRO-2482.

@dandanlen dandanlen added this pull request to the merge queue Aug 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 21, 2025
@j4m1ef0rd j4m1ef0rd added this pull request to the merge queue Aug 25, 2025
Merged via the queue into main with commit 98bfafd Aug 25, 2025
54 checks passed
@j4m1ef0rd j4m1ef0rd deleted the feat/swap-aborted-event branch August 25, 2025 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants