compound-protocol icon indicating copy to clipboard operation
compound-protocol copied to clipboard

Compound supply cap

Open bun919tw opened this issue 5 years ago • 3 comments

Implement supply cap mechanism.

  • Use internal cash for recording supply balance.
  • Add gulp function to absorb the excess cash into reserves.

Credits to @arr00 from Compound and Stanley from Cream.

bun919tw avatar Jan 20 '21 06:01 bun919tw

After using hardhat to test cToken upgrade, we found that putting internalCash in CErc20Storage will cause the storage collision. Although we put internalCash as the last variable in CErc20Storage. The order of the storage is CTokenStorage, CErc20Storage, and CDelegationStorage in CErc20Delegator.sol. Therefore, appending variables in CErc20Storage will still cause storage collision in the delegator.

bun919tw avatar Jan 20 '21 11:01 bun919tw

Thanks for looking into this @bun919tw. Good catch on the storage issue—I have addressed it in the branch where I wrote the original supply cap code. Additionally, I separated the supply cap code from CErc20, as I believe this is a path we are more likely to take. The default for a CErc20 will be one without internalCash for gas reasons, but riskier assets may adopt the new code. Take a look here to see the code I am referring.

arr00 avatar Jan 27 '21 06:01 arr00

Hi @arr00 , Thanks for the guideline. I've updated the implementation!

bun919tw avatar Jan 27 '21 11:01 bun919tw