Skip to content

docs(quoter-bot): add loan-as-collateral markets tib - #180

Open
julien-devatom wants to merge 3 commits into
mainfrom
loan-as-collateral-markets-ad63ab
Open

docs(quoter-bot): add loan-as-collateral markets tib#180
julien-devatom wants to merge 3 commits into
mainfrom
loan-as-collateral-markets-ad63ab

Conversation

@julien-devatom

@julien-devatom julien-devatom commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Why

Loan-as-collateral markets (loan asset in the market's collateral list — e.g. a USDC / cbBTC+USDC market) are the protocol-intended maker pattern for quoting both sides from zero inventory: instead of bootstrapping credit at negative carry, the maker posts the loan asset as collateral and lets sells create debt. TIB-2026-07-27 §3 explicitly reserved the position-health check as mandatory "before any strategy revision can increase collateralized debt" — this TIB is that revision, deciding the design before any code lands.

What

  • TIB-2026-08-27-quoter-loan-as-collateral-markets.md (new): the decision. Core points, each grounded in the pinned vendored Midnight source (336b924a):
    • a maturity-safe collateral-coverage invariant — debt is static face units and isHealthy has no time term, so collateral sized per publication for the worst case (current debt + every live sell cap converted at its tick price) makes pre-maturity liquidation impossible even if the bot halts; monitoring becomes a tripwire, not a control loop;
    • opt-in per-market debt config block; absent block = byte-for-byte today's behavior;
    • single non-reduce-only sell side (protocol take-netting consumes credit before minting debt; buys repay debt first — the built-in deleveraging channel), with the debt mode carried in quote identity so a config flip forces replace;
    • fail-closed qualification: loan asset in collateralParams, constant-oracle bytecode pinning (price() == 1e36), per-cycle enterGate.canIncreaseDebt recheck, disclosed maxLif settlement-penalty bound; the market ID content-addresses all params, so allowlisting is the acceptance boundary;
    • manual-first collateral management (bot never moves collateral in phases 1–2; auto-supply in phase 3 behind policy assertions and middleware intents; withdrawal automation excluded — the protocol health-checks withdrawCollateral against current debt only, never resting sells);
    • penalty-free LLTV = 1 maturity settlement (post-maturity liquidation at LIF = 1 is the settlement mechanism; repay + withdrawCollateral is the voluntary runbook);
    • breach posture (freeze sells, keep quoting buys), bootstrap obsolescence (start must accept an empty bootstrap list), five considered alternatives, phased delivery, and open questions (Morpho API takeability for collateral-backed sells; quoter-signer intent schedule).
  • TIB-2026-07-27: second partial-supersession note + header row, scoped to debt-enabled markets only (§7 no-unintended-debt invariant, Security "No negative credit", position-health not-required).
  • docs/INDEX.md: new entry in the bot-scoped TIB list.

Reviewer notes

Docs-only; no code changes. Every L… reference cites docs/context/repos/midnight-contracts.txt and was verified against it, including the 336b924a delta note (deployed supplyCollateral reverts on oracle revert). pnpm format has been run.

🤖 Generated with Claude Code


Devin Review

Review round 1 (codex)

All five inline findings were incorporated into the TIB: §3 sums sell-side units (credit + debt headroom) and converts once to seller assets at the worst-case tick; §5 pins every coverage input (debt, collateral, on-chain consumed) to one block and bans the eventually consistent API as a coverage input; §2/§6 fail readiness when the debt block is removed while on-chain debt is outstanding; §10 requires the signing middleware to mirror its buy-side aggregate-reservation model for debt capacity; §9 makes maturity settlement an actionable operator runbook, since LIF = 1 gives third parties no incentive to settle. The branch also merged main (TIB-2026-08-25's parallel partial supersession of TIB-2026-07-27, kept alongside this one in date order).

TIB-2026-08-27 decides how the ladder quotes both sides of a Midnight
loan-as-collateral market (loan asset in the collateral list, constant
price-1 oracle) from zero inventory: an opt-in per-market debt config
block, a maturity-safe collateral-coverage invariant that makes
pre-maturity liquidation impossible by construction, non-reduce-only
sells, manual-first collateral management, and penalty-free LLTV=1
post-maturity settlement. Partially supersedes TIB-2026-07-27 (no-debt
invariant and the reserved position-health check) and indexes the TIB.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin 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: 126bffeb2c

ℹ️ 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 docs/decisions/TIB-2026-08-27-quoter-loan-as-collateral-markets.md Outdated
Comment thread docs/decisions/TIB-2026-08-27-quoter-loan-as-collateral-markets.md Outdated
Comment thread docs/decisions/TIB-2026-08-27-quoter-loan-as-collateral-markets.md
Comment thread docs/decisions/TIB-2026-08-27-quoter-loan-as-collateral-markets.md Outdated
Comment thread docs/decisions/TIB-2026-08-27-quoter-loan-as-collateral-markets.md Outdated
julien-devatom and others added 2 commits August 28, 2026 09:02
…rkets-ad63ab

# Conflicts:
#	docs/decisions/TIB-2026-07-27-midnight-quoter-bot.md
Address the five codex findings: convert credit units to seller assets
before summing sell capacity, pin all coverage inputs to one block,
fail readiness when the debt block is removed over outstanding debt,
require aggregate debt reservations in the signing middleware, and make
maturity settlement an actionable operator runbook (LIF=1 gives third
parties no incentive to settle).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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