clober-dex / coupon-finance

Coupon Finance Solidity Contracts
Other
1 stars 0 forks source link

Fix: Validation of Decimals for Debt Tokens. #68

Closed detectivekim closed 1 year ago

detectivekim commented 1 year ago

Description

Due to the following code, debtDecimal must always be 18 or less. Therefore, within the setLoanConfiguration function, it is necessary to check if the decimal of the debtToken is 18 or lower.

https://github.com/clober-dex/coupon-finance/blob/6e917ad8f21b9b7c25469589dd733e1c1d92c87a/contracts/LoanPositionManager.sol#L163-L164

https://github.com/clober-dex/coupon-finance/blob/6e917ad8f21b9b7c25469589dd733e1c1d92c87a/contracts/LoanPositionManager.sol#L318-L339

detectivekim commented 1 year ago

Alternative Suggestions

minDebtAmount = (
    debtDecimal > 18
        ? (minDebtValueInEth * prices[2]) * 10 ** (debtDecimal - 18)
        : (minDebtValueInEth * prices[2]) / 10 ** (18 - debtDecimal)
) / prices[1];
detectivekim commented 1 year ago

Fixed at #69.