Skip to content
Audit finding Intermediate

User will Received Less Amount Of Numa

The protocol's scaling factor for burning assets to NUMA suffers from precision loss because it uses a base of 1000 instead of a larger precision. As a result, users receive slightly less NUMA than they should when calling burnAssetInputToNuma.

Nave765 Follow with onthehunt

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-12-numa-audit-judging/issues/161

Found by

Nave765, onthehunt

Summary

User will lose some Numa due to precision loss whenever user calls NumaPrinter::burnAssetInputToNuma.

Root Cause

BASE_1000 is being used in collateral factor calculation, criticalScaleForNumaPriceAndSellFee, and criticalDebaseFactor within VaultManager::getSynthScaling function.

https://github.com/sherlock-audit/2024-12-numa-audit/blob/main/Numa/contracts/NumaProtocol/VaultManager.sol#L550-L558

Solidity
function getSynthScaling() public view virtual returns (uint scaleSynthBurn, uint syntheticsCurrentPID, uint criticalScaleForNumaPriceAndSellFee, uint blockTime)
    {
        _;
@>      uint criticalDebaseFactor = (currentCF * BASE_1000) / cf_critical;
        // when reaching CF_CRITICAL, we use that criticalDebaseFactor in numa price so that numa price is clipped by this lower limit
        criticalScaleForNumaPriceAndSellFee = criticalDebaseFactor;

        // we apply this multiplier on the factor for when it's used on synthetics burning price
@>      criticalDebaseFactor = (criticalDebaseFactor * BASE_1000) / criticalDebaseMult;

        if (criticalDebaseFactor < scaleSynthBurn)
            scaleSynthBurn = criticalDebaseFactor;
        _;
    }

scaleSynthBurn is being used to scale NUMA to be received based on the burned asset when user calls NumaPrinter::burnAssetInputToNuma. However due to precision loss, user will get less amount than the actual amount to be received.

Assuming the protocol state :

  1. Eth balance of all vault = 2500000e18
  2. Synth value in ETH = 2300000e18
Variable Code Actual
Collateral Factor 1086 1086,9565
criticalScaleForNumaPriceAndSellFee 987 988,1422
scaleSynthBurn (criticalDebaseFactor) 897 898, 311

User calls NumaPrinter::burnAssetInputToNuma which then calculate the Numa received with NumaPrinter::getNbOfNumaFromAssetWithFee. However, user will get less costWithoutFee amount due to precision loss in scaleSynthBurn.

Assuming user try to deposit 500k worth of NUMA in nuAsset, due to low amount of precision user will get 655 less NUMA amount.

Solidity
    function getNbOfNumaFromAssetWithFee(
        address _nuAsset,
        uint256 _nuAssetAmount
    ) public view returns (uint256, uint256) {
        (uint scaleSynthBurn, , , ) = vaultManager.getSynthScaling();
        // apply scale
@>      costWithoutFee = (costWithoutFee * scaleSynthBurn) / BASE_1000;
        // burn fee
        uint256 amountToBurn = computeFeeAmountIn(
            costWithoutFee,
            burnAssetFeeBps
        );
        //uint256 amountToBurn = (_output * burnAssetFeeBps) / 10000;
        return (costWithoutFee - amountToBurn, amountToBurn);
    }
    }

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No Attack Required

Impact

User will get less amount when they try to exchange NuAsset to NUMA.

PoC

No response

Mitigation

Consider changing the precision to 1e18 or bigger than 1000.

The original report as published on Sherlock, by Nave765. 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 use of a small precision base (BASE_1000) in the scaling factor calculation causes truncation of fractional values, leading to a lower scaleSynthBurn and thus fewer NUMA tokens received.

Impact

Users could receive less NUMA than expected when exchanging NuAsset to NUMA, with the example showing a loss of 655 NUMA for a 500k deposit.

What the attacker needed

None

The fix

The precision should be increased to 1e18 or a value larger than 1000.

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.

When you swap one token for another, the system uses a scaling factor to decide how many tokens you get. This scaling factor is stored as a whole number, so small fractions get rounded down. Because the rounding is done with a small base (1000), the error adds up and you get a little less than you should.

More from Numa

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.