Skip to content

Revert metarules#476

Merged
neavra merged 3 commits intomainfrom
471-recipes-static-metarules
Jan 27, 2026
Merged

Revert metarules#476
neavra merged 3 commits intomainfrom
471-recipes-static-metarules

Conversation

@neavra
Copy link
Contributor

@neavra neavra commented Jan 27, 2026

Summary by CodeRabbit

  • New Features

    • Add optional provider preference to specify provider order and optionally restrict to preferred providers.
  • Refactor

    • Routing and rule generation moved to a runtime multi-provider model for EVM, Bitcoin, and XRP swaps; multiple provider-specific rules are produced and aggregated with unified error handling when no routes exist.
  • Tests

    • Expanded tests to validate multi-provider rule generation and preference-driven ordering.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Walkthrough

Reworks swap routing to generate rules for all applicable providers at runtime (THORChain, MayaChain, 1inch) and centralizes Bitcoin swap rule construction. Adds a ProviderPreference API to influence provider ordering, threads it through quote/build paths, and updates tests to expect multi-provider rule outputs.

Changes

Cohort / File(s) Summary
Metarule core
metarule/metarule.go
Replaced route_preference branching with runtime multi-provider rule generation for EVM, Bitcoin, and XRP flows. Added createBitcoinSwapRule helper to build provider-specific Bitcoin swap rules (vault, asset patterns, amounts, recipients, memo). Unified error when no providers apply.
Metarule tests
metarule/metarule_test.go
Tests updated to expect multiple provider-specific rules (THORChain and MayaChain) for BITCOIN_SWAP and related flows; validate per-provider constraints (vault constants, asset short-forms, memos, parameter mappings).
SDK: swap types
sdk/swap/types.go
Added ProviderPreference type and Preference *ProviderPreference to QuoteRequest to allow specifying provider order and OnlyPreferred behavior.
SDK: router logic & tests
sdk/swap/router.go, sdk/swap/router_test.go
FindRoute and getOrderedProviders signatures now accept *ProviderPreference. Ordering logic honours Preference (including OnlyPreferred). Tests updated to pass nil where appropriate and to cover preference ordering and filtering.
SDK: adapter / service / public flow
sdk/swap/adapter.go, sdk/swap/service.go, sdk/swap/swap.go, sdk/swap/router.go
Threaded Preference through SwapInput, SwapParams, QuoteRequest, MakeTx/GetSwap/GetQuote/ValidateRoute/GetSwapTxBundle so routing/quotes honour provider preferences. Internal router calls now accept an additional preference argument (nil in unchanged callsites).
Consumer-visible fields
sdk/swap/adapter.go, sdk/swap/service.go, sdk/swap/types.go
New exported fields: SwapInput.Preference *ProviderPreference and SwapParams.Preference *ProviderPreference; new public type ProviderPreference. Review call sites for propagation or intentional nil use.
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Revert metarules' is misleading; the PR introduces multi-provider rule generation and provider preference configuration across multiple files, not a reversion. Change the title to accurately reflect the main change, such as 'Add multi-provider rule generation and provider preference support for swaps' or similar.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 471-recipes-static-metarules

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@neavra neavra marked this pull request as ready for review January 27, 2026 09:37
Copy link
Contributor

@4others 4others left a comment

Choose a reason for hiding this comment

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

LGTM

@neavra neavra merged commit 881fe53 into main Jan 27, 2026
3 checks passed
@neavra neavra deleted the 471-recipes-static-metarules branch January 27, 2026 14:58
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.

Recipes: use old approach to build always static meta rule -> direct rules with TryFormat, and move route_preference to swap sdk

2 participants