-
Notifications
You must be signed in to change notification settings - Fork 0
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
Morpho Vault integration (p3) #68
Conversation
cwang25
commented
Aug 30, 2024
- Morpho Vault integration (earn flow)
… and update referneces
…o pass in complicated shares conversion amount, and also dropped risky changable receiver+owner address, so that client app can't forge iput of those fields to steal users' fund
… builder will only use repayAndwithdraw or supplyandBorrow, builder will never call inidividual supply/withdraw/repay...etc on its own, so trim those functions off to save cost. Also extend the ability to support repayMax and withdrawMax into function for both Morpho and MetaMorpho vault actions
be3d1b6
to
3961ebd
Compare
7da9452
to
2ab022c
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.
Overall, this looks straightforward enough, and the test coverage looks pretty good. I don't see any missing revert cases, that kind of thing. 👍
However, I don't entirely understand what the XXX
comments are about withdrawal checks that we don't implement. What are the "test that you have enough of the asset"-type comments about?
I brought up in a previous PR in this series that I think we should either (a) actually assert against the EIP712 data blobs or (b) drop the TODO
that says we should. I admit to not seeing a lot of value in these tests, but (as far as I can tell) the only thing preventing us from testing the EIP712 data is the tedium of copy/pasting the expected hashes and whatnot into the test-case, so we should either go ahead and do that... or decide not do it. We should not leave behind a lingering TODO.
As I look over this code, having just looked at #67, I am struck by how much repetition there is. I wonder if there is not a way to abstract over some of the duplicated code here? Maybe there is not, but it puts an itch in my brain that there are some 100s of lines of code that differ only in the tiniest ways that are copy-pasted between methods of QuarkBuilder.sol
. For example, there are code blocks in both PRs for // Validate generated actions for affordability
, and these code blocks are really similar-looking at first blush, and sort of long-winded and ugly. I wonder if the logic could be refactored into a helper.
Accounts.ChainAccounts[] memory chainAccountsList, | ||
PaymentInfo.Payment memory payment | ||
) external pure returns (BuilderResult memory) { | ||
// XXX confirm that you actually have the amount to withdraw |
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 this still a to-do?
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.
Yeah this is copied from the cometWithdraw builder, and since both are mostly the same, so I'm pretty sure if cometWithdraw still have this XXX
morpho will have the same as well.
From my understanding this is an optional feature that it's left undecided from the beginning from cometWithdraw.
Which we make builder to verify the input and revert if client ever pass in a larger amount to withdraw while user position doesn't have that much of asset in chainAccountList.
But also we don't really need to check, as client won't likely to send in a request to withdraw larger amount than user has. Plus client also provide the ChainAccountList, so if something very wrong in client causing client thinks user has more to withdraw than user has, it's likely client may also mess up the ChainAccountList as well which builder won't be able to catch either.
…resses set input in contract with Morpho system
…nto multiple scripts
…odate new fields for vault positions
31b32f7
to
28c3092
Compare
Yeah I figured repetition is a bit of pain, might need to major refactor and see if we can have a way to further modularize the builder. (Unfortunately solidity doesn't allow struct inheritances, so we have multiple structs with similar fields :( ). But I'm having some ideas of implementing some modularize functions to reduce those repetitions. Probably will be my next item after morpho integration if no one has picked that one up yet by then. |
Overall looks great. There does seem to be some weirdness with the action contexts that needs to be addressed. I also agree with Jordan that we should think more about modularizing the code. It is becoming difficult to review these changes because a lot of the logic is copy-and-paste with some small changes. It'll definitely give me a bit more confidence if the copy-and-paste logic can be shared so I know that the same code path is running for the different |
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.
Notes are addressed, and we've decided to commit to some refactoring of QuarkBuilder
as a follow-up while we integrate builder pack. So, Morpho should be unblocked! 👍