diff --git a/src/actions/createImage.ts b/src/actions/agent/createImage.ts similarity index 95% rename from src/actions/createImage.ts rename to src/actions/agent/createImage.ts index adbf55c..140cc72 100644 --- a/src/actions/createImage.ts +++ b/src/actions/agent/createImage.ts @@ -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", diff --git a/src/actions/getWalletAddress.ts b/src/actions/agent/getWalletAddress.ts similarity index 80% rename from src/actions/getWalletAddress.ts rename to src/actions/agent/getWalletAddress.ts index 7cd87c6..00b7672 100644 --- a/src/actions/getWalletAddress.ts +++ b/src/actions/agent/getWalletAddress.ts @@ -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", diff --git a/src/actions/balance.ts b/src/actions/balance/balance.ts similarity index 91% rename from src/actions/balance.ts rename to src/actions/balance/balance.ts index 381b2a5..97e2d57 100644 --- a/src/actions/balance.ts +++ b/src/actions/balance/balance.ts @@ -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", diff --git a/src/actions/tokenDataByTicker.ts b/src/actions/dexscreener/tokenDataByTicker.ts similarity index 90% rename from src/actions/tokenDataByTicker.ts rename to src/actions/dexscreener/tokenDataByTicker.ts index 28995a5..5991a65 100644 --- a/src/actions/tokenDataByTicker.ts +++ b/src/actions/dexscreener/tokenDataByTicker.ts @@ -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", diff --git a/src/actions/getAllDomainsTLDs.ts b/src/actions/domain/getAllDomainsTLDs.ts similarity index 89% rename from src/actions/getAllDomainsTLDs.ts rename to src/actions/domain/getAllDomainsTLDs.ts index d8d2b64..074e143 100644 --- a/src/actions/getAllDomainsTLDs.ts +++ b/src/actions/domain/getAllDomainsTLDs.ts @@ -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", diff --git a/src/actions/getAllRegisteredAllDomains.ts b/src/actions/domain/getAllRegisteredAllDomains.ts similarity index 91% rename from src/actions/getAllRegisteredAllDomains.ts rename to src/actions/domain/getAllRegisteredAllDomains.ts index a4d5688..b10717f 100644 --- a/src/actions/getAllRegisteredAllDomains.ts +++ b/src/actions/domain/getAllRegisteredAllDomains.ts @@ -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", diff --git a/src/actions/getMainAllDomainsDomain.ts b/src/actions/domain/getMainAllDomainsDomain.ts similarity index 91% rename from src/actions/getMainAllDomainsDomain.ts rename to src/actions/domain/getMainAllDomainsDomain.ts index 1071050..6b8a3cb 100644 --- a/src/actions/getMainAllDomainsDomain.ts +++ b/src/actions/domain/getMainAllDomainsDomain.ts @@ -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", diff --git a/src/actions/getOwnedAllDomains.ts b/src/actions/domain/getOwnedAllDomains.ts similarity index 91% rename from src/actions/getOwnedAllDomains.ts rename to src/actions/domain/getOwnedAllDomains.ts index e9f294a..2a98d4f 100644 --- a/src/actions/getOwnedAllDomains.ts +++ b/src/actions/domain/getOwnedAllDomains.ts @@ -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", diff --git a/src/actions/getOwnedDomainsForTLD.ts b/src/actions/domain/getOwnedDomainsForTLD.ts similarity index 91% rename from src/actions/getOwnedDomainsForTLD.ts rename to src/actions/domain/getOwnedDomainsForTLD.ts index 4343488..72854d8 100644 --- a/src/actions/getOwnedDomainsForTLD.ts +++ b/src/actions/domain/getOwnedDomainsForTLD.ts @@ -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", diff --git a/src/actions/getPrimaryDomain.ts b/src/actions/domain/getPrimaryDomain.ts similarity index 90% rename from src/actions/getPrimaryDomain.ts rename to src/actions/domain/getPrimaryDomain.ts index 2655dae..fdf985e 100644 --- a/src/actions/getPrimaryDomain.ts +++ b/src/actions/domain/getPrimaryDomain.ts @@ -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", diff --git a/src/actions/registerDomain.ts b/src/actions/domain/registerDomain.ts similarity index 91% rename from src/actions/registerDomain.ts rename to src/actions/domain/registerDomain.ts index 55f9354..5f5a6bc 100644 --- a/src/actions/registerDomain.ts +++ b/src/actions/domain/registerDomain.ts @@ -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", diff --git a/src/actions/resolveDomain.ts b/src/actions/domain/resolveDomain.ts similarity index 88% rename from src/actions/resolveDomain.ts rename to src/actions/domain/resolveDomain.ts index e54adea..b3d9534 100644 --- a/src/actions/resolveDomain.ts +++ b/src/actions/domain/resolveDomain.ts @@ -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", diff --git a/src/actions/resolveSolDomain.ts b/src/actions/domain/resolveSolDomain.ts similarity index 90% rename from src/actions/resolveSolDomain.ts rename to src/actions/domain/resolveSolDomain.ts index 60281e2..c72f0a3 100644 --- a/src/actions/resolveSolDomain.ts +++ b/src/actions/domain/resolveSolDomain.ts @@ -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", diff --git a/src/actions/flashCloseTrade.ts b/src/actions/flash/flashCloseTrade.ts similarity index 91% rename from src/actions/flashCloseTrade.ts rename to src/actions/flash/flashCloseTrade.ts index 3781d83..6b7e34a 100644 --- a/src/actions/flashCloseTrade.ts +++ b/src/actions/flash/flashCloseTrade.ts @@ -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", diff --git a/src/actions/flashOpenTrade.ts b/src/actions/flash/flashOpenTrade.ts similarity index 93% rename from src/actions/flashOpenTrade.ts rename to src/actions/flash/flashOpenTrade.ts index 790bdef..b0db660 100644 --- a/src/actions/flashOpenTrade.ts +++ b/src/actions/flash/flashOpenTrade.ts @@ -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", diff --git a/src/actions/createGibworkTask.ts b/src/actions/gibwork/createGibworkTask.ts similarity index 94% rename from src/actions/createGibworkTask.ts rename to src/actions/gibwork/createGibworkTask.ts index 12aa809..dc4b672 100644 --- a/src/actions/createGibworkTask.ts +++ b/src/actions/gibwork/createGibworkTask.ts @@ -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", diff --git a/src/actions/index.ts b/src/actions/index.ts index c974209..e327f8a 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -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, diff --git a/src/actions/fetchPrice.ts b/src/actions/jupiter/fetchPrice.ts similarity index 90% rename from src/actions/fetchPrice.ts rename to src/actions/jupiter/fetchPrice.ts index b232671..d16a371 100644 --- a/src/actions/fetchPrice.ts +++ b/src/actions/jupiter/fetchPrice.ts @@ -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", diff --git a/src/actions/getTokenData.ts b/src/actions/jupiter/getTokenData.ts similarity index 94% rename from src/actions/getTokenData.ts rename to src/actions/jupiter/getTokenData.ts index bf820dc..6b7f308 100644 --- a/src/actions/getTokenData.ts +++ b/src/actions/jupiter/getTokenData.ts @@ -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", diff --git a/src/actions/stakeWithJup.ts b/src/actions/jupiter/stakeWithJup.ts similarity index 90% rename from src/actions/stakeWithJup.ts rename to src/actions/jupiter/stakeWithJup.ts index 7f7680f..34cf91b 100644 --- a/src/actions/stakeWithJup.ts +++ b/src/actions/jupiter/stakeWithJup.ts @@ -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", diff --git a/src/actions/trade.ts b/src/actions/jupiter/trade.ts similarity index 95% rename from src/actions/trade.ts rename to src/actions/jupiter/trade.ts index a4c9e48..4710990 100644 --- a/src/actions/trade.ts +++ b/src/actions/jupiter/trade.ts @@ -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", diff --git a/src/actions/lendAsset.ts b/src/actions/lulo/lendAsset.ts similarity index 89% rename from src/actions/lendAsset.ts rename to src/actions/lulo/lendAsset.ts index 9ceb20e..3c29f91 100644 --- a/src/actions/lendAsset.ts +++ b/src/actions/lulo/lendAsset.ts @@ -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", diff --git a/src/actions/deployCollection.ts b/src/actions/metaplex/deployCollection.ts similarity index 93% rename from src/actions/deployCollection.ts rename to src/actions/metaplex/deployCollection.ts index 1ca5e14..dc0e5c0 100644 --- a/src/actions/deployCollection.ts +++ b/src/actions/metaplex/deployCollection.ts @@ -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; diff --git a/src/actions/mintNFT.ts b/src/actions/metaplex/mintNFT.ts similarity index 94% rename from src/actions/mintNFT.ts rename to src/actions/metaplex/mintNFT.ts index f04cfb7..f0810be 100644 --- a/src/actions/mintNFT.ts +++ b/src/actions/metaplex/mintNFT.ts @@ -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", diff --git a/src/actions/createOpenbookMarket.ts b/src/actions/openbook/createOpenbookMarket.ts similarity index 93% rename from src/actions/createOpenbookMarket.ts rename to src/actions/openbook/createOpenbookMarket.ts index ae76559..f978d35 100644 --- a/src/actions/createOpenbookMarket.ts +++ b/src/actions/openbook/createOpenbookMarket.ts @@ -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", diff --git a/src/actions/createOrcaSingleSidedWhirlpool.ts b/src/actions/orca/createOrcaSingleSidedWhirlpool.ts similarity index 95% rename from src/actions/createOrcaSingleSidedWhirlpool.ts rename to src/actions/orca/createOrcaSingleSidedWhirlpool.ts index f53c881..97eaca0 100644 --- a/src/actions/createOrcaSingleSidedWhirlpool.ts +++ b/src/actions/orca/createOrcaSingleSidedWhirlpool.ts @@ -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 = { diff --git a/src/actions/launchPumpfunToken.ts b/src/actions/pumpfun/launchPumpfunToken.ts similarity index 95% rename from src/actions/launchPumpfunToken.ts rename to src/actions/pumpfun/launchPumpfunToken.ts index 3c23394..8d64c0c 100644 --- a/src/actions/launchPumpfunToken.ts +++ b/src/actions/pumpfun/launchPumpfunToken.ts @@ -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", diff --git a/src/actions/pythFetchPrice.ts b/src/actions/pyth/pythFetchPrice.ts similarity index 89% rename from src/actions/pythFetchPrice.ts rename to src/actions/pyth/pythFetchPrice.ts index d9f7ae4..fb06de9 100644 --- a/src/actions/pythFetchPrice.ts +++ b/src/actions/pyth/pythFetchPrice.ts @@ -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", diff --git a/src/actions/raydiumCreateAmmV4.ts b/src/actions/raydium/raydiumCreateAmmV4.ts similarity index 94% rename from src/actions/raydiumCreateAmmV4.ts rename to src/actions/raydium/raydiumCreateAmmV4.ts index 8ad228d..b6c496b 100644 --- a/src/actions/raydiumCreateAmmV4.ts +++ b/src/actions/raydium/raydiumCreateAmmV4.ts @@ -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", diff --git a/src/actions/raydiumCreateClmm.ts b/src/actions/raydium/raydiumCreateClmm.ts similarity index 94% rename from src/actions/raydiumCreateClmm.ts rename to src/actions/raydium/raydiumCreateClmm.ts index dd24322..cb77605 100644 --- a/src/actions/raydiumCreateClmm.ts +++ b/src/actions/raydium/raydiumCreateClmm.ts @@ -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", diff --git a/src/actions/raydiumCreateCpmm.ts b/src/actions/raydium/raydiumCreateCpmm.ts similarity index 94% rename from src/actions/raydiumCreateCpmm.ts rename to src/actions/raydium/raydiumCreateCpmm.ts index b2159b5..ee74d9e 100644 --- a/src/actions/raydiumCreateCpmm.ts +++ b/src/actions/raydium/raydiumCreateCpmm.ts @@ -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", diff --git a/src/actions/getTPS.ts b/src/actions/solana/getTPS.ts similarity index 88% rename from src/actions/getTPS.ts rename to src/actions/solana/getTPS.ts index 490bfb4..69fce8d 100644 --- a/src/actions/getTPS.ts +++ b/src/actions/solana/getTPS.ts @@ -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", diff --git a/src/actions/requestFunds.ts b/src/actions/solana/requestFunds.ts similarity index 86% rename from src/actions/requestFunds.ts rename to src/actions/solana/requestFunds.ts index a4a95c2..8ce5d2f 100644 --- a/src/actions/requestFunds.ts +++ b/src/actions/solana/requestFunds.ts @@ -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", diff --git a/src/actions/stakeWithSolayer.ts b/src/actions/solayer/stakeWithSolayer.ts similarity index 91% rename from src/actions/stakeWithSolayer.ts rename to src/actions/solayer/stakeWithSolayer.ts index ec57944..5095bd7 100644 --- a/src/actions/stakeWithSolayer.ts +++ b/src/actions/solayer/stakeWithSolayer.ts @@ -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", diff --git a/src/actions/closeEmptyTokenAccounts.ts b/src/actions/token/closeEmptyTokenAccounts.ts similarity index 92% rename from src/actions/closeEmptyTokenAccounts.ts rename to src/actions/token/closeEmptyTokenAccounts.ts index 867c25e..85fb67b 100644 --- a/src/actions/closeEmptyTokenAccounts.ts +++ b/src/actions/token/closeEmptyTokenAccounts.ts @@ -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", diff --git a/src/actions/compressedAirdrop.ts b/src/actions/token/compressedAirdrop.ts similarity index 95% rename from src/actions/compressedAirdrop.ts rename to src/actions/token/compressedAirdrop.ts index 107d352..2abdc72 100644 --- a/src/actions/compressedAirdrop.ts +++ b/src/actions/token/compressedAirdrop.ts @@ -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", diff --git a/src/actions/deployToken.ts b/src/actions/token/deployToken.ts similarity index 93% rename from src/actions/deployToken.ts rename to src/actions/token/deployToken.ts index 3a3f25d..02c5a51 100644 --- a/src/actions/deployToken.ts +++ b/src/actions/token/deployToken.ts @@ -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", diff --git a/src/actions/transfer.ts b/src/actions/token/transfer.ts similarity index 94% rename from src/actions/transfer.ts rename to src/actions/token/transfer.ts index f4206aa..568d1a3 100644 --- a/src/actions/transfer.ts +++ b/src/actions/token/transfer.ts @@ -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", diff --git a/src/agent/index.ts b/src/agent/index.ts index 3563f8d..f841ac4 100644 --- a/src/agent/index.ts +++ b/src/agent/index.ts @@ -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, diff --git a/src/langchain/index.ts b/src/langchain/index.ts index ef282e3..178a42f 100644 --- a/src/langchain/index.ts +++ b/src/langchain/index.ts @@ -1,2439 +1,63 @@ -import { PublicKey } from "@solana/web3.js"; -import { BN } from "@coral-xyz/anchor"; -import Decimal from "decimal.js"; -import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../agent"; import { - GibworkCreateTaskReponse, - OrderParams, - PythFetchPriceResponse, - SolanaAgentKit, -} from "../index"; -import { create_image, FEE_TIERS, generateOrdersfromPattern } from "../tools"; -import { marketTokenMap } from "../utils/flashUtils"; -import { - CreateCollectionOptions, - CreateSingleOptions, - StoreInitOptions, -} from "@3land/listings-sdk/dist/types/implementation/implementationTypes"; - -export class SolanaBalanceTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const tokenAddress = input ? new PublicKey(input) : undefined; - const balance = await this.solanaKit.getBalance(tokenAddress); - - return JSON.stringify({ - status: "success", - balance, - token: input || "SOL", - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaBalanceOtherTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const { walletAddress, tokenAddress } = JSON.parse(input); - - const tokenPubKey = tokenAddress - ? new PublicKey(tokenAddress) - : undefined; - - const balance = await this.solanaKit.getBalanceOther( - new PublicKey(walletAddress), - tokenPubKey, - ); - - return JSON.stringify({ - status: "success", - balance, - wallet: walletAddress, - token: tokenAddress || "SOL", - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTransferTool extends Tool { - name = "solana_transfer"; - description = `Transfer tokens or SOL to another address ( also called as wallet address ). - - Inputs ( input is a JSON string ): - to: string, eg "8x2dR8Mpzuz2YqyZyZjUbYWKSWesBo5jMx2Q9Y86udVk" (required) - amount: number, eg 1 (required) - mint?: string, eg "So11111111111111111111111111111111111111112" or "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const recipient = new PublicKey(parsedInput.to); - const mintAddress = parsedInput.mint - ? new PublicKey(parsedInput.mint) - : undefined; - - const tx = await this.solanaKit.transfer( - recipient, - parsedInput.amount, - mintAddress, - ); - - return JSON.stringify({ - status: "success", - message: "Transfer completed successfully", - amount: parsedInput.amount, - recipient: parsedInput.to, - token: parsedInput.mint || "SOL", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaDeployTokenTool extends Tool { - name = "solana_deploy_token"; - description = `Deploy a new token on Solana blockchain. - - Inputs (input is a JSON string): - name: string, eg "My Token" (required) - uri: string, eg "https://example.com/token.json" (required) - symbol: string, eg "MTK" (required) - decimals?: number, eg 9 (optional, defaults to 9) - initialSupply?: number, eg 1000000 (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const result = await this.solanaKit.deployToken( - parsedInput.name, - parsedInput.uri, - parsedInput.symbol, - parsedInput.decimals, - parsedInput.initialSupply, - ); - - return JSON.stringify({ - status: "success", - message: "Token deployed successfully", - mintAddress: result.mint.toString(), - decimals: parsedInput.decimals || 9, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaDeployCollectionTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const result = await this.solanaKit.deployCollection(parsedInput); - - return JSON.stringify({ - status: "success", - message: "Collection deployed successfully", - collectionAddress: result.collectionAddress.toString(), - name: parsedInput.name, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaMintNFTTool extends Tool { - 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 which is ${this.solanaKit.wallet_address.toString()}`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const result = await this.solanaKit.mintNFT( - new PublicKey(parsedInput.collectionMint), - { - name: parsedInput.name, - uri: parsedInput.uri, - }, - parsedInput.recipient - ? new PublicKey(parsedInput.recipient) - : this.solanaKit.wallet_address, - ); - - return JSON.stringify({ - status: "success", - message: "NFT minted successfully", - mintAddress: result.mint.toString(), - metadata: { - name: parsedInput.name, - symbol: parsedInput.symbol, - uri: parsedInput.uri, - }, - recipient: parsedInput.recipient || result.mint.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaPerpCloseTradeTool extends Tool { - 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"`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const tx = - parsedInput.side === "long" - ? await this.solanaKit.closePerpTradeLong({ - price: parsedInput.price, - tradeMint: new PublicKey(parsedInput.tradeMint), - }) - : await this.solanaKit.closePerpTradeShort({ - price: parsedInput.price, - tradeMint: new PublicKey(parsedInput.tradeMint), - }); - - return JSON.stringify({ - status: "success", - message: "Perpetual trade closed successfully", - transaction: tx, - price: parsedInput.price, - tradeMint: new PublicKey(parsedInput.tradeMint), - side: parsedInput.side, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaPerpOpenTradeTool extends Tool { - 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"`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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, - price: parsedInput.price, - collateralAmount: parsedInput.collateralAmount, - collateralMint: new PublicKey(parsedInput.collateralMint), - leverage: parsedInput.leverage, - tradeMint: new PublicKey(parsedInput.tradeMint), - slippage: parsedInput.slippage, - side: parsedInput.side, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTradeTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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 JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaLimitOrderTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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 JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaBatchOrderTool extends Tool { - 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.`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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 JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCancelAllOrdersTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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 JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaWithdrawAllTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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", - }); - } - } -} - -export class SolanaRequestFundsTool extends Tool { - name = "solana_request_funds"; - description = "Request SOL from Solana faucet (devnet/testnet only)"; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(_input: string): Promise { - try { - await this.solanaKit.requestFaucetFunds(); - - return JSON.stringify({ - status: "success", - message: "Successfully requested faucet funds", - network: this.solanaKit.connection.rpcEndpoint.split("/")[2], - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRegisterDomainTool extends Tool { - 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) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - private validateInput(input: any): void { - if (!input.name || typeof input.name !== "string") { - throw new Error("name is required and must be a string"); - } - if ( - input.spaceKB !== undefined && - (typeof input.spaceKB !== "number" || input.spaceKB <= 0) - ) { - throw new Error("spaceKB must be a positive number when provided"); - } - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - this.validateInput(parsedInput); - - const tx = await this.solanaKit.registerDomain( - parsedInput.name, - parsedInput.spaceKB || 1, - ); - - return JSON.stringify({ - status: "success", - message: "Domain registered successfully", - transaction: tx, - domain: `${parsedInput.name}.sol`, - spaceKB: parsedInput.spaceKB || 1, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaResolveDomainTool extends Tool { - 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) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const domain = input.trim(); - const publicKey = await this.solanaKit.resolveSolDomain(domain); - - return JSON.stringify({ - status: "success", - message: "Domain resolved successfully", - publicKey: publicKey.toBase58(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaGetDomainTool extends Tool { - name = "solana_get_domain"; - description = `Retrieve the .sol domain associated for a given account address. - - Inputs: - account: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaGetWalletAddressTool extends Tool { - name = "solana_get_wallet_address"; - description = `Get the wallet address of the agent`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(_input: string): Promise { - return this.solanaKit.wallet_address.toString(); - } -} - -export class SolanaFlashOpenTrade extends Tool { - 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`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - // Validate input parameters - if (!parsedInput.token) { - throw new Error("Token is required, received: " + parsedInput.token); - } - if (!Object.keys(marketTokenMap).includes(parsedInput.token)) { - throw new Error( - "Token must be one of " + - Object.keys(marketTokenMap).join(", ") + - ", received: " + - parsedInput.token + - "\n" + - "Please check https://beast.flash.trade/ for the list of supported tokens", - ); - } - if (!["long", "short"].includes(parsedInput.type)) { - throw new Error( - 'Type must be either "long" or "short", received: ' + - parsedInput.type, - ); - } - if (!parsedInput.collateral || parsedInput.collateral <= 0) { - throw new Error( - "Collateral amount must be positive, received: " + - parsedInput.collateral, - ); - } - if (!parsedInput.leverage || parsedInput.leverage <= 0) { - throw new Error( - "Leverage must be positive, received: " + parsedInput.leverage, - ); - } - - const tx = await this.solanaKit.flashOpenTrade({ - token: parsedInput.token, - side: parsedInput.type, - collateralUsd: parsedInput.collateral, - leverage: parsedInput.leverage, - }); - - return JSON.stringify({ - status: "success", - message: "Flash trade position opened successfully", - transaction: tx, - token: parsedInput.token, - side: parsedInput.type, - collateral: parsedInput.collateral, - leverage: parsedInput.leverage, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaFlashCloseTrade extends Tool { - 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`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - // Validate input parameters - if (!parsedInput.token) { - throw new Error("Token is required"); - } - if (!["SOL", "BTC", "ETH"].includes(parsedInput.token)) { - throw new Error('Token must be one of ["SOL", "BTC", "ETH"]'); - } - if (!["long", "short"].includes(parsedInput.side)) { - throw new Error('Side must be either "long" or "short"'); - } - - const tx = await this.solanaKit.flashCloseTrade({ - token: parsedInput.token, - side: parsedInput.side, - }); - - return JSON.stringify({ - status: "success", - message: "Flash trade position closed successfully", - transaction: tx, - token: parsedInput.token, - side: parsedInput.side, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaPumpfunTokenLaunchTool extends Tool { - name = "solana_launch_pumpfun_token"; - - description = `This tool can be used to launch a token on Pump.fun, - do not use this tool for any other purpose, or for creating SPL tokens. - If the user asks you to chose the parameters, you should generate valid values. - For generating the image, you can use the solana_create_image tool. - - Inputs: - tokenName: string, eg "PumpFun Token", - tokenTicker: string, eg "PUMP", - description: string, eg "PumpFun Token is a token on the Solana blockchain", - imageUrl: string, eg "https://i.imgur.com/UFm07Np_d.png`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - private validateInput(input: any): void { - if (!input.tokenName || typeof input.tokenName !== "string") { - throw new Error("tokenName is required and must be a string"); - } - if (!input.tokenTicker || typeof input.tokenTicker !== "string") { - throw new Error("tokenTicker is required and must be a string"); - } - if (!input.description || typeof input.description !== "string") { - throw new Error("description is required and must be a string"); - } - if (!input.imageUrl || typeof input.imageUrl !== "string") { - throw new Error("imageUrl is required and must be a string"); - } - if ( - input.initialLiquiditySOL !== undefined && - typeof input.initialLiquiditySOL !== "number" - ) { - throw new Error("initialLiquiditySOL must be a number when provided"); - } - } - - protected async _call(input: string): Promise { - try { - // Parse and normalize input - input = input.trim(); - const parsedInput = JSON.parse(input); - - this.validateInput(parsedInput); - - // Launch token with validated input - await this.solanaKit.launchPumpFunToken( - parsedInput.tokenName, - parsedInput.tokenTicker, - parsedInput.description, - parsedInput.imageUrl, - { - twitter: parsedInput.twitter, - telegram: parsedInput.telegram, - website: parsedInput.website, - initialLiquiditySOL: parsedInput.initialLiquiditySOL, - }, - ); - - return JSON.stringify({ - status: "success", - message: "Token launched successfully on Pump.fun", - tokenName: parsedInput.tokenName, - tokenTicker: parsedInput.tokenTicker, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCreateImageTool extends Tool { - name = "solana_create_image"; - description = - "Create an image using OpenAI's DALL-E. Input should be a string prompt for the image."; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - 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 { - try { - this.validateInput(input); - const result = await create_image(this.solanaKit, input.trim()); - - return JSON.stringify({ - status: "success", - message: "Image created successfully", - ...result, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaLendAssetTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const amount = JSON.parse(input).amount || input; - - const tx = await this.solanaKit.lendAssets(amount); - - return JSON.stringify({ - status: "success", - message: "Asset lent successfully", - transaction: tx, - amount, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTPSCalculatorTool extends Tool { - name = "solana_get_tps"; - description = "Get the current TPS of the Solana network"; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(_input: string): Promise { - try { - const tps = await this.solanaKit.getTPS(); - return `Solana (mainnet-beta) current transactions per second: ${tps}`; - } catch (error: any) { - return `Error fetching TPS: ${error.message}`; - } - } -} - -export class SolanaStakeTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRestakeTool extends Tool { - name = "solana_restake"; - description = `This tool can be used to restake your SOL on Solayer to receive Solayer SOL (sSOL) as a Liquid Staking Token (LST). - - Inputs: - amount: number, eg 1 or 0.01 (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input) || Number(input); - - const tx = await this.solanaKit.restake(parsedInput.amount); - - return JSON.stringify({ - status: "success", - message: "Staked successfully", - transaction: tx, - amount: parsedInput.amount, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -/** - * Tool to fetch the price of a token in USDC - */ -export class SolanaFetchPriceTool extends Tool { - 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"`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const price = await this.solanaKit.fetchTokenPrice(input.trim()); - return JSON.stringify({ - status: "success", - tokenId: input.trim(), - priceInUSDC: price, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTokenDataTool extends Tool { - name = "solana_token_data"; - description = `Get the token data for a given token mint address - - Inputs: mintAddress is required. - mintAddress: string, eg "So11111111111111111111111111111111111111112" (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = input.trim(); - - const tokenData = await this.solanaKit.getTokenDataByAddress(parsedInput); - - return JSON.stringify({ - status: "success", - tokenData, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTokenDataByTickerTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const ticker = input.trim(); - const tokenData = await this.solanaKit.getTokenDataByTicker(ticker); - return JSON.stringify({ - status: "success", - tokenData, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCompressedAirdropTool extends Tool { - name = "solana_compressed_airdrop"; - description = `Airdrop SPL tokens with ZK Compression (also called as airdropping tokens) - - Inputs (input is a JSON string): - mintAddress: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required) - amount: number, the amount of tokens to airdrop per recipient, e.g., 42 (required) - decimals: number, the decimals of the token, e.g., 6 (required) - recipients: string[], the recipient addresses, e.g., ["1nc1nerator11111111111111111111111111111111"] (required) - priorityFeeInLamports: number, the priority fee in lamports. Default is 30_000. (optional) - shouldLog: boolean, whether to log progress to stdout. Default is false. (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const txs = await this.solanaKit.sendCompressedAirdrop( - parsedInput.mintAddress, - parsedInput.amount, - parsedInput.decimals, - parsedInput.recipients, - parsedInput.priorityFeeInLamports || 30_000, - parsedInput.shouldLog || false, - ); - - return JSON.stringify({ - status: "success", - message: `Airdropped ${parsedInput.amount} tokens to ${parsedInput.recipients.length} recipients.`, - transactionHashes: txs, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaClosePosition extends Tool { - name = "orca_close_position"; - description = `Closes an existing liquidity position in an Orca Whirlpool. This function fetches the position - details using the provided mint address and closes the position with a 1% slippage. - - Inputs (JSON string): - - positionMintAddress: string, the address of the position mint that represents the liquidity position.`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const positionMintAddress = new PublicKey( - inputFormat.positionMintAddress, - ); - - const txId = await this.solanaKit.orcaClosePosition(positionMintAddress); - - return JSON.stringify({ - status: "success", - message: "Liquidity position closed successfully.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaCreateCLMM extends Tool { - name = "orca_create_clmm"; - description = `Create a Concentrated Liquidity Market Maker (CLMM) pool on Orca, the most efficient and capital-optimized CLMM on Solana. This function initializes a CLMM pool but does not add liquidity. You can add liquidity later using a centered position or a single-sided position. - - Inputs (JSON string): - - mintDeploy: string, the mint of the token you want to deploy (required). - - mintPair: string, The mint of the token you want to pair the deployed mint with (required). - - initialPrice: number, initial price of mintA in terms of mintB, e.g., 0.001 (required). - - feeTier: number, fee tier in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const mintA = new PublicKey(inputFormat.mintDeploy); - const mintB = new PublicKey(inputFormat.mintPair); - const initialPrice = new Decimal(inputFormat.initialPrice); - const feeTier = inputFormat.feeTier; - - if (!feeTier || !(feeTier in FEE_TIERS)) { - throw new Error( - `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join( - ", ", - )}`, - ); - } - - const txId = await this.solanaKit.orcaCreateCLMM( - mintA, - mintB, - initialPrice, - feeTier, - ); - - return JSON.stringify({ - status: "success", - message: - "CLMM pool created successfully. Note: No liquidity was added.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaCreateSingleSideLiquidityPool extends Tool { - name = "orca_create_single_sided_liquidity_pool"; - description = `Create a single-sided liquidity pool on Orca, the most efficient and capital-optimized CLMM platform on Solana. - - This function initializes a single-sided liquidity pool, ideal for community driven project, fair launches, and fundraising. Minimize price impact by setting a narrow price range. - - Inputs (JSON string): - - depositTokenAmount: number, in units of the deposit token including decimals, e.g., 1000000000 (required). - - depositTokenMint: string, mint address of the deposit token, e.g., "DepositTokenMintAddress" (required). - - otherTokenMint: string, mint address of the other token, e.g., "OtherTokenMintAddress" (required). - - initialPrice: number, initial price of the deposit token in terms of the other token, e.g., 0.001 (required). - - maxPrice: number, maximum price at which liquidity is added, e.g., 5.0 (required). - - feeTier: number, fee tier for the pool in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const depositTokenAmount = inputFormat.depositTokenAmount; - const depositTokenMint = new PublicKey(inputFormat.depositTokenMint); - const otherTokenMint = new PublicKey(inputFormat.otherTokenMint); - const initialPrice = new Decimal(inputFormat.initialPrice); - const maxPrice = new Decimal(inputFormat.maxPrice); - const feeTier = inputFormat.feeTier; - - if (!feeTier || !(feeTier in FEE_TIERS)) { - throw new Error( - `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join( - ", ", - )}`, - ); - } - - const txId = await this.solanaKit.orcaCreateSingleSidedLiquidityPool( - depositTokenAmount, - depositTokenMint, - otherTokenMint, - initialPrice, - maxPrice, - feeTier, - ); - - return JSON.stringify({ - status: "success", - message: "Single-sided Whirlpool created successfully", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaFetchPositions extends Tool { - name = "orca_fetch_positions"; - description = `Fetch all the liquidity positions in an Orca Whirlpool by owner. Returns an object with positiont mint addresses as keys and position status details as values.`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(): Promise { - try { - const txId = await this.solanaKit.orcaFetchPositions(); - - return JSON.stringify({ - status: "success", - message: "Liquidity positions fetched.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaOpenCenteredPosition extends Tool { - name = "orca_open_centered_position_with_liquidity"; - description = `Add liquidity to a CLMM by opening a centered position in an Orca Whirlpool, the most efficient liquidity pool on Solana. - - Inputs (JSON string): - - whirlpoolAddress: string, address of the Orca Whirlpool (required). - - priceOffsetBps: number, bps offset (one side) from the current pool price, e.g., 500 for 5% (required). - - inputTokenMint: string, mint address of the deposit token (required). - - inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress); - const priceOffsetBps = parseInt(inputFormat.priceOffsetBps, 10); - const inputTokenMint = new PublicKey(inputFormat.inputTokenMint); - const inputAmount = new Decimal(inputFormat.inputAmount); - - if (priceOffsetBps < 0) { - throw new Error( - "Invalid distanceFromCurrentPriceBps. It must be equal or greater than 0.", - ); - } - - const txId = await this.solanaKit.orcaOpenCenteredPositionWithLiquidity( - whirlpoolAddress, - priceOffsetBps, - inputTokenMint, - inputAmount, - ); - - return JSON.stringify({ - status: "success", - message: "Centered liquidity position opened successfully.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaOpenSingleSidedPosition extends Tool { - name = "orca_open_single_sided_position"; - description = `Add liquidity to a CLMM by opening a single-sided position in an Orca Whirlpool, the most efficient liquidity pool on Solana. - - Inputs (JSON string): - - whirlpoolAddress: string, address of the Orca Whirlpool (required). - - distanceFromCurrentPriceBps: number, distance in basis points from the current price for the position (required). - - widthBps: number, width of the position in basis points (required). - - inputTokenMint: string, mint address of the deposit token (required). - - inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress); - const distanceFromCurrentPriceBps = - inputFormat.distanceFromCurrentPriceBps; - const widthBps = inputFormat.widthBps; - const inputTokenMint = new PublicKey(inputFormat.inputTokenMint); - const inputAmount = new Decimal(inputFormat.inputAmount); - - if (distanceFromCurrentPriceBps < 0 || widthBps < 0) { - throw new Error( - "Invalid distanceFromCurrentPriceBps or width. It must be equal or greater than 0.", - ); - } - - const txId = await this.solanaKit.orcaOpenSingleSidedPosition( - whirlpoolAddress, - distanceFromCurrentPriceBps, - widthBps, - inputTokenMint, - inputAmount, - ); - - return JSON.stringify({ - status: "success", - message: "Single-sided liquidity position opened successfully.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRaydiumCreateAmmV4 extends Tool { - name = "raydium_create_ammV4"; - description = `Raydium's Legacy AMM that requires an OpenBook marketID - - Inputs (input is a json string): - marketId: string (required) - baseAmount: number(int), eg: 111111 (required) - quoteAmount: number(int), eg: 111111 (required) - startTime: number(seconds), eg: now number or zero (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.raydiumCreateAmmV4( - new PublicKey(inputFormat.marketId), - new BN(inputFormat.baseAmount), - new BN(inputFormat.quoteAmount), - new BN(inputFormat.startTime), - ); - - return JSON.stringify({ - status: "success", - message: "Raydium amm v4 pool created successfully", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRaydiumCreateClmm extends Tool { - name = "raydium_create_clmm"; - description = `Concentrated liquidity market maker, custom liquidity ranges, increased capital efficiency - - Inputs (input is a json string): - mint1: string (required) - mint2: string (required) - configId: string (required) stores pool info, id, index, protocolFeeRate, tradeFeeRate, tickSpacing, fundFeeRate - initialPrice: number, eg: 123.12 (required) - startTime: number(seconds), eg: now number or zero (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.raydiumCreateClmm( - new PublicKey(inputFormat.mint1), - new PublicKey(inputFormat.mint2), - - new PublicKey(inputFormat.configId), - - new Decimal(inputFormat.initialPrice), - new BN(inputFormat.startTime), - ); - - return JSON.stringify({ - status: "success", - message: "Raydium clmm pool created successfully", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRaydiumCreateCpmm extends Tool { - name = "raydium_create_cpmm"; - description = `Raydium's newest CPMM, does not require marketID, supports Token 2022 standard - - Inputs (input is a json string): - mint1: string (required) - mint2: string (required) - configId: string (required), stores pool info, index, protocolFeeRate, tradeFeeRate, fundFeeRate, createPoolFee - mintAAmount: number(int), eg: 1111 (required) - mintBAmount: number(int), eg: 2222 (required) - startTime: number(seconds), eg: now number or zero (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.raydiumCreateCpmm( - new PublicKey(inputFormat.mint1), - new PublicKey(inputFormat.mint2), - - new PublicKey(inputFormat.configId), - - new BN(inputFormat.mintAAmount), - new BN(inputFormat.mintBAmount), - - new BN(inputFormat.startTime), - ); - - return JSON.stringify({ - status: "success", - message: "Raydium cpmm pool created successfully", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOpenbookCreateMarket extends Tool { - 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) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.openbookCreateMarket( - new PublicKey(inputFormat.baseMint), - new PublicKey(inputFormat.quoteMint), - - inputFormat.lotSize, - inputFormat.tickSize, - ); - - return JSON.stringify({ - status: "success", - message: "Openbook market created successfully", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaManifestCreateMarket extends Tool { - name = "solana_manifest_create_market"; - description = `Manifest market - - Inputs (input is a json string): - baseMint: string (required) - quoteMint: string (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.manifestCreateMarket( - new PublicKey(inputFormat.baseMint), - new PublicKey(inputFormat.quoteMint), - ); - - return JSON.stringify({ - status: "success", - message: "Create manifest market successfully", - transaction: tx[0], - marketId: tx[1], - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaPythFetchPrice extends Tool { - name = "solana_pyth_fetch_price"; - description = `Fetch the price of a given price feed from Pyth's Hermes service - - Inputs: - tokenSymbol: string, e.g., BTC for bitcoin`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const priceFeedID = await this.solanaKit.getPythPriceFeedID(input); - const price = await this.solanaKit.getPythPrice(priceFeedID); - - const response: PythFetchPriceResponse = { - status: "success", - tokenSymbol: input, - priceFeedID, - price, - }; - - return JSON.stringify(response); - } catch (error: any) { - const response: PythFetchPriceResponse = { - status: "error", - tokenSymbol: input, - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }; - return JSON.stringify(response); - } - } -} - -export class SolanaResolveAllDomainsTool extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const owner = await this.solanaKit.resolveAllDomains(input); - - if (!owner) { - return JSON.stringify({ - status: "error", - message: "Domain not found", - code: "DOMAIN_NOT_FOUND", - }); - } - - return JSON.stringify({ - status: "success", - message: "Domain resolved successfully", - owner: owner?.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "DOMAIN_RESOLUTION_ERROR", - }); - } - } -} - -export class SolanaGetOwnedDomains extends Tool { - name = "solana_get_owned_domains"; - description = `Get all domains owned by a specific wallet address. - - Inputs: - owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - 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, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_OWNED_DOMAINS_ERROR", - }); - } - } -} - -export class SolanaGetOwnedTldDomains extends Tool { - 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)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const domains = await this.solanaKit.getOwnedDomainsForTLD(input); - - return JSON.stringify({ - status: "success", - message: "TLD domains fetched successfully", - domains, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_TLD_DOMAINS_ERROR", - }); - } - } -} - -export class SolanaGetAllTlds extends Tool { - name = "solana_get_all_tlds"; - description = `Get all active top-level domains (TLDs) in the AllDomains Name Service`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(): Promise { - 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", - }); - } - } -} - -export class SolanaGetMainDomain extends Tool { - name = "solana_get_main_domain"; - description = `Get the main/favorite domain for a given wallet address. - - Inputs: - owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - 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, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_MAIN_DOMAIN_ERROR", - }); - } - } -} - -export class SolanaCreateGibworkTask extends Tool { - 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) - `; - - constructor(private solanaSdk: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const taskData = await this.solanaSdk.createGibworkTask( - parsedInput.title, - parsedInput.content, - parsedInput.requirements, - parsedInput.tags, - parsedInput.tokenMintAddress, - parsedInput.amount, - parsedInput.payer, - ); - - const response: GibworkCreateTaskReponse = { - status: "success", - taskId: taskData.taskId, - signature: taskData.signature, - }; - - return JSON.stringify(response); - } catch (err: any) { - return JSON.stringify({ - status: "error", - message: err.message, - code: err.code || "CREATE_TASK_ERROR", - }); - } - } -} - -export class SolanaRockPaperScissorsTool extends Tool { - name = "rock_paper_scissors"; - description = `Play rock paper scissors to win SEND coins. - - Inputs (input is a JSON string): - choice: string, either "rock", "paper", or "scissors" (required) - amount: number, amount of SOL to play with - must be 0.1, 0.01, or 0.005 SOL (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - private validateInput(input: any): void { - if (input.choice !== undefined) { - throw new Error("choice is required."); - } - if ( - input.amount !== undefined && - (typeof input.spaceKB !== "number" || input.spaceKB <= 0) - ) { - throw new Error("amount must be a positive number when provided"); - } - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - this.validateInput(parsedInput); - const result = await this.solanaKit.rockPaperScissors( - Number(parsedInput['"amount"']), - parsedInput['"choice"'].replace(/^"|"$/g, "") as - | "rock" - | "paper" - | "scissors", - ); - - return JSON.stringify({ - status: "success", - message: result, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTipLinkTool extends Tool { - name = "solana_tiplink"; - description = `Create a TipLink for transferring SOL or SPL tokens. - Input is a JSON string with: - - amount: number (required) - Amount to transfer - - splmintAddress: string (optional) - SPL token mint address`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - if (!parsedInput.amount) { - throw new Error("Amount is required"); - } - - const amount = parseFloat(parsedInput.amount); - const splmintAddress = parsedInput.splmintAddress - ? new PublicKey(parsedInput.splmintAddress) - : undefined; - - const { url, signature } = await this.solanaKit.createTiplink( - amount, - splmintAddress, - ); - - return JSON.stringify({ - status: "success", - url, - signature, - amount, - tokenType: splmintAddress ? "SPL" : "SOL", - message: `TipLink created successfully`, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaListNFTForSaleTool extends Tool { - name = "solana_list_nft_for_sale"; - description = `List an NFT for sale on Tensor Trade. - - Inputs (input is a JSON string): - nftMint: string, the mint address of the NFT (required) - price: number, price in SOL (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - // Validate NFT ownership first - const nftAccount = - await this.solanaKit.connection.getTokenAccountsByOwner( - this.solanaKit.wallet_address, - { mint: new PublicKey(parsedInput.nftMint) }, - ); - - if (nftAccount.value.length === 0) { - return JSON.stringify({ - status: "error", - message: - "NFT not found in wallet. Please make sure you own this NFT.", - code: "NFT_NOT_FOUND", - }); - } - - const tx = await this.solanaKit.tensorListNFT( - new PublicKey(parsedInput.nftMint), - parsedInput.price, - ); - - return JSON.stringify({ - status: "success", - message: "NFT listed for sale successfully", - transaction: tx, - price: parsedInput.price, - nftMint: parsedInput.nftMint, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCancelNFTListingTool extends Tool { - name = "solana_cancel_nft_listing"; - description = `Cancel an NFT listing on Tensor Trade. - - Inputs (input is a JSON string): - nftMint: string, the mint address of the NFT (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const tx = await this.solanaKit.tensorCancelListing( - new PublicKey(parsedInput.nftMint), - ); - - return JSON.stringify({ - status: "success", - message: "NFT listing cancelled successfully", - transaction: tx, - nftMint: parsedInput.nftMint, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaFetchTokenReportSummaryTool extends Tool { - name = "solana_fetch_token_report_summary"; - description = `Fetches a summary report for a specific token from RugCheck. - Inputs: - - mint: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const mint = input.trim(); - const report = await this.solanaKit.fetchTokenReportSummary(mint); - - return JSON.stringify({ - status: "success", - message: "Token report summary fetched successfully", - report, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_TOKEN_REPORT_SUMMARY_ERROR", - }); - } - } -} - -export class SolanaFetchTokenDetailedReportTool extends Tool { - name = "solana_fetch_token_detailed_report"; - description = `Fetches a detailed report for a specific token from RugCheck. - Inputs: - - mint: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const mint = input.trim(); - const detailedReport = - await this.solanaKit.fetchTokenDetailedReport(mint); - - return JSON.stringify({ - status: "success", - message: "Detailed token report fetched successfully", - report: detailedReport, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_TOKEN_DETAILED_REPORT_ERROR", - }); - } - } -} - -export class Solana3LandCreateSingle extends Tool { - 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 - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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 JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class Solana3LandCreateCollection extends Tool { - 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 - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - 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 JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCloseEmptyTokenAccounts extends Tool { - name = "close_empty_token_accounts"; - description = `Close all empty spl-token accounts and reclaim the rent`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(): Promise { - try { - const { signature, size } = - await this.solanaKit.closeEmptyTokenAccounts(); - - return JSON.stringify({ - status: "success", - message: `${size} accounts closed successfully. ${size === 48 ? "48 accounts can be closed in a single transaction try again to close more accounts" : ""}`, - signature, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} + SolanaBalanceTool, + SolanaBalanceOtherTool, + SolanaTransferTool, + SolanaDeployTokenTool, + SolanaDeployCollectionTool, + SolanaMintNFTTool, + SolanaTradeTool, + SolanaRequestFundsTool, + SolanaRegisterDomainTool, + SolanaGetWalletAddressTool, + SolanaPumpfunTokenLaunchTool, + SolanaCreateImageTool, + SolanaLendAssetTool, + SolanaTPSCalculatorTool, + SolanaStakeTool, + SolanaRestakeTool, + SolanaFetchPriceTool, + SolanaGetDomainTool, + SolanaTokenDataTool, + SolanaTokenDataByTickerTool, + SolanaCompressedAirdropTool, + SolanaRaydiumCreateAmmV4, + SolanaRaydiumCreateClmm, + SolanaRaydiumCreateCpmm, + SolanaOpenbookCreateMarket, + SolanaManifestCreateMarket, + SolanaLimitOrderTool, + SolanaBatchOrderTool, + SolanaCancelAllOrdersTool, + SolanaWithdrawAllTool, + SolanaOrcaClosePosition, + SolanaOrcaCreateCLMM, + SolanaOrcaCreateSingleSidedPool, + SolanaOrcaFetchPositions, + SolanaOrcaOpenCenteredPosition, + SolanaOrcaOpenSingleSidedPosition, + SolanaPythFetchPrice, + SolanaResolveDomainTool, + SolanaGetOwnedDomains, + SolanaGetOwnedTldDomains, + SolanaGetAllTlds, + SolanaGetMainDomain, + SolanaResolveAllDomainsTool, + SolanaCreateGibworkTask, + SolanaRockPaperScissorsTool, + SolanaTipLinkTool, + SolanaListNFTForSaleTool, + SolanaCancelNFTListingTool, + SolanaCloseEmptyTokenAccounts, + SolanaFetchTokenReportSummaryTool, + SolanaFetchTokenDetailedReportTool, + Solana3LandCreateSingle, + Solana3LandCreateCollection, + SolanaPerpOpenTradeTool, + SolanaPerpCloseTradeTool, + SolanaFlashOpenTrade, + SolanaFlashCloseTrade, +} from "./tools/index"; export function createSolanaTools(solanaKit: SolanaAgentKit) { return [ @@ -2467,9 +91,9 @@ export function createSolanaTools(solanaKit: SolanaAgentKit) { new SolanaBatchOrderTool(solanaKit), new SolanaCancelAllOrdersTool(solanaKit), new SolanaWithdrawAllTool(solanaKit), - new SolanaClosePosition(solanaKit), + new SolanaOrcaClosePosition(solanaKit), new SolanaOrcaCreateCLMM(solanaKit), - new SolanaOrcaCreateSingleSideLiquidityPool(solanaKit), + new SolanaOrcaCreateSingleSidedPool(solanaKit), new SolanaOrcaFetchPositions(solanaKit), new SolanaOrcaOpenCenteredPosition(solanaKit), new SolanaOrcaOpenSingleSidedPosition(solanaKit), @@ -2494,6 +118,5 @@ export function createSolanaTools(solanaKit: SolanaAgentKit) { new SolanaPerpCloseTradeTool(solanaKit), new SolanaFlashOpenTrade(solanaKit), new SolanaFlashCloseTrade(solanaKit), - new Solana3LandCreateSingle(solanaKit), ]; } diff --git a/src/langchain/tools/3land/create-collection.tool.ts b/src/langchain/tools/3land/create-collection.tool.ts new file mode 100644 index 0000000..5e41ded --- /dev/null +++ b/src/langchain/tools/3land/create-collection.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/3land/create-single.tool.ts b/src/langchain/tools/3land/create-single.tool.ts new file mode 100644 index 0000000..30c894a --- /dev/null +++ b/src/langchain/tools/3land/create-single.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/3land/index.ts b/src/langchain/tools/3land/index.ts new file mode 100644 index 0000000..bc50928 --- /dev/null +++ b/src/langchain/tools/3land/index.ts @@ -0,0 +1,2 @@ +export * from "./create-single.tool"; +export * from "./create-collection.tool"; diff --git a/src/langchain/tools/adrena/close-trade.tool.ts b/src/langchain/tools/adrena/close-trade.tool.ts new file mode 100644 index 0000000..4f78732 --- /dev/null +++ b/src/langchain/tools/adrena/close-trade.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/adrena/index.ts b/src/langchain/tools/adrena/index.ts new file mode 100644 index 0000000..d86de5e --- /dev/null +++ b/src/langchain/tools/adrena/index.ts @@ -0,0 +1,2 @@ +export * from "./open-trade.tool"; +export * from "./close-trade.tool"; diff --git a/src/langchain/tools/adrena/open-trade.tool.ts b/src/langchain/tools/adrena/open-trade.tool.ts new file mode 100644 index 0000000..b24d8b1 --- /dev/null +++ b/src/langchain/tools/adrena/open-trade.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/adrena/types.ts b/src/langchain/tools/adrena/types.ts new file mode 100644 index 0000000..90f0d53 --- /dev/null +++ b/src/langchain/tools/adrena/types.ts @@ -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; +} diff --git a/src/langchain/tools/agent/create-image.tool.ts b/src/langchain/tools/agent/create-image.tool.ts new file mode 100644 index 0000000..54a5a1d --- /dev/null +++ b/src/langchain/tools/agent/create-image.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/agent/index.ts b/src/langchain/tools/agent/index.ts new file mode 100644 index 0000000..5f7d4b7 --- /dev/null +++ b/src/langchain/tools/agent/index.ts @@ -0,0 +1,2 @@ +export * from "./create-image.tool"; +export * from "./wallet-address.tool"; diff --git a/src/langchain/tools/agent/types.ts b/src/langchain/tools/agent/types.ts new file mode 100644 index 0000000..8dce4d6 --- /dev/null +++ b/src/langchain/tools/agent/types.ts @@ -0,0 +1,9 @@ +import { BaseToolResponse } from "../common/types"; + +export interface CreateImageResponse extends BaseToolResponse { + images?: string[]; +} + +export interface WalletAddressResponse extends BaseToolResponse { + address?: string; +} diff --git a/src/langchain/tools/agent/wallet-address.tool.ts b/src/langchain/tools/agent/wallet-address.tool.ts new file mode 100644 index 0000000..78c8e1c --- /dev/null +++ b/src/langchain/tools/agent/wallet-address.tool.ts @@ -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 { + return JSON.stringify({ + status: "success", + message: "Wallet address retrieved successfully", + address: this.solanaKit.wallet_address.toString(), + } as WalletAddressResponse); + } +} diff --git a/src/langchain/tools/balance/balance-other.tool.ts b/src/langchain/tools/balance/balance-other.tool.ts new file mode 100644 index 0000000..3752b60 --- /dev/null +++ b/src/langchain/tools/balance/balance-other.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/balance/balance.tool.ts b/src/langchain/tools/balance/balance.tool.ts new file mode 100644 index 0000000..14403da --- /dev/null +++ b/src/langchain/tools/balance/balance.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/balance/index.ts b/src/langchain/tools/balance/index.ts new file mode 100644 index 0000000..7d453b8 --- /dev/null +++ b/src/langchain/tools/balance/index.ts @@ -0,0 +1,3 @@ +export * from "./balance.tool"; +export * from "./balance-other.tool"; +export * from "./types"; diff --git a/src/langchain/tools/balance/types.ts b/src/langchain/tools/balance/types.ts new file mode 100644 index 0000000..5d1f61a --- /dev/null +++ b/src/langchain/tools/balance/types.ts @@ -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; +} diff --git a/src/langchain/tools/common/base.tool.ts b/src/langchain/tools/common/base.tool.ts new file mode 100644 index 0000000..e8b4fa4 --- /dev/null +++ b/src/langchain/tools/common/base.tool.ts @@ -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); + } +} diff --git a/src/langchain/tools/common/index.ts b/src/langchain/tools/common/index.ts new file mode 100644 index 0000000..0bea65f --- /dev/null +++ b/src/langchain/tools/common/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./base.tool"; diff --git a/src/langchain/tools/common/types.ts b/src/langchain/tools/common/types.ts new file mode 100644 index 0000000..71400bb --- /dev/null +++ b/src/langchain/tools/common/types.ts @@ -0,0 +1,5 @@ +export interface BaseToolResponse { + status: "success" | "error"; + message: string; + code?: string; +} diff --git a/src/langchain/tools/dexscreener/index.ts b/src/langchain/tools/dexscreener/index.ts new file mode 100644 index 0000000..f993cf4 --- /dev/null +++ b/src/langchain/tools/dexscreener/index.ts @@ -0,0 +1 @@ +export * from "./token-data-ticker.tool"; diff --git a/src/langchain/tools/dexscreener/token-data-ticker.tool.ts b/src/langchain/tools/dexscreener/token-data-ticker.tool.ts new file mode 100644 index 0000000..949add5 --- /dev/null +++ b/src/langchain/tools/dexscreener/token-data-ticker.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/domain/get-domain.tool.ts b/src/langchain/tools/domain/get-domain.tool.ts new file mode 100644 index 0000000..2eebcca --- /dev/null +++ b/src/langchain/tools/domain/get-domain.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/domain/get_all_tld.tool.ts b/src/langchain/tools/domain/get_all_tld.tool.ts new file mode 100644 index 0000000..8f5f1b4 --- /dev/null +++ b/src/langchain/tools/domain/get_all_tld.tool.ts @@ -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 { + 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", + }); + } + } +} diff --git a/src/langchain/tools/domain/index.ts b/src/langchain/tools/domain/index.ts new file mode 100644 index 0000000..cfe75f4 --- /dev/null +++ b/src/langchain/tools/domain/index.ts @@ -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"; diff --git a/src/langchain/tools/domain/main-domain.tool.ts b/src/langchain/tools/domain/main-domain.tool.ts new file mode 100644 index 0000000..eb70581 --- /dev/null +++ b/src/langchain/tools/domain/main-domain.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/domain/owned-domains.tool.ts b/src/langchain/tools/domain/owned-domains.tool.ts new file mode 100644 index 0000000..2ab62dd --- /dev/null +++ b/src/langchain/tools/domain/owned-domains.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/domain/register-domain.tool.ts b/src/langchain/tools/domain/register-domain.tool.ts new file mode 100644 index 0000000..5b7d368 --- /dev/null +++ b/src/langchain/tools/domain/register-domain.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/domain/resolve-all-domains.tool.ts b/src/langchain/tools/domain/resolve-all-domains.tool.ts new file mode 100644 index 0000000..d1683c3 --- /dev/null +++ b/src/langchain/tools/domain/resolve-all-domains.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/domain/resolve-domain.tool.ts b/src/langchain/tools/domain/resolve-domain.tool.ts new file mode 100644 index 0000000..555e93a --- /dev/null +++ b/src/langchain/tools/domain/resolve-domain.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/domain/tld-domains.tool.ts b/src/langchain/tools/domain/tld-domains.tool.ts new file mode 100644 index 0000000..0cfaf2f --- /dev/null +++ b/src/langchain/tools/domain/tld-domains.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/domain/types.ts b/src/langchain/tools/domain/types.ts new file mode 100644 index 0000000..bf9a31f --- /dev/null +++ b/src/langchain/tools/domain/types.ts @@ -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[]; +} diff --git a/src/langchain/tools/flash/flash-close.tool.ts b/src/langchain/tools/flash/flash-close.tool.ts new file mode 100644 index 0000000..e5c9dd0 --- /dev/null +++ b/src/langchain/tools/flash/flash-close.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/flash/flash-open.tool.ts b/src/langchain/tools/flash/flash-open.tool.ts new file mode 100644 index 0000000..9b104c6 --- /dev/null +++ b/src/langchain/tools/flash/flash-open.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/flash/index.ts b/src/langchain/tools/flash/index.ts new file mode 100644 index 0000000..aabf20f --- /dev/null +++ b/src/langchain/tools/flash/index.ts @@ -0,0 +1,3 @@ +export * from "./flash-open.tool"; +export * from "./flash-close.tool"; +export * from "./types"; diff --git a/src/langchain/tools/flash/types.ts b/src/langchain/tools/flash/types.ts new file mode 100644 index 0000000..d733d5f --- /dev/null +++ b/src/langchain/tools/flash/types.ts @@ -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; +} diff --git a/src/langchain/tools/gibwork/create-task.tool.ts b/src/langchain/tools/gibwork/create-task.tool.ts new file mode 100644 index 0000000..70a0230 --- /dev/null +++ b/src/langchain/tools/gibwork/create-task.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/gibwork/index.ts b/src/langchain/tools/gibwork/index.ts new file mode 100644 index 0000000..62c6b2a --- /dev/null +++ b/src/langchain/tools/gibwork/index.ts @@ -0,0 +1,2 @@ +export * from "./create-task.tool"; +export * from "./types"; diff --git a/src/langchain/tools/gibwork/types.ts b/src/langchain/tools/gibwork/types.ts new file mode 100644 index 0000000..489ecbb --- /dev/null +++ b/src/langchain/tools/gibwork/types.ts @@ -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; +} diff --git a/src/langchain/tools/index.ts b/src/langchain/tools/index.ts new file mode 100644 index 0000000..7cb43ce --- /dev/null +++ b/src/langchain/tools/index.ts @@ -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"; diff --git a/src/langchain/tools/jupiter/fetch-price.tool.ts b/src/langchain/tools/jupiter/fetch-price.tool.ts new file mode 100644 index 0000000..67f6bf5 --- /dev/null +++ b/src/langchain/tools/jupiter/fetch-price.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/jupiter/index.ts b/src/langchain/tools/jupiter/index.ts new file mode 100644 index 0000000..824d2f5 --- /dev/null +++ b/src/langchain/tools/jupiter/index.ts @@ -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"; diff --git a/src/langchain/tools/jupiter/stake.tool.ts b/src/langchain/tools/jupiter/stake.tool.ts new file mode 100644 index 0000000..1ba7774 --- /dev/null +++ b/src/langchain/tools/jupiter/stake.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/jupiter/token-data.tool.ts b/src/langchain/tools/jupiter/token-data.tool.ts new file mode 100644 index 0000000..40ea58f --- /dev/null +++ b/src/langchain/tools/jupiter/token-data.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/jupiter/trade.tool.ts b/src/langchain/tools/jupiter/trade.tool.ts new file mode 100644 index 0000000..9c88b5b --- /dev/null +++ b/src/langchain/tools/jupiter/trade.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/jupiter/types.ts b/src/langchain/tools/jupiter/types.ts new file mode 100644 index 0000000..42ca0e8 --- /dev/null +++ b/src/langchain/tools/jupiter/types.ts @@ -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; +} diff --git a/src/langchain/tools/lulo/index.ts b/src/langchain/tools/lulo/index.ts new file mode 100644 index 0000000..3d93b46 --- /dev/null +++ b/src/langchain/tools/lulo/index.ts @@ -0,0 +1,2 @@ +export * from "./lend-asset.tool"; +export * from "./types"; diff --git a/src/langchain/tools/lulo/lend-asset.tool.ts b/src/langchain/tools/lulo/lend-asset.tool.ts new file mode 100644 index 0000000..94666b1 --- /dev/null +++ b/src/langchain/tools/lulo/lend-asset.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/lulo/types.ts b/src/langchain/tools/lulo/types.ts new file mode 100644 index 0000000..aba87b2 --- /dev/null +++ b/src/langchain/tools/lulo/types.ts @@ -0,0 +1,10 @@ +import { BaseToolResponse } from "../common/types"; + +export interface LendAssetInput { + amount: number; +} + +export interface LendAssetResponse extends BaseToolResponse { + transaction?: string; + amount?: number; +} diff --git a/src/langchain/tools/manifest/batch-order.tool.ts b/src/langchain/tools/manifest/batch-order.tool.ts new file mode 100644 index 0000000..2e57c01 --- /dev/null +++ b/src/langchain/tools/manifest/batch-order.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/manifest/cancel-orders.tool.ts b/src/langchain/tools/manifest/cancel-orders.tool.ts new file mode 100644 index 0000000..1ef4ff3 --- /dev/null +++ b/src/langchain/tools/manifest/cancel-orders.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/manifest/index.ts b/src/langchain/tools/manifest/index.ts new file mode 100644 index 0000000..65b11a9 --- /dev/null +++ b/src/langchain/tools/manifest/index.ts @@ -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"; diff --git a/src/langchain/tools/manifest/limit-order.tool.ts b/src/langchain/tools/manifest/limit-order.tool.ts new file mode 100644 index 0000000..73b23e1 --- /dev/null +++ b/src/langchain/tools/manifest/limit-order.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/manifest/manifest-market.tool.ts b/src/langchain/tools/manifest/manifest-market.tool.ts new file mode 100644 index 0000000..9ecb5b8 --- /dev/null +++ b/src/langchain/tools/manifest/manifest-market.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/manifest/types.ts b/src/langchain/tools/manifest/types.ts new file mode 100644 index 0000000..c0150f0 --- /dev/null +++ b/src/langchain/tools/manifest/types.ts @@ -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; +} diff --git a/src/langchain/tools/manifest/withdraw.tool.ts b/src/langchain/tools/manifest/withdraw.tool.ts new file mode 100644 index 0000000..7d110fb --- /dev/null +++ b/src/langchain/tools/manifest/withdraw.tool.ts @@ -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 { + 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", + }); + } + } +} diff --git a/src/langchain/tools/metaplex/deploy-collection.tool.ts b/src/langchain/tools/metaplex/deploy-collection.tool.ts new file mode 100644 index 0000000..32e972d --- /dev/null +++ b/src/langchain/tools/metaplex/deploy-collection.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/metaplex/index.ts b/src/langchain/tools/metaplex/index.ts new file mode 100644 index 0000000..0cecea3 --- /dev/null +++ b/src/langchain/tools/metaplex/index.ts @@ -0,0 +1,3 @@ +export * from "./deploy-collection.tool"; +export * from "./mint-nft.tool"; +export * from "./types"; diff --git a/src/langchain/tools/metaplex/mint-nft.tool.ts b/src/langchain/tools/metaplex/mint-nft.tool.ts new file mode 100644 index 0000000..97c93c4 --- /dev/null +++ b/src/langchain/tools/metaplex/mint-nft.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/metaplex/types.ts b/src/langchain/tools/metaplex/types.ts new file mode 100644 index 0000000..ecfcafd --- /dev/null +++ b/src/langchain/tools/metaplex/types.ts @@ -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; +} diff --git a/src/langchain/tools/openbook/index.ts b/src/langchain/tools/openbook/index.ts new file mode 100644 index 0000000..f33ba26 --- /dev/null +++ b/src/langchain/tools/openbook/index.ts @@ -0,0 +1,2 @@ +export * from "./openbook-market.tool"; +export * from "./types"; diff --git a/src/langchain/tools/openbook/openbook-market.tool.ts b/src/langchain/tools/openbook/openbook-market.tool.ts new file mode 100644 index 0000000..0077ea8 --- /dev/null +++ b/src/langchain/tools/openbook/openbook-market.tool.ts @@ -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 { + 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); + } + } +} diff --git a/src/langchain/tools/openbook/types.ts b/src/langchain/tools/openbook/types.ts new file mode 100644 index 0000000..6ae5503 --- /dev/null +++ b/src/langchain/tools/openbook/types.ts @@ -0,0 +1,6 @@ +export interface OpenbookMarketInput { + baseMint: string; + quoteMint: string; + lotSize: number; + tickSize: number; +} diff --git a/src/langchain/tools/orca/index.ts b/src/langchain/tools/orca/index.ts new file mode 100644 index 0000000..17ac156 --- /dev/null +++ b/src/langchain/tools/orca/index.ts @@ -0,0 +1,7 @@ +export * from "./orca-clmm.tool"; +export * from "./orca-single-sided-pool.tool"; +export * from "./orca-position.tool"; +export * from "./orca-fetch-positions.tool"; +export * from "./orca-centered-position.tool"; +export * from "./orca-single-sided-position.tool"; +export * from "./types"; diff --git a/src/langchain/tools/orca/orca-centered-position.tool.ts b/src/langchain/tools/orca/orca-centered-position.tool.ts new file mode 100644 index 0000000..ba38409 --- /dev/null +++ b/src/langchain/tools/orca/orca-centered-position.tool.ts @@ -0,0 +1,35 @@ +import { PublicKey } from "@solana/web3.js"; +import { Decimal } from "decimal.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { OrcaCenteredPositionInput, LiquidityResponse } from "./types"; + +export class SolanaOrcaOpenCenteredPosition extends BaseSolanaTool { + name = "orca_open_centered_position_with_liquidity"; + description = `Add liquidity to a CLMM by opening a centered position in an Orca Whirlpool, the most efficient liquidity pool on Solana. + + Inputs (JSON string): + - whirlpoolAddress: string, address of the Orca Whirlpool (required). + - priceOffsetBps: number, bps offset (one side) from the current pool price, e.g., 500 for 5% (required). + - inputTokenMint: string, mint address of the deposit token (required). + - inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`; + + async _call(input: string): Promise { + try { + const params: OrcaCenteredPositionInput = JSON.parse(input); + const txId = await this.solanaKit.orcaOpenCenteredPositionWithLiquidity( + new PublicKey(params.whirlpoolAddress), + params.priceOffsetBps, + new PublicKey(params.inputTokenMint), + new Decimal(params.inputAmount), + ); + + return JSON.stringify({ + status: "success", + message: "Centered liquidity position opened successfully.", + transaction: txId, + } as LiquidityResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/orca/orca-clmm.tool.ts b/src/langchain/tools/orca/orca-clmm.tool.ts new file mode 100644 index 0000000..b753a62 --- /dev/null +++ b/src/langchain/tools/orca/orca-clmm.tool.ts @@ -0,0 +1,46 @@ +import { PublicKey } from "@solana/web3.js"; +import { Decimal } from "decimal.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { LiquidityResponse } from "./types"; +import { FEE_TIERS } from "../../../tools/orca"; + +export class SolanaOrcaCreateCLMM extends BaseSolanaTool { + name = "orca_create_clmm"; + description = `Create a Concentrated Liquidity Market Maker (CLMM) pool on Orca, the most efficient and capital-optimized CLMM on Solana. This function initializes a CLMM pool but does not add liquidity. You can add liquidity later using a centered position or a single-sided position. + + Inputs (JSON string): + - mintDeploy: string, the mint of the token you want to deploy (required). + - mintPair: string, The mint of the token you want to pair the deployed mint with (required). + - initialPrice: number, initial price of mintA in terms of mintB, e.g., 0.001 (required). + - feeTier: number, fee tier in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`; + + async _call(input: string): Promise { + try { + const params = JSON.parse(input); + const feeTier = params.feeTier; + + if (!feeTier || !(feeTier in FEE_TIERS)) { + throw new Error( + `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join( + ", ", + )}`, + ); + } + const txId = await this.solanaKit.orcaCreateCLMM( + new PublicKey(params.mintDeploy), + new PublicKey(params.mintPair), + new Decimal(params.initialPrice), + feeTier, + ); + + return JSON.stringify({ + status: "success", + message: + "CLMM pool created successfully. Note: No liquidity was added.", + transaction: txId, + } as LiquidityResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/orca/orca-fetch-positions.tool.ts b/src/langchain/tools/orca/orca-fetch-positions.tool.ts new file mode 100644 index 0000000..d815639 --- /dev/null +++ b/src/langchain/tools/orca/orca-fetch-positions.tool.ts @@ -0,0 +1,21 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { OrcaPositionsResponse } from "./types"; + +export class SolanaOrcaFetchPositions extends BaseSolanaTool { + name = "orca_fetch_positions"; + description = `Fetch all the liquidity positions in an Orca Whirlpool by owner. Returns an object with position mint addresses as keys and position status details as values.`; + + async _call(): Promise { + try { + const positions = await this.solanaKit.orcaFetchPositions(); + + return JSON.stringify({ + status: "success", + message: "Liquidity positions fetched successfully", + positions: JSON.parse(positions), + } as OrcaPositionsResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/orca/orca-position.tool.ts b/src/langchain/tools/orca/orca-position.tool.ts new file mode 100644 index 0000000..67be90e --- /dev/null +++ b/src/langchain/tools/orca/orca-position.tool.ts @@ -0,0 +1,29 @@ +import { PublicKey } from "@solana/web3.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { OrcaPositionInput, LiquidityResponse } from "./types"; + +export class SolanaOrcaClosePosition extends BaseSolanaTool { + name = "orca_close_position"; + description = `Closes an existing liquidity position in an Orca Whirlpool. This function fetches the position + details using the provided mint address and closes the position with a 1% slippage. + + Inputs (JSON string): + - positionMintAddress: string, the address of the position mint that represents the liquidity position.`; + + async _call(input: string): Promise { + try { + const params: OrcaPositionInput = JSON.parse(input); + const txId = await this.solanaKit.orcaClosePosition( + new PublicKey(params.positionMintAddress), + ); + + return JSON.stringify({ + status: "success", + message: "Liquidity position closed successfully.", + transaction: txId, + } as LiquidityResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/orca/orca-single-sided-pool.tool.ts b/src/langchain/tools/orca/orca-single-sided-pool.tool.ts new file mode 100644 index 0000000..22604c4 --- /dev/null +++ b/src/langchain/tools/orca/orca-single-sided-pool.tool.ts @@ -0,0 +1,51 @@ +import { PublicKey } from "@solana/web3.js"; +import { Decimal } from "decimal.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { LiquidityResponse } from "./types"; +import { FEE_TIERS } from "../../../tools/orca"; + +export class SolanaOrcaCreateSingleSidedPool extends BaseSolanaTool { + name = "orca_create_single_sided_liquidity_pool"; + description = `Create a single-sided liquidity pool on Orca, the most efficient and capital-optimized CLMM platform on Solana. + + This function initializes a single-sided liquidity pool, ideal for community driven project, fair launches, and fundraising. Minimize price impact by setting a narrow price range. + + Inputs (JSON string): + - depositTokenAmount: number, in units of the deposit token including decimals, e.g., 1000000000 (required). + - depositTokenMint: string, mint address of the deposit token, e.g., "DepositTokenMintAddress" (required). + - otherTokenMint: string, mint address of the other token, e.g., "OtherTokenMintAddress" (required). + - initialPrice: number, initial price of the deposit token in terms of the other token, e.g., 0.001 (required). + - maxPrice: number, maximum price at which liquidity is added, e.g., 5.0 (required). + - feeTier: number, fee tier for the pool in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`; + + async _call(input: string): Promise { + try { + const params = JSON.parse(input); + const feeTier = params.feeTier; + + if (!feeTier || !(feeTier in FEE_TIERS)) { + throw new Error( + `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join( + ", ", + )}`, + ); + } + const txId = await this.solanaKit.orcaCreateSingleSidedLiquidityPool( + params.depositTokenAmount, + new PublicKey(params.depositTokenMint), + new PublicKey(params.otherTokenMint), + new Decimal(params.initialPrice), + new Decimal(params.maxPrice), + feeTier, + ); + + return JSON.stringify({ + status: "success", + message: "Single-sided Whirlpool created successfully", + transaction: txId, + } as LiquidityResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/orca/orca-single-sided-position.tool.ts b/src/langchain/tools/orca/orca-single-sided-position.tool.ts new file mode 100644 index 0000000..4d4aa5b --- /dev/null +++ b/src/langchain/tools/orca/orca-single-sided-position.tool.ts @@ -0,0 +1,37 @@ +import { PublicKey } from "@solana/web3.js"; +import { Decimal } from "decimal.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { OrcaSingleSidedPositionInput, LiquidityResponse } from "./types"; + +export class SolanaOrcaOpenSingleSidedPosition extends BaseSolanaTool { + name = "orca_open_single_sided_position"; + description = `Add liquidity to a CLMM by opening a single-sided position in an Orca Whirlpool, the most efficient liquidity pool on Solana. + + Inputs (JSON string): + - whirlpoolAddress: string, address of the Orca Whirlpool (required). + - distanceFromCurrentPriceBps: number, distance in basis points from the current price (required). + - widthBps: number, width of the position in basis points (required). + - inputTokenMint: string, mint address of the deposit token (required). + - inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`; + + async _call(input: string): Promise { + try { + const params: OrcaSingleSidedPositionInput = JSON.parse(input); + const txId = await this.solanaKit.orcaOpenSingleSidedPosition( + new PublicKey(params.whirlpoolAddress), + params.distanceFromCurrentPriceBps, + params.widthBps, + new PublicKey(params.inputTokenMint), + new Decimal(params.inputAmount), + ); + + return JSON.stringify({ + status: "success", + message: "Single-sided liquidity position opened successfully.", + transaction: txId, + } as LiquidityResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/orca/types.ts b/src/langchain/tools/orca/types.ts new file mode 100644 index 0000000..a7e51dc --- /dev/null +++ b/src/langchain/tools/orca/types.ts @@ -0,0 +1,51 @@ +import { BaseToolResponse } from "../common/types"; + +export interface OrcaClmmInput { + mintDeploy: string; + mintPair: string; + initialPrice: number | string; + feeTier: string; +} + +export interface OrcaSingleSidedInput { + depositTokenAmount: number; + depositTokenMint: string; + otherTokenMint: string; + initialPrice: number | string; + maxPrice: number | string; + feeTier: string; +} + +export interface OrcaPositionInput { + positionMintAddress: string; +} + +export interface OrcaCenteredPositionInput { + whirlpoolAddress: string; + priceOffsetBps: number; + inputTokenMint: string; + inputAmount: number | string; +} + +export interface OrcaSingleSidedPositionInput { + whirlpoolAddress: string; + distanceFromCurrentPriceBps: number; + widthBps: number; + inputTokenMint: string; + inputAmount: number | string; +} + +export interface LiquidityResponse extends BaseToolResponse { + transaction?: string; +} + +export interface OrcaPositionsResponse extends BaseToolResponse { + positions?: Record< + string, + { + whirlpoolAddress: string; + positionInRange: boolean; + distanceFromCenterBps: number; + } + >; +} diff --git a/src/langchain/tools/pumpfun/index.ts b/src/langchain/tools/pumpfun/index.ts new file mode 100644 index 0000000..938bace --- /dev/null +++ b/src/langchain/tools/pumpfun/index.ts @@ -0,0 +1 @@ +export * from "./launch-pumpfun-token.tool"; diff --git a/src/langchain/tools/pumpfun/launch-pumpfun-token.tool.ts b/src/langchain/tools/pumpfun/launch-pumpfun-token.tool.ts new file mode 100644 index 0000000..a4df4ba --- /dev/null +++ b/src/langchain/tools/pumpfun/launch-pumpfun-token.tool.ts @@ -0,0 +1,74 @@ +import { BaseSolanaTool } from "../common"; + +export class SolanaPumpfunTokenLaunchTool extends BaseSolanaTool { + name = "solana_launch_pumpfun_token"; + + description = `This tool can be used to launch a token on Pump.fun, + do not use this tool for any other purpose, or for creating SPL tokens. + If the user asks you to chose the parameters, you should generate valid values. + For generating the image, you can use the solana_create_image tool. + + Inputs: + tokenName: string, eg "PumpFun Token", + tokenTicker: string, eg "PUMP", + description: string, eg "PumpFun Token is a token on the Solana blockchain", + imageUrl: string, eg "https://i.imgur.com/UFm07Np_d.png`; + + private validateInput(input: any): void { + if (!input.tokenName || typeof input.tokenName !== "string") { + throw new Error("tokenName is required and must be a string"); + } + if (!input.tokenTicker || typeof input.tokenTicker !== "string") { + throw new Error("tokenTicker is required and must be a string"); + } + if (!input.description || typeof input.description !== "string") { + throw new Error("description is required and must be a string"); + } + if (!input.imageUrl || typeof input.imageUrl !== "string") { + throw new Error("imageUrl is required and must be a string"); + } + if ( + input.initialLiquiditySOL !== undefined && + typeof input.initialLiquiditySOL !== "number" + ) { + throw new Error("initialLiquiditySOL must be a number when provided"); + } + } + + protected async _call(input: string): Promise { + try { + // Parse and normalize input + input = input.trim(); + const parsedInput = JSON.parse(input); + + this.validateInput(parsedInput); + + // Launch token with validated input + await this.solanaKit.launchPumpFunToken( + parsedInput.tokenName, + parsedInput.tokenTicker, + parsedInput.description, + parsedInput.imageUrl, + { + twitter: parsedInput.twitter, + telegram: parsedInput.telegram, + website: parsedInput.website, + initialLiquiditySOL: parsedInput.initialLiquiditySOL, + }, + ); + + return JSON.stringify({ + status: "success", + message: "Token launched successfully on Pump.fun", + tokenName: parsedInput.tokenName, + tokenTicker: parsedInput.tokenTicker, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/tools/pyth/index.ts b/src/langchain/tools/pyth/index.ts new file mode 100644 index 0000000..4185ac7 --- /dev/null +++ b/src/langchain/tools/pyth/index.ts @@ -0,0 +1,2 @@ +export * from "./pyth-price.tool"; +export * from "./types"; diff --git a/src/langchain/tools/pyth/pyth-price.tool.ts b/src/langchain/tools/pyth/pyth-price.tool.ts new file mode 100644 index 0000000..a4e8bae --- /dev/null +++ b/src/langchain/tools/pyth/pyth-price.tool.ts @@ -0,0 +1,34 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { PythPriceResponse } from "./types"; + +export class SolanaPythFetchPrice extends BaseSolanaTool { + name = "solana_pyth_fetch_price"; + description = `Fetch the price of a given price feed from Pyth's Hermes service + + Inputs: + tokenSymbol: string, e.g., BTC for bitcoin`; + + async _call(input: string): Promise { + try { + const priceFeedID = await this.solanaKit.getPythPriceFeedID(input); + const price = await this.solanaKit.getPythPrice(priceFeedID); + + const response = { + status: "success", + tokenSymbol: input, + priceFeedID, + price, + }; + + return JSON.stringify(response); + } catch (error: any) { + const response: PythPriceResponse = { + status: "error", + tokenSymbol: input, + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }; + return JSON.stringify(response); + } + } +} diff --git a/src/langchain/tools/pyth/types.ts b/src/langchain/tools/pyth/types.ts new file mode 100644 index 0000000..8e31745 --- /dev/null +++ b/src/langchain/tools/pyth/types.ts @@ -0,0 +1,11 @@ +import { BaseToolResponse } from "../common/types"; + +export interface PythFetchPriceInput { + tokenSymbol: string; +} + +export interface PythPriceResponse extends BaseToolResponse { + tokenSymbol?: string; + priceFeedID?: string; + price?: string; +} diff --git a/src/langchain/tools/raydium/index.ts b/src/langchain/tools/raydium/index.ts new file mode 100644 index 0000000..90602a7 --- /dev/null +++ b/src/langchain/tools/raydium/index.ts @@ -0,0 +1,4 @@ +export * from "./raydium-amm.tool"; +export * from "./raydium-clmm.tool"; +export * from "./raydium-cpmm.tool"; +export * from "./types"; diff --git a/src/langchain/tools/raydium/raydium-amm.tool.ts b/src/langchain/tools/raydium/raydium-amm.tool.ts new file mode 100644 index 0000000..c4e997f --- /dev/null +++ b/src/langchain/tools/raydium/raydium-amm.tool.ts @@ -0,0 +1,36 @@ +import { PublicKey } from "@solana/web3.js"; +import { BN } from "@coral-xyz/anchor"; +import { BaseSolanaTool } from "../common/base.tool"; +import { RaydiumAmmV4Input } from "./types"; + +export class SolanaRaydiumCreateAmmV4 extends BaseSolanaTool { + name = "raydium_create_ammV4"; + description = `Raydium's Legacy AMM that requires an OpenBook marketID + + Inputs (input is a json string): + marketId: string (required) + baseAmount: number(int), eg: 111111 (required) + quoteAmount: number(int), eg: 111111 (required) + startTime: number(seconds), eg: now number or zero (required)`; + + protected async _call(input: string): Promise { + try { + const params: RaydiumAmmV4Input = JSON.parse(input); + + const tx = await this.solanaKit.raydiumCreateAmmV4( + new PublicKey(params.marketId), + new BN(params.baseAmount), + new BN(params.quoteAmount), + new BN(params.startTime), + ); + + return JSON.stringify({ + status: "success", + message: "Raydium amm v4 pool created successfully", + transaction: tx, + }); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/raydium/raydium-clmm.tool.ts b/src/langchain/tools/raydium/raydium-clmm.tool.ts new file mode 100644 index 0000000..ea9ebcd --- /dev/null +++ b/src/langchain/tools/raydium/raydium-clmm.tool.ts @@ -0,0 +1,39 @@ +import { PublicKey } from "@solana/web3.js"; +import { BN } from "@coral-xyz/anchor"; +import { Decimal } from "decimal.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { RaydiumClmmInput } from "./types"; + +export class SolanaRaydiumCreateClmm extends BaseSolanaTool { + name = "raydium_create_clmm"; + description = `Concentrated liquidity market maker, custom liquidity ranges, increased capital efficiency + + Inputs (input is a json string): + mint1: string (required) + mint2: string (required) + configId: string (required) stores pool info, id, index, protocolFeeRate, tradeFeeRate, tickSpacing, fundFeeRate + initialPrice: number, eg: 123.12 (required) + startTime: number(seconds), eg: now number or zero (required)`; + + protected async _call(input: string): Promise { + try { + const params: RaydiumClmmInput = JSON.parse(input); + + const tx = await this.solanaKit.raydiumCreateClmm( + new PublicKey(params.mint1), + new PublicKey(params.mint2), + new PublicKey(params.configId), + new Decimal(params.initialPrice), + new BN(params.startTime), + ); + + return JSON.stringify({ + status: "success", + message: "Raydium clmm pool created successfully", + transaction: tx, + }); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/raydium/raydium-cpmm.tool.ts b/src/langchain/tools/raydium/raydium-cpmm.tool.ts new file mode 100644 index 0000000..3424886 --- /dev/null +++ b/src/langchain/tools/raydium/raydium-cpmm.tool.ts @@ -0,0 +1,40 @@ +import { PublicKey } from "@solana/web3.js"; +import { BN } from "@coral-xyz/anchor"; +import { BaseSolanaTool } from "../common/base.tool"; +import { RaydiumCpmmInput } from "./types"; + +export class SolanaRaydiumCreateCpmm extends BaseSolanaTool { + name = "raydium_create_cpmm"; + description = `Raydium's newest CPMM, does not require marketID, supports Token 2022 standard + + Inputs (input is a json string): + mint1: string (required) + mint2: string (required) + configId: string (required), stores pool info, index, protocolFeeRate, tradeFeeRate, fundFeeRate, createPoolFee + mintAAmount: number(int), eg: 1111 (required) + mintBAmount: number(int), eg: 2222 (required) + startTime: number(seconds), eg: now number or zero (required)`; + + protected async _call(input: string): Promise { + try { + const params: RaydiumCpmmInput = JSON.parse(input); + + const tx = await this.solanaKit.raydiumCreateCpmm( + new PublicKey(params.mint1), + new PublicKey(params.mint2), + new PublicKey(params.configId), + new BN(params.mintAAmount), + new BN(params.mintBAmount), + new BN(params.startTime), + ); + + return JSON.stringify({ + status: "success", + message: "Raydium cpmm pool created successfully", + transaction: tx, + }); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/raydium/types.ts b/src/langchain/tools/raydium/types.ts new file mode 100644 index 0000000..8eeab17 --- /dev/null +++ b/src/langchain/tools/raydium/types.ts @@ -0,0 +1,23 @@ +export interface RaydiumAmmV4Input { + marketId: string; + baseAmount: number | string; + quoteAmount: number | string; + startTime: number; +} + +export interface RaydiumClmmInput { + mint1: string; + mint2: string; + configId: string; + initialPrice: number | string; + startTime: number; +} + +export interface RaydiumCpmmInput { + mint1: string; + mint2: string; + configId: string; + mintAAmount: number | string; + mintBAmount: number | string; + startTime: number; +} diff --git a/src/langchain/tools/rugcheck/index.ts b/src/langchain/tools/rugcheck/index.ts new file mode 100644 index 0000000..1d37ef4 --- /dev/null +++ b/src/langchain/tools/rugcheck/index.ts @@ -0,0 +1,3 @@ +export * from "./token-report-summary.tool"; +export * from "./token-report-detailed.tool"; +export * from "./types"; diff --git a/src/langchain/tools/rugcheck/token-report-detailed.tool.ts b/src/langchain/tools/rugcheck/token-report-detailed.tool.ts new file mode 100644 index 0000000..3463c10 --- /dev/null +++ b/src/langchain/tools/rugcheck/token-report-detailed.tool.ts @@ -0,0 +1,25 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { TokenReportResponse } from "./types"; + +export class SolanaFetchTokenDetailedReportTool extends BaseSolanaTool { + name = "solana_fetch_token_detailed_report"; + description = `Fetches a detailed report for a specific token from RugCheck. + Inputs: + - mint: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required).`; + + protected async _call(input: string): Promise { + try { + const mint = input.trim(); + const detailedReport = + await this.solanaKit.fetchTokenDetailedReport(mint); + + return JSON.stringify({ + status: "success", + message: "Detailed token report fetched successfully", + report: detailedReport, + } as TokenReportResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/rugcheck/token-report-summary.tool.ts b/src/langchain/tools/rugcheck/token-report-summary.tool.ts new file mode 100644 index 0000000..47df2e8 --- /dev/null +++ b/src/langchain/tools/rugcheck/token-report-summary.tool.ts @@ -0,0 +1,24 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { TokenReportResponse } from "./types"; + +export class SolanaFetchTokenReportSummaryTool extends BaseSolanaTool { + name = "solana_fetch_token_report_summary"; + description = `Fetches a summary report for a specific token from RugCheck. + Inputs: + - mint: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required).`; + + protected async _call(input: string): Promise { + try { + const mint = input.trim(); + const report = await this.solanaKit.fetchTokenReportSummary(mint); + + return JSON.stringify({ + status: "success", + message: "Token report summary fetched successfully", + report, + } as TokenReportResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/rugcheck/types.ts b/src/langchain/tools/rugcheck/types.ts new file mode 100644 index 0000000..7d440a9 --- /dev/null +++ b/src/langchain/tools/rugcheck/types.ts @@ -0,0 +1,17 @@ +import { BaseToolResponse } from "../common/types"; + +export interface TokenCheckResult { + tokenProgram: string; + tokenType: string; + risks: Array<{ + name: string; + level: string; + description: string; + score: number; + }>; + score: number; +} + +export interface TokenReportResponse extends BaseToolResponse { + report?: TokenCheckResult; +} diff --git a/src/langchain/tools/sendarcade/index.ts b/src/langchain/tools/sendarcade/index.ts new file mode 100644 index 0000000..3ea3ff4 --- /dev/null +++ b/src/langchain/tools/sendarcade/index.ts @@ -0,0 +1,2 @@ +export * from "./rock-paper-scissors.tool"; +export * from "./types"; diff --git a/src/langchain/tools/sendarcade/rock-paper-scissors.tool.ts b/src/langchain/tools/sendarcade/rock-paper-scissors.tool.ts new file mode 100644 index 0000000..987dda1 --- /dev/null +++ b/src/langchain/tools/sendarcade/rock-paper-scissors.tool.ts @@ -0,0 +1,28 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { RockPaperScissorsInput } from "./types"; + +export class SolanaRockPaperScissorsTool extends BaseSolanaTool { + name = "rock_paper_scissors"; + description = `Play rock paper scissors to win SEND coins. + + Inputs (input is a JSON string): + choice: string, either "rock", "paper", or "scissors" (required) + amount: number, amount of SOL to play with - must be 0.1, 0.01, or 0.005 SOL (required)`; + + protected async _call(input: string): Promise { + try { + const params: RockPaperScissorsInput = JSON.parse(input); + const result = await this.solanaKit.rockPaperScissors( + params.amount, + params.choice, + ); + + return JSON.stringify({ + status: "success", + message: result, + }); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/sendarcade/types.ts b/src/langchain/tools/sendarcade/types.ts new file mode 100644 index 0000000..30f19f9 --- /dev/null +++ b/src/langchain/tools/sendarcade/types.ts @@ -0,0 +1,4 @@ +export interface RockPaperScissorsInput { + choice: "rock" | "paper" | "scissors"; + amount: number; +} diff --git a/src/langchain/tools/solana/get-tps.tool.ts b/src/langchain/tools/solana/get-tps.tool.ts new file mode 100644 index 0000000..57abc86 --- /dev/null +++ b/src/langchain/tools/solana/get-tps.tool.ts @@ -0,0 +1,20 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { TPSResponse } from "./types"; + +export class SolanaTPSCalculatorTool extends BaseSolanaTool { + name = "solana_get_tps"; + description = "Get the current TPS of the Solana network"; + + async _call(_input: string): Promise { + try { + const tps = await this.solanaKit.getTPS(); + return JSON.stringify({ + status: "success", + message: `Current network TPS: ${tps}`, + tps, + } as TPSResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/solana/index.ts b/src/langchain/tools/solana/index.ts new file mode 100644 index 0000000..ae406d0 --- /dev/null +++ b/src/langchain/tools/solana/index.ts @@ -0,0 +1,3 @@ +export * from "./get-tps.tool"; +export * from "./request-funds.tool"; +export * from "./types"; diff --git a/src/langchain/tools/solana/request-funds.tool.ts b/src/langchain/tools/solana/request-funds.tool.ts new file mode 100644 index 0000000..4e96f08 --- /dev/null +++ b/src/langchain/tools/solana/request-funds.tool.ts @@ -0,0 +1,21 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { BaseToolResponse } from "../common/types"; + +export class SolanaRequestFundsTool extends BaseSolanaTool { + name = "solana_request_funds"; + description = "Request SOL from Solana faucet (devnet/testnet only)"; + + protected async _call(_input: string): Promise { + try { + await this.solanaKit.requestFaucetFunds(); + + return JSON.stringify({ + status: "success", + message: "Successfully requested faucet funds", + network: this.solanaKit.connection.rpcEndpoint.split("/")[2], + } as BaseToolResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/solana/types.ts b/src/langchain/tools/solana/types.ts new file mode 100644 index 0000000..6adb097 --- /dev/null +++ b/src/langchain/tools/solana/types.ts @@ -0,0 +1,13 @@ +import { BaseToolResponse } from "../common/types"; + +export interface CreateImageResponse extends BaseToolResponse { + images?: string[]; +} + +export interface TPSResponse extends BaseToolResponse { + tps?: number; +} + +export interface WalletAddressResponse extends BaseToolResponse { + address?: string; +} diff --git a/src/langchain/tools/solayer/index.ts b/src/langchain/tools/solayer/index.ts new file mode 100644 index 0000000..6cb45e7 --- /dev/null +++ b/src/langchain/tools/solayer/index.ts @@ -0,0 +1 @@ +export * from "./restake.tool"; diff --git a/src/langchain/tools/solayer/restake.tool.ts b/src/langchain/tools/solayer/restake.tool.ts new file mode 100644 index 0000000..16c0e1a --- /dev/null +++ b/src/langchain/tools/solayer/restake.tool.ts @@ -0,0 +1,27 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { StakeResponse } from "./types"; + +export class SolanaRestakeTool extends BaseSolanaTool { + name = "solana_restake"; + description = `This tool can be used to restake your SOL on Solayer to receive Solayer SOL (sSOL) as a Liquid Staking Token (LST). + + Inputs: + amount: number, eg 1 or 0.01 (required)`; + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input) || Number(input); + + const tx = await this.solanaKit.restake(parsedInput.amount); + + return JSON.stringify({ + status: "success", + message: "Staked successfully", + transaction: tx, + amount: parsedInput.amount, + } as StakeResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/solayer/types.ts b/src/langchain/tools/solayer/types.ts new file mode 100644 index 0000000..de3bcf1 --- /dev/null +++ b/src/langchain/tools/solayer/types.ts @@ -0,0 +1,6 @@ +import { BaseToolResponse } from "../common/types"; + +export interface StakeResponse extends BaseToolResponse { + transaction?: string; + amount?: number; +} diff --git a/src/langchain/tools/tensor/cancel-listing.tool.ts b/src/langchain/tools/tensor/cancel-listing.tool.ts new file mode 100644 index 0000000..afc0bc0 --- /dev/null +++ b/src/langchain/tools/tensor/cancel-listing.tool.ts @@ -0,0 +1,30 @@ +import { PublicKey } from "@solana/web3.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { NFTListingResponse } from "./types"; + +export class SolanaCancelNFTListingTool extends BaseSolanaTool { + name = "solana_cancel_nft_listing"; + description = `Cancel an NFT listing on Tensor Trade. + + Inputs (input is a JSON string): + nftMint: string, the mint address of the NFT (required)`; + + protected async _call(input: string): Promise { + try { + const params = JSON.parse(input); + + const tx = await this.solanaKit.tensorCancelListing( + new PublicKey(params.nftMint), + ); + + return JSON.stringify({ + status: "success", + message: "NFT listing cancelled successfully", + transaction: tx, + nftMint: params.nftMint, + } as NFTListingResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/tensor/index.ts b/src/langchain/tools/tensor/index.ts new file mode 100644 index 0000000..4a389d3 --- /dev/null +++ b/src/langchain/tools/tensor/index.ts @@ -0,0 +1,2 @@ +export * from "./list-nft.tool"; +export * from "./cancel-listing.tool"; diff --git a/src/langchain/tools/tensor/list-nft.tool.ts b/src/langchain/tools/tensor/list-nft.tool.ts new file mode 100644 index 0000000..712ff33 --- /dev/null +++ b/src/langchain/tools/tensor/list-nft.tool.ts @@ -0,0 +1,49 @@ +import { PublicKey } from "@solana/web3.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { ListNFTInput, NFTListingResponse } from "./types"; + +export class SolanaListNFTForSaleTool extends BaseSolanaTool { + name = "solana_list_nft_for_sale"; + description = `List an NFT for sale on Tensor Trade. + + Inputs (input is a JSON string): + nftMint: string, the mint address of the NFT (required) + price: number, price in SOL (required)`; + + protected async _call(input: string): Promise { + try { + const params: ListNFTInput = JSON.parse(input); + + // Validate NFT ownership + const nftAccount = + await this.solanaKit.connection.getTokenAccountsByOwner( + this.solanaKit.wallet_address, + { mint: new PublicKey(params.nftMint) }, + ); + + if (nftAccount.value.length === 0) { + return JSON.stringify({ + status: "error", + message: + "NFT not found in wallet. Please make sure you own this NFT.", + code: "NFT_NOT_FOUND", + } as NFTListingResponse); + } + + const tx = await this.solanaKit.tensorListNFT( + new PublicKey(params.nftMint), + params.price, + ); + + return JSON.stringify({ + status: "success", + message: "NFT listed for sale successfully", + transaction: tx, + price: params.price, + nftMint: params.nftMint, + } as NFTListingResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/tensor/types.ts b/src/langchain/tools/tensor/types.ts new file mode 100644 index 0000000..2ff243f --- /dev/null +++ b/src/langchain/tools/tensor/types.ts @@ -0,0 +1,22 @@ +import { BaseToolResponse } from "../common/types"; + +export interface ListNFTInput { + nftMint: string; + price: number; +} + +export interface MintNFTResponse extends BaseToolResponse { + mintAddress?: string; + metadata?: { + name: string; + symbol?: string; + uri: string; + }; + recipient?: string; +} + +export interface NFTListingResponse extends BaseToolResponse { + transaction?: string; + price?: number; + nftMint?: string; +} diff --git a/src/langchain/tools/tiplink/index.ts b/src/langchain/tools/tiplink/index.ts new file mode 100644 index 0000000..d0fae37 --- /dev/null +++ b/src/langchain/tools/tiplink/index.ts @@ -0,0 +1,2 @@ +export * from "./tiplink.tool"; +export * from "./types"; diff --git a/src/langchain/tools/tiplink/tiplink.tool.ts b/src/langchain/tools/tiplink/tiplink.tool.ts new file mode 100644 index 0000000..b92825d --- /dev/null +++ b/src/langchain/tools/tiplink/tiplink.tool.ts @@ -0,0 +1,42 @@ +import { PublicKey } from "@solana/web3.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { TipLinkInput, TipLinkResponse } from "./types"; + +export class SolanaTipLinkTool extends BaseSolanaTool { + name = "solana_tiplink"; + description = `Create a TipLink for transferring SOL or SPL tokens. + Input is a JSON string with: + - amount: number (required) - Amount to transfer + - splmintAddress: string (optional) - SPL token mint address`; + + protected async _call(input: string): Promise { + try { + const params: TipLinkInput = JSON.parse(input); + + if (!params.amount) { + throw new Error("Amount is required"); + } + + const amount = parseFloat(params.amount.toString()); + const splmintAddress = params.splmintAddress + ? new PublicKey(params.splmintAddress) + : undefined; + + const { url, signature } = await this.solanaKit.createTiplink( + amount, + splmintAddress, + ); + + return JSON.stringify({ + status: "success", + message: "TipLink created successfully", + url, + signature, + amount, + tokenType: splmintAddress ? "SPL" : "SOL", + } as TipLinkResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/tiplink/types.ts b/src/langchain/tools/tiplink/types.ts new file mode 100644 index 0000000..285f002 --- /dev/null +++ b/src/langchain/tools/tiplink/types.ts @@ -0,0 +1,13 @@ +import { BaseToolResponse } from "../common/types"; + +export interface TipLinkInput { + amount: number; + splmintAddress?: string; +} + +export interface TipLinkResponse extends BaseToolResponse { + url?: string; + signature?: string; + amount?: number; + tokenType?: "SOL" | "SPL"; +} diff --git a/src/langchain/tools/token/close-empty-accounts.tool.ts b/src/langchain/tools/token/close-empty-accounts.tool.ts new file mode 100644 index 0000000..1d31815 --- /dev/null +++ b/src/langchain/tools/token/close-empty-accounts.tool.ts @@ -0,0 +1,23 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { CloseEmptyAccountsResponse } from "./types"; + +export class SolanaCloseEmptyTokenAccounts extends BaseSolanaTool { + name = "close_empty_token_accounts"; + description = `Close all empty spl-token accounts and reclaim the rent`; + + protected async _call(): Promise { + try { + const { signature, size } = + await this.solanaKit.closeEmptyTokenAccounts(); + + return JSON.stringify({ + status: "success", + message: `${size} accounts closed successfully. ${size === 48 ? "48 accounts can be closed in a single transaction try again to close more accounts" : ""}`, + signature, + size, + } as CloseEmptyAccountsResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/token/compressed-airdrop.tool.ts b/src/langchain/tools/token/compressed-airdrop.tool.ts new file mode 100644 index 0000000..ce83903 --- /dev/null +++ b/src/langchain/tools/token/compressed-airdrop.tool.ts @@ -0,0 +1,38 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { CompressedAirdropInput, CompressedAirdropResponse } from "./types"; + +export class SolanaCompressedAirdropTool extends BaseSolanaTool { + name = "solana_compressed_airdrop"; + description = `Airdrop SPL tokens with ZK Compression (also called as airdropping tokens) + + Inputs (input is a JSON string): + mintAddress: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required) + amount: number, the amount of tokens to airdrop per recipient, e.g., 42 (required) + decimals: number, the decimals of the token, e.g., 6 (required) + recipients: string[], the recipient addresses, e.g., ["1nc1nerator11111111111111111111111111111111"] (required) + priorityFeeInLamports: number, the priority fee in lamports. Default is 30_000. (optional) + shouldLog: boolean, whether to log progress to stdout. Default is false. (optional)`; + + protected async _call(input: string): Promise { + try { + const params: CompressedAirdropInput = JSON.parse(input); + + const txs = await this.solanaKit.sendCompressedAirdrop( + params.mintAddress, + params.amount, + params.decimals, + params.recipients, + params.priorityFeeInLamports || 30_000, + params.shouldLog || false, + ); + + return JSON.stringify({ + status: "success", + message: `Airdropped ${params.amount} tokens to ${params.recipients.length} recipients.`, + transactionHashes: txs, + } as CompressedAirdropResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/token/deploy-token.tool.ts b/src/langchain/tools/token/deploy-token.tool.ts new file mode 100644 index 0000000..919e0ee --- /dev/null +++ b/src/langchain/tools/token/deploy-token.tool.ts @@ -0,0 +1,37 @@ +import { BaseSolanaTool } from "../common/base.tool"; +import { DeployTokenInput, DeployTokenResponse } from "./types"; + +export class SolanaDeployTokenTool extends BaseSolanaTool { + name = "solana_deploy_token"; + description = `Deploy a new token on Solana blockchain. + + Inputs (input is a JSON string): + name: string, eg "My Token" (required) + uri: string, eg "https://example.com/token.json" (required) + symbol: string, eg "MTK" (required) + decimals?: number, eg 9 (optional, defaults to 9) + initialSupply?: number, eg 1000000 (optional)`; + + protected async _call(input: string): Promise { + try { + const params: DeployTokenInput = JSON.parse(input); + + const result = await this.solanaKit.deployToken( + params.name, + params.uri, + params.symbol, + params.decimals, + params.initialSupply, + ); + + return JSON.stringify({ + status: "success", + message: "Token deployed successfully", + mintAddress: result.mint.toString(), + decimals: params.decimals || 9, + } as DeployTokenResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/token/index.ts b/src/langchain/tools/token/index.ts new file mode 100644 index 0000000..3db909d --- /dev/null +++ b/src/langchain/tools/token/index.ts @@ -0,0 +1,5 @@ +export * from "./deploy-token.tool"; +export * from "./compressed-airdrop.tool"; +export * from "./close-empty-accounts.tool"; +export * from "./transfer.tool"; +export * from "./types"; diff --git a/src/langchain/tools/token/transfer.tool.ts b/src/langchain/tools/token/transfer.tool.ts new file mode 100644 index 0000000..2a8e8e1 --- /dev/null +++ b/src/langchain/tools/token/transfer.tool.ts @@ -0,0 +1,39 @@ +import { PublicKey } from "@solana/web3.js"; +import { BaseSolanaTool } from "../common/base.tool"; +import { TransferToolInput, TransferToolResponse } from "./types"; + +export class SolanaTransferTool extends BaseSolanaTool { + name = "solana_transfer"; + description = `Transfer tokens or SOL to another address ( also called as wallet address ). + + Inputs ( input is a JSON string ): + to: string, eg "8x2dR8Mpzuz2YqyZyZjUbYWKSWesBo5jMx2Q9Y86udVk" (required) + amount: number, eg 1 (required) + mint?: string, eg "So11111111111111111111111111111111111111112" or "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (optional)`; + + protected async _call(input: string): Promise { + try { + const params: TransferToolInput = JSON.parse(input); + + const recipient = new PublicKey(params.to); + const mintAddress = params.mint ? new PublicKey(params.mint) : undefined; + + const tx = await this.solanaKit.transfer( + recipient, + params.amount, + mintAddress, + ); + + return JSON.stringify({ + status: "success", + message: "Transfer completed successfully", + amount: params.amount, + recipient: params.to, + token: params.mint || "SOL", + transaction: tx, + } as TransferToolResponse); + } catch (error: any) { + return this.handleError(error); + } + } +} diff --git a/src/langchain/tools/token/types.ts b/src/langchain/tools/token/types.ts new file mode 100644 index 0000000..624f786 --- /dev/null +++ b/src/langchain/tools/token/types.ts @@ -0,0 +1,45 @@ +import { BaseToolResponse } from "../common/types"; + +export interface DeployTokenInput { + name: string; + uri: string; + symbol: string; + decimals?: number; + initialSupply?: number; +} + +export interface DeployTokenResponse extends BaseToolResponse { + mintAddress?: string; + decimals?: number; +} + +export interface CompressedAirdropInput { + mintAddress: string; + amount: number; + decimals: number; + recipients: string[]; + priorityFeeInLamports?: number; + shouldLog?: boolean; +} + +export interface CompressedAirdropResponse extends BaseToolResponse { + transactionHashes?: string[]; +} + +export interface CloseEmptyAccountsResponse extends BaseToolResponse { + signature?: string; + size?: number; +} + +export interface TransferToolInput { + to: string; + amount: number; + mint?: string; +} + +export interface TransferToolResponse extends BaseToolResponse { + amount?: number; + recipient?: string; + token?: string; + transaction?: string; +} diff --git a/src/tools/create_3land_collectible.ts b/src/tools/3land/create_3land_collectible.ts similarity index 100% rename from src/tools/create_3land_collectible.ts rename to src/tools/3land/create_3land_collectible.ts diff --git a/src/tools/3land/index.ts b/src/tools/3land/index.ts new file mode 100644 index 0000000..13200de --- /dev/null +++ b/src/tools/3land/index.ts @@ -0,0 +1 @@ +export * from "./create_3land_collectible"; diff --git a/src/tools/adrena_perp_trading.ts b/src/tools/adrena/adrena_perp_trading.ts similarity index 98% rename from src/tools/adrena_perp_trading.ts rename to src/tools/adrena/adrena_perp_trading.ts index 8c47216..ec6e8f1 100644 --- a/src/tools/adrena_perp_trading.ts +++ b/src/tools/adrena/adrena_perp_trading.ts @@ -3,13 +3,13 @@ import { SystemProgram, TransactionInstruction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; -import { TOKENS, DEFAULT_OPTIONS } from "../constants"; +import { SolanaAgentKit } from "../../index"; +import { TOKENS, DEFAULT_OPTIONS } from "../../constants"; import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { BN } from "@coral-xyz/anchor"; -import AdrenaClient from "../utils/AdrenaClient"; -import { sendTx } from "../utils/send_tx"; +import AdrenaClient from "../../utils/AdrenaClient"; +import { sendTx } from "../../utils/send_tx"; const PRICE_DECIMALS = 10; const ADRENA_PROGRAM_ID = new PublicKey( diff --git a/src/tools/adrena/index.ts b/src/tools/adrena/index.ts new file mode 100644 index 0000000..8ad923a --- /dev/null +++ b/src/tools/adrena/index.ts @@ -0,0 +1 @@ +export * from "./adrena_perp_trading"; diff --git a/src/tools/create_image.ts b/src/tools/agent/create_image.ts similarity index 95% rename from src/tools/create_image.ts rename to src/tools/agent/create_image.ts index 106f3c2..91d5913 100644 --- a/src/tools/create_image.ts +++ b/src/tools/agent/create_image.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import OpenAI from "openai"; /** diff --git a/src/tools/get_wallet_address.ts b/src/tools/agent/get_wallet_address.ts similarity index 81% rename from src/tools/get_wallet_address.ts rename to src/tools/agent/get_wallet_address.ts index bf3c763..c302a86 100644 --- a/src/tools/get_wallet_address.ts +++ b/src/tools/agent/get_wallet_address.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; /** * Get the agents wallet address diff --git a/src/tools/agent/index.ts b/src/tools/agent/index.ts new file mode 100644 index 0000000..b3f2f51 --- /dev/null +++ b/src/tools/agent/index.ts @@ -0,0 +1,2 @@ +export * from "./create_image"; +export * from "./get_wallet_address"; diff --git a/src/tools/get_balance.ts b/src/tools/balance/get_balance.ts similarity index 94% rename from src/tools/get_balance.ts rename to src/tools/balance/get_balance.ts index a1e3736..36dbd36 100644 --- a/src/tools/get_balance.ts +++ b/src/tools/balance/get_balance.ts @@ -1,5 +1,5 @@ import { LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Get the balance of SOL or an SPL token for the agent's wallet diff --git a/src/tools/get_balance_other.ts b/src/tools/balance/get_balance_other.ts similarity index 97% rename from src/tools/get_balance_other.ts rename to src/tools/balance/get_balance_other.ts index 84c1c32..32df37c 100644 --- a/src/tools/get_balance_other.ts +++ b/src/tools/balance/get_balance_other.ts @@ -3,7 +3,7 @@ import { ParsedAccountData, PublicKey, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Get the balance of SOL or an SPL token for the specified wallet address (other than the agent's wallet) diff --git a/src/tools/balance/index.ts b/src/tools/balance/index.ts new file mode 100644 index 0000000..a5c50b1 --- /dev/null +++ b/src/tools/balance/index.ts @@ -0,0 +1,2 @@ +export * from "./get_balance"; +export * from "./get_balance_other"; diff --git a/src/tools/get_token_data.ts b/src/tools/dexscreener/get_token_data.ts similarity index 97% rename from src/tools/get_token_data.ts rename to src/tools/dexscreener/get_token_data.ts index 6e6bc44..1278d57 100644 --- a/src/tools/get_token_data.ts +++ b/src/tools/dexscreener/get_token_data.ts @@ -1,5 +1,5 @@ import { PublicKey } from "@solana/web3.js"; -import { JupiterTokenData } from "../types"; +import { JupiterTokenData } from "../../types"; export async function getTokenDataByAddress( mint: PublicKey, diff --git a/src/tools/dexscreener/index.ts b/src/tools/dexscreener/index.ts new file mode 100644 index 0000000..b9a3389 --- /dev/null +++ b/src/tools/dexscreener/index.ts @@ -0,0 +1 @@ +export * from "./get_token_data"; diff --git a/src/tools/get_all_domains_tlds.ts b/src/tools/domain/get_all_domains_tlds.ts similarity index 91% rename from src/tools/get_all_domains_tlds.ts rename to src/tools/domain/get_all_domains_tlds.ts index 4d2fcbd..2b84c2a 100644 --- a/src/tools/get_all_domains_tlds.ts +++ b/src/tools/domain/get_all_domains_tlds.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { getAllTld } from "@onsol/tldparser"; /** diff --git a/src/tools/get_all_registered_all_domains.ts b/src/tools/domain/get_all_registered_all_domains.ts similarity index 95% rename from src/tools/get_all_registered_all_domains.ts rename to src/tools/domain/get_all_registered_all_domains.ts index 019a5ea..1e5cd0e 100644 --- a/src/tools/get_all_registered_all_domains.ts +++ b/src/tools/domain/get_all_registered_all_domains.ts @@ -1,5 +1,5 @@ import { getAllDomains } from "@bonfida/spl-name-service"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { PublicKey } from "@solana/web3.js"; import { getAllDomainsTLDs } from "./get_all_domains_tlds"; diff --git a/src/tools/get_main_all_domains_domain.ts b/src/tools/domain/get_main_all_domains_domain.ts similarity index 100% rename from src/tools/get_main_all_domains_domain.ts rename to src/tools/domain/get_main_all_domains_domain.ts diff --git a/src/tools/get_owned_all_domains.ts b/src/tools/domain/get_owned_all_domains.ts similarity index 94% rename from src/tools/get_owned_all_domains.ts rename to src/tools/domain/get_owned_all_domains.ts index aa52e1e..87fda7c 100644 --- a/src/tools/get_owned_all_domains.ts +++ b/src/tools/domain/get_owned_all_domains.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { PublicKey } from "@solana/web3.js"; import { TldParser } from "@onsol/tldparser"; diff --git a/src/tools/get_owned_domains_for_tld.ts b/src/tools/domain/get_owned_domains_for_tld.ts similarity index 94% rename from src/tools/get_owned_domains_for_tld.ts rename to src/tools/domain/get_owned_domains_for_tld.ts index c3fde6a..347a180 100644 --- a/src/tools/get_owned_domains_for_tld.ts +++ b/src/tools/domain/get_owned_domains_for_tld.ts @@ -1,5 +1,5 @@ import { TldParser } from "@onsol/tldparser"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; /** * Get all domains owned by an address for a specific TLD * @param agent SolanaAgentKit instance diff --git a/src/tools/get_primary_domain.ts b/src/tools/domain/get_primary_domain.ts similarity index 96% rename from src/tools/get_primary_domain.ts rename to src/tools/domain/get_primary_domain.ts index 8e53f1d..ac0ff8f 100644 --- a/src/tools/get_primary_domain.ts +++ b/src/tools/domain/get_primary_domain.ts @@ -1,6 +1,6 @@ import { getPrimaryDomain as _getPrimaryDomain } from "@bonfida/spl-name-service"; import { PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../agent"; /** * Retrieves the primary .sol domain associated with a given Solana public key. diff --git a/src/tools/domain/index.ts b/src/tools/domain/index.ts new file mode 100644 index 0000000..4cbab02 --- /dev/null +++ b/src/tools/domain/index.ts @@ -0,0 +1,9 @@ +export * from "./get_all_domains_tlds"; +export * from "./get_all_registered_all_domains"; +export * from "./get_main_all_domains_domain"; +export * from "./get_owned_all_domains"; +export * from "./get_owned_domains_for_tld"; +export * from "./get_primary_domain"; +export * from "./register_domain"; +export * from "./resolve_domain"; +export * from "./resolve_sol_domain"; diff --git a/src/tools/register_domain.ts b/src/tools/domain/register_domain.ts similarity index 94% rename from src/tools/register_domain.ts rename to src/tools/domain/register_domain.ts index 1348001..a747f2d 100644 --- a/src/tools/register_domain.ts +++ b/src/tools/domain/register_domain.ts @@ -1,8 +1,8 @@ import { registerDomainNameV2 } from "@bonfida/spl-name-service"; import { Transaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../agent"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; -import { TOKENS } from "../constants"; +import { TOKENS } from "../../constants"; /** * Register a .sol domain name using Bonfida Name Service diff --git a/src/tools/resolve_domain.ts b/src/tools/domain/resolve_domain.ts similarity index 94% rename from src/tools/resolve_domain.ts rename to src/tools/domain/resolve_domain.ts index 6de2206..3230e2b 100644 --- a/src/tools/resolve_domain.ts +++ b/src/tools/domain/resolve_domain.ts @@ -1,5 +1,5 @@ import { TldParser } from "@onsol/tldparser"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../agent"; import { PublicKey } from "@solana/web3.js"; /** diff --git a/src/tools/resolve_sol_domain.ts b/src/tools/domain/resolve_sol_domain.ts similarity index 95% rename from src/tools/resolve_sol_domain.ts rename to src/tools/domain/resolve_sol_domain.ts index 32b090b..9f87295 100644 --- a/src/tools/resolve_sol_domain.ts +++ b/src/tools/domain/resolve_sol_domain.ts @@ -1,6 +1,6 @@ import { resolve } from "@bonfida/spl-name-service"; import { PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Resolves a .sol domain to a Solana PublicKey. diff --git a/src/tools/flash_close_trade.ts b/src/tools/flash/flash_close_trade.ts similarity index 96% rename from src/tools/flash_close_trade.ts rename to src/tools/flash/flash_close_trade.ts index c30d0b6..cdd2b4f 100644 --- a/src/tools/flash_close_trade.ts +++ b/src/tools/flash/flash_close_trade.ts @@ -1,7 +1,7 @@ import { ComputeBudgetProgram } from "@solana/web3.js"; import { PoolConfig, Side } from "flash-sdk"; import { BN } from "@coral-xyz/anchor"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { CLOSE_POSITION_CU, marketSdkInfo, @@ -10,8 +10,8 @@ import { fetchOraclePrice, createPerpClient, get_flash_privilege, -} from "../utils/flashUtils"; -import { FlashCloseTradeParams } from "../types"; +} from "../../utils/flashUtils"; +import { FlashCloseTradeParams } from "../../types"; /** * Closes an existing position on Flash.Trade diff --git a/src/tools/flash_open_trade.ts b/src/tools/flash/flash_open_trade.ts similarity index 98% rename from src/tools/flash_open_trade.ts rename to src/tools/flash/flash_open_trade.ts index 6a646dc..5af7c60 100644 --- a/src/tools/flash_open_trade.ts +++ b/src/tools/flash/flash_open_trade.ts @@ -8,7 +8,7 @@ import { Custody, } from "flash-sdk"; import { BN } from "@coral-xyz/anchor"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { ALL_TOKENS, marketSdkInfo, @@ -18,8 +18,8 @@ import { fetchOraclePrice, createPerpClient, get_flash_privilege, -} from "../utils/flashUtils"; -import { FlashTradeParams } from "../types"; +} from "../../utils/flashUtils"; +import { FlashTradeParams } from "../../types"; /** * Opens a new position on Flash.Trade diff --git a/src/tools/flash/index.ts b/src/tools/flash/index.ts new file mode 100644 index 0000000..9ba0ee8 --- /dev/null +++ b/src/tools/flash/index.ts @@ -0,0 +1,2 @@ +export * from "./flash_open_trade"; +export * from "./flash_close_trade"; diff --git a/src/tools/create_gibwork_task.ts b/src/tools/gibwork/create_gibwork_task.ts similarity index 97% rename from src/tools/create_gibwork_task.ts rename to src/tools/gibwork/create_gibwork_task.ts index 40ff3c3..3c06f8b 100644 --- a/src/tools/create_gibwork_task.ts +++ b/src/tools/gibwork/create_gibwork_task.ts @@ -1,6 +1,6 @@ import { VersionedTransaction } from "@solana/web3.js"; import { PublicKey } from "@solana/web3.js"; -import { GibworkCreateTaskReponse, SolanaAgentKit } from "../index"; +import { GibworkCreateTaskReponse, SolanaAgentKit } from "../../index"; /** * Create an new task on Gibwork diff --git a/src/tools/gibwork/index.ts b/src/tools/gibwork/index.ts new file mode 100644 index 0000000..aa738b2 --- /dev/null +++ b/src/tools/gibwork/index.ts @@ -0,0 +1 @@ +export * from "./create_gibwork_task"; diff --git a/src/tools/index.ts b/src/tools/index.ts index 2363e3a..7cb43ce 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -1,52 +1,24 @@ -export * from "./adrena_perp_trading"; -export * from "./create_gibwork_task"; -export * from "./create_image"; -export * from "./create_tiplinks"; -export * from "./deploy_collection"; -export * from "./deploy_token"; -export * from "./fetch_price"; -export * from "./get_all_domains_tlds"; -export * from "./get_all_registered_all_domains"; -export * from "./get_balance"; -export * from "./get_balance_other"; -export * from "./get_main_all_domains_domain"; -export * from "./get_owned_all_domains"; -export * from "./get_owned_domains_for_tld"; -export * from "./get_primary_domain"; -export * from "./get_token_data"; -export * from "./get_tps"; -export * from "./get_wallet_address"; -export * from "./launch_pumpfun_token"; -export * from "./lend"; -export * from "./manifest_trade"; -export * from "./mint_nft"; -export * from "./openbook_create_market"; -export * from "./orca_close_position"; -export * from "./orca_create_clmm"; -export * from "./orca_create_single_sided_liquidity_pool"; -export * from "./orca_fetch_positions"; -export * from "./orca_open_centered_position_with_liquidity"; -export * from "./orca_open_single_sided_position"; -export * from "./pyth_fetch_price"; -export * from "./raydium_create_ammV4"; -export * from "./raydium_create_clmm"; -export * from "./raydium_create_cpmm"; -export * from "./register_domain"; -export * from "./request_faucet_funds"; -export * from "./resolve_domain"; -export * from "./resolve_sol_domain"; -export * from "./rock_paper_scissor"; +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 "./send_compressed_airdrop"; -export * from "./stake_with_jup"; -export * from "./stake_with_solayer"; -export * from "./tensor_trade"; - -export * from "./close_empty_token_accounts"; - -export * from "./trade"; -export * from "./transfer"; -export * from "./flash_open_trade"; -export * from "./flash_close_trade"; - -export * from "./create_3land_collectible"; +export * from "./sendarcade"; +export * from "./solayer"; +export * from "./tensor"; +export * from "./3land"; +export * from "./tiplink"; +export * from "./token"; diff --git a/src/tools/fetch_price.ts b/src/tools/jupiter/fetch_price.ts similarity index 100% rename from src/tools/fetch_price.ts rename to src/tools/jupiter/fetch_price.ts diff --git a/src/tools/jupiter/index.ts b/src/tools/jupiter/index.ts new file mode 100644 index 0000000..6007331 --- /dev/null +++ b/src/tools/jupiter/index.ts @@ -0,0 +1,3 @@ +export * from "./fetch_price"; +export * from "./stake_with_jup"; +export * from "./trade"; diff --git a/src/tools/stake_with_jup.ts b/src/tools/jupiter/stake_with_jup.ts similarity index 97% rename from src/tools/stake_with_jup.ts rename to src/tools/jupiter/stake_with_jup.ts index c05915b..1db0955 100644 --- a/src/tools/stake_with_jup.ts +++ b/src/tools/jupiter/stake_with_jup.ts @@ -1,5 +1,5 @@ import { VersionedTransaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Stake SOL with Jup validator diff --git a/src/tools/trade.ts b/src/tools/jupiter/trade.ts similarity index 97% rename from src/tools/trade.ts rename to src/tools/jupiter/trade.ts index 4e11712..f4b2776 100644 --- a/src/tools/trade.ts +++ b/src/tools/jupiter/trade.ts @@ -1,11 +1,11 @@ import { VersionedTransaction, PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { TOKENS, DEFAULT_OPTIONS, JUP_API, JUP_REFERRAL_ADDRESS, -} from "../constants"; +} from "../../constants"; import { getMint } from "@solana/spl-token"; /** * Swap tokens using Jupiter Exchange diff --git a/src/tools/lulo/index.ts b/src/tools/lulo/index.ts new file mode 100644 index 0000000..a28ed36 --- /dev/null +++ b/src/tools/lulo/index.ts @@ -0,0 +1 @@ +export * from "./lend"; diff --git a/src/tools/lend.ts b/src/tools/lulo/lend.ts similarity index 97% rename from src/tools/lend.ts rename to src/tools/lulo/lend.ts index 732f00c..9a6644c 100644 --- a/src/tools/lend.ts +++ b/src/tools/lulo/lend.ts @@ -1,5 +1,5 @@ import { VersionedTransaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Lend tokens for yields using Lulo diff --git a/src/tools/manifest/index.ts b/src/tools/manifest/index.ts new file mode 100644 index 0000000..d69980c --- /dev/null +++ b/src/tools/manifest/index.ts @@ -0,0 +1 @@ +export * from "./manifest_trade"; diff --git a/src/tools/manifest_trade.ts b/src/tools/manifest/manifest_trade.ts similarity index 99% rename from src/tools/manifest_trade.ts rename to src/tools/manifest/manifest_trade.ts index e65aef7..9ef1fb3 100644 --- a/src/tools/manifest_trade.ts +++ b/src/tools/manifest/manifest_trade.ts @@ -11,7 +11,7 @@ import { Transaction, TransactionInstruction, } from "@solana/web3.js"; -import { BatchOrderPattern, OrderParams, SolanaAgentKit } from "../index"; +import { BatchOrderPattern, OrderParams, SolanaAgentKit } from "../../index"; export async function manifestCreateMarket( agent: SolanaAgentKit, diff --git a/src/tools/deploy_collection.ts b/src/tools/metaplex/deploy_collection.ts similarity index 94% rename from src/tools/deploy_collection.ts rename to src/tools/metaplex/deploy_collection.ts index 10fef9d..0b981be 100644 --- a/src/tools/deploy_collection.ts +++ b/src/tools/metaplex/deploy_collection.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { generateSigner, keypairIdentity, @@ -9,7 +9,7 @@ import { mplCore, ruleSet, } from "@metaplex-foundation/mpl-core"; -import { CollectionOptions, CollectionDeployment } from "../types"; +import { CollectionOptions, CollectionDeployment } from "../../types"; import { fromWeb3JsKeypair, toWeb3JsPublicKey, diff --git a/src/tools/metaplex/index.ts b/src/tools/metaplex/index.ts new file mode 100644 index 0000000..d6fe812 --- /dev/null +++ b/src/tools/metaplex/index.ts @@ -0,0 +1,2 @@ +export * from "./deploy_collection"; +export * from "./mint_nft"; diff --git a/src/tools/mint_nft.ts b/src/tools/metaplex/mint_nft.ts similarity index 95% rename from src/tools/mint_nft.ts rename to src/tools/metaplex/mint_nft.ts index 4c25b91..dd6b68c 100644 --- a/src/tools/mint_nft.ts +++ b/src/tools/metaplex/mint_nft.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { generateSigner, keypairIdentity } from "@metaplex-foundation/umi"; import { create, mplCore } from "@metaplex-foundation/mpl-core"; import { fetchCollection } from "@metaplex-foundation/mpl-core"; @@ -9,7 +9,7 @@ import { toWeb3JsPublicKey, } from "@metaplex-foundation/umi-web3js-adapters"; import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; -import { MintCollectionNFTResponse } from "../types"; +import { MintCollectionNFTResponse } from "../../types"; /** * Mint a new NFT as part of an existing collection diff --git a/src/tools/openbook/index.ts b/src/tools/openbook/index.ts new file mode 100644 index 0000000..58d481e --- /dev/null +++ b/src/tools/openbook/index.ts @@ -0,0 +1 @@ +export * from "./openbook_create_market"; diff --git a/src/tools/openbook_create_market.ts b/src/tools/openbook/openbook_create_market.ts similarity index 96% rename from src/tools/openbook_create_market.ts rename to src/tools/openbook/openbook_create_market.ts index c7c12aa..1702ba3 100644 --- a/src/tools/openbook_create_market.ts +++ b/src/tools/openbook/openbook_create_market.ts @@ -5,7 +5,7 @@ import { } from "@raydium-io/raydium-sdk-v2"; import { MintLayout, TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function openbookCreateMarket( agent: SolanaAgentKit, diff --git a/src/tools/orca/index.ts b/src/tools/orca/index.ts new file mode 100644 index 0000000..a405eb2 --- /dev/null +++ b/src/tools/orca/index.ts @@ -0,0 +1,6 @@ +export * from "./orca_close_position"; +export * from "./orca_create_clmm"; +export * from "./orca_create_single_sided_liquidity_pool"; +export * from "./orca_fetch_positions"; +export * from "./orca_open_centered_position_with_liquidity"; +export * from "./orca_open_single_sided_position"; diff --git a/src/tools/orca_close_position.ts b/src/tools/orca/orca_close_position.ts similarity index 96% rename from src/tools/orca_close_position.ts rename to src/tools/orca/orca_close_position.ts index 4475692..0cf758a 100644 --- a/src/tools/orca_close_position.ts +++ b/src/tools/orca/orca_close_position.ts @@ -4,7 +4,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { ORCA_WHIRLPOOL_PROGRAM_ID, @@ -12,7 +12,7 @@ import { buildWhirlpoolClient, PDAUtil, } from "@orca-so/whirlpools-sdk"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; import { Percentage } from "@orca-so/common-sdk"; /** diff --git a/src/tools/orca_create_clmm.ts b/src/tools/orca/orca_create_clmm.ts similarity index 98% rename from src/tools/orca_create_clmm.ts rename to src/tools/orca/orca_create_clmm.ts index 9fcdc33..4d3bb50 100644 --- a/src/tools/orca_create_clmm.ts +++ b/src/tools/orca/orca_create_clmm.ts @@ -4,7 +4,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { Decimal } from "decimal.js"; import { @@ -14,7 +14,7 @@ import { PoolUtil, buildWhirlpoolClient, } from "@orca-so/whirlpools-sdk"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; import { FEE_TIERS } from "./orca_create_single_sided_liquidity_pool"; /** diff --git a/src/tools/orca_create_single_sided_liquidity_pool.ts b/src/tools/orca/orca_create_single_sided_liquidity_pool.ts similarity index 99% rename from src/tools/orca_create_single_sided_liquidity_pool.ts rename to src/tools/orca/orca_create_single_sided_liquidity_pool.ts index 26792b8..c05a148 100644 --- a/src/tools/orca_create_single_sided_liquidity_pool.ts +++ b/src/tools/orca/orca_create_single_sided_liquidity_pool.ts @@ -4,7 +4,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { BN, Wallet } from "@coral-xyz/anchor"; import { Decimal } from "decimal.js"; import { @@ -36,7 +36,7 @@ import { getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, } from "@solana/spl-token"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; /** * Maps fee tier bps to their corresponding tick spacing values in the Orca Whirlpool protocol. diff --git a/src/tools/orca_fetch_positions.ts b/src/tools/orca/orca_fetch_positions.ts similarity index 98% rename from src/tools/orca_fetch_positions.ts rename to src/tools/orca/orca_fetch_positions.ts index f90b8a0..edeba5a 100644 --- a/src/tools/orca_fetch_positions.ts +++ b/src/tools/orca/orca_fetch_positions.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { ORCA_WHIRLPOOL_PROGRAM_ID, diff --git a/src/tools/orca_open_centered_position_with_liquidity.ts b/src/tools/orca/orca_open_centered_position_with_liquidity.ts similarity index 98% rename from src/tools/orca_open_centered_position_with_liquidity.ts rename to src/tools/orca/orca_open_centered_position_with_liquidity.ts index 63a8972..0fea787 100644 --- a/src/tools/orca_open_centered_position_with_liquidity.ts +++ b/src/tools/orca/orca_open_centered_position_with_liquidity.ts @@ -5,7 +5,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { Decimal } from "decimal.js"; import { @@ -18,7 +18,7 @@ import { NO_TOKEN_EXTENSION_CONTEXT, } from "@orca-so/whirlpools-sdk"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; import { Percentage } from "@orca-so/common-sdk"; import { TOKEN_2022_PROGRAM_ID } from "@solana/spl-token"; diff --git a/src/tools/orca_open_single_sided_position.ts b/src/tools/orca/orca_open_single_sided_position.ts similarity index 98% rename from src/tools/orca_open_single_sided_position.ts rename to src/tools/orca/orca_open_single_sided_position.ts index 741069a..daaec60 100644 --- a/src/tools/orca_open_single_sided_position.ts +++ b/src/tools/orca/orca_open_single_sided_position.ts @@ -4,7 +4,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { Decimal } from "decimal.js"; import { @@ -16,7 +16,7 @@ import { TokenExtensionContextForPool, NO_TOKEN_EXTENSION_CONTEXT, } from "@orca-so/whirlpools-sdk"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; import { Percentage } from "@orca-so/common-sdk"; import { TOKEN_2022_PROGRAM_ID } from "@solana/spl-token"; diff --git a/src/tools/pumpfun/index.ts b/src/tools/pumpfun/index.ts new file mode 100644 index 0000000..2d7cc24 --- /dev/null +++ b/src/tools/pumpfun/index.ts @@ -0,0 +1 @@ +export * from "./launch_pumpfun_token"; diff --git a/src/tools/launch_pumpfun_token.ts b/src/tools/pumpfun/launch_pumpfun_token.ts similarity index 99% rename from src/tools/launch_pumpfun_token.ts rename to src/tools/pumpfun/launch_pumpfun_token.ts index 08fd3bf..b18a05a 100644 --- a/src/tools/launch_pumpfun_token.ts +++ b/src/tools/pumpfun/launch_pumpfun_token.ts @@ -4,7 +4,7 @@ import { PumpfunLaunchResponse, PumpFunTokenOptions, SolanaAgentKit, -} from "../index"; +} from "../../index"; async function uploadMetadata( tokenName: string, diff --git a/src/tools/pyth/index.ts b/src/tools/pyth/index.ts new file mode 100644 index 0000000..118e222 --- /dev/null +++ b/src/tools/pyth/index.ts @@ -0,0 +1 @@ +export * from "./pyth_fetch_price"; diff --git a/src/tools/pyth_fetch_price.ts b/src/tools/pyth/pyth_fetch_price.ts similarity index 98% rename from src/tools/pyth_fetch_price.ts rename to src/tools/pyth/pyth_fetch_price.ts index 0946af4..ef5b6fa 100644 --- a/src/tools/pyth_fetch_price.ts +++ b/src/tools/pyth/pyth_fetch_price.ts @@ -1,5 +1,5 @@ import BN from "bn.js"; -import { PythPriceFeedIDItem } from "../types"; +import { PythPriceFeedIDItem } from "../../types"; /** * Fetch the price feed ID for a given token symbol from Pyth diff --git a/src/tools/raydium/index.ts b/src/tools/raydium/index.ts new file mode 100644 index 0000000..a116c1f --- /dev/null +++ b/src/tools/raydium/index.ts @@ -0,0 +1,3 @@ +export * from "./raydium_create_ammV4"; +export * from "./raydium_create_clmm"; +export * from "./raydium_create_cpmm"; diff --git a/src/tools/raydium_create_ammV4.ts b/src/tools/raydium/raydium_create_ammV4.ts similarity index 97% rename from src/tools/raydium_create_ammV4.ts rename to src/tools/raydium/raydium_create_ammV4.ts index 98f641e..1b5ce71 100644 --- a/src/tools/raydium_create_ammV4.ts +++ b/src/tools/raydium/raydium_create_ammV4.ts @@ -9,7 +9,7 @@ import { import { MintLayout, TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function raydiumCreateAmmV4( agent: SolanaAgentKit, diff --git a/src/tools/raydium_create_clmm.ts b/src/tools/raydium/raydium_create_clmm.ts similarity index 97% rename from src/tools/raydium_create_clmm.ts rename to src/tools/raydium/raydium_create_clmm.ts index 7d049d4..611c2f1 100644 --- a/src/tools/raydium_create_clmm.ts +++ b/src/tools/raydium/raydium_create_clmm.ts @@ -7,7 +7,7 @@ import { MintLayout } from "@solana/spl-token"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import Decimal from "decimal.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function raydiumCreateClmm( agent: SolanaAgentKit, diff --git a/src/tools/raydium_create_cpmm.ts b/src/tools/raydium/raydium_create_cpmm.ts similarity index 97% rename from src/tools/raydium_create_cpmm.ts rename to src/tools/raydium/raydium_create_cpmm.ts index 35c702d..59f1124 100644 --- a/src/tools/raydium_create_cpmm.ts +++ b/src/tools/raydium/raydium_create_cpmm.ts @@ -7,7 +7,7 @@ import { import { MintLayout } from "@solana/spl-token"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function raydiumCreateCpmm( agent: SolanaAgentKit, diff --git a/src/tools/rugcheck/index.ts b/src/tools/rugcheck/index.ts new file mode 100644 index 0000000..0201430 --- /dev/null +++ b/src/tools/rugcheck/index.ts @@ -0,0 +1 @@ +export * from "./rugcheck"; diff --git a/src/tools/rugcheck.ts b/src/tools/rugcheck/rugcheck.ts similarity index 97% rename from src/tools/rugcheck.ts rename to src/tools/rugcheck/rugcheck.ts index 11d533d..923c0f5 100644 --- a/src/tools/rugcheck.ts +++ b/src/tools/rugcheck/rugcheck.ts @@ -1,4 +1,4 @@ -import { TokenCheck } from "../types"; +import { TokenCheck } from "../../types"; const BASE_URL = "https://api.rugcheck.xyz/v1"; diff --git a/src/tools/sendarcade/index.ts b/src/tools/sendarcade/index.ts new file mode 100644 index 0000000..5d09c37 --- /dev/null +++ b/src/tools/sendarcade/index.ts @@ -0,0 +1 @@ +export * from "./rock_paper_scissor"; diff --git a/src/tools/rock_paper_scissor.ts b/src/tools/sendarcade/rock_paper_scissor.ts similarity index 98% rename from src/tools/rock_paper_scissor.ts rename to src/tools/sendarcade/rock_paper_scissor.ts index 8a0603e..f2a48c2 100644 --- a/src/tools/rock_paper_scissor.ts +++ b/src/tools/sendarcade/rock_paper_scissor.ts @@ -1,5 +1,5 @@ import { sendAndConfirmTransaction, Transaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; export async function rock_paper_scissor( agent: SolanaAgentKit, diff --git a/src/tools/get_tps.ts b/src/tools/solana/get_tps.ts similarity index 90% rename from src/tools/get_tps.ts rename to src/tools/solana/get_tps.ts index 7314ce3..1c29a79 100644 --- a/src/tools/get_tps.ts +++ b/src/tools/solana/get_tps.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function getTPS(agent: SolanaAgentKit): Promise { const perfSamples = await agent.connection.getRecentPerformanceSamples(); diff --git a/src/tools/solana/index.ts b/src/tools/solana/index.ts new file mode 100644 index 0000000..2e0b65a --- /dev/null +++ b/src/tools/solana/index.ts @@ -0,0 +1,2 @@ +export * from "./get_tps"; +export * from "./request_faucet_funds"; diff --git a/src/tools/request_faucet_funds.ts b/src/tools/solana/request_faucet_funds.ts similarity index 93% rename from src/tools/request_faucet_funds.ts rename to src/tools/solana/request_faucet_funds.ts index bde8eed..3ce9111 100644 --- a/src/tools/request_faucet_funds.ts +++ b/src/tools/solana/request_faucet_funds.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { LAMPORTS_PER_SOL } from "@solana/web3.js"; /** diff --git a/src/tools/solayer/index.ts b/src/tools/solayer/index.ts new file mode 100644 index 0000000..79dc074 --- /dev/null +++ b/src/tools/solayer/index.ts @@ -0,0 +1 @@ +export * from "./stake_with_solayer"; diff --git a/src/tools/stake_with_solayer.ts b/src/tools/solayer/stake_with_solayer.ts similarity index 97% rename from src/tools/stake_with_solayer.ts rename to src/tools/solayer/stake_with_solayer.ts index e2ef643..edbb8ff 100644 --- a/src/tools/stake_with_solayer.ts +++ b/src/tools/solayer/stake_with_solayer.ts @@ -1,5 +1,5 @@ import { VersionedTransaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Stake SOL with Solayer diff --git a/src/tools/tensor/index.ts b/src/tools/tensor/index.ts new file mode 100644 index 0000000..574b361 --- /dev/null +++ b/src/tools/tensor/index.ts @@ -0,0 +1 @@ +export * from "./tensor_trade"; diff --git a/src/tools/tensor_trade.ts b/src/tools/tensor/tensor_trade.ts similarity index 98% rename from src/tools/tensor_trade.ts rename to src/tools/tensor/tensor_trade.ts index 4025ac3..b96069b 100644 --- a/src/tools/tensor_trade.ts +++ b/src/tools/tensor/tensor_trade.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { TensorSwapSDK } from "@tensor-oss/tensorswap-sdk"; import { PublicKey, Transaction } from "@solana/web3.js"; import { AnchorProvider, Wallet } from "@coral-xyz/anchor"; diff --git a/src/tools/create_tiplinks.ts b/src/tools/tiplink/create_tiplinks.ts similarity index 98% rename from src/tools/create_tiplinks.ts rename to src/tools/tiplink/create_tiplinks.ts index 20348ad..f38dbc1 100644 --- a/src/tools/create_tiplinks.ts +++ b/src/tools/tiplink/create_tiplinks.ts @@ -13,7 +13,7 @@ import { getMint, createAssociatedTokenAccountInstruction, } from "@solana/spl-token"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; const MINIMUM_SOL_BALANCE = 0.003 * LAMPORTS_PER_SOL; diff --git a/src/tools/tiplink/index.ts b/src/tools/tiplink/index.ts new file mode 100644 index 0000000..a5f83d2 --- /dev/null +++ b/src/tools/tiplink/index.ts @@ -0,0 +1 @@ +export * from "./create_tiplinks"; diff --git a/src/tools/close_empty_token_accounts.ts b/src/tools/token/close_empty_token_accounts.ts similarity index 98% rename from src/tools/close_empty_token_accounts.ts rename to src/tools/token/close_empty_token_accounts.ts index 9a102db..a424b96 100644 --- a/src/tools/close_empty_token_accounts.ts +++ b/src/tools/token/close_empty_token_accounts.ts @@ -3,7 +3,7 @@ import { Transaction, TransactionInstruction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { AccountLayout, createCloseAccountInstruction, diff --git a/src/tools/deploy_token.ts b/src/tools/token/deploy_token.ts similarity index 97% rename from src/tools/deploy_token.ts rename to src/tools/token/deploy_token.ts index 798e020..0f78743 100644 --- a/src/tools/deploy_token.ts +++ b/src/tools/token/deploy_token.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { PublicKey } from "@solana/web3.js"; import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; import { generateSigner, keypairIdentity } from "@metaplex-foundation/umi"; diff --git a/src/tools/token/index.ts b/src/tools/token/index.ts new file mode 100644 index 0000000..495d246 --- /dev/null +++ b/src/tools/token/index.ts @@ -0,0 +1,4 @@ +export * from "./close_empty_token_accounts"; +export * from "./deploy_token"; +export * from "./send_compressed_airdrop"; +export * from "./transfer"; diff --git a/src/tools/send_compressed_airdrop.ts b/src/tools/token/send_compressed_airdrop.ts similarity index 99% rename from src/tools/send_compressed_airdrop.ts rename to src/tools/token/send_compressed_airdrop.ts index 871c810..4d01ed6 100644 --- a/src/tools/send_compressed_airdrop.ts +++ b/src/tools/token/send_compressed_airdrop.ts @@ -5,7 +5,7 @@ import { PublicKey, TransactionInstruction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { buildAndSignTx, calculateComputeUnitPrice, diff --git a/src/tools/transfer.ts b/src/tools/token/transfer.ts similarity index 97% rename from src/tools/transfer.ts rename to src/tools/token/transfer.ts index 9e11dd7..04473d1 100644 --- a/src/tools/transfer.ts +++ b/src/tools/token/transfer.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import { LAMPORTS_PER_SOL } from "@solana/web3.js"; import {