@chainstream-io/sdk 0.2.8 → 0.2.9
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/{chainstream-KjjsTvPO.d.cts → chainstream-B9uaC_fe.d.cts} +145 -254
- package/dist/{chainstream-KjjsTvPO.d.ts → chainstream-B9uaC_fe.d.ts} +145 -254
- package/dist/chainstream.cjs +45 -68
- package/dist/chainstream.cjs.map +1 -1
- package/dist/chainstream.d.cts +1 -1
- package/dist/chainstream.d.ts +1 -1
- package/dist/chainstream.mjs +45 -68
- package/dist/chainstream.mjs.map +1 -1
- package/dist/index.cjs +45 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +45 -68
- package/dist/index.mjs.map +1 -1
- package/dist/stream/index.cjs +45 -68
- package/dist/stream/index.cjs.map +1 -1
- package/dist/stream/index.d.cts +1 -1
- package/dist/stream/index.d.ts +1 -1
- package/dist/stream/index.mjs +45 -68
- package/dist/stream/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/chainstream.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as ChainStreamClient, y as ChainStreamClientOptions, z as ChainStreamRequestContext,
|
|
1
|
+
export { C as ChainStreamClient, y as ChainStreamClientOptions, z as ChainStreamRequestContext, h4 as PostOptions, T as TokenProvider } from './chainstream-B9uaC_fe.cjs';
|
|
2
2
|
import 'axios';
|
package/dist/chainstream.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as ChainStreamClient, y as ChainStreamClientOptions, z as ChainStreamRequestContext,
|
|
1
|
+
export { C as ChainStreamClient, y as ChainStreamClientOptions, z as ChainStreamRequestContext, h4 as PostOptions, T as TokenProvider } from './chainstream-B9uaC_fe.js';
|
|
2
2
|
import 'axios';
|
package/dist/chainstream.mjs
CHANGED
|
@@ -635,6 +635,35 @@ var StreamApi = class {
|
|
|
635
635
|
"subscribePairCandles"
|
|
636
636
|
);
|
|
637
637
|
}
|
|
638
|
+
/**
|
|
639
|
+
* Parse token stat data for a specific time window
|
|
640
|
+
* @param data - Raw WebSocket data
|
|
641
|
+
* @param suffix - Time window suffix (e.g., "1m", "5m", "1h", "1W", "1M")
|
|
642
|
+
*/
|
|
643
|
+
parseTokenStatWindow(data, suffix) {
|
|
644
|
+
return {
|
|
645
|
+
[`buys${suffix}`]: data[`b${suffix}`],
|
|
646
|
+
[`sells${suffix}`]: data[`s${suffix}`],
|
|
647
|
+
[`buyers${suffix}`]: data[`be${suffix}`],
|
|
648
|
+
[`sellers${suffix}`]: data[`se${suffix}`],
|
|
649
|
+
[`buyVolumeInUsd${suffix}`]: this.formatScientificNotation(data[`bviu${suffix}`]),
|
|
650
|
+
[`sellVolumeInUsd${suffix}`]: this.formatScientificNotation(data[`sviu${suffix}`]),
|
|
651
|
+
[`price${suffix}`]: this.formatScientificNotation(data[`p${suffix}`]),
|
|
652
|
+
[`openInUsd${suffix}`]: this.formatScientificNotation(data[`oiu${suffix}`]),
|
|
653
|
+
[`closeInUsd${suffix}`]: this.formatScientificNotation(data[`ciu${suffix}`]),
|
|
654
|
+
[`volumeChangeRatio${suffix}`]: this.formatScientificNotation(data[`vpc${suffix}`]),
|
|
655
|
+
[`trades${suffix}`]: data[`tr${suffix}`],
|
|
656
|
+
[`dappProgramCount${suffix}`]: data[`dpc${suffix}`],
|
|
657
|
+
[`poolCount${suffix}`]: data[`pc${suffix}`],
|
|
658
|
+
[`liquidityInUsd${suffix}`]: this.formatScientificNotation(data[`liq${suffix}`]),
|
|
659
|
+
[`liquidityChangeRatio${suffix}`]: this.formatScientificNotation(data[`lpc${suffix}`])
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Subscribe to token trade statistics
|
|
664
|
+
* Channel: dex-token-stats:{chain}_{tokenAddress}
|
|
665
|
+
* Time windows: 1m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 24h, 1W, 1M
|
|
666
|
+
*/
|
|
638
667
|
subscribeTokenStats({
|
|
639
668
|
chain,
|
|
640
669
|
tokenAddress,
|
|
@@ -642,76 +671,24 @@ var StreamApi = class {
|
|
|
642
671
|
filter
|
|
643
672
|
}) {
|
|
644
673
|
const channel = `dex-token-stats:${chain}_${tokenAddress}`;
|
|
674
|
+
const timeWindows = ["1m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "24h", "1W", "1M"];
|
|
645
675
|
return this.subscribe(
|
|
646
676
|
channel,
|
|
647
|
-
(data) =>
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
sellers5m: data.se5m,
|
|
663
|
-
buyVolumeInUsd5m: this.formatScientificNotation(data.bviu5m),
|
|
664
|
-
sellVolumeInUsd5m: this.formatScientificNotation(data.sviu5m),
|
|
665
|
-
price5m: this.formatScientificNotation(data.p5m),
|
|
666
|
-
openInUsd5m: this.formatScientificNotation(data.oiu5m),
|
|
667
|
-
closeInUsd5m: this.formatScientificNotation(data.ciu5m),
|
|
668
|
-
buys15m: data.b15m,
|
|
669
|
-
sells15m: data.s15m,
|
|
670
|
-
buyers15m: data.be15m,
|
|
671
|
-
sellers15m: data.se15m,
|
|
672
|
-
buyVolumeInUsd15m: this.formatScientificNotation(data.bviu15m),
|
|
673
|
-
sellVolumeInUsd15m: this.formatScientificNotation(data.sviu15m),
|
|
674
|
-
price15m: this.formatScientificNotation(data.p15m),
|
|
675
|
-
openInUsd15m: this.formatScientificNotation(data.oiu15m),
|
|
676
|
-
closeInUsd15m: this.formatScientificNotation(data.ciu15m),
|
|
677
|
-
buys30m: data.b30m,
|
|
678
|
-
sells30m: data.s30m,
|
|
679
|
-
buyers30m: data.be30m,
|
|
680
|
-
sellers30m: data.se30m,
|
|
681
|
-
buyVolumeInUsd30m: this.formatScientificNotation(data.bviu30m),
|
|
682
|
-
sellVolumeInUsd30m: this.formatScientificNotation(data.sviu30m),
|
|
683
|
-
price30m: this.formatScientificNotation(data.p30m),
|
|
684
|
-
openInUsd30m: this.formatScientificNotation(data.oiu30m),
|
|
685
|
-
closeInUsd30m: this.formatScientificNotation(data.ciu30m),
|
|
686
|
-
buys1h: data.b1h,
|
|
687
|
-
sells1h: data.s1h,
|
|
688
|
-
buyers1h: data.be1h,
|
|
689
|
-
sellers1h: data.se1h,
|
|
690
|
-
buyVolumeInUsd1h: this.formatScientificNotation(data.bviu1h),
|
|
691
|
-
sellVolumeInUsd1h: this.formatScientificNotation(data.sviu1h),
|
|
692
|
-
price1h: this.formatScientificNotation(data.p1h),
|
|
693
|
-
openInUsd1h: this.formatScientificNotation(data.oiu1h),
|
|
694
|
-
closeInUsd1h: this.formatScientificNotation(data.ciu1h),
|
|
695
|
-
buys4h: data.b4h,
|
|
696
|
-
sells4h: data.s4h,
|
|
697
|
-
buyers4h: data.be4h,
|
|
698
|
-
sellers4h: data.se4h,
|
|
699
|
-
buyVolumeInUsd4h: this.formatScientificNotation(data.bviu4h),
|
|
700
|
-
sellVolumeInUsd4h: this.formatScientificNotation(data.sviu4h),
|
|
701
|
-
price4h: this.formatScientificNotation(data.p4h),
|
|
702
|
-
openInUsd4h: this.formatScientificNotation(data.oiu4h),
|
|
703
|
-
closeInUsd4h: this.formatScientificNotation(data.ciu4h),
|
|
704
|
-
buys24h: data.b24h,
|
|
705
|
-
sells24h: data.s24h,
|
|
706
|
-
buyers24h: data.be24h,
|
|
707
|
-
sellers24h: data.se24h,
|
|
708
|
-
buyVolumeInUsd24h: this.formatScientificNotation(data.bviu24h),
|
|
709
|
-
sellVolumeInUsd24h: this.formatScientificNotation(data.sviu24h),
|
|
710
|
-
price24h: this.formatScientificNotation(data.p24h),
|
|
711
|
-
openInUsd24h: this.formatScientificNotation(data.oiu24h),
|
|
712
|
-
closeInUsd24h: this.formatScientificNotation(data.ciu24h),
|
|
713
|
-
price: this.formatScientificNotation(data.p)
|
|
714
|
-
}),
|
|
677
|
+
(data) => {
|
|
678
|
+
const windowData = timeWindows.reduce(
|
|
679
|
+
(acc, suffix) => ({
|
|
680
|
+
...acc,
|
|
681
|
+
...this.parseTokenStatWindow(data, suffix)
|
|
682
|
+
}),
|
|
683
|
+
{}
|
|
684
|
+
);
|
|
685
|
+
callback({
|
|
686
|
+
address: data.a,
|
|
687
|
+
timestamp: data.t,
|
|
688
|
+
price: this.formatScientificNotation(data.p),
|
|
689
|
+
...windowData
|
|
690
|
+
});
|
|
691
|
+
},
|
|
715
692
|
filter,
|
|
716
693
|
"subscribeTokenStats"
|
|
717
694
|
);
|