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

Added a Morpho Blue integration #1094

Merged
merged 67 commits into from
Jul 18, 2024
Merged

Conversation

jalextowle
Copy link
Contributor

@jalextowle jalextowle commented Jul 12, 2024

Resolved Issues

Fixes: #1099.

Description

This PR adds a Morpho Blue integration. This was a relatively straightforward integration, but there were a few interesting quirks that are worth noting:

  • In order to calculate the base and vault shares conversions, we need to make use of MorphoBalancesLib. This adds a good amount of bytecode to our integrations, so I needed to make our MorphoBlueConversions library external.
  • Morpho Blue's virtual share accounting means that totalSupplyShares is ~1 million times smaller than totalSupplyAssets, so the Morpho Blue vault share price is ~1e12. This results in the napkin math assertions in InstanceTest that multiply and divide by the vault share price to convert from base to vault shares having large tolerances (1e15). This was somewhat concerning, so I added several additional tests and assertions to verify that our precision isn't negatively effected by the small vault share price. After some significant testing, it seems that the fix for [CRASH REPORT] fuzz invariant -- close long after maturity result is not as expected #697 is working like a charm.

Review Checklists

Please check each item before approving the pull request. While going
through the checklist, it is recommended to leave comments on items that are
referenced in the checklist to make sure that they are reviewed. If there are
multiple reviewers, copy the checklists into sections titled ## [Reviewer Name].
If the PR doesn't touch Solidity, the corresponding checklist can
be removed.

[[Reviewer Name]]

  • Tokens
    • Do all approve calls use forceApprove?
    • Do all transfer calls use safeTransfer?
    • Do all transferFrom calls use msg.sender as the from address?
      • If not, is the function access restricted to prevent unauthorized
        token spend?
  • Low-level calls (call, delegatecall, staticcall, transfer, send)
    • Is the returned success boolean checked to handle failed calls?
    • If using delegatecall, are there strict access controls on the
      addresses that can be called? It shouldn't be possible to delegatecall
      arbitrary addresses, so the list of possible targets should either be
      immutable or tightly controlled by an admin.
  • Reentrancy
    • Are functions that make external calls or transfer ether marked as nonReentrant?
      • If not, is there documentation that explains why reentrancy is
        not a concern or how it's mitigated?
  • Gas Optimizations
    • Is the logic as simple as possible?
    • Are the storage values that are used repeatedly cached in stack or
      memory variables?
    • If loops are used, are there guards in place to avoid out-of-gas
      issues?
  • Visibility
    • Are all payable functions restricted to avoid stuck ether?
  • Math
    • Is all of the arithmetic checked or guarded by if-statements that will
      catch underflows?
    • If Safe functions are altered, are potential underflows and
      overflows caught so that a failure flag can be thrown?
    • Are all of the rounding directions clearly documented?
  • Testing
    • Are there new or updated unit or integration tests?
    • Do the tests cover the happy paths?
    • Do the tests cover the unhappy paths?
    • Are there an adequate number of fuzz tests to ensure that we are
      covering the full input space?

Base automatically changed from jalextowle/integration/aave to main July 15, 2024 11:23
@coveralls
Copy link
Collaborator

coveralls commented Jul 15, 2024

Pull Request Test Coverage Report for Build 9990193146

Details

  • 58 of 76 (76.32%) changed or added relevant lines in 11 files are covered.
  • 3 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.5%) to 91.602%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contracts/src/instances/morpho-blue/MorphoBlueConversions.sol 7 8 87.5%
contracts/src/instances/morpho-blue/MorphoBlueBase.sol 18 22 81.82%
contracts/src/instances/morpho-blue/MorphoBlueTarget0.sol 1 6 16.67%
contracts/src/deployers/morpho-blue/MorphoBlueHyperdriveDeployerCoordinator.sol 18 26 69.23%
Files with Coverage Reduction New Missed Lines %
contracts/src/deployers/ezeth/EzETHHyperdriveDeployerCoordinator.sol 1 56.0%
contracts/src/deployers/lseth/LsETHHyperdriveDeployerCoordinator.sol 1 60.0%
contracts/src/deployers/reth/RETHHyperdriveDeployerCoordinator.sol 1 60.0%
Totals Coverage Status
Change from base Build 9978133834: -0.5%
Covered Lines: 2138
Relevant Lines: 2334

💛 - Coveralls

Copy link
Contributor

@mcclurejt mcclurejt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, comments aren't blocking

@cashd
Copy link
Contributor

cashd commented Jul 17, 2024

lgtm! thanks for this 🙏

@jalextowle jalextowle force-pushed the jalextowle/integration/morpho-blue branch from e2d415f to 28110b3 Compare July 18, 2024 10:52
Copy link
Contributor

@jrhea jrhea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work

@jalextowle jalextowle enabled auto-merge July 18, 2024 11:05
@jalextowle jalextowle added this pull request to the merge queue Jul 18, 2024
Merged via the queue into main with commit 2514eec Jul 18, 2024
31 checks passed
@jalextowle jalextowle deleted the jalextowle/integration/morpho-blue branch July 18, 2024 12:11
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.

Morpho Blue Integration
5 participants