Composability is the ability of software components to be combined freely into new systems. In crypto it means that smart contracts and decentralised applications on a public blockchain can call each other, reuse each other's tokens and stack on top of one another without asking anyone's permission. A lending protocol can accept another protocol's token as collateral, and a trading app can route orders through several exchanges in a single transaction.
The idea is closely tied to decentralised finance (DeFi), where it is often described with the phrase "money legos". It depends on three features of public chains: shared state that every contract can read, open-source code, and common token standards such as ERC-20.
Composability in plain terms
Think of a set of plastic building bricks. Every brick, whoever made it, has the same studs on top and holes underneath, so any brick fits any other. You can build a house, take part of it and turn it into a car, or add someone else's wheels.
On a blockchain, each app is a brick with standard connectors. A token made by one team works in a wallet built by a second team and an exchange built by a third. Nobody needs to sign a partnership deal first. The benefit is that new products can be assembled quickly. The risk is that a cracked brick near the bottom can bring down everything built on it.
How composability works
On the Ethereum blockchain and similar networks, every contract lives in one shared environment, the Ethereum Virtual Machine (EVM), and can call any other contract's public functions. Three properties make that useful:
- Standard interfaces. Token standards define the same functions (transfer, balance, approve) for every token, so applications can handle tokens they have never seen before.
- Permissionless access. Any developer can call a deployed contract. There is no API key or contract to sign, unlike most APIs in traditional finance.
- Atomic execution. Several calls inside one transaction either all succeed or all revert, a property described in atomic. This "synchronous" composability lets a user borrow, swap and repay in one step.
Examples in DeFi
- Liquidity tokens as collateral. Depositing into a liquidity pool on an automated market maker such as Uniswap (UNI) returns a liquidity provider token, which other protocols can accept as collateral or stake for rewards.
- Stablecoins inside other protocols. Dai (DAI) is used across lending markets such as Compound (COMP), exchanges like Curve and many yield strategies.
- Liquid staking tokens. Tokens issued by staking services such as Lido are reused as collateral elsewhere, so the same staked ether earns staking rewards and backs a loan at the same time.
- Flash loans. Protocols such as Aave (AAVE) lend any amount without collateral, provided it is repaid within the same transaction. Users combine them with swaps and liquidations for flash loan arbitrage, as described in Flash Loans on Aave.
- Aggregators. Trading and yield aggregators split one order across many exchanges or move deposits between lending markets automatically.
Risks of composability
- Contagion. If one protocol fails, every protocol that holds its token or relies on its prices can be hit. Dependencies are often several layers deep and hard to see.
- Price manipulation. Attackers use flash loans to borrow large sums, move a thinly traded market, and exploit a protocol that reads that market as a price source. In February 2020 two attacks on the bZx lending platform used this pattern, and it has been repeated many times since. Robust oracles are the usual defence.
- Unexpected interactions. Contracts audited separately can behave badly together, for example through reentrancy, where one contract calls back into another before its state has been updated.
- Ordering attacks. Multi-step transactions visible in the mempool can be targeted by front-running.
Composability across chains and layers
Full synchronous composability exists only within one chain. Once applications are spread across Layer 2 rollups, separate chains or shards, calls between them become asynchronous: a message is sent and the answer arrives later, so an atomic borrow-swap-repay is no longer possible. This is a major trade-off in scaling design, and a reason for projects such as Optimism's Superchain and other attempts at blockchain interoperability to restore cross-chain composability.
The concept also matters outside crypto. Supporters of programmable money and tokenised bank deposits argue that standard, combinable building blocks could let financial products be assembled the way software is today, while regulators note that the same linkages make risks harder to contain.