User should not receive rewards for the rebalance period, when protocol was blacklisted, because of unpredicted behaviour of protocol price
User should not receive rewards for the rebalance period, when protocol was blacklisted, because of unpredicted behaviour of protocol price.\\nWhen user allocates derby tokens to some underlying protocol, he receive rewards according to the exchange price of that protocols token. This reward can be positive or negative. Rewards of protocol are set to `Game` contract inside `settleRewards` function and they are accumulated for user, once he calls `rebalanceBasket`.\\n```\\n  function storePriceAndRewards(uint256 _totalUnderlying, uint256 _protocolId) internal {\\n    uint256 currentPrice = price(_protocolId);\\n    if (lastPrices[_protocolId] == 0) {\\n      lastPrices[_protocolId] = currentPrice;\\n      return;\\n    }\\n\\n\\n    int256 priceDiff = int256(currentPrice - lastPrices[_protocolId]);\\n    int256 nominator = (int256(_totalUnderlying * performanceFee) * priceDiff);\\n    int256 totalAllocatedTokensRounded = totalAllocatedTokens / 1E18;\\n    int256 denominator = totalAllocatedTokensRounded * int256(lastPrices[_protocolId]) * 100; // * 100 cause perfFee is in percentages\\n\\n\\n    if (totalAllocatedTokensRounded == 0) {\\n      rewardPerLockedToken[rebalancingPeriod][_protocolId] = 0;\\n    } else {\\n      rewardPerLockedToken[rebalancingPeriod][_protocolId] = nominator / denominator;\\n    }\\n\\n\\n    lastPrices[_protocolId] = currentPrice;\\n  }\\n```\\n\\nEvery time, previous price of protocol is compared with current price.\\nIn case if some protocol is hacked, there is `Vault.blacklistProtocol` function, that should withdraw reserves from protocol and mark it as blacklisted. The problem is that because of the hack it's not possible to determine what will happen with exhange rate of protocol. It can be 0, ot it can be very small or it can be high for any reasons. But protocol still accrues rewards per token for protocol, even that it is blacklisted. Because of that, user that allocated to that protocol can face with accruing very big negative or positive rewards. Both this cases are bad.\\nSo i believe that in case if protocol is blacklisted, it's better to set rewards as 0 for it.\\nExample. 1.User allocated 100 derby tokens for protocol A 2.Before `Vault.rebalance` call, protocol A was hacked which made it exchangeRate to be not real. 3.Derby team has blacklisted that protocol A. 4.Vault.rebalance is called which used new(incorrect) exchangeRate of protocol A in order to calculate `rewardPerLockedToken` 5.When user calls rebalance basket next time, his rewards are accumulated with extremely high/low value.
Issue User should not receive rewards for the rebalance period, when protocol was blacklisted, because of unpredicted behaviour of protocol price\\nIn case if protocol is blacklisted, then set `rewardPerLockedToken` to 0 inside `storePriceAndRewards` function.
User's rewards calculation is unpredictable.
```\\n  function storePriceAndRewards(uint256 _totalUnderlying, uint256 _protocolId) internal {\\n    uint256 currentPrice = price(_protocolId);\\n    if (lastPrices[_protocolId] == 0) {\\n      lastPrices[_protocolId] = currentPrice;\\n      return;\\n    }\\n\\n\\n    int256 priceDiff = int256(currentPrice - lastPrices[_protocolId]);\\n    int256 nominator = (int256(_totalUnderlying * performanceFee) * priceDiff);\\n    int256 totalAllocatedTokensRounded = totalAllocatedTokens / 1E18;\\n    int256 denominator = totalAllocatedTokensRounded * int256(lastPrices[_protocolId]) * 100; // * 100 cause perfFee is in percentages\\n\\n\\n    if (totalAllocatedTokensRounded == 0) {\\n      rewardPerLockedToken[rebalancingPeriod][_protocolId] = 0;\\n    } else {\\n      rewardPerLockedToken[rebalancingPeriod][_protocolId] = nominator / denominator;\\n    }\\n\\n\\n    lastPrices[_protocolId] = currentPrice;\\n  }\\n```\\n