user can drawDebt that is below dust amount
According to the protocol, drawDebt prevents user from drawing below the `quoteDust_` amount. However, a logical error in the code can allow user to draw below dust amount.\\n`_revertOnMinDebt` is used in `drawDebt` to prevent dust loans. As you can see, the protocol wants to take the average of debt in the pool and make it the minimum if there are 10 or more loans. If it is lower than 10 loans, a `quoteDust` is used as the minimum. There is an edge case, whereby there are 10 loans in the pool, and the borrowers repay the loans till there is only 1 unit owed for each loan.(Might revert due to rounding error but it is describing a situation whereby repaying till a low amount of poolDebt can enable this). A new borrower can then `drawDebt` and because `_revertOnMindebt` only goes through the average loan amount check and not the `quoteDust_` amount check, he/she is able to draw loan that is well below the `quoteDust_` amount.\\n```\\n    function _revertOnMinDebt(\\n        LoansState storage loans_,\\n        uint256 poolDebt_,\\n        uint256 borrowerDebt_,\\n        uint256 quoteDust_\\n    ) view {\\n        if (borrowerDebt_ != 0) {\\n            uint256 loansCount = Loans.noOfLoans(loans_);\\n            if (loansCount >= 10) {\\n                if (borrowerDebt_ < _minDebtAmount(poolDebt_, loansCount)) revert AmountLTMinDebt();\\n            } else {\\n                if (borrowerDebt_ < quoteDust_)                            revert DustAmountNotExceeded();\\n            }\\n        }\\n    }\\n```\\n\\n```\\n    function _minDebtAmount(\\n        uint256 debt_,\\n        uint256 loansCount_\\n    ) pure returns (uint256 minDebtAmount_) {\\n        if (loansCount_ != 0) {\\n            minDebtAmount_ = Maths.wdiv(Maths.wdiv(debt_, Maths.wad(loansCount_)), 10**19);\\n        }\\n    }\\n```\\n
Issue user can drawDebt that is below dust amount\\nRecommend checking that loan amount is more than `quoteDust_` regardless of the loan count.\\n```\\n    function _revertOnMinDebt(\\n        LoansState storage loans_,\\n        uint256 poolDebt_,\\n        uint256 borrowerDebt_,\\n        uint256 quoteDust_\\n    ) view {\\n        if (borrowerDebt_ != 0) {\\n            uint256 loansCount = Loans.noOfLoans(loans_);\\n            if (loansCount >= 10) {\\n                if (borrowerDebt_ < _minDebtAmount(poolDebt_, loansCount)) revert AmountLTMinDebt();\\n            } \\n            if (borrowerDebt_ < quoteDust_) revert DustAmountNotExceeded();\\n            \\n        }\\n    }\\n```\\n
A minimum loan amount is used to deter dust loans, which can diminish user experience.
```\\n    function _revertOnMinDebt(\\n        LoansState storage loans_,\\n        uint256 poolDebt_,\\n        uint256 borrowerDebt_,\\n        uint256 quoteDust_\\n    ) view {\\n        if (borrowerDebt_ != 0) {\\n            uint256 loansCount = Loans.noOfLoans(loans_);\\n            if (loansCount >= 10) {\\n                if (borrowerDebt_ < _minDebtAmount(poolDebt_, loansCount)) revert AmountLTMinDebt();\\n            } else {\\n                if (borrowerDebt_ < quoteDust_)                            revert DustAmountNotExceeded();\\n            }\\n        }\\n    }\\n```\\n