clanker-sdk 4.0.13 → 4.0.15
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/cli/cli.js +63 -40
- package/dist/cli/create-clanker.js +61 -39
- package/dist/index.d.ts +244 -44
- package/dist/index.js +341 -64
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -883,14 +883,12 @@ var init_Clanker = __esm({
|
|
|
883
883
|
|
|
884
884
|
// src/constants.ts
|
|
885
885
|
import { base, baseSepolia } from "viem/chains";
|
|
886
|
-
var CLANKER_FACTORY_V3_1,
|
|
886
|
+
var CLANKER_FACTORY_V3_1, WETH_ADDRESS, DEGEN_ADDRESS, NATIVE_ADDRESS, CLANKER_ADDRESS, ANON_ADDRESS, HIGHER_ADDRESS, CB_BTC_ADDRESS, A0X_ADDRESS, SUPPORTED_CHAINS, DEFAULT_SUPPLY, CLANKER_FACTORY_V4, CLANKER_LOCKER_V4, CLANKER_VAULT_V4, CLANKER_AIRDROP_V4, CLANKER_DEVBUY_V4, CLANKER_MEV_MODULE_V4, CLANKER_HOOK_STATIC_FEE_V4, CLANKER_HOOK_DYNAMIC_FEE_V4;
|
|
887
887
|
var init_constants = __esm({
|
|
888
888
|
"src/constants.ts"() {
|
|
889
889
|
"use strict";
|
|
890
890
|
init_esm_shims();
|
|
891
891
|
CLANKER_FACTORY_V3_1 = "0x2A787b2362021cC3eEa3C24C4748a6cD5B687382";
|
|
892
|
-
CLANKER_FACTORY_V4 = "0x8608Ed9A6C2897678501FA01c47f9CC248457F94";
|
|
893
|
-
CLANKER_LOCKER_V4 = "0x057DA2d99D57FDc9B0316Fa1eC073E05d6f4c063";
|
|
894
892
|
WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
|
|
895
893
|
DEGEN_ADDRESS = "0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed";
|
|
896
894
|
NATIVE_ADDRESS = "0x20DD04c17AFD5c9a8b3f2cdacaa8Ee7907385BEF";
|
|
@@ -901,12 +899,14 @@ var init_constants = __esm({
|
|
|
901
899
|
A0X_ADDRESS = "0x820C5F0fB255a1D18fd0eBB0F1CCefbC4D546dA7";
|
|
902
900
|
SUPPORTED_CHAINS = [base.id, baseSepolia.id];
|
|
903
901
|
DEFAULT_SUPPLY = 100000000000000000000000000000n;
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
902
|
+
CLANKER_FACTORY_V4 = "0xE85A59c628F7d27878ACeB4bf3b35733630083a9";
|
|
903
|
+
CLANKER_LOCKER_V4 = "0x29d17C1A8D851d7d4cA97FAe97AcAdb398D9cCE0";
|
|
904
|
+
CLANKER_VAULT_V4 = "0x8E845EAd15737bF71904A30BdDD3aEE76d6ADF6C";
|
|
905
|
+
CLANKER_AIRDROP_V4 = "0x56Fa0Da89eD94822e46734e736d34Cab72dF344F";
|
|
906
|
+
CLANKER_DEVBUY_V4 = "0x1331f0788F9c08C8F38D52c7a1152250A9dE00be";
|
|
907
|
+
CLANKER_MEV_MODULE_V4 = "0xE143f9872A33c955F23cF442BB4B1EFB3A7402A2";
|
|
908
|
+
CLANKER_HOOK_STATIC_FEE_V4 = "0xDd5EeaFf7BD481AD55Db083062b13a3cdf0A68CC";
|
|
909
|
+
CLANKER_HOOK_DYNAMIC_FEE_V4 = "0x34a45c6B61876d739400Bd71228CbcbD4F53E8cC";
|
|
910
910
|
}
|
|
911
911
|
});
|
|
912
912
|
|
|
@@ -4513,7 +4513,7 @@ var init_vanityAddress = __esm({
|
|
|
4513
4513
|
});
|
|
4514
4514
|
|
|
4515
4515
|
// src/services/buildTransaction.ts
|
|
4516
|
-
import { encodeFunctionData
|
|
4516
|
+
import { encodeFunctionData, getAddress, isAddress as isAddress2, stringify } from "viem";
|
|
4517
4517
|
async function buildTransaction({
|
|
4518
4518
|
deployerAddress,
|
|
4519
4519
|
formData,
|
|
@@ -4596,7 +4596,7 @@ async function buildTransaction({
|
|
|
4596
4596
|
}
|
|
4597
4597
|
};
|
|
4598
4598
|
try {
|
|
4599
|
-
const deployCalldata =
|
|
4599
|
+
const deployCalldata = encodeFunctionData({
|
|
4600
4600
|
abi: Clanker_v3_1_abi,
|
|
4601
4601
|
functionName: "deployToken",
|
|
4602
4602
|
args: [tokenConfig]
|
|
@@ -4838,12 +4838,12 @@ import { encodeAbiParameters } from "viem";
|
|
|
4838
4838
|
function encodeFeeConfig(config2) {
|
|
4839
4839
|
if (config2.type === "static") {
|
|
4840
4840
|
return {
|
|
4841
|
-
hook:
|
|
4841
|
+
hook: CLANKER_HOOK_STATIC_FEE_V4,
|
|
4842
4842
|
poolData: encodeAbiParameters(STATIC_FEE_PARAMETERS, [config2.clankerFee, config2.pairedFee])
|
|
4843
4843
|
};
|
|
4844
4844
|
} else {
|
|
4845
4845
|
return {
|
|
4846
|
-
hook:
|
|
4846
|
+
hook: CLANKER_HOOK_DYNAMIC_FEE_V4,
|
|
4847
4847
|
poolData: encodeAbiParameters(DYNAMIC_FEE_PARAMETERS, [
|
|
4848
4848
|
config2.baseFee,
|
|
4849
4849
|
config2.maxLpFee,
|
|
@@ -4878,7 +4878,7 @@ var init_fee = __esm({
|
|
|
4878
4878
|
// src/deployment/v4.ts
|
|
4879
4879
|
import {
|
|
4880
4880
|
encodeAbiParameters as encodeAbiParameters2,
|
|
4881
|
-
encodeFunctionData as
|
|
4881
|
+
encodeFunctionData as encodeFunctionData2,
|
|
4882
4882
|
parseEventLogs as parseEventLogs2
|
|
4883
4883
|
} from "viem";
|
|
4884
4884
|
function buildTokenV4(cfg, chainId, salt) {
|
|
@@ -4897,12 +4897,12 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4897
4897
|
},
|
|
4898
4898
|
lockerConfig: {
|
|
4899
4899
|
locker: CLANKER_LOCKER_V4,
|
|
4900
|
-
rewardAdmins: cfg.
|
|
4901
|
-
rewardRecipients: cfg.
|
|
4902
|
-
rewardBps: cfg.
|
|
4903
|
-
tickLower: cfg.
|
|
4904
|
-
tickUpper: cfg.
|
|
4905
|
-
positionBps: cfg.
|
|
4900
|
+
rewardAdmins: cfg.rewardsConfig?.admins.map((a) => a.admin) || [],
|
|
4901
|
+
rewardRecipients: cfg.rewardsConfig?.admins.map((a) => a.recipient) || [],
|
|
4902
|
+
rewardBps: cfg.rewardsConfig?.admins.map((a) => a.bps) || [],
|
|
4903
|
+
tickLower: cfg.poolConfig?.positions.map((p) => p.tickLower) || [DEFAULT_TICK_LOWER],
|
|
4904
|
+
tickUpper: cfg.poolConfig?.positions.map((p) => p.tickUpper) || [DEFAULT_TICK_UPPER],
|
|
4905
|
+
positionBps: cfg.poolConfig?.positions.map((p) => p.positionBps) || [DEFAULT_POSITION_BPS],
|
|
4906
4906
|
lockerData: "0x"
|
|
4907
4907
|
},
|
|
4908
4908
|
poolConfig: {
|
|
@@ -4913,14 +4913,14 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4913
4913
|
poolData
|
|
4914
4914
|
},
|
|
4915
4915
|
mevModuleConfig: {
|
|
4916
|
-
mevModule:
|
|
4916
|
+
mevModule: CLANKER_MEV_MODULE_V4,
|
|
4917
4917
|
mevModuleData: "0x"
|
|
4918
4918
|
},
|
|
4919
4919
|
extensionConfigs: [
|
|
4920
4920
|
// vaulting extension
|
|
4921
4921
|
...cfg.vault?.percentage ? [
|
|
4922
4922
|
{
|
|
4923
|
-
extension:
|
|
4923
|
+
extension: CLANKER_VAULT_V4,
|
|
4924
4924
|
msgValue: 0n,
|
|
4925
4925
|
extensionBps: cfg.vault.percentage * 100,
|
|
4926
4926
|
extensionData: encodeAbiParameters2(VAULT_EXTENSION_PARAMETERS, [
|
|
@@ -4933,7 +4933,7 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4933
4933
|
// airdrop extension
|
|
4934
4934
|
...cfg.airdrop ? [
|
|
4935
4935
|
{
|
|
4936
|
-
extension:
|
|
4936
|
+
extension: CLANKER_AIRDROP_V4,
|
|
4937
4937
|
msgValue: 0n,
|
|
4938
4938
|
extensionBps: cfg.airdrop.percentage,
|
|
4939
4939
|
extensionData: encodeAbiParameters2(AIRDROP_EXTENSION_PARAMETERS, [
|
|
@@ -4946,7 +4946,7 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4946
4946
|
// devBuy extension
|
|
4947
4947
|
...cfg.devBuy && cfg.devBuy.ethAmount !== "0" ? [
|
|
4948
4948
|
{
|
|
4949
|
-
extension:
|
|
4949
|
+
extension: CLANKER_DEVBUY_V4,
|
|
4950
4950
|
msgValue: BigInt(parseFloat(cfg.devBuy.ethAmount) * 1e18),
|
|
4951
4951
|
extensionBps: 0,
|
|
4952
4952
|
extensionData: encodeAbiParameters2(DEVBUY_EXTENSION_PARAMETERS, [
|
|
@@ -4958,7 +4958,7 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4958
4958
|
] : []
|
|
4959
4959
|
]
|
|
4960
4960
|
};
|
|
4961
|
-
const deployCalldata =
|
|
4961
|
+
const deployCalldata = encodeFunctionData2({
|
|
4962
4962
|
abi: Clanker_v4_abi,
|
|
4963
4963
|
functionName: "deployToken",
|
|
4964
4964
|
args: [deploymentConfig]
|
|
@@ -5005,13 +5005,28 @@ async function deployTokenV4(cfg, wallet, publicClient) {
|
|
|
5005
5005
|
if (!account) {
|
|
5006
5006
|
throw new Error("Wallet account required for deployToken");
|
|
5007
5007
|
}
|
|
5008
|
-
const
|
|
5008
|
+
const balance = await publicClient.getBalance({ address: account.address });
|
|
5009
|
+
console.log("Wallet balance:", balance.toString(), "wei");
|
|
5010
|
+
console.log("Wallet balance in ETH:", Number(balance) / 1e18, "ETH");
|
|
5011
|
+
const { transaction } = "transaction" in cfg ? cfg : buildTokenV4(cfg, CHAIN_ID || 8453);
|
|
5009
5012
|
console.log("Deployment config:", JSON.stringify(transaction, bigIntReplacer, 2));
|
|
5013
|
+
const gasEstimate = await publicClient.estimateGas({
|
|
5014
|
+
account: account.address,
|
|
5015
|
+
to: transaction.to,
|
|
5016
|
+
data: transaction.data,
|
|
5017
|
+
value: transaction.value
|
|
5018
|
+
});
|
|
5019
|
+
console.log("Estimated gas required:", gasEstimate.toString());
|
|
5020
|
+
const gasWithBuffer = gasEstimate * 120n / 100n;
|
|
5021
|
+
console.log("Gas with 20% buffer:", gasWithBuffer.toString());
|
|
5010
5022
|
const tx = await wallet.sendTransaction({
|
|
5011
5023
|
...transaction,
|
|
5012
5024
|
account,
|
|
5013
5025
|
chain: publicClient.chain,
|
|
5014
|
-
value: transaction.value
|
|
5026
|
+
value: transaction.value,
|
|
5027
|
+
gas: gasWithBuffer,
|
|
5028
|
+
maxFeePerGas: 100000000n,
|
|
5029
|
+
maxPriorityFeePerGas: 100000000n
|
|
5015
5030
|
});
|
|
5016
5031
|
console.log("Transaction hash:", tx);
|
|
5017
5032
|
const receipt = await publicClient.waitForTransactionReceipt({
|
|
@@ -5203,12 +5218,18 @@ var init_index = __esm({
|
|
|
5203
5218
|
init_types();
|
|
5204
5219
|
init_validation();
|
|
5205
5220
|
init_vanityAddress();
|
|
5221
|
+
init_constants();
|
|
5206
5222
|
init_extensions();
|
|
5207
5223
|
init_builders();
|
|
5208
5224
|
init_merkleTree();
|
|
5209
5225
|
Clanker = class {
|
|
5210
5226
|
wallet;
|
|
5211
5227
|
publicClient;
|
|
5228
|
+
/**
|
|
5229
|
+
* Creates a new instance of the Clanker SDK
|
|
5230
|
+
* @param config - Optional configuration object containing wallet and public client
|
|
5231
|
+
* @throws {Error} If the provided configuration is invalid
|
|
5232
|
+
*/
|
|
5212
5233
|
constructor(config2) {
|
|
5213
5234
|
if (config2) {
|
|
5214
5235
|
const validationResult = validateConfig(config2);
|
|
@@ -5222,28 +5243,29 @@ var init_index = __esm({
|
|
|
5222
5243
|
}
|
|
5223
5244
|
}
|
|
5224
5245
|
/**
|
|
5225
|
-
*
|
|
5226
|
-
* @param cfg Token configuration for V4 deployment
|
|
5246
|
+
* Builds V4 token deployment data without actually deploying
|
|
5247
|
+
* @param cfg - Token configuration for V4 deployment
|
|
5227
5248
|
* @returns Object containing transaction data, target address, and network info
|
|
5228
5249
|
*/
|
|
5229
5250
|
buildV4(cfg) {
|
|
5230
|
-
const chainId = this.publicClient?.chain?.id ||
|
|
5251
|
+
const chainId = this.publicClient?.chain?.id || 8453;
|
|
5231
5252
|
const result = buildTokenV4(cfg, chainId);
|
|
5232
5253
|
return result;
|
|
5233
5254
|
}
|
|
5234
5255
|
/**
|
|
5235
|
-
*
|
|
5236
|
-
* @param cfg Token configuration for V4 deployment
|
|
5237
|
-
* @returns
|
|
5256
|
+
* Generates a vanity address for a V4 token deployment
|
|
5257
|
+
* @param cfg - Token configuration for V4 deployment
|
|
5258
|
+
* @returns Promise resolving to an object containing transaction data, target address, and network info with vanity address
|
|
5238
5259
|
*/
|
|
5239
5260
|
async withVanityAddress(cfg) {
|
|
5240
|
-
const chainId = this.publicClient?.chain?.id ||
|
|
5261
|
+
const chainId = this.publicClient?.chain?.id || 8453;
|
|
5241
5262
|
return withVanityAddress(cfg, chainId);
|
|
5242
5263
|
}
|
|
5243
5264
|
/**
|
|
5244
|
-
*
|
|
5245
|
-
* @param cfg Token configuration for V4 deployment or pre-built deployment data
|
|
5246
|
-
* @returns
|
|
5265
|
+
* Deploys a token using the V4 protocol
|
|
5266
|
+
* @param cfg - Token configuration for V4 deployment or pre-built deployment data
|
|
5267
|
+
* @returns Promise resolving to the address of the deployed token
|
|
5268
|
+
* @throws {Error} If wallet client or public client is not configured
|
|
5247
5269
|
*/
|
|
5248
5270
|
async deployTokenV4(cfg) {
|
|
5249
5271
|
if (!this.wallet) {
|
|
@@ -5255,9 +5277,10 @@ var init_index = __esm({
|
|
|
5255
5277
|
return deployTokenV4(cfg, this.wallet, this.publicClient);
|
|
5256
5278
|
}
|
|
5257
5279
|
/**
|
|
5258
|
-
*
|
|
5259
|
-
* @param cfg Token configuration for V3 deployment
|
|
5260
|
-
* @returns
|
|
5280
|
+
* Deploys a token using the V3 protocol
|
|
5281
|
+
* @param cfg - Token configuration for V3 deployment
|
|
5282
|
+
* @returns Promise resolving to the address of the deployed token
|
|
5283
|
+
* @throws {Error} If wallet client or public client is not configured
|
|
5261
5284
|
*/
|
|
5262
5285
|
async deployToken(cfg) {
|
|
5263
5286
|
if (!this.wallet) {
|
|
@@ -853,8 +853,6 @@ var Clanker_v3_1_abi = [
|
|
|
853
853
|
// src/constants.ts
|
|
854
854
|
import { base, baseSepolia } from "viem/chains";
|
|
855
855
|
var CLANKER_FACTORY_V3_1 = "0x2A787b2362021cC3eEa3C24C4748a6cD5B687382";
|
|
856
|
-
var CLANKER_FACTORY_V4 = "0x8608Ed9A6C2897678501FA01c47f9CC248457F94";
|
|
857
|
-
var CLANKER_LOCKER_V4 = "0x057DA2d99D57FDc9B0316Fa1eC073E05d6f4c063";
|
|
858
856
|
var WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
|
|
859
857
|
var DEGEN_ADDRESS = "0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed";
|
|
860
858
|
var NATIVE_ADDRESS = "0x20DD04c17AFD5c9a8b3f2cdacaa8Ee7907385BEF";
|
|
@@ -865,15 +863,17 @@ var CB_BTC_ADDRESS = "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf";
|
|
|
865
863
|
var A0X_ADDRESS = "0x820C5F0fB255a1D18fd0eBB0F1CCefbC4D546dA7";
|
|
866
864
|
var SUPPORTED_CHAINS = [base.id, baseSepolia.id];
|
|
867
865
|
var DEFAULT_SUPPLY = 100000000000000000000000000000n;
|
|
868
|
-
var
|
|
869
|
-
var
|
|
870
|
-
var
|
|
871
|
-
var
|
|
872
|
-
var
|
|
873
|
-
var
|
|
866
|
+
var CLANKER_FACTORY_V4 = "0xE85A59c628F7d27878ACeB4bf3b35733630083a9";
|
|
867
|
+
var CLANKER_LOCKER_V4 = "0x29d17C1A8D851d7d4cA97FAe97AcAdb398D9cCE0";
|
|
868
|
+
var CLANKER_VAULT_V4 = "0x8E845EAd15737bF71904A30BdDD3aEE76d6ADF6C";
|
|
869
|
+
var CLANKER_AIRDROP_V4 = "0x56Fa0Da89eD94822e46734e736d34Cab72dF344F";
|
|
870
|
+
var CLANKER_DEVBUY_V4 = "0x1331f0788F9c08C8F38D52c7a1152250A9dE00be";
|
|
871
|
+
var CLANKER_MEV_MODULE_V4 = "0xE143f9872A33c955F23cF442BB4B1EFB3A7402A2";
|
|
872
|
+
var CLANKER_HOOK_STATIC_FEE_V4 = "0xDd5EeaFf7BD481AD55Db083062b13a3cdf0A68CC";
|
|
873
|
+
var CLANKER_HOOK_DYNAMIC_FEE_V4 = "0x34a45c6B61876d739400Bd71228CbcbD4F53E8cC";
|
|
874
874
|
|
|
875
875
|
// src/services/buildTransaction.ts
|
|
876
|
-
import { encodeFunctionData
|
|
876
|
+
import { encodeFunctionData, getAddress, isAddress as isAddress2, stringify } from "viem";
|
|
877
877
|
|
|
878
878
|
// src/utils/unix-timestamp.ts
|
|
879
879
|
function getRelativeUnixTimestamp(unixTimestamp) {
|
|
@@ -4486,7 +4486,7 @@ async function buildTransaction({
|
|
|
4486
4486
|
}
|
|
4487
4487
|
};
|
|
4488
4488
|
try {
|
|
4489
|
-
const deployCalldata =
|
|
4489
|
+
const deployCalldata = encodeFunctionData({
|
|
4490
4490
|
abi: Clanker_v3_1_abi,
|
|
4491
4491
|
functionName: "deployToken",
|
|
4492
4492
|
args: [tokenConfig]
|
|
@@ -4689,7 +4689,7 @@ async function deployTokenV3(cfg, wallet, publicClient) {
|
|
|
4689
4689
|
// src/deployment/v4.ts
|
|
4690
4690
|
import {
|
|
4691
4691
|
encodeAbiParameters as encodeAbiParameters2,
|
|
4692
|
-
encodeFunctionData as
|
|
4692
|
+
encodeFunctionData as encodeFunctionData2,
|
|
4693
4693
|
parseEventLogs as parseEventLogs2
|
|
4694
4694
|
} from "viem";
|
|
4695
4695
|
|
|
@@ -4708,12 +4708,12 @@ var DYNAMIC_FEE_PARAMETERS = [
|
|
|
4708
4708
|
function encodeFeeConfig(config2) {
|
|
4709
4709
|
if (config2.type === "static") {
|
|
4710
4710
|
return {
|
|
4711
|
-
hook:
|
|
4711
|
+
hook: CLANKER_HOOK_STATIC_FEE_V4,
|
|
4712
4712
|
poolData: encodeAbiParameters(STATIC_FEE_PARAMETERS, [config2.clankerFee, config2.pairedFee])
|
|
4713
4713
|
};
|
|
4714
4714
|
} else {
|
|
4715
4715
|
return {
|
|
4716
|
-
hook:
|
|
4716
|
+
hook: CLANKER_HOOK_DYNAMIC_FEE_V4,
|
|
4717
4717
|
poolData: encodeAbiParameters(DYNAMIC_FEE_PARAMETERS, [
|
|
4718
4718
|
config2.baseFee,
|
|
4719
4719
|
config2.maxLpFee,
|
|
@@ -4791,12 +4791,12 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4791
4791
|
},
|
|
4792
4792
|
lockerConfig: {
|
|
4793
4793
|
locker: CLANKER_LOCKER_V4,
|
|
4794
|
-
rewardAdmins: cfg.
|
|
4795
|
-
rewardRecipients: cfg.
|
|
4796
|
-
rewardBps: cfg.
|
|
4797
|
-
tickLower: cfg.
|
|
4798
|
-
tickUpper: cfg.
|
|
4799
|
-
positionBps: cfg.
|
|
4794
|
+
rewardAdmins: cfg.rewardsConfig?.admins.map((a) => a.admin) || [],
|
|
4795
|
+
rewardRecipients: cfg.rewardsConfig?.admins.map((a) => a.recipient) || [],
|
|
4796
|
+
rewardBps: cfg.rewardsConfig?.admins.map((a) => a.bps) || [],
|
|
4797
|
+
tickLower: cfg.poolConfig?.positions.map((p) => p.tickLower) || [DEFAULT_TICK_LOWER],
|
|
4798
|
+
tickUpper: cfg.poolConfig?.positions.map((p) => p.tickUpper) || [DEFAULT_TICK_UPPER],
|
|
4799
|
+
positionBps: cfg.poolConfig?.positions.map((p) => p.positionBps) || [DEFAULT_POSITION_BPS],
|
|
4800
4800
|
lockerData: "0x"
|
|
4801
4801
|
},
|
|
4802
4802
|
poolConfig: {
|
|
@@ -4807,14 +4807,14 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4807
4807
|
poolData
|
|
4808
4808
|
},
|
|
4809
4809
|
mevModuleConfig: {
|
|
4810
|
-
mevModule:
|
|
4810
|
+
mevModule: CLANKER_MEV_MODULE_V4,
|
|
4811
4811
|
mevModuleData: "0x"
|
|
4812
4812
|
},
|
|
4813
4813
|
extensionConfigs: [
|
|
4814
4814
|
// vaulting extension
|
|
4815
4815
|
...cfg.vault?.percentage ? [
|
|
4816
4816
|
{
|
|
4817
|
-
extension:
|
|
4817
|
+
extension: CLANKER_VAULT_V4,
|
|
4818
4818
|
msgValue: 0n,
|
|
4819
4819
|
extensionBps: cfg.vault.percentage * 100,
|
|
4820
4820
|
extensionData: encodeAbiParameters2(VAULT_EXTENSION_PARAMETERS, [
|
|
@@ -4827,7 +4827,7 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4827
4827
|
// airdrop extension
|
|
4828
4828
|
...cfg.airdrop ? [
|
|
4829
4829
|
{
|
|
4830
|
-
extension:
|
|
4830
|
+
extension: CLANKER_AIRDROP_V4,
|
|
4831
4831
|
msgValue: 0n,
|
|
4832
4832
|
extensionBps: cfg.airdrop.percentage,
|
|
4833
4833
|
extensionData: encodeAbiParameters2(AIRDROP_EXTENSION_PARAMETERS, [
|
|
@@ -4840,7 +4840,7 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4840
4840
|
// devBuy extension
|
|
4841
4841
|
...cfg.devBuy && cfg.devBuy.ethAmount !== "0" ? [
|
|
4842
4842
|
{
|
|
4843
|
-
extension:
|
|
4843
|
+
extension: CLANKER_DEVBUY_V4,
|
|
4844
4844
|
msgValue: BigInt(parseFloat(cfg.devBuy.ethAmount) * 1e18),
|
|
4845
4845
|
extensionBps: 0,
|
|
4846
4846
|
extensionData: encodeAbiParameters2(DEVBUY_EXTENSION_PARAMETERS, [
|
|
@@ -4852,7 +4852,7 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4852
4852
|
] : []
|
|
4853
4853
|
]
|
|
4854
4854
|
};
|
|
4855
|
-
const deployCalldata =
|
|
4855
|
+
const deployCalldata = encodeFunctionData2({
|
|
4856
4856
|
abi: Clanker_v4_abi,
|
|
4857
4857
|
functionName: "deployToken",
|
|
4858
4858
|
args: [deploymentConfig]
|
|
@@ -4899,13 +4899,28 @@ async function deployTokenV4(cfg, wallet, publicClient) {
|
|
|
4899
4899
|
if (!account) {
|
|
4900
4900
|
throw new Error("Wallet account required for deployToken");
|
|
4901
4901
|
}
|
|
4902
|
-
const
|
|
4902
|
+
const balance = await publicClient.getBalance({ address: account.address });
|
|
4903
|
+
console.log("Wallet balance:", balance.toString(), "wei");
|
|
4904
|
+
console.log("Wallet balance in ETH:", Number(balance) / 1e18, "ETH");
|
|
4905
|
+
const { transaction } = "transaction" in cfg ? cfg : buildTokenV4(cfg, CHAIN_ID || 8453);
|
|
4903
4906
|
console.log("Deployment config:", JSON.stringify(transaction, bigIntReplacer, 2));
|
|
4907
|
+
const gasEstimate = await publicClient.estimateGas({
|
|
4908
|
+
account: account.address,
|
|
4909
|
+
to: transaction.to,
|
|
4910
|
+
data: transaction.data,
|
|
4911
|
+
value: transaction.value
|
|
4912
|
+
});
|
|
4913
|
+
console.log("Estimated gas required:", gasEstimate.toString());
|
|
4914
|
+
const gasWithBuffer = gasEstimate * 120n / 100n;
|
|
4915
|
+
console.log("Gas with 20% buffer:", gasWithBuffer.toString());
|
|
4904
4916
|
const tx = await wallet.sendTransaction({
|
|
4905
4917
|
...transaction,
|
|
4906
4918
|
account,
|
|
4907
4919
|
chain: publicClient.chain,
|
|
4908
|
-
value: transaction.value
|
|
4920
|
+
value: transaction.value,
|
|
4921
|
+
gas: gasWithBuffer,
|
|
4922
|
+
maxFeePerGas: 100000000n,
|
|
4923
|
+
maxPriorityFeePerGas: 100000000n
|
|
4909
4924
|
});
|
|
4910
4925
|
console.log("Transaction hash:", tx);
|
|
4911
4926
|
const receipt = await publicClient.waitForTransactionReceipt({
|
|
@@ -4943,6 +4958,11 @@ import { encodeAbiParameters as encodeAbiParameters6 } from "viem";
|
|
|
4943
4958
|
var Clanker = class {
|
|
4944
4959
|
wallet;
|
|
4945
4960
|
publicClient;
|
|
4961
|
+
/**
|
|
4962
|
+
* Creates a new instance of the Clanker SDK
|
|
4963
|
+
* @param config - Optional configuration object containing wallet and public client
|
|
4964
|
+
* @throws {Error} If the provided configuration is invalid
|
|
4965
|
+
*/
|
|
4946
4966
|
constructor(config2) {
|
|
4947
4967
|
if (config2) {
|
|
4948
4968
|
const validationResult = validateConfig(config2);
|
|
@@ -4956,28 +4976,29 @@ var Clanker = class {
|
|
|
4956
4976
|
}
|
|
4957
4977
|
}
|
|
4958
4978
|
/**
|
|
4959
|
-
*
|
|
4960
|
-
* @param cfg Token configuration for V4 deployment
|
|
4979
|
+
* Builds V4 token deployment data without actually deploying
|
|
4980
|
+
* @param cfg - Token configuration for V4 deployment
|
|
4961
4981
|
* @returns Object containing transaction data, target address, and network info
|
|
4962
4982
|
*/
|
|
4963
4983
|
buildV4(cfg) {
|
|
4964
|
-
const chainId = this.publicClient?.chain?.id ||
|
|
4984
|
+
const chainId = this.publicClient?.chain?.id || 8453;
|
|
4965
4985
|
const result = buildTokenV4(cfg, chainId);
|
|
4966
4986
|
return result;
|
|
4967
4987
|
}
|
|
4968
4988
|
/**
|
|
4969
|
-
*
|
|
4970
|
-
* @param cfg Token configuration for V4 deployment
|
|
4971
|
-
* @returns
|
|
4989
|
+
* Generates a vanity address for a V4 token deployment
|
|
4990
|
+
* @param cfg - Token configuration for V4 deployment
|
|
4991
|
+
* @returns Promise resolving to an object containing transaction data, target address, and network info with vanity address
|
|
4972
4992
|
*/
|
|
4973
4993
|
async withVanityAddress(cfg) {
|
|
4974
|
-
const chainId = this.publicClient?.chain?.id ||
|
|
4994
|
+
const chainId = this.publicClient?.chain?.id || 8453;
|
|
4975
4995
|
return withVanityAddress(cfg, chainId);
|
|
4976
4996
|
}
|
|
4977
4997
|
/**
|
|
4978
|
-
*
|
|
4979
|
-
* @param cfg Token configuration for V4 deployment or pre-built deployment data
|
|
4980
|
-
* @returns
|
|
4998
|
+
* Deploys a token using the V4 protocol
|
|
4999
|
+
* @param cfg - Token configuration for V4 deployment or pre-built deployment data
|
|
5000
|
+
* @returns Promise resolving to the address of the deployed token
|
|
5001
|
+
* @throws {Error} If wallet client or public client is not configured
|
|
4981
5002
|
*/
|
|
4982
5003
|
async deployTokenV4(cfg) {
|
|
4983
5004
|
if (!this.wallet) {
|
|
@@ -4989,9 +5010,10 @@ var Clanker = class {
|
|
|
4989
5010
|
return deployTokenV4(cfg, this.wallet, this.publicClient);
|
|
4990
5011
|
}
|
|
4991
5012
|
/**
|
|
4992
|
-
*
|
|
4993
|
-
* @param cfg Token configuration for V3 deployment
|
|
4994
|
-
* @returns
|
|
5013
|
+
* Deploys a token using the V3 protocol
|
|
5014
|
+
* @param cfg - Token configuration for V3 deployment
|
|
5015
|
+
* @returns Promise resolving to the address of the deployed token
|
|
5016
|
+
* @throws {Error} If wallet client or public client is not configured
|
|
4995
5017
|
*/
|
|
4996
5018
|
async deployToken(cfg) {
|
|
4997
5019
|
if (!this.wallet) {
|