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
| Feature | Uniswap V3 | Aave V3 | Euler Finance |
|---|---|---|---|
| Primary Risk | Slippage & Recipient Diversion | Collateral Theft | Share Misattribution |
| Interaction Type | Stateless (Swap) | Stateful (Debt) | Stateful (Vault Shares) |
| Critical Checks | recipient, amountOutMinimum | onBehalfOf, healthFactor | receiver, amount |
| Oracle Need | High (for dynamic slippage) | High (for health monitoring) | Medium (for exposure caps) |
| Complexity | High (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
calldataarguments. - Challenge: The
ExactInputSingleParamsstruct is deeply nested, requiring the interpreter to useCALLDATA_POINTER_RESOLVE. - Recommendation: Use
enforceViewto validate parameters off-chain before submission if gas is a concern, or use optimized policies that check therecipientfirst.
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_CHECKopcode 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
vaultaddress is passed as a parameter, allowing you to reuse the same bytecode across different assets.
Universal Best Practices
- Self-Custody Invariant: Always enforce that the
recipient,onBehalfOf, orreceiverof any asset transfer is the smart account itself. - Selector Whitelisting: Explicitly allow only the functions needed (e.g.,
swap,supply,deposit) and block everything else. - Fail Fast: Order your policy checks so that the cheapest and most likely-to-fail conditions (like
targetcheck) 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.