THORChain_Router.sol
The safeTransferFrom function is intended to handle the transfer of ERC-20 tokens while accounting for potential transfer fees by comparing the balances before and after the transfer. However, this function fails to revert the transaction or handle cases where the actual amount transferred is less than the requested amount due to token fees or other deductions, leading to a mismatch in balance tracking and potential loss of funds for users.
Code snippet:
Expected Behavior: The function should correctly calculate the transferred amount and revert if the actual amount received is less than expected, thus preventing any discrepancy in balance tracking.
Expected Behavior code snippet:
Logic:
Actual Behavior: The function returns the difference in the balance, which may be less than the requested transfer amount due to fees or other deductions, without verifying that the full amount has been received.
Actual Behavior code snippet:
Logic:
This calculation error could lead to scenarios where the contract operates with incorrect assumptions about token balances; thereby, affecting subsequent transactions and user balances within the contract. Its critical to implement strict checks and balances in token handling functions to ensure consistency and prevent financial discrepancies.
Lets break down the Logic in both the expected and actual behaviors of the safeTransferFrom function to clarify the potential issues:
In summary, the expected behavior includes a safeguard to revert transactions when the net transferred amount is less than what was demanded, ensuring integrity and consistency in token balances. The actual behavior; however, lacks this safeguard, allowing discrepancies to go unchecked and potentially resulting in a shortfall in credited funds.
