Skip to content

[midnight adapter] Arbitrary enterGateFactory per adapter - #1183

Closed
devin-ai-integration[bot] wants to merge 2 commits into
adapter-agnostic-wrapper-gatefrom
devin/1792485600-arbitrary-gate-factory
Closed

devin-ai-integration[bot] wants to merge 2 commits into
adapter-agnostic-wrapper-gatefrom
devin/1792485600-arbitrary-gate-factory

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Note

A Midnight adapter checks that a gated market's gate comes from its trusted gate factory, so it can always admit shareholders on force deallocation. In #1136 the adapter factory fixes that gate factory at deployment and each adapter only chooses whether to use it. This PR lets each adapter be created with any gate factory, and leaves the trust decision to registries and curators, which can read the adapter's enterGateFactory(). Adapter factories no longer need to know the gate factory's address at deployment.

- constructor(address _midnight, address _enterGateFactory)
- createMidnightAdapter(parentVault, durations, bool useGateFactory, salt)
+ constructor(address _midnight)
+ createMidnightAdapter(parentVault, durations, address enterGateFactory, salt)

Context

Impact of merging

  • MidnightAdapterFactory drops the enterGateFactory immutable; its constructor takes only midnight, and CreateMidnightAdapterFactory only emits midnight.
  • createMidnightAdapter, midnightAdapter and CreateMidnightAdapter take an address enterGateFactory where they took bool useGateFactory. The CREATE2 salt is keccak256(abi.encode(enterGateFactory, salt)).
  • An adapter is only safe in gated markets if its enterGateFactory is a trusted VaultV2CompatibleEnterGateFactory. A registry accepting Midnight adapters must check it; this PR adds no registry.
  • Deploying an adapter factory no longer needs the gate factory's predicted address: deploy the adapter factory, then the gate factory with it.

Changes

  • Behavior change, parent [midnight adapter] Wrapper gate with registry #1136: MidnightAdapterFactory and IMidnightAdapterFactory take the gate factory per adapter.
  • MidnightAdapter NatSpec: what a zero or non-trusted enterGateFactory implies.
  • Tests: factory tests fuzz the gate factory address; gated tests deploy the gate factory after the adapter factory.

Evidence

  • forge test --match-path "test/{MidnightAdapterTest,integration/MidnightAdapterIntegrationTest}.sol": 305 passed.

Open questions

@devin-ai-integration devin-ai-integration Bot changed the title devin/1792485600 arbitrary gate factory [midnight adapter] Arbitrary enterGateFactory per adapter Oct 20, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T15:56:01.300745Z 1b23e87 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@linear-code

linear-code Bot commented Oct 20, 2026

Copy link
Copy Markdown

PRO-270

@MathisGD
MathisGD requested a review from adhusson October 20, 2026 15:35
@MathisGD
MathisGD removed this pull request from stack #1184 October 20, 2026 21:31
@MathisGD

Copy link
Copy Markdown
Collaborator

@MathisGD MathisGD closed this Oct 21, 2026
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.

1 participant