@b3dotfun/sdk 0.0.49-alpha.8 → 0.0.49-alpha.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.
Files changed (39) hide show
  1. package/dist/cjs/bondkit/bondkitToken.d.ts +3 -1
  2. package/dist/cjs/bondkit/bondkitToken.js +19 -0
  3. package/dist/cjs/bondkit/components/TradingView.d.ts +1 -1
  4. package/dist/cjs/bondkit/components/TradingView.js +14 -3
  5. package/dist/cjs/bondkit/components/index.d.ts +1 -1
  6. package/dist/cjs/bondkit/components/index.js +1 -1
  7. package/dist/cjs/bondkit/components/types.d.ts +1 -0
  8. package/dist/cjs/bondkit/config.d.ts +1 -0
  9. package/dist/cjs/bondkit/config.js +1 -0
  10. package/dist/cjs/bondkit/index.d.ts +1 -1
  11. package/dist/cjs/bondkit/index.js +2 -6
  12. package/dist/cjs/bondkit/types.d.ts +15 -0
  13. package/dist/esm/bondkit/bondkitToken.d.ts +3 -1
  14. package/dist/esm/bondkit/bondkitToken.js +19 -0
  15. package/dist/esm/bondkit/components/TradingView.d.ts +1 -1
  16. package/dist/esm/bondkit/components/TradingView.js +14 -3
  17. package/dist/esm/bondkit/components/index.d.ts +1 -1
  18. package/dist/esm/bondkit/components/index.js +1 -1
  19. package/dist/esm/bondkit/components/types.d.ts +1 -0
  20. package/dist/esm/bondkit/config.d.ts +1 -0
  21. package/dist/esm/bondkit/config.js +1 -0
  22. package/dist/esm/bondkit/index.d.ts +1 -1
  23. package/dist/esm/bondkit/index.js +1 -1
  24. package/dist/esm/bondkit/types.d.ts +15 -0
  25. package/dist/types/bondkit/bondkitToken.d.ts +3 -1
  26. package/dist/types/bondkit/components/TradingView.d.ts +1 -1
  27. package/dist/types/bondkit/components/index.d.ts +1 -1
  28. package/dist/types/bondkit/components/types.d.ts +1 -0
  29. package/dist/types/bondkit/config.d.ts +1 -0
  30. package/dist/types/bondkit/index.d.ts +1 -1
  31. package/dist/types/bondkit/types.d.ts +15 -0
  32. package/package.json +1 -1
  33. package/src/bondkit/bondkitToken.ts +24 -0
  34. package/src/bondkit/components/TradingView.tsx +15 -3
  35. package/src/bondkit/components/index.ts +1 -1
  36. package/src/bondkit/components/types.ts +1 -0
  37. package/src/bondkit/config.ts +2 -0
  38. package/src/bondkit/index.ts +1 -1
  39. package/src/bondkit/types.ts +19 -0
@@ -1,6 +1,6 @@
1
1
  import type { Address, EIP1193Provider, GetContractReturnType, Hex, PublicClient, WalletClient } from "viem";
2
2
  import { BondkitTokenABI } from "./abis";
3
- import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, SwapQuote, TokenDetails, TransactionResponse } from "./types";
3
+ import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, MarketCapChartResponse, SwapQuote, TokenDetails, TransactionResponse } from "./types";
4
4
  import { TokenStatus } from "./types";
