Submitted by Byteblockers, also found by kaden
There is an inconsistency in the calculation of the debtCeiling between the borrow() function and the debtCeiling() function. This not only leads to operational discrepancies, but also impacts liquidity utilization. Specifically, the more restrictive debtCeiling in the borrow() function results in underutilized liquidity, which in turn could lead to missed profit opportunities for lenders.
There is an inconsistency in the way borrow() calculates a much smaller value for debtCeiling than the actual debtCeiling() function. This renders this check useless, since borrow prevents issuance from going even close to the actual debt ceiling.
Lets take the parameters below to illustrate the issue and follow along the two calculations:
1. borrow() functions calculation method:
This function calculates the debtCeiling using a simpler formula:
Note: For the provided formula, please see the original submission contents here.
2. debtCeiling() functions calculation method:
The formula used here is more complex so we will it break it down below:
Note: For the provided formula, please see the original submission contents here.
This method involves several intermediate steps to arrive at the debtCeiling. The process includes:
toleratedGaugeWeight
Note: For the provided formula, please see the original submission contents here.
debtCeilingBefore
Note: For the provided formula, please see the original submission contents here.
remainingDebtCeiling
Note: For the provided formula, please see the original submission contents here.
otherGaugesWeight
Note: For the provided formula, please see the original submission contents here.
maxBorrow
Note: For the provided formula, please see the original submission contents here.
debtCeiling
Note: For the provided formula, please see the original submission contents here.
With the same parameters, this method results in a debtCeiling of 75,000.
The lower debtCeiling set by the borrow() function (42,000) significantly restricts the amount that can be borrowed compared to what is actually permissible as per the debtCeiling() function (75,000).
This discrepancy leads to a situation where a portion of the liquidity remains unused. In a lending scenario, unused liquidity equates to lost income opportunities for lenders, as these funds are not being loaned out and thus not generating interest.
Unify the debtCeiling calculation method which is used across the protocol.
Error
eswak (Ethereum Credit Guild) confirmed
