Skip to content

Commit

Permalink
0 slashSD and penalty case
Browse files Browse the repository at this point in the history
  • Loading branch information
Manoj Patra committed Apr 17, 2023
1 parent a6c0b4c commit 3877222
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions contracts/SDCollateral.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ contract SDCollateral is ISDCollateral, Initializable, AccessControlUpgradeable,
function slashSD(address _operator, uint256 _sdToSlash) internal returns (uint256 _sdSlashed) {
uint256 sdBalance = operatorSDBalance[_operator];
_sdSlashed = Math.min(_sdToSlash, sdBalance);
if (_sdSlashed == 0) {
return 0;
}
operatorSDBalance[_operator] -= _sdSlashed;
totalSDCollateral -= _sdSlashed;
IAuction(staderConfig.getAuctionContract()).createLot(_sdSlashed);
Expand Down
4 changes: 2 additions & 2 deletions contracts/ValidatorWithdrawalVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract ValidatorWithdrawalVault is
emit DistributedRewards(userShare, operatorShare, protocolShare);
}

function settleFunds() external override nonReentrant {
function settleFunds() external override nonReentrant returns (uint256 _sdSlashed) {
if (!isWithdrawnValidator() || vaultSettleStatus) {
revert ValidatorNotWithdrawnOrSettled();
}
Expand All @@ -86,7 +86,7 @@ contract ValidatorWithdrawalVault is
uint256 penaltyAmount = getPenaltyAmount();

if (operatorShare < penaltyAmount) {
ISDCollateral(staderConfig.getSDCollateral()).slashValidatorSD(validatorId, poolId);
_sdSlashed = ISDCollateral(staderConfig.getSDCollateral()).slashValidatorSD(validatorId, poolId);
penaltyAmount = operatorShare;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IValidatorWithdrawalVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface IValidatorWithdrawalVault {
// methods
function distributeRewards() external;

function settleFunds() external;
function settleFunds() external returns (uint256 _sdSlashed);

// setters
function updateStaderConfig(address _staderConfig) external;
Expand Down

0 comments on commit 3877222

Please sign in to comment.