Matador Docs
Integrations

Protocol Integration Comparison

Comparing permission strategies across Uniswap, Aave, and Euler.

Different protocols require different permission strategies. This guide compares the architectural considerations for integrating Matador with major DeFi protocols.

Comparison Matrix

FeatureUniswap V3Aave V3Euler Finance
Primary RiskSlippage & Recipient DiversionCollateral TheftShare Misattribution
Interaction TypeStateless (Swap)Stateful (Debt)Stateful (Vault Shares)
Critical Checksrecipient, amountOutMinimumonBehalfOf, healthFactorreceiver, amount
Oracle NeedHigh (for dynamic slippage)High (for health monitoring)Medium (for exposure caps)
ComplexityHigh (Nested Structs)Medium (Direct Args)Medium (Direct Args)

Strategy Deep Dive

Uniswap V3 (Stateless Execution)

Uniswap interactions are typically atomic. The risk is immediate: if a swap is executed with bad parameters, funds are lost instantly.

  • Focus: Strict validation of calldata arguments.
  • Challenge: The ExactInputSingleParams struct is deeply nested, requiring the interpreter to use CALLDATA_POINTER_RESOLVE.
  • Recommendation: Use enforceView to validate parameters off-chain before submission if gas is a concern, or use optimized policies that check the recipient first.

Aave V3 (State Management)

Aave positions persist over time. The risk is managing the health of the position.

  • Focus: Monitoring account state (healthFactor) before and after actions.
  • Challenge: Checking health requires an external staticcall, which costs gas.
  • Recommendation: Use the STATE_VARIABLE_CHECK opcode to verify health. For high-frequency bots, trust the bot's off-chain calculation for supplying (low risk), but enforce on-chain checks for borrowing (high risk).

Euler Finance (Modular Vaults)

Euler interactions involve minting/burning vault shares.

  • Focus: Ensuring shares are minted to the correct owner.
  • Challenge: Euler has many vaults (one per asset). Policies must be parameterized correctly for each vault address.
  • Recommendation: Use a parameterized policy template where the vault address is passed as a parameter, allowing you to reuse the same bytecode across different assets.

Universal Best Practices

  1. Self-Custody Invariant: Always enforce that the recipient, onBehalfOf, or receiver of any asset transfer is the smart account itself.
  2. Selector Whitelisting: Explicitly allow only the functions needed (e.g., swap, supply, deposit) and block everything else.
  3. Fail Fast: Order your policy checks so that the cheapest and most likely-to-fail conditions (like target check) run first.

Standardizing Policies

While protocols differ, the underlying pattern of Target Check -> Selector Check -> Argument Validation applies universally. Build your internal policy library around this structure.

On this page