diff --git a/src/mappers/gateiofutures.ts b/src/mappers/gateiofutures.ts index 110823c..f9d6914 100644 --- a/src/mappers/gateiofutures.ts +++ b/src/mappers/gateiofutures.ts @@ -113,7 +113,9 @@ export class GateIOFuturesDerivativeTickerMapper implements Mapper<'gate-io-futu } *map(message: GateIOFuturesTicker, localTimestamp: Date): IterableIterator { - for (const futuresTicker of message.result) { + const tickers = Array.isArray(message.result) ? message.result : [message.result] + + for (const futuresTicker of tickers) { if (futuresTicker.contract === undefined) { return } @@ -179,14 +181,23 @@ type GateIOFuturesTicker = { channel: 'futures.tickers' event: 'update' - result: [ - { - contract: string - last: string - funding_rate: string - mark_price: string - index_price: string - funding_rate_indicative: string - } - ] + result: + | [ + { + contract: string + last: string + funding_rate: string + mark_price: string + index_price: string + funding_rate_indicative: string + } + ] + | { + contract: string + last: string + funding_rate: string + mark_price: string + index_price: string + funding_rate_indicative: string + } } diff --git a/test/__snapshots__/mappers.test.ts.snap b/test/__snapshots__/mappers.test.ts.snap index 0be1e55..423f140 100644 --- a/test/__snapshots__/mappers.test.ts.snap +++ b/test/__snapshots__/mappers.test.ts.snap @@ -4712,6 +4712,25 @@ Array [ exports[`mappers map gate-io-futures messages 15`] = `Array []`; +exports[`mappers map gate-io-futures messages 16`] = ` +Array [ + Object { + "exchange": "gate-io-futures", + "fundingRate": 0.0001, + "fundingTimestamp": undefined, + "indexPrice": 26.9291, + "lastPrice": 25.595, + "localTimestamp": 2020-07-01T00:00:01.275Z, + "markPrice": 26.929, + "openInterest": undefined, + "predictedFundingRate": 0.0001, + "symbol": "ETC_USD", + "timestamp": 2022-03-17T07:13:26.000Z, + "type": "derivative_ticker", + }, +] +`; + exports[`mappers map gemini messages 1`] = ` Array [ Object { diff --git a/test/mappers.test.ts b/test/mappers.test.ts index 628b2d4..8233966 100644 --- a/test/mappers.test.ts +++ b/test/mappers.test.ts @@ -5843,6 +5843,28 @@ describe('mappers', () => { } ] ] + }, + { + time: 1647501206, + channel: 'futures.tickers', + event: 'update', + result: { + contract: 'ETC_USD', + last: '25.595', + change_percentage: '0', + total_size: '14', + volume_24h: '0', + volume_24h_base: '0', + volume_24h_quote: '0', + volume_24h_settle: '0', + mark_price: '26.929', + funding_rate: '0.0001', + funding_rate_indicative: '0.0001', + index_price: '26.9291', + quanto_base_rate: '0.0006594', + volume_24_usd: '0', + volume_24_btc: '0' + } } ] const gateIOFuturesMapper = createMapper('gate-io-futures')