@chainstream-io/sdk 0.2.7 → 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-kxqV2g1Q.d.cts → chainstream-B9uaC_fe.d.cts} +1055 -394
- package/dist/{chainstream-kxqV2g1Q.d.ts → chainstream-B9uaC_fe.d.ts} +1055 -394
- package/dist/chainstream.cjs +137 -76
- 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 +137 -76
- package/dist/chainstream.mjs.map +1 -1
- package/dist/index.cjs +303 -80
- 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 +267 -78
- 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.cjs
CHANGED
|
@@ -663,6 +663,35 @@ var StreamApi = class {
|
|
|
663
663
|
"subscribePairCandles"
|
|
664
664
|
);
|
|
665
665
|
}
|
|
666
|
+
/**
|
|
667
|
+
* Parse token stat data for a specific time window
|
|
668
|
+
* @param data - Raw WebSocket data
|
|
669
|
+
* @param suffix - Time window suffix (e.g., "1m", "5m", "1h", "1W", "1M")
|
|
670
|
+
*/
|
|
671
|
+
parseTokenStatWindow(data, suffix) {
|
|
672
|
+
return {
|
|
673
|
+
[`buys${suffix}`]: data[`b${suffix}`],
|
|
674
|
+
[`sells${suffix}`]: data[`s${suffix}`],
|
|
675
|
+
[`buyers${suffix}`]: data[`be${suffix}`],
|
|
676
|
+
[`sellers${suffix}`]: data[`se${suffix}`],
|
|
677
|
+
[`buyVolumeInUsd${suffix}`]: this.formatScientificNotation(data[`bviu${suffix}`]),
|
|
678
|
+
[`sellVolumeInUsd${suffix}`]: this.formatScientificNotation(data[`sviu${suffix}`]),
|
|
679
|
+
[`price${suffix}`]: this.formatScientificNotation(data[`p${suffix}`]),
|
|
680
|
+
[`openInUsd${suffix}`]: this.formatScientificNotation(data[`oiu${suffix}`]),
|
|
681
|
+
[`closeInUsd${suffix}`]: this.formatScientificNotation(data[`ciu${suffix}`]),
|
|
682
|
+
[`volumeChangeRatio${suffix}`]: this.formatScientificNotation(data[`vpc${suffix}`]),
|
|
683
|
+
[`trades${suffix}`]: data[`tr${suffix}`],
|
|
684
|
+
[`dappProgramCount${suffix}`]: data[`dpc${suffix}`],
|
|
685
|
+
[`poolCount${suffix}`]: data[`pc${suffix}`],
|
|
686
|
+
[`liquidityInUsd${suffix}`]: this.formatScientificNotation(data[`liq${suffix}`]),
|
|
687
|
+
[`liquidityChangeRatio${suffix}`]: this.formatScientificNotation(data[`lpc${suffix}`])
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Subscribe to token trade statistics
|
|
692
|
+
* Channel: dex-token-stats:{chain}_{tokenAddress}
|
|
693
|
+
* Time windows: 1m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 24h, 1W, 1M
|
|
694
|
+
*/
|
|
666
695
|
subscribeTokenStats({
|
|
667
696
|
chain,
|
|
668
697
|
tokenAddress,
|
|
@@ -670,76 +699,24 @@ var StreamApi = class {
|
|
|
670
699
|
filter
|
|
671
700
|
}) {
|
|
672
701
|
const channel = `dex-token-stats:${chain}_${tokenAddress}`;
|
|
702
|
+
const timeWindows = ["1m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "24h", "1W", "1M"];
|
|
673
703
|
return this.subscribe(
|
|
674
704
|
channel,
|
|
675
|
-
(data) =>
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
sellers5m: data.se5m,
|
|
691
|
-
buyVolumeInUsd5m: this.formatScientificNotation(data.bviu5m),
|
|
692
|
-
sellVolumeInUsd5m: this.formatScientificNotation(data.sviu5m),
|
|
693
|
-
price5m: this.formatScientificNotation(data.p5m),
|
|
694
|
-
openInUsd5m: this.formatScientificNotation(data.oiu5m),
|
|
695
|
-
closeInUsd5m: this.formatScientificNotation(data.ciu5m),
|
|
696
|
-
buys15m: data.b15m,
|
|
697
|
-
sells15m: data.s15m,
|
|
698
|
-
buyers15m: data.be15m,
|
|
699
|
-
sellers15m: data.se15m,
|
|
700
|
-
buyVolumeInUsd15m: this.formatScientificNotation(data.bviu15m),
|
|
701
|
-
sellVolumeInUsd15m: this.formatScientificNotation(data.sviu15m),
|
|
702
|
-
price15m: this.formatScientificNotation(data.p15m),
|
|
703
|
-
openInUsd15m: this.formatScientificNotation(data.oiu15m),
|
|
704
|
-
closeInUsd15m: this.formatScientificNotation(data.ciu15m),
|
|
705
|
-
buys30m: data.b30m,
|
|
706
|
-
sells30m: data.s30m,
|
|
707
|
-
buyers30m: data.be30m,
|
|
708
|
-
sellers30m: data.se30m,
|
|
709
|
-
buyVolumeInUsd30m: this.formatScientificNotation(data.bviu30m),
|
|
710
|
-
sellVolumeInUsd30m: this.formatScientificNotation(data.sviu30m),
|
|
711
|
-
price30m: this.formatScientificNotation(data.p30m),
|
|
712
|
-
openInUsd30m: this.formatScientificNotation(data.oiu30m),
|
|
713
|
-
closeInUsd30m: this.formatScientificNotation(data.ciu30m),
|
|
714
|
-
buys1h: data.b1h,
|
|
715
|
-
sells1h: data.s1h,
|
|
716
|
-
buyers1h: data.be1h,
|
|
717
|
-
sellers1h: data.se1h,
|
|
718
|
-
buyVolumeInUsd1h: this.formatScientificNotation(data.bviu1h),
|
|
719
|
-
sellVolumeInUsd1h: this.formatScientificNotation(data.sviu1h),
|
|
720
|
-
price1h: this.formatScientificNotation(data.p1h),
|
|
721
|
-
openInUsd1h: this.formatScientificNotation(data.oiu1h),
|
|
722
|
-
closeInUsd1h: this.formatScientificNotation(data.ciu1h),
|
|
723
|
-
buys4h: data.b4h,
|
|
724
|
-
sells4h: data.s4h,
|
|
725
|
-
buyers4h: data.be4h,
|
|
726
|
-
sellers4h: data.se4h,
|
|
727
|
-
buyVolumeInUsd4h: this.formatScientificNotation(data.bviu4h),
|
|
728
|
-
sellVolumeInUsd4h: this.formatScientificNotation(data.sviu4h),
|
|
729
|
-
price4h: this.formatScientificNotation(data.p4h),
|
|
730
|
-
openInUsd4h: this.formatScientificNotation(data.oiu4h),
|
|
731
|
-
closeInUsd4h: this.formatScientificNotation(data.ciu4h),
|
|
732
|
-
buys24h: data.b24h,
|
|
733
|
-
sells24h: data.s24h,
|
|
734
|
-
buyers24h: data.be24h,
|
|
735
|
-
sellers24h: data.se24h,
|
|
736
|
-
buyVolumeInUsd24h: this.formatScientificNotation(data.bviu24h),
|
|
737
|
-
sellVolumeInUsd24h: this.formatScientificNotation(data.sviu24h),
|
|
738
|
-
price24h: this.formatScientificNotation(data.p24h),
|
|
739
|
-
openInUsd24h: this.formatScientificNotation(data.oiu24h),
|
|
740
|
-
closeInUsd24h: this.formatScientificNotation(data.ciu24h),
|
|
741
|
-
price: this.formatScientificNotation(data.p)
|
|
742
|
-
}),
|
|
705
|
+
(data) => {
|
|
706
|
+
const windowData = timeWindows.reduce(
|
|
707
|
+
(acc, suffix) => ({
|
|
708
|
+
...acc,
|
|
709
|
+
...this.parseTokenStatWindow(data, suffix)
|
|
710
|
+
}),
|
|
711
|
+
{}
|
|
712
|
+
);
|
|
713
|
+
callback({
|
|
714
|
+
address: data.a,
|
|
715
|
+
timestamp: data.t,
|
|
716
|
+
price: this.formatScientificNotation(data.p),
|
|
717
|
+
...windowData
|
|
718
|
+
});
|
|
719
|
+
},
|
|
743
720
|
filter,
|
|
744
721
|
"subscribeTokenStats"
|
|
745
722
|
);
|
|
@@ -1951,6 +1928,8 @@ __export(token_exports, {
|
|
|
1951
1928
|
getToken: () => getToken,
|
|
1952
1929
|
getTokenLiquiditySnapshots: () => getTokenLiquiditySnapshots,
|
|
1953
1930
|
getTokenTraders: () => getTokenTraders,
|
|
1931
|
+
getTokenTransferTotal: () => getTokenTransferTotal,
|
|
1932
|
+
getTokenTransfers: () => getTokenTransfers,
|
|
1954
1933
|
getTokens: () => getTokens,
|
|
1955
1934
|
getTopHolders: () => getTopHolders,
|
|
1956
1935
|
listToken: () => listToken,
|
|
@@ -2106,12 +2085,25 @@ var getTokenLiquiditySnapshots = (chain, tokenAddress, params, options) => {
|
|
|
2106
2085
|
options
|
|
2107
2086
|
);
|
|
2108
2087
|
};
|
|
2088
|
+
var getTokenTransfers = (chain, tokenAddress, params, options) => {
|
|
2089
|
+
return chainstreamApiClient(
|
|
2090
|
+
{ url: `/v1/token/${chain}/${tokenAddress}/transfers`, method: "GET", params },
|
|
2091
|
+
options
|
|
2092
|
+
);
|
|
2093
|
+
};
|
|
2094
|
+
var getTokenTransferTotal = (chain, tokenAddress, params, options) => {
|
|
2095
|
+
return chainstreamApiClient(
|
|
2096
|
+
{ url: `/v1/token/${chain}/${tokenAddress}/transfer-total`, method: "GET", params },
|
|
2097
|
+
options
|
|
2098
|
+
);
|
|
2099
|
+
};
|
|
2109
2100
|
|
|
2110
2101
|
// src/openapi-client/generated/trade/trade.ts
|
|
2111
2102
|
var trade_exports = {};
|
|
2112
2103
|
__export(trade_exports, {
|
|
2113
2104
|
getActivities: () => getActivities,
|
|
2114
2105
|
getTopTraders: () => getTopTraders,
|
|
2106
|
+
getTraderGainersLosers: () => getTraderGainersLosers,
|
|
2115
2107
|
getTrades: () => getTrades
|
|
2116
2108
|
});
|
|
2117
2109
|
var getTrades = (chain, params, options) => {
|
|
@@ -2132,6 +2124,12 @@ var getTopTraders = (chain, params, options) => {
|
|
|
2132
2124
|
options
|
|
2133
2125
|
);
|
|
2134
2126
|
};
|
|
2127
|
+
var getTraderGainersLosers = (chain, params, options) => {
|
|
2128
|
+
return chainstreamApiClient(
|
|
2129
|
+
{ url: `/v1/trade/${chain}/trader-gainers-losers`, method: "GET", params },
|
|
2130
|
+
options
|
|
2131
|
+
);
|
|
2132
|
+
};
|
|
2135
2133
|
|
|
2136
2134
|
// src/openapi-client/generated/transaction/transaction.ts
|
|
2137
2135
|
var transaction_exports = {};
|
|
@@ -2173,26 +2171,35 @@ var getGasLimit = (chain, estimateGasLimitInput, options) => {
|
|
|
2173
2171
|
var wallet_exports = {};
|
|
2174
2172
|
__export(wallet_exports, {
|
|
2175
2173
|
calculatePnl: () => calculatePnl,
|
|
2176
|
-
getBalance: () => getBalance,
|
|
2177
2174
|
getBalanceUpdates: () => getBalanceUpdates,
|
|
2175
|
+
getNetWorth: () => getNetWorth,
|
|
2176
|
+
getNetWorthChart: () => getNetWorthChart,
|
|
2177
|
+
getNetWorthDetails: () => getNetWorthDetails,
|
|
2178
|
+
getNetWorthSummary: () => getNetWorthSummary,
|
|
2178
2179
|
getPnl: () => getPnl,
|
|
2179
|
-
|
|
2180
|
+
getPnlByToken: () => getPnlByToken,
|
|
2181
|
+
getPnlByWallet: () => getPnlByWallet,
|
|
2182
|
+
getPnlDetails: () => getPnlDetails,
|
|
2183
|
+
getTokensBalance: () => getTokensBalance,
|
|
2184
|
+
getWalletFirstTx: () => getWalletFirstTx,
|
|
2185
|
+
getWalletTransferTotal: () => getWalletTransferTotal,
|
|
2186
|
+
getWalletTransfers: () => getWalletTransfers
|
|
2180
2187
|
});
|
|
2181
|
-
var
|
|
2188
|
+
var getNetWorthSummary = (chain, params, options) => {
|
|
2182
2189
|
return chainstreamApiClient(
|
|
2183
|
-
{ url: `/v1/wallet/${chain}
|
|
2190
|
+
{ url: `/v1/wallet/${chain}/net-worth-summary`, method: "GET", params },
|
|
2184
2191
|
options
|
|
2185
2192
|
);
|
|
2186
2193
|
};
|
|
2187
|
-
var
|
|
2194
|
+
var getPnlByWallet = (chain, params, options) => {
|
|
2188
2195
|
return chainstreamApiClient(
|
|
2189
|
-
{ url: `/v1/wallet/${chain}
|
|
2196
|
+
{ url: `/v1/wallet/${chain}/pnl-by-wallet`, method: "GET", params },
|
|
2190
2197
|
options
|
|
2191
2198
|
);
|
|
2192
2199
|
};
|
|
2193
|
-
var
|
|
2200
|
+
var getWalletFirstTx = (chain, params, options) => {
|
|
2194
2201
|
return chainstreamApiClient(
|
|
2195
|
-
{ url: `/v1/wallet/${chain}
|
|
2202
|
+
{ url: `/v1/wallet/${chain}/first-tx`, method: "GET", params },
|
|
2196
2203
|
options
|
|
2197
2204
|
);
|
|
2198
2205
|
};
|
|
@@ -2207,6 +2214,60 @@ var calculatePnl = (chain, walletAddress, calculatePnlInput, options) => {
|
|
|
2207
2214
|
options
|
|
2208
2215
|
);
|
|
2209
2216
|
};
|
|
2217
|
+
var getNetWorth = (chain, walletAddress, params, options) => {
|
|
2218
|
+
return chainstreamApiClient(
|
|
2219
|
+
{ url: `/v1/wallet/${chain}/${walletAddress}/net-worth`, method: "GET", params },
|
|
2220
|
+
options
|
|
2221
|
+
);
|
|
2222
|
+
};
|
|
2223
|
+
var getTokensBalance = (chain, walletAddress, params, options) => {
|
|
2224
|
+
return chainstreamApiClient(
|
|
2225
|
+
{ url: `/v1/wallet/${chain}/${walletAddress}/tokens-balance`, method: "GET", params },
|
|
2226
|
+
options
|
|
2227
|
+
);
|
|
2228
|
+
};
|
|
2229
|
+
var getNetWorthChart = (chain, walletAddress, params, options) => {
|
|
2230
|
+
return chainstreamApiClient(
|
|
2231
|
+
{ url: `/v1/wallet/${chain}/${walletAddress}/net-worth-chart`, method: "GET", params },
|
|
2232
|
+
options
|
|
2233
|
+
);
|
|
2234
|
+
};
|
|
2235
|
+
var getNetWorthDetails = (chain, walletAddress, params, options) => {
|
|
2236
|
+
return chainstreamApiClient(
|
|
2237
|
+
{ url: `/v1/wallet/${chain}/${walletAddress}/net-worth-details`, method: "GET", params },
|
|
2238
|
+
options
|
|
2239
|
+
);
|
|
2240
|
+
};
|
|
2241
|
+
var getPnl = (chain, walletAddress, params, options) => {
|
|
2242
|
+
return chainstreamApiClient(
|
|
2243
|
+
{ url: `/v1/wallet/${chain}/${walletAddress}/pnl`, method: "GET", params },
|
|
2244
|
+
options
|
|
2245
|
+
);
|
|
2246
|
+
};
|
|
2247
|
+
var getPnlDetails = (chain, walletAddress, params, options) => {
|
|
2248
|
+
return chainstreamApiClient(
|
|
2249
|
+
{ url: `/v1/wallet/${chain}/${walletAddress}/pnl-details`, method: "GET", params },
|
|
2250
|
+
options
|
|
2251
|
+
);
|
|
2252
|
+
};
|
|
2253
|
+
var getPnlByToken = (chain, walletAddress, params, options) => {
|
|
2254
|
+
return chainstreamApiClient(
|
|
2255
|
+
{ url: `/v1/wallet/${chain}/${walletAddress}/pnl-by-token`, method: "GET", params },
|
|
2256
|
+
options
|
|
2257
|
+
);
|
|
2258
|
+
};
|
|
2259
|
+
var getWalletTransfers = (chain, walletAddress, params, options) => {
|
|
2260
|
+
return chainstreamApiClient(
|
|
2261
|
+
{ url: `/v1/wallet/${chain}/${walletAddress}/transfers`, method: "GET", params },
|
|
2262
|
+
options
|
|
2263
|
+
);
|
|
2264
|
+
};
|
|
2265
|
+
var getWalletTransferTotal = (chain, walletAddress, params, options) => {
|
|
2266
|
+
return chainstreamApiClient(
|
|
2267
|
+
{ url: `/v1/wallet/${chain}/${walletAddress}/transfer-total`, method: "GET", params },
|
|
2268
|
+
options
|
|
2269
|
+
);
|
|
2270
|
+
};
|
|
2210
2271
|
var getBalanceUpdates = (chain, walletAddress, params, options) => {
|
|
2211
2272
|
return chainstreamApiClient(
|
|
2212
2273
|
{ url: `/v1/wallet/${chain}/${walletAddress}/balance-updates`, method: "GET", params },
|