clanker-sdk 4.0.14 → 4.0.16
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 +65 -43
- package/dist/cli/create-clanker.js +64 -42
- package/dist/index.d.ts +219 -93
- package/dist/index.js +297 -145
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -74,7 +74,7 @@ var init_validation_schema = __esm({
|
|
|
74
74
|
})
|
|
75
75
|
}).optional(),
|
|
76
76
|
devBuy: z.object({
|
|
77
|
-
ethAmount: z.
|
|
77
|
+
ethAmount: z.number().optional()
|
|
78
78
|
}).optional(),
|
|
79
79
|
rewardsConfig: z.object({
|
|
80
80
|
creatorReward: z.number().min(0).max(1e4).refine(isValidBps, {
|
|
@@ -110,7 +110,7 @@ var init_validation_schema = __esm({
|
|
|
110
110
|
initialBuyConfigSchema = z.object({
|
|
111
111
|
pairedTokenPoolFee: z.number(),
|
|
112
112
|
pairedTokenSwapAmountOutMinimum: z.bigint(),
|
|
113
|
-
ethAmount: z.
|
|
113
|
+
ethAmount: z.number().optional()
|
|
114
114
|
});
|
|
115
115
|
rewardsConfigSchema = z.object({
|
|
116
116
|
creatorReward: z.bigint().gte(0n, "Creator reward must be greater than or equal to 0"),
|
|
@@ -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,9 +4897,9 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4897
4897
|
},
|
|
4898
4898
|
lockerConfig: {
|
|
4899
4899
|
locker: CLANKER_LOCKER_V4,
|
|
4900
|
-
rewardAdmins: cfg.rewardsConfig?.
|
|
4901
|
-
rewardRecipients: cfg.rewardsConfig?.
|
|
4902
|
-
rewardBps: cfg.rewardsConfig?.
|
|
4900
|
+
rewardAdmins: cfg.rewardsConfig?.recipients.map((reward) => reward.admin) || [],
|
|
4901
|
+
rewardRecipients: cfg.rewardsConfig?.recipients.map((reward) => reward.recipient) || [],
|
|
4902
|
+
rewardBps: cfg.rewardsConfig?.recipients.map((reward) => reward.bps) || [],
|
|
4903
4903
|
tickLower: cfg.poolConfig?.positions.map((p) => p.tickLower) || [DEFAULT_TICK_LOWER],
|
|
4904
4904
|
tickUpper: cfg.poolConfig?.positions.map((p) => p.tickUpper) || [DEFAULT_TICK_UPPER],
|
|
4905
4905
|
positionBps: cfg.poolConfig?.positions.map((p) => p.positionBps) || [DEFAULT_POSITION_BPS],
|
|
@@ -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, [
|
|
@@ -4944,10 +4944,10 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4944
4944
|
}
|
|
4945
4945
|
] : [],
|
|
4946
4946
|
// devBuy extension
|
|
4947
|
-
...cfg.devBuy && cfg.devBuy.ethAmount !==
|
|
4947
|
+
...cfg.devBuy && cfg.devBuy.ethAmount !== 0 ? [
|
|
4948
4948
|
{
|
|
4949
|
-
extension:
|
|
4950
|
-
msgValue: BigInt(
|
|
4949
|
+
extension: CLANKER_DEVBUY_V4,
|
|
4950
|
+
msgValue: BigInt(cfg.devBuy.ethAmount * 1e18),
|
|
4951
4951
|
extensionBps: 0,
|
|
4952
4952
|
extensionData: encodeAbiParameters2(DEVBUY_EXTENSION_PARAMETERS, [
|
|
4953
4953
|
DEVBUY_POOL_CONFIG,
|
|
@@ -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]
|
|
@@ -4967,7 +4967,7 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4967
4967
|
transaction: {
|
|
4968
4968
|
to: CLANKER_FACTORY_V4,
|
|
4969
4969
|
data: deployCalldata,
|
|
4970
|
-
value: cfg.devBuy && cfg.devBuy.ethAmount !==
|
|
4970
|
+
value: cfg.devBuy && cfg.devBuy.ethAmount !== 0 ? BigInt(cfg.devBuy.ethAmount * 1e18) : BigInt(0)
|
|
4971
4971
|
},
|
|
4972
4972
|
expectedAddress: "0x0000000000000000000000000000000000000000",
|
|
4973
4973
|
chainId
|
|
@@ -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({
|
|
@@ -5210,6 +5225,11 @@ var init_index = __esm({
|
|
|
5210
5225
|
Clanker = class {
|
|
5211
5226
|
wallet;
|
|
5212
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
|
+
*/
|
|
5213
5233
|
constructor(config2) {
|
|
5214
5234
|
if (config2) {
|
|
5215
5235
|
const validationResult = validateConfig(config2);
|
|
@@ -5223,28 +5243,29 @@ var init_index = __esm({
|
|
|
5223
5243
|
}
|
|
5224
5244
|
}
|
|
5225
5245
|
/**
|
|
5226
|
-
*
|
|
5227
|
-
* @param cfg Token configuration for V4 deployment
|
|
5246
|
+
* Builds V4 token deployment data without actually deploying
|
|
5247
|
+
* @param cfg - Token configuration for V4 deployment
|
|
5228
5248
|
* @returns Object containing transaction data, target address, and network info
|
|
5229
5249
|
*/
|
|
5230
5250
|
buildV4(cfg) {
|
|
5231
|
-
const chainId = this.publicClient?.chain?.id ||
|
|
5251
|
+
const chainId = this.publicClient?.chain?.id || 8453;
|
|
5232
5252
|
const result = buildTokenV4(cfg, chainId);
|
|
5233
5253
|
return result;
|
|
5234
5254
|
}
|
|
5235
5255
|
/**
|
|
5236
|
-
*
|
|
5237
|
-
* @param cfg Token configuration for V4 deployment
|
|
5238
|
-
* @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
|
|
5239
5259
|
*/
|
|
5240
5260
|
async withVanityAddress(cfg) {
|
|
5241
|
-
const chainId = this.publicClient?.chain?.id ||
|
|
5261
|
+
const chainId = this.publicClient?.chain?.id || 8453;
|
|
5242
5262
|
return withVanityAddress(cfg, chainId);
|
|
5243
5263
|
}
|
|
5244
5264
|
/**
|
|
5245
|
-
*
|
|
5246
|
-
* @param cfg Token configuration for V4 deployment or pre-built deployment data
|
|
5247
|
-
* @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
|
|
5248
5269
|
*/
|
|
5249
5270
|
async deployTokenV4(cfg) {
|
|
5250
5271
|
if (!this.wallet) {
|
|
@@ -5256,9 +5277,10 @@ var init_index = __esm({
|
|
|
5256
5277
|
return deployTokenV4(cfg, this.wallet, this.publicClient);
|
|
5257
5278
|
}
|
|
5258
5279
|
/**
|
|
5259
|
-
*
|
|
5260
|
-
* @param cfg Token configuration for V3 deployment
|
|
5261
|
-
* @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
|
|
5262
5284
|
*/
|
|
5263
5285
|
async deployToken(cfg) {
|
|
5264
5286
|
if (!this.wallet) {
|
|
@@ -5704,7 +5726,7 @@ RPC_URL=your_custom_rpc_url (if not provided, will use default Base RPC)
|
|
|
5704
5726
|
durationInDays: parseInt(answers.vaultConfig.durationInDays, 10)
|
|
5705
5727
|
} : void 0,
|
|
5706
5728
|
devBuy: answers.devBuy.ethAmount !== "0" ? {
|
|
5707
|
-
ethAmount: answers.devBuy.ethAmount,
|
|
5729
|
+
ethAmount: Number(answers.devBuy.ethAmount),
|
|
5708
5730
|
maxSlippage: answers.devBuy.maxSlippage
|
|
5709
5731
|
} : void 0,
|
|
5710
5732
|
rewardsConfig: {
|
|
@@ -56,7 +56,7 @@ var tokenConfigSchema = z.object({
|
|
|
56
56
|
})
|
|
57
57
|
}).optional(),
|
|
58
58
|
devBuy: z.object({
|
|
59
|
-
ethAmount: z.
|
|
59
|
+
ethAmount: z.number().optional()
|
|
60
60
|
}).optional(),
|
|
61
61
|
rewardsConfig: z.object({
|
|
62
62
|
creatorReward: z.number().min(0).max(1e4).refine(isValidBps, {
|
|
@@ -92,7 +92,7 @@ var poolConfigSchema = z.object({
|
|
|
92
92
|
var initialBuyConfigSchema = z.object({
|
|
93
93
|
pairedTokenPoolFee: z.number(),
|
|
94
94
|
pairedTokenSwapAmountOutMinimum: z.bigint(),
|
|
95
|
-
ethAmount: z.
|
|
95
|
+
ethAmount: z.number().optional()
|
|
96
96
|
});
|
|
97
97
|
var rewardsConfigSchema = z.object({
|
|
98
98
|
creatorReward: z.bigint().gte(0n, "Creator reward must be greater than or equal to 0"),
|
|
@@ -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,9 +4791,9 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4791
4791
|
},
|
|
4792
4792
|
lockerConfig: {
|
|
4793
4793
|
locker: CLANKER_LOCKER_V4,
|
|
4794
|
-
rewardAdmins: cfg.rewardsConfig?.
|
|
4795
|
-
rewardRecipients: cfg.rewardsConfig?.
|
|
4796
|
-
rewardBps: cfg.rewardsConfig?.
|
|
4794
|
+
rewardAdmins: cfg.rewardsConfig?.recipients.map((reward) => reward.admin) || [],
|
|
4795
|
+
rewardRecipients: cfg.rewardsConfig?.recipients.map((reward) => reward.recipient) || [],
|
|
4796
|
+
rewardBps: cfg.rewardsConfig?.recipients.map((reward) => reward.bps) || [],
|
|
4797
4797
|
tickLower: cfg.poolConfig?.positions.map((p) => p.tickLower) || [DEFAULT_TICK_LOWER],
|
|
4798
4798
|
tickUpper: cfg.poolConfig?.positions.map((p) => p.tickUpper) || [DEFAULT_TICK_UPPER],
|
|
4799
4799
|
positionBps: cfg.poolConfig?.positions.map((p) => p.positionBps) || [DEFAULT_POSITION_BPS],
|
|
@@ -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, [
|
|
@@ -4838,10 +4838,10 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4838
4838
|
}
|
|
4839
4839
|
] : [],
|
|
4840
4840
|
// devBuy extension
|
|
4841
|
-
...cfg.devBuy && cfg.devBuy.ethAmount !==
|
|
4841
|
+
...cfg.devBuy && cfg.devBuy.ethAmount !== 0 ? [
|
|
4842
4842
|
{
|
|
4843
|
-
extension:
|
|
4844
|
-
msgValue: BigInt(
|
|
4843
|
+
extension: CLANKER_DEVBUY_V4,
|
|
4844
|
+
msgValue: BigInt(cfg.devBuy.ethAmount * 1e18),
|
|
4845
4845
|
extensionBps: 0,
|
|
4846
4846
|
extensionData: encodeAbiParameters2(DEVBUY_EXTENSION_PARAMETERS, [
|
|
4847
4847
|
DEVBUY_POOL_CONFIG,
|
|
@@ -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]
|
|
@@ -4861,7 +4861,7 @@ function buildTokenV4(cfg, chainId, salt) {
|
|
|
4861
4861
|
transaction: {
|
|
4862
4862
|
to: CLANKER_FACTORY_V4,
|
|
4863
4863
|
data: deployCalldata,
|
|
4864
|
-
value: cfg.devBuy && cfg.devBuy.ethAmount !==
|
|
4864
|
+
value: cfg.devBuy && cfg.devBuy.ethAmount !== 0 ? BigInt(cfg.devBuy.ethAmount * 1e18) : BigInt(0)
|
|
4865
4865
|
},
|
|
4866
4866
|
expectedAddress: "0x0000000000000000000000000000000000000000",
|
|
4867
4867
|
chainId
|
|
@@ -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) {
|
|
@@ -5434,7 +5456,7 @@ RPC_URL=your_custom_rpc_url (if not provided, will use default Base RPC)
|
|
|
5434
5456
|
durationInDays: parseInt(answers.vaultConfig.durationInDays, 10)
|
|
5435
5457
|
} : void 0,
|
|
5436
5458
|
devBuy: answers.devBuy.ethAmount !== "0" ? {
|
|
5437
|
-
ethAmount: answers.devBuy.ethAmount,
|
|
5459
|
+
ethAmount: Number(answers.devBuy.ethAmount),
|
|
5438
5460
|
maxSlippage: answers.devBuy.maxSlippage
|
|
5439
5461
|
} : void 0,
|
|
5440
5462
|
rewardsConfig: {
|