Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
LABS
Guides

How to Plan Composable Pool Designs

A technical guide for developers on designing liquidity pools that are modular, upgradeable, and easily integrated with other DeFi protocols like lending markets and yield aggregators.
Chainscore © 2026
introduction
ARCHITECTURE

Introduction to Composable Pool Design

Learn how to design modular liquidity pools that can be assembled, upgraded, and integrated into broader DeFi systems.

Composable pool design is a software architecture pattern that treats liquidity pools as modular, interoperable building blocks. Instead of monolithic smart contracts that handle deposits, swaps, and rewards in a single, rigid system, composable designs separate these concerns into distinct, upgradeable components. This approach enables developers to create pools where the automated market maker (AMM) logic, fee structure, and reward mechanisms can be swapped independently. For example, a pool could use a constant product formula for its core AMM, a dynamic fee module that adjusts based on volatility, and a separate staking contract for liquidity provider (LP) incentives.

Planning a composable design starts with defining clear interfaces between components. The core interface is often the pool's vault or reservoir, which holds the underlying assets and manages LP token minting/burning. Separate modules then interact with this vault via standardized function calls. A swap module would call vault.swap() to execute trades, while a fee manager might call vault.collectFees(). This separation, inspired by the proxy pattern and diamond standard (EIP-2535), allows for gas-efficient upgrades and the creation of hybrid pools that combine the best features of different protocols, like Uniswap V3's concentrated liquidity with Balancer's weighted pools.

Effective planning requires mapping dependencies and data flow. Key considerations include: - How will price oracles be integrated? - Where are fees accrued and how are they distributed? - What are the admin controls for upgrading modules? A well-designed system minimizes trust assumptions by making modules stateless where possible and using time-locked multisig controls for upgrades. For developers, tools like Foundry and Hardhat are essential for testing interactions between mock modules before deployment. The goal is to create a system diagram where each component's inputs, outputs, and state changes are explicitly defined.

Real-world implementations demonstrate the power of this approach. Curve Finance employs a composable design with a base pool contract (StableSwap) that can be extended by gauge systems for rewards and vote-escrow mechanics for governance. Similarly, Balancer V2 separates asset management into a single vault, allowing multiple pool types (weighted, stable, etc.) to share custody and reduce gas costs. When planning your design, study these blueprints to understand how they manage re-entrancy guards, flash loan compatibility, and ERC-4626 tokenized vault standards for seamless integration with other DeFi primitives.

prerequisites
ARCHITECTURE

Prerequisites for Pool Design

Before writing a single line of code, a systematic approach to planning ensures your liquidity pool is secure, efficient, and composable. This guide outlines the foundational steps.

Effective pool design begins with a clear definition of its purpose. Are you building a stablecoin AMM like Curve, a concentrated liquidity pool like Uniswap V3, or a rebalancing index fund like Balancer? The core objective dictates the underlying mathematical model, fee structure, and required oracle support. For instance, a pool for volatile assets might use a constant product formula (x * y = k), while a stablecoin pool benefits from a StableSwap invariant that reduces slippage near parity. Documenting the target assets, expected trading volume, and primary user base is the first critical step.

Next, you must select the appropriate Automated Market Maker (AMM) invariant and fee model. This is a technical decision with direct implications for capital efficiency and impermanent loss. Key considerations include: the mathematical formula (e.g., constant product, constant sum, hybrid), the swap fee percentage (static or dynamic), and the protocol's fee distribution mechanism (to LPs, treasury, or ve-token holders). For advanced designs, evaluate if your pool requires oracle integrations for price feeds or external liquidity gauges for reward distribution, as seen in protocols like Curve and Balancer.

Security and composability are non-negotiable prerequisites. Your pool's smart contracts will interact with user funds and potentially other DeFi protocols. A thorough audit plan is essential. Furthermore, design for the Ethereum Virtual Machine (EVM) ecosystem by adhering to established interfaces like the ERC-20 standard for LP tokens and considering EIP-4626 for vault tokenization. This ensures your pool can be seamlessly integrated by wallets, aggregators (e.g., 1inch), and other yield protocols, maximizing its utility and adoption within the DeFi stack.

key-concepts-text
CORE CONCEPTS OF COMPOSABILITY

How to Plan Composable Pool Designs

A systematic approach to designing liquidity pools that can be seamlessly integrated and extended by other protocols.

Composable pool design begins with defining the interface—the set of functions and events that external contracts will call. This is your protocol's API. For an AMM pool, standard functions like swap, addLiquidity, and removeLiquidity are essential, but composability demands you also expose granular state data. Consider implementing ERC-4626 for yield-bearing vaults or the Uniswap V3 callback pattern for flash liquidity. The goal is to create a predictable, well-documented, and gas-efficient interface that other developers can rely on without needing to understand your pool's internal logic.

