界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
效率与协作 · SKILL.md

solana-defi-agent

solana-defi-agent

【效率与协作】DeFi toolkit for AI agents on Solana — swaps, lending, staking via Solana Actions/Blinks

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: solana-defi-agent description: DeFi toolkit for AI agents on Solana — swaps, lending, staking via Solana Actions/Blinks

Solana DeFi Agent Skill

DeFi toolkit for AI agents on Solana — swaps, lending, staking, and more

New here? → Start with QUICKSTART.md for a 10-minute setup guide.


What This Does

Solana Blinks (Blockchain Links) let you execute DeFi operations—swaps, deposits, staking—through simple URLs. This skill gives you:

  • CLI for quick operations: blinks execute <url> --amount=100
  • SDK for building automations
  • Registry access to 900+ trusted protocol endpoints
# Example: Deposit USDC to Kamino yield vault
blinks execute "https://kamino.dial.to/api/v0/lend/usdc-prime/deposit" --amount=100

⚠️ Before You Start

Required

  • Solana wallet keypair file (see QUICKSTART.md)
  • SOL for transaction fees (~0.01 SOL / $2 minimum)
  • Node.js 18+

Environment Variables

# .env file
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
SOLANA_WALLET_PATH=~/.config/solana/my-wallet.json

🔒 Security

  • Never commit keypairs to git - use .env and .gitignore
  • Test with small amounts first - mistakes happen
  • Verify hosts are trusted - CLI warns about untrusted hosts
  • Use a dedicated wallet - not your main holdings

Protocol Status (Updated 2026-02-02)

✅ Working

ProtocolActionsEndpoint
JupiterSwap any tokensworker.jup.ag
RaydiumSwap, LPshare.raydium.io
KaminoDeposit, withdraw, borrow, repaykamino.dial.to
JitoStake SOLjito.network, jito.dial.to
TensorBuy floor, bid on NFTstensor.dial.to
DriftVault deposit/withdrawapp.drift.trade

🔑 Needs API Key

ProtocolGet KeyNotes
Lulodev.lulo.fi24hr withdrawal cooldown

❌ Currently Broken

ProtocolIssueWorkaround
OrcaNo public blink APIUse Jupiter or Raydium
SanctumCloudflare blocks server IPsUse their web UI
Some dial.toRate limitingTry self-hosted endpoints

❓ Untested

MarginFi, Meteora, Helius, Magic Eden - endpoints exist but need verification.


Quick Reference

Inspect Before Executing

Always preview what a blink does:

blinks inspect <url>

Shows metadata, available actions, and trust status.

Execute Transactions

# Dry run first (simulates without sending)
blinks execute <url> --amount=100 --dry-run

# Execute for real
blinks execute <url> --amount=100

Protocol-Specific Commands

# Kamino
blinks kamino deposit --vault=usdc-prime --amount=100
blinks kamino withdraw --vault=usdc-prime --amount=50

# Jito
blinks jito stake --amount=1

# Generic (any blink URL)
blinks execute "https://..." --amount=X

SDK Usage

import {
  ActionsClient,
  BlinksExecutor,
  Wallet,
  getConnection,
  isHostTrusted,
} from '@openclaw/solana-defi-agent-skill';

// Initialize
const connection = getConnection();
const wallet = Wallet.fromEnv();
const actions = new ActionsClient();
const executor = new BlinksExecutor(connection);

// 1. Check if host is trusted
const trusted = await isHostTrusted('https://kamino.dial.to');
if (!trusted) throw new Error('Untrusted host!');

// 2. Get action metadata
const metadata = await actions.getAction(
  'https://kamino.dial.to/api/v0/lend/usdc-prime/deposit'
);
console.log('Available actions:', metadata.links.actions);

// 3. Get transaction
const tx = await actions.postAction(
  'https://kamino.dial.to/api/v0/lend/usdc-prime/deposit?amount=100',
  wallet.address
);

// 4. Simulate first
const sim = await executor.simulate(tx);
if (!sim.success) {
  throw new Error(`Simulation failed: ${sim.error}`);
}

// 5. Execute
const signature = await executor.signAndSend(tx, wallet.getSigner());
console.log('Success:', `https://solscan.io/tx/${signature}`);

How Blinks Work

  1. GET request to action URL → Returns metadata + available actions
  2. POST request with wallet address → Returns transaction to sign
  3. Sign transaction locally and submit to Solana
User → GET blink URL → Protocol returns actions
User → POST with wallet → Protocol returns transaction
User → Sign & submit → Transaction confirmed

The skill handles all of this. You just provide the URL and amount.


Troubleshooting

ErrorCauseFix
422 Unprocessable EntityMissing required tokensCheck token balance before deposit
403 ForbiddenCloudflare blockingTry protocol's self-hosted endpoint
Transaction simulation failedInsufficient SOL or stale txCheck balance, retry quickly
Rate limit exceededPublic RPC overloadedUse Helius/QuickNode free tier
Untrusted host warningHost not in Dialect registryVerify URL is correct

Blink URL Formats

The CLI accepts multiple formats:

# Direct URL (recommended)
blinks inspect "https://kamino.dial.to/api/v0/lend/usdc/deposit"

# Solana Action protocol
blinks inspect "solana-action:https://kamino.dial.to/..."

# dial.to interstitial
blinks inspect "https://dial.to/?action=solana-action:https://..."

RPC Recommendations

ProviderFree TierLink
Helius100k req/dayhelius.dev
QuickNode10M creditsquicknode.com
Alchemy300M CUalchemy.com
PublicRate limitedapi.mainnet-beta.solana.com

Public works for testing but will hit rate limits in production.


Files

solana-defi-agent-skill/
├── SKILL.md           # This file
├── QUICKSTART.md      # Beginner setup guide
├── README.md          # Package readme
├── .env.example       # Environment template
├── src/               # Source code
├── dist/              # Built CLI + SDK
├── docs/              # Protocol status, specs
└── tests/             # Protocol endpoint tests

Links

我的收藏