@chainstream-io/sdk 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/stream.d.ts +44 -43
- package/dist/api/stream.js +206 -196
- package/dist/api/stream.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/openapi/apis/DexPoolApi.d.ts +0 -2
- package/dist/openapi/apis/DexPoolApi.js +0 -47
- package/dist/openapi/apis/DexPoolApi.js.map +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js.map +1 -1
- package/dist/openapi/models/ObjectSerializer.d.ts +3 -1
- package/dist/openapi/models/ObjectSerializer.js +9 -3
- package/dist/openapi/models/ObjectSerializer.js.map +1 -1
- package/dist/openapi/models/RankingToken.d.ts +2 -0
- package/dist/openapi/models/RankingToken.js +6 -0
- package/dist/openapi/models/RankingToken.js.map +1 -1
- package/dist/openapi/models/RankingTokenStat.d.ts +10 -0
- package/dist/openapi/models/RankingTokenStat.js +60 -0
- package/dist/openapi/models/RankingTokenStat.js.map +1 -1
- package/dist/openapi/models/Token.d.ts +6 -4
- package/dist/openapi/models/Token.js +5 -5
- package/dist/openapi/models/Token.js.map +1 -1
- package/dist/openapi/models/TokenCreatorsDTO.d.ts +22 -0
- package/dist/openapi/models/TokenCreatorsDTO.js +34 -0
- package/dist/openapi/models/TokenCreatorsDTO.js.map +1 -0
- package/dist/openapi/models/TokenExtraDTO.d.ts +35 -0
- package/dist/openapi/models/TokenExtraDTO.js +112 -0
- package/dist/openapi/models/TokenExtraDTO.js.map +1 -0
- package/dist/openapi/models/TokenMarketData.d.ts +2 -2
- package/dist/openapi/models/TokenMarketData.js +4 -4
- package/dist/openapi/models/TokenMarketData.js.map +1 -1
- package/dist/openapi/models/TokenMetadata.d.ts +6 -4
- package/dist/openapi/models/TokenMetadata.js +5 -5
- package/dist/openapi/models/TokenMetadata.js.map +1 -1
- package/dist/openapi/models/TokenSocialMediasDTO.d.ts +32 -0
- package/dist/openapi/models/TokenSocialMediasDTO.js +94 -0
- package/dist/openapi/models/TokenSocialMediasDTO.js.map +1 -0
- package/dist/openapi/models/all.d.ts +3 -1
- package/dist/openapi/models/all.js +3 -1
- package/dist/openapi/models/all.js.map +1 -1
- package/dist/openapi/types/ObjectParamAPI.d.ts +0 -7
- package/dist/openapi/types/ObjectParamAPI.js +0 -6
- package/dist/openapi/types/ObjectParamAPI.js.map +1 -1
- package/dist/openapi/types/ObservableAPI.d.ts +0 -2
- package/dist/openapi/types/ObservableAPI.js +0 -18
- package/dist/openapi/types/ObservableAPI.js.map +1 -1
- package/dist/openapi/types/PromiseAPI.d.ts +0 -2
- package/dist/openapi/types/PromiseAPI.js +0 -8
- package/dist/openapi/types/PromiseAPI.js.map +1 -1
- package/package.json +1 -1
- package/src/api/stream.ts +441 -422
- package/src/index.ts +7 -1
- package/src/openapi/.openapi-generator/FILES +3 -1
- package/src/openapi/apis/DexPoolApi.ts +0 -85
- package/src/openapi/index.ts +1 -1
- package/src/openapi/models/ObjectSerializer.ts +9 -3
- package/src/openapi/models/RankingToken.ts +11 -0
- package/src/openapi/models/RankingTokenStat.ts +100 -0
- package/src/openapi/models/Token.ts +11 -9
- package/src/openapi/models/TokenCreatorsDTO.ts +59 -0
- package/src/openapi/models/{TokenExtraJsonDTO.ts → TokenExtraDTO.ts} +2 -2
- package/src/openapi/models/TokenMarketData.ts +6 -6
- package/src/openapi/models/TokenMetadata.ts +11 -9
- package/src/openapi/models/TokenSocialMediasDTO.ts +159 -0
- package/src/openapi/models/all.ts +3 -1
- package/src/openapi/types/ObjectParamAPI.ts +3 -43
- package/src/openapi/types/ObservableAPI.ts +3 -38
- package/src/openapi/types/PromiseAPI.ts +3 -25
package/src/api/stream.ts
CHANGED
|
@@ -92,6 +92,24 @@ export class StreamApi {
|
|
|
92
92
|
return unsubscribles;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Batch unsubscribe method that accepts an array of unsubscribe functions
|
|
97
|
+
* All unsubscribe calls will be executed at once
|
|
98
|
+
* @param unsubscribles Array of unsubscribe functions to execute
|
|
99
|
+
*/
|
|
100
|
+
batchUnsubscribe(unsubscribles: Unsubscrible[]): void {
|
|
101
|
+
if (!unsubscribles || unsubscribles.length === 0) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Execute all unsubscribe calls
|
|
106
|
+
unsubscribles.forEach((unsub) => {
|
|
107
|
+
if (unsub && typeof unsub.unsubscribe === "function") {
|
|
108
|
+
unsub.unsubscribe();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
95
113
|
subscribe<T = any>(channel: string, fn: (data: T) => void, filter?: string, methodName?: string): Unsubscrible {
|
|
96
114
|
let sub = this.realtimeClient.getSubscription(channel);
|
|
97
115
|
let listeners = this.listenersMap.get(channel);
|
|
@@ -284,93 +302,6 @@ export class StreamApi {
|
|
|
284
302
|
}), filter, "subscribeTokenStats");
|
|
285
303
|
}
|
|
286
304
|
|
|
287
|
-
subscribeRankingTokensStats({
|
|
288
|
-
chain,
|
|
289
|
-
channelType,
|
|
290
|
-
callback,
|
|
291
|
-
}: {
|
|
292
|
-
chain: string;
|
|
293
|
-
channelType: ChannelType;
|
|
294
|
-
callback: (data: TokenStat[]) => void;
|
|
295
|
-
}): Unsubscrible {
|
|
296
|
-
const channel = `dex-ranking-token-stats-list:${chain}_${channelType}`;
|
|
297
|
-
return this.subscribe(channel, (data: any[]) =>
|
|
298
|
-
callback(
|
|
299
|
-
data?.map(
|
|
300
|
-
(it: any) =>
|
|
301
|
-
({
|
|
302
|
-
address: it.a,
|
|
303
|
-
timestamp: it.t,
|
|
304
|
-
buys1m: it.b1m,
|
|
305
|
-
sells1m: it.s1m,
|
|
306
|
-
buyers1m: it.be1m,
|
|
307
|
-
sellers1m: it.se1m,
|
|
308
|
-
buyVolumeInUsd1m: this.formatScientificNotation(it.bviu1m),
|
|
309
|
-
sellVolumeInUsd1m: this.formatScientificNotation(it.sviu1m),
|
|
310
|
-
price1m: this.formatScientificNotation(it.p1m),
|
|
311
|
-
openInUsd1m: this.formatScientificNotation(it.oiu1m),
|
|
312
|
-
closeInUsd1m: this.formatScientificNotation(it.ciu1m),
|
|
313
|
-
buys5m: it.b5m,
|
|
314
|
-
sells5m: it.s5m,
|
|
315
|
-
buyers5m: it.be5m,
|
|
316
|
-
sellers5m: it.se5m,
|
|
317
|
-
buyVolumeInUsd5m: this.formatScientificNotation(it.bviu5m),
|
|
318
|
-
sellVolumeInUsd5m: this.formatScientificNotation(it.sviu5m),
|
|
319
|
-
price5m: this.formatScientificNotation(it.p5m),
|
|
320
|
-
openInUsd5m: this.formatScientificNotation(it.oiu5m),
|
|
321
|
-
closeInUsd5m: this.formatScientificNotation(it.ciu5m),
|
|
322
|
-
buys15m: it.b15m,
|
|
323
|
-
sells15m: it.s15m,
|
|
324
|
-
buyers15m: it.be15m,
|
|
325
|
-
sellers15m: it.se15m,
|
|
326
|
-
buyVolumeInUsd15m: this.formatScientificNotation(it.bviu15m),
|
|
327
|
-
sellVolumeInUsd15m: this.formatScientificNotation(it.sviu15m),
|
|
328
|
-
price15m: this.formatScientificNotation(it.p15m),
|
|
329
|
-
openInUsd15m: this.formatScientificNotation(it.oiu15m),
|
|
330
|
-
closeInUsd15m: this.formatScientificNotation(it.ciu15m),
|
|
331
|
-
buys30m: it.b30m,
|
|
332
|
-
sells30m: it.s30m,
|
|
333
|
-
buyers30m: it.be30m,
|
|
334
|
-
sellers30m: it.se30m,
|
|
335
|
-
buyVolumeInUsd30m: this.formatScientificNotation(it.bviu30m),
|
|
336
|
-
sellVolumeInUsd30m: this.formatScientificNotation(it.sviu30m),
|
|
337
|
-
price30m: this.formatScientificNotation(it.p30m),
|
|
338
|
-
openInUsd30m: this.formatScientificNotation(it.oiu30m),
|
|
339
|
-
closeInUsd30m: this.formatScientificNotation(it.ciu30m),
|
|
340
|
-
buys1h: it.b1h,
|
|
341
|
-
sells1h: it.s1h,
|
|
342
|
-
buyers1h: it.be1h,
|
|
343
|
-
sellers1h: it.se1h,
|
|
344
|
-
buyVolumeInUsd1h: this.formatScientificNotation(it.bviu1h),
|
|
345
|
-
sellVolumeInUsd1h: this.formatScientificNotation(it.sviu1h),
|
|
346
|
-
price1h: this.formatScientificNotation(it.p1h),
|
|
347
|
-
openInUsd1h: this.formatScientificNotation(it.oiu1h),
|
|
348
|
-
closeInUsd1h: this.formatScientificNotation(it.ciu1h),
|
|
349
|
-
buys4h: it.b4h,
|
|
350
|
-
sells4h: it.s4h,
|
|
351
|
-
buyers4h: it.be4h,
|
|
352
|
-
sellers4h: it.se4h,
|
|
353
|
-
buyVolumeInUsd4h: this.formatScientificNotation(it.bviu4h),
|
|
354
|
-
sellVolumeInUsd4h: this.formatScientificNotation(it.sviu4h),
|
|
355
|
-
price4h: this.formatScientificNotation(it.p4h),
|
|
356
|
-
openInUsd4h: this.formatScientificNotation(it.oiu4h),
|
|
357
|
-
closeInUsd4h: this.formatScientificNotation(it.ciu4h),
|
|
358
|
-
buys24h: it.b24h,
|
|
359
|
-
sells24h: it.s24h,
|
|
360
|
-
buyers24h: it.be24h,
|
|
361
|
-
sellers24h: it.se24h,
|
|
362
|
-
buyVolumeInUsd24h: this.formatScientificNotation(it.bviu24h),
|
|
363
|
-
sellVolumeInUsd24h: this.formatScientificNotation(it.sviu24h),
|
|
364
|
-
price24h: this.formatScientificNotation(it.p24h),
|
|
365
|
-
price: this.formatScientificNotation(it.p),
|
|
366
|
-
openInUsd24h: this.formatScientificNotation(it.oiu24h),
|
|
367
|
-
closeInUsd24h: this.formatScientificNotation(it.ciu24h),
|
|
368
|
-
}) as TokenStat
|
|
369
|
-
)
|
|
370
|
-
)
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
305
|
subscribeTokenHolders({
|
|
375
306
|
chain,
|
|
376
307
|
tokenAddress,
|
|
@@ -397,70 +328,92 @@ export class StreamApi {
|
|
|
397
328
|
}), filter, "subscribeTokenHolders");
|
|
398
329
|
}
|
|
399
330
|
|
|
400
|
-
|
|
331
|
+
subscribeNewToken({
|
|
401
332
|
chain,
|
|
402
|
-
channelType,
|
|
403
333
|
callback,
|
|
334
|
+
filter,
|
|
404
335
|
}: {
|
|
405
336
|
chain: string;
|
|
406
|
-
|
|
407
|
-
|
|
337
|
+
callback: (data: NewToken) => void;
|
|
338
|
+
filter?: string;
|
|
408
339
|
}): Unsubscrible {
|
|
409
|
-
const channel = `dex-
|
|
340
|
+
const channel = `dex-new-token:${chain}`;
|
|
341
|
+
return this.subscribe(channel, (data: any) =>
|
|
342
|
+
callback({
|
|
343
|
+
tokenAddress: data.a,
|
|
344
|
+
name: data.n,
|
|
345
|
+
symbol: data.s,
|
|
346
|
+
createdAtMs: data.cts,
|
|
347
|
+
}), filter, "subscribeNewToken");
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
subscribeNewTokensMetadata({
|
|
351
|
+
chain,
|
|
352
|
+
callback,
|
|
353
|
+
}: {
|
|
354
|
+
chain: string;
|
|
355
|
+
callback: (data: TokenMetadata[]) => void;
|
|
356
|
+
}): Unsubscrible {
|
|
357
|
+
const channel = `dex-new-tokens-metadata:${chain}`;
|
|
410
358
|
return this.subscribe(channel, (data: any[]) =>
|
|
411
359
|
callback(
|
|
412
|
-
data
|
|
360
|
+
data.map(
|
|
413
361
|
(it: any) =>
|
|
414
362
|
({
|
|
415
363
|
tokenAddress: it.a,
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
364
|
+
name: it.n,
|
|
365
|
+
symbol: it.s,
|
|
366
|
+
imageUrl: it.iu,
|
|
367
|
+
description: it.de,
|
|
368
|
+
socialMedia: (() => {
|
|
369
|
+
const socialMedia: any = {};
|
|
370
|
+
if (it.sm?.tw) {socialMedia.twitter = it.sm.tw}
|
|
371
|
+
if (it.sm?.tg) {socialMedia.telegram = it.sm.tg}
|
|
372
|
+
if (it.sm?.w) {socialMedia.website = it.sm.w}
|
|
373
|
+
if (it.sm?.tt) {socialMedia.tiktok = it.sm.tt}
|
|
374
|
+
if (it.sm?.dc) {socialMedia.discord = it.sm.dc}
|
|
375
|
+
if (it.sm?.fb) {socialMedia.facebook = it.sm.fb}
|
|
376
|
+
if (it.sm?.gh) {socialMedia.github = it.sm.gh}
|
|
377
|
+
if (it.sm?.ig) {socialMedia.instagram = it.sm.ig}
|
|
378
|
+
if (it.sm?.li) {socialMedia.linkedin = it.sm.li}
|
|
379
|
+
if (it.sm?.md) {socialMedia.medium = it.sm.md}
|
|
380
|
+
if (it.sm?.rd) {socialMedia.reddit = it.sm.rd}
|
|
381
|
+
if (it.sm?.yt) {socialMedia.youtube = it.sm.yt}
|
|
382
|
+
if (it.sm?.bb) {socialMedia.bitbucket = it.sm.bb}
|
|
383
|
+
return socialMedia;
|
|
384
|
+
})(),
|
|
385
|
+
createdAtMs: it.cts,
|
|
386
|
+
})
|
|
425
387
|
)
|
|
426
388
|
)
|
|
427
389
|
);
|
|
428
390
|
}
|
|
429
391
|
|
|
430
|
-
//
|
|
392
|
+
// subscribeNewTokens({
|
|
431
393
|
// chain,
|
|
432
|
-
// tokenAddress,
|
|
433
394
|
// callback,
|
|
434
395
|
// }: {
|
|
435
396
|
// chain: string;
|
|
436
|
-
//
|
|
437
|
-
// callback: (data: TradeEvent[]) => void;
|
|
397
|
+
// callback: (data: NewToken[]) => void;
|
|
438
398
|
// }): Unsubscrible {
|
|
439
|
-
// const channel = `dex-
|
|
399
|
+
// const channel = `dex-new-tokens:${chain}`;
|
|
440
400
|
// return this.subscribe(channel, (data: any[]) =>
|
|
441
401
|
// callback(
|
|
442
|
-
// data
|
|
402
|
+
// data.map(
|
|
443
403
|
// (it: any) =>
|
|
444
404
|
// ({
|
|
445
|
-
// maker: it.bwa,
|
|
446
|
-
// baseAmount: it.ba,
|
|
447
|
-
// quoteAmount: it.sa,
|
|
448
|
-
// // quoteSymbol: ,
|
|
449
|
-
// quoteAddress: it.swa,
|
|
450
|
-
// amountInUsd: it.baiu,
|
|
451
|
-
// timestamp: it.t,
|
|
452
|
-
// event: it.k,
|
|
453
|
-
// txHash: it.h,
|
|
454
|
-
// // priceInUsd: ,
|
|
455
|
-
// // id: ,
|
|
456
|
-
// // buyCostUsd: it.,
|
|
457
405
|
// tokenAddress: it.a,
|
|
458
|
-
//
|
|
406
|
+
// name: it.n,
|
|
407
|
+
// symbol: it.s,
|
|
408
|
+
// description: it.de,
|
|
409
|
+
// createdAtMs: it.cts,
|
|
410
|
+
// }) as NewToken
|
|
459
411
|
// )
|
|
460
412
|
// )
|
|
461
413
|
// );
|
|
462
414
|
// }
|
|
463
|
-
|
|
415
|
+
|
|
416
|
+
subscribeTokenSupply({
|
|
464
417
|
chain,
|
|
465
418
|
tokenAddress,
|
|
466
419
|
callback,
|
|
@@ -468,317 +421,48 @@ export class StreamApi {
|
|
|
468
421
|
}: {
|
|
469
422
|
chain: string;
|
|
470
423
|
tokenAddress: string;
|
|
471
|
-
callback: (data:
|
|
424
|
+
callback: (data: TokenSupply) => void;
|
|
472
425
|
filter?: string;
|
|
473
426
|
}): Unsubscrible {
|
|
474
|
-
const channel = `dex-
|
|
427
|
+
const channel = `dex-token-supply:${chain}_${tokenAddress}`;
|
|
475
428
|
return this.subscribe(channel, (data: any) =>
|
|
476
429
|
callback({
|
|
477
430
|
tokenAddress: data.a,
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
buyTokenAddress: data.btma,
|
|
483
|
-
buyTokenName: data.btn,
|
|
484
|
-
buyTokenSymbol: data.bts,
|
|
485
|
-
buyWalletAddress: data.bwa,
|
|
486
|
-
sellAmount: data.sa,
|
|
487
|
-
sellAmountInUsd: data.saiu,
|
|
488
|
-
sellTokenAddress: data.stma,
|
|
489
|
-
sellTokenName: data.stn,
|
|
490
|
-
sellTokenSymbol: data.sts,
|
|
491
|
-
sellWalletAddress: data.swa,
|
|
492
|
-
txHash: data.h,
|
|
493
|
-
}), filter, "subscribeTokenTrades");
|
|
431
|
+
supply: data.s,
|
|
432
|
+
marketCapInUsd: data.mc,
|
|
433
|
+
timestamp: data.ts,
|
|
434
|
+
}), filter, "subscribeTokenSupply");
|
|
494
435
|
}
|
|
495
436
|
|
|
496
|
-
|
|
437
|
+
subscribeTokenLiquidity({
|
|
497
438
|
chain,
|
|
498
|
-
|
|
439
|
+
tokenAddress,
|
|
499
440
|
callback,
|
|
500
441
|
filter,
|
|
501
442
|
}: {
|
|
502
443
|
chain: string;
|
|
503
|
-
|
|
504
|
-
callback: (data:
|
|
444
|
+
tokenAddress: string;
|
|
445
|
+
callback: (data: TokenLiquidity) => void;
|
|
505
446
|
filter?: string;
|
|
506
447
|
}): Unsubscrible {
|
|
507
|
-
const channel = `dex-
|
|
448
|
+
const channel = `dex-token-general-stat-num:${chain}_${tokenAddress}`;
|
|
508
449
|
return this.subscribe(channel, (data: any) =>
|
|
509
|
-
callback(
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
timestamp: data.t,
|
|
516
|
-
} as WalletBalance,
|
|
517
|
-
]), filter, "subscribeWalletBalance");
|
|
450
|
+
callback({
|
|
451
|
+
tokenAddress: data.a,
|
|
452
|
+
metricType: data.t,
|
|
453
|
+
value: data.v,
|
|
454
|
+
timestamp: data.ts,
|
|
455
|
+
}), filter, "subscribeTokenLiquidity");
|
|
518
456
|
}
|
|
519
457
|
|
|
520
|
-
|
|
458
|
+
subscribeRankingTokensLiquidity({
|
|
521
459
|
chain,
|
|
522
|
-
|
|
460
|
+
channelType,
|
|
523
461
|
callback,
|
|
524
|
-
filter,
|
|
525
462
|
}: {
|
|
526
463
|
chain: string;
|
|
527
|
-
|
|
528
|
-
callback: (data:
|
|
529
|
-
filter?: string;
|
|
530
|
-
}): Unsubscrible {
|
|
531
|
-
const channel = `dex-wallet-token-pnl:${chain}_${walletAddress}`;
|
|
532
|
-
return this.subscribe(channel, (data: any) =>
|
|
533
|
-
callback({
|
|
534
|
-
walletAddress: data.a,
|
|
535
|
-
tokenAddress: data.ta,
|
|
536
|
-
tokenPriceInUsd: data.tpiu,
|
|
537
|
-
timestamp: data.t,
|
|
538
|
-
opentime: data.ot,
|
|
539
|
-
lasttime: data.lt,
|
|
540
|
-
closetime: data.ct,
|
|
541
|
-
buyAmount: data.ba,
|
|
542
|
-
buyAmountInUsd: data.baiu,
|
|
543
|
-
buyCount: data.bs,
|
|
544
|
-
buyCount30d: data.bs30d,
|
|
545
|
-
buyCount7d: data.bs7d,
|
|
546
|
-
sellAmount: data.sa,
|
|
547
|
-
sellAmountInUsd: data.saiu,
|
|
548
|
-
sellCount: data.ss,
|
|
549
|
-
sellCount30d: data.ss30d,
|
|
550
|
-
sellCount7d: data.ss7d,
|
|
551
|
-
heldDurationTimestamp: data.hdts,
|
|
552
|
-
averageBuyPriceInUsd: data.abpiu,
|
|
553
|
-
averageSellPriceInUsd: data.aspiu,
|
|
554
|
-
unrealizedProfitInUsd: data.upiu,
|
|
555
|
-
unrealizedProfitRatio: data.upr,
|
|
556
|
-
realizedProfitInUsd: data.rpiu,
|
|
557
|
-
realizedProfitRatio: data.rpr,
|
|
558
|
-
totalRealizedProfitInUsd: data.trpiu,
|
|
559
|
-
totalRealizedProfitRatio: data.trr,
|
|
560
|
-
}), filter, "subscribeWalletPnl");
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
subscribeWalletPnlList({
|
|
564
|
-
chain,
|
|
565
|
-
walletAddress,
|
|
566
|
-
callback,
|
|
567
|
-
}: {
|
|
568
|
-
chain: string;
|
|
569
|
-
walletAddress: string;
|
|
570
|
-
callback: (data: WalletPnl[]) => void;
|
|
571
|
-
}): Unsubscrible {
|
|
572
|
-
const channel = `dex-wallet-pnl-list:${chain}_${walletAddress}`;
|
|
573
|
-
return this.subscribe(channel, (data: any[]) =>
|
|
574
|
-
callback(
|
|
575
|
-
data?.map(
|
|
576
|
-
(it: any) =>
|
|
577
|
-
({
|
|
578
|
-
walletAddress: it.a,
|
|
579
|
-
buys: it.bs,
|
|
580
|
-
buyAmount: it.ba,
|
|
581
|
-
buyAmountInUsd: it.baiu,
|
|
582
|
-
averageBuyPriceInUsd: it.abpiu,
|
|
583
|
-
sellAmount: it.sa,
|
|
584
|
-
sellAmountInUsd: it.saiu,
|
|
585
|
-
sells: it.ss,
|
|
586
|
-
wins: it.ws,
|
|
587
|
-
winRatio: it.wr,
|
|
588
|
-
pnlInUsd: it.piu,
|
|
589
|
-
averagePnlInUsd: it.apiu,
|
|
590
|
-
pnlRatio: it.pr,
|
|
591
|
-
profitableDays: it.pd,
|
|
592
|
-
losingDays: it.ld,
|
|
593
|
-
tokens: it.ts,
|
|
594
|
-
resolution: it.r,
|
|
595
|
-
}) as WalletPnl
|
|
596
|
-
)
|
|
597
|
-
)
|
|
598
|
-
);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
subscribeNewTokensMetadata({
|
|
602
|
-
chain,
|
|
603
|
-
callback,
|
|
604
|
-
}: {
|
|
605
|
-
chain: string;
|
|
606
|
-
callback: (data: TokenMetadata[]) => void;
|
|
607
|
-
}): Unsubscrible {
|
|
608
|
-
const channel = `dex-new-tokens-metadata:${chain}`;
|
|
609
|
-
return this.subscribe(channel, (data: any[]) =>
|
|
610
|
-
callback(
|
|
611
|
-
data.map(
|
|
612
|
-
(it: any) =>
|
|
613
|
-
({
|
|
614
|
-
tokenAddress: it.a,
|
|
615
|
-
name: it.n,
|
|
616
|
-
symbol: it.s,
|
|
617
|
-
imageUrl: it.iu,
|
|
618
|
-
description: it.de,
|
|
619
|
-
socialMedia: (() => {
|
|
620
|
-
const socialMedia: any = {};
|
|
621
|
-
if (it.sm?.tw) {socialMedia.twitter = it.sm.tw}
|
|
622
|
-
if (it.sm?.tg) {socialMedia.telegram = it.sm.tg}
|
|
623
|
-
if (it.sm?.w) {socialMedia.website = it.sm.w}
|
|
624
|
-
if (it.sm?.tt) {socialMedia.tiktok = it.sm.tt}
|
|
625
|
-
if (it.sm?.dc) {socialMedia.discord = it.sm.dc}
|
|
626
|
-
if (it.sm?.fb) {socialMedia.facebook = it.sm.fb}
|
|
627
|
-
if (it.sm?.gh) {socialMedia.github = it.sm.gh}
|
|
628
|
-
if (it.sm?.ig) {socialMedia.instagram = it.sm.ig}
|
|
629
|
-
if (it.sm?.li) {socialMedia.linkedin = it.sm.li}
|
|
630
|
-
if (it.sm?.md) {socialMedia.medium = it.sm.md}
|
|
631
|
-
if (it.sm?.rd) {socialMedia.reddit = it.sm.rd}
|
|
632
|
-
if (it.sm?.yt) {socialMedia.youtube = it.sm.yt}
|
|
633
|
-
if (it.sm?.bb) {socialMedia.bitbucket = it.sm.bb}
|
|
634
|
-
return socialMedia;
|
|
635
|
-
})(),
|
|
636
|
-
createdAtMs: it.cts,
|
|
637
|
-
})
|
|
638
|
-
)
|
|
639
|
-
)
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// subscribeNewTokens({
|
|
644
|
-
// chain,
|
|
645
|
-
// callback,
|
|
646
|
-
// }: {
|
|
647
|
-
// chain: string;
|
|
648
|
-
// callback: (data: NewToken[]) => void;
|
|
649
|
-
// }): Unsubscrible {
|
|
650
|
-
// const channel = `dex-new-tokens:${chain}`;
|
|
651
|
-
// return this.subscribe(channel, (data: any[]) =>
|
|
652
|
-
// callback(
|
|
653
|
-
// data.map(
|
|
654
|
-
// (it: any) =>
|
|
655
|
-
// ({
|
|
656
|
-
// tokenAddress: it.a,
|
|
657
|
-
// name: it.n,
|
|
658
|
-
// symbol: it.s,
|
|
659
|
-
// description: it.de,
|
|
660
|
-
// createdAtMs: it.cts,
|
|
661
|
-
// }) as NewToken
|
|
662
|
-
// )
|
|
663
|
-
// )
|
|
664
|
-
// );
|
|
665
|
-
// }
|
|
666
|
-
|
|
667
|
-
subscribeNewToken({
|
|
668
|
-
chain,
|
|
669
|
-
callback,
|
|
670
|
-
filter,
|
|
671
|
-
}: {
|
|
672
|
-
chain: string;
|
|
673
|
-
callback: (data: NewToken) => void;
|
|
674
|
-
filter?: string;
|
|
675
|
-
}): Unsubscrible {
|
|
676
|
-
const channel = `dex-new-token:${chain}`;
|
|
677
|
-
return this.subscribe(channel, (data: any) =>
|
|
678
|
-
callback({
|
|
679
|
-
tokenAddress: data.a,
|
|
680
|
-
name: data.n,
|
|
681
|
-
symbol: data.s,
|
|
682
|
-
createdAtMs: data.cts,
|
|
683
|
-
}), filter, "subscribeNewToken");
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
subscribeTokenSupply({
|
|
687
|
-
chain,
|
|
688
|
-
tokenAddress,
|
|
689
|
-
callback,
|
|
690
|
-
filter,
|
|
691
|
-
}: {
|
|
692
|
-
chain: string;
|
|
693
|
-
tokenAddress: string;
|
|
694
|
-
callback: (data: TokenSupply) => void;
|
|
695
|
-
filter?: string;
|
|
696
|
-
}): Unsubscrible {
|
|
697
|
-
const channel = `dex-token-supply:${chain}_${tokenAddress}`;
|
|
698
|
-
return this.subscribe(channel, (data: any) =>
|
|
699
|
-
callback({
|
|
700
|
-
tokenAddress: data.a,
|
|
701
|
-
supply: data.s,
|
|
702
|
-
marketCapInUsd: data.mc,
|
|
703
|
-
timestamp: data.ts,
|
|
704
|
-
}), filter, "subscribeTokenSupply");
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
subscribeRankingTokensSupply({
|
|
708
|
-
chain,
|
|
709
|
-
channelType,
|
|
710
|
-
callback,
|
|
711
|
-
}: {
|
|
712
|
-
chain: string;
|
|
713
|
-
channelType: ChannelType;
|
|
714
|
-
callback: (data: TokenSupply[]) => void;
|
|
715
|
-
}): Unsubscrible {
|
|
716
|
-
const channel = `dex-ranking-token-supply-list:${chain}_${channelType}`;
|
|
717
|
-
return this.subscribe(channel, (data: any[]) =>
|
|
718
|
-
callback(
|
|
719
|
-
data?.map(
|
|
720
|
-
(it: any) =>
|
|
721
|
-
({
|
|
722
|
-
tokenAddress: it.a,
|
|
723
|
-
supply: it.s,
|
|
724
|
-
marketCapInUsd: it.mc,
|
|
725
|
-
timestamp: it.ts,
|
|
726
|
-
})
|
|
727
|
-
)
|
|
728
|
-
)
|
|
729
|
-
);
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
subscribeDexPoolBalance({
|
|
733
|
-
chain,
|
|
734
|
-
poolAddress,
|
|
735
|
-
callback,
|
|
736
|
-
}: {
|
|
737
|
-
chain: string;
|
|
738
|
-
poolAddress: string;
|
|
739
|
-
callback: (data: DexPoolBalance) => void;
|
|
740
|
-
}): Unsubscrible {
|
|
741
|
-
const channel = `dex-pool-balance:${chain}_${poolAddress}`;
|
|
742
|
-
return this.subscribe(channel, (data: any) =>
|
|
743
|
-
callback({
|
|
744
|
-
poolAddress: data.a,
|
|
745
|
-
tokenAAddress: data.taa,
|
|
746
|
-
tokenALiquidityInUsd: data.taliu,
|
|
747
|
-
tokenBAddress: data.tba,
|
|
748
|
-
tokenBLiquidityInUsd: data.tbliu,
|
|
749
|
-
})
|
|
750
|
-
);
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
subscribeTokenLiquidity({
|
|
754
|
-
chain,
|
|
755
|
-
tokenAddress,
|
|
756
|
-
callback,
|
|
757
|
-
filter,
|
|
758
|
-
}: {
|
|
759
|
-
chain: string;
|
|
760
|
-
tokenAddress: string;
|
|
761
|
-
callback: (data: TokenLiquidity) => void;
|
|
762
|
-
filter?: string;
|
|
763
|
-
}): Unsubscrible {
|
|
764
|
-
const channel = `dex-token-general-stat-num:${chain}_${tokenAddress}`;
|
|
765
|
-
return this.subscribe(channel, (data: any) =>
|
|
766
|
-
callback({
|
|
767
|
-
tokenAddress: data.a,
|
|
768
|
-
metricType: data.t,
|
|
769
|
-
value: data.v,
|
|
770
|
-
timestamp: data.ts,
|
|
771
|
-
}), filter, "subscribeTokenLiquidity");
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
subscribeRankingTokensLiquidity({
|
|
775
|
-
chain,
|
|
776
|
-
channelType,
|
|
777
|
-
callback,
|
|
778
|
-
}: {
|
|
779
|
-
chain: string;
|
|
780
|
-
channelType: ChannelType;
|
|
781
|
-
callback: (data: TokenLiquidity[]) => void;
|
|
464
|
+
channelType: ChannelType;
|
|
465
|
+
callback: (data: TokenLiquidity[]) => void;
|
|
782
466
|
}): Unsubscrible {
|
|
783
467
|
const channel = `dex-ranking-token-general_stat_num-list:${chain}_${channelType}`;
|
|
784
468
|
return this.subscribe(channel, (data: any[]) =>
|
|
@@ -954,21 +638,302 @@ export class StreamApi {
|
|
|
954
638
|
);
|
|
955
639
|
}
|
|
956
640
|
|
|
957
|
-
|
|
641
|
+
subscribeRankingTokensStats({
|
|
958
642
|
chain,
|
|
959
|
-
|
|
643
|
+
channelType,
|
|
960
644
|
callback,
|
|
961
|
-
filter,
|
|
962
645
|
}: {
|
|
963
646
|
chain: string;
|
|
964
|
-
|
|
965
|
-
callback: (data:
|
|
966
|
-
filter?: string;
|
|
647
|
+
channelType: ChannelType;
|
|
648
|
+
callback: (data: TokenStat[]) => void;
|
|
967
649
|
}): Unsubscrible {
|
|
968
|
-
const channel = `dex-
|
|
969
|
-
return this.subscribe(channel, (data: any) =>
|
|
970
|
-
callback(
|
|
971
|
-
|
|
650
|
+
const channel = `dex-ranking-token-stats-list:${chain}_${channelType}`;
|
|
651
|
+
return this.subscribe(channel, (data: any[]) =>
|
|
652
|
+
callback(
|
|
653
|
+
data?.map(
|
|
654
|
+
(it: any) =>
|
|
655
|
+
({
|
|
656
|
+
address: it.a,
|
|
657
|
+
timestamp: it.t,
|
|
658
|
+
buys1m: it.b1m,
|
|
659
|
+
sells1m: it.s1m,
|
|
660
|
+
buyers1m: it.be1m,
|
|
661
|
+
sellers1m: it.se1m,
|
|
662
|
+
buyVolumeInUsd1m: this.formatScientificNotation(it.bviu1m),
|
|
663
|
+
sellVolumeInUsd1m: this.formatScientificNotation(it.sviu1m),
|
|
664
|
+
price1m: this.formatScientificNotation(it.p1m),
|
|
665
|
+
openInUsd1m: this.formatScientificNotation(it.oiu1m),
|
|
666
|
+
closeInUsd1m: this.formatScientificNotation(it.ciu1m),
|
|
667
|
+
buys5m: it.b5m,
|
|
668
|
+
sells5m: it.s5m,
|
|
669
|
+
buyers5m: it.be5m,
|
|
670
|
+
sellers5m: it.se5m,
|
|
671
|
+
buyVolumeInUsd5m: this.formatScientificNotation(it.bviu5m),
|
|
672
|
+
sellVolumeInUsd5m: this.formatScientificNotation(it.sviu5m),
|
|
673
|
+
price5m: this.formatScientificNotation(it.p5m),
|
|
674
|
+
openInUsd5m: this.formatScientificNotation(it.oiu5m),
|
|
675
|
+
closeInUsd5m: this.formatScientificNotation(it.ciu5m),
|
|
676
|
+
buys15m: it.b15m,
|
|
677
|
+
sells15m: it.s15m,
|
|
678
|
+
buyers15m: it.be15m,
|
|
679
|
+
sellers15m: it.se15m,
|
|
680
|
+
buyVolumeInUsd15m: this.formatScientificNotation(it.bviu15m),
|
|
681
|
+
sellVolumeInUsd15m: this.formatScientificNotation(it.sviu15m),
|
|
682
|
+
price15m: this.formatScientificNotation(it.p15m),
|
|
683
|
+
openInUsd15m: this.formatScientificNotation(it.oiu15m),
|
|
684
|
+
closeInUsd15m: this.formatScientificNotation(it.ciu15m),
|
|
685
|
+
buys30m: it.b30m,
|
|
686
|
+
sells30m: it.s30m,
|
|
687
|
+
buyers30m: it.be30m,
|
|
688
|
+
sellers30m: it.se30m,
|
|
689
|
+
buyVolumeInUsd30m: this.formatScientificNotation(it.bviu30m),
|
|
690
|
+
sellVolumeInUsd30m: this.formatScientificNotation(it.sviu30m),
|
|
691
|
+
price30m: this.formatScientificNotation(it.p30m),
|
|
692
|
+
openInUsd30m: this.formatScientificNotation(it.oiu30m),
|
|
693
|
+
closeInUsd30m: this.formatScientificNotation(it.ciu30m),
|
|
694
|
+
buys1h: it.b1h,
|
|
695
|
+
sells1h: it.s1h,
|
|
696
|
+
buyers1h: it.be1h,
|
|
697
|
+
sellers1h: it.se1h,
|
|
698
|
+
buyVolumeInUsd1h: this.formatScientificNotation(it.bviu1h),
|
|
699
|
+
sellVolumeInUsd1h: this.formatScientificNotation(it.sviu1h),
|
|
700
|
+
price1h: this.formatScientificNotation(it.p1h),
|
|
701
|
+
openInUsd1h: this.formatScientificNotation(it.oiu1h),
|
|
702
|
+
closeInUsd1h: this.formatScientificNotation(it.ciu1h),
|
|
703
|
+
buys4h: it.b4h,
|
|
704
|
+
sells4h: it.s4h,
|
|
705
|
+
buyers4h: it.be4h,
|
|
706
|
+
sellers4h: it.se4h,
|
|
707
|
+
buyVolumeInUsd4h: this.formatScientificNotation(it.bviu4h),
|
|
708
|
+
sellVolumeInUsd4h: this.formatScientificNotation(it.sviu4h),
|
|
709
|
+
price4h: this.formatScientificNotation(it.p4h),
|
|
710
|
+
openInUsd4h: this.formatScientificNotation(it.oiu4h),
|
|
711
|
+
closeInUsd4h: this.formatScientificNotation(it.ciu4h),
|
|
712
|
+
buys24h: it.b24h,
|
|
713
|
+
sells24h: it.s24h,
|
|
714
|
+
buyers24h: it.be24h,
|
|
715
|
+
sellers24h: it.se24h,
|
|
716
|
+
buyVolumeInUsd24h: this.formatScientificNotation(it.bviu24h),
|
|
717
|
+
sellVolumeInUsd24h: this.formatScientificNotation(it.sviu24h),
|
|
718
|
+
price24h: this.formatScientificNotation(it.p24h),
|
|
719
|
+
price: this.formatScientificNotation(it.p),
|
|
720
|
+
openInUsd24h: this.formatScientificNotation(it.oiu24h),
|
|
721
|
+
closeInUsd24h: this.formatScientificNotation(it.ciu24h),
|
|
722
|
+
}) as TokenStat
|
|
723
|
+
)
|
|
724
|
+
)
|
|
725
|
+
);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
subscribeRankingTokensHolders({
|
|
729
|
+
chain,
|
|
730
|
+
channelType,
|
|
731
|
+
callback,
|
|
732
|
+
}: {
|
|
733
|
+
chain: string;
|
|
734
|
+
channelType: ChannelType;
|
|
735
|
+
callback: (data: TokenHolder[]) => void;
|
|
736
|
+
}): Unsubscrible {
|
|
737
|
+
const channel = `dex-ranking-token-holding-list:${chain}_${channelType}`;
|
|
738
|
+
return this.subscribe(channel, (data: any[]) =>
|
|
739
|
+
callback(
|
|
740
|
+
data?.map(
|
|
741
|
+
(it: any) =>
|
|
742
|
+
({
|
|
743
|
+
tokenAddress: it.a,
|
|
744
|
+
holders: it.h,
|
|
745
|
+
top100Amount: this.formatScientificNotation(it.t100a),
|
|
746
|
+
top10Amount: this.formatScientificNotation(it.t10a),
|
|
747
|
+
top100Holders: it.t100h,
|
|
748
|
+
top10Holders: it.t10h,
|
|
749
|
+
top100Ratio: this.formatScientificNotation(it.t100r),
|
|
750
|
+
top10Ratio: this.formatScientificNotation(it.t10r),
|
|
751
|
+
timestamp: it.ts,
|
|
752
|
+
}) as TokenHolder
|
|
753
|
+
)
|
|
754
|
+
)
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
subscribeRankingTokensSupply({
|
|
759
|
+
chain,
|
|
760
|
+
channelType,
|
|
761
|
+
callback,
|
|
762
|
+
}: {
|
|
763
|
+
chain: string;
|
|
764
|
+
channelType: ChannelType;
|
|
765
|
+
callback: (data: TokenSupply[]) => void;
|
|
766
|
+
}): Unsubscrible {
|
|
767
|
+
const channel = `dex-ranking-token-supply-list:${chain}_${channelType}`;
|
|
768
|
+
return this.subscribe(channel, (data: any[]) =>
|
|
769
|
+
callback(
|
|
770
|
+
data?.map(
|
|
771
|
+
(it: any) =>
|
|
772
|
+
({
|
|
773
|
+
tokenAddress: it.a,
|
|
774
|
+
supply: it.s,
|
|
775
|
+
marketCapInUsd: it.mc,
|
|
776
|
+
timestamp: it.ts,
|
|
777
|
+
})
|
|
778
|
+
)
|
|
779
|
+
)
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// subscribeTokenTrades({
|
|
784
|
+
// chain,
|
|
785
|
+
// tokenAddress,
|
|
786
|
+
// callback,
|
|
787
|
+
// }: {
|
|
788
|
+
// chain: string;
|
|
789
|
+
// tokenAddress: string;
|
|
790
|
+
// callback: (data: TradeEvent[]) => void;
|
|
791
|
+
// }): Unsubscrible {
|
|
792
|
+
// const channel = `dex-trades:${chain}_${tokenAddress}`;
|
|
793
|
+
// return this.subscribe(channel, (data: any[]) =>
|
|
794
|
+
// callback(
|
|
795
|
+
// data?.map(
|
|
796
|
+
// (it: any) =>
|
|
797
|
+
// ({
|
|
798
|
+
// maker: it.bwa,
|
|
799
|
+
// baseAmount: it.ba,
|
|
800
|
+
// quoteAmount: it.sa,
|
|
801
|
+
// // quoteSymbol: ,
|
|
802
|
+
// quoteAddress: it.swa,
|
|
803
|
+
// amountInUsd: it.baiu,
|
|
804
|
+
// timestamp: it.t,
|
|
805
|
+
// event: it.k,
|
|
806
|
+
// txHash: it.h,
|
|
807
|
+
// // priceInUsd: ,
|
|
808
|
+
// // id: ,
|
|
809
|
+
// // buyCostUsd: it.,
|
|
810
|
+
// tokenAddress: it.a,
|
|
811
|
+
// }) as TradeEvent
|
|
812
|
+
// )
|
|
813
|
+
// )
|
|
814
|
+
// );
|
|
815
|
+
// }
|
|
816
|
+
|
|
817
|
+
subscribeWalletBalance({
|
|
818
|
+
chain,
|
|
819
|
+
walletAddress,
|
|
820
|
+
callback,
|
|
821
|
+
filter,
|
|
822
|
+
}: {
|
|
823
|
+
chain: string;
|
|
824
|
+
walletAddress: string;
|
|
825
|
+
callback: (data: WalletBalance[]) => void;
|
|
826
|
+
filter?: string;
|
|
827
|
+
}): Unsubscrible {
|
|
828
|
+
const channel = `dex-wallet-balance:${chain}_${walletAddress}`;
|
|
829
|
+
return this.subscribe(channel, (data: any) =>
|
|
830
|
+
callback([
|
|
831
|
+
{
|
|
832
|
+
walletAddress: data.a,
|
|
833
|
+
tokenAddress: data.ta,
|
|
834
|
+
tokenPriceInUsd: data.tpiu,
|
|
835
|
+
balance: data.b,
|
|
836
|
+
timestamp: data.t,
|
|
837
|
+
} as WalletBalance,
|
|
838
|
+
]), filter, "subscribeWalletBalance");
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
subscribeWalletPnl({
|
|
842
|
+
chain,
|
|
843
|
+
walletAddress,
|
|
844
|
+
callback,
|
|
845
|
+
filter,
|
|
846
|
+
}: {
|
|
847
|
+
chain: string;
|
|
848
|
+
walletAddress: string;
|
|
849
|
+
callback: (data: WalletTokenPnl) => void;
|
|
850
|
+
filter?: string;
|
|
851
|
+
}): Unsubscrible {
|
|
852
|
+
const channel = `dex-wallet-token-pnl:${chain}_${walletAddress}`;
|
|
853
|
+
return this.subscribe(channel, (data: any) =>
|
|
854
|
+
callback({
|
|
855
|
+
walletAddress: data.a,
|
|
856
|
+
tokenAddress: data.ta,
|
|
857
|
+
tokenPriceInUsd: data.tpiu,
|
|
858
|
+
timestamp: data.t,
|
|
859
|
+
opentime: data.ot,
|
|
860
|
+
lasttime: data.lt,
|
|
861
|
+
closetime: data.ct,
|
|
862
|
+
buyAmount: data.ba,
|
|
863
|
+
buyAmountInUsd: data.baiu,
|
|
864
|
+
buyCount: data.bs,
|
|
865
|
+
buyCount30d: data.bs30d,
|
|
866
|
+
buyCount7d: data.bs7d,
|
|
867
|
+
sellAmount: data.sa,
|
|
868
|
+
sellAmountInUsd: data.saiu,
|
|
869
|
+
sellCount: data.ss,
|
|
870
|
+
sellCount30d: data.ss30d,
|
|
871
|
+
sellCount7d: data.ss7d,
|
|
872
|
+
heldDurationTimestamp: data.hdts,
|
|
873
|
+
averageBuyPriceInUsd: data.abpiu,
|
|
874
|
+
averageSellPriceInUsd: data.aspiu,
|
|
875
|
+
unrealizedProfitInUsd: data.upiu,
|
|
876
|
+
unrealizedProfitRatio: data.upr,
|
|
877
|
+
realizedProfitInUsd: data.rpiu,
|
|
878
|
+
realizedProfitRatio: data.rpr,
|
|
879
|
+
totalRealizedProfitInUsd: data.trpiu,
|
|
880
|
+
totalRealizedProfitRatio: data.trr,
|
|
881
|
+
}), filter, "subscribeWalletPnl");
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
subscribeWalletPnlList({
|
|
885
|
+
chain,
|
|
886
|
+
walletAddress,
|
|
887
|
+
callback,
|
|
888
|
+
}: {
|
|
889
|
+
chain: string;
|
|
890
|
+
walletAddress: string;
|
|
891
|
+
callback: (data: WalletPnl[]) => void;
|
|
892
|
+
}): Unsubscrible {
|
|
893
|
+
const channel = `dex-wallet-pnl-list:${chain}_${walletAddress}`;
|
|
894
|
+
return this.subscribe(channel, (data: any[]) =>
|
|
895
|
+
callback(
|
|
896
|
+
data?.map(
|
|
897
|
+
(it: any) =>
|
|
898
|
+
({
|
|
899
|
+
walletAddress: it.a,
|
|
900
|
+
buys: it.bs,
|
|
901
|
+
buyAmount: it.ba,
|
|
902
|
+
buyAmountInUsd: it.baiu,
|
|
903
|
+
averageBuyPriceInUsd: it.abpiu,
|
|
904
|
+
sellAmount: it.sa,
|
|
905
|
+
sellAmountInUsd: it.saiu,
|
|
906
|
+
sells: it.ss,
|
|
907
|
+
wins: it.ws,
|
|
908
|
+
winRatio: it.wr,
|
|
909
|
+
pnlInUsd: it.piu,
|
|
910
|
+
averagePnlInUsd: it.apiu,
|
|
911
|
+
pnlRatio: it.pr,
|
|
912
|
+
profitableDays: it.pd,
|
|
913
|
+
losingDays: it.ld,
|
|
914
|
+
tokens: it.ts,
|
|
915
|
+
resolution: it.r,
|
|
916
|
+
}) as WalletPnl
|
|
917
|
+
)
|
|
918
|
+
)
|
|
919
|
+
);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
subscribeTokenTrade({
|
|
923
|
+
chain,
|
|
924
|
+
tokenAddress,
|
|
925
|
+
callback,
|
|
926
|
+
filter,
|
|
927
|
+
}: {
|
|
928
|
+
chain: string;
|
|
929
|
+
tokenAddress: string;
|
|
930
|
+
callback: (data: TradeActivity) => void;
|
|
931
|
+
filter?: string;
|
|
932
|
+
}): Unsubscrible {
|
|
933
|
+
const channel = `dex-trade:${chain}_${tokenAddress}`;
|
|
934
|
+
return this.subscribe(channel, (data: any) =>
|
|
935
|
+
callback({
|
|
936
|
+
tokenAddress: data.a,
|
|
972
937
|
timestamp: data.t,
|
|
973
938
|
kind: data.k,
|
|
974
939
|
buyAmount: data.ba,
|
|
@@ -986,6 +951,60 @@ export class StreamApi {
|
|
|
986
951
|
txHash: data.h,
|
|
987
952
|
}), filter, "subscribeTokenTrades");
|
|
988
953
|
}
|
|
954
|
+
|
|
955
|
+
subscribeWalletTrade({
|
|
956
|
+
chain,
|
|
957
|
+
walletAddress,
|
|
958
|
+
callback,
|
|
959
|
+
filter,
|
|
960
|
+
}: {
|
|
961
|
+
chain: string;
|
|
962
|
+
walletAddress: string;
|
|
963
|
+
callback: (data: TradeActivity) => void;
|
|
964
|
+
filter?: string;
|
|
965
|
+
}): Unsubscrible {
|
|
966
|
+
const channel = `dex-wallet-trade:${chain}_${walletAddress}`;
|
|
967
|
+
return this.subscribe(channel, (data: any) =>
|
|
968
|
+
callback({
|
|
969
|
+
tokenAddress: data.a,
|
|
970
|
+
timestamp: data.t,
|
|
971
|
+
kind: data.k,
|
|
972
|
+
buyAmount: data.ba,
|
|
973
|
+
buyAmountInUsd: data.baiu,
|
|
974
|
+
buyTokenAddress: data.btma,
|
|
975
|
+
buyTokenName: data.btn,
|
|
976
|
+
buyTokenSymbol: data.bts,
|
|
977
|
+
buyWalletAddress: data.bwa,
|
|
978
|
+
sellAmount: data.sa,
|
|
979
|
+
sellAmountInUsd: data.saiu,
|
|
980
|
+
sellTokenAddress: data.stma,
|
|
981
|
+
sellTokenName: data.stn,
|
|
982
|
+
sellTokenSymbol: data.sts,
|
|
983
|
+
sellWalletAddress: data.swa,
|
|
984
|
+
txHash: data.h,
|
|
985
|
+
}), filter, "subscribeTokenTrades");
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
subscribeDexPoolBalance({
|
|
989
|
+
chain,
|
|
990
|
+
poolAddress,
|
|
991
|
+
callback,
|
|
992
|
+
}: {
|
|
993
|
+
chain: string;
|
|
994
|
+
poolAddress: string;
|
|
995
|
+
callback: (data: DexPoolBalance) => void;
|
|
996
|
+
}): Unsubscrible {
|
|
997
|
+
const channel = `dex-pool-balance:${chain}_${poolAddress}`;
|
|
998
|
+
return this.subscribe(channel, (data: any) =>
|
|
999
|
+
callback({
|
|
1000
|
+
poolAddress: data.a,
|
|
1001
|
+
tokenAAddress: data.taa,
|
|
1002
|
+
tokenALiquidityInUsd: data.taliu,
|
|
1003
|
+
tokenBAddress: data.tba,
|
|
1004
|
+
tokenBLiquidityInUsd: data.tbliu,
|
|
1005
|
+
})
|
|
1006
|
+
);
|
|
1007
|
+
}
|
|
989
1008
|
}
|
|
990
1009
|
class StreamUnsubscrible<T> {
|
|
991
1010
|
constructor(
|