Skip to content
Business logic Audit finding Intermediate

Wrong liquidity units calculation

The liquidity-unit calculation in the protocol's utility function did not match the formula in the specification, because the multiplication by the pool price was applied to only one part of the numerator instead of the whole sum. This meant minted LP tokens did not correspond to the deposited tokens, so redeeming them would not return the initial amounts and the protocol could be economically exploited.

Vader Protocol contest

Originally disclosed on Code4rena

The spec defines the number of LP units to be minted as units = (P (a B + A b))/(2 A B) * slipAdjustment = P * (part1 + part2) / part3 * slipAdjustments but the Utils.calcLiquidityUnits function computes ((P * part1) + part2) / part3 * slipAdjustments.

The associativity on P * part1 is wrong, and part2 is not multiplied by P.

The math from the spec is not correctly implemented and could lead to the protocol being economically exploited, as redeeming the minted LP tokens does not result in the initial tokens anymore.

Recommend fixing the equation.

strictly-scarce (vader) confirmed:

Valid, but funds not at risk.

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

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

Root cause

Likely an operator-precedence mistake in the code: the price factor was multiplied only with the first term of the numerator rather than with the whole sum, so the implemented expression differs from the specified one.

Impact

Minted LP tokens would not redeem back to the initial tokens, which could allow economic exploitation of the protocol, though the maintainer stated funds were not at risk.

What the attacker needed

Deposit into the liquidity pool

The fix

The equation should be corrected so the implementation matches the specification, multiplying the price factor across the whole numerator sum.

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.

A liquidity pool lets people deposit two tokens and receive pool shares (LP tokens) in return. The number of shares should follow a published formula so that cashing out later returns roughly what was put in. Here the code grouped the arithmetic differently from the formula, so the share count was wrong and people could get more or fewer shares 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 from Vader Protocol contest

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.