mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-30 15:11:22 +00:00
chore: Merge main
This commit is contained in:
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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";
|
||||
|
||||
const getAllDomainsTLDsAction: Action = {
|
||||
name: "GET_ALL_TLDS",
|
||||
@@ -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";
|
||||
|
||||
const getOwnedAllDomainsAction: Action = {
|
||||
name: "GET_OWNED_ALL_DOMAINS",
|
||||
@@ -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";
|
||||
|
||||
const getOwnedDomainsForTLDAction: Action = {
|
||||
name: "GET_OWNED_DOMAINS_FOR_TLD",
|
||||
@@ -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";
|
||||
|
||||
const resolveDomainAction: Action = {
|
||||
name: "RESOLVE_ALL_DOMAINS",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -1,35 +1,42 @@
|
||||
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 "./metaplex/deployToken";
|
||||
import balanceAction from "./solana/balance";
|
||||
import transferAction from "./solana/transfer";
|
||||
import deployCollectionAction from "./metaplex/deployCollection";
|
||||
import mintNFTAction from "./metaplex/mintNFT";
|
||||
import tradeAction from "./jupiter/trade";
|
||||
import requestFundsAction from "./solana/requestFunds";
|
||||
import resolveDomainAction from "./sns/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 "./sns/registerDomain";
|
||||
import lendAssetAction from "./lulo/lendAsset";
|
||||
import createGibworkTaskAction from "./gibwork/createGibworkTask";
|
||||
import resolveSolDomainAction from "./sns/resolveSolDomain";
|
||||
import pythFetchPriceAction from "./pyth/pythFetchPrice";
|
||||
import getOwnedDomainsForTLDAction from "./alldomains/getOwnedDomainsForTLD";
|
||||
import getPrimaryDomainAction from "./sns/getPrimaryDomain";
|
||||
import getAllDomainsTLDsAction from "./alldomains/getAllDomainsTLDs";
|
||||
import getOwnedAllDomainsAction from "./alldomains/getOwnedAllDomains";
|
||||
import createImageAction from "./agent/createImage";
|
||||
import getMainAllDomainsDomainAction from "./sns/getMainAllDomainsDomain";
|
||||
import getAllRegisteredAllDomainsAction from "./sns/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";
|
||||
import createMultisigAction from "./squads/createMultisig";
|
||||
import approveMultisigProposalAction from "./squads/approveMultisigProposal";
|
||||
import createMultisigProposalAction from "./squads/createMultisigProposal";
|
||||
import depositToMultisigAction from "./squads/depositToMultisigTreasury";
|
||||
import executeMultisigProposalAction from "./squads/executeMultisigProposal";
|
||||
import rejectMultisigProposalAction from "./squads/rejectMultisigProposal";
|
||||
import transferFromMultisigAction from "./squads/transferFromMultisigTreasury";
|
||||
|
||||
export const ACTIONS = {
|
||||
WALLET_ADDRESS_ACTION: getWalletAddressAction,
|
||||
@@ -65,6 +72,13 @@ export const ACTIONS = {
|
||||
LAUNCH_PUMPFUN_TOKEN_ACTION: launchPumpfunTokenAction,
|
||||
FLASH_OPEN_TRADE_ACTION: flashOpenTradeAction,
|
||||
FLASH_CLOSE_TRADE_ACTION: flashCloseTradeAction,
|
||||
CREATE_MULTISIG_ACTION: createMultisigAction,
|
||||
DEPOSIT_TO_MULTISIG_ACTION: depositToMultisigAction,
|
||||
TRANSFER_FROM_MULTISIG_ACTION: transferFromMultisigAction,
|
||||
CREATE_MULTISIG_PROPOSAL_ACTION: createMultisigProposalAction,
|
||||
APPROVE_MULTISIG_PROPOSAL_ACTION: approveMultisigProposalAction,
|
||||
REJECT_MULTISIG_PROPOSAL_ACTION: rejectMultisigProposalAction,
|
||||
EXECUTE_MULTISIG_PROPOSAL_ACTION: executeMultisigProposalAction,
|
||||
};
|
||||
|
||||
export type { Action, ActionExample, Handler } from "../types/action";
|
||||
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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;
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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 = {
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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";
|
||||
|
||||
const getAllRegisteredAllDomainsAction: Action = {
|
||||
name: "GET_ALL_REGISTERED_ALL_DOMAINS",
|
||||
@@ -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";
|
||||
|
||||
const getMainAllDomainsDomainAction: Action = {
|
||||
name: "GET_MAIN_ALL_DOMAINS_DOMAIN",
|
||||
@@ -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";
|
||||
|
||||
const getPrimaryDomainAction: Action = {
|
||||
name: "GET_PRIMARY_DOMAIN",
|
||||
@@ -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";
|
||||
|
||||
const registerDomainAction: Action = {
|
||||
name: "REGISTER_DOMAIN",
|
||||
@@ -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/";
|
||||
|
||||
const resolveSolDomainAction: Action = {
|
||||
name: "RESOLVE_SOL_DOMAIN",
|
||||
@@ -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";
|
||||
|
||||
const balanceAction: Action = {
|
||||
name: "BALANCE_ACTION",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
50
src/actions/squads/approveMultisigProposal.ts
Normal file
50
src/actions/squads/approveMultisigProposal.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_approve_proposal } from "../../tools";
|
||||
|
||||
const approveMultisigProposalAction: Action = {
|
||||
name: "APPROVE_MULTISIG_PROPOSAL_ACTION",
|
||||
similes: [
|
||||
"approve proposal",
|
||||
"approve proposal to transfer funds",
|
||||
"approve proposal to transfer funds from 2-of-2 multisig",
|
||||
"approve proposal to transfer funds from 2-of-2 multisig account",
|
||||
"approve proposal to transfer funds from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Approve a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.
|
||||
|
||||
Note: For one AI agent, only one 2-by-2 multisig can be created as it is pair-wise.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
transactionIndex: 0,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Proposal approved successfully",
|
||||
transaction: "4xKpN2...",
|
||||
transactionIndex: "0",
|
||||
},
|
||||
explanation:
|
||||
"Approve a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
transactionIndex: z.number().optional(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const tx = await multisig_approve_proposal(agent, input.transactionIndex);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Proposal approved successfully",
|
||||
transaction: tx,
|
||||
transactionIndex: input.transactionIndex.toString(),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default approveMultisigProposalAction;
|
||||
52
src/actions/squads/createMultisig.ts
Normal file
52
src/actions/squads/createMultisig.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { create_squads_multisig } from "../../tools";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
|
||||
const createMultisigAction: Action = {
|
||||
name: "CREATE_MULTISIG_ACTION",
|
||||
similes: [
|
||||
"create multisig",
|
||||
"create squads multisig",
|
||||
"create 2-by-2 multisig",
|
||||
"create 2-of-2 multisig",
|
||||
"create 2-of-2 multisig account",
|
||||
"create 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Create a 2-of-2 multisig account on Solana using Squads with the user and the agent, where both approvals will be required to run the transactions.
|
||||
|
||||
Note: For one AI agent, only one 2-by-2 multisig can be created as it is pair-wise.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
creator: "7nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkN",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "2-by-2 multisig account created successfully",
|
||||
signature: "4xKpN2...",
|
||||
},
|
||||
explanation: "Create a 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
creator: z.string(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const multisig = await create_squads_multisig(
|
||||
agent,
|
||||
new PublicKey(input.creator as string),
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "2-by-2 multisig account created successfully",
|
||||
signature: multisig,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default createMultisigAction;
|
||||
55
src/actions/squads/createMultisigProposal.ts
Normal file
55
src/actions/squads/createMultisigProposal.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_create_proposal } from "../../tools";
|
||||
|
||||
const createMultisigProposalAction: Action = {
|
||||
name: "CREATE_MULTISIG_PROPOSAL_ACTION",
|
||||
similes: [
|
||||
"create proposal",
|
||||
"create proposal to transfer funds",
|
||||
"create proposal to transfer funds from 2-of-2 multisig",
|
||||
"create proposal to transfer funds from 2-of-2 multisig account",
|
||||
"create proposal to transfer funds from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Create a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.
|
||||
|
||||
If transactionIndex is not provided, the latest index will automatically be fetched and used.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
transactionIndex: 0,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Proposal created successfully",
|
||||
transaction: "4xKpN2...",
|
||||
transactionIndex: "0",
|
||||
},
|
||||
explanation:
|
||||
"Create a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
transactionIndex: z.number().optional(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const transactionIndex =
|
||||
input.transactionIndex !== undefined
|
||||
? Number(input.transactionIndex)
|
||||
: undefined;
|
||||
|
||||
const multisig = await multisig_create_proposal(agent, transactionIndex);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Proposal created successfully",
|
||||
transaction: multisig,
|
||||
transactionIndex: transactionIndex,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default createMultisigProposalAction;
|
||||
49
src/actions/squads/depositToMultisigTreasury.ts
Normal file
49
src/actions/squads/depositToMultisigTreasury.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_deposit_to_treasury } from "../../tools";
|
||||
|
||||
const depositToMultisigAction: Action = {
|
||||
name: "DEPOSIT_TO_MULTISIG_ACTION",
|
||||
similes: [
|
||||
"deposit to multisig",
|
||||
"deposit to squads multisig",
|
||||
"deposit to 2-of-2 multisig account",
|
||||
"deposit to 2-of-2 multisig account on Solana",
|
||||
"deposit SOL to 2-of-2 multisig",
|
||||
"deposit SPL tokens to 2-of-2 multisig",
|
||||
],
|
||||
description: `Deposit funds to a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
amount: 1,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Funds deposited to 2-by-2 multisig account successfully",
|
||||
signature: "4xKpN2...",
|
||||
},
|
||||
explanation: "Deposit 1 SOL to 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
amount: z.number().min(0, "Amount must be greater than 0"),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const multisig = await multisig_deposit_to_treasury(
|
||||
agent,
|
||||
input.amount as number,
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Funds deposited to 2-by-2 multisig account successfully",
|
||||
signature: multisig,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default depositToMultisigAction;
|
||||
53
src/actions/squads/executeMultisigProposal.ts
Normal file
53
src/actions/squads/executeMultisigProposal.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_execute_proposal } from "../../tools";
|
||||
|
||||
const executeMultisigProposalAction: Action = {
|
||||
name: "EXECUTE_MULTISIG_PROPOSAL_ACTION",
|
||||
similes: [
|
||||
"execute proposal",
|
||||
"execute proposal to transfer funds",
|
||||
"execute proposal to transfer funds from 2-of-2 multisig",
|
||||
"execute proposal to transfer funds from 2-of-2 multisig account",
|
||||
"execute proposal to transfer funds from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Execute a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
proposalIndex: 0,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Proposal executed successfully",
|
||||
transaction: "4xKpN2...",
|
||||
proposalIndex: "0",
|
||||
},
|
||||
explanation:
|
||||
"Execute a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
proposalIndex: z.number().optional(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const proposalIndex =
|
||||
input.proposalIndex !== undefined
|
||||
? Number(input.proposalIndex)
|
||||
: undefined;
|
||||
|
||||
const multisig = await multisig_execute_proposal(agent, proposalIndex);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Proposal executed successfully",
|
||||
transaction: multisig,
|
||||
proposalIndex,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default executeMultisigProposalAction;
|
||||
53
src/actions/squads/rejectMultisigProposal.ts
Normal file
53
src/actions/squads/rejectMultisigProposal.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_reject_proposal } from "../../tools";
|
||||
|
||||
const rejectMultisigProposalAction: Action = {
|
||||
name: "REJECT_MULTISIG_PROPOSAL_ACTION",
|
||||
similes: [
|
||||
"reject proposal",
|
||||
"reject proposal to transfer funds",
|
||||
"reject proposal to transfer funds from 2-of-2 multisig",
|
||||
"reject proposal to transfer funds from 2-of-2 multisig account",
|
||||
"reject proposal to transfer funds from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Reject a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
proposalIndex: 0,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Proposal rejected successfully",
|
||||
transaction: "4xKpN2...",
|
||||
proposalIndex: "0",
|
||||
},
|
||||
explanation:
|
||||
"Reject a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
proposalIndex: z.number().optional(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const proposalIndex =
|
||||
input.proposalIndex !== undefined
|
||||
? Number(input.proposalIndex)
|
||||
: undefined;
|
||||
|
||||
const tx = await multisig_reject_proposal(agent, proposalIndex);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Proposal rejected successfully",
|
||||
transaction: tx,
|
||||
proposalIndex,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default rejectMultisigProposalAction;
|
||||
56
src/actions/squads/transferFromMultisigTreasury.ts
Normal file
56
src/actions/squads/transferFromMultisigTreasury.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_transfer_from_treasury } from "../../tools";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
|
||||
const transferFromMultisigAction: Action = {
|
||||
name: "TRANSFER_FROM_MULTISIG_ACTION",
|
||||
similes: [
|
||||
"transfer from multisig",
|
||||
"transfer from squads multisig",
|
||||
"transfer SOL from 2-by-2 multisig",
|
||||
"transfer from 2-of-2 multisig account",
|
||||
"transfer from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Create a transaction to transfer funds from a 2-of-2 multisig account on Solana using Squads with the user and the agent, where both approvals will be required to run the transactions.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
amount: 1,
|
||||
recipient: "7nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkN",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Transaction added to 2-by-2 multisig account successfully",
|
||||
transaction: "4xKpN2...",
|
||||
amount: "1",
|
||||
recipient: "7nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkN",
|
||||
},
|
||||
explanation: "Transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
amount: z.number().min(0, "Amount must be greater than 0"),
|
||||
recipient: z.string(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const multisig = await multisig_transfer_from_treasury(
|
||||
agent,
|
||||
input.amount as number,
|
||||
new PublicKey(input.recipient as string),
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Transaction added to 2-by-2 multisig account successfully",
|
||||
transaction: multisig,
|
||||
amount: input.amount,
|
||||
recipient: input.recipient,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default transferFromMultisigAction;
|
||||
@@ -2,8 +2,12 @@ import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
||||
import { BN } from "@coral-xyz/anchor";
|
||||
import bs58 from "bs58";
|
||||
import Decimal from "decimal.js";
|
||||
import {
|
||||
CreateCollectionOptions,
|
||||
CreateSingleOptions,
|
||||
StoreInitOptions,
|
||||
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
|
||||
import { DEFAULT_OPTIONS } from "../constants";
|
||||
import { Config, TokenCheck } from "../types";
|
||||
import {
|
||||
deploy_collection,
|
||||
deploy_token,
|
||||
@@ -65,8 +69,19 @@ import {
|
||||
flashCloseTrade,
|
||||
createMeteoraDynamicAMMPool,
|
||||
createMeteoraDlmmPool,
|
||||
createCollection,
|
||||
createSingle,
|
||||
multisig_transfer_from_treasury,
|
||||
create_squads_multisig,
|
||||
multisig_create_proposal,
|
||||
multisig_deposit_to_treasury,
|
||||
multisig_reject_proposal,
|
||||
multisig_approve_proposal,
|
||||
multisig_execute_proposal,
|
||||
} from "../tools";
|
||||
import {
|
||||
Config,
|
||||
TokenCheck,
|
||||
CollectionDeployment,
|
||||
CollectionOptions,
|
||||
GibworkCreateTaskReponse,
|
||||
@@ -78,22 +93,6 @@ import {
|
||||
FlashTradeParams,
|
||||
FlashCloseTradeParams,
|
||||
} from "../types";
|
||||
import {
|
||||
createCollection,
|
||||
createSingle,
|
||||
} from "../tools/create_3land_collectible";
|
||||
import {
|
||||
CreateCollectionOptions,
|
||||
CreateSingleOptions,
|
||||
StoreInitOptions,
|
||||
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
|
||||
import { create_squads_multisig } from "../tools/squads_multisig/create_multisig";
|
||||
import { deposit_to_multisig } from "../tools/squads_multisig/deposit_to_multisig";
|
||||
import { transfer_from_multisig } from "../tools/squads_multisig/transfer_from_multisig";
|
||||
import { create_proposal } from "../tools/squads_multisig/create_proposal";
|
||||
import { approve_proposal } from "../tools/squads_multisig/approve_proposal";
|
||||
import { execute_transaction } from "../tools/squads_multisig/execute_proposal";
|
||||
import { reject_proposal } from "../tools/squads_multisig/reject_proposal";
|
||||
|
||||
/**
|
||||
* Main class for interacting with Solana blockchain
|
||||
@@ -677,7 +676,7 @@ export class SolanaAgentKit {
|
||||
vaultIndex: number = 0,
|
||||
mint?: PublicKey,
|
||||
): Promise<string> {
|
||||
return deposit_to_multisig(this, amount, vaultIndex, mint);
|
||||
return multisig_deposit_to_treasury(this, amount, vaultIndex, mint);
|
||||
}
|
||||
|
||||
async transferFromMultisig(
|
||||
@@ -686,30 +685,30 @@ export class SolanaAgentKit {
|
||||
vaultIndex: number = 0,
|
||||
mint?: PublicKey,
|
||||
): Promise<string> {
|
||||
return transfer_from_multisig(this, amount, to, vaultIndex, mint);
|
||||
return multisig_transfer_from_treasury(this, amount, to, vaultIndex, mint);
|
||||
}
|
||||
|
||||
async createMultisigProposal(
|
||||
transactionIndex?: number | bigint,
|
||||
): Promise<string> {
|
||||
return create_proposal(this, transactionIndex);
|
||||
return multisig_create_proposal(this, transactionIndex);
|
||||
}
|
||||
|
||||
async approveMultisigProposal(
|
||||
transactionIndex?: number | bigint,
|
||||
): Promise<string> {
|
||||
return approve_proposal(this, transactionIndex);
|
||||
return multisig_approve_proposal(this, transactionIndex);
|
||||
}
|
||||
|
||||
async rejectMultisigProposal(
|
||||
transactionIndex?: number | bigint,
|
||||
): Promise<string> {
|
||||
return reject_proposal(this, transactionIndex);
|
||||
return multisig_reject_proposal(this, transactionIndex);
|
||||
}
|
||||
|
||||
async executeMultisigTransaction(
|
||||
transactionIndex?: number | bigint,
|
||||
): Promise<string> {
|
||||
return execute_transaction(this, transactionIndex);
|
||||
return multisig_execute_proposal(this, transactionIndex);
|
||||
}
|
||||
}
|
||||
|
||||
68
src/langchain/3land/create_collection.ts
Normal file
68
src/langchain/3land/create_collection.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import {
|
||||
CreateCollectionOptions,
|
||||
StoreInitOptions,
|
||||
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const inputFormat = JSON.parse(input);
|
||||
const privateKey = inputFormat.privateKey;
|
||||
const isMainnet = inputFormat.isMainnet;
|
||||
|
||||
const optionsWithBase58: StoreInitOptions = {
|
||||
...(privateKey && { privateKey }),
|
||||
...(isMainnet && { isMainnet }),
|
||||
};
|
||||
|
||||
const collectionSymbol = inputFormat?.collectionSymbol;
|
||||
const collectionName = inputFormat?.collectionName;
|
||||
const collectionDescription = inputFormat?.collectionDescription;
|
||||
const mainImageUrl = inputFormat?.mainImageUrl;
|
||||
const coverImageUrl = inputFormat?.coverImageUrl;
|
||||
|
||||
const collectionOpts: CreateCollectionOptions = {
|
||||
...(collectionSymbol && { collectionSymbol }),
|
||||
...(collectionName && { collectionName }),
|
||||
...(collectionDescription && { collectionDescription }),
|
||||
...(mainImageUrl && { mainImageUrl }),
|
||||
...(coverImageUrl && { coverImageUrl }),
|
||||
};
|
||||
|
||||
const tx = await this.solanaKit.create3LandCollection(
|
||||
optionsWithBase58,
|
||||
collectionOpts,
|
||||
);
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: `Created Collection successfully ${tx}`,
|
||||
transaction: tx,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
91
src/langchain/3land/create_single.ts
Normal file
91
src/langchain/3land/create_single.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import {
|
||||
CreateSingleOptions,
|
||||
StoreInitOptions,
|
||||
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const inputFormat = JSON.parse(input);
|
||||
const privateKey = inputFormat.privateKey;
|
||||
const isMainnet = inputFormat.isMainnet;
|
||||
|
||||
const optionsWithBase58: StoreInitOptions = {
|
||||
...(privateKey && { privateKey }),
|
||||
...(isMainnet && { isMainnet }),
|
||||
};
|
||||
|
||||
const collectionAccount = inputFormat.collectionAccount;
|
||||
|
||||
const itemName = inputFormat?.itemName;
|
||||
const sellerFee = inputFormat?.sellerFee;
|
||||
const itemAmount = inputFormat?.itemAmount;
|
||||
const itemSymbol = inputFormat?.itemSymbol;
|
||||
const itemDescription = inputFormat?.itemDescription;
|
||||
const traits = inputFormat?.traits;
|
||||
const price = inputFormat?.price;
|
||||
const mainImageUrl = inputFormat?.mainImageUrl;
|
||||
const coverImageUrl = inputFormat?.coverImageUrl;
|
||||
const splHash = inputFormat?.splHash;
|
||||
|
||||
const createItemOptions: CreateSingleOptions = {
|
||||
...(itemName && { itemName }),
|
||||
...(sellerFee && { sellerFee }),
|
||||
...(itemAmount && { itemAmount }),
|
||||
...(itemSymbol && { itemSymbol }),
|
||||
...(itemDescription && { itemDescription }),
|
||||
...(traits && { traits }),
|
||||
...(price && { price }),
|
||||
...(mainImageUrl && { mainImageUrl }),
|
||||
...(coverImageUrl && { coverImageUrl }),
|
||||
...(splHash && { splHash }),
|
||||
};
|
||||
|
||||
if (!collectionAccount) {
|
||||
throw new Error("Collection account is required");
|
||||
}
|
||||
|
||||
const tx = await this.solanaKit.create3LandNft(
|
||||
optionsWithBase58,
|
||||
collectionAccount,
|
||||
createItemOptions,
|
||||
isMainnet,
|
||||
);
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: `Created listing successfully ${tx}`,
|
||||
transaction: tx,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
src/langchain/3land/index.ts
Normal file
2
src/langchain/3land/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./create_single";
|
||||
export * from "./create_collection";
|
||||
49
src/langchain/adrena/close_trade.ts
Normal file
49
src/langchain/adrena/close_trade.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
src/langchain/adrena/index.ts
Normal file
2
src/langchain/adrena/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./open_trade";
|
||||
export * from "./close_trade";
|
||||
65
src/langchain/adrena/open_trade.ts
Normal file
65
src/langchain/adrena/open_trade.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const parsedInput = JSON.parse(input);
|
||||
|
||||
const tx =
|
||||
parsedInput.side === "long"
|
||||
? await this.solanaKit.openPerpTradeLong({
|
||||
price: parsedInput.price,
|
||||
collateralAmount: parsedInput.collateralAmount,
|
||||
collateralMint: new PublicKey(parsedInput.collateralMint),
|
||||
leverage: parsedInput.leverage,
|
||||
tradeMint: new PublicKey(parsedInput.tradeMint),
|
||||
slippage: parsedInput.slippage,
|
||||
})
|
||||
: await this.solanaKit.openPerpTradeLong({
|
||||
price: parsedInput.price,
|
||||
collateralAmount: parsedInput.collateralAmount,
|
||||
collateralMint: new PublicKey(parsedInput.collateralMint),
|
||||
leverage: parsedInput.leverage,
|
||||
tradeMint: new PublicKey(parsedInput.tradeMint),
|
||||
slippage: parsedInput.slippage,
|
||||
});
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Perpetual trade opened successfully",
|
||||
transaction: tx,
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
38
src/langchain/agent/create_image.ts
Normal file
38
src/langchain/agent/create_image.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { create_image } from "../../tools/agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
src/langchain/agent/index.ts
Normal file
2
src/langchain/agent/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./create_image";
|
||||
export * from "./wallet_address";
|
||||
15
src/langchain/agent/wallet_address.ts
Normal file
15
src/langchain/agent/wallet_address.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
return this.solanaKit.wallet_address.toString();
|
||||
}
|
||||
}
|
||||
29
src/langchain/alldomains/get_all_tld.ts
Normal file
29
src/langchain/alldomains/get_all_tld.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const tlds = await this.solanaKit.getAllDomainsTLDs();
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "TLDs fetched successfully",
|
||||
tlds,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "FETCH_TLDS_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
4
src/langchain/alldomains/index.ts
Normal file
4
src/langchain/alldomains/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from "./resolve_all_domains";
|
||||
export * from "./owned_domains";
|
||||
export * from "./tld_domains";
|
||||
export * from "./get_all_tld";
|
||||
34
src/langchain/alldomains/owned_domains.ts
Normal file
34
src/langchain/alldomains/owned_domains.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const ownerPubkey = new PublicKey(input.trim());
|
||||
const domains = await this.solanaKit.getOwnedAllDomains(ownerPubkey);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Owned domains fetched successfully",
|
||||
domains,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "FETCH_OWNED_DOMAINS_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
42
src/langchain/alldomains/resolve_all_domains.ts
Normal file
42
src/langchain/alldomains/resolve_all_domains.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/langchain/alldomains/tld_domains.ts
Normal file
32
src/langchain/alldomains/tld_domains.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
1
src/langchain/dexscreener/index.ts
Normal file
1
src/langchain/dexscreener/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./token_data_ticker";
|
||||
31
src/langchain/dexscreener/token_data_ticker.ts
Normal file
31
src/langchain/dexscreener/token_data_ticker.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
53
src/langchain/flash/flash_close.ts
Normal file
53
src/langchain/flash/flash_close.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
81
src/langchain/flash/flash_open.ts
Normal file
81
src/langchain/flash/flash_open.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { marketTokenMap } from "../../utils/flashUtils";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
src/langchain/flash/index.ts
Normal file
2
src/langchain/flash/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./flash_open";
|
||||
export * from "./flash_close";
|
||||
52
src/langchain/gibwork/create_task.ts
Normal file
52
src/langchain/gibwork/create_task.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { GibworkCreateTaskReponse } from "../../index";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
1
src/langchain/gibwork/index.ts
Normal file
1
src/langchain/gibwork/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./create_task";
|
||||
File diff suppressed because it is too large
Load Diff
34
src/langchain/jupiter/fetch_price.ts
Normal file
34
src/langchain/jupiter/fetch_price.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
/**
|
||||
* 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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
4
src/langchain/jupiter/index.ts
Normal file
4
src/langchain/jupiter/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from "./fetch_price";
|
||||
export * from "./token_data";
|
||||
export * from "./trade";
|
||||
export * from "./stake";
|
||||
35
src/langchain/jupiter/stake.ts
Normal file
35
src/langchain/jupiter/stake.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const parsedInput = JSON.parse(input) || Number(input);
|
||||
|
||||
const tx = await this.solanaKit.stake(parsedInput.amount);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Staked successfully",
|
||||
transaction: tx,
|
||||
amount: parsedInput.amount,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/langchain/jupiter/token_data.ts
Normal file
33
src/langchain/jupiter/token_data.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
48
src/langchain/jupiter/trade.ts
Normal file
48
src/langchain/jupiter/trade.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const parsedInput = JSON.parse(input);
|
||||
|
||||
const tx = await this.solanaKit.trade(
|
||||
new PublicKey(parsedInput.outputMint),
|
||||
parsedInput.inputAmount,
|
||||
parsedInput.inputMint
|
||||
? new PublicKey(parsedInput.inputMint)
|
||||
: new PublicKey("So11111111111111111111111111111111111111112"),
|
||||
parsedInput.slippageBps,
|
||||
);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Trade executed successfully",
|
||||
transaction: tx,
|
||||
inputAmount: parsedInput.inputAmount,
|
||||
inputToken: parsedInput.inputMint || "SOL",
|
||||
outputToken: parsedInput.outputMint,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/langchain/lightprotocol/compressed_airdrop.ts
Normal file
46
src/langchain/lightprotocol/compressed_airdrop.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
1
src/langchain/lightprotocol/index.ts
Normal file
1
src/langchain/lightprotocol/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./compressed_airdrop";
|
||||
1
src/langchain/lulo/index.ts
Normal file
1
src/langchain/lulo/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./lend_asset";
|
||||
35
src/langchain/lulo/lend_asset.ts
Normal file
35
src/langchain/lulo/lend_asset.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
97
src/langchain/manifest/batch_order.ts
Normal file
97
src/langchain/manifest/batch_order.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import { OrderParams } from "../../types";
|
||||
import { generateOrdersfromPattern } from "../../tools/manifest";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const parsedInput = JSON.parse(input);
|
||||
let ordersToPlace: OrderParams[] = [];
|
||||
|
||||
if (!parsedInput.marketId) {
|
||||
throw new Error("Market ID is required");
|
||||
}
|
||||
|
||||
if (parsedInput.pattern) {
|
||||
ordersToPlace = generateOrdersfromPattern(parsedInput.pattern);
|
||||
} else if (Array.isArray(parsedInput.orders)) {
|
||||
ordersToPlace = parsedInput.orders;
|
||||
} else {
|
||||
throw new Error("Either pattern or orders array is required");
|
||||
}
|
||||
|
||||
if (ordersToPlace.length === 0) {
|
||||
throw new Error("No orders generated or provided");
|
||||
}
|
||||
|
||||
ordersToPlace.forEach((order: OrderParams, index: number) => {
|
||||
if (!order.quantity || !order.side || !order.price) {
|
||||
throw new Error(
|
||||
`Invalid order at index ${index}: quantity, side, and price are required`,
|
||||
);
|
||||
}
|
||||
if (order.side !== "Buy" && order.side !== "Sell") {
|
||||
throw new Error(
|
||||
`Invalid side at index ${index}: must be "Buy" or "Sell"`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const tx = await this.solanaKit.batchOrder(
|
||||
new PublicKey(parsedInput.marketId),
|
||||
parsedInput.orders,
|
||||
);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Batch order executed successfully",
|
||||
transaction: tx,
|
||||
marketId: parsedInput.marketId,
|
||||
orders: parsedInput.orders,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
35
src/langchain/manifest/cancel_orders.ts
Normal file
35
src/langchain/manifest/cancel_orders.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const marketId = new PublicKey(input.trim());
|
||||
const tx = await this.solanaKit.cancelAllOrders(marketId);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Cancel orders successfully",
|
||||
transaction: tx,
|
||||
marketId,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
5
src/langchain/manifest/index.ts
Normal file
5
src/langchain/manifest/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from "./manifest_market";
|
||||
export * from "./batch_order";
|
||||
export * from "./cancel_orders";
|
||||
export * from "./limit_order";
|
||||
export * from "./withdraw";
|
||||
49
src/langchain/manifest/limit_order.ts
Normal file
49
src/langchain/manifest/limit_order.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const parsedInput = JSON.parse(input);
|
||||
|
||||
const tx = await this.solanaKit.limitOrder(
|
||||
new PublicKey(parsedInput.marketId),
|
||||
parsedInput.quantity,
|
||||
parsedInput.side,
|
||||
parsedInput.price,
|
||||
);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Trade executed successfully",
|
||||
transaction: tx,
|
||||
marketId: parsedInput.marketId,
|
||||
quantity: parsedInput.quantity,
|
||||
side: parsedInput.side,
|
||||
price: parsedInput.price,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/langchain/manifest/manifest_market.ts
Normal file
41
src/langchain/manifest/manifest_market.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
35
src/langchain/manifest/withdraw.ts
Normal file
35
src/langchain/manifest/withdraw.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
try {
|
||||
const marketId = new PublicKey(input.trim());
|
||||
const tx = await this.solanaKit.withdrawAll(marketId);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Withdrew successfully",
|
||||
transaction: tx,
|
||||
marketId,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
37
src/langchain/metaplex/deploy_collection.ts
Normal file
37
src/langchain/metaplex/deploy_collection.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
45
src/langchain/metaplex/deploy_token.ts
Normal file
45
src/langchain/metaplex/deploy_token.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
3
src/langchain/metaplex/index.ts
Normal file
3
src/langchain/metaplex/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from "./deploy_collection";
|
||||
export * from "./mint_nft";
|
||||
export * from "./deploy_token";
|
||||
53
src/langchain/metaplex/mint_nft.ts
Normal file
53
src/langchain/metaplex/mint_nft.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
src/langchain/meteora/index.ts
Normal file
2
src/langchain/meteora/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./meteora_dlmm_pool";
|
||||
export * from "./meteora_dynamic_pool";
|
||||
83
src/langchain/meteora/meteora_dlmm_pool.ts
Normal file
83
src/langchain/meteora/meteora_dlmm_pool.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { BN } from "bn.js";
|
||||
|
||||
export class SolanaMeteoraCreateDlmmPool extends Tool {
|
||||
name = "meteora_create_dlmm_pool";
|
||||
description = `Create a Meteora DLMM Pool. This function doesn't add liquidity.
|
||||
|
||||
Inputs (JSON string):
|
||||
- tokenAMint: string, token A mint (required).
|
||||
- tokenBMint: string, token B mint (required).
|
||||
- binStep: number, pool bin step, e.g., 20 (required).
|
||||
- initialPrice: number, pool initial price, e.g., 0.25 (required).
|
||||
- feeBps: number, trade fee in percentage, e.g. 20 for 0.2% (required).
|
||||
- priceRoundingUp: boolean, whether the initial price should be rounded up or not, default is true (optional).
|
||||
- activationType: number, pool start trading time indicator. 0 is slot and 1 is timestamp, default is 1 for timestamp (optional).
|
||||
- activationPoint: number, pool start trading slot / timestamp, default is null means pool can start trading immediately (optional).
|
||||
- hasAlphaVault: boolean, whether the pool supports alpha vault, default is false (optional).
|
||||
- computeUnitMicroLamports: number, the priority fee in micro-lamports unit, default is 100000 (optional).
|
||||
`;
|
||||
|
||||
constructor(private solanaKit: SolanaAgentKit) {
|
||||
super();
|
||||
}
|
||||
|
||||
async _call(input: string): Promise<string> {
|
||||
try {
|
||||
interface CreateMeteoraDlmmPoolInput {
|
||||
tokenAMint: string;
|
||||
tokenBMint: string;
|
||||
binStep: number;
|
||||
initialPrice: number;
|
||||
feeBps: number;
|
||||
priceRoundingUp?: boolean;
|
||||
activationType?: number;
|
||||
activationPoint?: number;
|
||||
hasAlphaVault?: boolean;
|
||||
computeUnitMicroLamports?: number;
|
||||
}
|
||||
const inputFormat: CreateMeteoraDlmmPoolInput = JSON.parse(input);
|
||||
|
||||
const tokenAMint = new PublicKey(inputFormat.tokenAMint);
|
||||
const tokenBMint = new PublicKey(inputFormat.tokenBMint);
|
||||
const binStep = inputFormat.binStep;
|
||||
const initialPrice = inputFormat.initialPrice;
|
||||
const feeBps = inputFormat.feeBps;
|
||||
const priceRoundingUp = inputFormat.priceRoundingUp ?? true;
|
||||
const activationType = inputFormat.activationType ?? 1;
|
||||
const activationPoint = inputFormat.activationPoint
|
||||
? new BN(inputFormat.activationPoint)
|
||||
: undefined;
|
||||
const hasAlphaVault = inputFormat.hasAlphaVault ?? false;
|
||||
const computeUnitMicroLamports =
|
||||
inputFormat.computeUnitMicroLamports ?? 100000;
|
||||
|
||||
const txId = await this.solanaKit.meteoraCreateDlmmPool(
|
||||
tokenAMint,
|
||||
tokenBMint,
|
||||
binStep,
|
||||
initialPrice,
|
||||
priceRoundingUp,
|
||||
feeBps,
|
||||
activationType,
|
||||
hasAlphaVault,
|
||||
activationPoint,
|
||||
computeUnitMicroLamports,
|
||||
);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Meteora DLMM pool created successfully.",
|
||||
transaction: txId,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
82
src/langchain/meteora/meteora_dynamic_pool.ts
Normal file
82
src/langchain/meteora/meteora_dynamic_pool.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { BN } from "bn.js";
|
||||
|
||||
export class SolanaMeteoraCreateDynamicPool extends Tool {
|
||||
name = "meteora_create_dynamic_pool";
|
||||
description = `Create a Meteora Dynamic Pool. This function adds liquidity with a constant-product formula.
|
||||
|
||||
Inputs (JSON string):
|
||||
- tokenAMint: string, token A mint (required).
|
||||
- tokenBMint: string, token B mint (required).
|
||||
- tokenAAmount: number, token A amount including decimals, e.g., 1000000000 (required).
|
||||
- tokenBAmount: number, token B amount including decimals, e.g., 1000000000 (required).
|
||||
- tradeFeeNumerator: number, trade fee numerator, e.g., 2500 for 2.5% (required).
|
||||
- activationType: number, pool start trading time indicator, 0 is slot and 1 is timestamp, default is 1 for timestamp (optional).
|
||||
- activationPoint: number, pool start trading slot / timestamp, default is null means pool can start trading immediately (optional).
|
||||
- hasAlphaVault: boolean, whether the pool supports alpha vault, default is false (optional).
|
||||
- computeUnitMicroLamports: number, the priority fee in micro-lamports unit, default is 100000 (optional).
|
||||
`;
|
||||
|
||||
constructor(private solanaKit: SolanaAgentKit) {
|
||||
super();
|
||||
}
|
||||
|
||||
async _call(input: string): Promise<string> {
|
||||
try {
|
||||
interface CreateMeteoraDynamicAmmPoolInput {
|
||||
tokenAMint: string;
|
||||
tokenBMint: string;
|
||||
tokenAAmount: number;
|
||||
tokenBAmount: number;
|
||||
tradeFeeNumerator: number;
|
||||
activationType?: number;
|
||||
activationPoint?: number;
|
||||
hasAlphaVault?: boolean;
|
||||
computeUnitMicroLamports?: number;
|
||||
}
|
||||
const inputFormat: CreateMeteoraDynamicAmmPoolInput = JSON.parse(input);
|
||||
|
||||
const tokenAMint = new PublicKey(inputFormat.tokenAMint);
|
||||
const tokenBMint = new PublicKey(inputFormat.tokenBMint);
|
||||
const tokenAAmount = new BN(inputFormat.tokenAAmount.toString());
|
||||
const tokenBAmount = new BN(inputFormat.tokenBAmount.toString());
|
||||
|
||||
const tradeFeeNumerator = new BN(
|
||||
inputFormat.tradeFeeNumerator.toString(),
|
||||
).toNumber();
|
||||
const activationType = inputFormat.activationType ?? 1;
|
||||
const activationPoint = inputFormat.activationPoint
|
||||
? new BN(inputFormat.activationPoint)
|
||||
: null;
|
||||
const hasAlphaVault = inputFormat.hasAlphaVault ?? false;
|
||||
const computeUnitMicroLamports =
|
||||
inputFormat.computeUnitMicroLamports ?? 100000;
|
||||
|
||||
const txId = await this.solanaKit.meteoraCreateDynamicPool(
|
||||
tokenAMint,
|
||||
tokenBMint,
|
||||
tokenAAmount,
|
||||
tokenBAmount,
|
||||
tradeFeeNumerator,
|
||||
activationPoint,
|
||||
hasAlphaVault,
|
||||
activationType,
|
||||
computeUnitMicroLamports,
|
||||
);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Meteora Dynamic pool created successfully.",
|
||||
transaction: txId,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
1
src/langchain/openbook/index.ts
Normal file
1
src/langchain/openbook/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./openbook_market";
|
||||
45
src/langchain/openbook/openbook_market.ts
Normal file
45
src/langchain/openbook/openbook_market.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
6
src/langchain/orca/index.ts
Normal file
6
src/langchain/orca/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from "./orca_clmm";
|
||||
export * from "./orca_single_sided_pool";
|
||||
export * from "./orca_position";
|
||||
export * from "./orca_fetch_positions";
|
||||
export * from "./orca_centered_position";
|
||||
export * from "./orca_single_sided_position";
|
||||
54
src/langchain/orca/orca_centered_position.ts
Normal file
54
src/langchain/orca/orca_centered_position.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Decimal } from "decimal.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
58
src/langchain/orca/orca_clmm.ts
Normal file
58
src/langchain/orca/orca_clmm.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Decimal } from "decimal.js";
|
||||
import { FEE_TIERS } from "../../tools/orca";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/langchain/orca/orca_fetch_positions.ts
Normal file
29
src/langchain/orca/orca_fetch_positions.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/langchain/orca/orca_position.ts
Normal file
39
src/langchain/orca/orca_position.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
65
src/langchain/orca/orca_single_sided_pool.ts
Normal file
65
src/langchain/orca/orca_single_sided_pool.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Decimal } from "decimal.js";
|
||||
import { FEE_TIERS } from "../../tools/orca";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
58
src/langchain/orca/orca_single_sided_position.ts
Normal file
58
src/langchain/orca/orca_single_sided_position.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Decimal } from "decimal.js";
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
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<string> {
|
||||
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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
1
src/langchain/pumpfun/index.ts
Normal file
1
src/langchain/pumpfun/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./launch_pumpfun_token";
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user