Skip to content

Conversation

@adhusson
Copy link
Contributor

@adhusson adhusson commented Nov 7, 2025

No description provided.

Copy link
Contributor

@peyha peyha left a comment

Choose a reason for hiding this comment

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

Nice 🔥 🔥 using a linked list to manage maturities is smart

If I understand correctly, the allocation workflow should be

An allocator creates a make offer for the vault
A taker takes this offer onchain
| morphoV2 calls onBuy on the adapter
| | the adapter updates its state
| | the adapter calls allocate on its parent vault
| | | the vault V2 calls allocate on the market V2 adapter
| | | | the adapter returns the corresponding ids and allocated assets

_positions[obligationId].growth += gainedGrowth;
_maturities[obligation.maturity].growthLostAtMaturity += gainedGrowth;
currentGrowth += gainedGrowth;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this usecase for ? buying after maturity ? the vault is likely to get liquidated so not sure there is a huge usecase

Comment on lines +15 to +16
/// @dev Losses are immdiately accounted minus a discount applied to the remaining interest to be earned, in proportion
/// to the relative sizes of the loss and the adapter's position in the obligation hit by the loss.
Copy link
Contributor

Choose a reason for hiding this comment

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

not very clear

/* ACCOUNTING */

uint256 public _totalAssets;
uint48 public lastUpdate;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess uint48 is for packing, so why not uint64? It is much more likely to be handled by all EVM tools such as certora


// Do not cleanup the linked list if we end up at 0 growth
function withdraw(Obligation memory obligation, uint256 obligationUnits, uint256 shares) external {
require(IVaultV2(parentVault).isAllocator(msg.sender), NotAuthorized());
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't lenders also be able to trigger a withdraw on morpho V2 ?

accrueInterest();
if (obligation.maturity > block.timestamp) {
uint128 timeToMaturity = uint128(obligation.maturity - block.timestamp);
uint128 gainedGrowth = ((obligationUnits - buyerAssets) / timeToMaturity).toUint128();
Copy link
Contributor

Choose a reason for hiding this comment

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

there could be some roundings by defining growth with this, not sure it's an issue though

nextMaturity = firstMaturity;
} else {
nextMaturity = _maturities[prevMaturity].nextMaturity;
require(nextMaturity != 0, IncorrectHint());
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure we should revert on this, a vault v2 could set multiple offers (with both sell and buy) and this could create some path dependency on the execution of these offers (what if the sell offer removes the prevMaturity for some buy)

Copy link
Contributor

Choose a reason for hiding this comment

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

in this case, you could just use nextMaturity=firstMaturity


uint256 _totalAssetsBefore = _totalAssets;
removeUnits(obligation, obligationUnits);
require(vaultBuffer >= _totalAssetsBefore.zeroFloorSub(_totalAssets), BufferTooLow());
Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed during the bootcamp, using this specific buffer is the second idea but it lacks the ability to sell at a loss in a controlled way

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.

3 participants