Next, architect for state isolation and permissionless extension. Your pool's core logic should be immutable and secure, but its functionality should be extendable. Use a proxy pattern or a modular system where new features (e.g., a new fee calculator or oracle) can be attached via approved hooks. The key is to separate the storage layer from the logic layer. This allows for upgrades and the attachment of peripheral contracts—like limit order modules or MEV protection—without risking the core liquidity. Always ensure that any extension cannot drain the pool or break its core invariants.

Finally, plan for integration pathways and incentive alignment. A composable pool isn't useful if integrators find it difficult to use. Provide clear examples: a code snippet for performing a swap from another contract, or a forge test demonstrating how to read pool reserves. Consider the economic incentives for third parties to build on your pool. This often involves designing a sustainable fee-sharing model or governance mechanism for ecosystem projects. Successful composable designs, like Balancer's Boosted Pools or Curve's gauge system, create a positive feedback loop where more integrations attract more liquidity, which in turn attracts more integrations.

design-considerations
COMPOSABLE POOL ARCHITECTURE

Key Design Considerations

Designing a composable pool requires balancing liquidity efficiency, security, and user experience. These core principles guide effective architecture.

01

Fee Structure & Incentive Alignment

A pool's fee model must align incentives between LPs, traders, and the protocol. Common structures include:

  • Fixed fees: A simple percentage (e.g., 0.3% on Uniswap V2).
  • Dynamic fees: Adjust based on volatility or pool utilization (e.g., Uniswap V4 hooks).
  • Protocol-owned liquidity: Fees accrue directly to a treasury for buybacks or staking rewards.

Consider fee tiers for different asset pairs and how fees compound with yield from external protocols.

02

Oracle Integration & Price Feeds

Secure, low-latency oracles are critical for lending, derivatives, and leveraged pools. Design choices include:

  • On-chain TWAPs: Use time-weighted average prices from DEX pools (e.g., Uniswap V3). Resilient to short-term manipulation but have latency.
  • Multi-source oracles: Aggregate data from Chainlink, Pyth, and API3. Provides robustness but increases gas costs.
  • Custom logic: Implement circuit breakers or staleness checks. For a lending pool, you might require two oracle confirmations before liquidating a position.
03

Composability with External Protocols

Pools should be designed as lego blocks for DeFi. Key integration points are:

  • Yield Sources: Automatically deposit idle liquidity into lending markets (Aave, Compound) or restaking protocols (EigenLayer).
  • Leverage: Enable flash loans for instant leverage from protocols like Aave or Balancer.
  • Account Abstraction: Use ERC-4337 for gas sponsorship or batch transactions from the pool contract.

Smart contract functions must be permissioned and have clear security boundaries for these interactions.

04

Liquidity Concentration & Capital Efficiency

Passive liquidity across all prices is capital inefficient. Modern designs use:

  • Concentrated Liquidity: Allow LPs to set custom price ranges (Uniswap V3). This can provide 100-1000x more capital efficiency for stable pairs.
  • Dynamic Ranges: Use oracles or volatility data to automatically adjust LP positions.
  • Just-in-Time Liquidity: Solvers or MEV bots can inject liquidity at block finalization, reducing LP impermanent loss.

These models require more complex math but significantly improve returns for active LPs.

05

Upgradeability & Governance

Pools need a strategy for future improvements without introducing centralization risks.

  • Transparent Proxies: Use OpenZeppelin's UUPS or Transparent Proxy patterns. UUPS is more gas-efficient as upgrade logic is in the implementation.
  • Timelocks: Implement a delay (e.g., 48 hours) for governance-executed upgrades, allowing users to exit.
  • Multisig vs. Token Governance: A 5/9 multisig is common for early-stage protocols. Mature protocols often transition to token-based voting (e.g., Compound Governor).
  • Emergency Functions: Include a guardian role with limited powers (e.g., pausing deposits) for critical vulnerabilities.
06

Gas Optimization & Batch Operations

High gas costs are a primary UX barrier. Optimize by:

  • Singleton Contracts: Deploy one factory that manages all pools (like Uniswap V3). Reduces deployment costs.
  • Multicall: Allow users to bundle swap, deposit, and stake actions into one transaction.
  • Storage Slots: Pack multiple boolean flags or small integers into a single storage slot.
  • View Functions: Off-chain aggregators rely on efficient view functions to calculate quotes; optimize these to prevent RPC timeouts.

Every 10,000 gas saved per swap can translate to significant savings at scale.

