Securityadvancedarticle30 min read

DeFi Integration Model: A Guide for Developers on Composability | VCC

DeFi integration models are reusable architectural approaches for combining multiple protocols into a single application. Each of the five main models — Adapter, Proxy, Strategy, Vault, and Oracle Adapter — addresses specific challenges in integrating with different balances of gas, complexity, and

Vietcardano teamTeam

Đội ngũ biên tập VietCardanoCommunity — các chuyên gia blockchain và Cardano, cung cấp nội dung giáo dục và nghiên cứu chuyên sâu cho cộng đồng.

Published September 14, 2026
Mục lục (54 mục)

DeFi integration models are reusable architectural approaches for combining multiple protocols into a single application. Each of the five main models — Adapter, Proxy, Strategy, Vault, and Oracle Adapter — addresses specific challenges in integrating with different balances of gas, complexity, and risk. Choosing the right model will determine whether your combined position is capital-efficient or a potentially damaging trap.

The Composability Spectrum — From Basic Principles to Strategies

The “Money Lego” concept remains a unique value of DeFi: composability without permission allows developers to stack protocols like building blocks. However, in 2024-2026, it’s important to understand the models, not just the protocols. The explosion of protocols – Uniswap V4 hooks, ERC-4626 implementations, EigenLayer AVS – means that every integration decision today is architecturally critical. A saying sums up the principle: every DeFi protocol you integrate increases your attack surface – models are your risk management framework.

Diagram - DeFi composability stack: base layer (EVM) → primitives (ERC20, AMM, lending) → composable

Diagram - DeFi composability stack: base layer (EVM) → primitives (ERC20, AMM, lending) → composable

Layer 0: EVM Execution environment

The call-based contracts via CALL, DELEGATECALL, and STATICCALL form the foundation. DELEGATECALL specifically supports proxy patterns – it executes code outside the caller’s memory context, a mechanism that lies behind the logic of upgradeable.

Level 1: Token standard

  • ERC-20: replaceable token database

Level 2: basic units

RoughMain protocolsCombined capability interface
AMMUniswap V3/V4, Curve, Balancerthe functions swap, mint, burn, and flash
Cho vayAave V3, Compound V3, Morpho Blue'supply', 'borrow', 'flashLoan', 'liquidationCall'
Cryptocurrencies are stableUSDC, DAI, LUSD, VNDCmint, redeem, oracle price data sources

Level 3: Protocols may be composed

The DEX aggregator (1inch, Paraswap, Matcha) operates through the basic units of Layer 2. Optimization tools (Yearn, Beefy, Sommelier) combine lending + AMM + strategy logic. Leverage protocols (Gearbox, Euler, Contango) combine lending + DEX + oracles for positions without fully collateralized assets.

Level 4: User Strategy

Leveraged yield, basis trade (spot + perp), delta neutral (LP + hedge), cross-chain arb (bridge + arb + bridge). Each strategy is a specific structure of the Layer 2-3 primitives.


Main integrated model classification

These five models form a decision framework. Start with the simplest model that solves your problem – each layer adds additional attack surface.

Flowchart - Core DeFi integration patterns: Adapter, Proxy, Strategy, Vault, Oracle Adapter, each wi

Flowchart - Core DeFi integration patterns: Adapter, Proxy, Strategy, Vault, Oracle Adapter, each wi

TemplateYou've solved the problem.Main MechanismAir CeilingComplexSurface inspection table
AdapterEnclosing the external interfaceThe Wrapper contract translates calls+20-50kLowOnly the Wrapper
Proxy (EIP-2535)Logic can be upgradedDiamond standard / flat pattern+50-100kHighBezel + diamond
Strategic (ERC-4626)Performance theory can be structuredStandardized storage interface and strategy+30-80kMiddle levelVault + Strategy
Vault (ERC-4626)Standardized accountingShare account, deposit/withdraw funds+40-90kMiddle levelVault contract
Oracle AdapterData outside the string on the stringAggregator + age check+100-200kHighOracle + adapter

Gas demand: Ethereum Q3 2024 mainnet. L2 (Arbitrum/Optimism) decreases by 80-90%. Data may vary depending on the complexity of the deployment.

Decision-making format: which sample do I need?

  1. Do you need to integrate an external protocol with a non-standard interface? → Adapter

Form 1 - Adapter: Surrounding external protocols

Diagram - Adapter pattern: Your Contract → Adapter Wrapper → External Protocol (Uniswap/Aave/Curve)

