minDepositAmount is unnecessarily high, can price out many users
The minimum deposit amount for tokens with fewer than 18 decimals is calculated as 0.1 tokens, which for high-value tokens like WBTC amounts to over $2000. This could price out many users from depositing into Public Vaults.
Submitted by obront, also found by Tointer, bin2chen, 0xcm, and zaskoh
The minDepositAmount() function is intended to ensure that all depositors into Public Vaults are depositing more than dust to protect against attacks like the 4626 front running attack. It is calculated as follows:
function minDepositAmount()
public
view
virtual
override(ERC4626Cloned)
returns (uint256)
{
if (ERC20(asset()).decimals() == uint8(18)) {
return 100 gwei;
} else {
return 10**(ERC20(asset()).decimals() - 1);
}
}
For assets with 18 decimals, this calculation is totally reasonable, as the minimum deposit is just 100 gwei (1/10k of a USD). However, for other assets, the formula returns 0.1 tokens, regardless of value.
While this may be fine for low-priced tokens, it leads to a minimum deposit for tokens like WBTC to be over $2000 USD, certainly too high for many user and not aligned with the intended behavior (which can be seen in the 18 decimal base case).
Proof of Concept
- WBTC is 8 decimals and has a value of ~$20k USD
- the minimum deposit is calculated as
return 10**(ERC20(asset()).decimals() - 1); - for WBTC, this would return
10 ** 7 20,000 * (10 ** 7) / (10 ** 8)=2000 USD
This is far out of line with the 1/10,000 USD expected for tokens with 18 decimals.
Recommended Mitigation Steps
Since our requirements for the size of deposit are so low, we can customize a formula that ensures we get a small final result in all cases. For example:
if (ERC20(asset()).decimals() < 4) {
return 10**(ERC20(asset()).decimals() - 1);
else if (ERC20(asset()).decimals() < 8) {
return 10**(ERC20(asset()).decimals() - 2);
} else {
return 10**(ERC20(asset()).decimals() - 6);
}
SantiagoGregory (Astaria) confirmed
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 minimum deposit formula returns 0.1 tokens for any token with fewer than 18 decimals, without considering the token's actual value.
Impact
Users depositing high-value tokens with fewer than 18 decimals, such as WBTC, would need to deposit over $2000, which could exclude many users.
What the attacker needed
Deposit into a Public Vault; token has fewer than 18 decimals
The fix
The minimum deposit calculation should be adjusted to produce a small final amount for all token decimals, for example by using a different exponent based on the number of decimals.
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 vault is a smart contract where users deposit tokens. The code sets a minimum deposit to stop tiny 'dust' deposits that could be used in attacks. For tokens with 18 decimal places the minimum is tiny, but for tokens with fewer decimals the same formula makes the minimum much larger in dollar terms, so people with expensive tokens must deposit a lot.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.