Skip to content

Added MorphoBlueMarket to integrate USDC ARM to Morpho markets - #329

Open
naddison36 wants to merge 6 commits into
mainfrom
nicka/morpho-blue-lending
Open

Added MorphoBlueMarket to integrate USDC ARM to Morpho markets#329
naddison36 wants to merge 6 commits into
mainfrom
nicka/morpho-blue-lending

Conversation

@naddison36

@naddison36 naddison36 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds direct Morpho Blue lending-market support for the USDC ARM.

  • Adds an ERC-4626-compatible MorphoBlueMarket wrapper around a single Morpho Blue market.
  • Uses one shared implementation with a separately configured proxy for each market.
  • Projects pending interest and protocol-fee dilution when valuing Morpho supply shares.
  • Limits withdrawals and redemptions based on available market liquidity.
  • Restricts position movement to the linked ARM.
  • Supports token-agnostic reward collection:
    • USDC rewards return to the ARM.
    • Other reward tokens are sent to the harvester.

Deployment

Adds deployment 043, which deploys and registers wrappers for:

Market Market ID
OETH/USDC 86% 0xb8fef900b383db2dbbf4458c7f46acf5b140f26d603a6d1829963f241b82510e
WBTC/USDC 86% 0x3a85e619751152991742810df6ec69ce473daef99e28a64ab2340d7b7ccfee49
cbBTC/USDC 86% 0xba3ba077d9c838696b76e29a394ae9f0d1517a372e30fd9a0fc19c516fb4c5a7
cbBTC/USDC 86% 0x64d65c9a2d91c36d56fbc42d69e979335320169b3df63bf92789e2c8883fcc64

The deployment:

  • Verifies each configured parameter set against its expected Morpho market ID.
  • Uses the 5/8 multisig as wrapper owner.
  • Uses the buyback operator as harvester.
  • Registers all four wrappers with the USDC ARM.
  • Does not activate a market automatically, allowing the operator to select one later.

Testing

Adds unit coverage for:

  • Proxy initialization and market configuration.
  • Multiple proxies sharing one implementation.
  • Deposits and complete position redemption.
  • Pending interest and protocol-fee accounting.
  • Liquidity-constrained withdrawals and redemptions.
  • ARM-only position movement.
  • Token-agnostic reward routing.
  • Harvester authorization.
  • Rejection of unknown Morpho markets.

Comment on lines +80 to +83
address public arm;
address public asset;
MorphoMarketId public marketId;
MorphoMarketParams public marketParams;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we could mark them all as immutable?

address public harvester;
IDistributor public merkleDistributor;

uint256[42] private _gap;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think I lack of context here, why using 42 for the gap and not 50?

/// @param tokens The incentive tokens to collect.
/// @return amounts The amount of each corresponding token transferred.
function collectRewards(address[] calldata tokens) external returns (uint256[] memory amounts) {
require(msg.sender == harvester, "Only harvester can collect");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We’re currently using a mix of require statements and custom error. Should we standardize on custom errors?

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.

2 participants