-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feat/base 1 #12
Feat/base 1 #12
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.
Love the ideas. I added some comments too
@@ -0,0 +1,6 @@ | |||
// SPDX-License-Identifier: GNU AGPLv3 |
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.
should be accessible from lib
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.
Not sure what you mean. How can a lib cannot access this?
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.
from the imported library aave-core-v3
I mean
@@ -0,0 +1,76 @@ | |||
// SPDX-License-Identifier: GNU AGPLv3 |
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.
same
@@ -0,0 +1,19 @@ | |||
// SPDX-License-Identifier: UNLICENSED |
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 don't really get the usage of this file tbh
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.
This library is meant to aggregate the libraries we use in Morpho. This IMO is important in our case so that we are less likely to run into the issue of using two versions of the same library accidentally. It doesn't have to be this way, but I think this is one way we can softly enforce what libraries we use in our contracts.
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.
Ok we can go with it for now
dfe2958
to
64a999c
Compare
64a999c
to
47a2dbf
Compare
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'm globally ok with the changes :)
Note that I didn't check the in-depth logic, security, etc.
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 really like the internal-by-default pattern
I also like the library-based plug-in logic
There a lot of conventions introduced in this PR, which I am for or not against, but we shouldn't consider them set in stone as quick as this PR is merged because we (at least I) need to test how they behave
@@ -1,4 +1,6 @@ | |||
// SPDX-License-Identifier: UNLICENSED | |||
pragma solidity ^0.8.17; | |||
|
|||
library Errors {} | |||
library Errors { |
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.
This library will be used much like an enum and the common naming standard of enum is singular
This is obviously not mandatory
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.
Whatever works for you guys
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.
Do you mean having the library renamed to be a single letter? @Rubilmax
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.
Sorry, I should have been more specific. I had in mind to name it Error
instead of Errors
, to use it like revert Error.MarketNotCreated()
|
||
library Events {} | ||
library Events { |
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.
This library will be used much like an enum and the common naming standard of enum is singular
This is obviously not mandatory
uint256 p2pSupplyIndex; // 256 bits | ||
uint256 p2pBorrowIndex; // 256 bits | ||
BorrowMask borrowMask; // 256 bits | ||
Delta deltas; // 1024 bits | ||
uint32 lastUpdateTimestamp; // 32 bits | ||
uint112 poolSupplyIndex; // 112 bits | ||
uint112 poolBorrowIndex; // 112 bits | ||
address underlying; // 168 bits | ||
address variableDebtToken; // 168 bits | ||
uint16 reserveFactor; // 16 bits | ||
uint16 p2pIndexCursor; // 16 bits | ||
PauseStatuses pauseStatuses; // 64 bits |
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.
Could we count in bytes? 😁
EDIT: Actually I don't know if it's a good idea
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.
Bytes seems okay as this is the minimal unit of each variable, but I prefer bits since it requires no translation between something like uint256 to bytes.
src/libraries/MarketMaskLib.sol
Outdated
function setSupplying(Types.UserMarkets memory userMarkets, Types.BorrowMask memory borrowMask, bool supplying) | ||
internal | ||
pure | ||
returns (Types.UserMarkets memory newUserMarket) |
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.
Could we modify the input struct and return it? Or is it bad software design?
src/libraries/Types.sol
Outdated
ThreeHeapOrdering.HeapArray suppliersP2P; // in scaled unit | ||
ThreeHeapOrdering.HeapArray suppliersPool; // in scaled unit | ||
ThreeHeapOrdering.HeapArray borrowersP2P; // in scaled unit | ||
ThreeHeapOrdering.HeapArray borrowersPool; // in scaled unit |
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.
ThreeHeapOrdering.HeapArray suppliersP2P; // in scaled unit | |
ThreeHeapOrdering.HeapArray suppliersPool; // in scaled unit | |
ThreeHeapOrdering.HeapArray borrowersP2P; // in scaled unit | |
ThreeHeapOrdering.HeapArray borrowersPool; // in scaled unit | |
ThreeHeapOrdering.HeapArray p2pSuppliers; // in scaled unit | |
ThreeHeapOrdering.HeapArray poolSuppliers; // in scaled unit | |
ThreeHeapOrdering.HeapArray p2pBorrowers; // in scaled unit | |
ThreeHeapOrdering.HeapArray poolBorrowers; // in scaled unit |
struct AssetLiquidityData { | ||
uint256 decimals; // The number of decimals of the underlying token. | ||
uint256 tokenUnit; // The token unit considering its decimals. | ||
uint256 liquidationThreshold; // The liquidation threshold applied on this token (in basis point). | ||
uint256 ltv; // The LTV applied on this token (in basis point). | ||
uint256 underlyingPrice; // The price of the token (In base currency in wad). | ||
} | ||
|
||
struct LiquidityData { | ||
uint256 collateral; // The collateral value (In base currency in wad). | ||
uint256 maxDebt; // The max debt value (In base currency in wad). | ||
uint256 liquidationThresholdValue; // The liquidation threshold value (In base currency in wad). | ||
uint256 debt; // The debt value (In base currency in wad). | ||
} |
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.
These could be updated to match branch upgrade-morpho-1
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.
Hmm remember we're dealing with Aave V3. So we first need to make sure that it's using the same units
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.
And it depends on the network lol... So value
may be the best keyword in this case (in place of Usd
or Eth
). Any better proposal?
struct UserMarkets { | ||
bytes32 data; | ||
} | ||
|
||
struct BorrowMask { | ||
bytes32 data; | ||
} |
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.
Why wrap these inside structs?
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 believe that the UserMarkets and BorrowMask should be treated as strongly typed, similar to what aave does. This should prevent any developer mistakes when working with these variables (including us)
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.
Note that we might come back to the way we're handling it with Morpho-Compound (namely keeping the list of user's entered markets)
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.
Approving this to merge, but keeping conversations unresolved for future reference
A proposed initial layout of the contract structure.