DeFiFoundrySolidity
16,653 OP
View results
Submission Details
Severity: medium
Invalid

Unnecessary Calculation of unexchangedBalance

Summary
In StrategyMainnet.sol in _freeFunds we want to withdraw to address(this) from transmuter the available funds (unexchangedFunds). The calculation for unexchangedFunds is incorrect

Vulnerability Details
https://github.com/alchemix-finance/v2-foundry/blob/master/src/TransmuterV2.sol#L353-L370
When we call

uint256 totalAvailabe = transmuter.getUnexchangedBalance(address(this));

It should calculate the totalAvailable balance for us to withdraw, however the calculations there is incorrect, since it gets the current unexchangedBalance and deducts it with exchanged :

unexchangedBalance -= exchanged;

This is incorrect since everywhere in those contract unexchangedBalance keeps a right track of itself same for the exchange also. For example when we do withdraw from Transmuter to our contract it keeps a track by

unexchangedDelta: -SafeCast.toInt256(amount)

same applies for the exchangedBalance.

So thats why the deduction from unexchangedBalance -= exchanged is inccorect. getUnexchangedBalanceshould return just unexchangedBalance. so then the checks if the amount is greater or not to be correct.

If we use the original logic, it will deduct our already exchanged tokens from the unexchangedBalance (which is incorrect like i said since in every operation those both values are updated so its not needed of deduction inside this function). and if we do this deduction the real left balance inside transmuter will not be correct and the transfered amount wont be correct.

Impact
Incorrect calculation of left balance inside transmuter contract (Leads to User not being able to get all his funds out of the contract)

Tools Used
Manual review

Recommendations

Return just the getUnexchangedBalance without deducting it from exchangedBalance

Updates

Appeal created

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope
0xkann Submitter
7 months ago
inallhonesty Lead Judge
7 months ago
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

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