@b3dotfun/sdk 0.0.40-alpha.5 → 0.0.40-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bondkit/bondkitToken.d.ts +36 -1
- package/dist/cjs/bondkit/bondkitToken.js +266 -0
- 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 +373 -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 +3 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +35 -16
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/esm/bondkit/bondkitToken.d.ts +36 -1
- package/dist/esm/bondkit/bondkitToken.js +266 -0
- 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 +369 -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 +3 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +36 -17
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/types/bondkit/bondkitToken.d.ts +36 -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 +3 -2
- package/package.json +6 -5
- package/src/bondkit/bondkitToken.ts +321 -1
- package/src/bondkit/constants.ts +7 -0
- package/src/bondkit/index.ts +3 -0
- package/src/bondkit/swapService.ts +461 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +49 -24
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- package/src/global-account/react/hooks/useAuthentication.ts +1 -2
|
@@ -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,6 +19,7 @@ export declare class BondkitToken {
|
|
|
18
19
|
private walletClientInstance;
|
|
19
20
|
private connectedProvider?;
|
|
20
21
|
private tradingToken?;
|
|
22
|
+
private swapService?;
|
|
21
23
|
constructor(contractAddress: string, walletKey?: string, rpcUrl?: string);
|
|
22
24
|
connect(provider?: EIP1193Provider): boolean;
|
|
23
25
|
/**
|
|
@@ -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");
|
|
@@ -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;
|
|
@@ -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 {};
|