Skip to content

[VPD-893]: Integrate DeviationBoundedOracle for conservative CF path#668

Open
GitGuru7 wants to merge 9 commits intodevelopfrom
feat/vpd-893-bounded-price-oracle
Open

[VPD-893]: Integrate DeviationBoundedOracle for conservative CF path#668
GitGuru7 wants to merge 9 commits intodevelopfrom
feat/vpd-893-bounded-price-oracle

Conversation

@GitGuru7
Copy link
Copy Markdown
Contributor

Description

Integrate DeviationBoundedOracle into Comptroller for conservative CF-path pricing

  • Introduce ComptrollerV19Storage with a new deviationBoundedOracle slot
    and add setDeviationBoundedOracle admin setter in SetterFacet

  • Call dbo.updateProtectionState() for all account assets before liquidity
    checks in redeemAllowed and borrowAllowed (populates transient price cache)

  • In ComptrollerLens, use bounded collateral/debt prices from the DBO in the
    collateral-factor path; liquidation-threshold path continues to use spot prices

  • I have updated the documentation to account for the changes in the code.

  • If I added new functionality, I added tests covering it.

  • If I fixed a bug, I added a test preventing this bug from silently reappearing again.

  • My contribution follows Venus contribution guidelines.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c38590fa-faa7-4183-ac56-1145cd78d4dc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/vpd-893-bounded-price-oracle

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 and usage tips.

@GitGuru7 GitGuru7 marked this pull request as ready for review April 9, 2026 06:14
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

VToken[] memory assets = ComptrollerInterface(comptroller).getAssetsIn(account);
uint assetsCount = assets.length;
if (weightingStrategy == WeightFunction.USE_COLLATERAL_FACTOR) {
vars.boundedOracle = ComptrollerInterface(comptroller).deviationBoundedOracle();
Copy link
Copy Markdown
Contributor

@fred-venus fred-venus Apr 9, 2026

Choose a reason for hiding this comment

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

meaning in this case spotOracle = addr(0) ? why not we always return both ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, because only one of the oracle is used based on the chosen weighting strategy.

@fred-venus
Copy link
Copy Markdown
Contributor

I guess we will need to update the VenusLens contract as well. It's not directly used by any other contract, but I'm thinking that fe/be might have certain dependencies. Probably we could return three prices instead of just the spot price.

@fred-venus
Copy link
Copy Markdown
Contributor

I guess we will need to update the VenusLens contract as well. It's not directly used by any other contract, but I'm thinking that fe/be might have certain dependencies. Probably we could return three prices instead of just the spot price.

also same thing to SnapshotLens, better confirm with FE/BE if they are reply on it in some way

@fred-venus
Copy link
Copy Markdown
Contributor

fred-venus commented Apr 9, 2026

in VAI controller#getMintableVAI, should we update this function as well ? What I saw is that we are still using the spot price instead of the updated DeviationBoundedOracle price.

"Function that returns the amount of VAI a user can mint based on their account liquidy and the VAI mint rate"

* are gas-efficient. Should be called before any liquidity calculation in the CF path.
* @param account The account whose collateral assets need protection state updates
*/
function _getAccountLiquidity(
Copy link
Copy Markdown
Contributor

@fred-venus fred-venus Apr 10, 2026

Choose a reason for hiding this comment

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

so this _getAccountLiquidity is removed ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes just its just a additional refactor, It was originally just a wrapper around getHypotheticalAccountLiquidity. If we decide to keep it, we would need to maintain two versions, one view and one non-view.

Functionally, it only abstracts setting the hypothetical borrow/mint values to zero in the getHypotheticalAccountLiquidityInternal. However, this abstraction is already handled in the main external getAccountLiquidity function, which makes the wrapper unnecessory.
And this also improves readability that there only exist one getHypotheticalAccountLiquidity (and no internal wrapper which does the same thing)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah, agree its fine to remove it

@fred-venus
Copy link
Copy Markdown
Contributor

While I don't think this is a major issue or that it will have any substantial impact, would it be better to use a Deviation Oracle here? As thats what would actually be used in a borrowing scenario.

CleanShot 2026-04-10 at 15 15 36@2x

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.

2 participants