code-423n4 / 2021-11-yaxis-findings

0 stars 0 forks source link

Tokens with fee on transfer are not supported #49

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

There are ERC20 tokens that charge fee for every transfer() or transferFrom().

In the current implementation, YaxisVaultAdapter.sol#withdraw() assumes that the received amount is the same as the transfer amount.

https://github.com/code-423n4/2021-11-yaxis/blob/146febcb61ae7fe20b0920849c4f4bbe111c6ba7/contracts/v3/alchemix/adapters/YaxisVaultAdapter.sol#L68-L72

function withdraw(address _recipient, uint256 _amount) external override onlyAdmin {
    vault.withdraw(_tokensToShares(_amount));
    address _token = vault.getToken();
    IDetailedERC20(_token).safeTransfer(_recipient, _amount);
}

Recommended

Consider calling balanceOf() to get the actual balances.

Xuefeng-Zhu commented 2 years ago

not does apply for our use case

0xleastwood commented 2 years ago

As the vault token adheres to the VaultToken contract, there is no expectation that fee on transfer tokens may be used instead of the provided implementation.

0xleastwood commented 2 years ago

Will keep this as non-critical for future reference.