Skip to content

✨ auditor: support non-collateral markets - #815

Open
patitonar wants to merge 1 commit into
mainfrom
non-collateral-markets
Open

✨ auditor: support non-collateral markets#815
patitonar wants to merge 1 commit into
mainfrom
non-collateral-markets

Conversation

@patitonar

@patitonar patitonar commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for markets that can be used for borrowing but not counted as collateral.
    • Administrators can designate or update a market’s collateral eligibility.
    • Health, liquidity, liquidation, withdrawal, and debt previews now reflect non-collateral market behavior.
    • Deployment configuration supports enabling and synchronizing this setting.
  • Compatibility

    • Existing market data and legacy integrations remain supported when the new setting is unavailable.

@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6c022f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/protocol Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Auditor adds configurable non-collateral markets. Collateral, liquidity, liquidation, bad-debt, and preview calculations exclude these markets while retaining debt accounting. Deployment scripts, periphery contracts, upgrade compatibility, and protocol tests support the expanded market metadata.

Changes

Non-collateral market support

Layer / File(s) Summary
Auditor collateral-status rules
contracts/Auditor.sol, test/Protocol.t.sol, .changeset/brave-otter-glides.md
Auditor stores and updates nonCollateral. Collateral valuation, market entry, liquidation collateral, and bad-debt checks exclude flagged markets while debt remains included.
Periphery calculations and market wiring
contracts/periphery/*, deploy/Markets.ts, hardhat.config.ts, test/hardhat/*, test/Previewer.t.sol, test/RewardsController.t.sol, test/*
Periphery previews consume the expanded market tuple and exclude non-collateral balances from collateral calculations. Deployment configuration supports optional market flags and synchronizes compatible Auditors.
Auditor upgrade compatibility
test/Auditor.t.sol, test/hardhat/1_auditor.ts, test/DebtManager.t.sol, test/DebtPreviewer.t.sol
Upgrade tests preserve legacy market state and getter decoding while validating the new flag and post-upgrade operations.
Market and verified-account behavior
test/Market.t.sol, test/VerifiedMarket.t.sol, test/DebtManager.t.sol, test/DebtPreviewer.t.sol, test/IntegrationPreviewer.t.sol, test/Previewer.t.sol
Tests cover borrowing, deleveraging, withdrawals, liquidation, bad debt, locking, debt rolls, previews, and debt socialization with non-collateral supply.

Estimated code review effort: 4 (Complex) | ~60 minutes

Merge Risk: 🟡 Moderate · up to d764c

The PR adds debt-only market support and synchronizes collateral eligibility during deployment. Although the accounting behavior is covered by focused tests, omitted configuration can reverse an existing market’s collateral policy, failed validation can leave a partial rollout, and the public market-enablement interface changes; these risks should be explicitly handled or accepted before merge.

Sequence Diagram(s)

sequenceDiagram
  participant Admin
  participant Auditor
  participant Previewer
  participant Market
  Admin->>Auditor: enableMarket(..., nonCollateral)
  Auditor-->>Previewer: return market metadata and nonCollateral
  Previewer->>Market: calculate collateral and debt effects
  Market->>Auditor: execute liquidity or liquidation check
  Auditor-->>Market: exclude non-collateral collateral and retain debt
Loading

Suggested reviewers: cruzdanilo, itofarina

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding non-collateral market support to Auditor and related components.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch non-collateral-markets
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch non-collateral-markets

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/Protocol.t.sol (1)

630-641: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Load metadata for collateralMarket.

Line 636 loads metadata for market again. Lines 637-641 value collateralMarket's balance. If the markets use different decimals or adjust factors, the bad-debt assertion calculates incorrect adjusted collateral.

Proposed fix
-      (b.adjustFactor, b.decimals, , , , ) = auditor.markets(market);
+      (b.adjustFactor, b.decimals, , , , ) = auditor.markets(collateralMarket);

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 782541f2-ee53-44a7-9913-bbf7b6db3376

📥 Commits

Reviewing files that changed from the base of the PR and between 695096d and 9fd6a42.

📒 Files selected for processing (28)
  • .changeset/brave-otter-glides.md
  • .gas-snapshot
  • contracts/Auditor.sol
  • contracts/periphery/DebtManager.sol
  • contracts/periphery/DebtPreviewer.sol
  • contracts/periphery/DebtRoller.sol
  • contracts/periphery/InstallmentsRouter.sol
  • contracts/periphery/IntegrationPreviewer.sol
  • contracts/periphery/Previewer.sol
  • deploy/Markets.ts
  • hardhat.config.ts
  • test/Auditor.t.sol
  • test/AuditorUpgrade.t.sol
  • test/DebtManager.t.sol
  • test/DebtPreviewer.t.sol
  • test/DebtRoller.t.sol
  • test/InstallmentsRouter.t.sol
  • test/IntegrationPreviewer.t.sol
  • test/Market.t.sol
  • test/Pauser.t.sol
  • test/Previewer.t.sol
  • test/Protocol.t.sol
  • test/RewardsController.t.sol
  • test/VerifiedMarket.t.sol
  • test/hardhat/0_admin.ts
  • test/hardhat/1_auditor.ts
  • test/hardhat/defaultEnv.ts
  • test/hardhat/marketEnv.ts

Comment thread test/AuditorUpgrade.t.sol Outdated
Comment thread test/Market.t.sol

@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: 9fd6a4276d

ℹ️ 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 deploy/Markets.ts Outdated
Comment thread contracts/Auditor.sol Outdated
Comment thread contracts/Auditor.sol
Comment thread contracts/periphery/DebtManager.sol
@patitonar
patitonar force-pushed the non-collateral-markets branch from 9fd6a42 to d4a2b81 Compare August 10, 2026 19:38

@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: d4a2b81e02

ℹ️ 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 contracts/periphery/DebtRoller.sol
Comment thread contracts/periphery/Previewer.sol
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.78%. Comparing base (4b5fec7) to head (6c022f3).

Files with missing lines Patch % Lines
contracts/periphery/DebtPreviewer.sol 93.75% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #815      +/-   ##
==========================================
- Coverage   94.82%   94.78%   -0.04%     
==========================================
  Files          31       31              
  Lines        2724     2744      +20     
  Branches      457      473      +16     
==========================================
+ Hits         2583     2601      +18     
- Misses        140      142       +2     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@patitonar
patitonar force-pushed the non-collateral-markets branch from d4a2b81 to ce13b65 Compare August 25, 2026 19:46

@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: ce13b6524e

ℹ️ 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 contracts/periphery/IntegrationPreviewer.sol

@coderabbitai coderabbitai 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.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: aac7bf33-b255-4786-baff-9a3d60a7c825

📥 Commits

Reviewing files that changed from the base of the PR and between d4a2b81 and ce13b65.

📒 Files selected for processing (7)
  • .gas-snapshot
  • contracts/Auditor.sol
  • hardhat.config.ts
  • test/Auditor.t.sol
  • test/AuditorUpgrade.t.sol
  • test/Market.t.sol
  • test/Protocol.t.sol

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread contracts/Auditor.sol
Comment thread contracts/Auditor.sol
Comment thread test/AuditorUpgrade.t.sol Outdated
Comment thread test/Protocol.t.sol
@patitonar
patitonar force-pushed the non-collateral-markets branch from ce13b65 to d764c05 Compare August 31, 2026 19:51

@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: d764c05998

ℹ️ 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 contracts/periphery/DebtPreviewer.sol
Comment thread contracts/periphery/InstallmentsRouter.sol

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f0d8d592-30a5-41ce-9290-1fc80d7f7e13

📥 Commits

Reviewing files that changed from the base of the PR and between ce13b65 and d764c05.

📒 Files selected for processing (2)
  • .gas-snapshot
  • test/Auditor.t.sol

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread test/Auditor.t.sol
@patitonar
patitonar force-pushed the non-collateral-markets branch from d764c05 to 6c022f3 Compare September 1, 2026 15:51
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