Add extended Midnight bundle options#857
Draft
Rubilmax wants to merge 58 commits into
Draft
Conversation
Rubilmax
force-pushed
the
hermes/marketv2-action-flows-implementation
branch
from
July 13, 2026 09:39
0a07ac8 to
50c0fee
Compare
Contributor
|
Non-zero referralFeePct breaks the assets↔debt identity on repay (funds footgun, undocumented API behavior) repayWithdrawCollateral.ts passes repayAssets directly as assets. However, the TIB (line 238) documents that to repay a debt D when a referral fee is applied, the required amount is: assets = floor(D * WAD / (WAD - referralFeePct)) —not assets = D. The identity assets == D only holds when referralFeePct = 0. Impact: An integrator setting referralFeePct > 0 and passing repayAssets = D will under-repay, leaving residual debt because part of the supplied assets is taken as the referral fee. This PR is the first one to expose referralFeePct, yet the parameter has no JSDoc (neither on the function parameters nor in types/action.ts).
|
Rubilmax
force-pushed
the
hermes/marketv2-action-flows-implementation
branch
from
July 16, 2026 09:19
0321d43 to
91d57a6
Compare
Base automatically changed from
hermes/marketv2-action-flows-implementation
to
main
July 16, 2026 09:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on
hermes/marketv2-action-flows-implementation.This follow-up restores the Midnight bundle options intentionally left out of the first markets-app implementation PR:
takeLend,supplyCollateralTakeBorrow, andrepayWithdrawCollateral.reduceOnly, referral fee parameters, max continuous fee cap, receiver overrides, and generic collateral withdrawal lists.The first PR keeps the app-used approval-only, asset-targeted action surface. This stacked PR carries the broader SDK surface for a later review. The audit did not find a unit-target Midnight take helper in the current morpho-sdk implementation, so this branch does not add one.
Validation
pnpm exec vitest run --root . --project morpho-sdk packages/morpho-sdk/src/actions/midnight/takeLend.test.ts packages/morpho-sdk/src/actions/midnight/takeBorrow.test.ts packages/morpho-sdk/src/actions/midnight/supplyCollateralTakeBorrow.test.ts packages/morpho-sdk/src/actions/midnight/repayWithdrawCollateral.test.ts packages/morpho-sdk/src/entities/midnight/midnight.test.ts packages/morpho-sdk/src/actions/requirements/midnight/getMidnightBundlesRequirements.test.ts packages/morpho-sdk/src/actions/requirements/encode/encodeErc20Permit2Transfer.test.ts packages/morpho-sdk/src/actions/signatures/getMidnightTokenPermit.test.tspnpm --filter @morpho-org/morpho-sdk build