-
Notifications
You must be signed in to change notification settings - Fork 12
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
UNI-1030 check reverted when one of the adapters is broken or paused. #71
Conversation
There was a problem hiding this 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?
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 |
308e89a
to
21d5afa
Compare
There was a problem hiding this 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:
union-v2-contracts/contracts/asset/AssetManager.sol
Lines 531 to 547 in 49d1a72
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.
No description provided.