Utilization math should include `liquidityThresholdPercent`
The utilization ratio calculation for a lending pool ignores the liquidity threshold percentage, which caps the maximum borrowable amount. This causes the interest rate to be lower than it should be, reducing profits for liquidity providers.
Source: https://github.com/sherlock-audit/2024-04-teller-finance-judging/issues/70
Found by
0x3b, 0xadrii
Summary
Utilization math should include liquidityThresholdPercent, as this represents the maximum value that can be borrowed. This means that if borrowing reaches principal * liquidityThresholdPercent, then 100% of the available assets are considered borrowed.
Vulnerability Detail
getPoolUtilizationRatio is used within getMinInterestRate to calculate the interest rate at which borrowers borrow. Higher utilization equates to a higher APR.
However, in the current case, getMinInterestRate fails to include liquidityThresholdPercent in its calculation. This variable is crucial as it caps the maximum borrowing allowed (e.g., if it's 80%, then a maximum of 80% of the assets can be borrowed).
Not including this variable means that the utilization (and thus the APR) will appear lower than it actually is. An example of this is a more risky market with a lower liquidityThresholdPercent, such as 40%. In these markets, even though there is some risk that the LPs take, the maximum utilization will be 40%, as borrowers cannot borrow above that, even if there is demand for this token. This in tern will decease the profits LPs make from staking in risky markets.
Impact
This results in a breakdown of core contract functionality. Utilization above liquidityThresholdPercent is unreachable, leading to lower LP profits.
Code Snippet
function getPoolUtilizationRatio() public view returns (uint16) {
if (getPoolTotalEstimatedValue() == 0) { return 0; }
return uint16( Math.min(
getTotalPrincipalTokensOutstandingInActiveLoans() * 10000 /
getPoolTotalEstimatedValue(), 10000 ));
}
Tool used
Manual Review
Recommendation
Include liquidityThresholdPercent in getPoolUtilizationRatio. For example:
- return uint16(Math.min(getTotalPrincipalTokensOutstandingInActiveLoans() * 10000 / getPoolTotalEstimatedValue(), 10000));
+ return uint16(Math.min(getTotalPrincipalTokensOutstandingInActiveLoans() * 10000 / (getPoolTotalEstimatedValue().percent(liquidityThresholdPercent)), 10000));
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/teller-protocol/teller-protocol-v2-audit-2024/pull/17
sherlock-admin2
The Lead Senior Watson signed off on the fix.
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
Liquidity providers earn lower interest than intended because the interest rate is based on an understated utilization ratio, reducing their profits.
What the attacker needed
None
The fix
The issue was fixed by including the liquidity threshold percentage in the utilization ratio calculation, as confirmed by the protocol team and the lead auditor.
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 pool, the utilization ratio shows how much of the available money has been borrowed. Interest rates often rise as utilization increases. The code that calculates this ratio forgot to account for a rule that limits borrowing to a certain percentage of the pool. So the ratio looks lower than it really is, and lenders earn less interest than they should.
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.