@b3dotfun/sdk 0.0.40 → 0.0.41-alpha.0

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 (227) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +11 -1
  2. package/dist/cjs/anyspend/react/components/AnySpend.js +17 -4
  3. package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
  4. package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
  5. package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
  6. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +33 -11
  7. package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
  8. package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
  9. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
  10. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  11. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +6 -3
  12. package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
  13. package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -3
  14. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  15. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
  16. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
  17. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  18. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
  19. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +8 -11
  20. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  21. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
  22. package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  23. package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
  24. package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
  25. package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
  26. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  27. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
  28. package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  29. package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
  30. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  31. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +18 -8
  32. package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  33. package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
  34. package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
  35. package/dist/cjs/anyspend/react/providers/index.js +3 -0
  36. package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
  37. package/dist/cjs/anyspend/services/anyspend.js +2 -0
  38. package/dist/cjs/anyspend/types/api.d.ts +51 -1
  39. package/dist/cjs/anyspend/utils/chain.js +1 -1
  40. package/dist/cjs/anyspend/utils/orderPayload.js +3 -0
  41. package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
  42. package/dist/cjs/bondkit/bondkitToken.js +268 -2
  43. package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
  44. package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
  45. package/dist/cjs/bondkit/components/TradingView.js +3 -4
  46. package/dist/cjs/bondkit/config.d.ts +1 -1
  47. package/dist/cjs/bondkit/config.js +5 -2
  48. package/dist/cjs/bondkit/constants.d.ts +4 -0
  49. package/dist/cjs/bondkit/constants.js +6 -1
  50. package/dist/cjs/bondkit/index.d.ts +1 -0
  51. package/dist/cjs/bondkit/index.js +4 -1
  52. package/dist/cjs/bondkit/swapService.d.ts +43 -0
  53. package/dist/cjs/bondkit/swapService.js +376 -0
  54. package/dist/cjs/bondkit/types.d.ts +10 -4
  55. package/dist/cjs/bondkit/types.js +4 -5
  56. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
  57. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +41 -9
  58. package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
  59. package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
  60. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
  61. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
  62. package/dist/cjs/global-account/react/hooks/index.js +3 -1
  63. package/dist/cjs/global-account/react/hooks/useAccountAssets.js +5 -2
  64. package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -3
  65. package/dist/cjs/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
  66. package/dist/cjs/global-account/react/hooks/useGlobalAccount.js +32 -0
  67. package/dist/cjs/global-account/react/hooks/useQueryB3.js +5 -2
  68. package/dist/cjs/global-account/react/hooks/useQueryBSMNT.js +5 -2
  69. package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
  70. package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +7 -1
  71. package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +2 -2
  72. package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +28 -24
  73. package/dist/cjs/shared/utils/fetchBalances.d.ts +1 -1
  74. package/dist/esm/anyspend/react/components/AnySpend.d.ts +11 -1
  75. package/dist/esm/anyspend/react/components/AnySpend.js +17 -4
  76. package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
  77. package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
  78. package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
  79. package/dist/esm/anyspend/react/components/AnySpendCustom.js +33 -11
  80. package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
  81. package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
  82. package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
  83. package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  84. package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +6 -3
  85. package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
  86. package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -4
  87. package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  88. package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
  89. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
  90. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  91. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
  92. package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -11
  93. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  94. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
  95. package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  96. package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
  97. package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
  98. package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
  99. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  100. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
  101. package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  102. package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
  103. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  104. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +18 -8
  105. package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  106. package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
  107. package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
  108. package/dist/esm/anyspend/react/providers/index.js +1 -0
  109. package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
  110. package/dist/esm/anyspend/services/anyspend.js +2 -0
  111. package/dist/esm/anyspend/types/api.d.ts +51 -1
  112. package/dist/esm/anyspend/utils/chain.js +1 -1
  113. package/dist/esm/anyspend/utils/orderPayload.js +3 -0
  114. package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
  115. package/dist/esm/bondkit/bondkitToken.js +268 -2
  116. package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
  117. package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
  118. package/dist/esm/bondkit/components/TradingView.js +3 -4
  119. package/dist/esm/bondkit/config.d.ts +1 -1
  120. package/dist/esm/bondkit/config.js +5 -2
  121. package/dist/esm/bondkit/constants.d.ts +4 -0
  122. package/dist/esm/bondkit/constants.js +5 -0
  123. package/dist/esm/bondkit/index.d.ts +1 -0
  124. package/dist/esm/bondkit/index.js +2 -0
  125. package/dist/esm/bondkit/swapService.d.ts +43 -0
  126. package/dist/esm/bondkit/swapService.js +372 -0
  127. package/dist/esm/bondkit/types.d.ts +10 -4
  128. package/dist/esm/bondkit/types.js +4 -5
  129. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
  130. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +42 -9
  131. package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
  132. package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
  133. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
  134. package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
  135. package/dist/esm/global-account/react/hooks/index.js +1 -0
  136. package/dist/esm/global-account/react/hooks/useAccountAssets.js +2 -2
  137. package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -3
  138. package/dist/esm/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
  139. package/dist/esm/global-account/react/hooks/useGlobalAccount.js +29 -0
  140. package/dist/esm/global-account/react/hooks/useQueryB3.js +5 -2
  141. package/dist/esm/global-account/react/hooks/useQueryBSMNT.js +5 -2
  142. package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
  143. package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +4 -1
  144. package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +2 -2
  145. package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +29 -25
  146. package/dist/esm/shared/utils/fetchBalances.d.ts +1 -1
  147. package/dist/styles/index.css +1 -1
  148. package/dist/types/anyspend/react/components/AnySpend.d.ts +11 -1
  149. package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
  150. package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
  151. package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  152. package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  153. package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  154. package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  155. package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  156. package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
  157. package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  158. package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  159. package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  160. package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  161. package/dist/types/anyspend/react/providers/index.d.ts +1 -0
  162. package/dist/types/anyspend/services/anyspend.d.ts +1 -1
  163. package/dist/types/anyspend/types/api.d.ts +51 -1
  164. package/dist/types/bondkit/bondkitToken.d.ts +37 -2
  165. package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
  166. package/dist/types/bondkit/config.d.ts +1 -1
  167. package/dist/types/bondkit/constants.d.ts +4 -0
  168. package/dist/types/bondkit/index.d.ts +1 -0
  169. package/dist/types/bondkit/swapService.d.ts +43 -0
  170. package/dist/types/bondkit/types.d.ts +10 -4
  171. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
  172. package/dist/types/global-account/react/hooks/index.d.ts +1 -0
  173. package/dist/types/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
  174. package/dist/types/shared/utils/fetchBalances.d.ts +1 -1
  175. package/package.json +6 -5
  176. package/src/anyspend/react/components/AnySpend.tsx +37 -1
  177. package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
  178. package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
  179. package/src/anyspend/react/components/AnySpendCustom.tsx +63 -13
  180. package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
  181. package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
  182. package/src/anyspend/react/components/AnyspendDepositHype.tsx +22 -0
  183. package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
  184. package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +7 -4
  185. package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
  186. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
  187. package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
  188. package/src/anyspend/react/components/common/OrderDetails.tsx +10 -14
  189. package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
  190. package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
  191. package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
  192. package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
  193. package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
  194. package/src/anyspend/react/hooks/useAnyspendFlow.ts +18 -8
  195. package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
  196. package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
  197. package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
  198. package/src/anyspend/react/providers/index.ts +1 -0
  199. package/src/anyspend/services/anyspend.ts +3 -1
  200. package/src/anyspend/types/api.ts +51 -1
  201. package/src/anyspend/types/api_req_res.ts +6 -10
  202. package/src/anyspend/utils/chain.ts +1 -1
  203. package/src/anyspend/utils/orderPayload.ts +3 -0
  204. package/src/bondkit/bondkitToken.ts +323 -3
  205. package/src/bondkit/bondkitTokenFactory.ts +2 -2
  206. package/src/bondkit/components/TradingView.tsx +3 -5
  207. package/src/bondkit/config.ts +5 -2
  208. package/src/bondkit/constants.ts +7 -0
  209. package/src/bondkit/index.ts +3 -0
  210. package/src/bondkit/swapService.ts +464 -0
  211. package/src/bondkit/types.ts +12 -5
  212. package/src/global-account/react/components/B3Provider/B3Provider.tsx +55 -15
  213. package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
  214. package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
  215. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
  216. package/src/global-account/react/hooks/index.ts +1 -0
  217. package/src/global-account/react/hooks/useAccountAssets.ts +4 -3
  218. package/src/global-account/react/hooks/useAuthentication.ts +2 -3
  219. package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
  220. package/src/global-account/react/hooks/useOneBalance.tsx +1 -1
  221. package/src/global-account/react/hooks/useQueryB3.ts +22 -15
  222. package/src/global-account/react/hooks/useQueryBSMNT.ts +22 -15
  223. package/src/global-account/react/hooks/useSimBalance.ts +2 -2
  224. package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +4 -1
  225. package/src/global-account/react/hooks/useTokenFromUrl.tsx +2 -2
  226. package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +30 -26
  227. package/src/shared/utils/fetchBalances.ts +1 -1
