Credit Facility
https://github.com/Paracosm-Labs/mintdeals-contracts/blob/main/contracts/CreditFacility.sol
The CreditFacility contract is a crucial component of the MintDeals platform, managing interactions with JustLend for asset management, collateral handling, borrowing, repaying, and yield claiming for increasing capacity.
Key Functions
Asset Management
1. Supply Asset
Allows users to supply a specific amount of an underlying asset to JustLend.
Users receive cTokens in return.
The asset can be supplied for the sender or on behalf of another user (beneficiary).
2. Redeem Asset
Enables users to withdraw (redeem) a specific amount of the underlying asset from the protocol.
Ensures that the redemption doesn't cause under-collateralization.
Borrowing and Repayment
3. Borrow
Allows users to borrow a specific amount of a stablecoin from JustLend.
Checks if the borrowed amount is within the user's borrowing power.
4. Repay Borrow
Enables users to repay a specific amount of borrowed stablecoin.
Can be used to repay on behalf of another user (beneficiary).
Collateral Management
5. Enable As Collateral
Allows admins to enter markets as collateral, adding assets to the liquidity calculation.
Configuration
6. Add CToken
Enables admins to add new cToken contracts to the system.
7. Update Collateral Factors
Allows admins to update the collateral factors for stablecoins and non-stablecoins.
Utility Functions
8. Calculate Total Borrowing Power
Calculates the total borrowing power of a specific user based on their deposits.
9. Calculate Total User Stablecoin Borrows
Calculates the total amount of stablecoins borrowed by a user.
10. Calculate Total User Deposits
Calculates the total amount of stablecoin deposits and non-stablecoin deposits for a user.
11. Get User Reserve Valuation
Gets the USD valuation of a user's non-stablecoin asset deposits.
Key Concepts
cTokens: Representation of supplied assets in the JustLend protocol.
Collateral Factors: Determine the borrowing power of supplied assets (different for stablecoins and non-stablecoins).
Borrowing Power: The maximum amount a user can borrow based on their supplied collateral.
This contract forms the backbone of MintDeals' credit facility, enabling businesses to leverage their membership fees as collateral for borrowing, while also managing asset supply, borrowing and repaying in a decentralized manner.
Last updated