Agent API Documentation

StakePilot Agent API

Build AI agents that interact with the StakePilot autonomous staking vault on Solana.

Overview

StakePilot is a smart contract vault where:

  • •Users deposit SOL and set staking preferences
  • •Agents analyze validators and execute optimal staking
  • •Security: Agents can stake but NEVER withdraw to themselves
🤖Base URL
https://stakepilot-olig.vercel.app/api/agent

Quick Start

1. Get vault status
curl https://stakepilot-olig.vercel.app/api/agent/vault
2. Get qualified validators
curl https://stakepilot-olig.vercel.app/api/agent/validators
3. Get staking plan with reasoning
curl https://stakepilot-olig.vercel.app/api/agent/analyze
4. Execute staking (requires auth)
curl -X POST https://stakepilot-olig.vercel.app/api/agent/stake \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"allocations": [{"validatorVote": "49DJ...", "amount": 1.0}]}'

Endpoints

Read Operations (No Auth)

EndpointMethodDescription
/vaultGETVault status (balance, deposits, users)
/validatorsGETList qualified validators with scores
/positionsGETCurrent stake positions
/analyzeGETRun decision algorithm, get staking plan
/docsGETOpenAPI specification (JSON)

Write Operations (Auth Required)

EndpointMethodDescription
/stakePOSTExecute staking to validators
/unstakePOSTDeactivate stake positions

Authentication

Write operations require an API key in the Authorization header:

Authorization: Bearer <your-api-key>

Validator Criteria

The agent only stakes to validators meeting these requirements:

Stake
< 1M SOL
Commission
≤ 5%
MEV Comm
≤ 10%
Uptime
> 95%

Smart Contract

Program ID
66VGaTF2qqogyAC6jczwepjk3C6i5QAe8YQ4mFHveC4b
Vault PDA
HpsHuysk6HJ8HW5VcRJvBCqdw4jpwLoHi1EW3Lma2p5u

Security Model

✓ Agent CAN

  • • Stake vault funds TO validators
  • • Deactivate stakes for rebalancing
  • • Return deactivated SOL to vault

✗ Agent CANNOT

  • • Withdraw SOL to itself
  • • Transfer to external addresses
  • • Change vault settings

Examples

TypeScript Agent

import axios from 'axios';

const API = 'https://stakepilot-olig.vercel.app/api/agent';
const API_KEY = 'your-api-key';

async function runStakingAgent() {
  // 1. Check vault state
  const { data: vault } = await axios.get(`${API}/vault`);
  console.log(`Available: ${vault.availableToStake} SOL`);

  if (vault.availableToStake < 1) {
    console.log('Insufficient balance');
    return;
  }

  // 2. Get analysis and staking plan
  const { data: analysis } = await axios.get(`${API}/analyze`);
  console.log('Action:', analysis.action);
  console.log('Reasoning:', analysis.reasoning);

  if (analysis.action !== 'stake') return;

  // 3. Execute staking
  const allocations = analysis.analysis.map((v: any) => ({
    validatorVote: v.voteAccount,
    amount: v.allocation,
  }));

  const { data: result } = await axios.post(
    `${API}/stake`,
    { allocations },
    { headers: { Authorization: `Bearer ${API_KEY}` } }
  );

  console.log('Result:', result);
}

// Run hourly
setInterval(runStakingAgent, 60 * 60 * 1000);
runStakingAgent();

AI Agent Prompt

You are a Solana staking agent for StakePilot. Your goal is to optimize staking yield while supporting network decentralization.


Available tools:

- GET /api/agent/vault - Check vault balance

- GET /api/agent/validators - Get qualified validators

- GET /api/agent/analyze - Get recommended staking plan

- POST /api/agent/stake - Execute staking


When vault has >1 SOL available, analyze and execute the optimal staking plan.

Ready to Build?

Check the live vault or explore the API documentation.