@agentek/tools
Version:
Blockchain tools for AI agents
192 lines • 10.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.intentCoinchanAirdrop = exports.intentCoinchanMakeHold = exports.intentCoinchanClaimVested = exports.intentCoinchanMakeLocked = exports.intentCoinchanMake = void 0;
const client_js_1 = require("../client.js");
const zod_1 = require("zod");
const constants_js_1 = require("./constants.js");
const viem_1 = require("viem");
const utils_js_1 = require("../utils.js");
exports.intentCoinchanMake = (0, client_js_1.createTool)({
name: "intentCoinchanMake",
description: "Create a new Coinchan token, mint supplies and add initial liquidity via ZAMM",
supportedChains: constants_js_1.supportedChains,
parameters: zod_1.z.object({
chainId: zod_1.z.number().describe("Chain ID for execution"),
name: zod_1.z.string().describe("Name of the token"),
symbol: zod_1.z.string().describe("Symbol of the token"),
tokenURI: zod_1.z.string().describe("A valid URL to token metadata like name, description, and image url"),
poolSupply: zod_1.z.string().describe("Amount of token to add to pool in human readable format"),
ownerSupply: zod_1.z.string().describe("Amount of token to transfer to owner in human readable format"),
swapFee: zod_1.z.number().describe("Swap fee for the pool e.g. 100 for 1%"),
owner: utils_js_1.addressSchema.describe("Address receiving owner supply and pool liquidity"),
value: zod_1.z.string().describe("Native token value in human readable Ether format representing liquidity funded")
}),
execute: async (client, args) => {
// @TODO: Helper tools to create for generating token URI
const { chainId, name, symbol, tokenURI, poolSupply, ownerSupply, swapFee, owner, value } = args;
const ops = [];
const poolSupplyFormatted = (0, viem_1.parseEther)(poolSupply);
const ownerSupplyFormatted = (0, viem_1.parseEther)(ownerSupply);
const swapFeeFormatted = BigInt(swapFee);
const data = (0, viem_1.encodeFunctionData)({
abi: constants_js_1.CoinchanAbi,
functionName: "make",
args: [
name,
symbol,
tokenURI,
poolSupplyFormatted,
ownerSupplyFormatted,
swapFeeFormatted,
owner
]
});
ops.push({ target: constants_js_1.CoinchanAddress, value: (0, viem_1.parseEther)(value).toString(), data: data });
const intentDescription = `Create coin ${symbol} and add liquidity`;
const walletClient = client.getWalletClient(chainId);
if (!walletClient) {
return { intent: intentDescription, ops, chain: chainId };
}
const hash = await client.executeOps(ops, chainId);
return { intent: intentDescription, ops, chain: chainId, hash };
}
});
exports.intentCoinchanMakeLocked = (0, client_js_1.createTool)({
name: "intentCoinchanMakeLocked",
description: "Create a new Coinchan token with locked liquidity and optional vesting schedule.",
supportedChains: constants_js_1.supportedChains,
parameters: zod_1.z.object({
chainId: zod_1.z.number().describe("Chain ID for execution (e.g. 8453 for Base)"),
name: zod_1.z.string().describe("Name of the token"),
symbol: zod_1.z.string().describe("Symbol of the token"),
tokenURI: zod_1.z.string().describe("A valid URL to token metadata like name, description, and image url"),
poolSupply: zod_1.z.string().describe("Amount of token to add to pool in human readable format (e.g. '1000')"),
creatorSupply: zod_1.z.string().describe("Amount of token to transfer to creator in human readable format (e.g. '100')"),
swapFee: zod_1.z.number().describe("Swap fee for the pool in basis points (e.g. 100 for 1%)"),
creator: utils_js_1.addressSchema.describe("Ethereum address of the creator"),
unlockPeriod: zod_1.z.number().describe("Number of days until liquidity unlock (e.g. 180)"),
vesting: zod_1.z.boolean().describe("Whether to enable linear vesting of locked liquidity over the unlock period"),
value: zod_1.z.string().describe("Native ETH value in wei as a decimal string to fund initial liquidity"),
}),
execute: async (client, args) => {
const { chainId, name, symbol, tokenURI, poolSupply, creatorSupply, swapFee, creator, unlockPeriod, vesting, value } = args;
const ops = [];
const unlockTime = BigInt(unlockPeriod * 24 * 60 * 60); // Convert days to seconds until unlock
const data = (0, viem_1.encodeFunctionData)({
abi: constants_js_1.CoinchanAbi,
functionName: "makeLocked",
args: [
name,
symbol,
tokenURI,
(0, viem_1.parseEther)(poolSupply),
(0, viem_1.parseEther)(creatorSupply),
BigInt(swapFee),
creator,
unlockTime,
vesting
]
});
ops.push({ target: constants_js_1.CoinchanAddress, value: BigInt(value).toString(), data: data });
const intentDescription = `Make coin ${symbol} with locked liquidity`;
const walletClient = client.getWalletClient(chainId);
if (!walletClient) {
return { intent: intentDescription, ops, chain: chainId };
}
const hash = await client.executeOps(ops, chainId);
return { intent: intentDescription, ops, chain: chainId, hash };
}
});
exports.intentCoinchanClaimVested = (0, client_js_1.createTool)({
name: "intentCoinchanClaimVested",
description: "Claim vested liquidity for a locked Coinchan token. Only works if vesting was enabled at creation.",
supportedChains: constants_js_1.supportedChains,
parameters: zod_1.z.object({
chainId: zod_1.z.number().describe("Chain ID for execution (e.g. 8453 for Base)"),
coinId: zod_1.z.string().describe("The Coinchan token ID as a decimal string"),
}),
execute: async (client, args) => {
const { chainId, coinId } = args;
const ops = [];
const data = (0, viem_1.encodeFunctionData)({ abi: constants_js_1.CoinchanAbi, functionName: "claimVested", args: [BigInt(coinId)] });
ops.push({ target: constants_js_1.CoinchanAddress, value: "0", data: data });
const intentDescription = `Claim vested liquidity for coin ${coinId}`;
const walletClient = client.getWalletClient(chainId);
if (!walletClient) {
return { intent: intentDescription, ops, chain: chainId };
}
const hash = await client.executeOps(ops, chainId);
return { intent: intentDescription, ops, chain: chainId, hash };
}
});
exports.intentCoinchanMakeHold = (0, client_js_1.createTool)({
name: "intentCoinchanMakeHold",
description: "Create a new Coinchan token and hold liquidity for the creator instead of locking it.",
supportedChains: constants_js_1.supportedChains,
parameters: zod_1.z.object({
chainId: zod_1.z.number().describe("Chain ID for execution (e.g. 8453 for Base)"),
name: zod_1.z.string().describe("Name of the token"),
symbol: zod_1.z.string().describe("Symbol of the token"),
tokenURI: zod_1.z.string().describe("A valid URL to token metadata like name, description, and image url"),
poolSupply: zod_1.z.string().describe("Amount of token to add to pool in wei as a decimal string"),
creatorSupply: zod_1.z.string().describe("Amount of token to transfer to creator in wei as a decimal string"),
swapFee: zod_1.z.string().describe("Swap fee for the pool as a decimal string (e.g. '100' for 1%)"),
creator: utils_js_1.addressSchema.describe("Ethereum address of the creator"),
value: zod_1.z.string().describe("Native ETH value in wei as a decimal string to fund initial liquidity"),
}),
execute: async (client, args) => {
const { chainId, name, symbol, tokenURI, poolSupply, creatorSupply, swapFee, creator, value } = args;
const ops = [];
const data = (0, viem_1.encodeFunctionData)({
abi: constants_js_1.CoinchanAbi,
functionName: "makeHold",
args: [
name,
symbol,
tokenURI,
BigInt(poolSupply),
BigInt(creatorSupply),
BigInt(swapFee),
creator
]
});
ops.push({ target: constants_js_1.CoinchanAddress, value: BigInt(value).toString(), data: data });
const intentDescription = `Create coin ${symbol} and hold liquidity`;
const walletClient = client.getWalletClient(chainId);
if (!walletClient) {
return { intent: intentDescription, ops, chain: chainId };
}
const hash = await client.executeOps(ops, chainId);
return { intent: intentDescription, ops, chain: chainId, hash };
}
});
exports.intentCoinchanAirdrop = (0, client_js_1.createTool)({
name: "intentCoinchanAirdrop",
description: "Airdrop a Coinchan token to multiple addresses in a single transaction.",
supportedChains: constants_js_1.supportedChains,
parameters: zod_1.z.object({
chainId: zod_1.z.number().describe("Chain ID for execution (e.g. 8453 for Base)"),
coinId: zod_1.z.string().describe("The Coinchan token ID as a decimal string"),
recipients: zod_1.z.array(utils_js_1.addressSchema).describe("Array of recipient Ethereum addresses"),
amounts: zod_1.z.array(zod_1.z.string()).describe("Array of token amounts in wei as decimal strings, one per recipient"),
totalSum: zod_1.z.string().describe("Total sum of all amounts in wei as a decimal string"),
}),
execute: async (client, args) => {
const { chainId, coinId, recipients, amounts, totalSum } = args;
const ops = [];
const data = (0, viem_1.encodeFunctionData)({
abi: constants_js_1.CoinchanAbi,
functionName: "airdrop",
args: [BigInt(coinId), recipients, amounts.map(a => BigInt(a)), BigInt(totalSum)]
});
ops.push({ target: constants_js_1.CoinchanAddress, value: "0", data: data });
const intentDescription = `Coinchan.airdrop: distribute token ${coinId} to multiple recipients`;
const walletClient = client.getWalletClient(chainId);
if (!walletClient) {
return { intent: intentDescription, ops, chain: chainId };
}
const hash = await client.executeOps(ops, chainId);
return { intent: intentDescription, ops, chain: chainId, hash };
}
});
//# sourceMappingURL=intents.js.map