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