Prepare SDK prerequisites for Midnight action flows#829
Conversation
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
One broader issue I could not attach to a diff line: the current Example: at price |
b33e9e1 to
16a2721
Compare
75aa4f0 to
5d98ef3
Compare
Foulks-Plb
left a comment
There was a problem hiding this comment.
Parallel PR Review (Claude)
Reviewed commit: 6fd6eea2
9 personas ran (8 baseline + ci-release-security); 0 failed. The core change — Blue/Midnight requirement-helper split, the widened Requirement/RequirementSignature generics, the new Midnight requirement resolvers, ABI arg ordering, Permit2 SignatureTransfer + DAI routing, changeset/lockfile/packaging — was reviewed by the code-quality, module-api, morpho-protocol, web3-security, silent-failure, style-conventions and ci-release personas and came back clean. Findings are concentrated in docs/JSDoc and test coverage of the new Midnight surface.
| Severity | Count |
|---|---|
| Critical | 0 |
| High | 0 |
| Medium | 7 |
| Low | 2 |
Out-of-scope note (not posted inline)
packages/morpho-sdk/BUNDLER3.md is not in this PR's diff, so it was dropped by the scope filter — but the renames in this PR leave dangling links/symbols there: it still points at src/actions/requirements/getRequirements.ts (lines 21, 73) and getMorphoAuthorizationRequirement.ts (lines 101, 111), both moved to blue/getBlueRequirements.ts / blue/getBlueAuthorizationRequirement.ts. Worth a follow-up.
Note on the AGENTS.md findings
Several AGENTS.md edits document Midnight symbols/folders that don't exist yet in this stacked PR (MorphoMidnight/MidnightActions, client.morpho.midnight(...), an actions/midnight/ folder). If these are intentional forward-references for the rest of the stack, consider deferring them to the PR that lands the code so the agent-facing docs never describe absent surface.
This is an automated parallel review posted as a comment — it does not approve or request changes. A human decides.
34a0273 to
8478fd9
Compare
There was a problem hiding this comment.
Pull request overview
Prepares prerequisite SDK changes to support upcoming Morpho Midnight action flows by reshaping Morpho Blue “requirements” helpers/types, and extending midnight-sdk tree validation and offer/market utilities.
Changes:
- Renames and restructures Morpho SDK requirement helpers/types (Blue-specific requirements + Bundler3 permit helpers), including authorization action discriminator changes.
- Updates Morpho SDK entities/actions/tests and WDK adapter code to consume the new Blue authorization/requirements surfaces.
- Enhances
midnight-sdkmempool tree validation to optionally validate ratified payload bytes, and adds/relocates offer math & consumable-units helpers (removing older fetch/math surfaces).
Reviewed changes
Copilot reviewed 68 out of 69 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Locks viem bump to 2.53.1. |
| packages/wdk-protocol-lending-morpho-evm/src/morpho-protocol-evm.ts | Updates requirement authorization action typing to BlueAuthorizationAction. |
| packages/wdk-protocol-lending-morpho-evm/src/morpho-protocol-evm.test.ts | Adjusts mocked requirement action discriminator to blueAuthorization. |
| packages/morpho-sdk/test/actions/blue/withdraw.test.ts | Uses isRequirementBlueAuthorization guard. |
| packages/morpho-sdk/test/actions/blue/supplyCollateralBorrow.test.ts | Uses blueAuthorization discriminator + isRequirementBlueAuthorization. |
| packages/morpho-sdk/test/actions/blue/repayWithdrawCollateral.test.ts | Uses isRequirementBlueAuthorization in requirement execution loop. |
| packages/morpho-sdk/test/actions/blue/refinance.test.ts | Uses isRequirementBlueAuthorization for auth-only requirement sets. |
| packages/morpho-sdk/test/actions/blue/reallocations.test.ts | Uses isRequirementBlueAuthorization; updates one test name for clarity. |
| packages/morpho-sdk/test/actions/blue/borrow.test.ts | Uses isRequirementBlueAuthorization. |
| packages/morpho-sdk/test/actions/blue/authorization.test.ts | Updates expectations to blueAuthorization discriminator and new guard. |
| packages/morpho-sdk/src/utils.ts | Removes getDaiPermitTypedData re-export from utils barrel. |
| packages/morpho-sdk/src/types/error.ts | Adds deposit/signature mismatch errors for owner/spender. |
| packages/morpho-sdk/src/types/AGENTS.md | Updates docs to BlueAuthorizationAction and prerequisites wording. |
| packages/morpho-sdk/src/types/action.ts | Renames MorphoAuthorizationAction → BlueAuthorizationAction; generifies Requirement/RequirementSignature; introduces isRequirementBlueAuthorization. |
| packages/morpho-sdk/src/helpers/validate.ts | Updates doc references for signature requirement paths. |
| packages/morpho-sdk/src/entities/vaultV2/vaultV2.ts | Switches to getBlueRequirements for vault requirement resolution. |
| packages/morpho-sdk/src/entities/vaultV1/vaultV1.ts | Switches to getBlueRequirements for vault requirement resolution. |
| packages/morpho-sdk/src/entities/blue/blue.ts | Migrates Blue entity requirements/authorization helpers to Blue-prefixed APIs/types and adds useSimplePermit docstrings. |
| packages/morpho-sdk/src/entities/blue/blue.test.ts | Updates test titles to “Blue authorization”. |
| packages/morpho-sdk/src/entities/AGENTS.md | Updates signature-requirement doc references (encodeBundler3Erc20Permit2). |
| packages/morpho-sdk/src/actions/vaultV2/deposit.test.ts | Uses getBlueRequirements in unit tests. |
| packages/morpho-sdk/src/actions/vaultV1/migrateToV2.test.ts | Uses getBlueRequirements in unit tests. |
| packages/morpho-sdk/src/actions/vaultV1/deposit.test.ts | Uses getBlueRequirements in unit tests. |
| packages/morpho-sdk/src/actions/requirements/index.ts | Re-exports new blue/ and bundler3/ requirement modules; removes old entrypoints. |
| packages/morpho-sdk/src/actions/requirements/getRequirementsAction.ts | Updates inline docs to avoid old helper naming. |
| packages/morpho-sdk/src/actions/requirements/encode/index.ts | Exports encodeBundler3Erc20Permit2 and removes old permit2 encoder export. |
| packages/morpho-sdk/src/actions/requirements/encode/encodeErc20Permit.ts | Tightens return type generics and clarifies doc about standard ERC-2612 tokens. |
| packages/morpho-sdk/src/actions/requirements/encode/encodeErc20Permit.test.ts | Removes DAI permit signing test from standard ERC-2612 encoder suite. |
| packages/morpho-sdk/src/actions/requirements/encode/encodeErc20Approval.ts | Updates docs to reference Bundler3 permit2 helper. |
| packages/morpho-sdk/src/actions/requirements/encode/encodeBundler3Erc20Permit2.ts | Introduces Bundler3-scoped Permit2 signature requirement encoder. |
| packages/morpho-sdk/src/actions/requirements/encode/encodeBundler3Erc20Permit2.test.ts | Renames tests to new encoder entrypoint. |
| packages/morpho-sdk/src/actions/requirements/bundler3/index.ts | Adds Bundler3 requirement barrel exports. |
| packages/morpho-sdk/src/actions/requirements/bundler3/getBundler3RequirementsPermit2.ts | Renames and re-types Permit2 requirement helper for Bundler3. |
| packages/morpho-sdk/src/actions/requirements/bundler3/getBundler3RequirementsPermit.ts | Renames EIP-2612 permit requirement helper for Bundler3 and fixes import path. |
| packages/morpho-sdk/src/actions/requirements/blue/index.ts | Adds Blue requirement barrel exports. |
| packages/morpho-sdk/src/actions/requirements/blue/getBlueRequirements.ts | Adds Blue-specific requirement resolver that routes ERC-2612 vs Permit2 vs approval. |
| packages/morpho-sdk/src/actions/requirements/blue/getBlueRequirements.test.ts | Updates tests for renamed Blue/Bundler3 requirement helpers and DAI routing behavior. |
| packages/morpho-sdk/src/actions/requirements/blue/getBlueAuthorizationRequirement.ts | Renames authorization prerequisite helper and discriminator to blueAuthorization. |
| packages/morpho-sdk/src/actions/requirements/blue/getBlueAuthorizationRequirement.test.ts | Updates tests for renamed Blue authorization helper. |
| packages/morpho-sdk/src/actions/blue/supplyCollateralBorrow.test.ts | Uses getBlueRequirements in unit tests. |
| packages/morpho-sdk/src/actions/blue/supplyCollateral.test.ts | Uses getBlueRequirements in unit tests. |
| packages/morpho-sdk/src/actions/blue/supply.test.ts | Uses getBlueRequirements in unit tests. |
| packages/morpho-sdk/src/actions/blue/refinance.ts | Updates doc wording to “authorized on Blue”. |
| packages/morpho-sdk/README.md | Updates builder=signer invariant references to encodeBundler3Erc20Permit2. |
| packages/morpho-sdk/BUNDLER3.md | Updates builder=signer section to encodeBundler3Erc20Permit2 (but still contains outdated authorization helper links). |
| packages/midnight-sdk/src/signatures/TreeUtils.ts | Extends mempool validation to optionally include ratification data and throws on API validation issues. |
| packages/midnight-sdk/src/signatures/TreeUtils.test.ts | Adds tests for ecrecover/setter ratification validation and new thrown error behavior. |
| packages/midnight-sdk/src/signatures/Tree.ts | Re-exports new ratification type; updates mempoolValidate docs. |
| packages/midnight-sdk/src/offers/OfferUtils.ts | Adds offer price/rate/APR/consumable-units helpers; refactors parameter typing and market handling. |
| packages/midnight-sdk/src/offers/OfferUtils.test.ts | Adds coverage for new offer helpers and consumable-units behavior (incl. property tests). |
| packages/midnight-sdk/src/offers/Offer.ts | Allows hydrated Market on offer.market and adds convenience getters/methods. |
| packages/midnight-sdk/src/math/TickLib.ts | Adds tickToApr helper using time-to-maturity annualization. |
| packages/midnight-sdk/src/math/TickLib.test.ts | Extends test coverage to tickToApr. |
| packages/midnight-sdk/src/math/TakeAmountsLib.test.ts | Removes tests for deleted ConsumableUnitsLib. |
| packages/midnight-sdk/src/math/index.ts | Stops exporting removed ConsumableUnitsLib. |
| packages/midnight-sdk/src/math/ConsumableUnitsLib.ts | Removes old consumable-units library module. |
| packages/midnight-sdk/src/market/Position.ts | Normalizes hydrated Market via new Market.from. |
| packages/midnight-sdk/src/market/Market.ts | Adds Market.from constructor/normalization helper. |
| packages/midnight-sdk/src/market/Market.test.ts | Adds tests for Market.from. |
| packages/midnight-sdk/src/fetch/Offer.ts | Removes fetchConsumableUnits (logic moved to offer utils + explicit reads). |
| packages/midnight-sdk/src/fetch/index.ts | Stops exporting removed offer fetch helper. |
| packages/midnight-sdk/src/fetch/fetch.test.ts | Removes tests for deleted fetchConsumableUnits. |
| packages/midnight-sdk/src/errors.ts | Adds MidnightMempoolValidationError for API validation failures. |
| packages/midnight-sdk/src/api/MidnightApi.ts | Updates docs to reflect ratification-aware tree validation. |
| packages/midnight-sdk/src/abis.ts | Adds midnightBundlesAbi and supporting tuple component constants. |
| packages/midnight-sdk/README.md | Updates make-side flow to validate ratified payload bytes and document thrown validation error. |
| packages/midnight-sdk/package.json | Bumps viem to 2.53.1. |
| .changeset/blue-requirements-helpers.md | Declares Morpho SDK major for requirement helper renames and DAI permit changes; WDK patch. |
| .changeset/add-midnight-sdk.md | Updates midnight-sdk changeset text to reflect new Market.from, ratification validation, bundles ABI, and moved consumable-units logic. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2df3f3c26a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
5e91b48 to
a249138
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68658c8d1b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Summary
This PR isolates the prerequisite SDK/package work that should sit between the Midnight action-flow TIB and the concrete morpho-sdk action-flow implementation.
It includes:
midnight-apiIt intentionally does not add the
MorphoMidnightentity or theactions/midnighttransaction builders; those remain in the implementation PR stacked on top.Validation
pnpm --filter @morpho-org/morpho-sdk buildpnpm --filter @morpho-org/midnight-sdk buildpnpm --filter @morpho-org/midnight-sdk test -- src/signatures/TreeUtils.test.tspnpm --filter @morpho-org/morpho-sdk test -- src/actions/requirementswas attempted, but fork-backed suites requireMAINNET_RPC_URL; 327 tests passed before env-gated suites failed during setup.