Skip to content
Audit finding Beginner

Consumes more gas than intended in getstandardizedprice function in helper library

The getStandardizedPrice function calls a public standardize function that then calls an internal _standardize function, adding unnecessary gas overhead. An attacker could not exploit this; it is a minor efficiency issue that increases transaction costs for users.

iehnnkta Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

57931 sc insight consumes more gas than intended in getstandardizedprice function in helper library

Submitted on Oct 29th 2025 at 14:03:36 UTC by @iehnnkta for Audit Comp | Belong

Description

getStandardPrice uses standardize, which internally calls _standardise (or _standardize) where the actual operation happens. The extra indirection through the public standardize mediator function causes slightly higher gas usage. While this is a small overhead, the protocol is intended to be deployed on Ethereum mainnet where gas costs are significant.

A gas composition comparison is provided in the Proof of Concept section.

Vulnerability Details

  • The gas overhead arises because getStandardizedPrice is calling a public function standardize which in turn calls the internal/private _standardize function, instead of calling the internal function directly.
  • This indirection results in a small but measurable increase in gas consumption for the operation.

Reference location in the target repository: https://github.com/immunefi-team/audit-comp-belong/blob/a17f775dcc4c125704ce85d4e18b744daece65af/contracts/v2/utils/Helper.sol#L106

Proof of Concept

The following minimal contract reproduces the observed difference:

Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {MetadataReaderLib} from "solady/src/utils/MetadataReaderLib.sol";
import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol";

contract getter {
    /// @dev Used for precise calculations.
    using FixedPointMathLib for uint256;
    /// @dev Used for metadata reading (e.g., token decimals).
    using MetadataReaderLib for address;

    uint256 public constant BPS = 10 ** 27;

    function getStandardizedPrice(address token, address tokenPriceFeed, uint256 amount, uint256 maxPriceFeedDelay)
        external
        pure
        returns (uint256 priceAmount)
    {
        (uint256 tokenPriceInUsd, uint8 pfDecimals) = getPrice(tokenPriceFeed, maxPriceFeedDelay);
        // (amount * price) / 10^priceFeedDecimals
        uint256 usdValue = amount.fullMulDiv(tokenPriceInUsd, 10 ** pfDecimals);
        // Standardize the USD value to 27 decimals
        priceAmount = _standardize(18, usdValue); //@audit-issue [Insight] use internal function
    }

    function standardize(address, uint256 amount) public pure returns (uint256) {
        return _standardize(18, amount);
    }

    function _standardize(uint8 decimals, uint256 amount) private pure returns (uint256) {
        return amount.fullMulDiv(BPS, 10 ** decimals);
    }

    function getPrice(address, uint256)
        public
        pure
        returns (uint256 price, uint8 decimals)
    {
        return (100000000, 8); // indicates $1 (for token/USD - the price is in 8 decimals), 18 decimals
    }
}

Observed results when running in RemixIDE:

<details> <summary>Execution logs</summary> </details>

References

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

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 function calls a public wrapper instead of the internal implementation directly, adding an unnecessary function call.

Impact

The only impact is a small increase in gas costs for users; there is no security vulnerability.

What the attacker needed

None

The fix

The function should call the internal _standardize function directly instead of going through the public standardize wrapper.

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.

Smart contracts on Ethereum charge a fee called gas for every operation. Calling an extra function, even a simple one, costs a little more gas. This report points out that the code could skip one function call to save a small amount of gas.

More by iehnnkta

View all

5 more disclosed reports, best first.

More from Belong

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.