Skip to content

Conversation

@adhusson
Copy link
Contributor

@adhusson adhusson commented Nov 13, 2025

net gas cost could be ok here we never read the entire market from storage

gas cost test file

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@adhusson adhusson force-pushed the feat/one-market-per-adapter branch from 514886a to a7c04f7 Compare November 13, 2025 20:58
@adhusson adhusson force-pushed the feat/one-market-per-adapter branch from a7c04f7 to 8862319 Compare November 13, 2025 21:02
@morpho-org morpho-org deleted a comment from chatgpt-codex-connector bot Nov 13, 2025
@morpho-org morpho-org deleted a comment from chatgpt-codex-connector bot Nov 13, 2025
@adhusson
Copy link
Contributor Author

@codex please review again (wrong branch was pushed before)

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

adhusson and others added 2 commits November 14, 2025 16:45
Co-authored-by: Quentin Garchery <garchery.quentin@gmail.com>
Signed-off-by: Adrien Husson <adhusson@gmail.com>
@peyha
Copy link
Contributor

peyha commented Nov 18, 2025

In the current adapter code, we have two distinct concept of ids

  • the vault v2 cap id
  • the market id from morpho blue

don't think it's a huge issue but it might be worth a dev comment to prevent misunderstandings (or we could use the market id as the vault v2 cap id but it would break the current cap id computation standard)

@MathisGD
Copy link
Contributor

we never define the id, I think it's fine

@MathisGD
Copy link
Contributor

@codex review again please

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +114 to +118
if (assets > 0) {
(, burnedShares) = IMorpho(morpho).withdraw(marketParams(), assets, 0, address(this), address(this));
// Safe cast because Market V1 bounds the total shares to uint128.max.
supplyShares -= uint128(burnedShares);
}

Choose a reason for hiding this comment

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

P1 Badge Deallocate underflows if anyone supplies on adapter’s behalf

The adapter now derives its position from the locally tracked supplyShares and subtracts the shares burned on withdraw (supplyShares -= uint128(burnedShares)). Because supplyShares is only updated inside allocate/deallocate, an external user can call IMorpho.supply(..., onBehalf = address(this)) to mint supply shares for the adapter without touching this counter. When the vault later deallocates, burnedShares reflects the real Morpho balance (including the donated shares) but the subtraction uses the stale supplyShares, causing an underflow revert and blocking withdrawals; the extra assets are also invisible to realAssets because newAllocation multiplies the tracked supplyShares only. This makes the adapter DOS‑able by a benign “donation” to its market.

Useful? React with 👍 / 👎.

@MathisGD MathisGD changed the title one market per v1 adapter MarketV1AdapterV2 Nov 20, 2025
MarketParams({loanToken: loanToken, collateralToken: collateralToken, oracle: oracle, irm: irm, lltv: lltv});
}

function newAllocation() public view returns (uint256) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The name is strange for me. It's also an external function so it's even more strange.

  • expectedSupplyAssets
  • accrueAllocationView
  • currentSupplyPosition

@adhusson adhusson changed the title MarketV1AdapterV2 MarketV1AdapterV2 (1 adapter per market) Nov 20, 2025
@MathisGD
Copy link
Contributor

replaced by #789

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.

Improve properties about marketParamsList Struct interface of market adapter

5 participants