Skip to content

Commit d80fe64

Browse files
Merge pull request #896 from 0xsend/fix_send_ceiling_functions_again
Fix send ceiling functions again
2 parents f73680a + ee14c80 commit d80fe64

File tree

3 files changed

+379
-12
lines changed

3 files changed

+379
-12
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

supabase/database-generated.types.ts

+22-11
Original file line numberDiff line numberDiff line change
@@ -1339,17 +1339,28 @@ export type Database = {
13391339
user_id: string
13401340
}
13411341
}
1342-
sum_qualification_sends: {
1343-
Args: {
1344-
distribution_number: number
1345-
send_ceiling: number
1346-
}
1347-
Returns: {
1348-
user_id: string
1349-
amount: number
1350-
sent_to: string[]
1351-
}[]
1352-
}
1342+
sum_qualification_sends:
1343+
| {
1344+
Args: {
1345+
distribution_number: number
1346+
}
1347+
Returns: {
1348+
user_id: string
1349+
amount: number
1350+
sent_to: string[]
1351+
}[]
1352+
}
1353+
| {
1354+
Args: {
1355+
distribution_number: number
1356+
send_ceiling: number
1357+
}
1358+
Returns: {
1359+
user_id: string
1360+
amount: number
1361+
sent_to: string[]
1362+
}[]
1363+
}
13531364
tag_search: {
13541365
Args: {
13551366
query: string

0 commit comments

Comments
 (0)