@agentek/tools
Version:
Blockchain tools for AI agents
65 lines • 3.04 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.coinchanGetVestableAmount = exports.coinchanGetCoinsCount = exports.coinchanGetCoins = void 0;
const client_js_1 = require("../client.js");
const zod_1 = require("zod");
const constants_js_1 = require("./constants.js");
exports.coinchanGetCoins = (0, client_js_1.createTool)({
name: "coinchanGetCoins",
description: "Fetch a list of Coinchan token IDs between index ranges. Use coinchanGetCoinsCount first to know the valid range.",
supportedChains: constants_js_1.supportedChains,
parameters: zod_1.z.object({
chainId: zod_1.z.number().describe("Chain ID (e.g. 8453 for Base)"),
start: zod_1.z.number().describe("Start index (0-based) of the token range to fetch"),
finish: zod_1.z.number().describe("End index (exclusive) of the token range to fetch"),
}),
execute: async (client, args) => {
const { chainId, start, finish } = args;
const publicClient = client.getPublicClient(chainId);
const coins = await publicClient.readContract({
address: constants_js_1.CoinchanAddress,
abi: constants_js_1.CoinchanAbi,
functionName: "getCoins",
args: [start, finish]
});
return { start, finish, coins };
}
});
exports.coinchanGetCoinsCount = (0, client_js_1.createTool)({
name: "coinchanGetCoinsCount",
description: "Get the total number of Coinchan tokens created on the given chain.",
supportedChains: constants_js_1.supportedChains,
parameters: zod_1.z.object({ chainId: zod_1.z.number().describe("Chain ID (e.g. 8453 for Base)") }),
execute: async (client, args) => {
const { chainId } = args;
const publicClient = client.getPublicClient(chainId);
const count = await publicClient.readContract({
address: constants_js_1.CoinchanAddress,
abi: constants_js_1.CoinchanAbi,
functionName: "getCoinsCount",
args: []
});
return { count };
}
});
exports.coinchanGetVestableAmount = (0, client_js_1.createTool)({
name: "coinchanGetVestableAmount",
description: "Get the amount of liquidity currently available to vest for a locked Coinchan token.",
supportedChains: constants_js_1.supportedChains,
parameters: zod_1.z.object({
chainId: zod_1.z.number().describe("Chain ID (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 publicClient = client.getPublicClient(chainId);
const vestable = await publicClient.readContract({
address: constants_js_1.CoinchanAddress,
abi: constants_js_1.CoinchanAbi,
functionName: "getVestableAmount",
args: [BigInt(coinId)]
});
return { coinId, vestable: vestable.toString() };
}
});
//# sourceMappingURL=tools.js.map