diff --git a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol index 8c754db..19921b3 100644 --- a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol +++ b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol @@ -159,39 +159,43 @@ contract BondEscalationResolutionModule is AccessControllerModule, IBondEscalati if (_escalation.resolution == Resolution.Unresolved) revert BondEscalationResolutionModule_NotResolved(); - uint256 _pledgerBalanceBefore; - uint256 _pledgerProportion; - uint256 _amountToRelease; RequestParameters memory _params = decodeRequestData(_request.resolutionModuleData); + address _pledger = _accessControl.user; + { + uint256 _pledgerBalanceBefore; uint256 _reward; if (_escalation.resolution == Resolution.DisputerWon) { - _pledgerBalanceBefore = pledgesForDispute[_disputeId][_accessControl.user]; - pledgesForDispute[_disputeId][_accessControl.user] -= _pledgerBalanceBefore; - _pledgerProportion = FixedPointMathLib.mulDivDown(_pledgerBalanceBefore, BASE, _escalation.pledgesFor); - _reward = FixedPointMathLib.mulDivDown(_escalation.pledgesAgainst, _pledgerProportion, BASE); - _amountToRelease = _reward + _pledgerBalanceBefore; + _pledgerBalanceBefore = pledgesForDispute[_disputeId][_pledger]; + pledgesForDispute[_disputeId][_pledger] -= _pledgerBalanceBefore; + _reward = FixedPointMathLib.mulDivDown( + _escalation.pledgesAgainst, + FixedPointMathLib.mulDivDown(_pledgerBalanceBefore, BASE, _escalation.pledgesFor), + BASE + ); _claimPledge({ _request: _request, _dispute: _dispute, - _amountToRelease: _amountToRelease, - _pledge: _accessControl.user, + _amountToRelease: _reward + _pledgerBalanceBefore, + _pledger: _pledger, _resolution: _escalation.resolution, _params: _params }); } else if (_escalation.resolution == Resolution.DisputerLost) { - _pledgerBalanceBefore = pledgesAgainstDispute[_disputeId][_accessControl.user]; - pledgesAgainstDispute[_disputeId][_accessControl.user] -= _pledgerBalanceBefore; - _pledgerProportion = FixedPointMathLib.mulDivDown(_pledgerBalanceBefore, BASE, _escalation.pledgesAgainst); - _reward = FixedPointMathLib.mulDivDown(_escalation.pledgesFor, _pledgerProportion, BASE); - _amountToRelease = _reward + _pledgerBalanceBefore; + _pledgerBalanceBefore = pledgesAgainstDispute[_disputeId][_pledger]; + pledgesAgainstDispute[_disputeId][_pledger] -= _pledgerBalanceBefore; + _reward = FixedPointMathLib.mulDivDown( + _escalation.pledgesFor, + FixedPointMathLib.mulDivDown(_pledgerBalanceBefore, BASE, _escalation.pledgesAgainst), + BASE + ); _claimPledge({ _request: _request, _dispute: _dispute, - _amountToRelease: _amountToRelease, - _pledge: _accessControl.user, + _amountToRelease: _reward + _pledgerBalanceBefore, + _pledger: _pledger, _resolution: _escalation.resolution, _params: _params }); @@ -200,28 +204,28 @@ contract BondEscalationResolutionModule is AccessControllerModule, IBondEscalati if (_escalation.resolution == Resolution.NoResolution) { { - uint256 _pledgerBalanceFor = pledgesForDispute[_disputeId][_accessControl.user]; + uint256 _pledgerBalanceFor = pledgesForDispute[_disputeId][_pledger]; if (_pledgerBalanceFor > 0) { - pledgesForDispute[_disputeId][_accessControl.user] -= _pledgerBalanceFor; + pledgesForDispute[_disputeId][_pledger] -= _pledgerBalanceFor; _claimPledge({ _request: _request, _dispute: _dispute, _amountToRelease: _pledgerBalanceFor, - _pledge: _accessControl.user, + _pledger: _pledger, _resolution: _escalation.resolution, _params: _params }); } } { - uint256 _pledgerBalanceAgainst = pledgesAgainstDispute[_disputeId][_accessControl.user]; + uint256 _pledgerBalanceAgainst = pledgesAgainstDispute[_disputeId][_pledger]; if (_pledgerBalanceAgainst > 0) { - pledgesAgainstDispute[_disputeId][_accessControl.user] -= _pledgerBalanceAgainst; + pledgesAgainstDispute[_disputeId][_pledger] -= _pledgerBalanceAgainst; _claimPledge({ _request: _request, _dispute: _dispute, _amountToRelease: _pledgerBalanceAgainst, - _pledge: _accessControl.user, + _pledger: _pledger, _resolution: _escalation.resolution, _params: _params });