Credit Manager

https://github.com/Paracosm-Labs/mintdeals-contracts/blob/main/contracts/CreditManager.sol

The CreditManager contract is another crucial component of the MintDeals platform, managing user credit scores, borrowing capacities, and interactions with the CreditFacility contract for lending and borrowing operations.

Key Functions

User Management

1. Register User

function registerUser(address user) external
  • Initializes credit information for a new user.

  • Sets the user's initial credit score to the baseline (500).

Asset Management

2. Supply

function supply(address tokenAddress, uint256 amount) external
  • Allows users to supply assets to the credit facility.

  • Transfers tokens from the user to the contract and then to the CreditFacility.

3. Withdraw

function withdraw(address tokenAddress, uint256 amount) external
  • Enables admins to withdraw assets from the credit facility.

  • Redeems assets from CreditFacility and transfers them to the admin.

Borrowing and Repayment

4. Borrow

function borrow(address tokenAddress, uint256 amount) external
  • Allows users to borrow assets based on their credit score and borrowing capacity.

  • Ensures the borrowed amount doesn't exceed user limits or global credit limits.

5. Repay

function repay(address tokenAddress, uint256 repaymentAmount) external
  • Enables users to repay borrowed assets.

  • Calculates and deducts interest fees from the repayment amount.

6. Repay With Fees

function repayWithFees(address tokenAddress, uint256 amount) external
  • Allows admins to make repayments using accumulated repayment fees.

Credit Score Management

7. Set Credit Score

function setCreditScore(address user, uint256 scoreStep, bool increase, uint256 newBoostFactor) external
  • Allows admins to adjust a user's credit score and boost factor.

  • Can increase or decrease the score based on the increase parameter.

Global Credit Limit Management

8. Update Global Max Credit Limit

function updateGlobalMaxCreditLimit(address cTokenAddress) external
  • Updates the global maximum credit limit based on the valuation of non-stablecoin assets.

Fee Management

9. Withdraw Fees

function withdrawFees(address tokenAddress, uint256 amount, address to) external
  • Allows admins to withdraw accumulated repayment fees.

Configuration

10. Set Interest Delta

function setInterestDeltaBP(uint256 _delta) external
  • Sets the interest delta in basis points.

11. Set Global Max Credit Limit

function setGlobalMaxCreditLimit(uint256 newLimit) external
  • Sets or updates the maximum global credit limit.

12. Set Borrowing Multiplier

function setBorrowingMultiplierBP(uint256 newMultiplier) external
  • Sets or updates the borrowing multiplier used to determine max borrowable amount.

13. Set Score Steps

function setScoreSteps(uint256 _borrowScoreStep, uint256 _repayScoreStep) external
  • Sets the score steps used for increasing/decreasing credit scores.

14. Set Blocks Passed Threshold

function setBlocksPassedThreshold(uint256 _blocksPassedThreshold) external
  • Sets the threshold of blocks passed, used in credit scoring.

View Functions

15. Get Credit Info

function getCreditInfo(address user) external view
  • Retrieves a user's credit score, credit balance used, and borrowing capacity.

Key Concepts

  1. Credit Score: A numeric representation of a user's creditworthiness, ranging from 250 - 500 to 850.

  2. Borrowing Capacity: The maximum amount a user can borrow, calculated based on their credit score and boost factor.

  3. Global Credit Limit: The maximum total credit that can be issued across all users.

  4. Interest Delta: An additional interest rate applied on top of the base rate from the CreditFacility.

  5. Boost Factor: A multiplier that can increase a user's borrowing capacity.

This contract is central to MintDeals' credit system, managing user credit scores, facilitating borrowing and repayment, and ensuring the overall health of the credit facility. It interacts closely with the CreditFacility contract to manage asset supply, borrowing, and repayment operations.

Last updated