@@ -8,14 +8,14 @@ const config_1 = require("./config");
8
8
  // Define the event ABI snippet for BondkitTokenCreated specifically for decoding
9
9
  const bondkitTokenCreatedEventAbi = abis_1.BondkitTokenFactoryABI.find(item => item.type === "event" && item.name === "BondkitTokenCreated");
10
10
  class BondkitTokenFactory {
11
- constructor(chainId, walletKey) {
11
+ constructor(chainId, walletKey, rpcUrl) {
12
12
  if (walletKey && !walletKey.startsWith("0x")) {
13
13
  this.walletKey = `0x${walletKey}`;
14
14
  }
15
15
  else if (walletKey) {
16
16
  this.walletKey = walletKey;
17
17
  }
18
- const config = (0, config_1.getConfig)(chainId);
18
+ const config = (0, config_1.getConfig)(chainId, rpcUrl);
19
19
  this.chain = config.chain;
20
20
  this.contractAddress = config.factoryAddress;
21
21
  this.rpcUrl = config.rpcUrl;
@@ -2,16 +2,15 @@
2
2
  "use client";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const cdn_loader_1 = require("./utils/cdn-loader");
6
- const format_1 = require("./utils/format");
7
5
  const lucide_react_1 = require("lucide-react");
8
6
  const react_1 = require("react");
7
+ const cdn_loader_1 = require("./utils/cdn-loader");
8
+ const format_1 = require("./utils/format");
9
9
  // TradingView will be available on window after loading from CDN
10
10
  // Datafeed will be implemented inline
11
11
  // Mock loading overlay - replace with your actual loading component
12
12
  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
13
  const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
14
- const theme = "light";
15
14
  // Use token info for the current trade
16
15
  const currentTrade = {
17
16
  product_id: tokenAddress && tokenSymbol ? `${tokenSymbol}-${tokenAddress}` : "BONDKIT",
@@ -247,7 +246,7 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
247
246
  tvWidgetRef.current = null;
248
247
  }
249
248
  };
250
- }, [theme, librariesLoaded]);
249
+ }, [librariesLoaded, currentTrade?.product_id, tradingViewDefaultInterval, tradingViewTimezone]);
251
250
  (0, react_1.useEffect)(() => {
252
251
  if (chartLoaded &&
253
252
  currentTrade?.product_id &&
@@ -7,4 +7,4 @@ export interface Config {
7
7
  apiEndpoint: string;
8
8
  }
9
9
  export type SupportedChainId = typeof base.id;
10
- export declare const getConfig: (chainId: number) => Config;
10
+ export declare const getConfig: (chainId: number, rpcUrl?: string) => Config;
@@ -9,9 +9,12 @@ const baseMainnetConfig = {
9
9
  factoryAddress: constants_1.BaseBondkitTokenFactoryContractAddress,
10
10
  apiEndpoint: "https://api.b3.fun/bondkit-tokens",
11
11
  };
12
- const getConfig = (chainId) => {
12
+ const getConfig = (chainId, rpcUrl) => {
13
13
  if (chainId === chains_1.base.id) {
14
- return baseMainnetConfig;
14
+ return {
15
+ ...baseMainnetConfig,
16
+ rpcUrl: rpcUrl || constants_1.BaseMainnetRpcUrl,
17
+ };
15
18
  }
16
19
  throw new Error(`Unsupported chainId: ${chainId}. This SDK is configured for Base (Chain ID: ${chains_1.base.id}) only.`);
17
20
  };
@@ -1,3 +1,7 @@
1
1
  import type { Address } from "viem";
2
2
  export declare const BaseBondkitTokenFactoryContractAddress: Address;
3
3
  export declare const BaseMainnetRpcUrl = "https://base-rpc.publicnode.com";
4
+ export declare const UniversalRouterAddress: Address;
5
+ export declare const QuoterAddress: Address;
6
+ export declare const Permit2Address: Address;
7
+ export declare const B3TokenAddress: Address;
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseMainnetRpcUrl = exports.BaseBondkitTokenFactoryContractAddress = void 0;
3
+ exports.B3TokenAddress = exports.Permit2Address = exports.QuoterAddress = exports.UniversalRouterAddress = exports.BaseMainnetRpcUrl = exports.BaseBondkitTokenFactoryContractAddress = void 0;
4
4
  exports.BaseBondkitTokenFactoryContractAddress = "0x5d641bbB206d4B5585eCCd919F36270200A9A2Ad";
5
5
  exports.BaseMainnetRpcUrl = "https://base-rpc.publicnode.com";
6
+ // Uniswap V4 addresses on Base
7
+ exports.UniversalRouterAddress = "0x6ff5693b99212da76ad316178a184ab56d299b43";
8
+ exports.QuoterAddress = "0x0d5e0f971ed27fbff6c2837bf31316121532048d";
9
+ exports.Permit2Address = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
10
+ exports.B3TokenAddress = "0xB3B32F9f8827D4634fE7d973Fa1034Ec9fdDB3B3";
@@ -4,4 +4,5 @@ export * from "./config";
4
4
  export * from "./constants";
5
5
  export * from "./types";
6
6
  export * from "./abis";
7
+ export { BondkitSwapService } from "./swapService";
7
8
  export { default as TradingView } from "./components/TradingView";
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.TradingView = void 0;
20
+ exports.TradingView = exports.BondkitSwapService = void 0;
21
21
  // Core exports
22
22
  __exportStar(require("./bondkitToken"), exports);
23
23
  __exportStar(require("./bondkitTokenFactory"), exports);
@@ -28,6 +28,9 @@ __exportStar(require("./constants"), exports);
28
28
  __exportStar(require("./types"), exports);
29
29
  // ABIs
30
30
  __exportStar(require("./abis"), exports);
31
+ // Swap functionality
32
+ var swapService_1 = require("./swapService");
33
+ Object.defineProperty(exports, "BondkitSwapService", { enumerable: true, get: function () { return swapService_1.BondkitSwapService; } });
31
34
  // Components
32
35
  var TradingView_1 = require("./components/TradingView");
33
36
  Object.defineProperty(exports, "TradingView", { enumerable: true, get: function () { return __importDefault(TradingView_1).default; } });
@@ -0,0 +1,43 @@
1
+ import type { Address, WalletClient } from "viem";
2
+ import type { SwapQuote } from "./types";
3
+ interface SwapParams {
4
+ tokenIn: Address;
5
+ tokenOut: Address;
6
+ amountIn: string;
7
+ tokenInDecimals: number;
8
+ tokenOutDecimals: number;
9
+ slippageTolerance: number;
10
+ recipient: Address;
11
+ deadline?: number;
12
+ }
13
+ /**
14
+ * Internal swap service for handling Uniswap V4 swaps between trading token and bondkit token
15
+ */
16
+ export declare class BondkitSwapService {
17
+ private v4Config;
18
+ private configInitialized;
19
+ private readonly bondkitTokenAddress;
20
+ private readonly publicClient;
21
+ constructor(bondkitTokenAddress: Address);
22
+ /**
23
+ * Initialize V4 pool configuration from bondkit token contract
24
+ */
25
+ private initializeV4Config;
26
+ /**
27
+ * Get V4 pool configuration
28
+ */
29
+ private getV4Config;
30
+ /**
31
+ * Handle token approvals for swap
32
+ */
33
+ private handleTokenApprovals;
34
+ /**
35
+ * Get swap quote
36
+ */
37
+ getSwapQuote(params: SwapParams): Promise<SwapQuote | null>;
38
+ /**
39
+ * Execute swap transaction
40
+ */
41
+ executeSwap(params: SwapParams, walletClient: WalletClient): Promise<string | null>;
42
+ }
43
+ export {};
@@ -0,0 +1,376 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BondkitSwapService = void 0;
4
+ const viem_1 = require("viem");
5
+ const chains_1 = require("viem/chains");
6
+ const constants_1 = require("./constants");
7
+ // Minimal ABIs needed for swap functionality
8
+ const UNIVERSAL_ROUTER_ABI = [
9
+ {
10
+ inputs: [
11
+ { name: "commands", type: "bytes" },
12
+ { name: "inputs", type: "bytes[]" },
13
+ { name: "deadline", type: "uint256" },
14
+ ],
15
+ name: "execute",
16
+ outputs: [],
17
+ stateMutability: "payable",
18
+ type: "function",
19
+ },
20
+ ];
21
+ const QUOTER_ABI = [
22
+ {
23
+ inputs: [
24
+ {
25
+ components: [
26
+ {
27
+ components: [
28
+ { internalType: "Currency", name: "currency0", type: "address" },
29
+ { internalType: "Currency", name: "currency1", type: "address" },
30
+ { internalType: "uint24", name: "fee", type: "uint24" },
31
+ { internalType: "int24", name: "tickSpacing", type: "int24" },
32
+ { internalType: "contract IHooks", name: "hooks", type: "address" },
33
+ ],
34
+ internalType: "struct PoolKey",
35
+ name: "poolKey",
36
+ type: "tuple",
37
+ },
38
+ { internalType: "bool", name: "zeroForOne", type: "bool" },
39
+ { internalType: "uint128", name: "exactAmount", type: "uint128" },
40
+ { internalType: "bytes", name: "hookData", type: "bytes" },
41
+ ],
42
+ internalType: "struct IV4Quoter.QuoteExactSingleParams",
43
+ name: "params",
44
+ type: "tuple",
45
+ },
46
+ ],
47
+ name: "quoteExactInputSingle",
48
+ outputs: [
49
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
50
+ { internalType: "uint256", name: "gasEstimate", type: "uint256" },
51
+ ],
52
+ stateMutability: "nonpayable",
53
+ type: "function",
54
+ },
55
+ ];
56
+ const ERC20_ABI = [
57
+ {
58
+ inputs: [
59
+ { name: "spender", type: "address" },
60
+ { name: "amount", type: "uint256" },
61
+ ],
62
+ name: "approve",
63
+ outputs: [{ name: "", type: "bool" }],
64
+ stateMutability: "nonpayable",
65
+ type: "function",
66
+ },
67
+ {
68
+ inputs: [
69
+ { name: "owner", type: "address" },
70
+ { name: "spender", type: "address" },
71
+ ],
72
+ name: "allowance",
73
+ outputs: [{ name: "", type: "uint256" }],
74
+ stateMutability: "view",
75
+ type: "function",
76
+ },
77
+ ];
78
+ const PERMIT2_ABI = [
79
+ {
80
+ inputs: [
81
+ { name: "token", type: "address" },
82
+ { name: "spender", type: "address" },
83
+ { name: "amount", type: "uint160" },
84
+ { name: "expiration", type: "uint48" },
85
+ ],
86
+ name: "approve",
87
+ outputs: [],
88
+ stateMutability: "nonpayable",
89
+ type: "function",
90
+ },
91
+ {
92
+ inputs: [
93
+ { name: "owner", type: "address" },
94
+ { name: "token", type: "address" },
95
+ { name: "spender", type: "address" },
96
+ ],
97
+ name: "allowance",
98
+ outputs: [
99
+ { name: "amount", type: "uint160" },
100
+ { name: "expiration", type: "uint48" },
101
+ { name: "nonce", type: "uint48" },
102
+ ],
103
+ stateMutability: "view",
104
+ type: "function",
105
+ },
106
+ ];
107
+ const TOKEN_V4_CONFIG_ABI = [
108
+ {
109
+ inputs: [],
110
+ name: "v4Hook",
111
+ outputs: [{ internalType: "address", name: "", type: "address" }],
112
+ stateMutability: "view",
113
+ type: "function",
114
+ },
115
+ {
116
+ inputs: [],
117
+ name: "v4PoolFee",
118
+ outputs: [{ internalType: "uint24", name: "", type: "uint24" }],
119
+ stateMutability: "view",
120
+ type: "function",
121
+ },
122
+ {
123
+ inputs: [],
124
+ name: "v4TickSpacing",
125
+ outputs: [{ internalType: "int24", name: "", type: "int24" }],
126
+ stateMutability: "view",
127
+ type: "function",
128
+ },
129
+ ];
130
+ // Command and action constants
131
+ const COMMANDS = {
132
+ V4_SWAP: "0x10",
133
+ };
134
+ const V4_ACTIONS = {
135
+ SWAP_EXACT_IN_SINGLE: 6,
136
+ TAKE_ALL: 15,
137
+ SETTLE_ALL: 12,
138
+ };
139
+ /**
140
+ * Internal swap service for handling Uniswap V4 swaps between trading token and bondkit token
141
+ */
142
+ class BondkitSwapService {
143
+ constructor(bondkitTokenAddress) {
144
+ this.v4Config = null;
145
+ this.configInitialized = false;
146
+ this.bondkitTokenAddress = bondkitTokenAddress;
147
+ this.publicClient = (0, viem_1.createPublicClient)({
148
+ chain: chains_1.base,
149
+ transport: (0, viem_1.http)(constants_1.BaseMainnetRpcUrl),
150
+ });
151
+ }
152
+ /**
153
+ * Initialize V4 pool configuration from bondkit token contract
154
+ */
155
+ async initializeV4Config() {
156
+ if (this.configInitialized) {
157
+ return;
158
+ }
159
+ try {
160
+ const tokenContract = (0, viem_1.getContract)({
161
+ address: this.bondkitTokenAddress,
162
+ abi: TOKEN_V4_CONFIG_ABI,
163
+ client: this.publicClient,
164
+ });
165
+ const [hook, fee, tickSpacing] = await Promise.all([
166
+ tokenContract.read.v4Hook(),
167
+ tokenContract.read.v4PoolFee(),
168
+ tokenContract.read.v4TickSpacing(),
169
+ ]);
170
+ this.v4Config = {
171
+ hook: hook,
172
+ fee: Number(fee),
173
+ tickSpacing: Number(tickSpacing),
174
+ };
175
+ this.configInitialized = true;
176
+ }
177
+ catch (error) {
178
+ console.warn("Failed to initialize V4 configuration:", error);
179
+ // Use fallback configuration
180
+ this.v4Config = {
181
+ hook: "0xB36f4A2FB18b745ef8eD31452781a463d2B3f0cC",
182
+ fee: 30000,
183
+ tickSpacing: 60,
184
+ };
185
+ this.configInitialized = true;
186
+ }
187
+ }
188
+ /**
189
+ * Get V4 pool configuration
190
+ */
191
+ async getV4Config() {
192
+ await this.initializeV4Config();
193
+ if (!this.v4Config) {
194
+ throw new Error("Failed to initialize V4 configuration");
195
+ }
196
+ return this.v4Config;
197
+ }
198
+ /**
199
+ * Handle token approvals for swap
200
+ */
201
+ async handleTokenApprovals(tokenAddress, amountIn, walletClient, deadline) {
202
+ // Skip approvals for ETH
203
+ if (tokenAddress === "0x0000000000000000000000000000000000000000") {
204
+ return;
205
+ }
206
+ const userAddress = walletClient.account?.address;
207
+ if (!userAddress) {
208
+ throw new Error("No user address found");
209
+ }
210
+ const erc20Contract = (0, viem_1.getContract)({
211
+ address: tokenAddress,
212
+ abi: ERC20_ABI,
213
+ client: walletClient,
214
+ });
215
+ const permit2Contract = (0, viem_1.getContract)({
216
+ address: constants_1.Permit2Address,
217
+ abi: PERMIT2_ABI,
218
+ client: walletClient,
219
+ });
220
+ // Check ERC20 allowance to Permit2
221
+ const currentAllowance = (await erc20Contract.read.allowance([userAddress, constants_1.Permit2Address]));
222
+ const requiredAmount = BigInt(amountIn);
223
+ if (currentAllowance < requiredAmount) {
224
+ await erc20Contract.write.approve([constants_1.Permit2Address, BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")], {
225
+ account: userAddress,
226
+ chain: chains_1.base,
227
+ });
228
+ }
229
+ // Check Permit2 allowance for Universal Router
230
+ const permit2Allowance = (await permit2Contract.read.allowance([
231
+ userAddress,
232
+ tokenAddress,
233
+ constants_1.UniversalRouterAddress,
234
+ ]));
235
+ const [currentPermit2Amount, expiration] = permit2Allowance;
236
+ const currentTime = Math.floor(Date.now() / 1000);
237
+ const isExpired = expiration <= currentTime;
238
+ if (currentPermit2Amount < requiredAmount || isExpired) {
239
+ await permit2Contract.write.approve([tokenAddress, constants_1.UniversalRouterAddress, BigInt("0xffffffffffffffffffffffffffffffffffffff"), Number(deadline)], {
240
+ account: userAddress,
241
+ chain: chains_1.base,
242
+ });
243
+ }
244
+ }
245
+ /**
246
+ * Get swap quote
247
+ */
248
+ async getSwapQuote(params) {
249
+ try {
250
+ const { tokenIn, tokenOut, amountIn, tokenInDecimals, tokenOutDecimals, slippageTolerance } = params;
251
+ const v4Config = await this.getV4Config();
252
+ const amountInWei = (0, viem_1.parseUnits)(amountIn, tokenInDecimals);
253
+ // Determine token order for pool
254
+ const currency0 = tokenIn.toLowerCase() < tokenOut.toLowerCase() ? tokenIn : tokenOut;
255
+ const currency1 = tokenIn.toLowerCase() < tokenOut.toLowerCase() ? tokenOut : tokenIn;
256
+ const zeroForOne = tokenIn.toLowerCase() === currency0.toLowerCase();
257
+ const poolKey = {
258
+ currency0: currency0,
259
+ currency1: currency1,
260
+ fee: v4Config.fee,
261
+ tickSpacing: v4Config.tickSpacing,
262
+ hooks: v4Config.hook,
263
+ };
264
+ const quoteParams = {
265
+ poolKey,
266
+ zeroForOne,
267
+ exactAmount: BigInt(amountInWei.toString()),
268
+ hookData: "0x",
269
+ };
270
+ const { result } = await this.publicClient.simulateContract({
271
+ address: constants_1.QuoterAddress,
272
+ abi: QUOTER_ABI,
273
+ functionName: "quoteExactInputSingle",
274
+ args: [quoteParams],
275
+ });
276
+ const [amountOut] = result;
277
+ const amountOutRaw = (0, viem_1.formatUnits)(amountOut, tokenOutDecimals);
278
+ const amountOutFormatted = parseFloat(amountOutRaw).toFixed(Math.min(6, tokenOutDecimals));
279
+ // Calculate minimum amount out with slippage
280
+ const slippageMultiplier = (100 - slippageTolerance) / 100;
281
+ const amountOutMinRaw = parseFloat(amountOutFormatted) * slippageMultiplier;
282
+ const amountOutMin = amountOutMinRaw.toFixed(tokenOutDecimals);
283
+ // Simple execution price calculation
284
+ const rate = parseFloat(amountOutFormatted) / parseFloat(amountIn);
285
+ const executionPrice = `1 = ${rate.toFixed(6)}`;
286
+ return {
287
+ amountOut: amountOutFormatted,
288
+ amountOutMin,
289
+ priceImpact: "0.0", // Simplified
290
+ executionPrice,
291
+ fee: (v4Config.fee / 10000).toString(),
292
+ };
293
+ }
294
+ catch (error) {
295
+ console.warn("Error getting swap quote:", error);
296
+ return null;
297
+ }
298
+ }
299
+ /**
300
+ * Execute swap transaction
301
+ */
302
+ async executeSwap(params, walletClient) {
303
+ try {
304
+ const { tokenIn, tokenOut, amountIn, tokenInDecimals, tokenOutDecimals, deadline } = params;
305
+ const swapDeadline = deadline || Math.floor(Date.now() / 1000) + 3600;
306
+ if (!walletClient.account) {
307
+ throw new Error("Wallet client must have an account");
308
+ }
309
+ const amountInWei = (0, viem_1.parseUnits)(amountIn, tokenInDecimals);
310
+ // Handle token approvals
311
+ await this.handleTokenApprovals(tokenIn, amountInWei.toString(), walletClient, swapDeadline);
312
+ // Get quote for minimum amount out
313
+ const quote = await this.getSwapQuote(params);
314
+ if (!quote) {
315
+ throw new Error("Unable to get swap quote");
316
+ }
317
+ const amountOutMinimum = (0, viem_1.parseUnits)(quote.amountOutMin, tokenOutDecimals);
318
+ const v4Config = await this.getV4Config();
319
+ // Determine token order
320
+ const currency0 = tokenIn.toLowerCase() < tokenOut.toLowerCase() ? tokenIn : tokenOut;
321
+ const currency1 = tokenIn.toLowerCase() < tokenOut.toLowerCase() ? tokenOut : tokenIn;
322
+ const zeroForOne = tokenIn.toLowerCase() === currency0.toLowerCase();
323
+ const poolKey = [currency0, currency1, v4Config.fee, v4Config.tickSpacing, v4Config.hook];
324
+ // Encode V4 actions
325
+ const actions = [
326
+ {
327
+ type: V4_ACTIONS.SWAP_EXACT_IN_SINGLE,
328
+ params: [poolKey, zeroForOne, amountInWei, amountOutMinimum, "0x"],
329
+ },
330
+ {
331
+ type: V4_ACTIONS.TAKE_ALL,
332
+ params: [(zeroForOne ? currency1 : currency0), BigInt(0)],
333
+ },
334
+ {
335
+ type: V4_ACTIONS.SETTLE_ALL,
336
+ params: [(zeroForOne ? currency0 : currency1), amountInWei],
337
+ },
338
+ ];
339
+ // Encode actions
340
+ const actionTypes = actions.map(action => action.type);
341
+ const actionsBytes = ("0x" + actionTypes.map(type => type.toString(16).padStart(2, "0")).join(""));
342
+ const actionParams = actions.map(action => {
343
+ switch (action.type) {
344
+ case V4_ACTIONS.SWAP_EXACT_IN_SINGLE:
345
+ return (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("((address,address,uint24,int24,address),bool,uint128,uint128,bytes)"), [action.params]);
346
+ case V4_ACTIONS.TAKE_ALL:
347
+ return (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("address,uint256"), action.params);
348
+ case V4_ACTIONS.SETTLE_ALL:
349
+ return (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("address,uint256"), action.params);
350
+ default:
351
+ return "0x00";
352
+ }
353
+ });
354
+ const v4SwapInput = (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("bytes,bytes[]"), [actionsBytes, actionParams]);
355
+ const commands = COMMANDS.V4_SWAP;
356
+ const inputs = [v4SwapInput];
357
+ // Execute swap
358
+ const universalRouter = (0, viem_1.getContract)({
359
+ address: constants_1.UniversalRouterAddress,
360
+ abi: UNIVERSAL_ROUTER_ABI,
361
+ client: walletClient,
362
+ });
363
+ const txHash = await universalRouter.write.execute([commands, inputs, BigInt(swapDeadline)], {
364
+ account: walletClient.account,
365
+ chain: chains_1.base,
366
+ value: tokenIn === "0x0000000000000000000000000000000000000000" ? amountInWei : BigInt(0),
367
+ });
368
+ return txHash;
369
+ }
370
+ catch (error) {
371
+ console.warn("Error executing swap:", error);
372
+ return null;
373
+ }
374
+ }
375
+ }
376
+ exports.BondkitSwapService = BondkitSwapService;
@@ -49,10 +49,9 @@ export type DexMigrationEventArgs = {
49
49
  ethForFeeRecipient: bigint;
50
50
  };
51
51
  export declare enum TokenStatus {
52
- Inactive = 0,// Assuming mapping from ABI, verify actual enum values if specified elsewhere
53
- BondingPhase = 1,
54
- DexPhase = 2,
55
- Migrated = 3
52
+ Uninitialized = 0,
53
+ Bonding = 1,
54
+ Dex = 2
56
55
  }
57
56
  export interface GetTransactionHistoryOptions {
58
57
  userAddress?: Address;
@@ -80,3 +79,10 @@ export interface TransactionResponse {
80
79
  skip: number;
81
80
  data: Transaction[];
82
81
  }
82
+ export interface SwapQuote {
83
+ amountOut: string;
84
+ amountOutMin: string;
85
+ priceImpact: string;
86
+ executionPrice: string;
87
+ fee: string;
88
+ }
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TokenStatus = void 0;
4
- // Enum for Status (used in BondkitToken ABI)
4
+ // Enum for Status (matches contract Status enum exactly)
5
5
  var TokenStatus;
6
6
  (function (TokenStatus) {
7
- TokenStatus[TokenStatus["Inactive"] = 0] = "Inactive";
8
- TokenStatus[TokenStatus["BondingPhase"] = 1] = "BondingPhase";
9
- TokenStatus[TokenStatus["DexPhase"] = 2] = "DexPhase";
10
- TokenStatus[TokenStatus["Migrated"] = 3] = "Migrated";
7
+ TokenStatus[TokenStatus["Uninitialized"] = 0] = "Uninitialized";
8
+ TokenStatus[TokenStatus["Bonding"] = 1] = "Bonding";
9
+ TokenStatus[TokenStatus["Dex"] = 2] = "Dex";
11
10
  })(TokenStatus || (exports.TokenStatus = TokenStatus = {}));
@@ -1,13 +1,12 @@
1
1
  import { PermissionsConfig } from "../../../../global-account/types/permissions";
2
+ import "@reservoir0x/relay-kit-ui/styles.css";
2
3
  import { Account } from "thirdweb/wallets";
3
4
  import { ClientType } from "../../../client-manager";
4
5
  import { B3ContextType } from "./types";
5
- import "@reservoir0x/relay-kit-ui/styles.css";
6
- export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], any, readonly import("wagmi").CreateConnectorFn[]>;
7
6
  /**
8
7
  * Main B3Provider component
9
8
  */
10
- export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, }: {
9
+ export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, }: {
11
10
  theme: "light" | "dark";
12
11
  children: React.ReactNode;
13
12
  accountOverride?: Account;
@@ -19,6 +18,8 @@ export declare function B3Provider({ theme, children, accountOverride, environme
19
18
  style?: React.CSSProperties;
20
19
  };
21
20
  clientType?: ClientType;
21
+ rpcUrls?: Record<number, string>;
22
+ partnerId?: string;
22
23
  }): import("react/jsx-runtime").JSX.Element;
23
24
  /**
24
25
  * Inner provider component that provides the actual B3Context