Skip to content

docs: MidnightBundles (Stermi no. 14)#965

Open
MathisGD wants to merge 4 commits into
mainfrom
MathisGD-patch-2
Open

docs: MidnightBundles (Stermi no. 14)#965
MathisGD wants to merge 4 commits into
mainfrom
MathisGD-patch-2

Conversation

@MathisGD
Copy link
Copy Markdown
Contributor

@MathisGD MathisGD commented Jun 2, 2026

No description provided.

Removed redundant authorization comments for the taker and msg.sender in multiple functions.

Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
@MathisGD MathisGD self-assigned this Jun 2, 2026
@MathisGD MathisGD requested review from QGarchery, adhusson and peyha June 2, 2026 10:11
Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
Comment thread src/periphery/MidnightBundles.sol
Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
@linear
Copy link
Copy Markdown

linear Bot commented Jun 2, 2026

PRO-108

Comment thread src/periphery/MidnightBundles.sol Outdated
Comment thread src/periphery/MidnightBundles.sol Outdated
/// on Midnight.
/// @dev msg.sender is always the tokens payer (for buy, supplyCollateral and repay), and receiver is always the tokens
/// receiver (for sell and withdraw collateral).
/// @dev msg.sender must have approved the bundler to pull enough tokens.
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.

same remark actually for the tokens

/// @dev The msg.sender will pay at most maxBuyerAssets.
/// @dev Total loan assets transferred from msg.sender is
/// filledBuyerAssets + filledBuyerAssets * referralFeePct / (WAD - referralFeePct).
/// @dev The receiver will receive collateralWithdrawals[0].assets of the first collateral token of the list etc.
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.

Not very clear, which list ? It's actually the following list:

[
takes[0].offer.market.collateralParams[collateralWithdrawals[0].collateralIndex).token, 
takes[0].offer.market.collateralParams[collateralWithdrawals[1].collateralIndex).token, 
takes[0].offer.market.collateralParams[collateralWithdrawals[2].collateralIndex).token, 
...
]

/// EXTERNAL ///

/// @dev The taker must have authorized this bundler and the msg.sender (if different from the taker) on Midnight.
/// @dev This function should only be called with the same market for all takes.
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 should mention that the offers may not be all the same at the end of the Take[] array, if the amount needed is found without needing those offers: the check is in the take loop, not the collateral loop.
So someone could supply/withdraw collateral in a market not desired, if he did not check that all the markets are the same in the passed offers

/// @dev The receiver will receive at least minSellerAssets.
/// @dev Total loan assets received by the receiver is
/// filledSellerAssets - filledSellerAssets * referralFeePct / WAD.
/// @dev msg.sender will pay collateralWithdrawals[0].assets of the first collateral token of the list etc.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// @dev msg.sender will pay collateralWithdrawals[0].assets of the first collateral token of the list etc.
/// @dev msg.sender will pay collateralSupplies[0].assets of the first collateral token of the list etc.

also not super clear syntax, would go for something like

Suggested change
/// @dev msg.sender will pay collateralWithdrawals[0].assets of the first collateral token of the list etc.
/// @dev msg.sender will pay all collaterals from collateralSupplies.

import {ConsumableUnitsLib} from "./ConsumableUnitsLib.sol";
import {WAD} from "../libraries/ConstantsLib.sol";

/// @dev buy/sell functions take min("units needed to targetUnits", takes[i].units, "consumable units") units.
Copy link
Copy Markdown
Contributor

@adhusson adhusson Jun 3, 2026

Choose a reason for hiding this comment

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

For clarity, also just talking about target units is a bit misleading for functions that target assets

Suggested change
/// @dev buy/sell functions take min("units needed to targetUnits", takes[i].units, "consumable units") units.
/// @dev For each offer, the buy/sell functions will take min("units needed to fill target units / assets", takes[i].units, "units still consumable in takes[i].offer") units.

/// @dev The msg.sender will pay at most maxBuyerAssets.
/// @dev Total loan assets transferred from msg.sender is
/// filledBuyerAssets + filledBuyerAssets * referralFeePct / (WAD - referralFeePct).
/// @dev The receiver will receive collateralWithdrawals[0].assets of the first collateral token of the list etc.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// @dev The receiver will receive collateralWithdrawals[0].assets of the first collateral token of the list etc.
/// @dev The collateralReceiver will receive collateralWithdrawals[0].assets of the first collateral token of the list etc.

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.

4 participants