Skip to content

Commit

Permalink
Critical bug fix to RariFundManager._withdrawFrom
Browse files Browse the repository at this point in the history
Before this bug fix, RariFundManager._withdrawFrom may have burned more RFT than necessary when processing a user's withdrawal. After withdrawing from a pool, to update the pool balance cache, instead of subtracting the amount actually withdrawn from the pool, the total withdrawal amount was subtracted from the pool balance cache. This could have caused the cached fund balance used in the RFT burn amount calculation to be lower than it should have been, causing the amount of RFT burned to be higher than it should have been.
  • Loading branch information
davidlucid committed Aug 16, 2020
1 parent cc641c1 commit 9059e8c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contracts/RariFundManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,8 @@ contract RariFundManager is Ownable {
_rariFundController.withdrawFromPoolKnowingBalance(pool, currencyCode, poolAmount, poolBalance);

if (pool == 0) {
for (uint256 j = 0; j < _dydxBalancesCache.length; j++) if (_dydxTokenAddressesCache[j] == erc20Contract) _dydxBalancesCache[j] = poolBalance.sub(amount);
} else _poolBalanceCache[currencyCode][pool] = poolBalance.sub(amount);
for (uint256 j = 0; j < _dydxBalancesCache.length; j++) if (_dydxTokenAddressesCache[j] == erc20Contract) _dydxBalancesCache[j] = poolBalance.sub(poolAmount);
} else _poolBalanceCache[currencyCode][pool] = poolBalance.sub(poolAmount);

contractBalance = contractBalance.add(poolAmount);
}
Expand Down

0 comments on commit 9059e8c

Please sign in to comment.