Skip to content

Latest commit

 

History

History
56 lines (34 loc) · 2.2 KB

040.md

File metadata and controls

56 lines (34 loc) · 2.2 KB

Attractive Raisin Sheep

High

All exchange rates are incorrect, except in the case of ETH.

Summary

The following lines of code contain incorrect exchangeRate calculations:

The exchangeRate calculated in the above locations is incorrect due to a flawed calculation logic in the price function found in MasterPriceOracle.sol.

Root Cause

The price function is returning the token price in USD instead of the exchange rate in ETH.
Refer to the following code:

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

This issue can lead to significant confusion in the price calculations throughout the protocol, including the depositing and withdrawing of USDa, USDT, and collaterals. e.g: The deposit amount can often be 0 because the token price in USD is significantly less than 1e18. Then causes the transaction to revert. https://github.com/sherlock-audit/2024-11-autonomint/blob/main/Blockchain/Blockchian/contracts/lib/BorrowLib.sol#L689

PoC

No response

Mitigation

To correct this issue, the following changes should be made to the code:

-    return (uint128(uint256(price_)), ethPrice);
+    return (uint128(uint256(price_) * 1e18 / ethPrice), ethPrice);