sherlock-audit / 2023-01-ajna-judging

1 stars 0 forks source link

kaysoft - The `deployPool` function will fail for tokens that have decimals more than 18 #168

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

kaysoft

medium

The deployPool function will fail for tokens that have decimals more than 18

Summary

The deployPool function will fail for tokens that have decimals more than 18

Vulnerability Detail

The code for the deployPool function assumes that all tokens will have 18 decimals or lower some tokens like YAM token has 24 decimals.

File: contracts/src/ERC20PoolFactory.sol
53: uint256 quoteTokenScale = 10 ** (18 - IERC20Token(quote_).decimals());
54: uint256 collateralScale = 10 ** (18 - IERC20Token(collateral_).decimals());

Impact

Transaction will fail for tokens that have decimals more than 18.

Code Snippet

contracts/src/ERC20PoolFactory.sol#L53

File: contracts/src/ERC20PoolFactory.sol
53: uint256 quoteTokenScale = 10 ** (18 - IERC20Token(quote_).decimals());
54: uint256 collateralScale = 10 ** (18 - IERC20Token(collateral_).decimals());

Tool used

Manual Review

Recommendation

Consider implementing the lines to take into account of tokens that have more than 18 decimals.

Duplicate of #123