1+ import  {  SimpleAdapter ,  FetchOptions ,  FetchResult  }  from  "../../adapters/types" ; 
2+ import  {  CHAIN  }  from  "../../helpers/chains" ; 
3+ 
4+ const  FEE_ACCURED_EVENT  =  "event FeeAccrued(address indexed account, bytes32 indexed subaccount, address token, uint256 feeAmount, uint256 balance, uint64 messageIdx)" ; 
5+ 
6+ const  ORDER_MATCHED_EVENT  =  "event PerpOrderMatched(uint32 indexed productId, address indexed maker, address indexed taker, bytes32 makerSubaccount, bytes32 takerSubaccount, uint8 makerSide, uint8 takerSide, uint128 fillQuantity, uint128 price, uint64 messageIdx)" ; 
7+ 
8+ const  EXCHANGE_GATEWAY  =  "0xB3cDC82035C495c484C9fF11eD5f3Ff6d342e3cc" ; 
9+ 
10+ async  function  fetch ( options : FetchOptions ) : Promise < FetchResult >  { 
11+     const  dailyFees  =  options . createBalances ( ) ; 
12+     const  dailyVolume  =  options . createBalances ( ) ; 
13+ 
14+     const  feeAccuredLogs  =  await  options . getLogs ( { 
15+         target : EXCHANGE_GATEWAY , 
16+         eventAbi : FEE_ACCURED_EVENT 
17+     } ) ; 
18+ 
19+     const  orderMatchedLogs  =  await  options . getLogs ( { 
20+         target : EXCHANGE_GATEWAY , 
21+         eventAbi : ORDER_MATCHED_EVENT 
22+     } ) ; 
23+ 
24+     feeAccuredLogs . forEach ( ( fee : any )  =>  { 
25+         dailyFees . addCGToken ( "ethena-usde" ,  Number ( fee . feeAmount )  /  1e9 ) ; 
26+     } ) ; 
27+ 
28+     orderMatchedLogs . forEach ( ( order :any ) => { 
29+         dailyVolume . addCGToken ( "ethena-usde" , ( Number ( order . fillQuantity ) / 1e9 ) * ( Number ( order . price ) / 1e9 ) ) ; 
30+     } ) ; 
31+ 
32+     return  { 
33+         dailyVolume, 
34+         dailyFees, 
35+         dailyRevenue : dailyFees , 
36+         dailyProtocolRevenue : dailyFees , 
37+     } 
38+ } 
39+ 
40+ const  methodology  =  { 
41+     Volume : "Ethereal perp trade volume" , 
42+     Fees : "All trading fees paid by users" , 
43+     Revenue : "All the fees is revenue" , 
44+     ProtocolRevenue : "All the revenue goes to protocol" , 
45+ } 
46+ 
47+ const  adapter : SimpleAdapter  =  { 
48+     version : 2 , 
49+     fetch, 
50+     chains : [ CHAIN . ETHEREAL ] , 
51+     methodology, 
52+     start : '2025-10-21' 
53+ } 
54+ 
55+ export  default  adapter ; 
0 commit comments