Skip to content

feat(bots): add monitored market making and offer invalidation - #114

Draft
julien-devatom wants to merge 16 commits into
mainfrom
fix/market-making-bootstrap-monitor
Draft

feat(bots): add monitored market making and offer invalidation#114
julien-devatom wants to merge 16 commits into
mainfrom
fix/market-making-bootstrap-monitor

Conversation

@julien-devatom

@julien-devatom julien-devatom commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add fail-loud monitored setup checks and monitored market bootstrap with safe verbose diagnostics, submitted transaction hashes, and owned-offer cleanup on shutdown
  • add production ladder reconciliation with fresh inventory, reference-rate, and capacity reads; nearest-rung funding; a 101 USDC floor; correct reduce-only lower and lend-side higher offers; durable ownership; transaction validation; signing and broadcast; replacement; and cleanup
  • make ladder read-only mode exercise the same tree construction, spread guard, and unsigned Mempool validation as live publication
  • harden local signing, pending-aware nonce allocation, fresh group IDs, cleanup against current on-chain consumption, cross-strategy cash-reservation accounting, bounded monitor timers, independent transaction-confirmation deadlines, and durable retirement of confirmed canceled groups
  • add invalidate [group-id]: invalidate every active maker group by default or one explicit group, with exact transaction policy checks, receipt confirmation, partial-failure reporting, durable cleanup, and read-only preview
  • document every supported environment variable and every BOOTSTRAP_MARKETS and LADDER_MARKETS field, including units, defaults, constraints, and ladder-side semantics

Operator commands

bun run start -- setup-check --monitor
bun run start -- bootstrap --monitor --verbose
bun run start -- ladder --monitor --verbose
bun run start -- invalidate
bun run start -- invalidate 0x<64-hex-group-id>

Add --readonly to bootstrap, ladder, or invalidate to inspect and validate the intended action without signing or broadcasting.

Verification

  • Node.js 24.14.1 and pinned Bun 1.3.12
  • bun install --frozen-lockfile
  • bun run --filter @morpho-org/market-making-bot typecheck
  • bun lint — 0 warnings, 0 errors across 332 files
  • bun format
  • bun knip
  • bun run --filter @morpho-org/market-making-bot jsdoc:build — 320 declarations, including the checker and ladder signature utility
  • bun test --dots — 1,309 passed, 3 skipped, 0 failed, 7,304 assertions across 121 files
  • anti-vacuity verification: deliberately broke the read-only ladder validation assertion and the confirmed invalidation transaction-hash assertion, observed both focused tests fail, restored them, and reran green
  • live read-only ladder recenter exercised the exact tree, Mempool, and spread validation path without signing or broadcasting
  • live read-only ladder inspection encoded the lower reduce-only offer near 4.02% APR and the higher lend offer near 4.53% APR; neither encoded 0%
  • live read-only invalidation inspection covered both all-groups discovery and direct group targeting without signing or broadcasting

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43a33a7e3f

ℹ️ 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".

Comment thread bots/market-making/src/infrastructure/ladder/ladder-offer.utils.ts Outdated
Comment thread bots/market-making/src/infrastructure/ladder/production-ladder.ts Outdated
Comment thread bots/market-making/src/application/ladder/ladder-market-maker.service.ts Outdated
Comment thread bots/market-making/src/infrastructure/cli/cli.ts Outdated

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3abf2e35eb

ℹ️ 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".

Comment thread bots/market-making/src/infrastructure/ladder/ladder-offer.utils.ts Outdated
Comment thread bots/market-making/src/infrastructure/ladder/ladder-group-ownership.utils.ts Outdated
Comment thread bots/market-making/src/application/ladder/ladder-market-maker.service.ts Outdated

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

export const inspectJSDocSource = (file: string, source: string): JSDocInspection => {

P3 Badge Document the exported JSDoc inspection helper

This exported helper is part of the script's TypeScript surface (the tests import it), but it has no substantive JSDoc and the checker does not include scripts/check-jsdoc.ts in its own enforced inventory. That lets the new documentation gate pass while one of its own exported APIs violates the repository’s public-surface documentation rule; add JSDoc for this helper and include the script in the inventory.

AGENTS.md reference: AGENTS.md:L32-L36

ℹ️ 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".

Comment thread bots/market-making/src/infrastructure/bootstrap/production-bootstrap.ts Outdated
@julien-devatom julien-devatom changed the title feat(bots): add monitored market bootstrap and ladder feat(bots): add monitored market making and offer invalidation Jul 30, 2026
@julien-devatom

Copy link
Copy Markdown
Collaborator Author

@codex review

@julien-devatom

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

async reconcile(parameters: Parameters<LadderMakeService['reconcile']>[0]) {
this.write(formatReadOnlyMakeEvent('ladder', 'reconcile', parameters))
return 'logged' as const

P2 Badge Validate ladder dry-runs before logging them

When an operator uses ladder --readonly or its monitor as a preflight, this adapter logs every reconcile request without invoking the production tree builder, spread guard, or unsigned Mempool validation. Live publication still performs those checks, so cases such as a market that matures after the initial setup gate or an SDK/Mempool policy rejection are reported as logged in dry-run but halt in write mode; add a validation seam like bootstrap read-only uses before emitting the readonly.make record.

ℹ️ 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".

Comment thread bots/market-making/src/application/invalidation/offer-invalidation.service.ts Outdated
Comment thread bots/market-making/typedoc.json
@julien-devatom

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c042128a0

ℹ️ 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".

Comment thread bots/market-making/src/infrastructure/bootstrap/bootstrap-make.service.ts Outdated
Comment thread bots/market-making/src/infrastructure/ladder/ladder-make.service.ts Outdated
@prd-carapulse

prd-carapulse Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40fa76587d

ℹ️ 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".

Comment thread bots/market-making/src/infrastructure/ladder/production-ladder.ts Outdated
Treat durable bootstrap and ladder publications as pending active state until the Morpho API indexes them, preventing duplicate monitor publications.
@prd-carapulse

prd-carapulse Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@codex review

@prd-carapulse

prd-carapulse Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d04862a7b4

ℹ️ 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".

Comment thread bots/market-making/src/infrastructure/ladder/production-ladder.ts Outdated
Comment thread bots/market-making/src/infrastructure/bootstrap/production-bootstrap.ts Outdated
Comment thread bots/market-making/src/infrastructure/ladder/production-ladder.ts Outdated
@prd-carapulse

prd-carapulse Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef3ef12b7a

ℹ️ 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".

Comment thread bots/market-making/typedoc.json
@prd-carapulse

prd-carapulse Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: c030ecb65c

ℹ️ 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".

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