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

UNI-1030 check reverted when one of the adapters is broken or paused. #71

Merged

Conversation

twygod
Copy link
Contributor

@twygod twygod commented Nov 24, 2022

No description provided.

Copy link
Member

@maxweng maxweng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@twygod do you think we can add an integration/simulation test here to make sure the changes will work when the underlying lending market failed?

@twygod
Copy link
Contributor Author

twygod commented Dec 3, 2022

underlying lending market failed

I don't think it is necessary. We only need to test whether the assetmanager is executed correctly when the underlying lending market failed. The unit test is enough

Copy link

@dmitriia dmitriia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok.

Notice that now all the distribution that failed to be allocated with deposit() will go to the very last strategy:

uint256 tokenSupply = token.balanceOf(address(this));
for (uint256 i = 0; i < percentagesLength; i++) {
IMoneyMarketAdapter moneyMarket = supportedMoneyMarkets[i];
uint256 amountToDeposit = (tokenSupply * percentages[i]) / 10000;
if (amountToDeposit == 0) continue;
token.safeTransfer(address(moneyMarket), amountToDeposit);
moneyMarket.deposit(tokenAddress);
}
uint256 remainingTokens = token.balanceOf(address(this));
IMoneyMarketAdapter lastMoneyMarket = supportedMoneyMarkets[supportedMoneyMarketsSize - 1];
if (remainingTokens > 0) {
token.safeTransfer(address(lastMoneyMarket), remainingTokens);
lastMoneyMarket.deposit(tokenAddress);
}

        uint256 tokenSupply = token.balanceOf(address(this));

        for (uint256 i = 0; i < percentagesLength; i++) {
            IMoneyMarketAdapter moneyMarket = supportedMoneyMarkets[i];
            uint256 amountToDeposit = (tokenSupply * percentages[i]) / 10000;
            if (amountToDeposit == 0) continue;
            token.safeTransfer(address(moneyMarket), amountToDeposit);
            moneyMarket.deposit(tokenAddress);
        }

        uint256 remainingTokens = token.balanceOf(address(this));

        IMoneyMarketAdapter lastMoneyMarket = supportedMoneyMarkets[supportedMoneyMarketsSize - 1];
        if (remainingTokens > 0) {
            token.safeTransfer(address(lastMoneyMarket), remainingTokens);
            lastMoneyMarket.deposit(tokenAddress);
        }

I.e. when moneyMarket.deposit(tokenAddress) fails and return false it isn't treated on the spot with some kind of redistribution, but all the unallocated funds will go to the last strategy.

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

Successfully merging this pull request may close these issues.

4 participants