clanker-sdk 4.2.4 → 4.2.5

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.
@@ -18015,6 +18015,8 @@ declare const clankerTokenV4: z.ZodObject<{
18015
18015
  image: z.ZodDefault<z.ZodString>;
18016
18016
  /** Id of the chain that the token will be deployed to. Defaults to base (8453). */
18017
18017
  chainId: z.ZodDefault<z.ZodLiteral<1 | 143 | 8453 | 10143 | 2741 | 84532 | 42161 | 130>>;
18018
+ /** Custom salt for CREATE2 deployment. If provided, this will be used instead of vanity address generation. Takes precedence over vanity. */
18019
+ salt: z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>;
18018
18020
  /** Admin for the token. They will be able to change fields like image, metadata, etc. */
18019
18021
  tokenAdmin: z.ZodCustom<`0x${string}`, `0x${string}`>;
18020
18022
  /** Metadata for the token. */
package/dist/cli/cli.js CHANGED
@@ -9,12 +9,12 @@ var __export = (target, all) => {
9
9
  __defProp(target, name, { get: all[name], enumerable: true });
10
10
  };
11
11
 
12
- // node_modules/.pnpm/tsup@8.4.0_typescript@5.8.3/node_modules/tsup/assets/esm_shims.js
12
+ // node_modules/tsup/assets/esm_shims.js
13
13
  import { fileURLToPath } from "url";
14
14
  import path from "path";
15
15
  var getFilename, getDirname, __dirname;
16
16
  var init_esm_shims = __esm({
17
- "node_modules/.pnpm/tsup@8.4.0_typescript@5.8.3/node_modules/tsup/assets/esm_shims.js"() {
17
+ "node_modules/tsup/assets/esm_shims.js"() {
18
18
  "use strict";
19
19
  getFilename = () => fileURLToPath(import.meta.url);
20
20
  getDirname = () => path.dirname(getFilename());
@@ -6282,7 +6282,12 @@ var init_clankers = __esm({
6282
6282
  });
6283
6283
 
6284
6284
  // src/services/vanityAddress.ts
6285
- import { encodeDeployData, keccak256 } from "viem";
6285
+ import {
6286
+ encodeAbiParameters,
6287
+ encodeDeployData,
6288
+ getContractAddress,
6289
+ keccak256
6290
+ } from "viem";
6286
6291
  import { abstract as abstract3, monadTestnet as monadTestnet3 } from "viem/chains";
6287
6292
  var findVanityAddress;
6288
6293
  var init_vanityAddress = __esm({
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // node_modules/.pnpm/tsup@8.4.0_typescript@5.8.3/node_modules/tsup/assets/esm_shims.js
3
+ // node_modules/tsup/assets/esm_shims.js
4
4
  import { fileURLToPath } from "url";
5
5
  import path from "path";
6
6
  var getFilename = () => fileURLToPath(import.meta.url);
@@ -3137,7 +3137,12 @@ var WETH_ADDRESSES = {
3137
3137
  var DEFAULT_SUPPLY = 100000000000000000000000000000n;
3138
3138
 
3139
3139
  // src/services/vanityAddress.ts
3140
- import { encodeDeployData, keccak256 } from "viem";
3140
+ import {
3141
+ encodeAbiParameters,
3142
+ encodeDeployData,
3143
+ getContractAddress,
3144
+ keccak256
3145
+ } from "viem";
3141
3146
  import { abstract as abstract3, monadTestnet as monadTestnet3 } from "viem/chains";
3142
3147
 
3143
3148
  // src/utils/clankers.ts
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { C as ClankerTokenV3 } from './clankerTokenV3-BqHTF9QY.js';
2
- import { a as Chain, C as ClankerTokenV4, b as ClankerDeployment } from './clankerTokenV4-Btn0ZN4v.js';
3
- export { d as CLANKERS, g as Chains, h as ClankerDeployments, f as Clankers, R as RelatedV3_1, c as RelatedV4, T as Type, i as clankerConfigFor } from './clankerTokenV4-Btn0ZN4v.js';
4
- import { ContractConstructorArgs } from 'viem';
2
+ import { a as Chain, C as ClankerTokenV4, b as ClankerDeployment } from './clankerTokenV4-xiAq6G4R.js';
3
+ export { d as CLANKERS, g as Chains, h as ClankerDeployments, f as Clankers, R as RelatedV3_1, c as RelatedV4, T as Type, i as clankerConfigFor } from './clankerTokenV4-xiAq6G4R.js';
4
+ import { ContractConstructorArgs, Hex } from 'viem';
5
5
  import { C as ClankerToken_v3_1_abi, a as ClankerToken_v4_abi } from './ClankerToken-Dra5lppJ.js';
6
6
  import { StandardMerkleTree } from '@openzeppelin/merkle-tree';
7
7
  import 'zod/v4';
@@ -43,6 +43,19 @@ declare const findVanityAddressV4: (args: ContractConstructorArgs<typeof Clanker
43
43
  salt: `0x${string}`;
44
44
  token: `0x${string}`;
45
45
  }>;
46
+ /**
47
+ * Predict the token address for a V4 deployment with a custom salt using CREATE2.
48
+ *
49
+ * The Clanker contract uses: keccak256(abi.encode(tokenAdmin, salt))
50
+ * as the actual CREATE2 salt.
51
+ *
52
+ * @param args Constructor arguments for the token
53
+ * @param config Clanker deployment configuration
54
+ * @param salt Custom salt for CREATE2 deployment
55
+ * @param tokenAdmin Token admin address (used to derive the actual CREATE2 salt)
56
+ * @returns The predicted token address
57
+ */
58
+ declare const predictTokenAddressV4: (args: ContractConstructorArgs<typeof ClankerToken_v4_abi>, config: ClankerDeployment, salt: Hex, tokenAdmin: `0x${string}`) => `0x${string}`;
46
59
 
47
60
  /**
48
61
  * Calculate starting tick and spacing for a token pooled against ETH.
@@ -82,4 +95,4 @@ declare function createMerkleTree(entries: AirdropEntry[]): {
82
95
  declare function getMerkleProof(tree: StandardMerkleTree<[string, string]>, entries: [string, string][], account: `0x${string}`, amount: number): `0x${string}`[];
83
96
  declare function encodeAirdropData(merkleRoot: `0x${string}`, lockupDuration: number, vestingDuration: number): `0x${string}`;
84
97
 
85
- export { A0X_ADDRESS, ANON_ADDRESS, type AirdropEntry, CB_BTC_ADDRESS, CLANKER_ADDRESS, Chain, ClankerDeployment, ClankerTokenV4, DEFAULT_SUPPLY, DEGEN_ADDRESS, FEE_CONFIGS, FeeConfigs, HIGHER_ADDRESS, NATIVE_ADDRESS, POOL_POSITIONS, PoolPositions, WETH_ADDRESSES, createMerkleTree, encodeAirdropData, findVanityAddress, findVanityAddressV4, getMerkleProof, getTickFromMarketCap, getTickFromMarketCapUSDC };
98
+ export { A0X_ADDRESS, ANON_ADDRESS, type AirdropEntry, CB_BTC_ADDRESS, CLANKER_ADDRESS, Chain, ClankerDeployment, ClankerTokenV4, DEFAULT_SUPPLY, DEGEN_ADDRESS, FEE_CONFIGS, FeeConfigs, HIGHER_ADDRESS, NATIVE_ADDRESS, POOL_POSITIONS, PoolPositions, WETH_ADDRESSES, createMerkleTree, encodeAirdropData, findVanityAddress, findVanityAddressV4, getMerkleProof, getTickFromMarketCap, getTickFromMarketCapUSDC, predictTokenAddressV4 };
package/dist/index.js CHANGED
@@ -206,7 +206,12 @@ var FEE_CONFIGS = {
206
206
  };
207
207
 
208
208
  // src/services/vanityAddress.ts
209
- import { encodeDeployData, keccak256 } from "viem";
209
+ import {
210
+ encodeAbiParameters,
211
+ encodeDeployData,
212
+ getContractAddress,
213
+ keccak256
214
+ } from "viem";
210
215
  import { abstract as abstract3, monadTestnet as monadTestnet3 } from "viem/chains";
211
216
 
212
217
  // src/abi/v3.1/ClankerToken.ts
@@ -5759,6 +5764,30 @@ var findVanityAddressV4 = async (args, admin, suffix = "0x4b07", config) => {
5759
5764
  const { address, salt } = await response.json();
5760
5765
  return { token: address, salt };
5761
5766
  };
5767
+ var predictTokenAddressV4 = (args, config, salt, tokenAdmin) => {
5768
+ const deployData = encodeDeployData({
5769
+ abi: config.token.abi,
5770
+ bytecode: config.token.bytecode,
5771
+ args
5772
+ });
5773
+ const actualSalt = keccak256(
5774
+ encodeAbiParameters(
5775
+ [
5776
+ { type: "address", name: "tokenAdmin" },
5777
+ { type: "bytes32", name: "salt" }
5778
+ ],
5779
+ [tokenAdmin, salt]
5780
+ )
5781
+ );
5782
+ const predictedAddress = getContractAddress({
5783
+ from: config.address,
5784
+ // deployer (Clanker contract)
5785
+ salt: actualSalt,
5786
+ bytecode: deployData,
5787
+ opcode: "CREATE2"
5788
+ });
5789
+ return predictedAddress;
5790
+ };
5762
5791
 
5763
5792
  // src/utils/market-cap.ts
5764
5793
  var getTickFromMarketCap = (marketCap) => {
@@ -5781,7 +5810,7 @@ function getTickFromMarketCapUSDC(marketCapUSDC, tickSpacing = 200) {
5781
5810
 
5782
5811
  // src/utils/merkleTree.ts
5783
5812
  import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
5784
- import { encodeAbiParameters } from "viem";
5813
+ import { encodeAbiParameters as encodeAbiParameters2 } from "viem";
5785
5814
  var TOKEN_DECIMALS = 18n;
5786
5815
  function toTokenDecimals(amount) {
5787
5816
  return BigInt(amount) * 10n ** TOKEN_DECIMALS;
@@ -5806,7 +5835,7 @@ function getMerkleProof(tree, entries, account, amount) {
5806
5835
  return proof.map((p) => p);
5807
5836
  }
5808
5837
  function encodeAirdropData(merkleRoot, lockupDuration, vestingDuration) {
5809
- return encodeAbiParameters(
5838
+ return encodeAbiParameters2(
5810
5839
  [{ type: "bytes32" }, { type: "uint256" }, { type: "uint256" }],
5811
5840
  [merkleRoot, BigInt(lockupDuration), BigInt(vestingDuration)]
5812
5841
  );
@@ -5835,5 +5864,6 @@ export {
5835
5864
  findVanityAddressV4,
5836
5865
  getMerkleProof,
5837
5866
  getTickFromMarketCap,
5838
- getTickFromMarketCapUSDC
5867
+ getTickFromMarketCapUSDC,
5868
+ predictTokenAddressV4
5839
5869
  };
package/dist/v3/index.js CHANGED
@@ -3119,7 +3119,12 @@ var WETH_ADDRESSES = {
3119
3119
  var DEFAULT_SUPPLY = 100000000000000000000000000000n;
3120
3120
 
3121
3121
  // src/services/vanityAddress.ts
3122
- import { encodeDeployData, keccak256 } from "viem";
3122
+ import {
3123
+ encodeAbiParameters,
3124
+ encodeDeployData,
3125
+ getContractAddress,
3126
+ keccak256
3127
+ } from "viem";
3123
3128
  import { abstract as abstract3, monadTestnet as monadTestnet3 } from "viem/chains";
3124
3129
 
3125
3130
  // src/utils/clankers.ts
@@ -1,7 +1,7 @@
1
1
  import { C as ClankerTransactionConfig, f as ClankerAirdrop_v4_abi, c as ClankerResult, g as Clanker_PresaleEthToCreator_v4_1_abi } from '../../write-clanker-contracts-B4LSHPv2.js';
2
2
  import { MerkleTree } from '@openzeppelin/merkle-tree/dist/merkletree.js';
3
3
  import * as z from 'zod/v4';
4
- import { a as Chain, C as ClankerTokenV4 } from '../../clankerTokenV4-Btn0ZN4v.js';
4
+ import { a as Chain, C as ClankerTokenV4 } from '../../clankerTokenV4-xiAq6G4R.js';
5
5
  import { Clanker } from '../index.js';
6
6
  import { C as ClankerError } from '../../errors-5Gv28Tkr.js';
7
7
  import 'viem';
@@ -6861,7 +6861,7 @@ var Clanker_PresaleEthToCreator_v4_1_abi = [
6861
6861
 
6862
6862
  // src/config/clankerTokenV4.ts
6863
6863
  import {
6864
- encodeAbiParameters,
6864
+ encodeAbiParameters as encodeAbiParameters2,
6865
6865
  isAddressEqual as isAddressEqual2,
6866
6866
  stringify as stringify2,
6867
6867
  zeroAddress,
@@ -7069,7 +7069,12 @@ var POOL_POSITIONS = {
7069
7069
  };
7070
7070
 
7071
7071
  // src/services/vanityAddress.ts
7072
- import { encodeDeployData, keccak256 } from "viem";
7072
+ import {
7073
+ encodeAbiParameters,
7074
+ encodeDeployData,
7075
+ getContractAddress,
7076
+ keccak256
7077
+ } from "viem";
7073
7078
  import { abstract as abstract3, monadTestnet as monadTestnet3 } from "viem/chains";
7074
7079
  var findVanityAddressV4 = async (args, admin, suffix = "0x4b07", config) => {
7075
7080
  const data = encodeDeployData({
@@ -7084,6 +7089,30 @@ var findVanityAddressV4 = async (args, admin, suffix = "0x4b07", config) => {
7084
7089
  const { address, salt } = await response.json();
7085
7090
  return { token: address, salt };
7086
7091
  };
7092
+ var predictTokenAddressV4 = (args, config, salt, tokenAdmin) => {
7093
+ const deployData = encodeDeployData({
7094
+ abi: config.token.abi,
7095
+ bytecode: config.token.bytecode,
7096
+ args
7097
+ });
7098
+ const actualSalt = keccak256(
7099
+ encodeAbiParameters(
7100
+ [
7101
+ { type: "address", name: "tokenAdmin" },
7102
+ { type: "bytes32", name: "salt" }
7103
+ ],
7104
+ [tokenAdmin, salt]
7105
+ )
7106
+ );
7107
+ const predictedAddress = getContractAddress({
7108
+ from: config.address,
7109
+ // deployer (Clanker contract)
7110
+ salt: actualSalt,
7111
+ bytecode: deployData,
7112
+ opcode: "CREATE2"
7113
+ });
7114
+ return predictedAddress;
7115
+ };
7087
7116
 
7088
7117
  // src/config/clankerTokenV4.ts
7089
7118
  var NULL_DEVBUY_POOL_CONFIG = {
@@ -7108,6 +7137,8 @@ var clankerTokenV4 = z3.strictObject({
7108
7137
  image: z3.string().default(""),
7109
7138
  /** Id of the chain that the token will be deployed to. Defaults to base (8453). */
7110
7139
  chainId: z3.literal(Chains).default(8453),
7140
+ /** Custom salt for CREATE2 deployment. If provided, this will be used instead of vanity address generation. Takes precedence over vanity. */
7141
+ salt: hexSchema.optional(),
7111
7142
  /** Admin for the token. They will be able to change fields like image, metadata, etc. */
7112
7143
  tokenAdmin: addressSchema.refine((v) => !isAddressEqual2(v, zeroAddress), {
7113
7144
  error: "Admin cannot be zero address"
@@ -7311,23 +7342,24 @@ var clankerTokenV4Converter = async (config) => {
7311
7342
  if (cfg.presale && !clankerConfig?.related?.presale) {
7312
7343
  throw new Error(`Presales are not available on chain ${cfg.chainId}`);
7313
7344
  }
7314
- const { salt, token: expectedAddress } = cfg.vanity ? await findVanityAddressV4(
7315
- [
7316
- cfg.name,
7317
- cfg.symbol,
7318
- DEFAULT_SUPPLY,
7319
- cfg.tokenAdmin,
7320
- cfg.image,
7321
- metadata,
7322
- socialContext,
7323
- BigInt(cfg.chainId)
7324
- ],
7345
+ const tokenArgs = [
7346
+ cfg.name,
7347
+ cfg.symbol,
7348
+ DEFAULT_SUPPLY,
7325
7349
  cfg.tokenAdmin,
7326
- "0x4b07",
7327
- clankerConfig
7328
- ) : {
7350
+ cfg.image,
7351
+ metadata,
7352
+ socialContext,
7353
+ BigInt(cfg.chainId)
7354
+ ];
7355
+ const { salt, token: expectedAddress } = cfg.salt ? {
7356
+ // Use custom salt if provided, predict the address using CREATE2
7357
+ salt: cfg.salt,
7358
+ token: predictTokenAddressV4(tokenArgs, clankerConfig, cfg.salt, cfg.tokenAdmin)
7359
+ } : cfg.vanity ? await findVanityAddressV4(tokenArgs, cfg.tokenAdmin, "0x4b07", clankerConfig) : {
7360
+ // Default case: use zeroHash and predict address
7329
7361
  salt: zeroHash,
7330
- token: void 0
7362
+ token: predictTokenAddressV4(tokenArgs, clankerConfig, zeroHash, cfg.tokenAdmin)
7331
7363
  };
7332
7364
  const airdropAmount = BigInt(cfg.airdrop?.amount || 0) * BigInt(1e18);
7333
7365
  const bpsAirdropped = airdropAmount * 10000n / DEFAULT_SUPPLY + (airdropAmount * 10000n % DEFAULT_SUPPLY ? 1n : 0n);
@@ -7363,7 +7395,7 @@ var clankerTokenV4Converter = async (config) => {
7363
7395
  },
7364
7396
  lockerConfig: {
7365
7397
  locker: cfg.locker.locker === "Locker" ? clankerConfig.related.locker : cfg.locker.locker,
7366
- lockerData: encodeAbiParameters(ClankerLpLocker_Instantiation_v4_abi, [
7398
+ lockerData: encodeAbiParameters2(ClankerLpLocker_Instantiation_v4_abi, [
7367
7399
  {
7368
7400
  feePreference: cfg.rewards.recipients.map(({ token }) => FeeInToInt[token])
7369
7401
  }
@@ -7384,7 +7416,7 @@ var clankerTokenV4Converter = async (config) => {
7384
7416
  },
7385
7417
  mevModuleConfig: {
7386
7418
  mevModule: clankerConfig.related?.mevModuleV2 || clankerConfig.related?.mevModule,
7387
- mevModuleData: clankerConfig.related?.mevModuleV2 ? encodeAbiParameters(Clanker_MevSniperAuction_InitData_v4_1_abi, [
7419
+ mevModuleData: clankerConfig.related?.mevModuleV2 ? encodeAbiParameters2(Clanker_MevSniperAuction_InitData_v4_1_abi, [
7388
7420
  {
7389
7421
  startingFee: cfg.sniperFees.startingFee,
7390
7422
  endingFee: cfg.sniperFees.endingFee,
@@ -7399,7 +7431,7 @@ var clankerTokenV4Converter = async (config) => {
7399
7431
  extension: clankerConfig.related.vault,
7400
7432
  msgValue: 0n,
7401
7433
  extensionBps: cfg.vault.percentage * 100,
7402
- extensionData: encodeAbiParameters(ClankerVault_Instantiation_v4_abi, [
7434
+ extensionData: encodeAbiParameters2(ClankerVault_Instantiation_v4_abi, [
7403
7435
  cfg.vault.recipient ?? cfg.tokenAdmin,
7404
7436
  BigInt(cfg.vault.lockupDuration),
7405
7437
  BigInt(cfg.vault.vestingDuration)
@@ -7412,7 +7444,7 @@ var clankerTokenV4Converter = async (config) => {
7412
7444
  extension: clankerConfig.related.airdrop,
7413
7445
  msgValue: 0n,
7414
7446
  extensionBps: Number(bpsAirdropped),
7415
- extensionData: encodeAbiParameters(ClankerAirdropV2_Instantiation_v4_abi, [
7447
+ extensionData: encodeAbiParameters2(ClankerAirdropV2_Instantiation_v4_abi, [
7416
7448
  cfg.airdrop.admin || cfg.tokenAdmin,
7417
7449
  cfg.airdrop.merkleRoot,
7418
7450
  BigInt(cfg.airdrop.lockupDuration),
@@ -7426,7 +7458,7 @@ var clankerTokenV4Converter = async (config) => {
7426
7458
  extension: clankerConfig.related.devbuy,
7427
7459
  msgValue: BigInt(cfg.devBuy.ethAmount * 1e18),
7428
7460
  extensionBps: 0,
7429
- extensionData: encodeAbiParameters(ClankerUniV4EthDevBuy_Instantiation_v4_abi, [
7461
+ extensionData: encodeAbiParameters2(ClankerUniV4EthDevBuy_Instantiation_v4_abi, [
7430
7462
  cfg.devBuy.poolKey,
7431
7463
  BigInt(cfg.devBuy.amountOutMin * 1e18),
7432
7464
  cfg.tokenAdmin
@@ -7454,7 +7486,7 @@ var clankerTokenV4Converter = async (config) => {
7454
7486
  function encodeFeeConfig(tokenConfig, clankerConfig) {
7455
7487
  const config = tokenConfig.fees;
7456
7488
  if (config.type === "static") {
7457
- const feeData = encodeAbiParameters(ClankerHook_StaticFee_Instantiation_v4_abi, [
7489
+ const feeData = encodeAbiParameters2(ClankerHook_StaticFee_Instantiation_v4_abi, [
7458
7490
  config.clankerFee * 100,
7459
7491
  // uniBps
7460
7492
  config.pairedFee * 100
@@ -7463,7 +7495,7 @@ function encodeFeeConfig(tokenConfig, clankerConfig) {
7463
7495
  if (clankerConfig.related.feeStaticHookV2) {
7464
7496
  return {
7465
7497
  hook: clankerConfig.related.feeStaticHookV2,
7466
- poolData: encodeAbiParameters(Clanker_PoolInitializationData_v4_1_abi, [
7498
+ poolData: encodeAbiParameters2(Clanker_PoolInitializationData_v4_1_abi, [
7467
7499
  {
7468
7500
  extension: tokenConfig.poolExtension.address,
7469
7501
  extensionData: tokenConfig.poolExtension.initData,
@@ -7478,7 +7510,7 @@ function encodeFeeConfig(tokenConfig, clankerConfig) {
7478
7510
  };
7479
7511
  }
7480
7512
  if (config.type === "dynamic") {
7481
- const feeData = encodeAbiParameters(ClankerHook_DynamicFee_Instantiation_v4_abi, [
7513
+ const feeData = encodeAbiParameters2(ClankerHook_DynamicFee_Instantiation_v4_abi, [
7482
7514
  config.baseFee * 100,
7483
7515
  // uniBps
7484
7516
  config.maxFee * 100,
@@ -7492,7 +7524,7 @@ function encodeFeeConfig(tokenConfig, clankerConfig) {
7492
7524
  if (clankerConfig.related.feeDynamicHookV2) {
7493
7525
  return {
7494
7526
  hook: clankerConfig.related.feeDynamicHookV2,
7495
- poolData: encodeAbiParameters(Clanker_PoolInitializationData_v4_1_abi, [
7527
+ poolData: encodeAbiParameters2(Clanker_PoolInitializationData_v4_1_abi, [
7496
7528
  {
7497
7529
  extension: tokenConfig.poolExtension.address,
7498
7530
  extensionData: tokenConfig.poolExtension.initData,
@@ -2,8 +2,8 @@ import { C as ClankerTransactionConfig, d as ClankerFeeLocker_abi, b as ClankerF
2
2
  import * as viem from 'viem';
3
3
  import { WalletClient, Transport, Chain, Account, PublicClient } from 'viem';
4
4
  import { a as ClankerToken_v4_abi } from '../ClankerToken-Dra5lppJ.js';
5
- import { C as ClankerTokenV4 } from '../clankerTokenV4-Btn0ZN4v.js';
6
- export { e as encodeFeeConfig } from '../clankerTokenV4-Btn0ZN4v.js';
5
+ import { C as ClankerTokenV4 } from '../clankerTokenV4-xiAq6G4R.js';
6
+ export { e as encodeFeeConfig } from '../clankerTokenV4-xiAq6G4R.js';
7
7
  import { C as ClankerError } from '../errors-5Gv28Tkr.js';
8
8
  import 'zod/v4';
9
9
 
package/dist/v4/index.js CHANGED
@@ -1401,7 +1401,7 @@ var ClankerVault_Instantiation_v4_abi = [
1401
1401
 
1402
1402
  // src/config/clankerTokenV4.ts
1403
1403
  import {
1404
- encodeAbiParameters,
1404
+ encodeAbiParameters as encodeAbiParameters2,
1405
1405
  isAddressEqual,
1406
1406
  stringify,
1407
1407
  zeroAddress,
@@ -2060,7 +2060,12 @@ var POOL_POSITIONS = {
2060
2060
  };
2061
2061
 
2062
2062
  // src/services/vanityAddress.ts
2063
- import { encodeDeployData, keccak256 } from "viem";
2063
+ import {
2064
+ encodeAbiParameters,
2065
+ encodeDeployData,
2066
+ getContractAddress,
2067
+ keccak256
2068
+ } from "viem";
2064
2069
  import { abstract as abstract3, monadTestnet as monadTestnet3 } from "viem/chains";
2065
2070
 
2066
2071
  // src/abi/v3.1/ClankerToken.ts
@@ -6607,6 +6612,30 @@ var findVanityAddressV4 = async (args, admin, suffix = "0x4b07", config) => {
6607
6612
  const { address, salt } = await response.json();
6608
6613
  return { token: address, salt };
6609
6614
  };
6615
+ var predictTokenAddressV4 = (args, config, salt, tokenAdmin) => {
6616
+ const deployData = encodeDeployData({
6617
+ abi: config.token.abi,
6618
+ bytecode: config.token.bytecode,
6619
+ args
6620
+ });
6621
+ const actualSalt = keccak256(
6622
+ encodeAbiParameters(
6623
+ [
6624
+ { type: "address", name: "tokenAdmin" },
6625
+ { type: "bytes32", name: "salt" }
6626
+ ],
6627
+ [tokenAdmin, salt]
6628
+ )
6629
+ );
6630
+ const predictedAddress = getContractAddress({
6631
+ from: config.address,
6632
+ // deployer (Clanker contract)
6633
+ salt: actualSalt,
6634
+ bytecode: deployData,
6635
+ opcode: "CREATE2"
6636
+ });
6637
+ return predictedAddress;
6638
+ };
6610
6639
 
6611
6640
  // src/utils/zod-onchain.ts
6612
6641
  import { getAddress, isAddress, isHex } from "viem";
@@ -6663,6 +6692,8 @@ var clankerTokenV4 = z2.strictObject({
6663
6692
  image: z2.string().default(""),
6664
6693
  /** Id of the chain that the token will be deployed to. Defaults to base (8453). */
6665
6694
  chainId: z2.literal(Chains).default(8453),
6695
+ /** Custom salt for CREATE2 deployment. If provided, this will be used instead of vanity address generation. Takes precedence over vanity. */
6696
+ salt: hexSchema.optional(),
6666
6697
  /** Admin for the token. They will be able to change fields like image, metadata, etc. */
6667
6698
  tokenAdmin: addressSchema.refine((v) => !isAddressEqual(v, zeroAddress), {
6668
6699
  error: "Admin cannot be zero address"
@@ -6866,23 +6897,24 @@ var clankerTokenV4Converter = async (config) => {
6866
6897
  if (cfg.presale && !clankerConfig?.related?.presale) {
6867
6898
  throw new Error(`Presales are not available on chain ${cfg.chainId}`);
6868
6899
  }
6869
- const { salt, token: expectedAddress } = cfg.vanity ? await findVanityAddressV4(
6870
- [
6871
- cfg.name,
6872
- cfg.symbol,
6873
- DEFAULT_SUPPLY,
6874
- cfg.tokenAdmin,
6875
- cfg.image,
6876
- metadata,
6877
- socialContext,
6878
- BigInt(cfg.chainId)
6879
- ],
6900
+ const tokenArgs = [
6901
+ cfg.name,
6902
+ cfg.symbol,
6903
+ DEFAULT_SUPPLY,
6880
6904
  cfg.tokenAdmin,
6881
- "0x4b07",
6882
- clankerConfig
6883
- ) : {
6905
+ cfg.image,
6906
+ metadata,
6907
+ socialContext,
6908
+ BigInt(cfg.chainId)
6909
+ ];
6910
+ const { salt, token: expectedAddress } = cfg.salt ? {
6911
+ // Use custom salt if provided, predict the address using CREATE2
6912
+ salt: cfg.salt,
6913
+ token: predictTokenAddressV4(tokenArgs, clankerConfig, cfg.salt, cfg.tokenAdmin)
6914
+ } : cfg.vanity ? await findVanityAddressV4(tokenArgs, cfg.tokenAdmin, "0x4b07", clankerConfig) : {
6915
+ // Default case: use zeroHash and predict address
6884
6916
  salt: zeroHash,
6885
- token: void 0
6917
+ token: predictTokenAddressV4(tokenArgs, clankerConfig, zeroHash, cfg.tokenAdmin)
6886
6918
  };
6887
6919
  const airdropAmount = BigInt(cfg.airdrop?.amount || 0) * BigInt(1e18);
6888
6920
  const bpsAirdropped = airdropAmount * 10000n / DEFAULT_SUPPLY + (airdropAmount * 10000n % DEFAULT_SUPPLY ? 1n : 0n);
@@ -6918,7 +6950,7 @@ var clankerTokenV4Converter = async (config) => {
6918
6950
  },
6919
6951
  lockerConfig: {
6920
6952
  locker: cfg.locker.locker === "Locker" ? clankerConfig.related.locker : cfg.locker.locker,
6921
- lockerData: encodeAbiParameters(ClankerLpLocker_Instantiation_v4_abi, [
6953
+ lockerData: encodeAbiParameters2(ClankerLpLocker_Instantiation_v4_abi, [
6922
6954
  {
6923
6955
  feePreference: cfg.rewards.recipients.map(({ token }) => FeeInToInt[token])
6924
6956
  }
@@ -6939,7 +6971,7 @@ var clankerTokenV4Converter = async (config) => {
6939
6971
  },
6940
6972
  mevModuleConfig: {
6941
6973
  mevModule: clankerConfig.related?.mevModuleV2 || clankerConfig.related?.mevModule,
6942
- mevModuleData: clankerConfig.related?.mevModuleV2 ? encodeAbiParameters(Clanker_MevSniperAuction_InitData_v4_1_abi, [
6974
+ mevModuleData: clankerConfig.related?.mevModuleV2 ? encodeAbiParameters2(Clanker_MevSniperAuction_InitData_v4_1_abi, [
6943
6975
  {
6944
6976
  startingFee: cfg.sniperFees.startingFee,
6945
6977
  endingFee: cfg.sniperFees.endingFee,
@@ -6954,7 +6986,7 @@ var clankerTokenV4Converter = async (config) => {
6954
6986
  extension: clankerConfig.related.vault,
6955
6987
  msgValue: 0n,
6956
6988
  extensionBps: cfg.vault.percentage * 100,
6957
- extensionData: encodeAbiParameters(ClankerVault_Instantiation_v4_abi, [
6989
+ extensionData: encodeAbiParameters2(ClankerVault_Instantiation_v4_abi, [
6958
6990
  cfg.vault.recipient ?? cfg.tokenAdmin,
6959
6991
  BigInt(cfg.vault.lockupDuration),
6960
6992
  BigInt(cfg.vault.vestingDuration)
@@ -6967,7 +6999,7 @@ var clankerTokenV4Converter = async (config) => {
6967
6999
  extension: clankerConfig.related.airdrop,
6968
7000
  msgValue: 0n,
6969
7001
  extensionBps: Number(bpsAirdropped),
6970
- extensionData: encodeAbiParameters(ClankerAirdropV2_Instantiation_v4_abi, [
7002
+ extensionData: encodeAbiParameters2(ClankerAirdropV2_Instantiation_v4_abi, [
6971
7003
  cfg.airdrop.admin || cfg.tokenAdmin,
6972
7004
  cfg.airdrop.merkleRoot,
6973
7005
  BigInt(cfg.airdrop.lockupDuration),
@@ -6981,7 +7013,7 @@ var clankerTokenV4Converter = async (config) => {
6981
7013
  extension: clankerConfig.related.devbuy,
6982
7014
  msgValue: BigInt(cfg.devBuy.ethAmount * 1e18),
6983
7015
  extensionBps: 0,
6984
- extensionData: encodeAbiParameters(ClankerUniV4EthDevBuy_Instantiation_v4_abi, [
7016
+ extensionData: encodeAbiParameters2(ClankerUniV4EthDevBuy_Instantiation_v4_abi, [
6985
7017
  cfg.devBuy.poolKey,
6986
7018
  BigInt(cfg.devBuy.amountOutMin * 1e18),
6987
7019
  cfg.tokenAdmin
@@ -7009,7 +7041,7 @@ var clankerTokenV4Converter = async (config) => {
7009
7041
  function encodeFeeConfig(tokenConfig, clankerConfig) {
7010
7042
  const config = tokenConfig.fees;
7011
7043
  if (config.type === "static") {
7012
- const feeData = encodeAbiParameters(ClankerHook_StaticFee_Instantiation_v4_abi, [
7044
+ const feeData = encodeAbiParameters2(ClankerHook_StaticFee_Instantiation_v4_abi, [
7013
7045
  config.clankerFee * 100,
7014
7046
  // uniBps
7015
7047
  config.pairedFee * 100
@@ -7018,7 +7050,7 @@ function encodeFeeConfig(tokenConfig, clankerConfig) {
7018
7050
  if (clankerConfig.related.feeStaticHookV2) {
7019
7051
  return {
7020
7052
  hook: clankerConfig.related.feeStaticHookV2,
7021
- poolData: encodeAbiParameters(Clanker_PoolInitializationData_v4_1_abi, [
7053
+ poolData: encodeAbiParameters2(Clanker_PoolInitializationData_v4_1_abi, [
7022
7054
  {
7023
7055
  extension: tokenConfig.poolExtension.address,
7024
7056
  extensionData: tokenConfig.poolExtension.initData,
@@ -7033,7 +7065,7 @@ function encodeFeeConfig(tokenConfig, clankerConfig) {
7033
7065
  };
7034
7066
  }
7035
7067
  if (config.type === "dynamic") {
7036
- const feeData = encodeAbiParameters(ClankerHook_DynamicFee_Instantiation_v4_abi, [
7068
+ const feeData = encodeAbiParameters2(ClankerHook_DynamicFee_Instantiation_v4_abi, [
7037
7069
  config.baseFee * 100,
7038
7070
  // uniBps
7039
7071
  config.maxFee * 100,
@@ -7047,7 +7079,7 @@ function encodeFeeConfig(tokenConfig, clankerConfig) {
7047
7079
  if (clankerConfig.related.feeDynamicHookV2) {
7048
7080
  return {
7049
7081
  hook: clankerConfig.related.feeDynamicHookV2,
7050
- poolData: encodeAbiParameters(Clanker_PoolInitializationData_v4_1_abi, [
7082
+ poolData: encodeAbiParameters2(Clanker_PoolInitializationData_v4_1_abi, [
7051
7083
  {
7052
7084
  extension: tokenConfig.poolExtension.address,
7053
7085
  extensionData: tokenConfig.poolExtension.initData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clanker-sdk",
3
- "version": "4.2.4",
3
+ "version": "4.2.5",
4
4
  "description": "SDK for deploying tokens using Clanker",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",