-
Notifications
You must be signed in to change notification settings - Fork 50
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
Storage Refactor #269
Storage Refactor #269
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insightful because you can see how many lines of code and changes required to go from basic solidity to OOP
src/libraries/MarketLib.sol
Outdated
|
||
struct MarketState { | ||
uint128 totalSupply; // Market total supply. | ||
uint128 totalSupplyShares; // Market total supply shares. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the constraint of having shares as uint128
realistic? For a 18 decimals token, they are expected to have 36 decimals while 2^128 ~= 1e38
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me and @Jean-Grimal have discussed this a bit. We believe that it may be necessary to decrease the number of virtual shares to allow for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely think that this kind of refactoring is needed. However, I'm not completely satisfied with how it has been implemented here. Imo, MarketLib
could be utilized to abstract away even more complexity from the main contract and further reduce the number of sloads. Also, I think that MarketLib
currently contains way too many little functions. Still considering how it could be improved...
I agree with you, and don't think this should be the end of all refactoring. I am open to suggestions on how to improve things, but I would prefer that any additional changes come with new PRs as long as the current PR is an improvement and does not block further refactoring. |
struct UserBalances { | ||
uint128 borrowShares; // User' borrow balances. | ||
uint128 collateral; // User' collateral balance. | ||
uint128 supplyShares; // User' supply balances. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint128 supplyShares; // User' supply balances. | |
uint256 supplyShares; // User' supply balances. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with this since I find it problematic to use different storage types for the same type of variable. Is it possible that this particular point be isolated to another PR with its own scope of discussion?
Made an issue for it #309
When testing I realized that using |
Fixes #46
To be merged after #283