Steadefi

Steadefi
DeFiHardhatFoundryOracle
35,000 USDC
View results
Submission Details
Severity: medium
Invalid

Wrong LP token value due chainlink feed Decimals.

Summary

Unexpected but possible decimals of the feed not being 8 result in a bad LP distribution.

Vulnerability Details

Feeds can added without checking the decimals, so if a feed with decimals 10 is added, this affects directly to _getTokenPriceMinMaxFormatted() in the GMXOracle.sol:

function _getTokenPriceMinMaxFormatted(address token) internal view returns (uint256) {
(int256 _price, uint8 _priceDecimals) = chainlinkOracle.consult(token);
return uint256(_price) * 10 ** (30 - IERC20Metadata(token).decimals() - _priceDecimals);
}

This results in the protocol not to revert and also make an assertion test to fail:

[FAIL. Reason: Assertion failed.] test_getLpTokenValue() (gas: 378820)
Logs:
Error: lpTokenValue should be roughly 1e18
Error: Assertion Failed

Impact

Bad calculations of LP prices can be done and affect directly to the core logic of the protocol.

Tools Used

Manual Review

Recommendations

I would recommend to check the decimals of the feed before operating. And if some specific decimals not allowed have a protection for it before adding/interacting with them.

Updates

Lead Judging Commences

hans Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.