1+ import { FetchOptions , SimpleAdapter } from "../adapters/types" ;
2+ import { CHAIN } from "../helpers/chains" ;
3+ import BigNumber from "bignumber.js" ;
4+
5+ const pairs = [
6+ // Coin Flip
7+ {
8+ target : "0xa7f902847a16F1CDbF043c0653865D40e6695de5" ,
9+ eventAbi : "event CoinFlip_Outcome_Event( address indexed playerAddress, uint256 wager, uint256 payout, address tokenAddress, uint8[] coinOutcomes, uint256[] payouts, uint32 numGames, uint64 sequenceNumber )" ,
10+ } ,
11+ // Dice
12+ {
13+ target : "0x8baecE06d825d36b52cb588960aE707d6C76a54C" ,
14+ eventAbi : "event Dice_Outcome_Event( address indexed playerAddress, uint256 wager, uint256 payout, address tokenAddress, uint32 multiplier, bool isOver, uint256[] diceOutcomes, uint256[] payouts, uint32 numGames, uint64 sequenceNumber )" ,
15+ } ,
16+ // Rock Paper Scissors
17+ {
18+ target : "0xDA18dC7bb27Ca2056Fa3cA3da3973218Dc18F8e3" ,
19+ eventAbi : "event RockPaperScissors_Outcome_Event( address indexed playerAddress, uint256 wager, uint256 payout, address tokenAddress, uint8[] outcomes, uint8[] randomActions, uint256[] payouts, uint32 numGames, uint64 sequenceNumber )" ,
20+ } ,
21+ // Slots
22+ {
23+ target : "0xe3C0B41413Bc9913E0ace43a64637EF6C4e39F97" ,
24+ eventAbi : "event Slots_Outcome_Event( address indexed playerAddress, uint256 wager, uint256 payout, address tokenAddress, uint16[] slotIDs, uint256[] multipliers, uint256[] payouts, uint32 numGames, uint64 sequenceNumber )" ,
25+ } ,
26+ // Mines
27+ {
28+ target : "0x1CE656bD09a59A59513c4460220031d49038739e" ,
29+ eventAbi : "event Mines_End_Event( address indexed playerAddress, uint256 wager, uint256 payout, address tokenAddress, uint256 numMines, bool[25] revealedTiles, uint256 multiplier )" ,
30+ } ,
31+ // Plinko
32+ {
33+ target : "0xf970b3C6A1bd7745A07B317543EA999e4E98666c" ,
34+ eventAbi : "event Plinko_Outcome_Event( address indexed playerAddress, uint256 wager, uint256 payout, address tokenAddress, uint16[] paths, uint8 numRows, uint8 risk, uint256[] payouts, uint32 numGames, uint64 sequenceNumber )" ,
35+ } ,
36+ // Video Poker
37+ {
38+ target : "0x681D2C159EE77f660F5081a3c193fb9613b624C0" ,
39+ eventAbi : "event VideoPoker_Outcome_Event( address indexed playerAddress, uint256 wager, uint256 payout, address tokenAddress, (uint8,uint8)[5] playerHand, uint256 outcome, uint64 sequenceNumber, uint64 sequenceNumberStart )" ,
40+ } ,
41+ // Baccarat
42+ {
43+ target : "0xBEAaFcc7648354a0722350378bF2A295B9b946A8" ,
44+ eventAbi : "event Baccarat_Outcome_Event( address indexed playerAddress, uint256 totalWager, uint256[5] wager, uint256 totalPayout, address tokenAddress, (uint8,uint8)[6] playerHand, (uint8,uint8)[3] bankerCards, (uint8,uint8)[3] playerCards, uint256[3] outcome, uint256[5] payouts, uint64 sequenceNumber )" ,
45+ } ,
46+ // Roulette
47+ {
48+ target : "0x39AA4ECB48c52A018B2a1A700B89C4912FC39967" ,
49+ eventAbi : "event Roulette_Outcome_Event( address indexed playerAddress, uint256 totalWager, uint256 totalPayout, address tokenAddress, uint256[] wager, uint256[] rouletteType, uint256[] payouts, uint256 outcome, uint64 sequenceNumber )" ,
50+ } ,
51+ // Fish Prawn Crab
52+ {
53+ target : "0xbB1b4eE5D22ca19faa5aA9A55Caf4abAEd14607B" ,
54+ eventAbi : "event FishPrawnCrab_Outcome_Event( address indexed playerAddress, uint256 totalWager, uint256 totalPayout, address tokenAddress, uint256[] wager, uint256[] fishPrawnCrabType, uint256[] payouts, uint256[3] outcome, uint64 sequenceNumber )" ,
55+ } ,
56+ // Limbo
57+ {
58+ target : "0x11B83A467AbFF4c466294af94B99ACEF3D85929d" ,
59+ eventAbi : "event Limbo_Outcome_Event( address indexed playerAddress, uint256 wager, uint256 payout, address tokenAddress, uint32 multiplier, uint256[] limboOutcomes, uint256[] payouts, uint32 numGames, uint64 sequenceNumber )" ,
60+ } ,
61+ ] ;
62+
63+ // Hard-coded rate in smart contract
64+ const FEE_RATE = 0.1 / 100 ;
65+
66+ const fetch = async ( options : FetchOptions ) => {
67+ const dailyVolume = options . createBalances ( ) ;
68+ const dailyFees = options . createBalances ( ) ;
69+
70+ const logs : any [ ] = [ ] ;
71+ for ( const pair of pairs ) {
72+ const gameLogs = await options . getLogs ( {
73+ target : pair . target ,
74+ eventAbi : pair . eventAbi ,
75+ } ) ;
76+ logs . push ( ...gameLogs ) ;
77+ }
78+
79+ for ( const log of logs ) {
80+ let wagerRaw ;
81+ if ( 'wager' in log && ! ( 'totalWager' in log ) ) {
82+ wagerRaw = BigNumber ( log . wager ) ;
83+ if ( 'payouts' in log ) {
84+ wagerRaw = wagerRaw . multipliedBy ( log . payouts . length ) ;
85+ }
86+ } else if ( 'totalWager' in log ) {
87+ wagerRaw = BigNumber ( log . totalWager ) ;
88+ } else {
89+ console . warn ( "Unreachable code for log" , log )
90+ continue ;
91+ }
92+ const wagerStandardized = wagerRaw . dividedBy ( 1e18 ) . toNumber ( ) ;
93+ dailyVolume . addCGToken ( 'monad' , wagerStandardized )
94+ dailyFees . addCGToken ( 'monad' , wagerStandardized * FEE_RATE ) ;
95+ }
96+
97+ return {
98+ dailyVolume,
99+ dailyFees,
100+ } ;
101+ } ;
102+
103+ const adapter : SimpleAdapter = {
104+ version : 2 ,
105+ fetch,
106+ chains : [ CHAIN . MONAD ] ,
107+ start : '2025-10-24' ,
108+ methodology : {
109+ Volume : 'Total wager from all betting contracts.' ,
110+ Fees : 'There is amount of 0.1% wager collected as fees.' ,
111+ }
112+ }
113+
114+ export default adapter ;
0 commit comments