Skip to content

The Need for DeFi Composability

The Challenge

In the world of DeFi development, one of the most common challenges developers face is building transactions that depend on the results of previous operations. This limitation has traditionally forced developers to write custom smart contracts for even relatively simple multi-step operations.

A Common Scenario

Consider what happens when a user wants to take their USDC tokens, swap them on Uniswap, and then deposit the received tokens into Aave. While this sounds straightforward, it presents a fundamental challenge: you don't know exactly how many tokens you'll receive from the swap until it happens. This uncertainty ripples through your entire transaction flow.

The Traditional Solution

Until now, developers had two options:

  1. Write a custom smart contract to handle the entire flow
  2. Split the operation into multiple transactions requiring user intervention

Neither solution is ideal. Custom contracts need auditing, are expensive to deploy, and create maintenance overhead. Multiple transactions lead to a poor user experience and higher gas costs.

Enter the Composability Stack

The composability stack solves this by allowing developers to create dynamic, multi-step transactions entirely from frontend code. Let's look at how this works in practice:

Note: The following is pseudocode to demonstrate the concept

transaction = {
  steps: [
    // Step 1: Swap tokens
    swap({
      from: "USDT",
      to: "USDC",
      amount: 1500,
      dex: "uniswap"
    }),
 
    // Step 2: Supply to Aave
    // Uses exactly what we received from the swap
    supplyToAave({
      token: "USDC",
      amount: executionTimeBalanceOf(USDC)
    })
  ]
}

Cross-Chain Complexity

The challenge becomes even more pronounced when working across different chains. Developers need to track values and states across different networks. Here's how the composability stack handles this:

Note: The following is pseudocode to demonstrate the concept

transaction = {
  steps: [
    // Bridge USDC from Arbitrum to Optimism
    bridgeTokens({
      from: "arbitrum",
      to: "optimism",
      token: "USDC",
      amount: 1000
    }),
 
    // Supply whatever we received after bridging to Aave
    supplyToAave({
      chain: "optimism",
      token: "USDC",
      amount: executionTimeBalanceOf(USDC)
    })
  ]
}

Beyond Simple Transfers

The power of this system extends far beyond simple token transfers. It enables complex DeFi operations like:

  • Multi-hop trades across different DEXs
  • Cross-chain yield farming strategies
  • NFT minting and marketplace listings
  • DAO treasury management
  • Automated portfolio rebalancing

Frontend-First Development

What makes this approach revolutionary is that it shifts complex transaction composition from smart contracts to frontend code. Instead of spending time writing and auditing custom contracts, developers can focus on building their application logic using familiar programming patterns.

This means:

  • Faster development cycles
  • Lower deployment costs
  • Reduced security risks
  • Better user experiences
  • More flexible application architectures

The composability stack handles all the complexity of parameter injection, state management, and cross-chain communication, while developers focus on building their applications.