sherlock-audit / 2022-09-notional-judging

4 stars 2 forks source link

ak1 - TwoTokenPoolMixin.sol : the token's decimals could not be same. Calculation based on token decimal will not give correct result. #142

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

ak1

high

TwoTokenPoolMixin.sol : the token's decimals could not be same. Calculation based on token decimal will not give correct result.

Summary

TwoTokenPoolMixin.sol : the token's decimals could not be same.

Vulnerability Detail

In TwoTokenPoolMixin.sol, primary and secondary token's decimals are set by checking that they should be <= 18. But they can be different. When they are different, the calculation based on decimal values will not be correct.

Impact

The calculation based on primary and secondary decimals will not give correct result.

Code Snippet

https://github.com/sherlock-audit/2022-09-notional/blob/main/leveraged-vaults/contracts/vaults/balancer/mixins/TwoTokenPoolMixin.sol#L56-L66

Tool used

Manual Review

Recommendation

Add validation to check whether both of the token decimals are equal. or Do normalization of data based on the decimals while using them.

Duplicate of #88