ARCHITECTURE

Composable Pool Type Comparison

Comparison of core architectural models for building composable liquidity pools, focusing on trade-offs for developers.

Feature / MetricSingleton Factory (Uniswap V3)Minimal Proxy (Balancer V2)Diamond Proxy (ERC-2535)

Deployment Gas Cost

~3.5M gas

~1.2M gas

~2.1M gas

Upgrade Mechanism

Factory migration required

Proxy admin upgrade

Diamond cut (facet swap)

Storage Layout

Immutable, fixed

Upgradeable, single contract

Modular, multi-facet

Pool Creation Gas

High (~2M gas)

Low (~300K gas)

Medium (~800K gas)

Protocol Fee Flexibility

Cross-Function Reentrancy Guard

Global for all pools

Per-pool

Per-facet or per-function

Implementation Code Size Limit

24KB (contract limit)

24KB (proxy target)

Unlimited via facets

Admin Complexity

Low (factory owner)

Medium (proxy admin)

High (diamond cut permissions)

fee-structure-planning
LIQUIDITY ENGINEERING

How to Plan Composable Pool Designs

Composable pools are modular liquidity primitives that can be assembled into complex DeFi strategies. This guide covers the core design principles for their fee structures and incentive mechanisms.

A composable pool is a liquidity primitive designed to be a building block within a larger system, such as a Balancer v2 pool used as a constituent vault in a Yearn strategy. Unlike standalone Automated Market Makers (AMMs), their design must account for external integrators and protocol-owned liquidity. The primary design goals shift from maximizing retail trader volume to ensuring capital efficiency for integrators and creating sustainable fee yield for the protocol treasury. This requires planning for two distinct user layers: the end-user interacting with the integrated product and the protocol building atop your pool.

Fee structures for composable pools must be multi-layered. The base layer consists of standard swap fees (e.g., 0.05% for a stable pool, 0.3% for a volatile pair), which are typically split between Liquidity Providers (LPs) and the protocol treasury. The critical addition is an integrator fee tier. This can be a fixed percentage of swap volume routed through a specific integrator's contract or a rebate on protocol fees. For example, a lending protocol using your pool as a collateral oracle could receive a 10 basis point rebate, aligning incentives for them to direct volume to your pool. Smart contracts must track fee accrual per integrator address.

Incentive planning focuses on bootstrapping and sustaining Total Value Locked (TVL). For composable pools, direct liquidity mining to end-users is often less effective than protocol-to-protocol incentives. Consider emitting your protocol's governance tokens to integrators based on the TVL they direct to your pools or the volume they generate. This creates a flywheel: integrators are rewarded for using your infrastructure, which increases its liquidity and reliability, attracting more integrators. Always vest incentives over time to ensure long-term alignment and prevent mercenary capital from destabilizing the pool's reserves.

Technical implementation requires careful smart contract architecture. Use a fee manager contract that separates fee logic from core pool math. This contract should handle fee distribution, integrator whitelisting, and rebate calculations. For Balancer-style pools, this integrates with the Protocol Fees Collector. A common pattern is to store accumulated fees in a separate vault, allowing for gas-efficient claiming by LPs and the treasury. Ensure your contracts emit clear events for all fee transactions to allow integrators and analytics dashboards to track performance transparently.

Finally, model your economics before deployment. Use historical data from similar pools to project swap volume, fee income, and token emission costs. A key metric is the protocol-owned liquidity yield, which is the annual fee revenue generated by the treasury's share, divided by the value of the protocol's owned LP positions. Aim for this yield to exceed the cost of capital (e.g., staking APY) to ensure the treasury grows. Tools like Token Terminal and Dune Analytics dashboards are essential for benchmarking and ongoing analysis. Iterate on your parameters based on real-world usage post-launch.

integration-patterns
POOL ARCHITECTURE

Common Integration Patterns

Explore foundational patterns for designing modular liquidity pools that can be composed into complex DeFi applications.

security-considerations
SECURITY AND RISK PLANNING

How to Plan Composable Pool Designs

A systematic guide to designing secure, efficient, and resilient liquidity pools by understanding and mitigating composability risks.

Composable pool design refers to creating liquidity pools that can safely interact with other smart contracts in a DeFi ecosystem. Unlike isolated pools, composable designs enable features like flash loans, yield aggregation, and cross-protocol strategies. However, this interconnectedness introduces significant attack vectors, including reentrancy, price oracle manipulation, and economic exploits. Planning must begin with a clear threat model that identifies all external dependencies and potential failure points. A well-planned design treats every external call as a potential risk and implements safeguards accordingly.

