@@ -635,6 +635,49 @@ const bitgetMapper: SubscriptionMapper = {
635635 } )
636636 }
637637}
638+
639+ const mexcMapper : SubscriptionMapper = {
640+ canHandle : ( message : any ) => {
641+ return message . method === 'SUBSCRIPTION' && Array . isArray ( message . params )
642+ } ,
643+
644+ map : ( message : any ) => {
645+ return message . params . map ( ( param : string ) => {
646+ const separator = param . lastIndexOf ( '@' )
647+
648+ return {
649+ channel : separator === - 1 ? param : param . slice ( 0 , separator ) ,
650+ symbols : separator === - 1 ? [ ] : [ param . slice ( separator + 1 ) ]
651+ }
652+ } )
653+ }
654+ }
655+
656+ const mexcFuturesChannelMappings : Record < string , string > = {
657+ 'sub.deal' : 'push.deal' ,
658+ 'sub.depth' : 'push.depth' ,
659+ 'sub.ticker' : 'push.ticker' ,
660+ 'sub.index.price' : 'push.index.price' ,
661+ 'sub.fair.price' : 'push.fair.price' ,
662+ 'sub.funding.rate' : 'push.funding.rate' ,
663+ 'sub.contract' : 'push.contract'
664+ }
665+
666+ const mexcFuturesMapper : SubscriptionMapper = {
667+ canHandle : ( message : any ) => {
668+ return mexcFuturesChannelMappings [ message . method ] !== undefined
669+ } ,
670+
671+ map : ( message : any ) => {
672+ return [
673+ {
674+ channel : mexcFuturesChannelMappings [ message . method ] ,
675+ symbols : message . param ?. symbol !== undefined ? [ message . param . symbol ] : [ ]
676+ }
677+ ]
678+ }
679+ }
680+
638681const coinbaseInternationalMapper : SubscriptionMapper = {
639682 canHandle : ( message : any ) => {
640683 return message . type === 'SUBSCRIBE'
@@ -786,6 +829,8 @@ export const subscriptionsMappers: Record<Exchange, SubscriptionMapper> = {
786829 'kucoin-futures' : kucoinMapper ,
787830 bitget : bitgetMapper ,
788831 'bitget-futures' : bitgetMapper ,
832+ mexc : mexcMapper ,
833+ 'mexc-futures' : mexcFuturesMapper ,
789834 'coinbase-international' : coinbaseInternationalMapper ,
790835 hyperliquid : hyperliquidMapper ,
791836 lighter : lighterMapper ,
0 commit comments