chore: merge Voltr changes into remote branch

This commit is contained in:
jakeyvee
2025-01-15 21:18:14 +08:00
402 changed files with 65213 additions and 8710 deletions

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;