@b3dotfun/sdk 0.0.40-test.6 → 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.
- package/dist/cjs/anyspend/constants/index.d.ts +0 -1
- package/dist/cjs/anyspend/constants/index.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +22 -10
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +41 -20
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +10 -8
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +7 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +24 -23
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -8
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.js +24 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/providers/index.js +3 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +2 -0
- package/dist/cjs/anyspend/types/api.d.ts +51 -1
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +3 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
- package/dist/cjs/bondkit/bondkitToken.js +268 -2
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/cjs/bondkit/components/TradingView.js +3 -4
- package/dist/cjs/bondkit/config.d.ts +1 -1
- package/dist/cjs/bondkit/config.js +5 -2
- package/dist/cjs/bondkit/constants.d.ts +4 -0
- package/dist/cjs/bondkit/constants.js +6 -1
- package/dist/cjs/bondkit/index.d.ts +1 -0
- package/dist/cjs/bondkit/index.js +4 -1
- package/dist/cjs/bondkit/swapService.d.ts +43 -0
- package/dist/cjs/bondkit/swapService.js +376 -0
- package/dist/cjs/bondkit/types.d.ts +10 -4
- package/dist/cjs/bondkit/types.js +4 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +27 -28
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useAccountAssets.js +5 -2
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +0 -12
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -3
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.js +32 -0
- package/dist/cjs/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/cjs/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +7 -1
- package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +28 -24
- package/dist/cjs/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/esm/anyspend/constants/index.d.ts +0 -1
- package/dist/esm/anyspend/constants/index.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +23 -11
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +41 -20
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +11 -9
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +8 -5
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +25 -24
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +10 -9
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.js +21 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
- package/dist/esm/anyspend/react/providers/index.js +1 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +2 -0
- package/dist/esm/anyspend/types/api.d.ts +51 -1
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/anyspend/utils/orderPayload.js +3 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
- package/dist/esm/bondkit/bondkitToken.js +268 -2
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/esm/bondkit/components/TradingView.js +3 -4
- package/dist/esm/bondkit/config.d.ts +1 -1
- package/dist/esm/bondkit/config.js +5 -2
- package/dist/esm/bondkit/constants.d.ts +4 -0
- package/dist/esm/bondkit/constants.js +5 -0
- package/dist/esm/bondkit/index.d.ts +1 -0
- package/dist/esm/bondkit/index.js +2 -0
- package/dist/esm/bondkit/swapService.d.ts +43 -0
- package/dist/esm/bondkit/swapService.js +372 -0
- package/dist/esm/bondkit/types.d.ts +10 -4
- package/dist/esm/bondkit/types.js +4 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +27 -28
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAccountAssets.js +2 -2
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +0 -12
- package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -3
- package/dist/esm/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useGlobalAccount.js +29 -0
- package/dist/esm/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/esm/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +4 -1
- package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +29 -25
- package/dist/esm/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/types/anyspend/react/providers/index.d.ts +1 -0
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +51 -1
- package/dist/types/bondkit/bondkitToken.d.ts +37 -2
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/types/bondkit/config.d.ts +1 -1
- package/dist/types/bondkit/constants.d.ts +4 -0
- package/dist/types/bondkit/index.d.ts +1 -0
- package/dist/types/bondkit/swapService.d.ts +43 -0
- package/dist/types/bondkit/types.d.ts +10 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/types/shared/utils/fetchBalances.d.ts +1 -1
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +0 -2
- package/src/anyspend/react/components/AnySpend.tsx +52 -18
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +82 -34
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +38 -18
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +12 -4
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
- package/src/anyspend/react/components/common/OrderDetails.tsx +60 -47
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +62 -41
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
- package/src/anyspend/react/components/common/PaymentMethodSwitch.tsx +38 -0
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +65 -43
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +18 -8
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/services/anyspend.ts +3 -1
- package/src/anyspend/types/api.ts +51 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/chain.ts +1 -1
- package/src/anyspend/utils/orderPayload.ts +3 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/components/TradingView.tsx +3 -5
- package/src/bondkit/config.ts +5 -2
- package/src/bondkit/constants.ts +7 -0
- package/src/bondkit/index.ts +3 -0
- package/src/bondkit/swapService.ts +464 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +31 -32
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAccountAssets.ts +4 -3
- package/src/global-account/react/hooks/useAccountWallet.tsx +0 -13
- package/src/global-account/react/hooks/useAuthentication.ts +2 -3
- package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
- package/src/global-account/react/hooks/useOneBalance.tsx +1 -1
- package/src/global-account/react/hooks/useQueryB3.ts +22 -15
- package/src/global-account/react/hooks/useQueryBSMNT.ts +22 -15
- package/src/global-account/react/hooks/useSimBalance.ts +2 -2
- package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +4 -1
- package/src/global-account/react/hooks/useTokenFromUrl.tsx +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +30 -26
- package/src/shared/utils/fetchBalances.ts +1 -1
- package/dist/cjs/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/cjs/global-account/examples/client-selection-example.js +0 -96
- package/dist/esm/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/esm/global-account/examples/client-selection-example.js +0 -93
- package/dist/types/global-account/examples/client-selection-example.d.ts +0 -5
- package/src/global-account/docs/client-selection.md +0 -292
- package/src/global-account/examples/client-selection-example.tsx +0 -197
|
@@ -503,11 +503,16 @@ export interface paths {
|
|
|
503
503
|
* @example 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
504
504
|
*/
|
|
505
505
|
dstTokenAddress: string;
|
|
506
|
+
/**
|
|
507
|
+
* @description Recipient address
|
|
508
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
509
|
+
*/
|
|
510
|
+
recipientAddress?: string;
|
|
506
511
|
/**
|
|
507
512
|
* @description Type of trade execution
|
|
508
513
|
* @enum {string}
|
|
509
514
|
*/
|
|
510
|
-
tradeType: "EXACT_INPUT" | "
|
|
515
|
+
tradeType: "EXACT_INPUT" | "EXACT_OUTPUT";
|
|
511
516
|
/**
|
|
512
517
|
* @description Amount to quote
|
|
513
518
|
* @example 1000000000000000000
|
|
@@ -544,6 +549,11 @@ export interface paths {
|
|
|
544
549
|
* @example 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
545
550
|
*/
|
|
546
551
|
dstTokenAddress: string;
|
|
552
|
+
/**
|
|
553
|
+
* @description Recipient address
|
|
554
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
555
|
+
*/
|
|
556
|
+
recipientAddress?: string;
|
|
547
557
|
/** @description Custom payload for execution */
|
|
548
558
|
payload: {
|
|
549
559
|
/** @description Encoded transaction data */
|
|
@@ -567,6 +577,11 @@ export interface paths {
|
|
|
567
577
|
dstChain: number;
|
|
568
578
|
srcTokenAddress: string;
|
|
569
579
|
dstTokenAddress: string;
|
|
580
|
+
/**
|
|
581
|
+
* @description Recipient address
|
|
582
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
583
|
+
*/
|
|
584
|
+
recipientAddress?: string;
|
|
570
585
|
/** @enum {string} */
|
|
571
586
|
onrampVendor?: "coinbase" | "stripe" | "stripe-web2";
|
|
572
587
|
contractAddress: string;
|
|
@@ -581,6 +596,11 @@ export interface paths {
|
|
|
581
596
|
dstChain: number;
|
|
582
597
|
srcTokenAddress: string;
|
|
583
598
|
dstTokenAddress: string;
|
|
599
|
+
/**
|
|
600
|
+
* @description Recipient address
|
|
601
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
602
|
+
*/
|
|
603
|
+
recipientAddress?: string;
|
|
584
604
|
/** @enum {string} */
|
|
585
605
|
onrampVendor?: "coinbase" | "stripe" | "stripe-web2";
|
|
586
606
|
contractAddress: string;
|
|
@@ -592,6 +612,11 @@ export interface paths {
|
|
|
592
612
|
dstChain: number;
|
|
593
613
|
srcTokenAddress: string;
|
|
594
614
|
dstTokenAddress: string;
|
|
615
|
+
/**
|
|
616
|
+
* @description Recipient address
|
|
617
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
618
|
+
*/
|
|
619
|
+
recipientAddress?: string;
|
|
595
620
|
/** @enum {string} */
|
|
596
621
|
onrampVendor?: "coinbase" | "stripe" | "stripe-web2";
|
|
597
622
|
contractAddress: string;
|
|
@@ -622,6 +647,11 @@ export interface paths {
|
|
|
622
647
|
* @example 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
623
648
|
*/
|
|
624
649
|
dstTokenAddress: string;
|
|
650
|
+
/**
|
|
651
|
+
* @description Recipient address
|
|
652
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
653
|
+
*/
|
|
654
|
+
recipientAddress?: string;
|
|
625
655
|
/**
|
|
626
656
|
* @description Amount to quote
|
|
627
657
|
* @example 1000000000000000000
|
|
@@ -798,6 +828,16 @@ export interface paths {
|
|
|
798
828
|
* @example 0
|
|
799
829
|
*/
|
|
800
830
|
userBalance?: string;
|
|
831
|
+
/**
|
|
832
|
+
* @description Anyspend points that will be awarded for the order
|
|
833
|
+
* @example 100
|
|
834
|
+
*/
|
|
835
|
+
pointsAmount?: number;
|
|
836
|
+
/**
|
|
837
|
+
* @description Multiplier applied to points that will be awarded for the order
|
|
838
|
+
* @example 1.5
|
|
839
|
+
*/
|
|
840
|
+
pointsMultiplier?: number;
|
|
801
841
|
};
|
|
802
842
|
/** @example 200 */
|
|
803
843
|
statusCode: number;
|
|
@@ -1077,6 +1117,11 @@ export interface components {
|
|
|
1077
1117
|
* @example 990000
|
|
1078
1118
|
*/
|
|
1079
1119
|
actualDstAmount: string | null;
|
|
1120
|
+
/**
|
|
1121
|
+
* @description Amount in after fee
|
|
1122
|
+
* @example 990000
|
|
1123
|
+
*/
|
|
1124
|
+
amountInAfterFee: string | null;
|
|
1080
1125
|
};
|
|
1081
1126
|
/** @description HypeDuel-specific payload */
|
|
1082
1127
|
HypeDuelPayload: {
|
|
@@ -1090,6 +1135,11 @@ export interface components {
|
|
|
1090
1135
|
* @example 990000
|
|
1091
1136
|
*/
|
|
1092
1137
|
actualDstAmount: string | null;
|
|
1138
|
+
/**
|
|
1139
|
+
* @description Amount in after fee
|
|
1140
|
+
* @example 990000
|
|
1141
|
+
*/
|
|
1142
|
+
amountInAfterFee: string | null;
|
|
1093
1143
|
};
|
|
1094
1144
|
/** @description Custom execution payload */
|
|
1095
1145
|
CustomPayload: {
|
|
@@ -127,7 +127,7 @@ exports.EVM_MAINNET = {
|
|
|
127
127
|
name: chains_1.bsc.name,
|
|
128
128
|
logoUrl: "https://avatars.githubusercontent.com/u/45615063?s=280&v=4",
|
|
129
129
|
type: chain_1.ChainType.EVM,
|
|
130
|
-
nativeRequired: (0, viem_1.parseEther)("0.
|
|
130
|
+
nativeRequired: (0, viem_1.parseEther)("0.0001"),
|
|
131
131
|
canDepositNative: true,
|
|
132
132
|
defaultToken: (0, token_1.getBnbToken)(),
|
|
133
133
|
nativeToken: (0, token_1.getBnbToken)(),
|
|
@@ -9,6 +9,7 @@ const buildPayload = (orderType, params) => {
|
|
|
9
9
|
return {
|
|
10
10
|
expectedDstAmount,
|
|
11
11
|
actualDstAmount: null,
|
|
12
|
+
amountInAfterFee: null,
|
|
12
13
|
};
|
|
13
14
|
case "mint_nft":
|
|
14
15
|
if (nft?.type === "erc1155") {
|
|
@@ -23,6 +24,7 @@ const buildPayload = (orderType, params) => {
|
|
|
23
24
|
return {
|
|
24
25
|
contractAddress: (0, utils_1.normalizeAddress)(nft.contractAddress),
|
|
25
26
|
nftPrice: nft?.price || "",
|
|
27
|
+
tokenId: null,
|
|
26
28
|
contractType: nft?.type,
|
|
27
29
|
};
|
|
28
30
|
}
|
|
@@ -45,6 +47,7 @@ const buildPayload = (orderType, params) => {
|
|
|
45
47
|
return {
|
|
46
48
|
expectedDstAmount,
|
|
47
49
|
actualDstAmount: null,
|
|
50
|
+
amountInAfterFee: null,
|
|
48
51
|
};
|
|
49
52
|
default:
|
|
50
53
|
throw new Error(`Invalid order type: ${orderType}`);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Address, EIP1193Provider, GetContractReturnType, Hex, PublicClient, WalletClient } from "viem";
|
|
2
2
|
import { BondkitTokenABI } from "./abis";
|
|
3
|
-
import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions,
|
|
3
|
+
import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, SwapQuote, TokenDetails, TransactionResponse } from "./types";
|
|
4
|
+
import { TokenStatus } from "./types";
|
|
4
5
|
type ExecuteWriteOptions = {
|
|
5
6
|
value?: bigint;
|
|
6
7
|
gas?: bigint;
|
|
@@ -18,7 +19,8 @@ export declare class BondkitToken {
|
|
|
18
19
|
private walletClientInstance;
|
|
19
20
|
private connectedProvider?;
|
|
20
21
|
private tradingToken?;
|
|
21
|
-
|
|
22
|
+
private swapService?;
|
|
23
|
+
constructor(contractAddress: string, walletKey?: string, rpcUrl?: string);
|
|
22
24
|
connect(provider?: EIP1193Provider): boolean;
|
|
23
25
|
/**
|
|
24
26
|
* Connects using an EIP-1193 provider and requests accounts, selecting the first one.
|
|
@@ -69,5 +71,38 @@ export declare class BondkitToken {
|
|
|
69
71
|
migrateToDex(options?: ExecuteWriteOptions): Promise<Hex | undefined>;
|
|
70
72
|
transferTokenOwnership(newOwner: Address, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
|
|
71
73
|
renounceTokenOwnership(options?: ExecuteWriteOptions): Promise<Hex | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* Get the swap service instance (lazy initialization)
|
|
76
|
+
*/
|
|
77
|
+
private getSwapService;
|
|
78
|
+
/**
|
|
79
|
+
* Check if DEX swapping is available (token must be in Dex phase)
|
|
80
|
+
*/
|
|
81
|
+
isSwapAvailable(): Promise<boolean | undefined>;
|
|
82
|
+
/**
|
|
83
|
+
* Get swap quote for trading token → bondkit token
|
|
84
|
+
*/
|
|
85
|
+
getSwapQuoteForBondkitToken(amountTradingTokenIn: string, slippageTolerance?: number): Promise<SwapQuote | undefined>;
|
|
86
|
+
/**
|
|
87
|
+
* Get swap quote for bondkit token → trading token
|
|
88
|
+
*/
|
|
89
|
+
getSwapQuoteForTradingToken(amountBondkitTokenIn: string, slippageTolerance?: number): Promise<SwapQuote | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
* Swap trading token for bondkit token
|
|
92
|
+
*/
|
|
93
|
+
swapTradingTokenForBondkitToken(amountTradingTokenIn: string, slippageTolerance?: number, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
|
|
94
|
+
/**
|
|
95
|
+
* Swap bondkit token for trading token
|
|
96
|
+
*/
|
|
97
|
+
swapBondkitTokenForTradingToken(amountBondkitTokenIn: string, slippageTolerance?: number, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
|
|
98
|
+
/**
|
|
99
|
+
* Helper method to get trading token decimals
|
|
100
|
+
*/
|
|
101
|
+
private getTradingTokenDecimals;
|
|
102
|
+
/**
|
|
103
|
+
* Get trading token symbol
|
|
104
|
+
* @param tradingTokenAddress Optional trading token address to avoid fetching it again
|
|
105
|
+
*/
|
|
106
|
+
getTradingTokenSymbol(tradingTokenAddress?: Address): Promise<string | undefined>;
|
|
72
107
|
}
|
|
73
108
|
export {};
|
|
@@ -6,6 +6,8 @@ const accounts_1 = require("viem/accounts");
|
|
|
6
6
|
const chains_1 = require("viem/chains");
|
|
7
7
|
const abis_1 = require("./abis");
|
|
8
8
|
const config_1 = require("./config");
|
|
9
|
+
const swapService_1 = require("./swapService");
|
|
10
|
+
const types_1 = require("./types");
|
|
9
11
|
// Event ABI snippets for decoding
|
|
10
12
|
const boughtEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveBuy");
|
|
11
13
|
const soldEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveSell");
|
|
@@ -14,8 +16,8 @@ const dexMigrationEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "
|
|
|
14
16
|
const OKX_POLLING_MAX_RETRIES = 60; // 5 minutes with 5 second intervals
|
|
15
17
|
const OKX_POLLING_INTERVAL_MS = 5000; // 5 seconds
|
|
16
18
|
class BondkitToken {
|
|
17
|
-
constructor(contractAddress, walletKey) {
|
|
18
|
-
const sdkConfig = (0, config_1.getConfig)(chains_1.base.id);
|
|
19
|
+
constructor(contractAddress, walletKey, rpcUrl) {
|
|
20
|
+
const sdkConfig = (0, config_1.getConfig)(chains_1.base.id, rpcUrl);
|
|
19
21
|
this.chain = sdkConfig.chain;
|
|
20
22
|
this.rpcUrl = sdkConfig.rpcUrl;
|
|
21
23
|
this.apiEndpoint = sdkConfig.apiEndpoint;
|
|
@@ -558,5 +560,269 @@ class BondkitToken {
|
|
|
558
560
|
async renounceTokenOwnership(options) {
|
|
559
561
|
return this.executeWrite("renounceOwnership", [], options);
|
|
560
562
|
}
|
|
563
|
+
// --- DEX Swap Methods ---
|
|
564
|
+
/**
|
|
565
|
+
* Get the swap service instance (lazy initialization)
|
|
566
|
+
*/
|
|
567
|
+
getSwapService() {
|
|
568
|
+
if (!this.swapService) {
|
|
569
|
+
this.swapService = new swapService_1.BondkitSwapService(this.contractAddress);
|
|
570
|
+
}
|
|
571
|
+
return this.swapService;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Check if DEX swapping is available (token must be in Dex phase)
|
|
575
|
+
*/
|
|
576
|
+
async isSwapAvailable() {
|
|
577
|
+
try {
|
|
578
|
+
const status = await this.currentStatus();
|
|
579
|
+
return status === types_1.TokenStatus.Dex;
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
console.warn("Error checking swap availability:", error);
|
|
583
|
+
return undefined;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Get swap quote for trading token → bondkit token
|
|
588
|
+
*/
|
|
589
|
+
async getSwapQuoteForBondkitToken(amountTradingTokenIn, slippageTolerance = 0.5) {
|
|
590
|
+
try {
|
|
591
|
+
// Check if swapping is available
|
|
592
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
593
|
+
if (!swapAvailable) {
|
|
594
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
598
|
+
if (!tradingTokenAddress) {
|
|
599
|
+
console.warn("Trading token address not available");
|
|
600
|
+
return undefined;
|
|
601
|
+
}
|
|
602
|
+
// Get token details for decimals
|
|
603
|
+
const [tradingTokenDecimals, bondkitTokenDecimals] = await Promise.all([
|
|
604
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
605
|
+
this.decimals(),
|
|
606
|
+
]);
|
|
607
|
+
if (tradingTokenDecimals === undefined || bondkitTokenDecimals === undefined) {
|
|
608
|
+
console.warn("Unable to fetch token decimals");
|
|
609
|
+
return undefined;
|
|
610
|
+
}
|
|
611
|
+
const swapService = this.getSwapService();
|
|
612
|
+
const quote = await swapService.getSwapQuote({
|
|
613
|
+
tokenIn: tradingTokenAddress,
|
|
614
|
+
tokenOut: this.contractAddress,
|
|
615
|
+
amountIn: amountTradingTokenIn,
|
|
616
|
+
tokenInDecimals: tradingTokenDecimals,
|
|
617
|
+
tokenOutDecimals: bondkitTokenDecimals,
|
|
618
|
+
slippageTolerance,
|
|
619
|
+
recipient: this.walletClientInstance.account?.address || "0x0000000000000000000000000000000000000000",
|
|
620
|
+
});
|
|
621
|
+
return quote || undefined;
|
|
622
|
+
}
|
|
623
|
+
catch (error) {
|
|
624
|
+
console.warn("Error getting swap quote for bondkit token:", error);
|
|
625
|
+
return undefined;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Get swap quote for bondkit token → trading token
|
|
630
|
+
*/
|
|
631
|
+
async getSwapQuoteForTradingToken(amountBondkitTokenIn, slippageTolerance = 0.5) {
|
|
632
|
+
try {
|
|
633
|
+
// Check if swapping is available
|
|
634
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
635
|
+
if (!swapAvailable) {
|
|
636
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
637
|
+
return undefined;
|
|
638
|
+
}
|
|
639
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
640
|
+
if (!tradingTokenAddress) {
|
|
641
|
+
console.warn("Trading token address not available");
|
|
642
|
+
return undefined;
|
|
643
|
+
}
|
|
644
|
+
// Get token details for decimals
|
|
645
|
+
const [bondkitTokenDecimals, tradingTokenDecimals] = await Promise.all([
|
|
646
|
+
this.decimals(),
|
|
647
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
648
|
+
]);
|
|
649
|
+
if (bondkitTokenDecimals === undefined || tradingTokenDecimals === undefined) {
|
|
650
|
+
console.warn("Unable to fetch token decimals");
|
|
651
|
+
return undefined;
|
|
652
|
+
}
|
|
653
|
+
const swapService = this.getSwapService();
|
|
654
|
+
const quote = await swapService.getSwapQuote({
|
|
655
|
+
tokenIn: this.contractAddress,
|
|
656
|
+
tokenOut: tradingTokenAddress,
|
|
657
|
+
amountIn: amountBondkitTokenIn,
|
|
658
|
+
tokenInDecimals: bondkitTokenDecimals,
|
|
659
|
+
tokenOutDecimals: tradingTokenDecimals,
|
|
660
|
+
slippageTolerance,
|
|
661
|
+
recipient: this.walletClientInstance.account?.address || "0x0000000000000000000000000000000000000000",
|
|
662
|
+
});
|
|
663
|
+
return quote || undefined;
|
|
664
|
+
}
|
|
665
|
+
catch (error) {
|
|
666
|
+
console.warn("Error getting swap quote for trading token:", error);
|
|
667
|
+
return undefined;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Swap trading token for bondkit token
|
|
672
|
+
*/
|
|
673
|
+
async swapTradingTokenForBondkitToken(amountTradingTokenIn, slippageTolerance = 0.5, options) {
|
|
674
|
+
try {
|
|
675
|
+
// Check if swapping is available
|
|
676
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
677
|
+
if (!swapAvailable) {
|
|
678
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
679
|
+
return undefined;
|
|
680
|
+
}
|
|
681
|
+
if (!this.walletClientInstance.account && !this.walletKey) {
|
|
682
|
+
console.warn("Wallet key not set or client not connected for swap operation");
|
|
683
|
+
return undefined;
|
|
684
|
+
}
|
|
685
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
686
|
+
if (!tradingTokenAddress) {
|
|
687
|
+
console.warn("Trading token address not available");
|
|
688
|
+
return undefined;
|
|
689
|
+
}
|
|
690
|
+
// Get token details for decimals
|
|
691
|
+
const [tradingTokenDecimals, bondkitTokenDecimals] = await Promise.all([
|
|
692
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
693
|
+
this.decimals(),
|
|
694
|
+
]);
|
|
695
|
+
if (tradingTokenDecimals === undefined || bondkitTokenDecimals === undefined) {
|
|
696
|
+
console.warn("Unable to fetch token decimals");
|
|
697
|
+
return undefined;
|
|
698
|
+
}
|
|
699
|
+
const recipient = this.walletClientInstance.account?.address ||
|
|
700
|
+
(this.walletKey ? (0, accounts_1.privateKeyToAccount)(this.walletKey).address : undefined);
|
|
701
|
+
if (!recipient) {
|
|
702
|
+
console.warn("Unable to determine recipient address");
|
|
703
|
+
return undefined;
|
|
704
|
+
}
|
|
705
|
+
const swapService = this.getSwapService();
|
|
706
|
+
const txHash = await swapService.executeSwap({
|
|
707
|
+
tokenIn: tradingTokenAddress,
|
|
708
|
+
tokenOut: this.contractAddress,
|
|
709
|
+
amountIn: amountTradingTokenIn,
|
|
710
|
+
tokenInDecimals: tradingTokenDecimals,
|
|
711
|
+
tokenOutDecimals: bondkitTokenDecimals,
|
|
712
|
+
slippageTolerance,
|
|
713
|
+
recipient,
|
|
714
|
+
deadline: (options?.value ? Math.floor(Date.now() / 1000) : 0) + 3600,
|
|
715
|
+
}, this.walletClientInstance);
|
|
716
|
+
return txHash ? txHash : undefined;
|
|
717
|
+
}
|
|
718
|
+
catch (error) {
|
|
719
|
+
console.warn("Error swapping trading token for bondkit token:", error);
|
|
720
|
+
return undefined;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Swap bondkit token for trading token
|
|
725
|
+
*/
|
|
726
|
+
async swapBondkitTokenForTradingToken(amountBondkitTokenIn, slippageTolerance = 0.5, options) {
|
|
727
|
+
try {
|
|
728
|
+
// Check if swapping is available
|
|
729
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
730
|
+
if (!swapAvailable) {
|
|
731
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
732
|
+
return undefined;
|
|
733
|
+
}
|
|
734
|
+
if (!this.walletClientInstance.account && !this.walletKey) {
|
|
735
|
+
console.warn("Wallet key not set or client not connected for swap operation");
|
|
736
|
+
return undefined;
|
|
737
|
+
}
|
|
738
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
739
|
+
if (!tradingTokenAddress) {
|
|
740
|
+
console.warn("Trading token address not available");
|
|
741
|
+
return undefined;
|
|
742
|
+
}
|
|
743
|
+
// Get token details for decimals
|
|
744
|
+
const [bondkitTokenDecimals, tradingTokenDecimals] = await Promise.all([
|
|
745
|
+
this.decimals(),
|
|
746
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
747
|
+
]);
|
|
748
|
+
if (bondkitTokenDecimals === undefined || tradingTokenDecimals === undefined) {
|
|
749
|
+
console.warn("Unable to fetch token decimals");
|
|
750
|
+
return undefined;
|
|
751
|
+
}
|
|
752
|
+
const recipient = this.walletClientInstance.account?.address ||
|
|
753
|
+
(this.walletKey ? (0, accounts_1.privateKeyToAccount)(this.walletKey).address : undefined);
|
|
754
|
+
if (!recipient) {
|
|
755
|
+
console.warn("Unable to determine recipient address");
|
|
756
|
+
return undefined;
|
|
757
|
+
}
|
|
758
|
+
const swapService = this.getSwapService();
|
|
759
|
+
const txHash = await swapService.executeSwap({
|
|
760
|
+
tokenIn: this.contractAddress,
|
|
761
|
+
tokenOut: tradingTokenAddress,
|
|
762
|
+
amountIn: amountBondkitTokenIn,
|
|
763
|
+
tokenInDecimals: bondkitTokenDecimals,
|
|
764
|
+
tokenOutDecimals: tradingTokenDecimals,
|
|
765
|
+
slippageTolerance,
|
|
766
|
+
recipient,
|
|
767
|
+
deadline: (options?.value ? Math.floor(Date.now() / 1000) : 0) + 3600,
|
|
768
|
+
}, this.walletClientInstance);
|
|
769
|
+
return txHash ? txHash : undefined;
|
|
770
|
+
}
|
|
771
|
+
catch (error) {
|
|
772
|
+
console.warn("Error swapping bondkit token for trading token:", error);
|
|
773
|
+
return undefined;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Helper method to get trading token decimals
|
|
778
|
+
*/
|
|
779
|
+
async getTradingTokenDecimals(tradingTokenAddress) {
|
|
780
|
+
try {
|
|
781
|
+
// ETH has 18 decimals
|
|
782
|
+
if (tradingTokenAddress === "0x0000000000000000000000000000000000000000") {
|
|
783
|
+
return 18;
|
|
784
|
+
}
|
|
785
|
+
// For ERC20 tokens, read decimals from contract
|
|
786
|
+
const tradingTokenContract = (0, viem_1.getContract)({
|
|
787
|
+
address: tradingTokenAddress,
|
|
788
|
+
abi: viem_1.erc20Abi,
|
|
789
|
+
client: this.publicClient,
|
|
790
|
+
});
|
|
791
|
+
const decimals = await tradingTokenContract.read.decimals();
|
|
792
|
+
return Number(decimals);
|
|
793
|
+
}
|
|
794
|
+
catch (error) {
|
|
795
|
+
console.warn("Error fetching trading token decimals:", error);
|
|
796
|
+
return undefined;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Get trading token symbol
|
|
801
|
+
* @param tradingTokenAddress Optional trading token address to avoid fetching it again
|
|
802
|
+
*/
|
|
803
|
+
async getTradingTokenSymbol(tradingTokenAddress) {
|
|
804
|
+
try {
|
|
805
|
+
const tokenAddress = tradingTokenAddress || (await this.getTradingTokenAddress());
|
|
806
|
+
if (!tokenAddress) {
|
|
807
|
+
return undefined;
|
|
808
|
+
}
|
|
809
|
+
// ETH symbol
|
|
810
|
+
if (tokenAddress === "0x0000000000000000000000000000000000000000") {
|
|
811
|
+
return "ETH";
|
|
812
|
+
}
|
|
813
|
+
// For ERC20 tokens, read symbol from contract
|
|
814
|
+
const tradingTokenContract = (0, viem_1.getContract)({
|
|
815
|
+
address: tokenAddress,
|
|
816
|
+
abi: viem_1.erc20Abi,
|
|
817
|
+
client: this.publicClient,
|
|
818
|
+
});
|
|
819
|
+
const symbol = await tradingTokenContract.read.symbol();
|
|
820
|
+
return symbol;
|
|
821
|
+
}
|
|
822
|
+
catch (error) {
|
|
823
|
+
console.warn("Error fetching trading token symbol:", error);
|
|
824
|
+
return undefined;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
561
827
|
}
|
|
562
828
|
exports.BondkitToken = BondkitToken;
|
|
@@ -10,7 +10,7 @@ export declare class BondkitTokenFactory {
|
|
|
10
10
|
private rpcUrl;
|
|
11
11
|
private walletClientInstance;
|
|
12
12
|
private connectedProvider?;
|
|
13
|
-
constructor(chainId: SupportedChainId, walletKey?: string);
|
|
13
|
+
constructor(chainId: SupportedChainId, walletKey?: string, rpcUrl?: string);
|
|
14
14
|
connect(provider?: EIP1193Provider): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* Connects using an EIP-1193 provider and requests accounts, selecting the first one.
|
|
@@ -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
|
-
}, [
|
|
249
|
+
}, [librariesLoaded, currentTrade?.product_id, tradingViewDefaultInterval, tradingViewTimezone]);
|
|
251
250
|
(0, react_1.useEffect)(() => {
|
|
252
251
|
if (chartLoaded &&
|
|
253
252
|
currentTrade?.product_id &&
|
|
@@ -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
|
|
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";
|
|
@@ -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 {};
|