The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: low
Invalid

Protocol cannot swap WETH token if it is a collateral

Summary

The swap function is used to swap collateral tokens between themselves. The issue is if WETH is used as collateral, the function will fail.

Vulnerability Details

The swap function calls getSwapAddressFor to handle native eth.

return _token.addr == address(0) ? ISmartVaultManagerV3(manager).weth() : _token.addr;

This function basically tells the contract that if the symbol passed correspond to native ETH, then the contract rewrites the address as WETH. Later after setting up the swap parameters, the function executes one of two logics.

inToken == ISmartVaultManagerV3(manager).weth()
? executeNativeSwapAndFee(params, swapFee)
: executeERC20SwapAndFee(params, swapFee);

The issue is that if a user uses actual WETH tokens as collateral, then the function will still call executeNativeSwapAndFee instead of executeERC20SwapAndFee even though WETH is an ERC20 token. This function will then revert since it will try to send the fee amount in eth, which it doesnt have.

(bool sent,) = payable(ISmartVaultManagerV3(manager).protocol()).call{value: _swapFee}("");

This call will fail since the contract doesnt actually have any eth, and has only WETH.

Impact

Loans using WETH as collateral will have broken swaps.

Tools Used

Manual Review

Recommendations

Treat NATIVE as different from WETH, like it is done in curve protocol, where native ETH is represented in the pool as 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE. This will void conflicts with WETH.

Updates

Lead Judging Commences

hrishibhat Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

informational/invalid

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.