Diagram - Adapter pattern: Your Contract → Adapter Wrapper → External Protocol (Uniswap/Aave/Curve)

When to use

Use Uniswap V3/V4, Aave V3, Curve, or any protocol with a non-standard or version-dependent interface. The adapter converts your internal interface into their external one.

Perform

`solidity // Your internal interface interface IUniswapV3Adapter { function swapExactInputSingle( address tokenIn, address tokenOut, uint24 fee, uint256 amountIn, uint160 sqrtPriceLimitX96 ) external returns (uint256 amountOut); }

// Immutable wrapper - no upgradeability, minimal trust

constructor(address _router) { router = ISwapRouter(_router); }

function swapExactInputSingle(...) external override returns (uint256) {

Gas Optimization Techniques

  • Call by group via multicall: single transaction for multiple changes

Example: Yearn Adapter architecture

Yearn V3 uses adapters for Curve, Convex, Aave, Balancer, and Uniswap. Each adapter:

Risk Profile

RiskMinor reduction
Wrapper = the only point of failureSettings are non-editable; no administrative password
Interaction between upgrade capabilitiesInstall a new adapter; switch to the timelock management method
Interface discrepancyAutomated testing for mainnet forks in each protocol upgrade

Form 2 – Proxy (EIP-2535): Upgradeable Logic that can be structured

Diagram - Diamond proxy: Diamond (storage) → Facets (logic: Strategy, Risk, Oracle, Rewards) → Exter

Diagram - Diamond proxy: Diamond (storage) → Facets (logic: Strategy, Risk, Oracle, Rewards) → Exter

When to use

The strategy logic must be developed: yield optimization algorithms, risk parameters, reward distribution, oracle sources. The diamond convention distinguishes each logical domain into separate facets, sharing the same memory.

Diamond Common vs Simple Proxy

AspectIntelligent Proxy (OZ)EIP-2535 Diamond
Logical contractSingle deployment tasksMany aspects
Provide memoryShared (risk of collision)Provide diamond storage (with name)
Upgrade levelAll or nothingFrom the perspective of
CompatibilityThere are limitsNative — facets = module

Diamond Storage Model

// Each facet uses a unique storage namespace

// Facet reads/writes via assembly to specific slot

Deployments in the real world

  • Euler V2: Diamond for computer-based risk assessment, oracles, liquidation, and rewards for facets

Risk Profile

RiskMinor reduction
Attack vectors in administrationTimelock + multisig; defer facet upgrade
Facet upgrade timeAtomic's multi-dimensional improvement through 'diamondCut'
Memory layout errorTest automatic memory allocation; named frames
delegatecall reusability'nonReentrant' on all external facet functions

Form 3 – Strategy & Vault (ERC-4626): Product that can be tokenized

Diagram - ERC-4626 Vault + Strategy: User → Vault (shares) → Strategy (allocation) → Underlying Prot

Diagram - ERC-4626 Vault + Strategy: User → Vault (shares) → Strategy (allocation) → Underlying Prot

ERC-4626 is the Composability layer

The standards define: deposit, withdraw, mint, redeem, totalAssets, asset, decimals. This interface allows any vault to connect to any aggregator — Yearn, Beefy, 1inch, Paraswap all recognize ERC-4626 vaults.

Strategy Model: Separate concerns

Vault (ERC-4626) Strategy (Custom) ├── Share accounting ├── Allocation logic ├── Deposit/withdraw ├── Rebalance triggers ├── Fee collection ├── Risk checks └── Asset custody └── Protocol interactions

Multiple Strategy Vaults

A Allocator contract distributes vault assets across multiple strategies:

function rebalance() external { // 1. Withdraw from overallocated strategies // 2. Deposit into underallocated strategies // 3. Update allocation tracking // Gas: ~150-300k depending on strategy count }

Chemical gases

Each rebalance = call strategy + vault calculation. Number of units to amortize:


Form 4 - Oracle Adapter: Non-string data with minimum reliability

Diagram - Oracle Adapter: Price Feeds → Aggregator → Adapter (validation) → Consumer Contract

Diagram - Oracle Adapter: Price Feeds → Aggregator → Adapter (validation) → Consumer Contract

When to use

Any structure needs price, rate, or status from outside the EVM. Architecture: Aggregator (Chainlink/RedStone/Pyth) → Adapter (verifier) → User.

Adapter Tape tester

contract OracleAdapter { AggregatorV3Interface public immutable aggregator; uint256 public immutable heartbeat; // Max age (e.g., 3600s) uint256 public immutable deviationBps; // Max deviation (e.g., 100 bps) int256 public immutable minPrice; // Circuit breaker floor int256 public immutable maxPrice; // Circuit breaker ceiling

function getPrice() external view returns (int256) { (, int256 price, , uint256 updatedAt, ) = aggregator.latestRoundData();

// Staleness check

// Deviation check (requires previous price tracking)

return price;

Staleness Threshold: Heartbeat versus deviation

ApproachAdvantagesDisadvantagesUsed by
Heartbeat-basedSimple, predictableSlow to detect riskChainlink standard data sources
Guarantee based on deviationNotice sudden movementsRequest a price quoteRedStone, Pyth, custom adapters
Hybrid (both)The best of bothThere's more gasAave V3, Euler V2, Morpho Blue

Examples in practice

  • Aave V3 Price Oracle: Chainlink aggregator + backup selection check + error margin

Risk: Oracle Creates Condition = Liquidation Propagation Impact

A controlled source of supply in a position that is structured (e.g., a leveraged vault that uses an oracle to price the underlying asset) can result in:


Cross-sectional model of the protocols

These are the "menus" that developers actually build. Each menu combines multiple templates.

Diagram - Cross-protocol looping: deposit collateral → borrow stable → swap to collateral → redeposi

Diagram - Cross-protocol looping: deposit collateral → borrow stable → swap to collateral → redeposi

1. Leverage Yield

Model: Set collateral → Secure loan → Switch to collateral → Re-set collateral (recursive)

Mathematics:

  • Leverage efficiency ratio = 1 / (1 - LTV)

Risk: Level liquidation. Each loop has a compound gas cost. Optimal: 3-5 loops (increasing thereafter).

2. Basis Trade (Spot + Perpetual)

Model: Long point (asset being tokenized) + Short point (individual raising capital)

Works with: stETH + ETH perpetual, T-bill tokenized + future interest rate, VNDC + VND/USD forward

Math: Annual capitalization rate = (Funding Rate × 8760) / Position size

3. Delta Neutral

Model: LP position (Uniswap V3 focused) + Hedge (short or options)

Eliminate directional exposure; charge + capital. Risk: Residual impermanent loss, gamma risk, complexity of dynamic hedging

4. Cross-Chain Arbitrage

Pattern: Bridge → Arb on destination chain → Bridge back (compute atomically via callback)

Requirements: fast settlement, low bridge fees, MEV protection


Positional risk matrix

Two-axis model: Smart Contract Risk (state TERM_2__, code age, TERM_3__) × Oracle/Market Risk (diversity, volatility, fraud history).

Comparison - Risk matrix for composed DeFi positions: smart contract risk × oracle risk × liquidity

Comparison - Risk matrix for composed DeFi positions: smart contract risk × oracle risk × liquidity

QuadrantRisks of smart contractsOracle's risksExamplesAllocation guide
Q1: Basic ObjectsLow (audited, combat-tested, high TVL)Low (multiple data sources, low variability)Simple deposits from Aave, stable Uniswap V3, ERC-4626 vault (audited)Centralized liquidity – 60-80% of the DeFi portfolio
Q2: Depending on OracleLowGood (simple input, volatility, adjustment history)Repeat with leverage, financial arbitrage, bridges between chains + profitClose monitoring - 15-30%, price data alert
Q3: Risk of codeGood (un-audited, new, low TVL)LowUn-audited strategic keys, integration of new protocols, custom adaptersAudit Required - 5-15%, only after audit
Q4: Hazardous areaHighHighMax leverage on new protocol, cross-chain leveraged yield, synthetic + oracleExpert Only - <10%, by location size for total damage

Aggregate evaluation formula

Composite Score = (SC_Risk_Weight × SC_Score) + (Oracle_Risk_Weight × Oracle_Score) Weights: SC_Risk = 0.6, Oracle_Risk = 0.4 (code risk compounds faster) Thresholds: <30 = Q1, 30-50 = Q2, 50-70 = Q3, >70 = Q4

Diversification rule

There were never more than 10% of the portfolio in Q4. The positions created in Q4 had correlated failure modes – an oracle failure + a bug in the smart contract = total loss of capital.**


Vietnam context of the building tool – DeFi integrated in VN

Vietnamese builders face unique constraints and opportunities that affect their choice of integrated model.

VN DeFi Infrastructure Projects are Configurable

  • Kyber Network: KyberSwap aggregator + flexible groups (model adapter for multi-DEX routing)

Regulation: Decree 13/2023 on Sandbox

The sandbox regulations on fintech allow for the testing of DeFi protocols in a controlled manner. The implications are as follows: - Protocols that may be combined must undergo more rigorous scrutiny (the interactions of multiple protocols = complex risk) - KYC/AML must be performed at the limits of the combination process (ramp-up/tear-down of fiat currency) - Reporting obligations for monitoring traffic between protocols

Oracle's local needs

  • VND/USD feed: Important for VNDC, Vietnamese assets are tokenized, local lending market

Accessibility: Mobile-first, energy-optimized

  • 90%+ use mobile → UX must hide the complexity of the structure

Biography of a Talent

  • Strong foundation in EVM/Solidity (outsource history)

Decision Framework - Select your integration model

Flowchart - Decision framework: Upgrade need? → Proxy. External protocol? → Adapter. Yield product?

Flowchart - Decision framework: Upgrade need? → Proxy. External protocol? → Adapter. Yield product?

Checklist for selection

  1. Is there a need for an upgrade? → Proxy (EIP-2535 diamond for multi-facet; OZ Transparent for simplicity)

Change the gas cost model

NetworkIs a proxy feasible?Adapter costWarehouse costsRecommendation Statement
Ethereum MainnetRiyadh (~100k)Low (~30k)Average (~80k)Avoid using proxies; use immutable adapters
Arbitrum/OptimismYes (~10k)Very low (~3k)Low (~8k)Proxy diamond for logic can be upgraded
BSC/PolygonYes (~5k)Very low (~1k)Low (~5k)Proxies can be used; optimized for UX
TomoChainYes (<$0.01)Not significantNot significantAny model; developer's speed priority

The capabilities of the group determine the maximum level of complexity

  • No audit budget: only Adapter + Vault (non-configurable, default)

FAQ

1. What is the difference between the Adapter and Proxy models? An Adapter includes external calls (your interface → their interface); a Proxy allows for upgradable logic through shared memory of the facet. Adapter = translation layer; Proxy = development layer.

2. When should I use the ERC-4626 vault instead of a custom accounting? ERC-4626 provides composability – any aggregator recognizes it. Custom is only used when the standard doesn’t fit (e.g., non-swappable positions, complex fee structures).

3. What is the price of a flash loan arbitrage? ~300-500k on mainnet (2024); ~50-100k on Arbitrum/Optimism. Depends on the number of hops and the complexity of the DEX.

4. What is the biggest risk in DeFi positions? Smart contract risk compounds – a widespread issue across all integrated protocols. A bug in the Adapter + Oracle can lead to the loss of an entire position.

5. Can I create processes without writing Solidity? Yes — use Yearn/Beefy (ERC-4626 vaults) strategies, 1inch Fusion (aggregation of changes), or non-code tools like DeFi Saver (formula builder).

6. How do you audit a composed position? Audit each integration point + logic composition. Check: reentrancy (callback functions), access control (enhanced facets), oracle staleness (heartbeat/difference), enhanced security (storage collision).

7. What is the difference between Strategy and Vault in ERC-4626? Vault = accounting/tokenization (spending, sending, withdrawing); Strategy = allocation logic (where assets go, when to rebalance). They are separated for composability – one vault, multiple strategies.

8. How does EIP-2535 Diamond differ from OpenZeppelin Transparent Proxy? Diamond supports multiple memory-sharing logic contracts; Transparent Proxy = single deployment contract. Diamond allows for modular upgrades – upgrading the system without changing the logic of the oracle.


Refer and read more

Main sources

  • EIP-2535: Diamond Standard — https://eips.ethereum.org/EIPS/eip-2535

Refer to implementation

  • Yearn V3 Adapters - https://github.com/yearn/yearn-v3

Vietnam context

  • Decree 13/2023 Sandbox - https://thuvienphapluat.vn/van-ban/The-thao/Decree-13-2023-ND-CP-sandbox-fintech

* Last updated: 2026-09-02 | Author: 4+ years of experience in DeFi protocol development, contributing to the integration of Yearn/Euler/Morpho

Tags:

defi integration patternsdefi integration modelwhat is defi integration patternsdefi integration patterns guide