Skip to content

Commit 29aa129

Browse files
committed
Update tardis-dev to 16.5.0
1 parent 24064a6 commit 29aa129

4 files changed

Lines changed: 77 additions & 7 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"debug": "^4.4.1",
7979
"find-my-way": "^9.3.0",
8080
"is-docker": "^2.2.1",
81-
"tardis-dev": "^16.4.2",
81+
"tardis-dev": "^16.5.0",
8282
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.59.0",
8383
"yargs": "^17.5.1"
8484
},

src/ws/subscriptionsmappers.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,30 @@ const bullishMapper: SubscriptionMapper = {
704704
}
705705
}
706706

707-
export const subscriptionsMappers: Partial<Record<Exchange | 'lighter', SubscriptionMapper>> = {
707+
const polymarketMapper: SubscriptionMapper = {
708+
canHandle: (message: any) => {
709+
return message.type === 'market'
710+
},
711+
712+
map: (message: any) => {
713+
const symbols = message.assets_ids
714+
715+
const filters = [
716+
{ channel: 'book', symbols },
717+
{ channel: 'price_change', symbols },
718+
{ channel: 'last_trade_price', symbols },
719+
{ channel: 'tick_size_change', symbols }
720+
]
721+
722+
if (message.custom_feature_enabled === true) {
723+
filters.push({ channel: 'best_bid_ask', symbols }, { channel: 'new_market', symbols }, { channel: 'market_resolved', symbols })
724+
}
725+
726+
return filters
727+
}
728+
}
729+
730+
export const subscriptionsMappers: Record<Exchange, SubscriptionMapper> = {
708731
bitmex: bitmexMapper,
709732
coinbase: coinbaseMaper,
710733
deribit: deribitMapper,
@@ -763,7 +786,8 @@ export const subscriptionsMappers: Partial<Record<Exchange | 'lighter', Subscrip
763786
'coinbase-international': coinbaseInternationalMapper,
764787
hyperliquid: hyperliquidMapper,
765788
lighter: lighterMapper,
766-
bullish: bullishMapper
789+
bullish: bullishMapper,
790+
polymarket: polymarketMapper
767791
}
768792

769793
export type SubscriptionMapper = {

test/subscriptionsmappers.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,50 @@ describe('subscriptions mappers', () => {
5050
{ channel: 'V1TAIndexPrice', symbols: ['BTC'] }
5151
])
5252
})
53+
54+
test('maps Polymarket market subscriptions', () => {
55+
const mapper = subscriptionsMappers.polymarket
56+
const date = new Date()
57+
const message = { type: 'market', assets_ids: ['2174101397', '713210352'] }
58+
59+
expect(mapper.canHandle(message, date)).toBe(true)
60+
expect(mapper.map(message, date)).toEqual([
61+
{ channel: 'book', symbols: ['2174101397', '713210352'] },
62+
{ channel: 'price_change', symbols: ['2174101397', '713210352'] },
63+
{ channel: 'last_trade_price', symbols: ['2174101397', '713210352'] },
64+
{ channel: 'tick_size_change', symbols: ['2174101397', '713210352'] }
65+
])
66+
})
67+
68+
test('maps Polymarket custom market subscriptions', () => {
69+
const mapper = subscriptionsMappers.polymarket
70+
const date = new Date()
71+
const message = { type: 'market', assets_ids: ['2174101397'], custom_feature_enabled: true }
72+
73+
expect(mapper.map(message, date)).toEqual([
74+
{ channel: 'book', symbols: ['2174101397'] },
75+
{ channel: 'price_change', symbols: ['2174101397'] },
76+
{ channel: 'last_trade_price', symbols: ['2174101397'] },
77+
{ channel: 'tick_size_change', symbols: ['2174101397'] },
78+
{ channel: 'best_bid_ask', symbols: ['2174101397'] },
79+
{ channel: 'new_market', symbols: ['2174101397'] },
80+
{ channel: 'market_resolved', symbols: ['2174101397'] }
81+
])
82+
})
83+
84+
test('maps Polymarket empty asset subscriptions', () => {
85+
const mapper = subscriptionsMappers.polymarket
86+
const date = new Date()
87+
const message = { type: 'market', assets_ids: [], custom_feature_enabled: true }
88+
89+
expect(mapper.map(message, date)).toEqual([
90+
{ channel: 'book', symbols: [] },
91+
{ channel: 'price_change', symbols: [] },
92+
{ channel: 'last_trade_price', symbols: [] },
93+
{ channel: 'tick_size_change', symbols: [] },
94+
{ channel: 'best_bid_ask', symbols: [] },
95+
{ channel: 'new_market', symbols: [] },
96+
{ channel: 'market_resolved', symbols: [] }
97+
])
98+
})
5399
})

0 commit comments

Comments
 (0)