Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

_calculateTotalEarningPower formula can be simplified #34

Open
CergyK opened this issue Dec 6, 2024 · 2 comments
Open

_calculateTotalEarningPower formula can be simplified #34

CergyK opened this issue Dec 6, 2024 · 2 comments
Labels
Low/Info A Low/Info severity issue.

Comments

@CergyK
Copy link
Collaborator

CergyK commented Dec 6, 2024

Description

_calculateTotalEarningPower can be simplified to the equivalent formula:

GovernanceStaker.sol#L759-L768:

  function _calculateTotalEarningPower(
    uint256 _depositOldEarningPower,
    uint256 _depositNewEarningPower,
    uint256 _totalEarningPower
  ) internal pure returns (uint256 _newTotalEarningPower) {
-    if (_depositNewEarningPower >= _depositOldEarningPower) {
-      return _totalEarningPower + (_depositNewEarningPower - _depositOldEarningPower);
-    }
-    return _totalEarningPower - (_depositOldEarningPower - _depositNewEarningPower);
+    return _totalEarningPower + _depositNewEarningPower - _depositOldEarningPower;
  }
@alexkeating
Copy link

Will fix

@CergyK
Copy link
Collaborator Author

CergyK commented Dec 16, 2024

Fixed by withtally/staker#89

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Low/Info A Low/Info severity issue.
Projects
None yet
Development

No branches or pull requests

2 participants