Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compound supply cap #95

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bun919tw
Copy link

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.

* Add supply cap check to mintAllowed.
* Use internal cash for getCashPrior.
* Add gulp to absorb excess cash into reserves.
@bun919tw
Copy link
Author

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.

@arr00
Copy link
Contributor

arr00 commented Jan 27, 2021

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.

@bun919tw
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants