ekonomia-tech / protocol-alpha

Alpha version of a DeFi stablecoin protocol
GNU General Public License v3.0
4 stars 0 forks source link

Write base CDP module #67

Closed nmimran99 closed 2 years ago

nmimran99 commented 2 years ago

CDP Module writing.

Files:

  1. CDPPool.sol - main CDP module file
  2. ICDPPool.sol - interface
Short summary on how this module works:
    1. Upon deployment, there are a few parameters to be set:
        a. minDeb - the minimum debt to be taken in order to open a CDP
        b. liquidationCR - the CR is which a CDP becomes available from liquidation
        c. minCR - the minimum CR required to open a CDP. has to be higher than liquidationCR.
        d. protocolFee - currently set on constructor, but I want to change this to pull the protocol fee fro moduleManager
    4. The prices are all takes from chainlink price feeds
    5. Each CDPPool deals with only 1 type of collateral

    functions:
    1. open() - open a brand new CDP for a user. if there is already an open CDP, the user cannot call this function
    2. addCollateral() - the user can add collateral to the position, healing the CDP further. No fee
    3. removeCollateral() - the user can remove collateral from the position in case the CR goes higher. There is a fee
    6. addDebt() - the user can take additional debt if the CR approves it. in order to take more debt, minCR has to be met.
    7. removeDebt() - the user can remove debt, burning PHO from the user causing heal of the position. minDebt has to be met. No fee
    8. close() - If the user wants to completely close the position, he can call this function. this is the only function that closes the position.
    9. liquidate() - liquidation function in case the CR drops under the liquidationCR. currently does NOT handle underwater liquidations.
davekaj commented 2 years ago

rebased on main and resolved minor conflicts so I could do the PR review