The first technical step is to define the pool's state machine and permission boundaries. Determine which functions are external/public versus internal/private. Critical state changes—like updating reserves or minting LP tokens—should be protected by reentrancy guards and access controls. Use the Checks-Effects-Interactions pattern rigorously: perform all checks, update internal state, and only then make external calls. For example, a composable staking pool should update user rewards before transferring tokens to an external yield optimizer to prevent reentrancy attacks.

Oracle integration is a common risk vector. Pools that rely on price feeds for functions like swaps or liquidations must use decentralized oracles (e.g., Chainlink) and implement circuit breakers. Design should include a maximum price deviation threshold between transactions and a time-weighted average price (TWAP) mechanism, as used by Uniswap V3, to mitigate flash loan attacks. Never use a pool's own spot price as the sole oracle for critical value calculations, as this creates a manipulatable feedback loop.

Economic security requires analyzing tokenomics and incentive alignment. For pools with governance tokens or reward emissions, model scenarios like "vote-locking" or "fee-on-transfer" tokens that can break assumptions. Implement a whitelist for approved token pairs if the pool accepts arbitrary ERC-20s, as malicious tokens with unusual transfer logic can cause failures. Consider adding a safetyCheck modifier that validates token balances before and after interactions to detect anomalies, logging them for review.

Finally, plan for upgradeability and emergency procedures. Use proxy patterns (like Transparent or UUPS) with clear, multi-signature admin controls. Include pause functions for critical operations and a timelock for governance actions. Document all assumptions and failure modes in the code via NatSpec comments. A robust plan is not just about preventing attacks but ensuring the system can be safely managed and recovered when unexpected behavior occurs, preserving user funds above all else.

COMPOSABLE POOLS

Frequently Asked Questions

Common technical questions and solutions for designing efficient, secure, and scalable composable liquidity pools.

A standard AMM pool, like a Uniswap V2 constant product pool, is a self-contained contract that holds two tokens and uses a fixed bonding curve (x*y=k). A composable pool is a modular design where the core logic is separated from the token vault and accounting. This enables features like:

  • Dynamic fee tiers that can be updated via governance.
  • Customizable oracles (e.g., Time-Weighted Average Price) that can be plugged in.
  • Permissioned liquidity providers or whitelisted swap functions.
  • Multi-hop swaps that execute atomically within a single transaction by composing with other pools in the same vault.

The key innovation is the separation of concerns, allowing the swap logic, asset management, and fee structure to be upgraded or composed independently.

conclusion
DESIGN PRINCIPLES

Conclusion and Next Steps

This guide has outlined the core concepts for designing composable liquidity pools. The next step is to apply these principles to a real-world implementation.

Effective composable pool design is an iterative process that balances capital efficiency with security and user experience. Start by clearly defining your pool's purpose: is it for a stablecoin swap, a volatile asset pair, or a more exotic yield-bearing token? Your answer dictates the core AMM curve, fee structure, and required hooks. For example, a pool for wstETH and wETH might implement a low-fee, concentrated liquidity curve with a hook to sync the pool's wstETH balance with the underlying staking rewards from Lido.

Before writing a line of code, map out the data flow and permission model. Identify which entities (e.g., users, keepers, governance) can trigger state changes and what those changes are. Use tools like Mermaid or draw.io to diagram the interaction between your pool's core logic, any external oracles (like Chainlink), and your custom hooks. This exercise often reveals potential reentrancy risks, front-running vulnerabilities, or gas inefficiencies in the proposed architecture.

For development, begin with a fork of a proven, audited codebase. The Uniswap v4 code repository and its associated hook examples are the definitive starting point. Implement your logic in a test environment first, using frameworks like Foundry or Hardhat. Write comprehensive tests that simulate edge cases: extreme price volatility, flash loan attacks, and the failure states of any integrated external service. A robust test suite is non-negotiable for composable systems.

Once your pool logic is tested, the focus shifts to deployment and monitoring. Deploy to a testnet (like Sepolia or Holesky) and conduct a bug bounty or a limited audit with a specialized firm. After mainnet launch, implement monitoring dashboards using services like Tenderly or Chainscore to track key metrics: pool TVL, fee accrual, hook execution success rate, and anomalous transaction patterns. Proactive monitoring is your first line of defense against exploits in a live environment.

The ecosystem for composable pools is rapidly evolving. To stay current, follow the development of new hook standards, audit reports from major protocols, and research on novel AMM mathematics. Engage with the community on forums like the Uniswap Governance forum and Ethereum Research. The most successful pool designs are those that are secure, serve a clear need, and can adapt to the next wave of DeFi innovation.

How to Plan Composable Pool Designs for DeFi | ChainScore Guides