@levrbet/shared 0.5.75 → 0.5.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,655 +7,3 @@ datasource db {
7
7
  provider = "mongodb"
8
8
  url = env("MONGO_URI")
9
9
  }
10
-
11
- enum GamePhase {
12
- PreGame
13
- LiveGame
14
- PostGame
15
- Cancelled
16
- }
17
-
18
- enum Sides {
19
- A
20
- B
21
- C
22
- }
23
-
24
- enum MarketType {
25
- FullTimeWinner
26
- OverUnder
27
- }
28
-
29
- enum MarketStatus {
30
- Open
31
- Closed
32
- Settled
33
- Refunded
34
- }
35
-
36
- enum ScoringType {
37
- Points
38
- Goals
39
- }
40
-
41
- enum FixtureStatus {
42
- Scheduled
43
- Cancelled
44
- }
45
-
46
- enum SportGroup {
47
- Football
48
- Basketball
49
- Baseball
50
- Soccer
51
- Hockey
52
- Esports
53
- }
54
-
55
- enum LevrService {
56
- Auth
57
- Orderbook
58
- OracleCore
59
- OraclePeriphery
60
- OracleProcessor
61
- Leaderboard
62
- Lab
63
- LiquidationEngine
64
- LambdaFunctions
65
- }
66
-
67
- model Provider {
68
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
69
- name String @unique
70
- providerUrl String @unique
71
-
72
- createdAt DateTime @default(now())
73
- updatedAt DateTime @updatedAt
74
- }
75
-
76
- model Tournament {
77
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
78
- levrTournamentId String @unique
79
- chainId Int
80
- name String
81
- description String
82
- bannerUrl String
83
- startDate DateTime
84
- endDate DateTime
85
-
86
- games LevrGame[]
87
- leagues League[]
88
-
89
- createdAt DateTime @default(now())
90
- updatedAt DateTime @updatedAt
91
-
92
- @@unique([chainId, name])
93
- @@unique([chainId, description])
94
- @@unique([chainId, bannerUrl])
95
- @@index([name])
96
- }
97
-
98
- model Sport {
99
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
100
- levrSportId String @unique
101
- name String @unique
102
- periodType String
103
- scoringType ScoringType
104
- standardDurationMs Int
105
- standardPeriods Int
106
- periodDuration Int?
107
- hasDrawMarket Boolean
108
- sportGroup SportGroup
109
-
110
- leagues League[]
111
-
112
- createdAt DateTime @default(now())
113
- updatedAt DateTime @updatedAt
114
- }
115
-
116
- model League {
117
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
118
- name String @unique
119
- abbreviation String
120
- country String
121
- levrLeagueId String @unique
122
- opticOddsLeagueId String
123
- lsportsLeagueId String @unique
124
- logoKey String
125
- logoUrl String
126
-
127
- tournamentObjectId String @db.ObjectId
128
- tournament Tournament @relation(fields: [tournamentObjectId], references: [objectId])
129
- sportObjectId String @db.ObjectId
130
- sport Sport @relation(fields: [sportObjectId], references: [objectId])
131
- levrSportId String
132
-
133
- games LevrGame[]
134
- fixtures Fixture[]
135
- teams TeamData[]
136
-
137
- createdAt DateTime @default(now())
138
- updatedAt DateTime @updatedAt
139
- }
140
-
141
- model TeamData {
142
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
143
- levrTeamName String
144
- levrTeamOfficialAbbreviation String
145
- lsportsTeamName String
146
- opticOddsTeamName String
147
- lsportsTeamId String
148
- opticOddsTeamId String
149
- levrTeamId String
150
- opticOddsTeamLogoUrl String
151
- levrTeamLogoUrlAsHome String @unique
152
- levrTeamLogoUrlAsAway String @unique
153
- leagueObjectId String @db.ObjectId
154
- levrLeagueId String
155
- league League @relation(fields: [leagueObjectId], references: [objectId])
156
-
157
- @@unique([levrTeamId, levrTeamName, leagueObjectId])
158
- }
159
-
160
- model Fixture {
161
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
162
- levrFixtureId String @unique
163
- opticOddsFixtureId String? @unique
164
- lsportsFixtureId String? @unique
165
- seasonType String
166
- venue String
167
- eventName String
168
- location String
169
- venueLocation String
170
- fixtureDate DateTime
171
- lastUpdated DateTime
172
- homeTeam Json
173
- awayTeam Json
174
- fixtureStatus FixtureStatus
175
- sportGroup SportGroup? //optional for now so we don't break staging
176
- registeredChainIds Int[] // list of chain IDs where this fixture is registered
177
-
178
- leagueObjectId String @db.ObjectId
179
- league League @relation(fields: [leagueObjectId], references: [objectId])
180
-
181
- createdAt DateTime @default(now())
182
- updatedAt DateTime @updatedAt
183
-
184
- @@index([fixtureDate])
185
- @@index([leagueObjectId])
186
- @@index([eventName])
187
- }
188
-
189
- model Scores {
190
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
191
- scoresByPeriodHome Json
192
- scoresByPeriodAway Json
193
- totalScoresHome Float
194
- totalScoresAway Float
195
- chainId Int
196
-
197
- gameObjectId String @unique @db.ObjectId
198
- LevrGame LevrGame @relation(fields: [gameObjectId], references: [objectId])
199
-
200
- createdAt DateTime @default(now())
201
- updatedAt DateTime @updatedAt
202
- }
203
-
204
- model LevrGame {
205
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
206
- gameId Int @unique
207
- txHash String @unique
208
- chainId Int
209
- seasonType String
210
- venue String
211
- eventName String
212
- location String
213
- venueLocation String
214
- gameClock String
215
- gameProgressBps Int @default(0)
216
- paused Boolean @default(false)
217
- fixtureDate DateTime
218
- wentLiveAt DateTime?
219
- homeTeam Json // as defined in sample-data/lever/levr-game.json
220
- awayTeam Json // as defined in sample-data/lever/levr-game.json
221
- currentPeriod Int @default(0)
222
- actualDuration Float @default(0) // in milliseconds
223
- gamePhase GamePhase @default(PreGame)
224
- levrFixtureId String
225
- opticOddsFixtureId String?
226
- lsportsFixtureId String?
227
- liveScoreMatchId String?
228
-
229
- sportGroup SportGroup
230
-
231
- tournamentObjectId String @db.ObjectId
232
- fixtureObjectId String @db.ObjectId
233
- tournament Tournament @relation(fields: [tournamentObjectId], references: [objectId])
234
- leagueObjectId String @db.ObjectId
235
- league League @relation(fields: [leagueObjectId], references: [objectId])
236
- scores Scores?
237
-
238
- markets Market[]
239
-
240
- createdAt DateTime @default(now())
241
- updatedAt DateTime @updatedAt
242
-
243
- @@unique([chainId, levrFixtureId])
244
- @@unique([chainId, gameId])
245
- @@index([opticOddsFixtureId])
246
- @@index([lsportsFixtureId])
247
- @@index([eventName])
248
- @@index([fixtureDate])
249
- }
250
-
251
- model Odds {
252
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
253
- txHash String
254
- odds Json // define for the specific market type
255
- prices Json
256
- timestamp DateTime
257
- marketType MarketType
258
- details Json? // the unique details for the odds
259
- gamePhase GamePhase
260
- gamePeriod Int
261
- gameClock Int
262
- gameProgressBps Int?
263
- chainId Int
264
- marketPhase MarketStatus
265
- provider String? // optional for now to avoid breaking staging
266
- opticOddsOddsId String? // optional for now to avoid breaking staging
267
- lsportsOddsId String? // optional for now to avoid breaking staging
268
-
269
- levrGameObjectId String @db.ObjectId
270
- marketObjectId String @db.ObjectId
271
- gameMarketId String
272
- market Market @relation(fields: [marketObjectId], references: [objectId])
273
-
274
- createdAt DateTime @default(now())
275
- updatedAt DateTime @updatedAt
276
- }
277
-
278
- model Market {
279
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
280
- chainId Int
281
- gameId Int
282
- levrMarketId String
283
- levrMarketContract String
284
- gameMarketId String @unique
285
- txHash String
286
- maturedAt DateTime?
287
- leveraged Boolean @default(false)
288
- isMatured Boolean @default(false)
289
- normalizationFactor Float
290
- marketDetails Json
291
- marketRiskAllocation Json
292
- providers Json
293
- activeProvider Json
294
- marketType MarketType
295
- status MarketStatus
296
- winner Sides?
297
- targetLine Float? // for over under markets
298
-
299
- levrGameObjectId String @db.ObjectId // new unique identifier
300
- levrGame LevrGame @relation(fields: [levrGameObjectId], references: [objectId])
301
-
302
- odds Odds[]
303
-
304
- createdAt DateTime @default(now())
305
- updatedAt DateTime @updatedAt
306
- }
307
-
308
- enum UserOddsPreference {
309
- American
310
- Decimal
311
- European
312
- }
313
-
314
- model User {
315
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
316
- walletAddress String @unique
317
- userName String?
318
- email String?
319
- referralCode String? @unique
320
- referrerCode String?
321
- timeZone String @default("UTC")
322
- preferredTimeZone String?
323
- userOddsPreference UserOddsPreference @default(American)
324
- profileImageUrl String?
325
- profileImageKey String?
326
- language String @default("en")
327
- showRiskWarnings Boolean @default(true)
328
- showPreTransactionReminders Boolean @default(true)
329
- twoFactorEnabled Boolean @default(false)
330
- autoDetectTimeZone Boolean @default(true)
331
- autoApproveTxs Boolean @default(false)
332
- requireWithdrawalConfirmation Boolean @default(true)
333
-
334
- // Inverse relations (these fix your P1012 errors)
335
- referralsMade Referral[] @relation("ReferrerRelations") // users they referred
336
- referredBy Referral[] @relation("ReferredRelations") // who referred them
337
- referralRewards ReferralReward[] @relation("UserRewards") // their reward entries
338
- transactionHistory TransactionHistory[] @relation("TransactionHistory") // transaction history
339
- notifications Notification[] @relation("UserNotifications") // in-app notifications
340
-
341
- createdAt DateTime @default(now())
342
- updatedAt DateTime @updatedAt
343
- }
344
-
345
- enum ReferralStatus {
346
- Pending
347
- Active
348
- Suspended
349
- Completed
350
- }
351
-
352
- enum GreylistStatus {
353
- None // Not flagged — included in Merkle
354
- Flagged // Active greylist — excluded from Merkle
355
- Cleared // Admin-cleared — re-included in future epochs
356
- Confirmed // Admin-confirmed fraud — permanently excluded
357
- }
358
-
359
- model Referral {
360
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
361
- referrerId String @db.ObjectId
362
- referredId String @db.ObjectId
363
- referralCode String
364
- referralSource String? // e.g. campaign or link source
365
- status ReferralStatus @default(Active)
366
- greylistStatus GreylistStatus @default(None) // Denormalized flag for fast filtering in fee computation
367
-
368
- // Relations
369
- referrer User @relation("ReferrerRelations", fields: [referrerId], references: [objectId])
370
- referred User @relation("ReferredRelations", fields: [referredId], references: [objectId])
371
-
372
- createdAt DateTime @default(now())
373
- updatedAt DateTime @updatedAt
374
-
375
- @@index([referrerId])
376
- @@index([referredId])
377
- }
378
-
379
- model ReferralEpoch {
380
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
381
- periodId String @unique
382
- periodStart DateTime
383
- periodEnd DateTime
384
- timezone String @default("America/Mexico_City")
385
- status EpochStatus @default(Active)
386
-
387
- // On-chain reward info (one root per epoch)
388
- totalFeesUsd Float?
389
- rewardPoolUsd Float?
390
- merkleRoot String?
391
- merkleTxHash String?
392
- rootPublishedAt DateTime?
393
- notes String?
394
-
395
- ReferralRewards ReferralReward[]
396
-
397
- createdAt DateTime @default(now())
398
- updatedAt DateTime @updatedAt
399
- }
400
-
401
- enum EpochStatus {
402
- Active
403
- Processing
404
- Completed
405
- Failed
406
- }
407
-
408
- enum ReferralTier {
409
- T1
410
- T2
411
- T3
412
- }
413
-
414
- model ReferralReward {
415
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
416
- userId String @db.ObjectId
417
- epochId String @db.ObjectId
418
- periodId String // denormalized for readability (e.g. "2025W45")
419
-
420
- // --- Aggregates ---
421
- referredBetVolumeUsd Float @default(0.0)
422
- referredFeeUsd Float @default(0.0)
423
- tier ReferralTier @default(T1)
424
- tierPercentage Float @default(0.025)
425
-
426
- // --- Payouts ---
427
- payoutBeforeScaleUsd Float @default(0.0)
428
- payoutScaledUsd Float @default(0.0)
429
- payoutTokenUnits String? // token base units (string for precision)
430
- scaleFactor Float?
431
-
432
- // --- Claim sync info ---
433
- isClaimedOnChain Boolean @default(false)
434
- claimedTxHash String?
435
- lastSyncedFromChainAt DateTime?
436
-
437
- createdAt DateTime @default(now())
438
- updatedAt DateTime @updatedAt
439
-
440
- // --- Relations ---
441
- user User @relation("UserRewards", fields: [userId], references: [objectId])
442
- epoch ReferralEpoch @relation(fields: [epochId], references: [objectId])
443
-
444
- @@unique([userId, periodId])
445
- @@index([epochId])
446
- @@index([userId])
447
- }
448
-
449
- enum ApiKeyScope {
450
- Read
451
- Write
452
- }
453
-
454
- model ApiKey {
455
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
456
- apiKeyId String @unique
457
- userId String
458
- ethAddress String?
459
- name String
460
- ciphertext String
461
- kmsKeyId String
462
- service LevrService? // Optional: restrict key to a specific service
463
- scopes ApiKeyScope[]
464
- isActive Boolean @default(true)
465
- expiresAt DateTime?
466
- lastUsedAt DateTime?
467
- usageCount Int @default(0)
468
- createdAt DateTime @default(now())
469
- updatedAt DateTime @updatedAt
470
-
471
- @@index([userId, isActive])
472
- @@index([service, isActive])
473
- }
474
-
475
- model AuditLog {
476
- objectId String @id @default(cuid()) @map("_id")
477
- action String // e.g., "api_key.created", "application.created", "token.validated"
478
- resourceId String? // ID of the resource being acted upon
479
- metadata Json @default("{}")
480
- ipAddress String?
481
- userAgent String?
482
- timestamp DateTime @default(now())
483
- // Relations
484
- userId String
485
-
486
- @@index([action])
487
- @@index([timestamp])
488
- @@index([userId])
489
- }
490
-
491
- enum TransactionHistoryType {
492
- Deposit
493
- Withdrawal
494
- Wager
495
- }
496
-
497
- enum TransactionHistoryStatus {
498
- Completed
499
- Pending
500
- Failed
501
- }
502
-
503
- enum TransactionHistoryDescription {
504
- BetPlaced
505
- Deposited
506
- Withdrawn
507
- }
508
-
509
- model TransactionHistory {
510
- objectId String @id @default(cuid()) @map("_id")
511
- id String
512
- type TransactionHistoryType
513
- status TransactionHistoryStatus
514
- timestamp DateTime @default(now())
515
- balance Float
516
- description TransactionHistoryDescription
517
- amount Float
518
- // Relations
519
- walletAddress String
520
- user User @relation("TransactionHistory", fields: [walletAddress], references: [walletAddress])
521
-
522
- @@index([timestamp])
523
- @@index([walletAddress])
524
- }
525
-
526
- model GreylistEntry {
527
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
528
- walletAddress String // The greylisted wallet (referrer OR referee)
529
- status GreylistStatus @default(None)
530
- reason String // Why flagged (e.g. "velocity anomaly", "wallet clustering", "manual flag")
531
- source String // What triggered it: "admin", "system:velocity", "system:clustering"
532
- flaggedBy String? // Admin userId who flagged (null if system-flagged)
533
- reviewedBy String? // Admin userId who reviewed (cleared/confirmed)
534
- reviewedAt DateTime? // When reviewed
535
- reviewNotes String? // Admin notes on review decision
536
- metadata Json? // Arbitrary data: IP patterns, cluster info, etc.
537
-
538
- createdAt DateTime @default(now())
539
- updatedAt DateTime @updatedAt
540
-
541
- @@index([walletAddress])
542
- @@index([status])
543
- @@index([walletAddress, status])
544
- }
545
-
546
- enum OrderDirection {
547
- BID
548
- ASK
549
- }
550
-
551
- enum TerminalOrderStatus {
552
- FILLED
553
- CANCELLED
554
- }
555
-
556
- model ClosedOrder {
557
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
558
- orderId String @unique
559
- chainId Int
560
- gameId Int
561
- gameMarketId String
562
- levrMarketId String
563
- side Int
564
- direction OrderDirection
565
- type String
566
- status TerminalOrderStatus
567
- price Int
568
- ethAddress String
569
- cancelReason String?
570
- cancelDetails String?
571
- transactionHash String?
572
-
573
- // BID-specific
574
- budget String?
575
- filledBudget String?
576
- leverage Float?
577
-
578
- // ASK-specific
579
- volume String?
580
- filledVolume String?
581
- positionId String?
582
-
583
- placedAt DateTime
584
- resolvedAt DateTime @default(now())
585
- createdAt DateTime @default(now())
586
- updatedAt DateTime @updatedAt
587
-
588
- @@index([ethAddress])
589
- @@index([ethAddress, status])
590
- @@index([ethAddress, resolvedAt(sort: Desc)])
591
- @@index([chainId, gameMarketId])
592
- }
593
-
594
- model FreeBetCampaign {
595
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
596
- merkleRoot String @unique
597
- campaignId Int
598
- chainId Int
599
- name String
600
- description String
601
- txHash String?
602
-
603
- entries FreeBetCampaignEntry[]
604
-
605
- createdAt DateTime @default(now())
606
-
607
- @@unique([chainId, campaignId])
608
- }
609
-
610
- model FreeBetCampaignEntry {
611
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
612
- merkleRoot String
613
- ethAddress String
614
- proof Json?
615
- amount BigInt @default(0)
616
- nonce Int @default(0)
617
- spent Boolean @default(false)
618
- paused Boolean @default(false)
619
-
620
- campaign FreeBetCampaign @relation(fields: [merkleRoot], references: [merkleRoot])
621
-
622
- @@unique([merkleRoot, ethAddress, nonce])
623
- @@index([ethAddress])
624
- }
625
-
626
- enum NotificationType {
627
- BetPlaced
628
- BetSettled
629
- BetCredit
630
- Deposit
631
- Withdrawal
632
- ReferralSignup
633
- ReferralRewardEarned
634
- ReferralPayoutPublished
635
- MarketSettled
636
- GameLive
637
- ApiKeyCreated
638
- SecurityAlert
639
- GreylistFlagged
640
- Promo
641
- }
642
-
643
- model Notification {
644
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
645
- userId String @db.ObjectId
646
- user User @relation("UserNotifications", fields: [userId], references: [objectId])
647
- type NotificationType
648
- title String
649
- message String
650
- metadata Json @default("{}") // arbitrary event payload (e.g. amount, txHash, gameMarketId)
651
- actionUrl String? // optional deep link for the client to route to on click
652
- readAt DateTime?
653
-
654
- createdAt DateTime @default(now())
655
- updatedAt DateTime @updatedAt
656
-
657
- @@index([userId])
658
- @@index([userId, readAt])
659
- @@index([type])
660
- @@index([createdAt])
661
- }