Added refactoring changes for agent, action and tools

This commit is contained in:
0xCipherCoder
2025-01-10 17:34:13 +05:30
parent 75af298812
commit 7032ed7d99
220 changed files with 2907 additions and 2701 deletions

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { create_image } from "../tools/create_image";
import { create_image } from "../../tools/agent";
const createImageAction: Action = {
name: "CREATE_IMAGE",

View File

@@ -1,7 +1,7 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { SolanaAgentKit } from "..";
import { get_wallet_address } from "../tools";
import { Action } from "../types/action";
import { get_wallet_address } from "../../tools/agent";
const getWalletAddressAction: Action = {
name: "GET_WALLET_ADDRESS",

View File

@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { get_balance } from "../tools";
import { get_balance } from "../../tools/balance";
const balanceAction: Action = {
name: "BALANCE_ACTION",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getTokenDataByTicker } from "../tools";
import { getTokenDataByTicker } from "../../tools/dexscreener";
const tokenDataByTickerAction: Action = {
name: "GET_TOKEN_DATA_BY_TICKER",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getAllDomainsTLDs } from "../tools";
import { getAllDomainsTLDs } from "../../tools/domain";
const getAllDomainsTLDsAction: Action = {
name: "GET_ALL_TLDS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getAllRegisteredAllDomains } from "../tools";
import { getAllRegisteredAllDomains } from "../../tools/domain";
const getAllRegisteredAllDomainsAction: Action = {
name: "GET_ALL_REGISTERED_ALL_DOMAINS",

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { getMainAllDomainsDomain } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getMainAllDomainsDomain } from "../../tools/domain";
const getMainAllDomainsDomainAction: Action = {
name: "GET_MAIN_ALL_DOMAINS_DOMAIN",

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { getOwnedAllDomains } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getOwnedAllDomains } from "../../tools/domain";
const getOwnedAllDomainsAction: Action = {
name: "GET_OWNED_ALL_DOMAINS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getOwnedDomainsForTLD } from "../tools";
import { getOwnedDomainsForTLD } from "../../tools/domain";
const getOwnedDomainsForTLDAction: Action = {
name: "GET_OWNED_DOMAINS_FOR_TLD",

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { getPrimaryDomain } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getPrimaryDomain } from "../../tools/domain";
const getPrimaryDomainAction: Action = {
name: "GET_PRIMARY_DOMAIN",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { registerDomain } from "../tools";
import { registerDomain } from "../../tools/domain";
const registerDomainAction: Action = {
name: "REGISTER_DOMAIN",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { resolveAllDomains } from "../tools";
import { resolveAllDomains } from "../../tools/domain";
const resolveDomainAction: Action = {
name: "RESOLVE_ALL_DOMAINS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { resolveSolDomain } from "../tools";
import { resolveSolDomain } from "../../tools/domain";
const resolveSolDomainAction: Action = {
name: "RESOLVE_SOL_DOMAIN",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { flashCloseTrade } from "../tools";
import { flashCloseTrade } from "../../tools/flash";
const flashCloseTradeAction: Action = {
name: "FLASH_CLOSE_TRADE",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { flashOpenTrade } from "../tools";
import { flashOpenTrade } from "../../tools/flash";
const flashOpenTradeAction: Action = {
name: "FLASH_OPEN_TRADE",

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { create_gibwork_task } from "../tools";
import { create_gibwork_task } from "../../tools/gibwork";
const createGibworkTaskAction: Action = {
name: "CREATE_GIBWORK_TASK",

View File

@@ -1,35 +1,35 @@
import deployTokenAction from "./deployToken";
import balanceAction from "./balance";
import transferAction from "./transfer";
import deployCollectionAction from "./deployCollection";
import mintNFTAction from "./mintNFT";
import tradeAction from "./trade";
import requestFundsAction from "./requestFunds";
import resolveDomainAction from "./resolveDomain";
import getTokenDataAction from "./getTokenData";
import getTPSAction from "./getTPS";
import fetchPriceAction from "./fetchPrice";
import stakeWithJupAction from "./stakeWithJup";
import stakeWithSolayerAction from "./stakeWithSolayer";
import registerDomainAction from "./registerDomain";
import lendAssetAction from "./lendAsset";
import createGibworkTaskAction from "./createGibworkTask";
import resolveSolDomainAction from "./resolveSolDomain";
import pythFetchPriceAction from "./pythFetchPrice";
import getOwnedDomainsForTLDAction from "./getOwnedDomainsForTLD";
import getPrimaryDomainAction from "./getPrimaryDomain";
import getAllDomainsTLDsAction from "./getAllDomainsTLDs";
import getOwnedAllDomainsAction from "./getOwnedAllDomains";
import createImageAction from "./createImage";
import getMainAllDomainsDomainAction from "./getMainAllDomainsDomain";
import getAllRegisteredAllDomainsAction from "./getAllRegisteredAllDomains";
import raydiumCreateCpmmAction from "./raydiumCreateCpmm";
import raydiumCreateAmmV4Action from "./raydiumCreateAmmV4";
import createOrcaSingleSidedWhirlpoolAction from "./createOrcaSingleSidedWhirlpool";
import launchPumpfunTokenAction from "./launchPumpfunToken";
import getWalletAddressAction from "./getWalletAddress";
import flashOpenTradeAction from "./flashOpenTrade";
import flashCloseTradeAction from "./flashCloseTrade";
import deployTokenAction from "./token/deployToken";
import balanceAction from "./balance/balance";
import transferAction from "./token/transfer";
import deployCollectionAction from "./metaplex/deployCollection";
import mintNFTAction from "./metaplex/mintNFT";
import tradeAction from "./jupiter/trade";
import requestFundsAction from "./solana/requestFunds";
import resolveDomainAction from "./domain/registerDomain";
import getTokenDataAction from "./jupiter/getTokenData";
import getTPSAction from "./solana/getTPS";
import fetchPriceAction from "./jupiter/fetchPrice";
import stakeWithJupAction from "./jupiter/stakeWithJup";
import stakeWithSolayerAction from "./solayer/stakeWithSolayer";
import registerDomainAction from "./domain/registerDomain";
import lendAssetAction from "./lulo/lendAsset";
import createGibworkTaskAction from "./gibwork/createGibworkTask";
import resolveSolDomainAction from "./domain/resolveSolDomain";
import pythFetchPriceAction from "./pyth/pythFetchPrice";
import getOwnedDomainsForTLDAction from "./domain/getOwnedDomainsForTLD";
import getPrimaryDomainAction from "./domain/getPrimaryDomain";
import getAllDomainsTLDsAction from "./domain/getAllDomainsTLDs";
import getOwnedAllDomainsAction from "./domain/getOwnedAllDomains";
import createImageAction from "./agent/createImage";
import getMainAllDomainsDomainAction from "./domain/getMainAllDomainsDomain";
import getAllRegisteredAllDomainsAction from "./domain/getAllRegisteredAllDomains";
import raydiumCreateCpmmAction from "./raydium/raydiumCreateCpmm";
import raydiumCreateAmmV4Action from "./raydium/raydiumCreateAmmV4";
import createOrcaSingleSidedWhirlpoolAction from "./orca/createOrcaSingleSidedWhirlpool";
import launchPumpfunTokenAction from "./pumpfun/launchPumpfunToken";
import getWalletAddressAction from "./agent/getWalletAddress";
import flashOpenTradeAction from "./flash/flashOpenTrade";
import flashCloseTradeAction from "./flash/flashCloseTrade";
export const ACTIONS = {
WALLET_ADDRESS_ACTION: getWalletAddressAction,

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { fetchPrice } from "../tools";
import { fetchPrice } from "../../tools/jupiter";
const fetchPriceAction: Action = {
name: "FETCH_PRICE",

View File

@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { JupiterTokenData } from "../types";
import { getTokenAddressFromTicker, getTokenDataByAddress } from "../tools";
import { JupiterTokenData } from "../../types";
import { getTokenAddressFromTicker, getTokenDataByAddress } from "../../tools";
const getTokenDataAction: Action = {
name: "GET_TOKEN_DATA",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { stakeWithJup } from "../tools";
import { stakeWithJup } from "../../tools";
const stakeWithJupAction: Action = {
name: "STAKE_WITH_JUPITER",

View File

@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { trade } from "../tools";
import { trade } from "../../tools";
const tradeAction: Action = {
name: "TRADE",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { lendAsset } from "../tools";
import { lendAsset } from "../../tools/lulo";
const lendAssetAction: Action = {
name: "LEND_ASSET",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { deploy_collection } from "../tools";
import { deploy_collection } from "../../tools/metaplex";
interface CollectionOptions {
name: string;

View File

@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { mintCollectionNFT } from "../tools";
import { mintCollectionNFT } from "../../tools/metaplex";
const mintNFTAction: Action = {
name: "MINT_NFT",

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { openbookCreateMarket } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { openbookCreateMarket } from "../../tools/openbook";
const createOpenbookMarketAction: Action = {
name: "CREATE_OPENBOOK_MARKET",

View File

@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { Decimal } from "decimal.js";
import { orcaCreateSingleSidedLiquidityPool } from "../tools";
import { orcaCreateSingleSidedLiquidityPool } from "../../tools";
// Fee tiers mapping from the original tool
const FEE_TIERS = {

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { launchPumpFunToken } from "../tools";
import { launchPumpFunToken } from "../../tools";
const launchPumpfunTokenAction: Action = {
name: "LAUNCH_PUMPFUN_TOKEN",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { fetchPythPrice, fetchPythPriceFeedID } from "../tools";
import { fetchPythPrice, fetchPythPriceFeedID } from "../../tools";
const pythFetchPriceAction: Action = {
name: "PYTH_FETCH_PRICE",

View File

@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import { raydiumCreateAmmV4 } from "../tools";
import { raydiumCreateAmmV4 } from "../../tools";
const raydiumCreateAmmV4Action: Action = {
name: "RAYDIUM_CREATE_AMM_V4",

View File

@@ -1,10 +1,10 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { BN } from "@coral-xyz/anchor";
import Decimal from "decimal.js";
import { raydiumCreateClmm } from "../tools";
import { raydiumCreateClmm } from "../../tools";
const raydiumCreateClmmAction: Action = {
name: "RAYDIUM_CREATE_CLMM",

View File

@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import { raydiumCreateCpmm } from "../tools";
import { raydiumCreateCpmm } from "../../tools";
const raydiumCreateCpmmAction: Action = {
name: "RAYDIUM_CREATE_CPMM",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getTPS } from "../tools";
import { getTPS } from "../../tools/solana";
const getTPSAction: Action = {
name: "GET_TPS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { request_faucet_funds } from "../tools";
import { request_faucet_funds } from "../../tools/solana";
const requestFundsAction: Action = {
name: "REQUEST_FUNDS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { stakeWithSolayer } from "../tools";
import { stakeWithSolayer } from "../../tools";
const stakeWithSolayerAction: Action = {
name: "STAKE_WITH_SOLAYER",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { closeEmptyTokenAccounts } from "../tools";
import { closeEmptyTokenAccounts } from "../../tools";
const closeEmptyTokenAccountsAction: Action = {
name: "CLOSE_EMPTY_TOKEN_ACCOUNTS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { sendCompressedAirdrop } from "../tools";
import { sendCompressedAirdrop } from "../../tools";
const compressedAirdropAction: Action = {
name: "COMPRESSED_AIRDROP",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { deploy_token } from "../tools";
import { deploy_token } from "../../tools";
const deployTokenAction: Action = {
name: "DEPLOY_TOKEN",

View File

@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { transfer } from "../tools";
import { transfer } from "../../tools";
const transferAction: Action = {
name: "TRANSFER",

View File

@@ -63,7 +63,7 @@ import {
fetchPythPriceFeedID,
flashOpenTrade,
flashCloseTrade,
} from "../tools";
} from "../tools/";
import {
CollectionDeployment,
CollectionOptions,
@@ -79,7 +79,7 @@ import {
import {
createCollection,
createSingle,
} from "../tools/create_3land_collectible";
} from "../tools/3land/create_3land_collectible";
import {
CreateCollectionOptions,
CreateSingleOptions,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
import { BaseSolanaTool } from "../common/base.tool";
import {
CreateCollectionOptions,
StoreInitOptions,
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
export class Solana3LandCreateCollection extends BaseSolanaTool {
name = "3land_minting_tool";
description = `Creates an NFT Collection that you can visit on 3.land's website (3.land/collection/{collectionAccount})
Inputs:
privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string
isMainnet (required): defines is the tx takes places in mainnet
collectionSymbol (required): the symbol of the collection
collectionName (required): the name of the collection
collectionDescription (required): the description of the collection
mainImageUrl (required): the image of the collection
coverImageUrl (optional): the cover image of the collection`;
protected async _call(input: string): Promise<string> {
try {
const inputFormat = JSON.parse(input);
const privateKey = inputFormat.privateKey;
const isMainnet = inputFormat.isMainnet;
const optionsWithBase58: StoreInitOptions = {
...(privateKey && { privateKey }),
...(isMainnet && { isMainnet }),
};
const collectionSymbol = inputFormat?.collectionSymbol;
const collectionName = inputFormat?.collectionName;
const collectionDescription = inputFormat?.collectionDescription;
const mainImageUrl = inputFormat?.mainImageUrl;
const coverImageUrl = inputFormat?.coverImageUrl;
const collectionOpts: CreateCollectionOptions = {
...(collectionSymbol && { collectionSymbol }),
...(collectionName && { collectionName }),
...(collectionDescription && { collectionDescription }),
...(mainImageUrl && { mainImageUrl }),
...(coverImageUrl && { coverImageUrl }),
};
const tx = await this.solanaKit.create3LandCollection(
optionsWithBase58,
collectionOpts,
);
return JSON.stringify({
status: "success",
message: `Created Collection successfully ${tx}`,
transaction: tx,
});
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,81 @@
import { BaseSolanaTool } from "../common/base.tool";
import {
CreateSingleOptions,
StoreInitOptions,
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
export class Solana3LandCreateSingle extends BaseSolanaTool {
name = "3land_minting_tool";
description = `Creates an NFT and lists it on 3.land's website
Inputs:
privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string
collectionAccount (optional): represents the account for the nft collection
itemName (required): the name of the NFT
sellerFee (required): the fee of the seller
itemAmount (required): the amount of the NFTs that can be minted
itemDescription (required): the description of the NFT
traits (required): the traits of the NFT [{trait_type: string, value: string}]
price (required): the price of the item, if is 0 the listing will be free
mainImageUrl (required): the main image of the NFT
coverImageUrl (optional): the cover image of the NFT
splHash (optional): the hash of the spl token, if not provided listing will be in $SOL
isMainnet (required): defines is the tx takes places in mainnet`;
protected async _call(input: string): Promise<string> {
try {
const inputFormat = JSON.parse(input);
const privateKey = inputFormat.privateKey;
const isMainnet = inputFormat.isMainnet;
const optionsWithBase58: StoreInitOptions = {
...(privateKey && { privateKey }),
...(isMainnet && { isMainnet }),
};
const collectionAccount = inputFormat.collectionAccount;
const itemName = inputFormat?.itemName;
const sellerFee = inputFormat?.sellerFee;
const itemAmount = inputFormat?.itemAmount;
const itemSymbol = inputFormat?.itemSymbol;
const itemDescription = inputFormat?.itemDescription;
const traits = inputFormat?.traits;
const price = inputFormat?.price;
const mainImageUrl = inputFormat?.mainImageUrl;
const coverImageUrl = inputFormat?.coverImageUrl;
const splHash = inputFormat?.splHash;
const createItemOptions: CreateSingleOptions = {
...(itemName && { itemName }),
...(sellerFee && { sellerFee }),
...(itemAmount && { itemAmount }),
...(itemSymbol && { itemSymbol }),
...(itemDescription && { itemDescription }),
...(traits && { traits }),
...(price && { price }),
...(mainImageUrl && { mainImageUrl }),
...(coverImageUrl && { coverImageUrl }),
...(splHash && { splHash }),
};
if (!collectionAccount) {
throw new Error("Collection account is required");
}
const tx = await this.solanaKit.create3LandNft(
optionsWithBase58,
collectionAccount,
createItemOptions,
isMainnet,
);
return JSON.stringify({
status: "success",
message: `Created listing successfully ${tx}`,
transaction: tx,
});
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,2 @@
export * from "./create-single.tool";
export * from "./create-collection.tool";

View File

@@ -0,0 +1,39 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { PerpTradeResponse } from "./types";
export class SolanaPerpCloseTradeTool extends BaseSolanaTool {
name = "solana_close_perp_trade";
description = `This tool can be used to close perpetuals trade ( It uses Adrena Protocol ).
Inputs ( input is a JSON string ):
tradeMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn", "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" etc. (optional)
price?: number, eg 100 (optional)
side: string, eg: "long" or "short"`;
protected async _call(input: string): Promise<string> {
try {
const params = JSON.parse(input);
const tx =
params.side === "long"
? await this.solanaKit.closePerpTradeLong({
price: params.price,
tradeMint: new PublicKey(params.tradeMint),
})
: await this.solanaKit.closePerpTradeShort({
price: params.price,
tradeMint: new PublicKey(params.tradeMint),
});
return JSON.stringify({
status: "success",
message: "Perpetual trade closed successfully",
transaction: tx,
...params,
} as PerpTradeResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,2 @@
export * from "./open-trade.tool";
export * from "./close-trade.tool";

View File

@@ -0,0 +1,51 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { PerpTradeResponse } from "./types";
export class SolanaPerpOpenTradeTool extends BaseSolanaTool {
name = "solana_open_perp_trade";
description = `This tool can be used to open perpetuals trade ( It uses Adrena Protocol ).
Inputs ( input is a JSON string ):
collateralAmount: number, eg 1 or 0.01 (required)
collateralMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn" or "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" etc. (optional)
tradeMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn", "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" etc. (optional)
leverage: number, eg 50000 = x5, 100000 = x10, 1000000 = x100 (optional)
price?: number, eg 100 (optional)
slippage?: number, eg 0.3 (optional)
side: string, eg: "long" or "short"`;
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx =
parsedInput.side === "long"
? await this.solanaKit.openPerpTradeLong({
price: parsedInput.price,
collateralAmount: parsedInput.collateralAmount,
collateralMint: new PublicKey(parsedInput.collateralMint),
leverage: parsedInput.leverage,
tradeMint: new PublicKey(parsedInput.tradeMint),
slippage: parsedInput.slippage,
})
: await this.solanaKit.openPerpTradeLong({
price: parsedInput.price,
collateralAmount: parsedInput.collateralAmount,
collateralMint: new PublicKey(parsedInput.collateralMint),
leverage: parsedInput.leverage,
tradeMint: new PublicKey(parsedInput.tradeMint),
slippage: parsedInput.slippage,
});
return JSON.stringify({
status: "success",
message: "Perpetual trade opened successfully",
transaction: tx,
...parsedInput,
} as PerpTradeResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,29 @@
import { BaseToolResponse } from "../common/types";
export interface PerpCloseTradeInput {
tradeMint: string;
price?: number;
side: "long" | "short";
}
export interface PerpOpenTradeInput {
collateralAmount: number;
collateralMint?: string;
tradeMint?: string;
leverage?: number;
price?: number;
slippage?: number;
side: "long" | "short";
}
export interface PerpTradeResponse extends BaseToolResponse {
transaction?: string;
price?: number;
tradeMint?: string;
side?: "long" | "short";
collateralAmount?: number;
collateralMint?: string;
leverage?: number;
slippage?: number;
token?: string;
}

View File

@@ -0,0 +1,30 @@
import { BaseSolanaTool } from "../common/base.tool";
import { CreateImageResponse } from "./types";
import { create_image } from "../../../tools/agent";
export class SolanaCreateImageTool extends BaseSolanaTool {
name = "solana_create_image";
description =
"Create an image using OpenAI's DALL-E. Input should be a string prompt for the image.";
private validateInput(input: string): void {
if (typeof input !== "string" || input.trim().length === 0) {
throw new Error("Input must be a non-empty string prompt");
}
}
protected async _call(input: string): Promise<string> {
try {
this.validateInput(input);
const result = await create_image(this.solanaKit, input.trim());
return JSON.stringify({
status: "success",
message: "Image created successfully",
...result,
} as CreateImageResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,2 @@
export * from "./create-image.tool";
export * from "./wallet-address.tool";

View File

@@ -0,0 +1,9 @@
import { BaseToolResponse } from "../common/types";
export interface CreateImageResponse extends BaseToolResponse {
images?: string[];
}
export interface WalletAddressResponse extends BaseToolResponse {
address?: string;
}

View File

@@ -0,0 +1,15 @@
import { BaseSolanaTool } from "../common/base.tool";
import { WalletAddressResponse } from "./types";
export class SolanaGetWalletAddressTool extends BaseSolanaTool {
name = "solana_get_wallet_address";
description = "Get the wallet address of the agent";
async _call(_input: string): Promise<string> {
return JSON.stringify({
status: "success",
message: "Wallet address retrieved successfully",
address: this.solanaKit.wallet_address.toString(),
} as WalletAddressResponse);
}
}

View File

@@ -0,0 +1,37 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { BalanceOtherToolInput, BalanceOtherToolResponse } from "./types";
export class SolanaBalanceOtherTool extends BaseSolanaTool {
name = "solana_balance_other";
description = `Get the balance of a Solana wallet or token account which is different from the agent's wallet.
If no tokenAddress is provided, the SOL balance of the wallet will be returned.
Inputs ( input is a JSON string ):
walletAddress: string, eg "GDEkQF7UMr7RLv1KQKMtm8E2w3iafxJLtyXu3HVQZnME" (required)
tokenAddress: string, eg "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (optional)`;
protected async _call(input: string): Promise<string> {
try {
const params: BalanceOtherToolInput = JSON.parse(input);
const tokenPubKey = params.tokenAddress
? new PublicKey(params.tokenAddress)
: undefined;
const balance = await this.solanaKit.getBalanceOther(
new PublicKey(params.walletAddress),
tokenPubKey,
);
return JSON.stringify({
status: "success",
balance,
wallet: params.walletAddress,
token: params.tokenAddress || "SOL",
} as BalanceOtherToolResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,32 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { BalanceToolInput, BalanceToolResponse } from "./types";
export class SolanaBalanceTool extends BaseSolanaTool {
name = "solana_balance";
description = `Get the balance of a Solana wallet or token account.
If you want to get the balance of your wallet, you don't need to provide the tokenAddress.
If no tokenAddress is provided, the balance will be in SOL.
Inputs ( input is a JSON string ):
tokenAddress: string, eg "So11111111111111111111111111111111111111112" (optional)`;
protected async _call(input: string): Promise<string> {
try {
const params: BalanceToolInput = input ? JSON.parse(input) : {};
const tokenAddress = params.tokenAddress
? new PublicKey(params.tokenAddress)
: undefined;
const balance = await this.solanaKit.getBalance(tokenAddress);
return JSON.stringify({
status: "success",
balance,
token: params.tokenAddress || "SOL",
} as BalanceToolResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,3 @@
export * from "./balance.tool";
export * from "./balance-other.tool";
export * from "./types";

View File

@@ -0,0 +1,21 @@
import { BaseToolResponse } from "../common/types";
export interface BalanceToolInput {
tokenAddress?: string;
}
export interface BalanceToolResponse extends BaseToolResponse {
balance?: number;
token?: string;
}
export interface BalanceOtherToolInput {
walletAddress: string;
tokenAddress?: string;
}
export interface BalanceOtherToolResponse extends BaseToolResponse {
balance?: number;
wallet?: string;
token?: string;
}

View File

@@ -0,0 +1,17 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../../agent";
import { BaseToolResponse } from "./types";
export abstract class BaseSolanaTool extends Tool {
constructor(protected solanaKit: SolanaAgentKit) {
super();
}
protected handleError(error: any): string {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
} as BaseToolResponse);
}
}

View File

@@ -0,0 +1,2 @@
export * from "./types";
export * from "./base.tool";

View File

@@ -0,0 +1,5 @@
export interface BaseToolResponse {
status: "success" | "error";
message: string;
code?: string;
}

View File

@@ -0,0 +1 @@
export * from "./token-data-ticker.tool";

View File

@@ -0,0 +1,23 @@
import { BaseSolanaTool } from "../common/base.tool";
export class SolanaTokenDataByTickerTool extends BaseSolanaTool {
name = "solana_token_data_by_ticker";
description = `Get the token data for a given token ticker
Inputs: ticker is required.
ticker: string, eg "USDC" (required)`;
protected async _call(input: string): Promise<string> {
try {
const ticker = input.trim();
const tokenData = await this.solanaKit.getTokenDataByTicker(ticker);
return JSON.stringify({
status: "success",
tokenData,
});
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,26 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { DomainResponse } from "./types";
export class SolanaGetDomainTool extends BaseSolanaTool {
name = "solana_get_domain";
description = `Retrieve the .sol domain associated for a given account address.
Inputs:
account: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`;
protected async _call(input: string): Promise<string> {
try {
const account = new PublicKey(input.trim());
const domain = await this.solanaKit.getPrimaryDomain(account);
return JSON.stringify({
status: "success",
message: "Primary domain retrieved successfully",
domain,
} as DomainResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,24 @@
import { BaseSolanaTool } from "../common";
export class SolanaGetAllTlds extends BaseSolanaTool {
name = "solana_get_all_tlds";
description = `Get all active top-level domains (TLDs) in the AllDomains Name Service`;
async _call(): Promise<string> {
try {
const tlds = await this.solanaKit.getAllDomainsTLDs();
return JSON.stringify({
status: "success",
message: "TLDs fetched successfully",
tlds,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "FETCH_TLDS_ERROR",
});
}
}
}

View File

@@ -0,0 +1,9 @@
export * from "./register-domain.tool";
export * from "./resolve-domain.tool";
export * from "./resolve-all-domains.tool";
export * from "./get-domain.tool";
export * from "./owned-domains.tool";
export * from "./tld-domains.tool";
export * from "./main-domain.tool";
export * from "./get_all_tld.tool";
export * from "./types";

View File

@@ -0,0 +1,27 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { DomainResponse } from "./types";
export class SolanaGetMainDomain extends BaseSolanaTool {
name = "solana_get_main_domain";
description = `Get the main/favorite domain for a given wallet address.
Inputs:
owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`;
protected async _call(input: string): Promise<string> {
try {
const ownerPubkey = new PublicKey(input.trim());
const mainDomain =
await this.solanaKit.getMainAllDomainsDomain(ownerPubkey);
return JSON.stringify({
status: "success",
message: "Main domain fetched successfully",
domain: mainDomain,
} as DomainResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,26 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { DomainsListResponse } from "./types";
export class SolanaGetOwnedDomains extends BaseSolanaTool {
name = "solana_get_owned_domains";
description = `Get all domains owned by a specific wallet address.
Inputs:
owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`;
protected async _call(input: string): Promise<string> {
try {
const ownerPubkey = new PublicKey(input.trim());
const domains = await this.solanaKit.getOwnedAllDomains(ownerPubkey);
return JSON.stringify({
status: "success",
message: "Owned domains fetched successfully",
domains,
} as DomainsListResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,32 @@
import { BaseSolanaTool } from "../common/base.tool";
import { RegisterDomainInput, RegisterDomainResponse } from "./types";
export class SolanaRegisterDomainTool extends BaseSolanaTool {
name = "solana_register_domain";
description = `Register a .sol domain name for your wallet.
Inputs:
name: string, eg "pumpfun.sol" (required)
spaceKB: number, eg 1 (optional, default is 1)`;
protected async _call(input: string): Promise<string> {
try {
const params: RegisterDomainInput = JSON.parse(input);
const tx = await this.solanaKit.registerDomain(
params.name,
params.spaceKB || 1,
);
return JSON.stringify({
status: "success",
message: "Domain registered successfully",
transaction: tx,
domain: `${params.name}.sol`,
spaceKB: params.spaceKB || 1,
} as RegisterDomainResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,34 @@
import { BaseSolanaTool } from "../common/base.tool";
import { ResolveDomainResponse } from "./types";
export class SolanaResolveAllDomainsTool extends BaseSolanaTool {
name = "solana_resolve_all_domains";
description = `Resolve domain names to a public key for ALL domain types EXCEPT .sol domains.
Use this for domains like .blink, .bonk, etc.
DO NOT use this for .sol domains (use solana_resolve_domain instead).
Input:
domain: string, eg "mydomain.blink" or "mydomain.bonk" (required)`;
protected async _call(input: string): Promise<string> {
try {
const owner = await this.solanaKit.resolveAllDomains(input);
if (!owner) {
return JSON.stringify({
status: "error",
message: "Domain not found",
code: "DOMAIN_NOT_FOUND",
} as ResolveDomainResponse);
}
return JSON.stringify({
status: "success",
message: "Domain resolved successfully",
owner: owner?.toString(),
} as ResolveDomainResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,27 @@
import { BaseSolanaTool } from "../common/base.tool";
import { ResolveDomainResponse } from "./types";
export class SolanaResolveDomainTool extends BaseSolanaTool {
name = "solana_resolve_domain";
description = `Resolve ONLY .sol domain names to a Solana PublicKey.
This tool is exclusively for .sol domains.
DO NOT use this for other domain types like .blink, .bonk, etc.
Inputs:
domain: string, eg "pumpfun.sol" (required)`;
protected async _call(input: string): Promise<string> {
try {
const domain = input.trim();
const publicKey = await this.solanaKit.resolveSolDomain(domain);
return JSON.stringify({
status: "success",
message: "Domain resolved successfully",
publicKey: publicKey.toBase58(),
} as ResolveDomainResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,24 @@
import { BaseSolanaTool } from "../common/base.tool";
import { DomainsListResponse } from "./types";
export class SolanaGetOwnedTldDomains extends BaseSolanaTool {
name = "solana_get_owned_tld_domains";
description = `Get all domains owned by the agent's wallet for a specific TLD.
Inputs:
tld: string, eg "bonk" (required)`;
protected async _call(input: string): Promise<string> {
try {
const domains = await this.solanaKit.getOwnedDomainsForTLD(input);
return JSON.stringify({
status: "success",
message: "TLD domains fetched successfully",
domains,
} as DomainsListResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,45 @@
import { BaseToolResponse } from "../common/types";
export interface RegisterDomainInput {
name: string;
spaceKB?: number;
}
export interface ResolveDomainInput {
domain: string;
}
export interface GetDomainInput {
account: string;
}
export interface OwnedDomainsInput {
owner: string;
}
export interface TldDomainsInput {
tld: string;
}
export interface RegisterDomainResponse extends BaseToolResponse {
transaction?: string;
domain?: string;
spaceKB?: number;
}
export interface ResolveDomainResponse extends BaseToolResponse {
publicKey?: string;
owner?: string;
}
export interface DomainResponse extends BaseToolResponse {
domain?: string | null;
}
export interface DomainsListResponse extends BaseToolResponse {
domains?: string[];
}
export interface TldsResponse extends BaseToolResponse {
tlds?: string[];
}

View File

@@ -0,0 +1,34 @@
import { BaseSolanaTool } from "../common/base.tool";
import { FlashCloseTradeInput, PerpTradeResponse } from "./types";
export class SolanaFlashCloseTrade extends BaseSolanaTool {
name = "solana_flash_close_trade";
description = `Close an existing leveraged trading position on Flash.Trade exchange.
Inputs ( input is a JSON string ):
token: string, eg "SOL", "BTC", "ETH" (required)
side: string, eg "long", "short" (required)
Example prompt is Close a 20x leveraged trade for SOL on long side`;
protected async _call(input: string): Promise<string> {
try {
const params: FlashCloseTradeInput = JSON.parse(input);
const tx = await this.solanaKit.flashCloseTrade({
token: params.token,
side: params.side,
});
return JSON.stringify({
status: "success",
message: "Flash trade position closed successfully",
transaction: tx,
token: params.token,
side: params.side,
} as PerpTradeResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,40 @@
import { BaseSolanaTool } from "../common/base.tool";
import { FlashOpenTradeInput, PerpTradeResponse } from "./types";
export class SolanaFlashOpenTrade extends BaseSolanaTool {
name = "solana_flash_open_trade";
description = `This tool can be used to open a new leveraged trading position on Flash.Trade exchange.
Inputs ( input is a JSON string ):
token: string, eg "SOL", "BTC", "ETH" (required)
type: string, eg "long", "short" (required)
collateral: number, eg 10, 100, 1000 (required)
leverage: number, eg 5, 10, 20 (required)
Example prompt is Open a 20x leveraged trade for SOL on long side using flash trade with 500 USD as collateral`;
protected async _call(input: string): Promise<string> {
try {
const params: FlashOpenTradeInput = JSON.parse(input);
const tx = await this.solanaKit.flashOpenTrade({
token: params.token,
side: params.type,
collateralUsd: params.collateral,
leverage: params.leverage,
});
return JSON.stringify({
status: "success",
message: "Flash trade position opened successfully",
transaction: tx,
token: params.token,
side: params.type,
collateralAmount: params.collateral,
leverage: params.leverage,
} as PerpTradeResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,3 @@
export * from "./flash-open.tool";
export * from "./flash-close.tool";
export * from "./types";

View File

@@ -0,0 +1,25 @@
import { BaseToolResponse } from "../common/types";
export interface FlashOpenTradeInput {
token: string;
type: "long" | "short";
collateral: number;
leverage: number;
}
export interface FlashCloseTradeInput {
token: string;
side: "long" | "short";
}
export interface PerpTradeResponse extends BaseToolResponse {
transaction?: string;
price?: number;
tradeMint?: string;
side?: "long" | "short";
collateralAmount?: number;
collateralMint?: string;
leverage?: number;
slippage?: number;
token?: string;
}

View File

@@ -0,0 +1,41 @@
import { BaseSolanaTool } from "../common/base.tool";
import { CreateGibworkTaskInput, GibworkTaskResponse } from "./types";
export class SolanaCreateGibworkTask extends BaseSolanaTool {
name = "create_gibwork_task";
description = `Create a task on Gibwork.
Inputs (input is a JSON string):
title: string, title of the task (required)
content: string, description of the task (required)
requirements: string, requirements to complete the task (required)
tags: string[], list of tags associated with the task (required)
payer: string, payer address (optional, defaults to agent wallet)
tokenMintAddress: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required)
amount: number, payment amount (required)`;
protected async _call(input: string): Promise<string> {
try {
const params: CreateGibworkTaskInput = JSON.parse(input);
const taskData = await this.solanaKit.createGibworkTask(
params.title,
params.content,
params.requirements,
params.tags,
params.tokenMintAddress,
params.amount,
params.payer,
);
return JSON.stringify({
status: "success",
taskId: taskData.taskId,
signature: taskData.signature,
message: `Task "${params.title}" created successfully`,
} as GibworkTaskResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,2 @@
export * from "./create-task.tool";
export * from "./types";

View File

@@ -0,0 +1,16 @@
import { BaseToolResponse } from "../common/types";
export interface CreateGibworkTaskInput {
title: string;
content: string;
requirements: string;
tags: string[];
tokenMintAddress: string;
amount: number;
payer?: string;
}
export interface GibworkTaskResponse extends BaseToolResponse {
taskId?: string;
signature?: string;
}

View File

@@ -0,0 +1,24 @@
export * from "./adrena";
export * from "./balance";
export * from "./dexscreener";
export * from "./domain";
export * from "./flash";
export * from "./gibwork";
export * from "./jupiter";
export * from "./lulo";
export * from "./manifest";
export * from "./solana";
export * from "./agent";
export * from "./metaplex";
export * from "./openbook";
export * from "./orca";
export * from "./pumpfun";
export * from "./pyth";
export * from "./raydium";
export * from "./rugcheck";
export * from "./sendarcade";
export * from "./solayer";
export * from "./tensor";
export * from "./3land";
export * from "./tiplink";
export * from "./token";

View File

@@ -0,0 +1,23 @@
import { BaseSolanaTool } from "../common/base.tool";
import { PriceResponse } from "./types";
export class SolanaFetchPriceTool extends BaseSolanaTool {
name = "solana_fetch_price";
description = `Fetch the price of a given token in USDC.
Inputs:
- tokenId: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"`;
async _call(input: string): Promise<string> {
try {
const price = await this.solanaKit.fetchTokenPrice(input.trim());
return JSON.stringify({
status: "success",
tokenId: input.trim(),
priceInUSDC: price,
} as PriceResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,5 @@
export * from "./fetch-price.tool";
export * from "./token-data.tool";
export * from "./trade.tool";
export * from "./stake.tool";
export * from "./types";

View File

@@ -0,0 +1,27 @@
import { BaseSolanaTool } from "../common/base.tool";
import { StakeResponse } from "./types";
export class SolanaStakeTool extends BaseSolanaTool {
name = "solana_stake";
description = `This tool can be used to stake your SOL (Solana), also called as SOL staking or liquid staking.
Inputs ( input is a JSON string ):
amount: number, eg 1 or 0.01 (required)`;
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input) || Number(input);
const tx = await this.solanaKit.stake(parsedInput.amount);
return JSON.stringify({
status: "success",
message: "Staked successfully",
transaction: tx,
amount: parsedInput.amount,
} as StakeResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,23 @@
import { BaseSolanaTool } from "../common/base.tool";
export class SolanaTokenDataTool extends BaseSolanaTool {
name = "solana_token_data";
description = `Get the token data for a given token mint address
Inputs: mintAddress is required.
mintAddress: string, eg "So11111111111111111111111111111111111111112" (required)`;
protected async _call(input: string): Promise<string> {
try {
const parsedInput = input.trim();
const tokenData = await this.solanaKit.getTokenDataByAddress(parsedInput);
return JSON.stringify({
status: "success",
tokenData,
});
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,39 @@
import { BaseSolanaTool } from "../common";
import { PublicKey } from "@solana/web3.js";
export class SolanaTradeTool extends BaseSolanaTool {
name = "solana_trade";
description = `This tool can be used to swap tokens to another token ( It uses Jupiter Exchange ).
Inputs ( input is a JSON string ):
outputMint: string, eg "So11111111111111111111111111111111111111112" or "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (required)
inputAmount: number, eg 1 or 0.01 (required)
inputMint?: string, eg "So11111111111111111111111111111111111111112" (optional)
slippageBps?: number, eg 100 (optional)`;
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.trade(
new PublicKey(parsedInput.outputMint),
parsedInput.inputAmount,
parsedInput.inputMint
? new PublicKey(parsedInput.inputMint)
: new PublicKey("So11111111111111111111111111111111111111112"),
parsedInput.slippageBps,
);
return JSON.stringify({
status: "success",
message: "Trade executed successfully",
transaction: tx,
inputAmount: parsedInput.inputAmount,
inputToken: parsedInput.inputMint || "SOL",
outputToken: parsedInput.outputMint,
});
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,19 @@
import { BaseToolResponse } from "../common/types";
export interface FetchPriceInput {
tokenId: string;
}
export interface PriceResponse extends BaseToolResponse {
tokenId?: string;
priceInUSDC?: string;
}
export interface StakeInput {
amount: number;
}
export interface StakeResponse extends BaseToolResponse {
transaction?: string;
amount?: number;
}

View File

@@ -0,0 +1,2 @@
export * from "./lend-asset.tool";
export * from "./types";

View File

@@ -0,0 +1,28 @@
import { BaseSolanaTool } from "../common/base.tool";
import { LendAssetResponse } from "./types";
export class SolanaLendAssetTool extends BaseSolanaTool {
name = "solana_lend_asset";
description = `Lend idle USDC for yield using Lulo. ( only USDC is supported )
Inputs (input is a json string):
amount: number, eg 1, 0.01 (required)`;
async _call(input: string): Promise<string> {
try {
// Parse input either as direct number or JSON object
const amount = JSON.parse(input).amount || Number(input);
const tx = await this.solanaKit.lendAssets(amount);
return JSON.stringify({
status: "success",
message: "Asset lent successfully",
transaction: tx,
amount,
} as LendAssetResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,10 @@
import { BaseToolResponse } from "../common/types";
export interface LendAssetInput {
amount: number;
}
export interface LendAssetResponse extends BaseToolResponse {
transaction?: string;
amount?: number;
}

View File

@@ -0,0 +1,88 @@
import { BaseSolanaTool } from "../common";
import { OrderParams } from "../../../types";
import { generateOrdersfromPattern } from "./../../../tools/manifest";
import { PublicKey } from "@solana/web3.js";
export class SolanaBatchOrderTool extends BaseSolanaTool {
name = "solana_batch_order";
description = `Places multiple limit orders in one transaction using Manifest. Submit orders either as a list or pattern:
1. List format:
{
"marketId": "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ",
"orders": [
{ "quantity": 1, "side": "Buy", "price": 200 },
{ "quantity": 0.5, "side": "Sell", "price": 205 }
]
}
2. Pattern format:
{
"marketId": "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ",
"pattern": {
"side": "Buy",
"totalQuantity": 100,
"priceRange": { "max": 1.0 },
"spacing": { "type": "percentage", "value": 1 },
"numberOfOrders": 5
}
}
Examples:
- "Place 5 buy orders totaling 100 tokens, 1% apart below $1"
- "Create 3 sell orders of 10 tokens each between $50-$55"
- "Place buy orders worth 50 tokens, $0.10 spacing from $0.80"
Important: All orders must be in one transaction. Combine buy and sell orders into a single pattern or list. Never break the orders down to individual buy or sell orders.`;
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
let ordersToPlace: OrderParams[] = [];
if (!parsedInput.marketId) {
throw new Error("Market ID is required");
}
if (parsedInput.pattern) {
ordersToPlace = generateOrdersfromPattern(parsedInput.pattern);
} else if (Array.isArray(parsedInput.orders)) {
ordersToPlace = parsedInput.orders;
} else {
throw new Error("Either pattern or orders array is required");
}
if (ordersToPlace.length === 0) {
throw new Error("No orders generated or provided");
}
ordersToPlace.forEach((order: OrderParams, index: number) => {
if (!order.quantity || !order.side || !order.price) {
throw new Error(
`Invalid order at index ${index}: quantity, side, and price are required`,
);
}
if (order.side !== "Buy" && order.side !== "Sell") {
throw new Error(
`Invalid side at index ${index}: must be "Buy" or "Sell"`,
);
}
});
const tx = await this.solanaKit.batchOrder(
new PublicKey(parsedInput.marketId),
parsedInput.orders,
);
return JSON.stringify({
status: "success",
message: "Batch order executed successfully",
transaction: tx,
marketId: parsedInput.marketId,
orders: parsedInput.orders,
});
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,26 @@
import { BaseSolanaTool } from "../common";
import { PublicKey } from "@solana/web3.js";
export class SolanaCancelAllOrdersTool extends BaseSolanaTool {
name = "solana_cancel_all_orders";
description = `This tool can be used to cancel all orders from a Manifest market.
Input ( input is a JSON string ):
marketId: string, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)`;
protected async _call(input: string): Promise<string> {
try {
const marketId = new PublicKey(input.trim());
const tx = await this.solanaKit.cancelAllOrders(marketId);
return JSON.stringify({
status: "success",
message: "Cancel orders successfully",
transaction: tx,
marketId,
});
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,6 @@
export * from "./manifest-market.tool";
export * from "./batch-order.tool";
export * from "./cancel-orders.tool";
export * from "./limit-order.tool";
export * from "./withdraw.tool";
export * from "./types";

View File

@@ -0,0 +1,40 @@
import { BaseSolanaTool } from "../common";
import { PublicKey } from "@solana/web3.js";
export class SolanaLimitOrderTool extends BaseSolanaTool {
name = "solana_limit_order";
description = `This tool can be used to place limit orders using Manifest.
Do not allow users to place multiple orders with this instruction, use solana_batch_order instead.
Inputs ( input is a JSON string ):
marketId: PublicKey, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)
quantity: number, eg 1 or 0.01 (required)
side: string, eg "Buy" or "Sell" (required)
price: number, in tokens eg 200 for SOL/USDC (required)`;
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.limitOrder(
new PublicKey(parsedInput.marketId),
parsedInput.quantity,
parsedInput.side,
parsedInput.price,
);
return JSON.stringify({
status: "success",
message: "Trade executed successfully",
transaction: tx,
marketId: parsedInput.marketId,
quantity: parsedInput.quantity,
side: parsedInput.side,
price: parsedInput.price,
});
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,32 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { ManifestMarketInput, ManifestMarketResponse } from "./types";
export class SolanaManifestCreateMarket extends BaseSolanaTool {
name = "solana_manifest_create_market";
description = `Manifest market
Inputs (input is a json string):
baseMint: string (required)
quoteMint: string (required)`;
protected async _call(input: string): Promise<string> {
try {
const params: ManifestMarketInput = JSON.parse(input);
const tx = await this.solanaKit.manifestCreateMarket(
new PublicKey(params.baseMint),
new PublicKey(params.quoteMint),
);
return JSON.stringify({
status: "success",
message: "Create manifest market successfully",
transaction: tx[0],
marketId: tx[1],
} as ManifestMarketResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,11 @@
import { BaseToolResponse } from "../common/types";
export interface ManifestMarketInput {
baseMint: string;
quoteMint: string;
}
export interface ManifestMarketResponse extends BaseToolResponse {
transaction: string;
marketId: string;
}

View File

@@ -0,0 +1,30 @@
import { BaseSolanaTool } from "../common";
import { PublicKey } from "@solana/web3.js";
export class SolanaWithdrawAllTool extends BaseSolanaTool {
name = "solana_withdraw_all";
description = `This tool can be used to withdraw all funds from a Manifest market.
Input ( input is a JSON string ):
marketId: string, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)`;
protected async _call(input: string): Promise<string> {
try {
const marketId = new PublicKey(input.trim());
const tx = await this.solanaKit.withdrawAll(marketId);
return JSON.stringify({
status: "success",
message: "Withdrew successfully",
transaction: tx,
marketId,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,30 @@
import { BaseSolanaTool } from "../common/base.tool";
import { DeployCollectionInput, DeployCollectionResponse } from "./types";
export class SolanaDeployCollectionTool extends BaseSolanaTool {
name = "solana_deploy_collection";
description = `Deploy a new NFT collection on Solana blockchain.
Inputs (input is a JSON string):
name: string, eg "My Collection" (required)
uri: string, eg "https://example.com/collection.json" (required)
royaltyBasisPoints?: number, eg 500 for 5% (optional)
creators?: Array of { address: string, percentage: number } (optional)`;
protected async _call(input: string): Promise<string> {
try {
const params: DeployCollectionInput = JSON.parse(input);
const result = await this.solanaKit.deployCollection(params);
return JSON.stringify({
status: "success",
message: "Collection deployed successfully",
collectionAddress: result.collectionAddress.toString(),
name: params.name,
} as DeployCollectionResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,3 @@
export * from "./deploy-collection.tool";
export * from "./mint-nft.tool";
export * from "./types";

View File

@@ -0,0 +1,44 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { MintNFTInput, MintNFTResponse } from "./types";
export class SolanaMintNFTTool extends BaseSolanaTool {
name = "solana_mint_nft";
description = `Mint a new NFT in a collection on Solana blockchain.
Inputs (input is a JSON string):
collectionMint: string, eg "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w" (required) - The address of the collection to mint into
name: string, eg "My NFT" (required)
uri: string, eg "https://example.com/nft.json" (required)
recipient?: string, eg "9aUn5swQzUTRanaaTwmszxiv89cvFwUCjEBv1vZCoT1u" (optional) - The wallet to receive the NFT, defaults to agent's wallet`;
protected async _call(input: string): Promise<string> {
try {
const params: MintNFTInput = JSON.parse(input);
const result = await this.solanaKit.mintNFT(
new PublicKey(params.collectionMint),
{
name: params.name,
uri: params.uri,
},
params.recipient
? new PublicKey(params.recipient)
: this.solanaKit.wallet_address,
);
return JSON.stringify({
status: "success",
message: "NFT minted successfully",
mintAddress: result.mint.toString(),
metadata: {
name: params.name,
uri: params.uri,
},
recipient: params.recipient || result.mint.toString(),
} as MintNFTResponse);
} catch (error: any) {
return this.handleError(error);
}
}
}

View File

@@ -0,0 +1,33 @@
import { BaseToolResponse } from "../common/types";
export interface DeployCollectionInput {
name: string;
uri: string;
royaltyBasisPoints?: number;
creators?: Array<{
address: string;
percentage: number;
}>;
}
export interface MintNFTInput {
collectionMint: string;
name: string;
uri: string;
recipient?: string;
}
export interface DeployCollectionResponse extends BaseToolResponse {
collectionAddress?: string;
name?: string;
}
export interface MintNFTResponse extends BaseToolResponse {
mintAddress?: string;
metadata?: {
name: string;
symbol?: string;
uri: string;
};
recipient?: string;
}

View File

@@ -0,0 +1,2 @@
export * from "./openbook-market.tool";
export * from "./types";

View File

@@ -0,0 +1,35 @@
import { PublicKey } from "@solana/web3.js";
import { BaseSolanaTool } from "../common/base.tool";
import { OpenbookMarketInput } from "./types";
export class SolanaOpenbookCreateMarket extends BaseSolanaTool {
name = "solana_openbook_create_market";
description = `Openbook marketId, required for ammv4
Inputs (input is a json string):
baseMint: string (required)
quoteMint: string (required)
lotSize: number (required)
tickSize: number (required)`;
protected async _call(input: string): Promise<string> {
try {
const params: OpenbookMarketInput = JSON.parse(input);
const tx = await this.solanaKit.openbookCreateMarket(
new PublicKey(params.baseMint),
new PublicKey(params.quoteMint),
params.lotSize,
params.tickSize,
);
return JSON.stringify({
status: "success",
message: "Openbook market created successfully",
transaction: tx,
});
} catch (error: any) {
return this.handleError(error);
}
}
}

Some files were not shown because too many files have changed in this diff Show More