Skip to content

Commit

Permalink
feat: reduce storage reads
Browse files Browse the repository at this point in the history
  • Loading branch information
ckartik committed Sep 17, 2024
1 parent a998e0b commit 3e97502
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions contracts/contracts/core/ProviderRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,16 @@ contract ProviderRegistry is
// this is to prevent underflow and ensure the contract doesn't revert
// We also emit
uint256 providerStake = providerStakes[provider];
if (providerStakes[provider] < residualAmt + penaltyFee) {
emit InsufficientFundsToSlash(provider, providerStakes[provider], residualAmt, penaltyFee);
if (providerStakes[provider] < residualAmt) {
if (providerStake < residualAmt + penaltyFee) {
emit InsufficientFundsToSlash(provider, providerStake, residualAmt, penaltyFee);
if (providerStake < residualAmt) {
penaltyFee = 0;
residualAmt = providerStakes[provider];
residualAmt = providerStake;
} else {
penaltyFee = providerStakes[provider] - residualAmt;
penaltyFee = providerStake - residualAmt;
}
}
providerStakes[provider] -= residualAmt + penaltyFee;
providerStake -= residualAmt + penaltyFee;

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

0 comments on commit 3e97502

Please sign in to comment.