Skip to content

RECTOR-LABS/kami

Repository files navigation

Kami — AI Co-Pilot for Kamino DeFi on Solana

Chat-driven assistant for Kamino Finance. Ask in plain English — "best USDC yield on Kamino", "deposit 100 USDC", "will this borrow liquidate me?" — and Kami streams a natural-language answer plus, when relevant, a ready-to-sign mainnet transaction.

Live: kami.rectorspace.com · Bounty: Eitherway Track — Frontier Hackathon 2026

Proof of Life

Deposited live on mainnet through the deployed UI:

Features

Read-only tools (no signing)

Tool Purpose
getPortfolio Connected wallet's live Kamino position: deposits, borrows, APYs, LTV, health factor
findYield Top reserves by live supply / borrow APY, filterable by symbol
simulateHealth Project the user's health factor after a hypothetical deposit/borrow/withdraw/repay

Write actions (produce a signable transaction)

buildDeposit · buildBorrow · buildWithdraw · buildRepay

Each builds an unsigned v0 transaction server-side (fresh blockhash, proper compute budget, all required account inits for first-time users), then returns it as base64 wire bytes. The UI renders a Sign & Send card with the exact action/amount/protocol; the user signs with their wallet, the client submits, and on-chain confirmation is polled over HTTP until confirmed or blockhash expiry.

Preflight built-in: every build* tool runs simulateTransaction before returning. If the wallet is short on SOL for account rent, Kami surfaces a precise shortfall — before the user burns a failed-tx fee.

Architecture

  • Frontend — Vite + React 18 + TypeScript + Tailwind. Featured wallet: Solflare via @solana/wallet-adapter-solflare (unified extension / web / mobile fallback). Any Solana-wallet-standard wallet also works (Phantom, Backpack, etc.) — the "Use another wallet" option lists everything detected.
  • Chat backendserver/chat.ts exports a Web ReadableStream powered by Vercel AI SDK streamText + fullStream. Consumed by Fastify in local dev (server/index.ts) and a Node-style Vercel Function in production (api/chat.ts). One source of truth for tool wiring.
  • RPC — Same-origin /api/rpc Vercel Function proxies JSON-RPC to Helius server-side. Keeps the key off the browser, avoids CORS, and sidesteps new-domain reputation issues.
  • LLManthropic/claude-sonnet-4.6 via OpenRouter. Swappable via KAMI_MODEL.
  • DeFi@kamino-finance/klend-sdk 7.3 on @solana/kit v2, against the Kamino Main Market.
  • Transaction buildcreateNoopSigner + compileTransaction + getBase64EncodedWireTransaction. The wallet signs on the client; the server never holds a secret key.
  • Confirmation — HTTP polling over getSignatureStatuses + getBlockHeight (Vercel Functions can't upgrade WebSockets, so the default subscription-based confirmTransaction would hang).

Run locally

pnpm install
cp .env.example .env.local   # fill KAMI_OPENROUTER_API_KEY + SOLANA_RPC_URL
pnpm dev                     # web :5173 + api :3001 concurrently

Scripts

  • pnpm dev — web + api concurrently
  • pnpm dev:web — Vite frontend only
  • pnpm dev:api — Fastify backend only (tsx watch)
  • pnpm build — production bundle (tsc -b && vite build)
  • pnpm exec tsc -p server/tsconfig.json --noEmit — typecheck the server + api/*.ts Vercel Functions

Deployment

  • Vercel project rectors-projects/kami, auto-deploys from main.
  • Production env vars: KAMI_OPENROUTER_API_KEY, KAMI_MODEL, SOLANA_RPC_URL.
  • Custom domain kami.rectorspace.com served from Vercel with auto-renewed SSL (Cloudflare DNS-only).

Origin

Initial scaffold generated by Eitherway on 2026-04-19 (tagged eitherway-v0). Everything after is custom: Fastify + Vercel Function backends, Kamino SDK integration, the seven-tool suite, same-origin RPC proxy, preflight simulation, Sign & Send card, and the polling-based confirmation path.

About

AI co-pilot for Kamino DeFi on Solana — chat-driven lending, yield, and health-factor assistant. Built for the Eitherway Track, Frontier Hackathon 2026.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages