Skip to content

Commit

Permalink
feat: fixes bug around not slashing the provider balance.
Browse files Browse the repository at this point in the history
  • Loading branch information
ckartik committed Sep 17, 2024
1 parent 3e97502 commit 840d446
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions contracts/contracts/core/ProviderRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,18 @@ contract ProviderRegistry is
) external nonReentrant onlyPreConfirmationEngine whenNotPaused {
uint256 residualAmt = (amt * residualBidPercentAfterDecay * PRECISION) / PERCENT;
uint256 penaltyFee = (residualAmt * uint256(feePercent) * PRECISION) / PERCENT;
// if the provider's stake is less than the residual amount + penalty fee, we need to adjust the residual amount and penalty fee
// this is to prevent underflow and ensure the contract doesn't revert
// We also emit

uint256 providerStake = providerStakes[provider];


if (providerStake < residualAmt + penaltyFee) {
emit InsufficientFundsToSlash(provider, providerStake, residualAmt, penaltyFee);
if (providerStake < residualAmt) {
penaltyFee = 0;
residualAmt = providerStake;
} else {
penaltyFee = providerStake - residualAmt;
}
penaltyFee = providerStake - residualAmt;
}
providerStake -= residualAmt + penaltyFee;
providerStakes[provider] -= residualAmt + penaltyFee;

penaltyFeeTracker.accumulatedAmount += penaltyFee;
if (FeePayout.isPayoutDue(penaltyFeeTracker)) {
Expand Down

0 comments on commit 840d446

Please sign in to comment.