Skip to content
Pools DAI, converts it into Compound DAI, and sends interests to a beneficiary. Users putting DAI into the pool receives Pooled cDAI (pcDAI), an ERC20 token which is 1-for-1 redeemable for DAI at any time.
JavaScript
Branch: master
Clone or download
ZeframLou Merge pull request #8 from ZeframLou/add-kyber
Added Kyber Network extension
Latest commit 107d422 Aug 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
contracts refactored inheritance to extension Aug 8, 2019
migrations added deployment script for PooledCDAIFactory Aug 5, 2019
.gitignore initial commit Jul 25, 2019
LICENSE Create LICENSE Jul 25, 2019
README.md updated README Aug 8, 2019
package-lock.json initial commit Jul 25, 2019
package.json updated license in package.json Jul 25, 2019
truffle-config.js initial commit Jul 25, 2019

README.md

Pooled cDAI (pcDAI)

Pools DAI, converts it into Compound DAI (cDAI), and sends interests to a beneficiary. Users putting DAI into the pool receives Pooled cDAI (pcDAI), an ERC20 token which is 1-for-1 redeemable for DAI at any time.

How it works

Compound accrues interest to cDAI by increasing exchangeRate, the amount of DAI you can redeem per cDAI. Therefore, you can calculate the current DAI value of the pool's cDAI using exchangeRate * poolCDAIBalance. To calculate the interest, simply subtract the total DAI deposited from that value: exchangeRate * poolCDAIBalance - totalDAIDeposited. pcDAI records the total deposit using totalSupply, since pcDAI is 1-for-1 redeemable for DAI.

Since DAI deposits & withdrawals add/subtract the same amount from both sides of the minus sign, they don't affect the interest calculation, so there's no need for lock periods.

How to compile

npm install
truffle compile

Technical details

Roles

  • Beneficiary: the account that receives the interest
  • Owner: the account that can change the beneficiary, default is the creator of the pcDAI smart contract
  • User: accounts that can deposit into/withdraw from the pool (all accounts)

Creation

Call this function in PooledCDAIFactory

function createPCDAI(string memory name, string memory symbol, address _beneficiary, bool renounceOwnership) public returns (PooledCDAI)

Usage

User actions

  • function mint(address to, uint256 amount) public returns (bool)

Deposit amount DAI into pool, send minted pcDAI to to

  • function burn(address to, uint256 amount) public returns (bool)

Burn amount pcDAI, send redeemed DAI to to

  • function withdrawInterestInDAI() public returns (bool)

Withdraw accrued interest to beneficiary in DAI

  • function withdrawInterestInCDAI() public returns (bool)

Withdraw accrued interest to beneficiary in cDAI

Owner actions

  • function setBeneficiary(address newBeneficiary) public onlyOwner returns (bool)

Change the beneficiary to newBeneficiary

Helpers

  • function accruedInterestCurrent() public returns (uint256)

Calculates the current accrued interest. It's not a view function, since it updates the exchangeRate of cDAI.

  • function accruedInterestStored() public view returns (uint256)

Calculates the current accrued interest. It's a view function, but it uses the cDAI exchange rate at the last call to the cDAI smart contract, so it might not be up to date.

Extensions

Extensions are smart contracts that extend the features of Pooled cDAI.

Kyber Network

  • Location: contracts/extensions/PooledCDAIKyberExtension.sol
  • Description: Enables minting & burning pcDAI using ETH & ERC20 tokens supported by Kyber Network, rather than just DAI. There's no need to deploy one for each pool, since it uses pcDAI as a black box.
You can’t perform that action at this time.