Platform: Code4rena
Start Date: 09/11/2021
Pot Size: $75,000 USDC
Total HM: 57
Participants: 27
Period: 7 days
Judge: alcueca
Total Solo HM: 49
Id: 52
League: ETH
Rank: 19/27
Findings: 1
Award: $295.08
🌟 Selected for report: 0
🚀 Solo Findings: 0
295.0764 USDC - $295.08
shri4net
Unintended Fee is charged to user while using 'leave' function in XVader.sol as part of the voting/governance.
Ref contracts/x-vader/XVader.sol, function leave Ref contracts/tokens/Vader.sol, function _transfer
Example, User locks 100 vader and mints xVader shares via the enter function. Later on, user will Claim back the Vader via the leave function. During the leave, user gets less than 100 Vader, due to the tax being computed and substracted from the locked amount.
File : contracts/x-vader/XVader.sol 50 function leave(uint256 _shares) external { .. // Gets the amount of xVader in existence .. uint256 totalShares = totalSupply(); .. // Calculates the amount of vader the xVader is worth .. uint256 vaderAmount = ( .. _shares * vader.balanceOf(address(this)) .. ) / totalShares; .. .. _burn(msg.sender, _shares); 59 vader.transfer(msg.sender, vaderAmount); .. }
Comment: Since xVader is not in untaxed bracket, the amount transferred back will be tax deducted.
File : contracts/tokens/Vader.sol 250 function _transfer( ... address sender, ... address recipient, ... uint256 amount ... ) internal override { ... if (untaxed[msg.sender]) ... return ERC20._transfer(sender, recipient, amount); ... ... uint256 fee = calculateFee(); ... ... uint256 tax = (amount * fee) / _MAX_BASIS_POINTS; ... 262 amount -= tax; ... ... _burn(sender, tax); ... ... ERC20._transfer(sender, recipient, amount); ... }
Manual code review and unit test of issue
Add the XVader contract address also to the untaxed[] along with _vest, etc., in function setComponents
Modified code snippet (line 148) : function setComponents( ..., XVader _xvader, // To be added ... ) external onlyOwner { .... untaxed[address(_xvader)] = true; // To be added
#0 - 0xstormtrooper
2021-11-16T00:42:02Z