@@ -4,7 +4,7 @@ import { Interface, id, EventLog } from "ethers"
44import { BaseAdapter , FetchOptions , FetchV2 , SimpleAdapter } from "../../adapters/types"
55
66type Orderbook = { address : string , start : string }
7- type Orderbooks = { v3 : Orderbook [ ] , v4 : Orderbook [ ] , v5 : Orderbook [ ] }
7+ type Orderbooks = { v3 : Orderbook [ ] , v4 : Orderbook [ ] , v5 : Orderbook [ ] , v6 : Orderbook [ ] }
88
99const floats : Record < string , string > = {
1010 [ CHAIN . ARBITRUM ] : "0x2265980d35d97F5f65C73e954D2022380bcA4A77" ,
@@ -26,7 +26,8 @@ const orderbooks: Record<string, Orderbooks> = {
2626 ] ,
2727 v5 : [
2828 { address : "0x8df8075e4077dabf1e95f49059e4c1eea33094ab" , start : '2025-09-07' } ,
29- ]
29+ ] ,
30+ v6 : [ ]
3031 } ,
3132 [ CHAIN . BASE ] : {
3233 v3 : [
@@ -42,6 +43,9 @@ const orderbooks: Record<string, Orderbooks> = {
4243 ] ,
4344 v5 : [
4445 { address : "0x52ceb8ebef648744ffdde89f7bc9c3ac35944775" , start : '2025-10-10' } ,
46+ ] ,
47+ v6 : [
48+ { address : "0xe522cB4a5fCb2eb31a52Ff41a4653d85A4fd7C9D" , start : '2026-02-05' } ,
4549 ]
4650 } ,
4751 [ CHAIN . BSC ] : {
@@ -51,7 +55,8 @@ const orderbooks: Record<string, Orderbooks> = {
5155 v4 : [
5256 { address : "0xd2938e7c9fe3597f78832ce780feb61945c377d7" , start : '2024-09-23' } ,
5357 ] ,
54- v5 : [ ]
58+ v5 : [ ] ,
59+ v6 : [ ]
5560 } ,
5661 [ CHAIN . ETHEREUM ] : {
5762 v3 : [
@@ -60,7 +65,8 @@ const orderbooks: Record<string, Orderbooks> = {
6065 v4 : [
6166 { address : "0x0eA6d458488d1cf51695e1D6e4744e6FB715d37C" , start : '2024-10-25' } ,
6267 ] ,
63- v5 : [ ]
68+ v5 : [ ] ,
69+ v6 : [ ]
6470 } ,
6571 [ CHAIN . FLARE ] : {
6672 v3 : [
@@ -72,15 +78,17 @@ const orderbooks: Record<string, Orderbooks> = {
7278 { address : "0xA2Ac77b982A9c0999472c1De378A81d7363d926F" , start : '2024-08-19' } ,
7379 { address : "0x582d9e838FE6cD9F8147C66A8f56A3FBE513a6A2" , start : '2024-07-11' } ,
7480 ] ,
75- v5 : [ ]
81+ v5 : [ ] ,
82+ v6 : [ ]
7683 } ,
7784 [ CHAIN . LINEA ] : {
7885 v3 : [ ] ,
7986 v4 : [
8087 { address : "0x22410e2a46261a1b1e3899a072f303022801c764" , start : '2024-09-30' } ,
8188 { address : "0xF97DE1c2d864d90851aDBcbEe0A38260440B8D90" , start : '2024-07-29' } ,
8289 ] ,
83- v5 : [ ]
90+ v5 : [ ] ,
91+ v6 : [ ]
8492 } ,
8593 // not supported?
8694 // matchain: {
@@ -108,7 +116,8 @@ const orderbooks: Record<string, Orderbooks> = {
108116 ] ,
109117 v5 : [
110118 { address : "0x8a3c8e610d827093f7437e0c45efa648563c0dda" , start : '2025-09-22' } ,
111- ]
119+ ] ,
120+ v6 : [ ]
112121 } ,
113122} as const
114123
@@ -127,8 +136,8 @@ const ABI_V4 = {
127136 ClearV2 : `event ClearV2(address sender, (address owner, (address interpreter, address store, bytes bytecode) evaluable, ${ IO } [] validInputs, ${ IO } [] validOutputs, bytes32 nonce) alice, (address owner, (address interpreter, address store, bytes bytecode) evaluable, ${ IO } [] validInputs, ${ IO } [] validOutputs, bytes32 nonce) bob, ${ ClearConfig } clearConfig)` ,
128137} as const
129138
130- // v5 orderbook abi
131- export namespace ABI_V5 {
139+ // v5 and v6 orderbook abi
140+ export namespace ABI_V5_V6 {
132141 // structs
133142 export const Float = "bytes32" as const ;
134143 export const IOV2 = `(address token, bytes32 vaultId)` as const ;
@@ -159,7 +168,7 @@ export namespace ABI_V5 {
159168
160169const abi_v3 = new Interface ( [ ABI_V3 . Clear , ABI_V3 . AfterClear , ABI_V3 . TakeOrder ] )
161170const abi_v4 = new Interface ( [ ABI_V4 . ClearV2 , ABI_V4 . AfterClear , ABI_V4 . TakeOrderV2 ] )
162- const abi_v5 = new Interface ( [ ABI_V5 . events . ClearV3 , ABI_V5 . events . AfterClearV2 , ABI_V5 . events . TakeOrderV3 ] )
171+ const abi_v5_v6 = new Interface ( [ ABI_V5_V6 . events . ClearV3 , ABI_V5_V6 . events . AfterClearV2 , ABI_V5_V6 . events . TakeOrderV3 ] )
163172
164173async function fetchV3Vol ( { api, getLogs } : FetchOptions , dailyVolume : Balances ) {
165174 const targets = orderbooks [ api . chain ] . v3 . map ( v => v . address )
@@ -271,28 +280,28 @@ async function fetchV4Vol({ api, getLogs }: FetchOptions, dailyVolume: Balances)
271280 } )
272281}
273282
274- async function fetchV5Vol ( { api, getLogs } : FetchOptions , dailyVolume : Balances ) {
275- const targets = orderbooks [ api . chain ] . v5 . map ( v => v . address )
283+ async function fetchV5_V6Vol ( { api, getLogs } : FetchOptions , dailyVolume : Balances ) {
284+ const targets = orderbooks [ api . chain ] . v5 . concat ( orderbooks [ api . chain ] . v6 ) . map ( v => v . address )
276285 if ( ! targets . length ) return
277286
278287 const [ afterClearLogs , clearLogs , takeOrderLogs ] = await Promise . all ( [
279288 getLogs ( {
280289 targets,
281290 flatten : false ,
282291 entireLog : true ,
283- topic : id ( abi_v5 . getEvent ( "AfterClearV2" ) ! . format ( ) ) ,
292+ topic : id ( abi_v5_v6 . getEvent ( "AfterClearV2" ) ! . format ( ) ) ,
284293 } ) ,
285294 getLogs ( {
286295 targets,
287296 flatten : false ,
288297 entireLog : true ,
289- topic : id ( abi_v5 . getEvent ( "ClearV3" ) ! . format ( ) ) ,
298+ topic : id ( abi_v5_v6 . getEvent ( "ClearV3" ) ! . format ( ) ) ,
290299 } ) ,
291300 getLogs ( {
292301 targets,
293302 flatten : false ,
294303 entireLog : true ,
295- topic : id ( abi_v5 . getEvent ( "TakeOrderV3" ) ! . format ( ) ) ,
304+ topic : id ( abi_v5_v6 . getEvent ( "TakeOrderV3" ) ! . format ( ) ) ,
296305 } )
297306 ] ) as EventLog [ ] [ ] [ ]
298307
@@ -308,11 +317,11 @@ async function fetchV5Vol({ api, getLogs }: FetchOptions, dailyVolume: Balances)
308317 if ( clearLog ) {
309318 const {
310319 clearStateChange : { aliceOutput, bobInput }
311- } = abi_v5 . decodeEventLog ( "AfterClearV2" , log . data )
320+ } = abi_v5_v6 . decodeEventLog ( "AfterClearV2" , log . data )
312321 const {
313322 alice : { validOutputs } ,
314323 clearConfig : { aliceOutputIOIndex }
315- } = abi_v5 . decodeEventLog ( "ClearV3" , clearLog . data )
324+ } = abi_v5_v6 . decodeEventLog ( "ClearV3" , clearLog . data )
316325
317326 const token = validOutputs [ Number ( aliceOutputIOIndex ) ] . token . toLowerCase ( )
318327 tokenSet . add ( token )
@@ -326,7 +335,7 @@ async function fetchV5Vol({ api, getLogs }: FetchOptions, dailyVolume: Balances)
326335 const {
327336 input,
328337 config : { outputIOIndex, order } ,
329- } = abi_v5 . decodeEventLog ( "TakeOrderV3" , log . data )
338+ } = abi_v5_v6 . decodeEventLog ( "TakeOrderV3" , log . data )
330339
331340 const token = order . validOutputs [ Number ( outputIOIndex ) ] . token . toLowerCase ( )
332341 tokenSet . add ( token )
@@ -347,7 +356,7 @@ async function fetchV5Vol({ api, getLogs }: FetchOptions, dailyVolume: Balances)
347356 const vols = await api . multiCall ( {
348357 permitFailure : true ,
349358 target : floats [ api . chain ] ,
350- abi : ABI_V5 . float . toFixedDecimalLossy ,
359+ abi : ABI_V5_V6 . float . toFixedDecimalLossy ,
351360 calls : rawVols
352361 . filter ( ( rawVol ) => {
353362 const index = tokenList . indexOf ( rawVol . token ) ;
@@ -370,7 +379,7 @@ const fetchVolume: FetchV2 = async function (options: FetchOptions) {
370379 await Promise . allSettled ( [
371380 fetchV3Vol ( options , dailyVolume ) ,
372381 fetchV4Vol ( options , dailyVolume ) ,
373- fetchV5Vol ( options , dailyVolume ) ,
382+ fetchV5_V6Vol ( options , dailyVolume ) ,
374383 ] )
375384
376385 return { dailyVolume }
0 commit comments