@chainstream-io/sdk 0.2.6 → 0.2.7

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/index.cjs CHANGED
@@ -39,11 +39,13 @@ __export(index_exports, {
39
39
  ChainStreamClient: () => ChainStreamClient,
40
40
  ChainSymbol: () => ChainSymbol,
41
41
  ClaimRedPacketInputChain: () => ClaimRedPacketInputChain,
42
+ CreateEndpointInputChannelsItem: () => CreateEndpointInputChannelsItem,
42
43
  CreateRedPacketInputChain: () => CreateRedPacketInputChain,
43
44
  CreateTokenInputDex: () => CreateTokenInputDex,
44
45
  DexPoolDTOLiquidityModel: () => DexPoolDTOLiquidityModel,
45
46
  DexPoolDTOType: () => DexPoolDTOType,
46
47
  DexPoolDTOVersion: () => DexPoolDTOVersion,
48
+ EndpointResponseChannelsItem: () => EndpointResponseChannelsItem,
47
49
  FilterConditionField: () => FilterConditionField,
48
50
  GetActivitiesDirection: () => GetActivitiesDirection,
49
51
  GetActivitiesType: () => GetActivitiesType,
@@ -88,6 +90,7 @@ __export(index_exports, {
88
90
  ListTokenSortBy: () => ListTokenSortBy,
89
91
  MoonshotCreateTokenInputDex: () => MoonshotCreateTokenInputDex,
90
92
  MoonshotCreateTokenInputMigrationDex: () => MoonshotCreateTokenInputMigrationDex,
93
+ PriceType: () => PriceType,
91
94
  PumpCreateTokenInputDex: () => PumpCreateTokenInputDex,
92
95
  PumpCreateTokenInputMigrationDex: () => PumpCreateTokenInputMigrationDex,
93
96
  QuoteDex: () => QuoteDex,
@@ -103,6 +106,7 @@ __export(index_exports, {
103
106
  TokenCreationDTOType: () => TokenCreationDTOType,
104
107
  TokenTraderTag: () => TokenTraderTag,
105
108
  TradeType: () => TradeType,
109
+ UpdateEndpointInputChannelsItem: () => UpdateEndpointInputChannelsItem,
106
110
  WsChannelType: () => WsChannelType,
107
111
  WsDex: () => WsDex,
108
112
  WsMetricType: () => WsMetricType,
@@ -144,8 +148,10 @@ __export(index_exports, {
144
148
  getMigratedTokens: () => getMigratedTokens,
145
149
  getMintAndBurn: () => getMintAndBurn,
146
150
  getNewTokens: () => getNewTokens,
151
+ getPairCandles: () => getPairCandles,
147
152
  getPnl: () => getPnl,
148
153
  getPnlStats: () => getPnlStats,
154
+ getPoolCandles: () => getPoolCandles,
149
155
  getPools: () => getPools,
150
156
  getPriceByTime: () => getPriceByTime,
151
157
  getPrices: () => getPrices,
@@ -745,32 +751,92 @@ var StreamApi = class {
745
751
  }
746
752
  return strValue;
747
753
  }
754
+ /**
755
+ * Parse candle data from WebSocket message
756
+ */
757
+ parseCandleData(data) {
758
+ return {
759
+ address: data.a,
760
+ open: data.o,
761
+ close: data.c,
762
+ high: data.h,
763
+ low: data.l,
764
+ volume: data.v,
765
+ resolution: data.r,
766
+ time: data.t,
767
+ number: data.n
768
+ };
769
+ }
770
+ /**
771
+ * Subscribe to token candles (K-line)
772
+ * Channel: dex-candle:{chain}_{tokenAddress}_{resolution} (USD)
773
+ * Channel: dex-candle-in-native:{chain}_{tokenAddress}_{resolution} (Native)
774
+ * @param priceType - "usd" (default) or "native"
775
+ */
748
776
  subscribeTokenCandles({
749
777
  chain,
750
778
  tokenAddress,
751
779
  resolution,
752
780
  callback,
753
- filter
781
+ filter,
782
+ priceType = "usd"
754
783
  }) {
755
- const channel = `dex-candle:${chain}_${tokenAddress}_${resolution}`;
784
+ const prefix = priceType === "native" ? "dex-candle-in-native" : "dex-candle";
785
+ const channel = `${prefix}:${chain}_${tokenAddress}_${resolution}`;
756
786
  return this.subscribe(
757
787
  channel,
758
- (data) => {
759
- callback({
760
- open: data.o,
761
- close: data.c,
762
- high: data.h,
763
- low: data.l,
764
- volume: data.v,
765
- resolution: data.r,
766
- time: data.t,
767
- number: data.n
768
- });
769
- },
788
+ (data) => callback(this.parseCandleData(data)),
770
789
  filter,
771
790
  "subscribeTokenCandles"
772
791
  );
773
792
  }
793
+ /**
794
+ * Subscribe to pool candles (K-line)
795
+ * Channel: dex-pool-candle:{chain}_{poolAddress}_{resolution} (USD)
796
+ * Channel: dex-pool-candle-in-native:{chain}_{poolAddress}_{resolution} (Native)
797
+ * @param priceType - "usd" (default) or "native"
798
+ */
799
+ subscribePoolCandles({
800
+ chain,
801
+ poolAddress,
802
+ resolution,
803
+ callback,
804
+ filter,
805
+ priceType = "usd"
806
+ }) {
807
+ const prefix = priceType === "native" ? "dex-pool-candle-in-native" : "dex-pool-candle";
808
+ const channel = `${prefix}:${chain}_${poolAddress}_${resolution}`;
809
+ return this.subscribe(
810
+ channel,
811
+ (data) => callback(this.parseCandleData(data)),
812
+ filter,
813
+ "subscribePoolCandles"
814
+ );
815
+ }
816
+ /**
817
+ * Subscribe to pair candles (K-line)
818
+ * Channel: dex-pair-candle:{chain}_{pairAddress}_{resolution} (USD)
819
+ * Channel: dex-pair-candle-in-native:{chain}_{pairAddress}_{resolution} (Native)
820
+ * @param pairAddress - format: {tokenA}-{tokenB}
821
+ * @param priceType - "usd" (default) or "native"
822
+ */
823
+ subscribePairCandles({
824
+ chain,
825
+ pairAddress,
826
+ resolution,
827
+ callback,
828
+ filter,
829
+ priceType = "usd"
830
+ }) {
831
+ const prefix = priceType === "native" ? "dex-pair-candle-in-native" : "dex-pair-candle";
832
+ const channel = `${prefix}:${chain}_${pairAddress}_${resolution}`;
833
+ return this.subscribe(
834
+ channel,
835
+ (data) => callback(this.parseCandleData(data)),
836
+ filter,
837
+ "subscribePairCandles"
838
+ );
839
+ }
774
840
  subscribeTokenStats({
775
841
  chain,
776
842
  tokenAddress,
@@ -2087,6 +2153,8 @@ __export(token_exports, {
2087
2153
  getMetadata: () => getMetadata,
2088
2154
  getMetadataMulti: () => getMetadataMulti,
2089
2155
  getMintAndBurn: () => getMintAndBurn,
2156
+ getPairCandles: () => getPairCandles,
2157
+ getPoolCandles: () => getPoolCandles,
2090
2158
  getPools: () => getPools,
2091
2159
  getPriceByTime: () => getPriceByTime,
2092
2160
  getPrices: () => getPrices,
@@ -2167,6 +2235,18 @@ var getCandles = (chain, tokenAddress, params, options) => {
2167
2235
  options
2168
2236
  );
2169
2237
  };
2238
+ var getPoolCandles = (chain, poolAddress, params, options) => {
2239
+ return chainstreamApiClient(
2240
+ { url: `/v1/token/${chain}/pool/${poolAddress}/candles`, method: "GET", params },
2241
+ options
2242
+ );
2243
+ };
2244
+ var getPairCandles = (chain, pair, params, options) => {
2245
+ return chainstreamApiClient(
2246
+ { url: `/v1/token/${chain}/pair/${pair}/candles`, method: "GET", params },
2247
+ options
2248
+ );
2249
+ };
2170
2250
  var getTopHolders = (chain, tokenAddress, options) => {
2171
2251
  return chainstreamApiClient(
2172
2252
  { url: `/v1/token/${chain}/${tokenAddress}/topHolders`, method: "GET" },
@@ -2594,12 +2674,24 @@ var Resolution = {
2594
2674
  "15s": "15s",
2595
2675
  "30s": "30s",
2596
2676
  "1m": "1m",
2677
+ "3m": "3m",
2597
2678
  "5m": "5m",
2598
2679
  "15m": "15m",
2680
+ "30m": "30m",
2599
2681
  "1h": "1h",
2682
+ "2h": "2h",
2600
2683
  "4h": "4h",
2684
+ "6h": "6h",
2685
+ "8h": "8h",
2601
2686
  "12h": "12h",
2602
- "1d": "1d"
2687
+ "1d": "1d",
2688
+ "3d": "3d",
2689
+ "1w": "1w",
2690
+ "1M": "1M"
2691
+ };
2692
+ var PriceType = {
2693
+ usd: "usd",
2694
+ native: "native"
2603
2695
  };
2604
2696
  var TokenCreationDTOType = {
2605
2697
  create: "create",
@@ -2615,7 +2707,8 @@ var TokenTraderTag = {
2615
2707
  pro: "pro",
2616
2708
  insider: "insider",
2617
2709
  kol: "kol",
2618
- bluechip: "bluechip"
2710
+ bluechip: "bluechip",
2711
+ smart: "smart"
2619
2712
  };
2620
2713
  var BalanceTokenType = {
2621
2714
  SOL: "SOL",
@@ -2654,6 +2747,18 @@ var KYTRegisterWithdrawalRequestNetwork = {
2654
2747
  ethereum: "ethereum",
2655
2748
  Solana: "Solana"
2656
2749
  };
2750
+ var EndpointResponseChannelsItem = {
2751
+ soltokenmigrated: "sol.token.migrated",
2752
+ soltokencreated: "sol.token.created"
2753
+ };
2754
+ var CreateEndpointInputChannelsItem = {
2755
+ soltokenmigrated: "sol.token.migrated",
2756
+ soltokencreated: "sol.token.created"
2757
+ };
2758
+ var UpdateEndpointInputChannelsItem = {
2759
+ soltokenmigrated: "sol.token.migrated",
2760
+ soltokencreated: "sol.token.created"
2761
+ };
2657
2762
  var TradeType = {
2658
2763
  buy: "buy",
2659
2764
  sell: "sell"
@@ -3187,11 +3292,13 @@ var ListEndpointsOrder = {
3187
3292
  ChainStreamClient,
3188
3293
  ChainSymbol,
3189
3294
  ClaimRedPacketInputChain,
3295
+ CreateEndpointInputChannelsItem,
3190
3296
  CreateRedPacketInputChain,
3191
3297
  CreateTokenInputDex,
3192
3298
  DexPoolDTOLiquidityModel,
3193
3299
  DexPoolDTOType,
3194
3300
  DexPoolDTOVersion,
3301
+ EndpointResponseChannelsItem,
3195
3302
  FilterConditionField,
3196
3303
  GetActivitiesDirection,
3197
3304
  GetActivitiesType,
@@ -3236,6 +3343,7 @@ var ListEndpointsOrder = {
3236
3343
  ListTokenSortBy,
3237
3344
  MoonshotCreateTokenInputDex,
3238
3345
  MoonshotCreateTokenInputMigrationDex,
3346
+ PriceType,
3239
3347
  PumpCreateTokenInputDex,
3240
3348
  PumpCreateTokenInputMigrationDex,
3241
3349
  QuoteDex,
@@ -3251,6 +3359,7 @@ var ListEndpointsOrder = {
3251
3359
  TokenCreationDTOType,
3252
3360
  TokenTraderTag,
3253
3361
  TradeType,
3362
+ UpdateEndpointInputChannelsItem,
3254
3363
  WsChannelType,
3255
3364
  WsDex,
3256
3365
  WsMetricType,
@@ -3292,8 +3401,10 @@ var ListEndpointsOrder = {
3292
3401
  getMigratedTokens,
3293
3402
  getMintAndBurn,
3294
3403
  getNewTokens,
3404
+ getPairCandles,
3295
3405
  getPnl,
3296
3406
  getPnlStats,
3407
+ getPoolCandles,
3297
3408
  getPools,
3298
3409
  getPriceByTime,
3299
3410
  getPrices,