5
5
  type ExecuteWriteOptions = {
6
6
  value?: bigint;
@@ -16,6 +16,7 @@ export declare class BondkitToken {
16
16
  private walletKey?;
17
17
  private rpcUrl;
18
18
  private apiEndpoint;
19
+ private chartApiEndpoint;
19
20
  private walletClientInstance;
20
21
  private connectedProvider?;
21
22
  private tradingToken?;
@@ -56,6 +57,7 @@ export declare class BondkitToken {
56
57
  threshold: number;
57
58
  } | undefined>;
58
59
  getTransactionHistory(options?: GetTransactionHistoryOptions): Promise<TransactionResponse | undefined>;
60
+ getMarketCapChartData(): Promise<MarketCapChartResponse | undefined>;
59
61
  private executeWrite;
60
62
  /** Helper method to wait for transaction confirmation with OKX wallet fallback */
61
63
  waitForTransaction(hash: Hex): Promise<import("viem").TransactionReceipt>;
@@ -21,6 +21,7 @@ class BondkitToken {
21
21
  this.chain = sdkConfig.chain;
22
22
  this.rpcUrl = sdkConfig.rpcUrl;
23
23
  this.apiEndpoint = sdkConfig.apiEndpoint;
24
+ this.chartApiEndpoint = sdkConfig.chartApiEndpoint;
24
25
  if (walletKey && !walletKey.startsWith("0x")) {
25
26
  this.walletKey = `0x${walletKey}`;
26
27
  }
@@ -389,6 +390,24 @@ class BondkitToken {
389
390
  return undefined;
390
391
  }
391
392
  }
393
+ // --- Market Cap Chart Data --- //
394
+ async getMarketCapChartData() {
395
+ try {
396
+ const url = new URL("/recent_marketcap", this.chartApiEndpoint);
397
+ url.searchParams.set("contractAddress", this.contractAddress);
398
+ url.searchParams.set("chainId", this.chain.id.toString());
399
+ const response = await fetch(url.toString());
400
+ if (!response.ok) {
401
+ throw new Error(`HTTP error! status: ${response.status}`);
402
+ }
403
+ const result = await response.json();
404
+ return result;
405
+ }
406
+ catch (e) {
407
+ console.warn("Error fetching market cap chart data:", e);
408
+ return undefined;
409
+ }
410
+ }
392
411
  // --- Write Methods --- //
393
412
  async executeWrite(functionName, args, options) {
394
413
  if (!this.walletClientInstance.account && !this.walletKey) {
@@ -1,3 +1,3 @@
1
1
  import { TradingViewProps } from "./types";
2
- declare const TradingView: ({ className, tokenAddress, tokenSymbol }: TradingViewProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const TradingView: ({ className, tokenAddress, tokenSymbol, chainId }: TradingViewProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default TradingView;
@@ -4,17 +4,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const lucide_react_1 = require("lucide-react");
6
6
  const react_1 = require("react");
7
+ const config_1 = require("../config");
7
8
  const cdn_loader_1 = require("./utils/cdn-loader");
8
9
  const format_1 = require("./utils/format");
9
10
  // TradingView will be available on window after loading from CDN
10
11
  // Datafeed will be implemented inline
11
12
  // Mock loading overlay - replace with your actual loading component
12
13
  const GifLoadingOverlay = ({ className }) => ((0, jsx_runtime_1.jsx)("div", { className: `absolute inset-0 flex items-center justify-center bg-white/50 backdrop-blur-sm ${className || ""}`, children: (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-secondary-grey h-8 w-8 animate-spin" }) }));
13
- const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
14
+ const TradingView = ({ className, tokenAddress, tokenSymbol, chainId = 8453 }) => {
14
15
  // Use token info for the current trade
15
16
  const currentTrade = {
16
17
  product_id: tokenAddress && tokenSymbol ? `${tokenSymbol}-${tokenAddress}` : "BONDKIT",
17
18
  };
19
+ // Get chart API endpoint from config
20
+ const config = (0, config_1.getConfig)(chainId);
21
+ const chartApiUrl = `${config.chartApiEndpoint}/udf`;
18
22
  const [tradingViewDefaultInterval, setTradingViewDefaultInterval] = (0, react_1.useState)("60");
19
23
  const [tradingViewTimezone, setTradingViewTimezone] = (0, react_1.useState)("");
20
24
  const chartContainerRef = (0, react_1.useRef)(null);
@@ -126,7 +130,7 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
126
130
  unsubscribeBars: () => { },
127
131
  };
128
132
  };
129
- const datafeed = createUDFDatafeed("https://b3-udf-worker.sean-430.workers.dev/bondkit/udf");
133
+ const datafeed = createUDFDatafeed(chartApiUrl);
130
134
  // Calculate timeframe for last 2 days
131
135
  const currentTime = Math.floor(Date.now() / 1000);
132
136
  const twoDaysAgo = currentTime - 2 * 24 * 60 * 60; // 2 days in seconds
@@ -246,7 +250,14 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
246
250
  tvWidgetRef.current = null;
247
251
  }
248
252
  };
249
- }, [librariesLoaded, currentTrade?.product_id, tradingViewDefaultInterval, tradingViewTimezone]);
253
+ }, [
254
+ librariesLoaded,
255
+ currentTrade?.product_id,
256
+ tradingViewDefaultInterval,
257
+ tradingViewTimezone,
258
+ chartApiUrl,
259
+ chainId,
260
+ ]);
250
261
  (0, react_1.useEffect)(() => {
251
262
  if (chartLoaded &&
252
263
  currentTrade?.product_id &&
@@ -1,5 +1,5 @@
1
+ export * from "./config/cdn";
1
2
  export { default as TradingView } from "./TradingView";
2
3
  export type { TradingViewProps } from "./types";
3
4
  export * from "./utils/cdn-loader";
4
5
  export * from "./utils/format";
5
- export * from "./config/cdn";
@@ -18,8 +18,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.TradingView = void 0;
21
+ __exportStar(require("./config/cdn"), exports);
21
22
  var TradingView_1 = require("./TradingView");
22
23
  Object.defineProperty(exports, "TradingView", { enumerable: true, get: function () { return __importDefault(TradingView_1).default; } });
23
24
  __exportStar(require("./utils/cdn-loader"), exports);
24
25
  __exportStar(require("./utils/format"), exports);
25
- __exportStar(require("./config/cdn"), exports);
@@ -5,4 +5,5 @@ export interface TradingViewProps {
5
5
  className?: string;
6
6
  tokenAddress?: string;
7
7
  tokenSymbol?: string;
8
+ chainId?: number;
8
9
  }
@@ -5,6 +5,7 @@ export interface Config {
5
5
  rpcUrl: string;
6
6
  factoryAddress: Address;
7
7
  apiEndpoint: string;
8
+ chartApiEndpoint: string;
8
9
  }
9
10
  export type SupportedChainId = typeof base.id;
10
11
  export declare const getConfig: (chainId: number, rpcUrl?: string) => Config;
@@ -8,6 +8,7 @@ const baseMainnetConfig = {
8
8
  rpcUrl: constants_1.BaseMainnetRpcUrl,
9
9
  factoryAddress: constants_1.BaseBondkitTokenFactoryContractAddress,
10
10
  apiEndpoint: "https://api.b3.fun/bondkit-tokens",
11
+ chartApiEndpoint: "https://bondkit-chart-api.b3.fun",
11
12
  };
12
13
  const getConfig = (chainId, rpcUrl) => {
13
14
  if (chainId === chains_1.base.id) {
@@ -5,4 +5,4 @@ export * from "./constants";
5
5
  export * from "./types";
6
6
  export * from "./abis";
7
7
  export { BondkitSwapService } from "./swapService";
8
- export { default as TradingView } from "./components/TradingView";
8
+ export * from "./components";
@@ -13,11 +13,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
16
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.TradingView = exports.BondkitSwapService = void 0;
17
+ exports.BondkitSwapService = void 0;
21
18
  // Core exports
22
19
  __exportStar(require("./bondkitToken"), exports);
23
20
  __exportStar(require("./bondkitTokenFactory"), exports);
@@ -32,5 +29,4 @@ __exportStar(require("./abis"), exports);
32
29
  var swapService_1 = require("./swapService");
33
30
  Object.defineProperty(exports, "BondkitSwapService", { enumerable: true, get: function () { return swapService_1.BondkitSwapService; } });
34
31
  // Components
35
- var TradingView_1 = require("./components/TradingView");
36
- Object.defineProperty(exports, "TradingView", { enumerable: true, get: function () { return __importDefault(TradingView_1).default; } });
32
+ __exportStar(require("./components"), exports);
@@ -86,3 +86,18 @@ export interface SwapQuote {
86
86
  executionPrice: string;
87
87
  fee: string;
88
88
  }
89
+ export interface MarketCapDataPoint {
90
+ time: string;
91
+ value: string;
92
+ }
93
+ export interface TokenInfo {
94
+ contractAddress: string;
95
+ chainId: number;
96
+ name: string;
97
+ symbol: string;
98
+ found: boolean;
99
+ }
100
+ export interface MarketCapChartResponse {
101
+ tokenInfo: TokenInfo;
102
+ data: MarketCapDataPoint[];
103
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Address, EIP1193Provider, GetContractReturnType, Hex, PublicClient, WalletClient } from "viem";
2
2
  import { BondkitTokenABI } from "./abis";
3
- import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, SwapQuote, TokenDetails, TransactionResponse } from "./types";
3
+ import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, MarketCapChartResponse, SwapQuote, TokenDetails, TransactionResponse } from "./types";
4
4
  import { TokenStatus } from "./types";
5
5
  type ExecuteWriteOptions = {
6
6
  value?: bigint;
@@ -16,6 +16,7 @@ export declare class BondkitToken {
16
16
  private walletKey?;
17
17
  private rpcUrl;
18
18
  private apiEndpoint;
19
+ private chartApiEndpoint;
19
20
  private walletClientInstance;
20
21
  private connectedProvider?;
21
22
  private tradingToken?;
@@ -56,6 +57,7 @@ export declare class BondkitToken {
56
57
  threshold: number;
57
58
  } | undefined>;
58
59
  getTransactionHistory(options?: GetTransactionHistoryOptions): Promise<TransactionResponse | undefined>;
60
+ getMarketCapChartData(): Promise<MarketCapChartResponse | undefined>;
59
61
  private executeWrite;
60
62
  /** Helper method to wait for transaction confirmation with OKX wallet fallback */
61
63
  waitForTransaction(hash: Hex): Promise<import("viem").TransactionReceipt>;
@@ -18,6 +18,7 @@ export class BondkitToken {
18
18
  this.chain = sdkConfig.chain;
19
19
  this.rpcUrl = sdkConfig.rpcUrl;
20
20
  this.apiEndpoint = sdkConfig.apiEndpoint;
21
+ this.chartApiEndpoint = sdkConfig.chartApiEndpoint;
21
22
  if (walletKey && !walletKey.startsWith("0x")) {
22
23
  this.walletKey = `0x${walletKey}`;
23
24
  }
@@ -386,6 +387,24 @@ export class BondkitToken {
386
387
  return undefined;
387
388
  }
388
389
  }
390
+ // --- Market Cap Chart Data --- //
391
+ async getMarketCapChartData() {
392
+ try {
393
+ const url = new URL("/recent_marketcap", this.chartApiEndpoint);
394
+ url.searchParams.set("contractAddress", this.contractAddress);
395
+ url.searchParams.set("chainId", this.chain.id.toString());
396
+ const response = await fetch(url.toString());
397
+ if (!response.ok) {
398
+ throw new Error(`HTTP error! status: ${response.status}`);
399
+ }
400
+ const result = await response.json();
401
+ return result;
402
+ }
403
+ catch (e) {
404
+ console.warn("Error fetching market cap chart data:", e);
405
+ return undefined;
406
+ }
407
+ }
389
408
  // --- Write Methods --- //
390
409
  async executeWrite(functionName, args, options) {
391
410
  if (!this.walletClientInstance.account && !this.walletKey) {
@@ -1,3 +1,3 @@
1
1
  import { TradingViewProps } from "./types";
2
- declare const TradingView: ({ className, tokenAddress, tokenSymbol }: TradingViewProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const TradingView: ({ className, tokenAddress, tokenSymbol, chainId }: TradingViewProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default TradingView;
@@ -2,17 +2,21 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Loader2 } from "lucide-react";
4
4
  import { useEffect, useRef, useState } from "react";
5
+ import { getConfig } from "../config.js";
5
6
  import { loadScriptFromCDN } from "./utils/cdn-loader.js";
6
7
  import { formatNumberSmall } from "./utils/format.js";
7
8
  // TradingView will be available on window after loading from CDN
8
9
  // Datafeed will be implemented inline
9
10
  // Mock loading overlay - replace with your actual loading component
10
11
  const GifLoadingOverlay = ({ className }) => (_jsx("div", { className: `absolute inset-0 flex items-center justify-center bg-white/50 backdrop-blur-sm ${className || ""}`, children: _jsx(Loader2, { className: "text-secondary-grey h-8 w-8 animate-spin" }) }));
11
- const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
12
+ const TradingView = ({ className, tokenAddress, tokenSymbol, chainId = 8453 }) => {
12
13
  // Use token info for the current trade
13
14
  const currentTrade = {
14
15
  product_id: tokenAddress && tokenSymbol ? `${tokenSymbol}-${tokenAddress}` : "BONDKIT",
15
16
  };
17
+ // Get chart API endpoint from config
18
+ const config = getConfig(chainId);
19
+ const chartApiUrl = `${config.chartApiEndpoint}/udf`;
16
20
  const [tradingViewDefaultInterval, setTradingViewDefaultInterval] = useState("60");
17
21
  const [tradingViewTimezone, setTradingViewTimezone] = useState("");
18
22
  const chartContainerRef = useRef(null);
@@ -124,7 +128,7 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
124
128
  unsubscribeBars: () => { },
125
129
  };
126
130
  };
127
- const datafeed = createUDFDatafeed("https://b3-udf-worker.sean-430.workers.dev/bondkit/udf");
131
+ const datafeed = createUDFDatafeed(chartApiUrl);
128
132
  // Calculate timeframe for last 2 days
129
133
  const currentTime = Math.floor(Date.now() / 1000);
130
134
  const twoDaysAgo = currentTime - 2 * 24 * 60 * 60; // 2 days in seconds
@@ -244,7 +248,14 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
244
248
  tvWidgetRef.current = null;
245
249
  }
246
250
  };
247
- }, [librariesLoaded, currentTrade?.product_id, tradingViewDefaultInterval, tradingViewTimezone]);
251
+ }, [
252
+ librariesLoaded,
253
+ currentTrade?.product_id,
254
+ tradingViewDefaultInterval,
255
+ tradingViewTimezone,
256
+ chartApiUrl,
257
+ chainId,
258
+ ]);
248
259
  useEffect(() => {
249
260
  if (chartLoaded &&
250
261
  currentTrade?.product_id &&
@@ -1,5 +1,5 @@
1
+ export * from "./config/cdn";
1
2
  export { default as TradingView } from "./TradingView";
2
3
  export type { TradingViewProps } from "./types";
3
4
  export * from "./utils/cdn-loader";
4
5
  export * from "./utils/format";
5
- export * from "./config/cdn";
@@ -1,4 +1,4 @@
1
+ export * from "./config/cdn.js";
1
2
  export { default as TradingView } from "./TradingView.js";
2
3
  export * from "./utils/cdn-loader.js";
3
4
  export * from "./utils/format.js";
4
- export * from "./config/cdn.js";
@@ -5,4 +5,5 @@ export interface TradingViewProps {
5
5
  className?: string;
6
6
  tokenAddress?: string;
7
7
  tokenSymbol?: string;
8
+ chainId?: number;
8
9
  }
@@ -5,6 +5,7 @@ export interface Config {
5
5
  rpcUrl: string;
6
6
  factoryAddress: Address;
7
7
  apiEndpoint: string;
8
+ chartApiEndpoint: string;
8
9
  }
9
10
  export type SupportedChainId = typeof base.id;
10
11
  export declare const getConfig: (chainId: number, rpcUrl?: string) => Config;
@@ -5,6 +5,7 @@ const baseMainnetConfig = {
5
5
  rpcUrl: BaseMainnetRpcUrl,
6
6
  factoryAddress: BaseBondkitTokenFactoryContractAddress,
7
7
  apiEndpoint: "https://api.b3.fun/bondkit-tokens",
8
+ chartApiEndpoint: "https://bondkit-chart-api.b3.fun",
8
9
  };
9
10
  export const getConfig = (chainId, rpcUrl) => {
10
11
  if (chainId === base.id) {
@@ -5,4 +5,4 @@ export * from "./constants";
5
5
  export * from "./types";
6
6
  export * from "./abis";
7
7
  export { BondkitSwapService } from "./swapService";
8
- export { default as TradingView } from "./components/TradingView";
8
+ export * from "./components";
@@ -11,4 +11,4 @@ export * from "./abis/index.js";
11
11
  // Swap functionality
12
12
  export { BondkitSwapService } from "./swapService.js";
13
13
  // Components
14
- export { default as TradingView } from "./components/TradingView.js";
14
+ export * from "./components/index.js";
@@ -86,3 +86,18 @@ export interface SwapQuote {
86
86
  executionPrice: string;
87
87
  fee: string;
88
88
  }
89
+ export interface MarketCapDataPoint {
90
+ time: string;
91
+ value: string;
92
+ }
93
+ export interface TokenInfo {
94
+ contractAddress: string;
95
+ chainId: number;
96
+ name: string;
97
+ symbol: string;
98
+ found: boolean;
99
+ }
100
+ export interface MarketCapChartResponse {
101
+ tokenInfo: TokenInfo;
102
+ data: MarketCapDataPoint[];
103
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Address, EIP1193Provider, GetContractReturnType, Hex, PublicClient, WalletClient } from "viem";
2
2
  import { BondkitTokenABI } from "./abis";
3
- import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, SwapQuote, TokenDetails, TransactionResponse } from "./types";
3
+ import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, MarketCapChartResponse, SwapQuote, TokenDetails, TransactionResponse } from "./types";
4
4
  import { TokenStatus } from "./types";
5
5
  type ExecuteWriteOptions = {
6
6
  value?: bigint;
@@ -16,6 +16,7 @@ export declare class BondkitToken {
16
16
  private walletKey?;
17
17
  private rpcUrl;
18
18
  private apiEndpoint;
19
+ private chartApiEndpoint;
19
20
  private walletClientInstance;
20
21
  private connectedProvider?;
21
22
  private tradingToken?;
@@ -56,6 +57,7 @@ export declare class BondkitToken {
56
57
  threshold: number;
57
58
  } | undefined>;
58
59
  getTransactionHistory(options?: GetTransactionHistoryOptions): Promise<TransactionResponse | undefined>;
60
+ getMarketCapChartData(): Promise<MarketCapChartResponse | undefined>;
59
61
  private executeWrite;
60
62
  /** Helper method to wait for transaction confirmation with OKX wallet fallback */
61
63
  waitForTransaction(hash: Hex): Promise<import("viem").TransactionReceipt>;
@@ -1,3 +1,3 @@
1
1
  import { TradingViewProps } from "./types";
2
- declare const TradingView: ({ className, tokenAddress, tokenSymbol }: TradingViewProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const TradingView: ({ className, tokenAddress, tokenSymbol, chainId }: TradingViewProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default TradingView;
@@ -1,5 +1,5 @@
1
+ export * from "./config/cdn";
1
2
  export { default as TradingView } from "./TradingView";
2
3
  export type { TradingViewProps } from "./types";
3
4
  export * from "./utils/cdn-loader";
4
5
  export * from "./utils/format";
5
- export * from "./config/cdn";
@@ -5,4 +5,5 @@ export interface TradingViewProps {
5
5
  className?: string;
6
6
  tokenAddress?: string;
7
7
  tokenSymbol?: string;
8
+ chainId?: number;
8
9
  }
@@ -5,6 +5,7 @@ export interface Config {
5
5
  rpcUrl: string;
6
6
  factoryAddress: Address;
7
7
  apiEndpoint: string;
8
+ chartApiEndpoint: string;
8
9
  }
9
10
  export type SupportedChainId = typeof base.id;
10
11
  export declare const getConfig: (chainId: number, rpcUrl?: string) => Config;
@@ -5,4 +5,4 @@ export * from "./constants";
5
5
  export * from "./types";
6
6
  export * from "./abis";
7
7
  export { BondkitSwapService } from "./swapService";
8
- export { default as TradingView } from "./components/TradingView";
8
+ export * from "./components";
@@ -86,3 +86,18 @@ export interface SwapQuote {
86
86
  executionPrice: string;
87
87
  fee: string;
88
88
  }
89
+ export interface MarketCapDataPoint {
90
+ time: string;
91
+ value: string;
92
+ }
93
+ export interface TokenInfo {
94
+ contractAddress: string;
95
+ chainId: number;
96
+ name: string;
97
+ symbol: string;
98
+ found: boolean;
99
+ }
100
+ export interface MarketCapChartResponse {
101
+ tokenInfo: TokenInfo;
102
+ data: MarketCapDataPoint[];
103
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.49-alpha.8",
3
+ "version": "0.0.49-alpha.9",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -17,6 +17,7 @@ import { BondkitSwapService } from "./swapService";
17
17
  import type {
18
18
  BondkitTokenInitializationConfig,
19
19
  GetTransactionHistoryOptions,
20
+ MarketCapChartResponse,
20
21
  SwapQuote,
21
22
  TokenDetails,
22
23
  TransactionResponse,
@@ -52,6 +53,7 @@ export class BondkitToken {
52
53
  private walletKey?: Hex;
53
54
  private rpcUrl: string;
54
55
  private apiEndpoint: string;
56
+ private chartApiEndpoint: string;
55
57
  private walletClientInstance: WalletClient;
56
58
  private connectedProvider?: EIP1193Provider;
57
59
  private tradingToken?: Address;
@@ -62,6 +64,7 @@ export class BondkitToken {
62
64
  this.chain = sdkConfig.chain;
63
65
  this.rpcUrl = sdkConfig.rpcUrl;
64
66
  this.apiEndpoint = sdkConfig.apiEndpoint;
67
+ this.chartApiEndpoint = sdkConfig.chartApiEndpoint;
65
68
 
66
69
  if (walletKey && !walletKey.startsWith("0x")) {
67
70
  this.walletKey = `0x${walletKey}` as Hex;
@@ -459,6 +462,27 @@ export class BondkitToken {
459
462
  }
460
463
  }
461
464
 
465
+ // --- Market Cap Chart Data --- //
466
+ public async getMarketCapChartData(): Promise<MarketCapChartResponse | undefined> {
467
+ try {
468
+ const url = new URL("/recent_marketcap", this.chartApiEndpoint);
469
+ url.searchParams.set("contractAddress", this.contractAddress);
470
+ url.searchParams.set("chainId", this.chain.id.toString());
471
+
472
+ const response = await fetch(url.toString());
473
+
474
+ if (!response.ok) {
475
+ throw new Error(`HTTP error! status: ${response.status}`);
476
+ }
477
+
478
+ const result: MarketCapChartResponse = await response.json();
479
+ return result;
480
+ } catch (e) {
481
+ console.warn("Error fetching market cap chart data:", e);
482
+ return undefined;
483
+ }
484
+ }
485
+
462
486
  // --- Write Methods --- //
463
487
  private async executeWrite(
464
488
  functionName: string,
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { Loader2 } from "lucide-react";
4
4
  import { useEffect, useRef, useState } from "react";
5
+ import { getConfig } from "../config";
5
6
  import { TradingViewProps } from "./types";
6
7
  import { loadScriptFromCDN } from "./utils/cdn-loader";
7
8
  import { formatNumberSmall } from "./utils/format";
@@ -23,12 +24,16 @@ const GifLoadingOverlay = ({ className }: { className?: string }) => (
23
24
  </div>
24
25
  );
25
26
 
26
- const TradingView = ({ className, tokenAddress, tokenSymbol }: TradingViewProps) => {
27
+ const TradingView = ({ className, tokenAddress, tokenSymbol, chainId = 8453 }: TradingViewProps) => {
27
28
  // Use token info for the current trade
28
29
  const currentTrade = {
29
30
  product_id: tokenAddress && tokenSymbol ? `${tokenSymbol}-${tokenAddress}` : "BONDKIT",
30
31
  };
31
32
 
33
+ // Get chart API endpoint from config
34
+ const config = getConfig(chainId);
35
+ const chartApiUrl = `${config.chartApiEndpoint}/udf`;
36
+
32
37
  const [tradingViewDefaultInterval, setTradingViewDefaultInterval] = useState<ResolutionString>("60");
33
38
  const [tradingViewTimezone, setTradingViewTimezone] = useState<string>("");
34
39
 
@@ -153,7 +158,7 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }: TradingViewProps)
153
158
  };
154
159
  };
155
160
 
156
- const datafeed = createUDFDatafeed("https://b3-udf-worker.sean-430.workers.dev/bondkit/udf");
161
+ const datafeed = createUDFDatafeed(chartApiUrl);
157
162
  // Calculate timeframe for last 2 days
158
163
  const currentTime = Math.floor(Date.now() / 1000);
159
164
  const twoDaysAgo = currentTime - 2 * 24 * 60 * 60; // 2 days in seconds
@@ -280,7 +285,14 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }: TradingViewProps)
280
285
  tvWidgetRef.current = null;
281
286
  }
282
287
  };
283
- }, [librariesLoaded, currentTrade?.product_id, tradingViewDefaultInterval, tradingViewTimezone]);
288
+ }, [
289
+ librariesLoaded,
290
+ currentTrade?.product_id,
291
+ tradingViewDefaultInterval,
292
+ tradingViewTimezone,
293
+ chartApiUrl,
294
+ chainId,
295
+ ]);
284
296
 
285
297
  useEffect(() => {
286
298
  if (
@@ -1,5 +1,5 @@
1
+ export * from "./config/cdn";
1
2
  export { default as TradingView } from "./TradingView";
2
3
  export type { TradingViewProps } from "./types";
3
4
  export * from "./utils/cdn-loader";
4
5
  export * from "./utils/format";
5
- export * from "./config/cdn";
@@ -6,4 +6,5 @@ export interface TradingViewProps {
6
6
  className?: string;
7
7
  tokenAddress?: string;
8
8
  tokenSymbol?: string;
9
+ chainId?: number;
9
10
  }
@@ -7,6 +7,7 @@ export interface Config {
7
7
  rpcUrl: string;
8
8
  factoryAddress: Address;
9
9
  apiEndpoint: string;
10
+ chartApiEndpoint: string;
10
11
  }
11
12
 
12
13
  export type SupportedChainId = typeof base.id;
@@ -16,6 +17,7 @@ const baseMainnetConfig: Config = {
16
17
  rpcUrl: BaseMainnetRpcUrl,
17
18
  factoryAddress: BaseBondkitTokenFactoryContractAddress,
18
19
  apiEndpoint: "https://api.b3.fun/bondkit-tokens",
20
+ chartApiEndpoint: "https://bondkit-chart-api.b3.fun",
19
21
  };
20
22
 
21
23
  export const getConfig = (chainId: number, rpcUrl?: string): Config => {
@@ -16,4 +16,4 @@ export * from "./abis";
16
16
  export { BondkitSwapService } from "./swapService";
17
17
 
18
18
  // Components
19
- export { default as TradingView } from "./components/TradingView";
19
+ export * from "./components";
@@ -108,3 +108,22 @@ export interface SwapQuote {
108
108
  executionPrice: string;
109
109
  fee: string;
110
110
  }
111
+
112
+ // Market cap chart data types
113
+ export interface MarketCapDataPoint {
114
+ time: string; // ISO 8601 timestamp
115
+ value: string; // Market cap value as string (to handle large numbers)
116
+ }
117
+
118
+ export interface TokenInfo {
119
+ contractAddress: string;
120
+ chainId: number;
121
+ name: string;
122
+ symbol: string;
123
+ found: boolean;
124
+ }
125
+
126
+ export interface MarketCapChartResponse {
127
+ tokenInfo: TokenInfo;
128
+ data: MarketCapDataPoint[];
129
+ }