Skip to content

Commit 7d90ad2

Browse files
committed
fix: underflow in getIdleStake (TRST-L14)
1 parent d6d376c commit 7d90ad2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/horizon/contracts/staking/HorizonStakingBase.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ abstract contract HorizonStakingBase is
268268
* TODO: update the calculation after the transition period.
269269
*/
270270
function _getIdleStake(address _serviceProvider) internal view returns (uint256) {
271-
return
272-
_serviceProviders[_serviceProvider].tokensStaked -
273-
_serviceProviders[_serviceProvider].tokensProvisioned -
274-
_serviceProviders[_serviceProvider].__DEPRECATED_tokensAllocated -
271+
uint256 tokensUsed = _serviceProviders[_serviceProvider].tokensProvisioned +
272+
_serviceProviders[_serviceProvider].__DEPRECATED_tokensAllocated +
275273
_serviceProviders[_serviceProvider].__DEPRECATED_tokensLocked;
274+
uint256 tokensStaked = _serviceProviders[_serviceProvider].tokensStaked;
275+
return tokensStaked > tokensUsed ? tokensStaked - tokensUsed : 0;
276276
}
277277

278278
/**

0 commit comments

Comments
 (0)