Skip to content

Commit ee14c80

Browse files
Skip insert when shares = 0 in distributor
1 parent 8bc8cb1 commit ee14c80

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

apps/distributor/src/distributorv2.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,12 @@ export class DistributorV2Worker {
415415

416416
if (sendCeilingData && sendCeilingData.weight > 0n) {
417417
const scaledPreviousReward = previousReward / BigInt(sendSlash.scaling_divisor)
418+
const cappedSendScore =
419+
sendCeilingData.weight > scaledPreviousReward
420+
? scaledPreviousReward
421+
: sendCeilingData.weight
418422
if (scaledPreviousReward > 0n) {
419-
const slashPercentage = (sendCeilingData.weight * PERC_DENOM) / scaledPreviousReward
423+
const slashPercentage = (cappedSendScore * PERC_DENOM) / scaledPreviousReward
420424
amountAfterSlash = (amount * slashPercentage) / PERC_DENOM
421425
} else {
422426
amountAfterSlash = 0n
@@ -533,6 +537,11 @@ export class DistributorV2Worker {
533537
fixedPoolAmountsByAddress[share.address]?.amountAfterSlash || 0n
534538
const amountAfterSlash = hodlerPoolAmountAfterSlash + fixedPoolAmountAfterSlash
535539

540+
// Skip if amountAfterSlash is 0
541+
if (amountAfterSlash <= 0n) {
542+
return null
543+
}
544+
536545
// Update totals
537546
totalAmount += amount
538547
totalHodlerPoolAmount += hodlerPoolAmount

0 commit comments

Comments
 (0)