Merge branch 'main' into feat/drift-tool

This commit is contained in:
aryan
2025-01-18 01:34:39 +05:30
committed by GitHub
32 changed files with 1431 additions and 70 deletions

View File

@@ -14,6 +14,8 @@ import stakeWithJupAction from "./jupiter/stakeWithJup";
import stakeWithSolayerAction from "./solayer/stakeWithSolayer";
import registerDomainAction from "./sns/registerDomain";
import lendAssetAction from "./lulo/lendAsset";
import luloLendAction from "./lulo/luloLend";
import luloWithdrawAction from "./lulo/luloWithdraw";
import createGibworkTaskAction from "./gibwork/createGibworkTask";
import resolveSolDomainAction from "./sns/resolveSolDomain";
import pythFetchPriceAction from "./pyth/pythFetchPrice";
@@ -67,6 +69,9 @@ import driftSpotTokenSwapAction from "./drift/swapSpotToken";
import perpMarktetFundingRateAction from "./drift/perpMarketFundingRate";
import entryQuoteOfPerpTradeAction from "./drift/entryQuoteOfPerpTrade";
import lendAndBorrowAPYAction from "./drift/getLendAndBorrowAPY";
import getVoltrPositionValuesAction from "./voltr/getPositionValues";
import depositVoltrStrategyAction from "./voltr/depositStrategy";
import withdrawVoltrStrategyAction from "./voltr/withdrawStrategy";
export const ACTIONS = {
WALLET_ADDRESS_ACTION: getWalletAddressAction,
@@ -86,6 +91,8 @@ export const ACTIONS = {
STAKE_WITH_SOLAYER_ACTION: stakeWithSolayerAction,
REGISTER_DOMAIN_ACTION: registerDomainAction,
LEND_ASSET_ACTION: lendAssetAction,
LULO_LEND_ACTION: luloLendAction,
LULO_WITHDRAW_ACTION: luloWithdrawAction,
CREATE_GIBWORK_TASK_ACTION: createGibworkTaskAction,
RESOLVE_SOL_DOMAIN_ACTION: resolveSolDomainAction,
PYTH_FETCH_PRICE_ACTION: pythFetchPriceAction,
@@ -140,6 +147,9 @@ export const ACTIONS = {
DRIFT_PERP_MARKET_FUNDING_RATE_ACTION: perpMarktetFundingRateAction,
DRIFT_GET_ENTRY_QUOTE_OF_PERP_TRADE_ACTION: entryQuoteOfPerpTradeAction,
DRIFT_GET_LEND_AND_BORROW_APY_ACTION: lendAndBorrowAPYAction,
GET_VOLTR_POSITION_VALUES_ACTION: getVoltrPositionValuesAction,
DEPOSIT_VOLTR_STRATEGY_ACTION: depositVoltrStrategyAction,
WITHDRAW_VOLTR_STRATEGY_ACTION: withdrawVoltrStrategyAction,
};
export type { Action, ActionExample, Handler } from "../types/action";

View File

@@ -0,0 +1,62 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { luloLend } from "../../tools/lulo";
const luloLendAction: Action = {
name: "LULO_LEND",
similes: [
"lend USDC with lulo",
"lend PYUSD with lulo",
"lend USDS with lulo",
"lend USDT with lulo",
"lend SQL with lulo",
"lend jitoSQL with lulo",
"lend bSQL with lulo",
"lend mSQL with lulo",
"lend BONK with lulo",
"lend JUP with lulo",
],
description: "Lend SPL tokens using Lulo protocol",
examples: [
[
{
input: {
mintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
amount: 100,
},
output: {
status: "success",
signature: "4xKpN2...",
message: "Successfully lend 100 USDC",
},
explanation: "Lend 100 USDC on Lulo",
},
],
],
schema: z.object({
mintAddress: z.string().describe("SPL Mint address"),
amount: z.number().positive().describe("Amount to lend"),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const mintAddress = input.mintAddress as string;
const amount = input.amount as number;
const response = await luloLend(agent, mintAddress, amount);
return {
status: "success",
signature: response,
message: `Successfully lend ${amount} of token ${mintAddress}`,
};
} catch (error: any) {
return {
status: "error",
message: `Lend failed: ${error.message}`,
};
}
},
};
export default luloLendAction;

View File

@@ -0,0 +1,62 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { luloWithdraw } from "../../tools/lulo";
const luloWithdrawAction: Action = {
name: "LULO_WITHDRAW",
similes: [
"withdraw USDC with lulo",
"withdraw PYUSD with lulo",
"withdraw USDS with lulo",
"withdraw USDT with lulo",
"withdraw SQL with lulo",
"withdraw jitoSQL with lulo",
"withdraw bSQL with lulo",
"withdraw mSQL with lulo",
"withdraw BONK with lulo",
"withdraw JUP with lulo",
],
description: "Withdraw SPL tokens using Lulo protocol",
examples: [
[
{
input: {
mintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
amount: 100,
},
output: {
status: "success",
signature: "4xKpN2...",
message: "Successfully withdraw 100 USDC",
},
explanation: "Withdraw 100 USDC on Lulo",
},
],
],
schema: z.object({
mintAddress: z.string().describe("SPL Mint address"),
amount: z.number().positive().describe("Amount to lend"),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const mintAddress = input.mintAddress as string;
const amount = input.amount as number;
const response = await luloWithdraw(agent, mintAddress, amount);
return {
status: "success",
signature: response,
message: `Successfully withdraw ${amount} of token ${mintAddress}`,
};
} catch (error: any) {
return {
status: "error",
message: `Withdraw failed: ${error.message}`,
};
}
},
};
export default luloWithdrawAction;

View File

@@ -0,0 +1,83 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { BN } from "bn.js";
const depositVoltrStrategyAction: Action = {
name: "DEPOSIT_VOLTR_STRATEGY",
similes: [
"deposit to voltr strategy",
"add funds to voltr vault strategy",
"invest in voltr strategy",
"deposit assets to voltr",
"contribute to voltr vault",
"fund voltr strategy",
],
description: "Deposit assets into a specific strategy within a Voltr vault",
examples: [
[
{
input: {
depositAmount: "1000000000", // 1 USDC with 6 decimals
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
strategy: "9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk",
},
output: {
status: "success",
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
strategy: "9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk",
signature: "2ZE7Rz...",
message: "Successfully deposited 1000000000 into strategy",
},
explanation: "Deposit 1 USDC into a Voltr vault strategy",
},
],
],
schema: z.object({
depositAmount: z
.string()
.min(1)
.describe("The amount to deposit (in base units including decimals)"),
vault: z
.string()
.min(1)
.describe(
"The public key of the Voltr source vault to take assets from, e.g., 'Ga27...'",
),
strategy: z
.string()
.min(1)
.describe(
"The public key of the initialized target strategy to deposit into, e.g., 'Jheh...'",
),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const depositAmount = new BN(input.depositAmount);
const vault = new PublicKey(input.vault);
const strategy = new PublicKey(input.strategy);
const signature = await agent.voltrDepositStrategy(
depositAmount,
vault,
strategy,
);
return {
status: "success",
vault: vault.toBase58(),
strategy: strategy.toBase58(),
signature,
message: `Successfully deposited ${input.depositAmount} into strategy`,
};
} catch (error: any) {
return {
status: "error",
message: `Failed to deposit into strategy: ${error.message}`,
};
}
},
};
export default depositVoltrStrategyAction;

View File

@@ -0,0 +1,74 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
const getVoltrPositionValuesAction: Action = {
name: "GET_VOLTR_POSITION_VALUES",
similes: [
"get voltr vault value",
"check voltr position",
"get voltr vault assets",
"view voltr holdings",
"check voltr portfolio",
"get voltr vault breakdown",
],
description:
"Get the current position values and total assets for a Voltr vault",
examples: [
[
{
input: {
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
},
output: {
status: "success",
data: {
totalValue: 1000000,
positions: [
{
strategy: "4JHtgXyMb9gFJ1hGd2sh645jrZcxurSG3QP7Le3aTMTx",
value: 600000,
},
{
strategy: "4i9kzGr1UkxBCCUkQUQ4vsF51fjdt2knKxrwM1h1NW4g",
value: 400000,
},
],
},
message: "Successfully retrieved Voltr vault position values",
},
explanation:
"Get position values for a Voltr vault showing total value and value per strategy",
},
],
],
schema: z.object({
vault: z
.string()
.min(1)
.describe("The public key of the Voltr vault to query, e.g., 'Ga27...'"),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const vault = new PublicKey(input.vault);
const result = await agent.voltrGetPositionValues(vault);
const positionData = JSON.parse(result);
return {
status: "success",
vault: vault.toBase58(),
data: positionData,
message: "Successfully retrieved Voltr vault position values",
};
} catch (error: any) {
return {
status: "error",
message: `Failed to get vault position values: ${error.message}`,
};
}
},
};
export default getVoltrPositionValuesAction;

View File

@@ -0,0 +1,83 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { BN } from "bn.js";
const withdrawVoltrStrategyAction: Action = {
name: "WITHDRAW_VOLTR_STRATEGY",
similes: [
"withdraw from voltr strategy",
"remove funds from voltr vault strategy",
"take out from voltr strategy",
"withdraw assets from voltr",
"pull from voltr vault",
"redeem from voltr strategy",
],
description: "Withdraw assets from a specific strategy within a Voltr vault",
examples: [
[
{
input: {
withdrawAmount: "1000000000", // 1 USDC with 6 decimals
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
strategy: "9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk",
},
output: {
status: "success",
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
strategy: "9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk",
signature: "2ZE7Rz...",
message: "Successfully withdrew 1000000000 from strategy",
},
explanation: "Withdraw 1 USDC from a Voltr vault strategy",
},
],
],
schema: z.object({
withdrawAmount: z
.string()
.min(1)
.describe("The amount to withdraw (in base units including decimals)"),
vault: z
.string()
.min(1)
.describe(
"The public key of the Voltr source vault to deposit assets into, e.g., 'Ga27...'",
),
strategy: z
.string()
.min(1)
.describe(
"The public key of the initialized target strategy to withdraw from, e.g., 'Jheh...'",
),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const withdrawAmount = new BN(input.withdrawAmount);
const vault = new PublicKey(input.vault);
const strategy = new PublicKey(input.strategy);
const signature = await agent.voltrWithdrawStrategy(
withdrawAmount,
vault,
strategy,
);
return {
status: "success",
vault: vault.toBase58(),
strategy: strategy.toBase58(),
signature,
message: `Successfully withdrew ${input.withdrawAmount} from strategy`,
};
} catch (error: any) {
return {
status: "error",
message: `Failed to withdraw from strategy: ${error.message}`,
};
}
},
};
export default withdrawVoltrStrategyAction;