What is DeFi Composability and Why Does it Matter?

Composability
Matthew Hine
19th January 2021

We often talk about how mainstream DeFi needs a DLT platform that not only provides high scalability, but also doesn’t ruin composability (or more specifically “atomic composability”). Providing both limitless scalability and frictionless atomic composability at the same time is one of Radix’s biggest technology breakthroughs that is designed to work with our unique form of secure DeFi smart contracts.

The importance of scalability is pretty easy to understand; it’s the ability to handle more transactions and process them quickly and cheaply. But what exactly is composability and why is it so necessary for DeFi?

DeFi applications are often called “money Legos” – a direct reference to their composability. Each individual DeFi app “Lego brick” is a specific financial product or service that can be freely combined with others. A new DeFi app may combine many of these specific-purpose Lego-brick products and services into a more complex offering that is even more powerful or customized to specific user needs.

Importantly, these Legos are clicked together for each individual transaction, on the fly. This enables a level of flexibility and innovation that is unthinkable with traditional financial systems that are locked up behind the (fire)walls of banks.

In order to create a useful system of money Legos like this, the DeFi platform the apps run on needs two things:

  1. Standardization: DeFi apps need to be able to be connectable in a standardized and open way – just like Lego bricks need standard studs and holes so they can fit together in limitless configurations.
  2. Atomicity: DeFi apps need to be connectable instantly within a single transaction – just like Lego bricks need to all be in the same box and within reach of a builder to be freely put together as desired.

That’s DeFi composability. 

If a DeFi platform can’t frictionlessly deliver this kind of standardization and atomicity, it can’t provide the powerful composability that makes DeFi work and thrive. Without composability, it becomes just a place for apps to run separately as miniature walled gardens (kind of like the traditional finance system!). These apps may still be decentralized, but much of the transformative power and flexibility is lost.

To see how powerful composability is, here are some real-world examples from current DeFi applications:

Example 1: Decentralized Exchanges (see: Uniswap, Kyber)

“How does a lone exchange demonstrate composability” you might be thinking? We take it for granted, but tokens themselves are individual financial products; on Ethereum, for example, each token is a separate smart contract. Decentralized exchanges (whether order-book style like Kyber or AMM-style like Uniswap) work by composing trade transactions across multiple token smart contracts on demand.

This was made possible by Ethereum’s ERC-20 token standard, which many other platforms are also using as a template for their own implementations of tokens. But if token smart contracts live on separate side-chains or independent shards (as with some newer “scalable” platforms like Polkadot or Cosmos), atomicity is lost and suddenly true decentralized exchange becomes impossible.

Example 2: Automated Investment (see: Yearn)

Yearn highlighted a simple but highly valuable form of composability: automated investment across multiple other DeFi apps (like Compound, Aave, dYdX, and Curve) that provide various returns on staked tokens. The Yearn app uses the fact that it can instantly (atomically) check the current return on investment for these other apps through open interfaces, and automatically move its pool of investment to wherever it will be most profitable. From the user’s perspective, they can treat Yearn like a managed investment fund where they put in tokens and get returns without any further thought. But unlike in the traditional finance world, this “fund manager” is transparent, cheap, and responds instantly.

The result was that Yearn substantially kicked off the recent DeFi yield farming craze, as it significantly lowered the bar for users to get access to returns on their token holdings without the complexity of continuously comparing and moving tokens between different apps.

Once again, Yearn is only possible on a platform where it can instantly examine the other Lego bricks in the box and choose which one to plug in for each transaction – no composability, no Yearn.

Example 3: Flash Loans (see: Aave)

Flash loans are a concept invented in the DeFi world because it simply wasn’t possible before – and is a great example of atomic composability. Aave is a token lending platform. Normally borrowing means locking some collateral (in the form of other tokens) to get a loan. However Aave also provides a “flash loan” option where you can borrow tokens without collateral – as long as you return them in the same transaction (so there is no risk of default). You only pay a fee for the privilege.

What good is a loan that you take out and pay back within the same transaction? Composability makes it extremely useful. If multiple apps can be combined in a single transaction (atomically), then a loan can be used to conduct other business with those apps, as long as the end result produces (again atomically, within the same transaction) enough tokens to pay back the loan. 

The classic example is arbitrage. Say I notice that I can buy TokenA from Uniswap at a lower price than I can sell TokenA on Kyber. That’s an arbitrage opportunity – but normally I would be limited by the capital I have on hand to take advantage of it. With Aave, I can take out a loan (potentially a very large one), buy lots of TokenA on Uniswap, sell it all on Kyber, pay back the loan, and keep the resulting profit – all in a single transaction and without using any of my own capital!

Composability not only makes this possible, it makes it safe for all parties involved (assuming no smart contract bugs!) because either the whole set of transactions happens according to the rules set by each app, or none of it happens. For DeFi platforms that seek scalability by putting different applications on different side-chains or independent shards, this kind of complex all-in-one-step transaction is unthinkable.

Many new DLT platforms claim to provide high scalability, but only Radix has figured out how to do so without breaking the composability that make these applications possible – and that will enable the coming tidal wave of DeFi products and services that can take DeFi mainstream. To learn more about how Radix addresses the needs of mainstream DeFi, check out our DeFi whitepaper.