Skip to content

Show Mev protection only for supported providers#9198

Merged
rafaelekol merged 2 commits into
version/0.49from
mev-protect-updated
May 13, 2026
Merged

Show Mev protection only for supported providers#9198
rafaelekol merged 2 commits into
version/0.49from
mev-protect-updated

Conversation

@rafaelekol
Copy link
Copy Markdown
Contributor

@rafaelekol rafaelekol commented May 13, 2026

#9184

Summary by CodeRabbit

  • Improvements
    • Enhanced swap flow to evaluate MEV protection eligibility dynamically based on the specific tokens and blockchain types in your swap.
    • Improved consistency of protection availability checks across all supported swap providers.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

MEV protection capability determination is refactored from a static provider property to a runtime token-pair-aware method. The interface introduces mevProtectionAllowed(tokenIn, tokenOut), concrete providers implement blockchain-compatibility checks, and the ViewModel updates its capability gating logic to use the new method.

Changes

MEV Protection Token-Pair Capability

Layer / File(s) Summary
Interface Contract: Token-Pair-Aware MEV Protection
app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/IMultiSwapProvider.kt
IMultiSwapProvider adds mevProtectionAllowed(tokenIn, tokenOut) with default false implementation and formalizes requireTerms and riskLevel as required properties.
Provider Implementations: Blockchain-Aware MEV Eligibility
app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/BaseUniswapV3Provider.kt, app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/AllBridgeProvider.kt, app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/OneInchProvider.kt
AllBridgeProvider, BaseUniswapV3Provider, and OneInchProvider each implement mevProtectionAllowed to check both tokens share the same EVM blockchain type, replacing unconditional supportsMevProtection flags.
ViewModel Integration: Token-Pair MEV Capability Gating
app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/SwapConfirmViewModel.kt
SwapConfirmViewModel updates MEV protection capability checks in two state initialization paths to call the token-pair-aware mevProtectionAllowed(tokenIn, tokenOut) method.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • abdrasulov
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: MEV protection visibility is now gated to only supported providers through token-aware checks rather than a blanket provider-level flag.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mev-protect-updated

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/OneInchProvider.kt (1)

43-44: ⚖️ Poor tradeoff

Consider extracting common MEV protection logic.

The same mevProtectionAllowed implementation appears in BaseUniswapV3Provider, AllBridgeProvider, and OneInchProvider. While this duplication may be intentional to allow future provider-specific customization, consider extracting it to a common extension function or base implementation if all providers will consistently use this logic.

🔧 Possible approach

In a common utilities file:

fun IMultiSwapProvider.defaultMevProtectionAllowed(tokenIn: Token, tokenOut: Token): Boolean =
    tokenIn.blockchainType == tokenOut.blockchainType && tokenIn.blockchainType.isEvm

Then in providers:

override fun mevProtectionAllowed(tokenIn: Token, tokenOut: Token): Boolean =
    defaultMevProtectionAllowed(tokenIn, tokenOut)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/OneInchProvider.kt`
around lines 43 - 44, Multiple providers (OneInchProvider,
BaseUniswapV3Provider, AllBridgeProvider) implement identical
mevProtectionAllowed logic; extract it into a shared function (e.g.,
defaultMevProtectionAllowed) and have each provider delegate to it to remove
duplication. Create the utility function with the same signature (accepting
tokenIn and tokenOut) in a common utilities file or on the IMultiSwapProvider
interface, and replace each provider's mevProtectionAllowed body to call that
shared function (keep function name mevProtectionAllowed in providers for API
stability).
app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/IMultiSwapProvider.kt (1)

24-24: ⚡ Quick win

Consider adding KDoc to explain MEV protection eligibility.

The mevProtectionAllowed method determines a critical security feature but lacks documentation. Future implementers would benefit from understanding that MEV protection should typically return true only for same-chain swaps on EVM blockchains.

📝 Proposed documentation
+    /**
+     * Determines whether MEV protection is available for the given token pair.
+     * Typically returns true only when both tokens are on the same EVM blockchain,
+     * as MEV protection is specific to EVM chains and requires same-chain swaps.
+     *
+     * `@param` tokenIn The input token
+     * `@param` tokenOut The output token
+     * `@return` true if MEV protection can be applied, false otherwise
+     */
     fun mevProtectionAllowed(tokenIn: Token, tokenOut: Token): Boolean = false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/IMultiSwapProvider.kt`
at line 24, Add a KDoc comment to the IMultiSwapProvider interface explaining
the purpose and expected behavior of mevProtectionAllowed(tokenIn: Token,
tokenOut: Token): Boolean — note that it indicates whether MEV protection should
be applied for a given swap, that implementations should generally return true
only for same-chain swaps on EVM-compatible chains, describe the parameters
(tokenIn and tokenOut) and that the return value true enables MEV protection
while false disables it; attach this documentation directly above the
mevProtectionAllowed declaration in IMultiSwapProvider.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/IMultiSwapProvider.kt`:
- Line 24: Add a KDoc comment to the IMultiSwapProvider interface explaining the
purpose and expected behavior of mevProtectionAllowed(tokenIn: Token, tokenOut:
Token): Boolean — note that it indicates whether MEV protection should be
applied for a given swap, that implementations should generally return true only
for same-chain swaps on EVM-compatible chains, describe the parameters (tokenIn
and tokenOut) and that the return value true enables MEV protection while false
disables it; attach this documentation directly above the mevProtectionAllowed
declaration in IMultiSwapProvider.

In
`@app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/OneInchProvider.kt`:
- Around line 43-44: Multiple providers (OneInchProvider, BaseUniswapV3Provider,
AllBridgeProvider) implement identical mevProtectionAllowed logic; extract it
into a shared function (e.g., defaultMevProtectionAllowed) and have each
provider delegate to it to remove duplication. Create the utility function with
the same signature (accepting tokenIn and tokenOut) in a common utilities file
or on the IMultiSwapProvider interface, and replace each provider's
mevProtectionAllowed body to call that shared function (keep function name
mevProtectionAllowed in providers for API stability).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9451ee55-fe26-43e1-95b1-f9c23d319ab3

📥 Commits

Reviewing files that changed from the base of the PR and between 33d8b4a and c435028.

📒 Files selected for processing (5)
  • app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/SwapConfirmViewModel.kt
  • app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/AllBridgeProvider.kt
  • app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/BaseUniswapV3Provider.kt
  • app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/IMultiSwapProvider.kt
  • app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/OneInchProvider.kt

@rafaelekol rafaelekol merged commit eeb0560 into version/0.49 May 13, 2026
2 checks passed
@rafaelekol rafaelekol deleted the mev-protect-updated branch May 13, 2026 06:33
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.

2 participants