Add provider prioritization and sorter + OKX x Base#1002
Conversation
Introduce a PrioritizedProvider trait and a generic sort_by_priority_then_amount function in primitives::priority to centralize provider-priority-based sorting (with threshold override). Wire the new sorter into fiat client and swapper quote sorting, and implement PrioritizedProvider for FiatProvider and SwapProvider. Remove direct Cetus enum usages in favor of CetusAggregator where appropriate, add Base chain support for OKX in proxy provider, and export the new priority module from primitives. Includes unit tests for priority sorting and provider behavior.
Changed Files
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors and enhances how providers are prioritized and sorted across the application, particularly for fiat and swap quotes. By introducing a generic Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a robust and generic provider prioritization and sorting mechanism, which is a significant improvement for managing quote ordering in both fiat and swap functionalities. The new PrioritizedProvider trait and sort_by_priority_then_amount function centralize this logic, making the codebase more maintainable and extensible. The changes also correctly migrate from direct Cetus enum usages to CetusAggregator and add support for the Base chain to the OKX provider. However, there is a critical inconsistency identified in the SwapProvider's threshold_bps implementation and its corresponding unit tests that needs to be addressed.
Refactor primitives tests and provider threshold behavior. - crates/primitives/src/priority.rs: compacted the sort_by_priority_then_amount signature, replaced MockProvider::new with two helpers (mock_id and mock_id_priority) and updated tests to use them; adjusted mock defaults and minor comment style. - crates/primitives/src/swap_provider.rs: changed SwapProvider::threshold_bps() to return Some(200) (was 300) and updated tests to expect 200 for UniswapV3 and Okx. These changes simplify test provider construction and align the threshold BPS values used in tests with the new default.
Changes: