sharesToTokenAmount : Division by zero
The public sharesToTokenAmount function divides by the total shares minted for a token without checking whether that total is zero, and its callers do not guard against this either. When the total is zero the function reverts, so other contracts calling it or getFeeAccumulatedOnNft would fail unexpectedly.
Submitted by cmichel, also found by cccz and CertoraInc
The public sharesToTokenAmount function does not check if the denominator totalSharesMinted[_tokenAddress] is zero.
Neither do the callers of this function. The function will revert.
Calling functions like getFeeAccumulatedOnNft and sharesToTokenAmount from another contract should never revert.
Recommended Mitigation Steps
Return 0 in case totalSharesMinted[_tokenAddress] is zero.
ankurdubey521 (Biconomy) confirmed
A valid concern of runtime error.
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 a missing zero check on the total shares denominator before performing the division.
Impact
Calls to sharesToTokenAmount and functions such as getFeeAccumulatedOnNft could revert when no shares have been minted for a token, breaking integrations that expect a value.
What the attacker needed
No shares minted for the token
The fix
The function should return 0 when the total shares minted for the token is zero.
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.
A smart contract is a program that runs on a blockchain. This one has a function that converts a share of a pool into an amount of tokens by dividing by the total number of shares. Dividing by zero is not allowed, so the program stops with an error (a revert) instead of returning a number, and anything that called it also fails.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.