Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: CompoundERC4626 redeem() #5

Open
shortdoom opened this issue Sep 5, 2022 · 0 comments
Open

bug: CompoundERC4626 redeem() #5

shortdoom opened this issue Sep 5, 2022 · 0 comments

Comments

@shortdoom
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant