UNPKG

@agentek/tools

Version:

Blockchain tools for AI agents

192 lines 9.59 kB
"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"), 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"), creatorSupply: 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%"), creator: utils_js_1.addressSchema.describe("Ethereum Address of the Creator"), unlockPeriod: zod_1.z.number().describe("Number of days until unlock e.g. 180"), vesting: zod_1.z.boolean(), value: zod_1.z.bigint() }), 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: 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", supportedChains: constants_js_1.supportedChains, parameters: zod_1.z.object({ chainId: zod_1.z.number(), coinId: zod_1.z.string().describe("ID of the Coinchan token"), }), 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", supportedChains: constants_js_1.supportedChains, parameters: zod_1.z.object({ chainId: zod_1.z.number(), name: zod_1.z.string(), symbol: zod_1.z.string(), tokenURI: zod_1.z.string(), poolSupply: zod_1.z.bigint(), creatorSupply: zod_1.z.bigint(), swapFee: zod_1.z.bigint(), creator: utils_js_1.addressSchema.describe("Ethereum Address of the creator"), value: zod_1.z.bigint() }), 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, poolSupply, creatorSupply, swapFee, creator ] }); ops.push({ target: constants_js_1.CoinchanAddress, value: 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", supportedChains: constants_js_1.supportedChains, parameters: zod_1.z.object({ chainId: zod_1.z.number(), coinId: zod_1.z.bigint(), recipients: zod_1.z.array(utils_js_1.addressSchema).describe("Array of recipient addresses"), amounts: zod_1.z.array(zod_1.z.bigint()).describe("Array of token amounts"), totalSum: zod_1.z.bigint().describe("Total sum to transfer from sender"), }), 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: [coinId, recipients, amounts, 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