Fujicracy / fuji-v2

Cross-chain money market aggregator
https://fuji-v2-frontend.vercel.app
15 stars 10 forks source link

permissionless vaults: lack of support for fee-on-transfer tokens #316

Open trungore opened 1 year ago

trungore commented 1 year ago

Title

Lack of supporting for Fee-on-Transfer token

Affected smart contract

https://github.com/Fujicracy/fuji-v2/blob/1b939ec84af137db430fc2aa1b4c6f15e5254003/packages/protocol/src/abstracts/BaseVault.sol#L546-L547

Description

There are ERC20 tokens that may make certain customizations to their ERC20 contracts. One type of these tokens is deflationary tokens that charge a certain fee for every transfer() or transferFrom().

Assume that the BaseVault.asset() is a deflationary one. When a user call function BaseVault.deposit(x, addr), the actual amount of asset tokens that contract received will be smaller than x. This will make the call _executeProviderAction(assets, "deposit", activeProvider) revert since the provider requires the contract transfer exactly x tokens.

Since anyone can create a vault with arbitrary asset when Chief.permissionlessDeployments == true. The user can create one with fee-on-transfer tokens, to make the the protocol totally decentrallize, the contracts should support these type of tokens.

Attack scenario

Recommendation

Remember to calculate the actual amount token received by subtracting the balance of contract after and before the transferring.