IM=40%
now pool has,
balance: 300 token3
borrowed: 200 token3
maxCollateralAmount = 100
min(maxCollateralAmount, balance - borrowed) = 100
at this point,
collateralRatioBorrow = 100 / 200 = 50% > IM
total margin value==100
total borrowed value==200,
Which means thattotal margin value(how much SP has deposited) can be less than total borrowed value.
CL001
high
The checkBorrowSafe method is not set properly
Summary
according to the DODO Docs,
Borrowing Collateral Ratio
serves as an additional check condition when SP borrows funds. After borrowing, it must be ensured thatborrowing collateral ratio
is greater than 1 + IM. https://docs.dodoex.io/en/product/dodo-v3-pools/funding-model#b--object-objectVulnerability Detail
https://github.com/sherlock-audit/2023-12-dodo/blob/ea7f786161113144562a900dbff31457ff7025ef/dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultFunding.sol#L304 However, in the
checkBorrowSafe
method, theBorrowing Collateral Ratio
is greater than IM.For simplicity, assume the following scenario:
IM=40% now pool has, balance: 300 token3 borrowed: 200 token3 maxCollateralAmount = 100 min(maxCollateralAmount, balance - borrowed) = 100
at this point, collateralRatioBorrow = 100 / 200 = 50% > IM total margin value==100 total borrowed value==200, Which means that
total margin value
(how much SP has deposited) can be less thantotal borrowed value
.Impact
A malicious SP from borrowing funds indefinitely and causing other SPs to have no available funds.
Code Snippet
https://github.com/sherlock-audit/2023-12-dodo/blob/ea7f786161113144562a900dbff31457ff7025ef/dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultFunding.sol#L304
Tool used
Manual Review
Recommendation
Please confirm whether it is doc issue or a design choices.