Pool Full of cDAI

Eva Beylin
The Graph
Published in
4 min readSep 20, 2019

“I got a swimming pool full of cDAI and they dive in it
Pool full of cDAI I’mma dive in it”
— Kendrick Lamar

Pooled cDAI

In the wake of Compound Finance deploying their v2 contracts, the DeFi ecosystem has become increasingly more interesting, with new ways of investing capital and unique interest-bearing opportunities. One of the most exciting implementations is Pooled cDAI, built by Betoken Fund co-founder Zefram Lou.

Pooled cDAI is built on MakerDAO, Compound, Kyber Network, Blocknative and The Graph. Although this dApp is specifically for DAI-based tokens, users can launch a Kyber Extension — PooledCDAIKyberExtension.sol to pool Ether and over 70 other tokens that are available on Kyber Network. Currently there are 17 DAI pools deployed on mainnet with over 4K DAI pooled in aggregate.

When assets are deposited or withdrawn from Compound, cTokens or synthetic tokens representing the underlying asset are minted and burned. These tokens can redeem the underlying asset, can be used as collateral or transferred to other users. Note: cTokens are not transferable if the asset is currently being borrowed.

Users can pool their DAI, convert DAI into cDAI (Compound’s synthetic DAI token) and share the accrued interest with other users or projects. Pooled cDAI seamlessly lends DAI on Compound and routes the interest to a specified beneficiary.

The use cases for Pooled cDAI are endless! Aside from savings accounts and charitable donations, we can think of other everyday scenarios that benefit non-crypto users. Examples of how Pooled cDAI can be used:

  • Pensions — pension providers like Akropolis can allow users to accumulate their pensions in Ethereum-based assets and earn interest on the funds
  • Insurance — insurance providers like Nexus Mutual can pool the capital deposited as coverage and earn interest as a revenue stream, create additional insurance for covered contracts or reduce the cost of premiums by subtracting earned interest
  • Fantasy Sports — when starting a fantasy draft, users pool their funds and hold them until the season ends and a winner withdraws the reward. In the back-end of fantasy sports platforms, users can earn interest on their pooled assets while they play their make-believe athletics!

What other reasons do we pool funds today?

Pooled cDAI Subgraph

Pooled cDAI was built on The Graph as subgraphs are an efficient way of pulling data in real-time from the Ethereum blockchain and displaying it on a web UI like https://zeframlou.github.io/pool-dai/. Check out the subgraph here!

For simplicity, instead of integrating the existing Compound subgraph that is complex and indexes more data than is needed, the subgraph pulls from the PooledCDAI.sol contract that listens to events for minting and burning cDAI and withdrawing interest from Compound’s Comptroller and cDAI contracts and Maker’s DAI contract. The Pooled cDAI subgraph also watches MetadataPooledCDAIFactory.sol and PooledCDAIFactory.sol contracts.

Here’s an example query looking for all deployed DAI pools, ordered by the total pool supply in descending order. The total interest withdrawn has also been queried — meaning the total contribution a pool has made to a particular cause. We can also request information on the beneficiaries, pool owners and timestamps (or how long the pools have existed).

As more pools launch, we can use the subgraph to better understand which causes are most popular and analyze the financial impact. For example, a pool was created for GiveDirectly, a non-profit focused on providing cash transfers to families in poverty in East Africa.

Use The Graph today!

If you’re looking to query Ethereum to create a UI that tracks DeFi or to conduct analysis on Ethereum data, query the subgraphs that are live today. Deployed subgraphs include Uniswap, Compound, Synthetix, MakerDAO, MolochDAO and many more!

Or if you’d like to simplify your app’s data indexing, deploy your own subgraph. Check out The Graph docs to learn how you can run a graph node, create a subgraph and query other subgraphs.

You can also join the Discord channel to chat about launching a subgraph and join The Graph community.

Follow The Graph on Twitter

Join us on Discord

--

--