clanker-sdk 3.1.13 → 3.2.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/index.d.mts CHANGED
@@ -16,6 +16,7 @@ interface VaultConfig {
16
16
  interface PoolConfig {
17
17
  pairedToken: Address;
18
18
  initialMarketCapInPairedToken: bigint;
19
+ initialMarketCap?: string;
19
20
  }
20
21
  interface InitialBuyConfig {
21
22
  pairedTokenPoolFee: 10000;
@@ -28,6 +29,13 @@ interface RewardsConfig {
28
29
  interfaceAdmin: Address;
29
30
  interfaceRewardRecipient: Address;
30
31
  }
32
+ interface DeploymentConfig {
33
+ tokenConfig: TokenConfig;
34
+ vaultConfig?: VaultConfig;
35
+ poolConfig: PoolConfig;
36
+ initialBuyConfig?: InitialBuyConfig;
37
+ rewardsConfig: RewardsConfig;
38
+ }
31
39
  interface ClankerConfig {
32
40
  wallet: WalletClient;
33
41
  publicClient: PublicClient;
@@ -42,46 +50,13 @@ interface SimpleTokenConfig {
42
50
  percentage: number;
43
51
  durationInDays: number;
44
52
  };
53
+ pool?: {
54
+ quoteToken?: Address;
55
+ initialMarketCap?: string;
56
+ };
45
57
  metadata?: IClankerMetadata;
46
58
  context?: IClankerSocialContext;
47
59
  }
48
- interface DeploymentConfig {
49
- tokenConfig: TokenConfig;
50
- vaultConfig?: VaultConfig;
51
- poolConfig: PoolConfig;
52
- initialBuyConfig?: InitialBuyConfig;
53
- rewardsConfig: RewardsConfig;
54
- }
55
- interface DeploymentConfig {
56
- tokenConfig: {
57
- name: string;
58
- symbol: string;
59
- salt: `0x${string}`;
60
- image: string;
61
- metadata: IClankerMetadata;
62
- context: IClankerSocialContext;
63
- originatingChainId: bigint;
64
- };
65
- poolConfig: {
66
- pairedToken: Address;
67
- initialMarketCapInPairedToken: bigint;
68
- };
69
- vaultConfig?: {
70
- vaultPercentage: number;
71
- vaultDuration: bigint;
72
- };
73
- initialBuyConfig?: {
74
- pairedTokenPoolFee: 10000;
75
- pairedTokenSwapAmountOutMinimum: bigint;
76
- };
77
- rewardsConfig: {
78
- creatorReward: bigint;
79
- creatorAdmin: Address;
80
- creatorRewardRecipient: Address;
81
- interfaceAdmin: Address;
82
- interfaceRewardRecipient: Address;
83
- };
84
- }
85
60
  interface IClankerMetadata {
86
61
  description?: string;
87
62
  socialMediaUrls?: {
@@ -102,7 +77,9 @@ declare class Clanker {
102
77
  private readonly factoryAddress;
103
78
  private readonly publicClient;
104
79
  constructor(config: ClankerConfig);
80
+ private getTokenDecimals;
105
81
  private calculateTick;
82
+ private calculateTickFromMarketCap;
106
83
  private handleError;
107
84
  deploy(config: DeploymentConfig): Promise<Address>;
108
85
  /**
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ interface VaultConfig {
16
16
  interface PoolConfig {
17
17
  pairedToken: Address;
18
18
  initialMarketCapInPairedToken: bigint;
19
+ initialMarketCap?: string;
19
20
  }
20
21
  interface InitialBuyConfig {
21
22
  pairedTokenPoolFee: 10000;
@@ -28,6 +29,13 @@ interface RewardsConfig {
28
29
  interfaceAdmin: Address;
29
30
  interfaceRewardRecipient: Address;
30
31
  }
32
+ interface DeploymentConfig {
33
+ tokenConfig: TokenConfig;
34
+ vaultConfig?: VaultConfig;
35
+ poolConfig: PoolConfig;
36
+ initialBuyConfig?: InitialBuyConfig;
37
+ rewardsConfig: RewardsConfig;
38
+ }
31
39
  interface ClankerConfig {
32
40
  wallet: WalletClient;
33
41
  publicClient: PublicClient;
@@ -42,46 +50,13 @@ interface SimpleTokenConfig {
42
50
  percentage: number;
43
51
  durationInDays: number;
44
52
  };
53
+ pool?: {
54
+ quoteToken?: Address;
55
+ initialMarketCap?: string;
56
+ };
45
57
  metadata?: IClankerMetadata;
46
58
  context?: IClankerSocialContext;
47
59
  }
48
- interface DeploymentConfig {
49
- tokenConfig: TokenConfig;
50
- vaultConfig?: VaultConfig;
51
- poolConfig: PoolConfig;
52
- initialBuyConfig?: InitialBuyConfig;
53
- rewardsConfig: RewardsConfig;
54
- }
55
- interface DeploymentConfig {
56
- tokenConfig: {
57
- name: string;
58
- symbol: string;
59
- salt: `0x${string}`;
60
- image: string;
61
- metadata: IClankerMetadata;
62
- context: IClankerSocialContext;
63
- originatingChainId: bigint;
64
- };
65
- poolConfig: {
66
- pairedToken: Address;
67
- initialMarketCapInPairedToken: bigint;
68
- };
69
- vaultConfig?: {
70
- vaultPercentage: number;
71
- vaultDuration: bigint;
72
- };
73
- initialBuyConfig?: {
74
- pairedTokenPoolFee: 10000;
75
- pairedTokenSwapAmountOutMinimum: bigint;
76
- };
77
- rewardsConfig: {
78
- creatorReward: bigint;
79
- creatorAdmin: Address;
80
- creatorRewardRecipient: Address;
81
- interfaceAdmin: Address;
82
- interfaceRewardRecipient: Address;
83
- };
84
- }
85
60
  interface IClankerMetadata {
86
61
  description?: string;
87
62
  socialMediaUrls?: {
@@ -102,7 +77,9 @@ declare class Clanker {
102
77
  private readonly factoryAddress;
103
78
  private readonly publicClient;
104
79
  constructor(config: ClankerConfig);
80
+ private getTokenDecimals;
105
81
  private calculateTick;
82
+ private calculateTickFromMarketCap;
106
83
  private handleError;
107
84
  deploy(config: DeploymentConfig): Promise<Address>;
108
85
  /**
package/dist/index.js CHANGED
@@ -28,7 +28,16 @@ var import_actions = require("viem/actions");
28
28
 
29
29
  // src/constants.ts
30
30
  var WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
31
- var CLANKER_FACTORY_V3_1 = "0x2A787b2362021cC3eEa3C24C4748a6cD5B687382";
31
+ var CLANKER_FACTORY_V3_1 = "0x0000000000000000000000000000000000000000";
32
+ var ERC20_DECIMALS_ABI = [
33
+ {
34
+ "inputs": [],
35
+ "name": "decimals",
36
+ "outputs": [{ "type": "uint8", "name": "" }],
37
+ "stateMutability": "view",
38
+ "type": "function"
39
+ }
40
+ ];
32
41
 
33
42
  // src/abis/Clanker_V3_1.ts
34
43
  var Clanker_v3_1_abi = [
@@ -533,9 +542,36 @@ var Clanker = class {
533
542
  this.publicClient = config.publicClient;
534
543
  this.factoryAddress = config.factoryAddress ?? CLANKER_FACTORY_V3_1;
535
544
  }
536
- // Get paired token decimals
545
+ // Fetch token decimals from contract
546
+ async getTokenDecimals(tokenAddress) {
547
+ try {
548
+ const decimals = await (0, import_actions.readContract)(this.publicClient, {
549
+ address: tokenAddress,
550
+ abi: ERC20_DECIMALS_ABI,
551
+ functionName: "decimals"
552
+ });
553
+ return decimals;
554
+ } catch (error) {
555
+ console.warn(`Failed to fetch decimals for token ${tokenAddress}, defaulting to 18:`, error);
556
+ return 18;
557
+ }
558
+ }
559
+ // Fallback tick calculation with default price
537
560
  calculateTick() {
538
- let desiredPrice = 1e-10;
561
+ const desiredPrice = 1e-10;
562
+ const logBase = 1.0001;
563
+ const tickSpacing = 200;
564
+ const rawTick = Math.log(desiredPrice) / Math.log(logBase);
565
+ const initialTick = Math.floor(rawTick / tickSpacing) * tickSpacing;
566
+ return initialTick;
567
+ }
568
+ // Calculate tick based on desired market cap and token decimals
569
+ async calculateTickFromMarketCap(marketCap, quoteToken) {
570
+ const quoteDecimals = await this.getTokenDecimals(quoteToken);
571
+ const marketCapBigInt = (0, import_viem.parseEther)(marketCap);
572
+ const adjustedMarketCap = Number((0, import_viem.formatUnits)(marketCapBigInt, quoteDecimals));
573
+ const totalSupply = 1e6;
574
+ const desiredPrice = adjustedMarketCap / totalSupply;
539
575
  const logBase = 1.0001;
540
576
  const tickSpacing = 200;
541
577
  const rawTick = Math.log(desiredPrice) / Math.log(logBase);
@@ -618,18 +654,20 @@ var Clanker = class {
618
654
  throw new Error("Wallet account not configured");
619
655
  }
620
656
  const deployerAddress = this.wallet.account.address;
657
+ const quoteToken = config.pool?.quoteToken ?? WETH_ADDRESS;
658
+ const initialTick = config.pool?.initialMarketCap ? await this.calculateTickFromMarketCap(config.pool.initialMarketCap, quoteToken) : this.calculateTick();
621
659
  const deploymentConfig = {
622
660
  tokenConfig: {
623
661
  name: config.name,
624
662
  symbol: config.symbol,
625
- salt: config.salt || "0x0000000000000000000000000000000000000000000000000000000000000000",
626
- image: config.image || "https://ipfs.io/ipfs/QmcjfTeK3tpK3MVCQuvEaXvSscrqbL3MwsEo8LdBTWabY4",
627
- metadata: config.metadata || {
663
+ salt: config.salt ?? "0x0000000000000000000000000000000000000000000000000000000000000000",
664
+ image: config.image ?? "https://ipfs.io/ipfs/QmcjfTeK3tpK3MVCQuvEaXvSscrqbL3MwsEo8LdBTWabY4",
665
+ metadata: config.metadata ?? {
628
666
  description: "Clanker Token",
629
667
  socialMediaUrls: [],
630
668
  auditUrls: []
631
669
  },
632
- context: config.context || {
670
+ context: config.context ?? {
633
671
  interface: "Clanker SDK",
634
672
  platform: "Clanker",
635
673
  messageId: "Clanker SDK",
@@ -638,9 +676,9 @@ var Clanker = class {
638
676
  originatingChainId: BigInt(this.publicClient.chain.id)
639
677
  },
640
678
  poolConfig: {
641
- pairedToken: WETH_ADDRESS,
642
- // WETH on Base
643
- initialMarketCapInPairedToken: (0, import_viem.parseEther)("10")
679
+ pairedToken: quoteToken,
680
+ initialMarketCapInPairedToken: (0, import_viem.parseEther)(config.pool?.initialMarketCap ?? "10"),
681
+ initialMarketCap: config.pool?.initialMarketCap
644
682
  },
645
683
  vaultConfig: config.vault ? {
646
684
  vaultPercentage: config.vault.percentage,
package/dist/index.mjs CHANGED
@@ -2,13 +2,23 @@
2
2
  import {
3
3
  parseEther,
4
4
  stringify,
5
- parseEventLogs
5
+ parseEventLogs,
6
+ formatUnits
6
7
  } from "viem";
7
- import { simulateContract, writeContract } from "viem/actions";
8
+ import { simulateContract, writeContract, readContract } from "viem/actions";
8
9
 
9
10
  // src/constants.ts
10
11
  var WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
11
- var CLANKER_FACTORY_V3_1 = "0x2A787b2362021cC3eEa3C24C4748a6cD5B687382";
12
+ var CLANKER_FACTORY_V3_1 = "0x0000000000000000000000000000000000000000";
13
+ var ERC20_DECIMALS_ABI = [
14
+ {
15
+ "inputs": [],
16
+ "name": "decimals",
17
+ "outputs": [{ "type": "uint8", "name": "" }],
18
+ "stateMutability": "view",
19
+ "type": "function"
20
+ }
21
+ ];
12
22
 
13
23
  // src/abis/Clanker_V3_1.ts
14
24
  var Clanker_v3_1_abi = [
@@ -513,9 +523,36 @@ var Clanker = class {
513
523
  this.publicClient = config.publicClient;
514
524
  this.factoryAddress = config.factoryAddress ?? CLANKER_FACTORY_V3_1;
515
525
  }
516
- // Get paired token decimals
526
+ // Fetch token decimals from contract
527
+ async getTokenDecimals(tokenAddress) {
528
+ try {
529
+ const decimals = await readContract(this.publicClient, {
530
+ address: tokenAddress,
531
+ abi: ERC20_DECIMALS_ABI,
532
+ functionName: "decimals"
533
+ });
534
+ return decimals;
535
+ } catch (error) {
536
+ console.warn(`Failed to fetch decimals for token ${tokenAddress}, defaulting to 18:`, error);
537
+ return 18;
538
+ }
539
+ }
540
+ // Fallback tick calculation with default price
517
541
  calculateTick() {
518
- let desiredPrice = 1e-10;
542
+ const desiredPrice = 1e-10;
543
+ const logBase = 1.0001;
544
+ const tickSpacing = 200;
545
+ const rawTick = Math.log(desiredPrice) / Math.log(logBase);
546
+ const initialTick = Math.floor(rawTick / tickSpacing) * tickSpacing;
547
+ return initialTick;
548
+ }
549
+ // Calculate tick based on desired market cap and token decimals
550
+ async calculateTickFromMarketCap(marketCap, quoteToken) {
551
+ const quoteDecimals = await this.getTokenDecimals(quoteToken);
552
+ const marketCapBigInt = parseEther(marketCap);
553
+ const adjustedMarketCap = Number(formatUnits(marketCapBigInt, quoteDecimals));
554
+ const totalSupply = 1e6;
555
+ const desiredPrice = adjustedMarketCap / totalSupply;
519
556
  const logBase = 1.0001;
520
557
  const tickSpacing = 200;
521
558
  const rawTick = Math.log(desiredPrice) / Math.log(logBase);
@@ -598,18 +635,20 @@ var Clanker = class {
598
635
  throw new Error("Wallet account not configured");
599
636
  }
600
637
  const deployerAddress = this.wallet.account.address;
638
+ const quoteToken = config.pool?.quoteToken ?? WETH_ADDRESS;
639
+ const initialTick = config.pool?.initialMarketCap ? await this.calculateTickFromMarketCap(config.pool.initialMarketCap, quoteToken) : this.calculateTick();
601
640
  const deploymentConfig = {
602
641
  tokenConfig: {
603
642
  name: config.name,
604
643
  symbol: config.symbol,
605
- salt: config.salt || "0x0000000000000000000000000000000000000000000000000000000000000000",
606
- image: config.image || "https://ipfs.io/ipfs/QmcjfTeK3tpK3MVCQuvEaXvSscrqbL3MwsEo8LdBTWabY4",
607
- metadata: config.metadata || {
644
+ salt: config.salt ?? "0x0000000000000000000000000000000000000000000000000000000000000000",
645
+ image: config.image ?? "https://ipfs.io/ipfs/QmcjfTeK3tpK3MVCQuvEaXvSscrqbL3MwsEo8LdBTWabY4",
646
+ metadata: config.metadata ?? {
608
647
  description: "Clanker Token",
609
648
  socialMediaUrls: [],
610
649
  auditUrls: []
611
650
  },
612
- context: config.context || {
651
+ context: config.context ?? {
613
652
  interface: "Clanker SDK",
614
653
  platform: "Clanker",
615
654
  messageId: "Clanker SDK",
@@ -618,9 +657,9 @@ var Clanker = class {
618
657
  originatingChainId: BigInt(this.publicClient.chain.id)
619
658
  },
620
659
  poolConfig: {
621
- pairedToken: WETH_ADDRESS,
622
- // WETH on Base
623
- initialMarketCapInPairedToken: parseEther("10")
660
+ pairedToken: quoteToken,
661
+ initialMarketCapInPairedToken: parseEther(config.pool?.initialMarketCap ?? "10"),
662
+ initialMarketCap: config.pool?.initialMarketCap
624
663
  },
625
664
  vaultConfig: config.vault ? {
626
665
  vaultPercentage: config.vault.percentage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clanker-sdk",
3
- "version": "3.1.13",
3
+ "version": "3.2.0",
4
4
  "description": "SDK for deploying tokens using Clanker",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",