Skip to content
Business logic Audit finding Intermediate

Contradiction between high-leverage and liquidation check of position

The liquidation check in the Leverager contract prevents opening positions with leverage above 2x, contradicting the intended design that allows higher leverage. An attacker could not exploit this, but it limits the protocol's functionality.

000000 Follow with 0x73696d616f, 0xaxaxa and 21 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-02-yieldoor-judging/issues/357

Found by

000000, 0x73696d616f, 0xaxaxa, 0xmystery, AlexCzm, AuditorPraise, BugsBunny, Fade, JohnTPark24, KrisRenZo, Ryonen, TessKimy, Valy001, charles__cheerful, elvin.a.block, future2_22, iamnmt, jennifer37, montecristo, mstpr-brainbot, newspacexyz, novaman33, stuart_the_minion, whitehair0330

Summary

Market can allow leverage higher than 2x, and this is design choice. But the check owedAmount > totalDenom in isLiquidateable function doesn't allow leverage higher than 2x.

Root Cause

positionLeverage is calculated and checked in _checkWithinlimits function when open leverage.

Solidity
    function _checkWithinlimits(Position memory up) internal {
        ...
@>      uint256 positionLeverage = (up.initCollateralValue + up.borrowedAmount) * 1e18 / up.initCollateralValue;
        require(positionLeverage <= vp.maxTimesLeverage && positionLeverage <= maxLevTimes, "too high x leverage");
        ...
    }

Opening leverage also checks whether the position is liquidateable. isLiquidateable checks if owedAmount > totalDenom and returns true (indicating liquidation).

Solidity
    function isLiquidateable(uint256 _id) public view returns (bool liquidateable) {
        ...

        uint256 totalValueUSD = _calculateTokenValues(pos.token0, pos.token1, userBal0, userBal1, price);
        uint256 bPrice = IPriceFeed(pricefeed).getPrice(pos.denomination);
        uint256 totalDenom = totalValueUSD * (10 ** ERC20(pos.denomination).decimals()) / bPrice;

        uint256 bIndex = ILendingPool(lendingPool).getCurrentBorrowingIndex(pos.denomination);
        uint256 owedAmount = pos.borrowedAmount * bIndex / pos.borrowedIndex;

        /// here we make a calculation what would be the necessary collateral
        /// if we had the same borrowed amount, but at max leverage. Check docs for better explanation why.
        uint256 base = owedAmount * 1e18 / (vp.maxTimesLeverage - 1e18);
        base = base < pos.initCollateralValue ? base : pos.initCollateralValue;

@>      if (owedAmount > totalDenom || totalDenom - owedAmount < vp.minCollateralPct * base / 1e18) return true;
        else return false;
    }

When open leverage, owedAmount is equal to borrowedAmount and totalDenom is equal to initCollateralValue. To be not liquidateable, owedAmount <= totalDenom should be satisfied, and this means that positionLeverage is always smaller than 2x.

Root cause is contradiction between high-leverage and liquidation check of position. This means that the define of positionLeverage could be incorrect or liquidation check could be incorrect.

Internal Pre-conditions

No response

External Pre-conditions

No response

Attack Path

No response

Impact

Market doesn't allow leverage higher than 2x

PoC

No response

Mitigation

Update the positionLeverage check logic or isLiquidateable function logic.

The original report as published on Sherlock, by 000000. 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

Root cause

Likely the liquidation condition `owedAmount > totalDenom` is inconsistent with the leverage calculation, causing any position with leverage above 2x to be immediately liquidatable.

Impact

The market does not allow leverage higher than 2x, limiting the protocol's intended functionality.

What the attacker needed

None

The fix

The `positionLeverage` check logic or the `isLiquidateable` function logic should be updated to resolve the contradiction.

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 protocol, leverage means borrowing to increase your position size. The code has a check that is supposed to allow up to a certain maximum leverage, but another check in the liquidation logic effectively caps it at 2x, so users cannot open higher-leverage positions even though the design says they should be able to.

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 000000

View all

32 more disclosed reports, best first.

More from Yieldoor

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.