ERC20 Tokens with more than 18 decimals
are not compatible
#581
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-533
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/utils/TradingLibrary.sol#L115
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/Trading.sol#L675
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/Trading.sol#L643-L659
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/StableVault.sol#L65-L72
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/StableVault.sol#L44-L51
Vulnerability details
ERC20 Tokens with more than 18
decimals
are not compatibleSummary
Some token won't be compatible as used a hardcoded value of
18-decimals
, if decimals is bigger than 18, it will revert due to an underflow, and therefore, not be compatible.Impact
Some erc20 tokens not compatible as
StableVault.sol
functionswithdraw
,deposit
will revert when usedSame happens on:
-
Trading.sol
functions_handleDeposit
and_handleWithdraw
-
TradingLibrary.sol#verifyPrice()
References
https://ethereum.stackexchange.com/questions/118896/can-an-erc-20-have-more-than-18-decimals
Proof of Concept
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/StableVault.sol#L44-L51
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/StableVault.sol#L65-L72
_handleDeposit
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/Trading.sol#L643-L659
_handleWithdraw
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/Trading.sol#L675
And in
TradingLibrary.sol#verifyPrice()
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/utils/TradingLibrary.sol#L115
Recommended Steps
Consider this edge case and don't use a hardcoded amount
18
in when usingdecimals()
The text was updated successfully, but these errors were encountered: