@b3dotfun/sdk 0.0.25-alpha.0 → 0.0.25-alpha.2
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/abis/BondkitTokenABI.d.ts +301 -73
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +296 -920
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.d.ts +253 -19
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.js +189 -370
- package/dist/cjs/bondkit/bondkitToken.d.ts +7 -4
- package/dist/cjs/bondkit/bondkitToken.js +85 -10
- package/dist/cjs/bondkit/constants.js +1 -1
- package/dist/cjs/bondkit/json_abis/BondkitABI.json +297 -913
- package/dist/cjs/bondkit/json_abis/BondkitFactoryABI.json +191 -368
- package/dist/cjs/bondkit/types.d.ts +7 -2
- package/dist/esm/bondkit/abis/BondkitTokenABI.d.ts +301 -73
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +296 -920
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.d.ts +253 -19
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.js +189 -370
- package/dist/esm/bondkit/bondkitToken.d.ts +7 -4
- package/dist/esm/bondkit/bondkitToken.js +86 -11
- package/dist/esm/bondkit/constants.js +1 -1
- package/dist/esm/bondkit/json_abis/BondkitABI.json +297 -913
- package/dist/esm/bondkit/json_abis/BondkitFactoryABI.json +191 -368
- package/dist/esm/bondkit/types.d.ts +7 -2
- package/dist/types/bondkit/abis/BondkitTokenABI.d.ts +301 -73
- package/dist/types/bondkit/abis/BondkitTokenFactoryABI.d.ts +253 -19
- package/dist/types/bondkit/bondkitToken.d.ts +7 -4
- package/dist/types/bondkit/types.d.ts +7 -2
- package/package.json +1 -1
- package/src/bondkit/abis/BondkitTokenABI.ts +296 -920
- package/src/bondkit/abis/BondkitTokenFactoryABI.ts +189 -370
- package/src/bondkit/bondkitToken.ts +102 -14
- package/src/bondkit/constants.ts +1 -1
- package/src/bondkit/json_abis/BondkitABI.json +297 -913
- package/src/bondkit/json_abis/BondkitFactoryABI.json +191 -368
- package/src/bondkit/types.ts +7 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address, EIP1193Provider, GetContractReturnType, Hex, PublicClient, WalletClient } from "viem";
|
|
2
2
|
import { BondkitTokenABI } from "./abis";
|
|
3
|
-
import type {
|
|
3
|
+
import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, TokenDetails, TokenStatus, TransactionResponse } from "./types";
|
|
4
4
|
type ExecuteWriteOptions = {
|
|
5
5
|
value?: bigint;
|
|
6
6
|
gas?: bigint;
|
|
@@ -17,6 +17,7 @@ export declare class BondkitToken {
|
|
|
17
17
|
private apiEndpoint;
|
|
18
18
|
private walletClientInstance;
|
|
19
19
|
private connectedProvider?;
|
|
20
|
+
private tradingToken?;
|
|
20
21
|
constructor(contractAddress: string, walletKey?: string);
|
|
21
22
|
connect(provider?: EIP1193Provider): boolean;
|
|
22
23
|
/**
|
|
@@ -30,6 +31,8 @@ export declare class BondkitToken {
|
|
|
30
31
|
decimals(): Promise<number | undefined>;
|
|
31
32
|
totalSupply(): Promise<bigint | undefined>;
|
|
32
33
|
balanceOf(account: Address): Promise<bigint | undefined>;
|
|
34
|
+
getTradingTokenBalanceOf(account: Address): Promise<bigint | undefined>;
|
|
35
|
+
getTradingTokenAddress(): Promise<Address | undefined>;
|
|
33
36
|
allowance(owner: Address, spender: Address): Promise<bigint | undefined>;
|
|
34
37
|
owner(): Promise<Address | undefined>;
|
|
35
38
|
getTokenDetails(): Promise<TokenDetails | undefined>;
|
|
@@ -37,9 +40,9 @@ export declare class BondkitToken {
|
|
|
37
40
|
currentStatus(): Promise<TokenStatus | undefined>;
|
|
38
41
|
getCurrentPhase(): Promise<string | undefined>;
|
|
39
42
|
getAmountOfTokensToBuy(ethAmount: bigint | string): Promise<bigint | undefined>;
|
|
40
|
-
|
|
43
|
+
getAmountOfTradingTokensToSell(amount: bigint): Promise<bigint | undefined>;
|
|
41
44
|
getCurrentBondingCurvePricePerToken(): Promise<bigint | undefined>;
|
|
42
|
-
|
|
45
|
+
totalRaisedBonding(): Promise<bigint | undefined>;
|
|
43
46
|
getTotalSupply(): Promise<bigint | undefined>;
|
|
44
47
|
getPaginatedHolders(startIndex: bigint, count?: bigint): Promise<{
|
|
45
48
|
address: Address;
|
|
@@ -57,7 +60,7 @@ export declare class BondkitToken {
|
|
|
57
60
|
approve(spender: Address, amount: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
|
|
58
61
|
transferFrom(from: Address, to: Address, amount: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
|
|
59
62
|
/** Buy tokens with ETH. Payable function. */
|
|
60
|
-
buy(
|
|
63
|
+
buy(amount: bigint | string, minTokensOut: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
|
|
61
64
|
/** Sell tokens for ETH. */
|
|
62
65
|
sell(tokenAmount: bigint, minEthOut: bigint, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
|
|
63
66
|
/** Migrate liquidity to DEX. Only callable by owner/migrationAdmin based on typical patterns. */
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BondkitToken = void 0;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const accounts_1 = require("viem/accounts");
|
|
6
|
+
const chains_1 = require("viem/chains");
|
|
6
7
|
const abis_1 = require("./abis");
|
|
7
8
|
const config_1 = require("./config");
|
|
8
|
-
const chains_1 = require("viem/chains");
|
|
9
9
|
// Event ABI snippets for decoding
|
|
10
10
|
const boughtEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveBuy");
|
|
11
11
|
const soldEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveSell");
|
|
@@ -40,6 +40,9 @@ class BondkitToken {
|
|
|
40
40
|
abi: abis_1.BondkitTokenABI,
|
|
41
41
|
client: this.walletClientInstance,
|
|
42
42
|
});
|
|
43
|
+
this.contract.read.tradingToken().then(tradingToken => {
|
|
44
|
+
this.tradingToken = tradingToken;
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
connect(provider) {
|
|
45
48
|
try {
|
|
@@ -166,6 +169,41 @@ class BondkitToken {
|
|
|
166
169
|
return undefined;
|
|
167
170
|
}
|
|
168
171
|
}
|
|
172
|
+
async getTradingTokenBalanceOf(account) {
|
|
173
|
+
try {
|
|
174
|
+
if (!this.tradingToken) {
|
|
175
|
+
console.warn("Trading token address not available");
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
// If trading token is ETH (zero address), get ETH balance
|
|
179
|
+
if (this.tradingToken === "0x0000000000000000000000000000000000000000") {
|
|
180
|
+
return await this.publicClient.getBalance({ address: account });
|
|
181
|
+
}
|
|
182
|
+
// For ERC20 trading tokens, get token balance
|
|
183
|
+
const tradingTokenContract = (0, viem_1.getContract)({
|
|
184
|
+
address: this.tradingToken,
|
|
185
|
+
abi: viem_1.erc20Abi,
|
|
186
|
+
client: this.publicClient, // Use public client for read operations
|
|
187
|
+
});
|
|
188
|
+
return await tradingTokenContract.read.balanceOf([account]);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
console.warn(`Error fetching trading token balance for ${account}:`, error);
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async getTradingTokenAddress() {
|
|
196
|
+
try {
|
|
197
|
+
if (!this.tradingToken) {
|
|
198
|
+
this.tradingToken = (await this.contract.read.tradingToken());
|
|
199
|
+
}
|
|
200
|
+
return this.tradingToken;
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
console.warn("Error fetching trading token address:", error);
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
169
207
|
async allowance(owner, spender) {
|
|
170
208
|
try {
|
|
171
209
|
return await this.contract.read.allowance([owner, spender]);
|
|
@@ -249,12 +287,12 @@ class BondkitToken {
|
|
|
249
287
|
return undefined;
|
|
250
288
|
}
|
|
251
289
|
}
|
|
252
|
-
async
|
|
290
|
+
async getAmountOfTradingTokensToSell(amount) {
|
|
253
291
|
try {
|
|
254
|
-
return await this.contract.read.
|
|
292
|
+
return await this.contract.read.getAmountOfTradingTokensToSell([amount]);
|
|
255
293
|
}
|
|
256
294
|
catch (e) {
|
|
257
|
-
console.warn("Error in
|
|
295
|
+
console.warn("Error in getAmountOfTradingTokensToSell:", e);
|
|
258
296
|
return undefined;
|
|
259
297
|
}
|
|
260
298
|
}
|
|
@@ -267,12 +305,12 @@ class BondkitToken {
|
|
|
267
305
|
return undefined;
|
|
268
306
|
}
|
|
269
307
|
}
|
|
270
|
-
async
|
|
308
|
+
async totalRaisedBonding() {
|
|
271
309
|
try {
|
|
272
|
-
return await this.contract.read.
|
|
310
|
+
return await this.contract.read.totalRaisedBonding();
|
|
273
311
|
}
|
|
274
312
|
catch (e) {
|
|
275
|
-
console.warn("Error fetching
|
|
313
|
+
console.warn("Error fetching totalRaisedBonding:", e);
|
|
276
314
|
return undefined;
|
|
277
315
|
}
|
|
278
316
|
}
|
|
@@ -428,11 +466,48 @@ class BondkitToken {
|
|
|
428
466
|
return this.executeWrite("transferFrom", [from, to, amount], options);
|
|
429
467
|
}
|
|
430
468
|
/** Buy tokens with ETH. Payable function. */
|
|
431
|
-
async buy(
|
|
469
|
+
async buy(amount, minTokensOut, options) {
|
|
432
470
|
if (!boughtEventAbi)
|
|
433
471
|
console.warn("Bought event ABI not found for event decoding.");
|
|
434
|
-
|
|
435
|
-
|
|
472
|
+
if (this.tradingToken === "0x0000000000000000000000000000000000000000") {
|
|
473
|
+
const value = typeof amount === "string" ? (0, viem_1.parseEther)(amount) : amount;
|
|
474
|
+
return this.executeWrite("buy", [minTokensOut], { ...options, value });
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
// For ERC20 trading tokens, we need to approve first, then call buy
|
|
478
|
+
const tradingTokenContract = (0, viem_1.getContract)({
|
|
479
|
+
address: this.tradingToken,
|
|
480
|
+
abi: viem_1.erc20Abi,
|
|
481
|
+
client: this.walletClientInstance,
|
|
482
|
+
});
|
|
483
|
+
const currentAllowance = await tradingTokenContract.read.allowance([
|
|
484
|
+
this.walletClientInstance.account?.address,
|
|
485
|
+
this.contractAddress,
|
|
486
|
+
]);
|
|
487
|
+
const amountBigInt = typeof amount === "string" ? (0, viem_1.parseEther)(amount) : BigInt(amount);
|
|
488
|
+
if (currentAllowance < amountBigInt) {
|
|
489
|
+
// Get account for the approve transaction
|
|
490
|
+
const accountToUse = this.walletKey ? (0, accounts_1.privateKeyToAccount)(this.walletKey) : this.walletClientInstance.account;
|
|
491
|
+
if (!accountToUse)
|
|
492
|
+
throw new Error("Account for transaction could not be determined.");
|
|
493
|
+
// Create approve options with required fields but without value (ERC20 approve doesn't need ETH)
|
|
494
|
+
const approveOptions = {
|
|
495
|
+
account: accountToUse,
|
|
496
|
+
chain: this.chain,
|
|
497
|
+
};
|
|
498
|
+
// Add optional transaction parameters if provided
|
|
499
|
+
if (options?.gas !== undefined)
|
|
500
|
+
approveOptions.gas = options.gas;
|
|
501
|
+
if (options?.maxFeePerGas !== undefined)
|
|
502
|
+
approveOptions.maxFeePerGas = options.maxFeePerGas;
|
|
503
|
+
if (options?.maxPriorityFeePerGas !== undefined)
|
|
504
|
+
approveOptions.maxPriorityFeePerGas = options.maxPriorityFeePerGas;
|
|
505
|
+
const approveTx = await tradingTokenContract.write.approve([this.contractAddress, amountBigInt], approveOptions);
|
|
506
|
+
await this.publicClient.waitForTransactionReceipt({ hash: approveTx });
|
|
507
|
+
}
|
|
508
|
+
// Now call the buy function with the trading token amount
|
|
509
|
+
return this.executeWrite("buy", [amountBigInt, minTokensOut], options);
|
|
510
|
+
}
|
|
436
511
|
}
|
|
437
512
|
/** Sell tokens for ETH. */
|
|
438
513
|
async sell(tokenAmount, minEthOut, options) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseMainnetRpcUrl = exports.BaseBondkitTokenFactoryContractAddress = void 0;
|
|
4
|
-
exports.BaseBondkitTokenFactoryContractAddress = "
|
|
4
|
+
exports.BaseBondkitTokenFactoryContractAddress = "0x0ccA36e9BE8Fdf456dE4BC20b378B1560Aeb6653";
|
|
5
5
|
exports.BaseMainnetRpcUrl = "https://base-rpc.publicnode.com";
|