Skip to content

Add Adrastia Prudentia for controlling supply & borrow caps #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: development
Choose a base branch
from

Conversation

TRiLeZ
Copy link
Collaborator

@TRiLeZ TRiLeZ commented Jun 5, 2023

Description

Adds support for using Adrastia Prudentia for controlling supply & borrow caps.

Task list

  • Implement the logic and storage mechanisms for using Prudentia
  • Implement the logic for admins to enable the use of Prudentia
  • Test

Type of change

  • Docs change / dependency upgrade
  • Configuration / tooling changes
  • Refactoring
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires changes in customer code

High-level change(s) description - from the user's perspective

Adrastia Prudentia is a novel rate controller system that can be used to manage a variety of risk parameters. Prudentia improves security and user experience while streamlining risk management. Its key features are:

  • Rate limiting support: Safeguard against excessive rate fluctuations, enhancing platform stability and user experience.
  • Delayed rate activation: Give users visibility on upcoming rate changes, fostering transparency and allowing them to plan accordingly.
  • Granular access control: With five unique roles, enable precise control over rate management to ensure a secure and well-organized system.
  • Circuit breaker support: Protect the platform from extreme market conditions and minimize risks through automated emergency response mechanisms.
  • Dynamic rates: Automatically adjust rates in response to market changes, ensuring the platform stays competitive and aligned with prevailing conditions.

This PR uses Prudentia for controlling supply & borrow caps. Lenders and borrowers can expect more fluid changes as they won't have to wait for the vault's risk management team to perform updates; these updates can be automated. Tighter controls can also be employed as updates can be more frequent, allowing for greater protection of user collateral.

Risk management teams can expect to do less tedious work. Instead of manually changing supply & borrow caps as vault activity changes, they can continue monitoring the markets, making infrequent adjustments as necessary. They can also rest with more peace of mind as Prudentia's rate limiting and other controls protect the vault from human mistakes, such as missing a zero.

Note: Ultimately, the changes to the user's experience depend on how Prudentia is configured.

uint256 underlyingDecimals = 18;

// Try to get the underlying asset address (we use a staticcall b/c CEther doesn't have an underlying)
(bool success, bytes memory data) = cToken.staticcall(abi.encodeWithSignature("underlying()"));
Copy link
Contributor

Choose a reason for hiding this comment

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

after the refactoring from #638 is merged, the CEther/CToken will removed from the codebase in favour of CErc20, so these calls can be simplified

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the speedy review, Veliko! I've simplified the calls for getting the underlying token address.

* @author Tyler Loewen (TRILEZ SOFTWARE INC. dba. Adrastia)
* @notice A diamond extension that allows the Comptroller to use Adrastia Prudentia to control supply and borrow caps.
*/
contract ComptrollerPrudentiaCapsExt is DiamondExtension, ComptrollerV4Storage, ComptrollerErrorReporter {
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like this extension does not need to inherit the ComptrollerErrorReporter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Fixed.

@TRiLeZ TRiLeZ changed the title WIP: Add Adrastia Prudentia for controlling supply & borrow caps Add Adrastia Prudentia for controlling supply & borrow caps Jun 10, 2023
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