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:
Asymmetrical Conversions: Incorrect scaling or application of the expansion factor may cause conversions from one token to another to differ from the reverse conversion, leading to inconsistencies in pricing and trading.
Arbitrage Opportunities: Inaccurate pricing calculations may create arbitrage opportunities where traders can exploit price discrepancies between token pairs, potentially leading to economic inefficiencies and loss of value.
To address this issue and ensure consistent and symmetrical conversions between token pairs, follow these steps:
Determine Correct Usage: Review the intended purpose and scale of the UNISWAP_EXPANSION_FACTOR and decide whether it should act as a multiplier or divisor for price calculations.
Update Code: Adjust the usage of the UNISWAP_EXPANSION_FACTOR in both token0ToToken1 and token1ToToken0 functions to ensure consistent application.
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:
Asymmetrical Conversions: Incorrect scaling or application of the expansion factor may cause conversions from one token to another to differ from the reverse conversion, leading to inconsistencies in pricing and trading.
Arbitrage Opportunities: Inaccurate pricing calculations may create arbitrage opportunities where traders can exploit price discrepancies between token pairs, potentially leading to economic inefficiencies and loss of value.
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: