Skip to content
Smart contracts Audit finding Intermediate

_decimalMultiplier doesn’t account for tokens with decimals higher than 18

The decimal multiplier calculation in StrategySwapper assumes token decimals are at most 18, so swapping tokens with more than 18 decimals always reverts. This prevents strategies from harvesting rewards when such tokens are involved.

shenwilly Follow

Originally disclosed on Code4rena

Submitted by shenwilly, also found by pauliax, StyxRave, and WatchPug

StrategySwapper.sol#L287-L289 StrategySwapper.sol#L318-L320 StrategySwapper.sol#L335-L337

In StrategySwapper, swapping from or to tokens with decimals higher than 18 will always revert. This will cause inabilities for strategies to harvest rewards.

Proof of Concept

L288 will revert when token_ has higher than 18 decimals.

 return 10**(18 - IERC20Full(token_).decimals());

Recommended Mitigation Steps

Consider modifying how _decimalMultiplier works so it could handle tokens with higher than 18 decimals.

Update the calculation of _minTokenAmountOut and _minWethAmountOut to account when decimals are higher/lower than 18.

chase-manning (Backd) confirmed and resolved


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

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

The code assumes token decimals are never greater than 18, so the subtraction 18 minus decimals underflows or produces an invalid exponent when decimals exceed 18.

Impact

Swaps involving tokens with more than 18 decimals always revert, so strategies cannot harvest rewards for those tokens.

What the attacker needed

Token with more than 18 decimals

The fix

The decimal multiplier calculation and the minimum output amount calculations should be updated to handle tokens with more or fewer than 18 decimals; the report states the issue was confirmed and resolved.

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.

Tokens can have different numbers of decimal places. The code calculates a scaling factor by subtracting the token's decimals from 18, which becomes negative if the token has more than 18 decimals. That negative exponent causes the transaction to fail, so the strategy cannot swap or harvest rewards.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by shenwilly

View all

12 more disclosed reports, best first.

More from Backd Tokenomics contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.