sherlock-audit / 2024-04-teller-finance-judging

10 stars 9 forks source link

0xrobsol - Inconsistency in Application of UNISWAP_EXPANSION_FACTOR in Token Conversion Functions #240

Closed sherlock-admin3 closed 5 months ago

sherlock-admin3 commented 5 months ago

0xrobsol

high

Inconsistency in Application of UNISWAP_EXPANSION_FACTOR in Token Conversion Functions

Summary

Inconsistencies have been identified in the application of UNISWAP_EXPANSION_FACTOR between two token conversion functions within the smart contract, potentially leading to incorrect token amount calculations.

Vulnerability Detail

The token0ToToken1 function uses UNISWAP_EXPANSION_FACTOR as a multiplier, while the token1ToToken0 function uses it as a divisor. This inconsistent application could result in errors in calculating the correct amount of tokens to be exchanged, particularly when these functions are used under the assumption that the price scaling is uniformly handled.

Impact

Inconsistent usage of the UNISWAP_EXPANSION_FACTOR could lead to the following issues:

Code Snippet

https://github.com/sherlock-audit/2024-04-teller-finance/blob/main/teller-protocol-v2-audit-2024/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol#L681

Tool used

Manual Review

Recommendation

To address this issue and ensure consistent and symmetrical conversions between token pairs, follow these steps:

nevillehuang commented 5 months ago

Invalid, no issue here, computation is correct