Skip to content

Commit

Permalink
change stake values only when amount is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCardinalError committed Nov 8, 2024
1 parent 32f9d4a commit 025c379
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,15 @@ contract StakeRegistry is AccessControl, Pausable {
}

if (_stakingSet != 0 && !addressNotFrozen(msg.sender)) revert Frozen();
uint256 updatedPotentialStake = stakes[msg.sender].potentialStake + _addAmount;
uint256 updatedCommittedStake = updatedPotentialStake / (OracleContract.currentPrice() * 2 ** _height);

uint256 updatedPotentialStake = stakes[msg.sender].potentialStake;
uint256 updatedCommittedStake = stakes[msg.sender].committedStake;

// Only update stake values if _addAmount is greater than 0
if (_addAmount > 0) {
updatedPotentialStake = stakes[msg.sender].potentialStake + _addAmount;
updatedCommittedStake = updatedPotentialStake / (OracleContract.currentPrice() * 2 ** _height);
}

stakes[msg.sender] = Stake({
overlay: _newOverlay,
Expand Down

0 comments on commit 025c379

Please sign in to comment.