clanker-sdk 3.6.0 → 3.8.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
@@ -78,8 +78,14 @@ interface IClankerSocialContext {
78
78
  id?: string;
79
79
  }
80
80
 
81
+ /** Lightweight container for a pre-built deploy transaction */
82
+ type PreparedDeployTx = {
83
+ to: Address;
84
+ data: `0x${string}`;
85
+ value: bigint;
86
+ };
81
87
  declare class Clanker {
82
- private readonly wallet;
88
+ private readonly wallet?;
83
89
  private readonly factoryAddress;
84
90
  private readonly publicClient;
85
91
  constructor(config: ClankerConfig);
@@ -89,12 +95,10 @@ declare class Clanker {
89
95
  private calculateTickForQuoteToken;
90
96
  private handleError;
91
97
  deploy(config: DeploymentConfig): Promise<Address>;
92
- /**
93
- * Simplified token deployment method for easier user experience
94
- * @param config Simple configuration for token deployment
95
- * @returns Deployed token address
96
- */
97
- deployToken(config: SimpleTokenConfig): Promise<Address>;
98
+ private buildDeploymentConfig;
99
+ /** Creates calldata + value without asking the wallet to sign/send. */
100
+ prepareDeployToken(cfg: SimpleTokenConfig): Promise<PreparedDeployTx>;
101
+ deployToken(cfg: SimpleTokenConfig): Promise<Address>;
98
102
  }
99
103
 
100
- export { Clanker, type ClankerConfig, type DeploymentConfig, type IClankerMetadata, type IClankerSocialContext, type InitialBuyConfig, type PoolConfig, type RewardsConfig, type SimpleTokenConfig, type TokenConfig, type VaultConfig };
104
+ export { Clanker, type ClankerConfig, type DeploymentConfig, type IClankerMetadata, type IClankerSocialContext, type InitialBuyConfig, type PoolConfig, type PreparedDeployTx, type RewardsConfig, type SimpleTokenConfig, type TokenConfig, type VaultConfig };
package/dist/index.d.ts CHANGED
@@ -78,8 +78,14 @@ interface IClankerSocialContext {
78
78
  id?: string;
79
79
  }
80
80
 
81
+ /** Lightweight container for a pre-built deploy transaction */
82
+ type PreparedDeployTx = {
83
+ to: Address;
84
+ data: `0x${string}`;
85
+ value: bigint;
86
+ };
81
87
  declare class Clanker {
82
- private readonly wallet;
88
+ private readonly wallet?;
83
89
  private readonly factoryAddress;
84
90
  private readonly publicClient;
85
91
  constructor(config: ClankerConfig);
@@ -89,12 +95,10 @@ declare class Clanker {
89
95
  private calculateTickForQuoteToken;
90
96
  private handleError;
91
97
  deploy(config: DeploymentConfig): Promise<Address>;
92
- /**
93
- * Simplified token deployment method for easier user experience
94
- * @param config Simple configuration for token deployment
95
- * @returns Deployed token address
96
- */
97
- deployToken(config: SimpleTokenConfig): Promise<Address>;
98
+ private buildDeploymentConfig;
99
+ /** Creates calldata + value without asking the wallet to sign/send. */
100
+ prepareDeployToken(cfg: SimpleTokenConfig): Promise<PreparedDeployTx>;
101
+ deployToken(cfg: SimpleTokenConfig): Promise<Address>;
98
102
  }
99
103
 
100
- export { Clanker, type ClankerConfig, type DeploymentConfig, type IClankerMetadata, type IClankerSocialContext, type InitialBuyConfig, type PoolConfig, type RewardsConfig, type SimpleTokenConfig, type TokenConfig, type VaultConfig };
104
+ export { Clanker, type ClankerConfig, type DeploymentConfig, type IClankerMetadata, type IClankerSocialContext, type InitialBuyConfig, type PoolConfig, type PreparedDeployTx, type RewardsConfig, type SimpleTokenConfig, type TokenConfig, type VaultConfig };
package/dist/index.js CHANGED
@@ -684,7 +684,7 @@ var Clanker = class {
684
684
  throw new Error(`Deployment failed: ${message}`);
685
685
  }
686
686
  async deploy(config) {
687
- if (!this.wallet.account) {
687
+ if (!this.wallet?.account) {
688
688
  throw new Error("Wallet account not configured");
689
689
  }
690
690
  try {
@@ -749,33 +749,32 @@ var Clanker = class {
749
749
  this.handleError(error);
750
750
  }
751
751
  }
752
- /**
753
- * Simplified token deployment method for easier user experience
754
- * @param config Simple configuration for token deployment
755
- * @returns Deployed token address
756
- */
757
- async deployToken(config) {
758
- if (!this.wallet.account) {
759
- throw new Error("Wallet account not configured");
760
- }
761
- const deployerAddress = this.wallet.account.address;
762
- const quoteToken = config.pool?.quoteToken ?? WETH_ADDRESS;
752
+ async buildDeploymentConfig(cfg) {
753
+ const quoteToken = cfg.pool?.quoteToken ?? WETH_ADDRESS;
763
754
  const quoteDecimals = await this.getQuoteTokenDecimals(quoteToken);
764
755
  console.log("Quote token decimals:", quoteDecimals);
756
+ const marketCap = (0, import_viem.parseUnits)(
757
+ cfg.pool?.initialMarketCap ?? "100",
758
+ quoteDecimals
759
+ );
760
+ const tick = await this.calculateTickForQuoteToken(
761
+ quoteToken,
762
+ marketCap
763
+ );
765
764
  let initialBuyConfig = {
766
765
  pairedTokenPoolFee: 1e4,
767
766
  // Default to 1%
768
767
  pairedTokenSwapAmountOutMinimum: BigInt(0),
769
768
  ethAmount: void 0
770
769
  };
771
- if (config.devBuy) {
772
- const ethAmount = (0, import_viem.parseEther)(config.devBuy.ethAmount);
770
+ if (cfg.devBuy) {
771
+ const ethAmount = (0, import_viem.parseEther)(cfg.devBuy.ethAmount);
773
772
  const { fee, sqrtPriceX96 } = await this.findMostLiquidPool(quoteToken);
774
773
  const minOutput = this.calculateMinimumOutput(
775
774
  ethAmount,
776
775
  sqrtPriceX96,
777
776
  quoteDecimals,
778
- config.devBuy.maxSlippage ?? 5
777
+ cfg.devBuy.maxSlippage ?? 5
779
778
  );
780
779
  initialBuyConfig = {
781
780
  pairedTokenPoolFee: fee,
@@ -783,41 +782,43 @@ var Clanker = class {
783
782
  ethAmount
784
783
  };
785
784
  console.log("Dev buy configuration:", {
786
- ethAmount: config.devBuy.ethAmount,
785
+ ethAmount: cfg.devBuy.ethAmount,
787
786
  fee,
788
787
  minOutput: minOutput.toString()
789
788
  });
790
789
  }
791
- const deploymentConfig = {
790
+ const deployerAddress = this.wallet?.account?.address ?? "0x0000000000000000000000000000000000000000";
791
+ return {
792
792
  tokenConfig: {
793
- name: config.name,
794
- symbol: config.symbol,
795
- salt: config.salt || "0x0000000000000000000000000000000000000000000000000000000000000000",
796
- image: config.image || "https://ipfs.io/ipfs/QmcjfTeK3tpK3MVCQuvEaXvSscrqbL3MwsEo8LdBTWabY4",
797
- metadata: config.metadata || {
793
+ name: cfg.name,
794
+ symbol: cfg.symbol,
795
+ salt: cfg.salt || "0x0000000000000000000000000000000000000000000000000000000000000000",
796
+ image: cfg.image || "https://ipfs.io/ipfs/QmcjfTeK3tpK3MVCQuvEaXvSscrqbL3MwsEo8LdBTWabY4",
797
+ metadata: JSON.stringify(cfg.metadata || {
798
798
  description: "Clanker Token",
799
799
  socialMediaUrls: [],
800
800
  auditUrls: []
801
- },
802
- context: config.context || {
801
+ }),
802
+ context: JSON.stringify(cfg.context || {
803
803
  interface: "Clanker SDK",
804
804
  platform: "Clanker",
805
805
  messageId: "Clanker SDK",
806
806
  id: "Clanker SDK"
807
- },
807
+ }),
808
808
  originatingChainId: BigInt(this.publicClient.chain.id)
809
809
  },
810
810
  poolConfig: {
811
811
  pairedToken: quoteToken,
812
- initialMarketCapInPairedToken: (0, import_viem.parseUnits)(
813
- config.pool?.initialMarketCap ?? "100",
814
- quoteDecimals
815
- )
812
+ tickIfToken0IsNewToken: tick,
813
+ initialMarketCapInPairedToken: marketCap
814
+ },
815
+ vaultConfig: cfg.vault ? {
816
+ vaultPercentage: cfg.vault.percentage,
817
+ vaultDuration: BigInt(cfg.vault.durationInDays * 24 * 60 * 60)
818
+ } : {
819
+ vaultPercentage: 0,
820
+ vaultDuration: 0n
816
821
  },
817
- vaultConfig: config.vault ? {
818
- vaultPercentage: config.vault.percentage,
819
- vaultDuration: BigInt(config.vault.durationInDays * 24 * 60 * 60)
820
- } : void 0,
821
822
  initialBuyConfig,
822
823
  rewardsConfig: {
823
824
  creatorReward: BigInt(40),
@@ -828,7 +829,43 @@ var Clanker = class {
828
829
  interfaceRewardRecipient: deployerAddress
829
830
  }
830
831
  };
831
- return this.deploy(deploymentConfig);
832
+ }
833
+ /** Creates calldata + value without asking the wallet to sign/send. */
834
+ async prepareDeployToken(cfg) {
835
+ const deploymentConfig = await this.buildDeploymentConfig(cfg);
836
+ const { request } = await (0, import_actions.simulateContract)(this.publicClient, {
837
+ address: this.factoryAddress,
838
+ abi: Clanker_v3_1_abi,
839
+ functionName: "deployToken",
840
+ args: [deploymentConfig],
841
+ value: deploymentConfig.initialBuyConfig?.ethAmount ?? 0n,
842
+ chain: this.publicClient.chain,
843
+ // give Viem *some* account for simulation
844
+ account: this.wallet?.account ?? deploymentConfig.rewardsConfig.creatorAdmin
845
+ });
846
+ return {
847
+ to: this.factoryAddress,
848
+ data: request.data,
849
+ value: request.value ?? 0n
850
+ };
851
+ }
852
+ async deployToken(cfg) {
853
+ if (!this.wallet) throw new Error("Wallet client required for deployToken");
854
+ if (!this.wallet.account) throw new Error("Wallet account required for deployToken");
855
+ const tx = await this.prepareDeployToken(cfg);
856
+ const hash = await this.wallet.sendTransaction({
857
+ ...tx,
858
+ account: this.wallet.account,
859
+ chain: this.publicClient.chain
860
+ });
861
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
862
+ const [log] = (0, import_viem.parseEventLogs)({
863
+ abi: Clanker_v3_1_abi,
864
+ eventName: "TokenCreated",
865
+ logs: receipt.logs
866
+ });
867
+ if (!log) throw new Error("No deployment event found");
868
+ return log.args.tokenAddress;
832
869
  }
833
870
  };
834
871
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -665,7 +665,7 @@ var Clanker = class {
665
665
  throw new Error(`Deployment failed: ${message}`);
666
666
  }
667
667
  async deploy(config) {
668
- if (!this.wallet.account) {
668
+ if (!this.wallet?.account) {
669
669
  throw new Error("Wallet account not configured");
670
670
  }
671
671
  try {
@@ -730,33 +730,32 @@ var Clanker = class {
730
730
  this.handleError(error);
731
731
  }
732
732
  }
733
- /**
734
- * Simplified token deployment method for easier user experience
735
- * @param config Simple configuration for token deployment
736
- * @returns Deployed token address
737
- */
738
- async deployToken(config) {
739
- if (!this.wallet.account) {
740
- throw new Error("Wallet account not configured");
741
- }
742
- const deployerAddress = this.wallet.account.address;
743
- const quoteToken = config.pool?.quoteToken ?? WETH_ADDRESS;
733
+ async buildDeploymentConfig(cfg) {
734
+ const quoteToken = cfg.pool?.quoteToken ?? WETH_ADDRESS;
744
735
  const quoteDecimals = await this.getQuoteTokenDecimals(quoteToken);
745
736
  console.log("Quote token decimals:", quoteDecimals);
737
+ const marketCap = parseUnits(
738
+ cfg.pool?.initialMarketCap ?? "100",
739
+ quoteDecimals
740
+ );
741
+ const tick = await this.calculateTickForQuoteToken(
742
+ quoteToken,
743
+ marketCap
744
+ );
746
745
  let initialBuyConfig = {
747
746
  pairedTokenPoolFee: 1e4,
748
747
  // Default to 1%
749
748
  pairedTokenSwapAmountOutMinimum: BigInt(0),
750
749
  ethAmount: void 0
751
750
  };
752
- if (config.devBuy) {
753
- const ethAmount = parseEther(config.devBuy.ethAmount);
751
+ if (cfg.devBuy) {
752
+ const ethAmount = parseEther(cfg.devBuy.ethAmount);
754
753
  const { fee, sqrtPriceX96 } = await this.findMostLiquidPool(quoteToken);
755
754
  const minOutput = this.calculateMinimumOutput(
756
755
  ethAmount,
757
756
  sqrtPriceX96,
758
757
  quoteDecimals,
759
- config.devBuy.maxSlippage ?? 5
758
+ cfg.devBuy.maxSlippage ?? 5
760
759
  );
761
760
  initialBuyConfig = {
762
761
  pairedTokenPoolFee: fee,
@@ -764,41 +763,43 @@ var Clanker = class {
764
763
  ethAmount
765
764
  };
766
765
  console.log("Dev buy configuration:", {
767
- ethAmount: config.devBuy.ethAmount,
766
+ ethAmount: cfg.devBuy.ethAmount,
768
767
  fee,
769
768
  minOutput: minOutput.toString()
770
769
  });
771
770
  }
772
- const deploymentConfig = {
771
+ const deployerAddress = this.wallet?.account?.address ?? "0x0000000000000000000000000000000000000000";
772
+ return {
773
773
  tokenConfig: {
774
- name: config.name,
775
- symbol: config.symbol,
776
- salt: config.salt || "0x0000000000000000000000000000000000000000000000000000000000000000",
777
- image: config.image || "https://ipfs.io/ipfs/QmcjfTeK3tpK3MVCQuvEaXvSscrqbL3MwsEo8LdBTWabY4",
778
- metadata: config.metadata || {
774
+ name: cfg.name,
775
+ symbol: cfg.symbol,
776
+ salt: cfg.salt || "0x0000000000000000000000000000000000000000000000000000000000000000",
777
+ image: cfg.image || "https://ipfs.io/ipfs/QmcjfTeK3tpK3MVCQuvEaXvSscrqbL3MwsEo8LdBTWabY4",
778
+ metadata: JSON.stringify(cfg.metadata || {
779
779
  description: "Clanker Token",
780
780
  socialMediaUrls: [],
781
781
  auditUrls: []
782
- },
783
- context: config.context || {
782
+ }),
783
+ context: JSON.stringify(cfg.context || {
784
784
  interface: "Clanker SDK",
785
785
  platform: "Clanker",
786
786
  messageId: "Clanker SDK",
787
787
  id: "Clanker SDK"
788
- },
788
+ }),
789
789
  originatingChainId: BigInt(this.publicClient.chain.id)
790
790
  },
791
791
  poolConfig: {
792
792
  pairedToken: quoteToken,
793
- initialMarketCapInPairedToken: parseUnits(
794
- config.pool?.initialMarketCap ?? "100",
795
- quoteDecimals
796
- )
793
+ tickIfToken0IsNewToken: tick,
794
+ initialMarketCapInPairedToken: marketCap
795
+ },
796
+ vaultConfig: cfg.vault ? {
797
+ vaultPercentage: cfg.vault.percentage,
798
+ vaultDuration: BigInt(cfg.vault.durationInDays * 24 * 60 * 60)
799
+ } : {
800
+ vaultPercentage: 0,
801
+ vaultDuration: 0n
797
802
  },
798
- vaultConfig: config.vault ? {
799
- vaultPercentage: config.vault.percentage,
800
- vaultDuration: BigInt(config.vault.durationInDays * 24 * 60 * 60)
801
- } : void 0,
802
803
  initialBuyConfig,
803
804
  rewardsConfig: {
804
805
  creatorReward: BigInt(40),
@@ -809,7 +810,43 @@ var Clanker = class {
809
810
  interfaceRewardRecipient: deployerAddress
810
811
  }
811
812
  };
812
- return this.deploy(deploymentConfig);
813
+ }
814
+ /** Creates calldata + value without asking the wallet to sign/send. */
815
+ async prepareDeployToken(cfg) {
816
+ const deploymentConfig = await this.buildDeploymentConfig(cfg);
817
+ const { request } = await simulateContract(this.publicClient, {
818
+ address: this.factoryAddress,
819
+ abi: Clanker_v3_1_abi,
820
+ functionName: "deployToken",
821
+ args: [deploymentConfig],
822
+ value: deploymentConfig.initialBuyConfig?.ethAmount ?? 0n,
823
+ chain: this.publicClient.chain,
824
+ // give Viem *some* account for simulation
825
+ account: this.wallet?.account ?? deploymentConfig.rewardsConfig.creatorAdmin
826
+ });
827
+ return {
828
+ to: this.factoryAddress,
829
+ data: request.data,
830
+ value: request.value ?? 0n
831
+ };
832
+ }
833
+ async deployToken(cfg) {
834
+ if (!this.wallet) throw new Error("Wallet client required for deployToken");
835
+ if (!this.wallet.account) throw new Error("Wallet account required for deployToken");
836
+ const tx = await this.prepareDeployToken(cfg);
837
+ const hash = await this.wallet.sendTransaction({
838
+ ...tx,
839
+ account: this.wallet.account,
840
+ chain: this.publicClient.chain
841
+ });
842
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
843
+ const [log] = parseEventLogs({
844
+ abi: Clanker_v3_1_abi,
845
+ eventName: "TokenCreated",
846
+ logs: receipt.logs
847
+ });
848
+ if (!log) throw new Error("No deployment event found");
849
+ return log.args.tokenAddress;
813
850
  }
814
851
  };
815
852
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clanker-sdk",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "description": "SDK for deploying tokens using Clanker",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",