Skip to content

Commit d105495

Browse files
committed
Mimimum credits granted while gravity is doing sketchy stuff
1 parent 6a4e860 commit d105495

File tree

1 file changed

+5
-1
lines changed
  • web/src/app/api/v1/ads/impression

1 file changed

+5
-1
lines changed

web/src/app/api/v1/ads/impression/_post.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type { NextRequest } from 'next/server'
1919

2020
// Revenue share: users get 75% of payout as credits
2121
const AD_REVENUE_SHARE = 0.75
22+
const MINIMUM_CREDITS_GRANTED = 0.02
2223

2324
// Rate limiting: max impressions per user per hour
2425
const MAX_IMPRESSIONS_PER_HOUR = 60
@@ -224,7 +225,10 @@ export async function postAdImpression(params: {
224225
// Calculate credits to grant (75% of payout, converted to credits)
225226
// Payout is in dollars, credits are 1:1 with cents, so multiply by 100
226227
const userShareDollars = payout * AD_REVENUE_SHARE
227-
const creditsToGrant = Math.floor(userShareDollars * 100)
228+
const creditsToGrant = Math.max(
229+
MINIMUM_CREDITS_GRANTED,
230+
Math.floor(userShareDollars * 100),
231+
)
228232

229233
// Grant credits if any
230234
let creditsGranted = 0

0 commit comments

Comments
 (0)