Compound supply cap
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.
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.
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.
Hi @arr00 , Thanks for the guideline. I've updated the implementation!