LendingTerm inconsistency between debt ceiling as calculated in borrow() and debtCeiling()
The borrow() function calculates a lower debt ceiling than the debtCeiling() function, causing the check in GuildToken to be ineffective and leaving liquidity underutilised. An attacker could not exploit this directly, but it leads to missed profit opportunities for lenders.
Byteblockers Follow with kaden
Originally disclosed on Code4rena
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.
Proof of Concept
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.
uint256 debtCeilingAfterDecrement = LendingTerm(gauge).debtCeiling(-int256(weight));
require(issuance <= debtCeilingAfterDecrement, "GuildToken: debt ceiling used");
Let’s take the parameters below to illustrate the issue and follow along the two calculations:
Parameter | Value |
Issuance | 20,000 |
Total Borrowed Credit | 70,000 (5k when we call borrow + 65k old loans) |
Total Weight | 100,000 |
Gauge Weight | 50,000 |
Gauge Weight Tolerance | 60% (1.2e18) |
1. borrow() function’s calculation method:
This function calculates the debtCeiling using a simpler formula:
Note: For the provided formula, please see the original submission contents here.
- Applying the provided parameters (Gauge Weight: 50,000, Total Borrowed Credit: 70,000, Total Weight: 100,000, and Weight Tolerance: 1.2), the resulting
debtCeilingis 42,000.
2. debtCeiling() function’s 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:
- Calculating the tolerated gauge weight.
- Determining the initial debt ceiling before any new borrowings.
- Computing the remaining debt ceiling after factoring in current issuance.
- Establishing the weight of other gauges.
- Determining the maximum borrowable amount.
- Adding the current issuance to the maximum borrow to get the final
debtCeiling.
Note: For the provided formula, please see the original submission contents here.
Note: For the provided formula, please see the original submission contents here.
Note: For the provided formula, please see the original submission contents here.
Note: For the provided formula, please see the original submission contents here.
Note: For the provided formula, please see the original submission contents here.
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.
Recommended Mitigation Steps
Unify the debtCeiling calculation method which is used across the protocol.
Assessed type
Error
eswak (Ethereum Credit Guild) confirmed
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The inconsistency could lead to underutilised liquidity and missed profit opportunities for lenders, but it does not appear to allow direct theft or loss of funds.
What the attacker needed
None
The fix
The debt ceiling calculation method should be unified across the protocol.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a lending system, a debt ceiling is the maximum amount that can be borrowed. This report found that two parts of the code calculate this ceiling differently: one part allows borrowing up to 75,000, but another part only allows up to 42,000. This means the system is more restrictive than intended, so some money that could be lent out is not, which reduces earnings for lenders.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.