Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,88 @@ const parsedData = await agent.parseAccount(
console.log("parsed data:", parsedData)
```

### Get Sanctum LST Price

```typescript
const prices = await agent.getSanctumLSTPrice([
"bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1",
"7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn"
])

console.log('prices', prices)
```

### Get Sanctum LST APY

```typescript
const apys = await agent.getSanctumLSTAPY([
"bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1",
"7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn"
])

console.log('apys', apys)
```

### Get Sanctum LST TVL

```typescript
const tvls = await agent.getSanctumLSTTVL([
"bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1",
"7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn"
])

console.log('tvls', tvls)
```

### Get Sanctum Owend LST

```typescript
const lsts = await agent.getSanctumOwnedLST()

console.log('lsts', lsts)
```

### Add Liquidity to Sanctum Infinite Pool

```typescript
const txId = await agent.addSanctumLiquidity(
"So11111111111111111111111111111111111111112",
"1000000000",
"1100000000",
5000
)

console.log('txId', txId)
```

### Remove Liquidity from Sanctum Infinite Pool

```typescript
const txId = await agent.removeSanctumLiquidity(
"So11111111111111111111111111111111111111112",
"1000000000",
"1100000000",
5000
)

console.log('txId', txId)
```

### Swap Sanctum LST

```typescript
const txId = await agent.swapSanctumLST(
"So11111111111111111111111111111111111111112",
"1000000000",
"1100000000",
5000,
"7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn"
)

console.log('txId', txId)
```


### Get Chain Data

Note: To use OKX DEX integration, you need to set up the following environment variables: Get OKX API keys from the [OKX Developer Portal] (https://www.okx.com/web3/build/dev-portal)
Expand Down
14 changes: 14 additions & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ import cancelLimitOrdersAction from "./jupiter/cancelLimitOrders";
import getOpenLimitOrdersAction from "./jupiter/getOpenLimitOrders";
import parseAccountAction from "./solanafm/parseAccount";
import parseInstructionAction from "./solanafm/parseInstruction";
import getSanctumLSTPriceAction from "./sanctum/sanctumGetLSTPrice";
import getSanctumLSTAPYAction from "./sanctum/sanctumGetLSTAPY";
import getSanctumLSTTVLAction from "./sanctum/sanctumGetLSTTVL";
import sanctumAddLiquidityAction from "./sanctum/sanctumAddLiquidity";
import sanctumRemoveLiquidityAction from "./sanctum/sanctumRemoveLiquidity";
import sanctumGetOwnedLSTAction from "./sanctum/sanctumGetOwnedLST";
import sanctumSwapLSTAction from "./sanctum/sanctumSwapLST";

export const ACTIONS = {
GET_INFO_ACTION: getInfoAction,
Expand Down Expand Up @@ -256,6 +263,13 @@ export const ACTIONS = {
GET_OPEN_LIMIT_ORDERS_ACTION: getOpenLimitOrdersAction,
PARSE_ACCOUNT_ACTION: parseAccountAction,
PARSE_INSTRUCTION_ACTION: parseInstructionAction,
SANCTUM_GET_PRICE_ACTION: getSanctumLSTPriceAction,
SANCTUM_GET_APY_ACTION: getSanctumLSTAPYAction,
SANCTUM_GET_TVL_ACTION: getSanctumLSTTVLAction,
SANCTUM_ADD_LIQUIDITY_ACTION: sanctumAddLiquidityAction,
SANCTUM_REMOVE_LIQUIDITY_ACTION: sanctumRemoveLiquidityAction,
SANCTUM_GET_OWNED_LST_ACTION: sanctumGetOwnedLSTAction,
SANCTUM_SWAP_LST_ACTION: sanctumSwapLSTAction,
};

export type { Action, ActionExample, Handler } from "../types/action";
7 changes: 7 additions & 0 deletions src/actions/sanctum/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from "./sanctumGetLSTPrice";
export * from "./sanctumGetLSTTVL";
export * from "./sanctumGetLSTAPY";
export * from "./sanctumAddLiquidity";
export * from "./sanctumRemoveLiquidity";
export * from "./sanctumGetOwnedLST";
export * from "./sanctumSwapLST";
58 changes: 58 additions & 0 deletions src/actions/sanctum/sanctumAddLiquidity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { SolanaAgentKit } from "../../agent";
import { sanctumAddLiquidity } from "../../tools";
import { Action } from "../../types/action";
import { z } from "zod";

const sanctumAddLiquidityAction: Action = {
name: "SANCTUM_ADD_LIQUIDITY",
similes: ["add liquidity to sanctum pool", "deposit to sanctum pool"],
description: "Add liquidity to a Sanctum pool with specified parameters",
examples: [
[
{
input: {
lstMint: "So11111111111111111111111111111111111111112",
amount: "1000000000",
quotedAmount: "900000000",
priorityFee: 5000,
},
output: {
status: "success",
message: "Liquidity added successfully",
txId: "2jg87stmvPygRXJrqfpydZQSzGJK9rKvawekzy5mzuEmSjRf8bCmiGpFH8iLa2YrQxtreWcK99319DVTpCJHYZfx",
},
explanation: "Add liquidity to a Sanctum pool",
},
],
],
schema: z.object({
lstMint: z.string(),
amount: z.string(),
quotedAmount: z.string(),
priorityFee: z.number(),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const result = await sanctumAddLiquidity(
agent,
input.lstMint,
input.amount,
input.quotedAmount,
input.priorityFee,
);

return {
status: "success",
message: "Liquidity added successfully",
txId: result.txId,
};
} catch (error: any) {
return {
status: "error",
message: `Adding liquidity to Sanctum pool failed: ${error.message}`,
};
}
},
};

export default sanctumAddLiquidityAction;
52 changes: 52 additions & 0 deletions src/actions/sanctum/sanctumGetLSTAPY.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { sanctumGetLSTAPY } from "../../tools";
import { Action } from "../../types/action";
import { z } from "zod";

const sanctumGetLSTAPYAction: Action = {
name: "GET_SANCTUM_APY",
similes: ["get sanctum LST APY", "fetch sanctum LST APY"],
description:
"Fetch the APY of a LST(Liquid Staking Token) on Sanctum with specified mint addresses or symbols",
examples: [
[
{
input: {
inputs: [
"INF",
"pwrsol",
"mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
"laineSOL",
],
},
output: {
pwrsol: 0.08321988140942367,
laineSOL: 0.0831767225669587,
INF: 0.06542961909093714,
mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So: 0.08143705823579084,
},
explanation: "Fetch the APY of LSTs on Sanctum",
},
],
],
schema: z.object({
inputs: z.array(z.string()),
}),
handler: async (input: Record<string, any>) => {
try {
const apys = await sanctumGetLSTAPY(input.inputs);

return {
status: "success",
message: "APY fetched successfully",
apys: apys,
};
} catch (error: any) {
return {
status: "error",
message: `Fetching Sanctum LST APY failed: ${error.message}`,
};
}
},
};

export default sanctumGetLSTAPYAction;
52 changes: 52 additions & 0 deletions src/actions/sanctum/sanctumGetLSTPrice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { sanctumGetLSTPrice } from "../../tools";
import { Action } from "../../types/action";
import { z } from "zod";

const sanctumGetLSTPriceAction: Action = {
name: "GET_SANCTUM_PRICE",
similes: ["get sanctum LST price", "fetch sanctum LST price"],
description:
"Fetch the Price of a LST(Liquid Staking Token) on Sanctum with specified mint addresses or symbols",
examples: [
[
{
input: {
inputs: [
"INF",
"pwrsol",
"mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
"laineSOL",
],
},
output: {
INF: "1303329251",
laineSOL: "1221330946",
mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So: "1279055247",
pwrsol: "1105899448",
},
explanation: "Fetch the prices of LSTs on Sanctum",
},
],
],
schema: z.object({
mints: z.array(z.string()),
}),
handler: async (input: Record<string, any>) => {
try {
const prices = await sanctumGetLSTPrice(input.mints);

return {
status: "success",
message: "Price fetched successfully",
prices: prices,
};
} catch (error: any) {
return {
status: "error",
message: `Fetching Sanctum LST price failed: ${error.message}`,
};
}
},
};

export default sanctumGetLSTPriceAction;
53 changes: 53 additions & 0 deletions src/actions/sanctum/sanctumGetLSTTVL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { sanctumGetLSTTVL } from "../../tools";
import { Action } from "../../types/action";
import { z } from "zod";

const sanctumGetLSTTVLTool: Action = {
name: "GET_SANCTUM_TVL",
similes: ["get sanctum LST TVL", "fetch sanctum LST TVL"],
description:
"Fetch the TVL of a LST(Liquid Staking Token) on Sanctum with specified mint addresses or symbols",

examples: [
[
{
input: {
inputs: [
"INF",
"pwrsol",
"mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
"laineSOL",
],
},
output: {
pwrsol: "3100602224977",
INF: "620838653321879",
mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So: "4892112998338119",
laineSOL: "55512833109331",
},
explanation: "Fetch the TVL of LSTs on Sanctum",
},
],
],
schema: z.object({
inputs: z.array(z.string()),
}),
handler: async (input: Record<string, any>) => {
try {
const tvls = await sanctumGetLSTTVL(input.inputs);

return {
status: "success",
message: "TVL fetched successfully",
tvls: tvls,
};
} catch (error: any) {
return {
status: "error",
message: `Fetching Sanctum LST TVL failed: ${error.message}`,
};
}
},
};

export default sanctumGetLSTTVLTool;
51 changes: 51 additions & 0 deletions src/actions/sanctum/sanctumGetOwnedLST.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { SolanaAgentKit } from "../../agent";
import { sanctumGetOwnedLST } from "../../tools";
import { Action } from "../../types/action";
import { z } from "zod";

const sanctumGetOwnedLSTAction: Action = {
name: "SANCTUM_GET_OWNED_LST",
similes: [
"get owned lst",
"get owned lst tokens",
"get owned lst assets",
"get owned lst assets list",
],
description:
"Fetch the owned LST(Liquid Staking Token) on Sanctum with specified account",
examples: [
[
{
input: {},
output: {
lsts: [
{
mint: "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
balance: 0.0035,
},
],
},
explanation: "Owned LSTs fetched successfully",
},
],
],
schema: z.object({}),
handler: async (agent: SolanaAgentKit) => {
try {
const result = await sanctumGetOwnedLST(agent);

return {
status: "success",
message: "Owned LSTs fetched successfully",
lsts: result,
};
} catch (error: any) {
return {
status: "error",
message: `Fetching owned LSTs failed: ${error.message}`,
};
}
},
};

export default sanctumGetOwnedLSTAction;
Loading
Loading