Skip to content
Business logic Audit finding Advanced

Incorrect MOMP calculation in neutral price calculation

The MOMP calculation in the Loans.update function incorrectly divides the borrower's accrued debt by the total number of loans, rather than the total pool debt. This results in a lower neutral price, causing kickers to lose their bonds more often than expected.

Jeiwan Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-01-ajna-judging/issues/148

Found by

Jeiwan

Summary

When calculating MOMP to find the neutral price of a borrower, borrower's accrued debt is divided by the total number of loans in the pool, but it's total pool's debt that should be divided. The mistake will result in lower neutral prices and more lost bonds to kickers.

Vulnerability Detail

As per the whitepaper:

MOMP: is the price at which the amount of deposit above it is equal to the average loan size of the pool. MOMP is short for “Most Optimistic Matching Price”, as it’s the price at which a loan of average size would match with the most favorable lenders on the book.

I.e. MOMP is calculated on the total number of loans of a pool (so that the average loan size could be found).

MOMP calculation is implemented correctly when kicking a debt, however it's implementation in the Loans.update function is not correct:

Solidity
uint256 loansInPool = loans_.loans.length - 1 + auctions_.noOfAuctions;
uint256 curMomp     = _priceAt(Deposits.findIndexOfSum(deposits_, Maths.wdiv(borrowerAccruedDebt_, loansInPool * 1e18)));

Here, only borrower's debt (borrowerAccruedDebt_) is divided, not the entire debt of the pool.

Impact

The miscalculation affects only borrower's neutral price calculation. Since MOMP is calculated on a smaller debt (borrower's debt will almost always be smaller than total pool's debt), the value of MOMP will be smaller than expected, and the neutral price will also be smaller (from the whitepaper: "The NP of a loan is the interest-adjusted MOMP..."). This will cause kickers to lose their bonds more often than expected, as per the whitepaper:

If the liquidation auction yields a value that is over the “Neutral Price,” NP, the kicker forfeits a portion or all of their bond.

Code Snippet

Loans.sol#L113-L114

Tool used

Manual Review

Recommendation

Consider using total pool's debt in the MOMP calculation in Loans.update.

The original report as published on Sherlock, by Jeiwan. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 miscalculation causes kickers to lose their bonds more often than expected because the neutral price is lower than it should be.

What the attacker needed

None

The fix

The MOMP calculation in Loans.update should use the total pool's debt instead of the borrower's accrued debt.

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 neutral price is a threshold used to decide if a liquidator (kicker) loses their bond. The code that calculates this price uses the wrong debt amount, making the price too low. As a result, liquidators lose their bonds more often 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.

More by Jeiwan

View all

69 more disclosed reports, best first.

More from Ajna #2

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.