-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Using redeem() on CompoundV2 wrapper with current implementation, leveraging LibCompound, fails to return appropriate assets calculation when calling redeem(). Issue doesn't touch withdraw().
Exchanging totalAsset() implementation from LibCompound's viewUnderlyingBalanceOf() too:
function totalAssets() public view virtual override returns (uint256) {
return cToken.balanceOf(address(this)).mulWadDown(cToken.exchangeRateStored());
}
fixes shares/assets calculation.
Otherwise, inspecting state change during redeem() yields wrong amount of totalAssets() (AUM), example with hh console.log
totalAssets() 3177334480600619999224 --- with LibCompound
totalAssets() 999999999999801353087 --- with hardcoded division by exchangeRateStored()
I may be missing something as I didn't fully inspect where things go south in LibCompound and my implementation of CompoundWrapper is also protocol specific. Can make a PR later if Issue makes sense.