Comment on page

Collateral & Borrowing

Users need to choose the market rule by calling chosen rule. The market rules specify the parameters of loans. The rules concern which assets can be used as collateral, which can be borrowed, and what coefficients assets have while calculating the Health factor.
Depending on the market rule, assets have different Collateral Coefficients and Borrow Coefficients. At all times, the Health Factor must be greater than 1, otherwise, liquidation can happen.
Once the rule is chosen, the user can deposit an asset that was registered by the market owner. If the borrowing is enabled for the asset then the user is earning the proportional part of interest paid by borrowers.
At any time a user can redeem the deposited assets. After redeeming, the Health Factor must be greater than 1, otherwise, the call will fail.
If the asset is specified by the user-chosen rule as collateral, the user can mark it as collateral by calling set as collateral.
If a user has deposited some assets and marked at least one as a collateral then the user can borrow, by calling borrow, any asset that is allowed for borrowing by the user-chosen rule. The users' debt is increasing with time as interest is accumulating.
At any time user can repay any debt the user has taken by calling repay.
If at any time, due to accumulation of interests or assets price oscillations, the user position coefficient Health Factor becomes equal or smaller than 1, anyone can liquidate the user's position by calling liquidate. The liquidator pays part of the user's debt and gets the right part of the user's collateral. The value of the revived collateral by the liquidator is higher than the value of the debt he is repaying. In this way, liquidators are rewarded and users who have managed their position wrongly are punished. The penalty/reward is proportional to the amount of the liquidated debt and the penalty parameter specified for each asset by market rules.