Skip to content

Latest commit

 

History

History
55 lines (34 loc) · 1.5 KB

003.md

File metadata and controls

55 lines (34 loc) · 1.5 KB

Early Viridian Haddock

High

_stablecoinSwap() should revert if feeAmount is > 0 but can't collect fee

Summary

Block https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/stablecoin/StablecoinHandler.sol#L148-L156 is in charge to collect fees but it won't transfer the fee amount is either ss.stablecoinFeeCurrency or ss.stablecoinFeeSafe are equal to address(0)

Root Cause

The logic is broken because only in the case where ss.stablecoinFeeCurrency AND ss.stablecoinFeeSafe are != address(0), then fees are collected, while the logic should be:

  1. check if feeAmount > 0
  2. if true, revert if ss.stablecoinFeeCurrency or ss.stablecoinFeeSafe are == address(0)
  3. collect fees

see #mitigation

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

No response

PoC

No response

Mitigation

Replace block https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/stablecoin/StablecoinHandler.sol#L148-L156 with:

if (ss.feeAmount > 0) {
    if (ss.stablecoinFeeCurrency == address(0)) revert ZeroValueInput("<ERROR MESSAGE HERE>");
    if (ss.stablecoinFeeSafe == address(0)) revert ZeroValueInput("<ERROR MESSAGE HERE>");

    ERC20PermitUpgradeable(ss.stablecoinFeeCurrency).safeTransferFrom(
        wallet,
        ss.stablecoinFeeSafe,
        ss.feeAmount
    );
}