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

Accrued.rewardsAccrued can be zero #834

Open
Rubilmax opened this issue May 12, 2023 · 1 comment
Open

Accrued.rewardsAccrued can be zero #834

Rubilmax opened this issue May 12, 2023 · 1 comment

Comments

@Rubilmax
Copy link
Collaborator

Rubilmax commented May 12, 2023

Issue

https://github.com/morpho-org/morpho-aave-v3/blob/03cee70c50a8d0abf3c5eebdd416127fe8a54ea5/src/RewardsManager.sol#L355-357

Accrued event is emitted without regard to rewardsAccrued: sometimes, when claiming rewards for assets the user didn't supply/borrow for, Accrued events are emitted because the reward's asset index was updated, without the user's data being updated.

Recommendation

Split the Accrued event in 2:

  • RewardIndexUpdated(asset, reward, newAssetIndex): emitted whenever the asset's index is updated in storage
  • RewardAccrued(asset, reward, user, rewardsAccrued): emitted whenever a user's rewards was accrued

What I think we can learn

  • The condition rewardDataUpdated || userDataUpdated is too broad: each condition corresponds to a storage update, and should thus be bound to independent events
@MerlinEgalite
Copy link
Contributor

Inspired by Aave's code but agree this was a mistake.

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

No branches or pull requests

2 participants