Skip to content

Commit

Permalink
Merge branch 'main' into langchain-tool-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
thearyanag authored Jan 29, 2025
2 parents e792922 + c5a48c3 commit b237360
Show file tree
Hide file tree
Showing 11 changed files with 486 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

</div>

An open-source toolkit for connecting AI agents to Solana protocols. Now, any agent, using any model can autonomously perform 15+ Solana actions:
An open-source toolkit for connecting AI agents to Solana protocols. Now, any agent, using any model can autonomously perform 60+ Solana actions:

- Trade tokens
- Launch new tokens
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"@bonfida/spl-name-service": "^3.0.7",
"@cks-systems/manifest-sdk": "0.1.59",
"@coral-xyz/anchor": "0.29",
"@drift-labs/sdk": "2.107.0-beta.3",
"@drift-labs/vaults-sdk": "^0.2.49",
"@drift-labs/sdk": "2.108.0-beta.4",
"@drift-labs/vaults-sdk": "^0.3.2",
"@langchain/core": "^0.3.26",
"@langchain/groq": "^0.1.2",
"@langchain/langgraph": "^0.2.36",
Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ import getInfoAction from "./agent/get_info";
import getPriceInferenceAction from "./allora/getPriceInference";
import getAllTopicsAction from "./allora/getAllTopics";
import getInferenceByTopicIdAction from "./allora/getInferenceByTopicId";
import closeOrcaPositionAction from "./orca/closeOrcaPosition";
import createOrcaCLMMAction from "./orca/createOrcaCLMM";
import fetchOrcaPositionsAction from "./orca/fetchOrcaPositions";
import openOrcaCenteredPositionWithLiquidityAction from "./orca/openOrcaCenteredPositionWithLiquidity";
import openOrcaSingleSidedPositionAction from "./orca/openOrcaSingleSidedPosition";
export const ACTIONS = {
GET_INFO_ACTION: getInfoAction,
WALLET_ADDRESS_ACTION: getWalletAddressAction,
Expand Down Expand Up @@ -114,6 +119,12 @@ export const ACTIONS = {
RAYDIUM_CREATE_AMM_V4_ACTION: raydiumCreateAmmV4Action,
CREATE_ORCA_SINGLE_SIDED_WHIRLPOOL_ACTION:
createOrcaSingleSidedWhirlpoolAction,
CLOSE_ORCA_POSITION_ACTION: closeOrcaPositionAction,
CREATE_ORCA_CLMM_ACTION: createOrcaCLMMAction,
FETCH_ORCA_POSITIONS_ACTION: fetchOrcaPositionsAction,
OPEN_ORCA_CENTERED_POSITION_WITH_LIQUIDITY_ACTION:
openOrcaCenteredPositionWithLiquidityAction,
OPEN_ORCA_SINGLE_SIDED_POSITION_ACTION: openOrcaSingleSidedPositionAction,
LAUNCH_PUMPFUN_TOKEN_ACTION: launchPumpfunTokenAction,
FLASH_OPEN_TRADE_ACTION: flashOpenTradeAction,
FLASH_CLOSE_TRADE_ACTION: flashCloseTradeAction,
Expand Down
58 changes: 58 additions & 0 deletions src/actions/orca/closeOrcaPosition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { z } from "zod";
import type { Action } from "../../types";
import { orcaClosePosition } from "../../tools";
import { PublicKey } from "@solana/web3.js";

const closeOrcaPositionAction: Action = {
name: "CLOSE_ORCA_POSITION_ACTION",
similes: [
"close orca liquidity position",
"close orca whirlpool position",
"close orca liquidity pool",
"close my orca liquidity position",
],
description:
"Close an existing liquidity position in an Orca Whirlpool. This functions fetches the position details using the provided mint address and closes the position with a 1% slippage",
examples: [
[
{
input: {
positionMintAddress: "EPjasdf...",
},
output: {
status: "success",
signature: "12Erx...",
message: "Successfully closed Orca whirlpool position",
},
explanation: "Close a USDC/SOL whirlpool position",
},
],
],
schema: z.object({
positionMintAddress: z
.string()
.describe("The mint address of the liquidity position to close"),
}),
handler: async (agent, input) => {
try {
const signature = await orcaClosePosition(
agent,
new PublicKey(input.positionMintAddress),
);

return {
status: "success",
signature,
message: "Successfully closed Orca whirlpool position",
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - TS doesn't know that `e` has a `message` property
message: `Failed to close Orca whirlpool position: ${e.message}`,
};
}
},
};

export default closeOrcaPositionAction;
89 changes: 89 additions & 0 deletions src/actions/orca/createOrcaCLMM.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { z } from "zod";
import type { Action } from "../../types";
import { PublicKey } from "@solana/web3.js";
import { orcaCreateCLMM } from "../../tools";
import Decimal from "decimal.js";

const createOrcaCLMMAction: Action = {
name: "CREATE_ORCA_CLMM_ACTION",
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.",
similes: [
"create orca clmm",
"create orca concentrated pool",
"create orca clmm pool",
"create orca concentrated liquidity",
],
examples: [
[
{
input: {
mintDeploy: "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN",
mintPair: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
initialPrice: 1.1,
feeTier: 1,
},
output: {
status: "success",
message:
"CLMM pool created successfully. Note: No liquidity was added.",
},
explanation: "Create a CLMM pool with USDC and JUP",
},
],
],
schema: z.object({
mintDeploy: z
.string()
.describe("The mint address of the token you want to deploy"),
mintPair: z
.string()
.describe(
"The mint address of the token you want to pair the deployed mint with",
),
initialPrice: z
.number()
.positive()
.describe("Initial price of mintDeploy in terms of mintPair"),
feeTier: z
.number()
.positive()
.min(1)
.describe(
"The fee tier in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200",
),
}),
handler: async (agent, input) => {
try {
const [mintDeploy, mintPair, initialPrice, feeTier] = [
new PublicKey(input.mintDeploy),
new PublicKey(input.mintPair),
new Decimal(input.initialPrice),
input.feeTier,
];

const signature = await orcaCreateCLMM(
agent,
mintDeploy,
mintPair,
initialPrice,
feeTier,
);

return {
status: "success",
message:
"CLMM pool created successfully. Note: No liquidity was added.",
signature,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - TS doesn't know that `e` has a `message` property
message: `Failed to create Orca CLMM pool: ${e.message}`,
};
}
},
};

export default createOrcaCLMMAction;
54 changes: 54 additions & 0 deletions src/actions/orca/fetchOrcaPositions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { z } from "zod";
import type { Action } from "../../types";
import { orcaFetchPositions } from "../../tools";

const fetchOrcaPositionsAction: Action = {
name: "FETCH_ORCA_POSITIONS_ACTION",
description:
"Fetch all the liquidity positions in an Orca Whirlpool by owner. Returns an object with position mint addresses as keys and position status details as values.",
similes: [
"fetch orca liquidity positions",
"fetch orca whirlpool positions",
"fetch orca liquidity pools",
"fetch my orca liquidity positions",
],
examples: [
[
{
input: {},
output: {
status: "success",
message: "Liquidity positions fetched.",
positions: {
positionMintAddress1: {
whirlpoolAddress: "whirlpoolAddress1",
positionInRange: true,
distanceFromCenterBps: 250,
},
},
},
explanation: "Fetch all Orca whirlpool positions",
},
],
],
schema: z.object({}),
handler: async (agent) => {
try {
const positions = JSON.parse(await orcaFetchPositions(agent));

return {
status: "success",
message: "Liquidity positions fetched.",
positions,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - TS doesn't know that `e` has a `message` property
message: `Failed to fetch Orca whirlpool positions: ${e.message}`,
};
}
},
};

export default fetchOrcaPositionsAction;
Loading

0 comments on commit b237360

Please sign in to comment.