torch-liquidation-bot

9
0
Source

a read-only lending market scanner that discovers Torch Market positions, profiles borrower wallets, and scores loan risk. Optionally executes liquidations when the user provides a wallet keypair.

Install

mkdir -p .claude/skills/torch-liquidation-bot && curl -L -o skill.zip "https://mcp.directory/api/skills/download/2432" && unzip -o skill.zip -d .claude/skills/torch-liquidation-bot && rm skill.zip

Installs to .claude/skills/torch-liquidation-bot

About this skill

Torch Liquidation Bot

You're here because you want to run a liquidation keeper on Torch Market -- and you want to do it safely.

Every migrated token on Torch has a built-in lending market. Holders lock tokens as collateral and borrow SOL from the community treasury (up to 50% LTV, 2% weekly interest). When a loan's LTV crosses 65%, it becomes liquidatable. Anyone can liquidate it and collect a 10% bonus on the collateral value.

That's where this bot comes in.

It scans every migrated token's lending market using the SDK's bulk loan scanner (getAllLoanPositions) -- one RPC call per token returns all active positions pre-sorted by health. When it finds one that's underwater, it liquidates it through your vault. The collateral tokens go to your vault ATA. The SOL cost comes from your vault. The agent wallet that signs the transaction holds nothing.

This is not a read-only scanner. This is a fully operational keeper that generates its own keypair, verifies vault linkage, and executes liquidation transactions autonomously in a continuous loop.


How It Works

┌──────────────────────────────────────────────────────────┐
│                  LIQUIDATION LOOP                          │
│                                                           │
│  1. Discover migrated tokens (getTokens)                  │
│  2. For each token, scan all loans (getAllLoanPositions)   │
│     — single RPC call, returns positions sorted by health │
│     — liquidatable → at_risk → healthy                    │
│  3. Skip tokens with no active loans                      │
│  4. For each liquidatable position:                       │
│     → buildLiquidateTransaction(vault=creator)            │
│     → sign with agent keypair                             │
│     → submit and confirm                                  │
│     → break when health != 'liquidatable' (pre-sorted)    │
│  5. Sleep SCAN_INTERVAL_MS, repeat                        │
│                                                           │
│  All SOL comes from vault. All collateral goes to vault.  │
│  Agent wallet holds nothing. Vault is the boundary.       │
└──────────────────────────────────────────────────────────┘

The Agent Keypair

The bot generates a fresh Keypair in-process on every startup. No private key file. No environment variable (unless you want to provide one). The keypair is disposable -- it signs transactions but holds nothing of value.

On first run, the bot checks if this keypair is linked to your vault. If not, it prints the exact SDK call you need to link it:

--- ACTION REQUIRED ---
agent wallet is NOT linked to the vault.
link it by running (from your authority wallet):

  buildLinkWalletTransaction(connection, {
    authority: "<your-authority-pubkey>",
    vault_creator: "<your-vault-creator>",
    wallet_to_link: "<agent-pubkey>"
  })

then restart the bot.
-----------------------

Link it from your authority wallet (hardware wallet, multisig, whatever you use). The agent never needs the authority's key. The authority never needs the agent's key. They share a vault, not keys.

The Vault

This is the same Torch Vault from the full Torch Market protocol. It holds all assets -- SOL and tokens. The agent is a disposable controller.

When the bot liquidates a position:

  • SOL cost comes from the vault (the liquidation payment to cover the borrower's debt)
  • Collateral tokens go to the vault's associated token account (ATA)
  • 10% bonus means the collateral received is worth 10% more than the SOL spent

The human principal retains full control:

  • withdrawVault() — pull SOL at any time
  • withdrawTokens(mint) — pull collateral tokens at any time
  • unlinkWallet(agent) — revoke agent access instantly

If the agent keypair is compromised, the attacker gets dust and vault access that you revoke in one transaction.


Getting Started

1. Install

npm install torch-liquidation-bot@4.0.2

Or use the bundled source from ClawHub — the Torch SDK is included in lib/torchsdk/ and the bot source is in lib/kit/.

2. Create and Fund a Vault (Human Principal)

From your authority wallet:

import { Connection } from "@solana/web3.js";
import {
  buildCreateVaultTransaction,
  buildDepositVaultTransaction,
} from "./lib/torchsdk/index.js";

const connection = new Connection(process.env.SOLANA_RPC_URL);

// Create vault
const { transaction: createTx } = await buildCreateVaultTransaction(connection, {
  creator: authorityPubkey,
});
// sign and submit with authority wallet...

// Fund vault with SOL for liquidations
const { transaction: depositTx } = await buildDepositVaultTransaction(connection, {
  depositor: authorityPubkey,
  vault_creator: authorityPubkey,
  amount_sol: 5_000_000_000, // 5 SOL
});
// sign and submit with authority wallet...

3. Run the Bot

VAULT_CREATOR=<your-vault-creator-pubkey> SOLANA_RPC_URL=<rpc-url> npx torch-liquidation-bot

On first run, the bot prints the agent keypair and instructions to link it. Link it from your authority wallet, then restart.

4. Configuration

VariableRequiredDefaultDescription
SOLANA_RPC_URLYes--Solana RPC endpoint (HTTPS). Fallback: RPC_URL
VAULT_CREATORYes--Vault creator pubkey
SOLANA_PRIVATE_KEYNo--Disposable controller keypair (base58 or JSON byte array). If omitted, generates fresh keypair on startup (recommended)
SCAN_INTERVAL_MSNo30000Milliseconds between scan cycles (min 5000)
LOG_LEVELNoinfodebug, info, warn, error

Architecture

packages/bot/src/
├── index.ts    — entry point: keypair generation, vault verification, scan loop
├── config.ts   — loadConfig(): validates SOLANA_RPC_URL, VAULT_CREATOR, SOLANA_PRIVATE_KEY, SCAN_INTERVAL_MS, LOG_LEVEL
├── types.ts    — BotConfig, LogLevel interfaces
└── utils.ts    — sol(), bpsToPercent(), withTimeout(), createLogger()

The bot is ~192 lines of TypeScript. It does one thing: find underwater loans and liquidate them through the vault.

Dependencies

PackageVersionPurpose
@solana/web3.js1.98.4Solana RPC, keypair, transaction
torchsdk3.7.22Token queries, bulk loan scanning, liquidation builder, vault queries

Two runtime dependencies. Both pinned to exact versions. No ^ or ~ ranges.


Vault Safety Model

The same seven guarantees from the Torch Market vault apply here:

PropertyGuarantee
Full custodyVault holds all SOL and all collateral tokens. Agent wallet holds nothing.
Closed loopLiquidation SOL comes from vault, collateral tokens go to vault. No leakage to agent.
Authority separationCreator (immutable PDA seed) vs Authority (transferable admin) vs Controller (disposable signer).
One link per walletAgent can only belong to one vault. PDA uniqueness enforces this on-chain.
Permissionless depositsAnyone can top up the vault. Hardware wallet deposits, agent liquidates.
Instant revocationAuthority can unlink the agent at any time. One transaction.
Authority-only withdrawalsOnly the vault authority can withdraw SOL or tokens. The agent cannot extract value.

The Closed Economic Loop for Liquidations

DirectionFlow
SOL outVault → Borrower's treasury debt (covers the loan)
Tokens inBorrower's collateral → Vault ATA (at 10% discount)
NetVault receives collateral worth 110% of SOL spent

The bot is profitable by design — every successful liquidation returns more value than it costs. The profit accumulates in the vault. The authority withdraws when ready.


Lending Parameters

ParameterValue
Max LTV50%
Liquidation Threshold65%
Interest Rate2% per epoch (~weekly)
Liquidation Bonus10%
Utilization Cap70% of treasury
Min Borrow0.1 SOL

Collateral value is calculated from Raydium pool reserves. The 0.03% Token-2022 transfer fee (3 bps, immutable per mint) applies on collateral deposits and withdrawals.

When Liquidations Happen

A loan becomes liquidatable when its LTV exceeds 65%. This happens when:

  • The token price drops (collateral value decreases relative to debt)
  • Interest accrues (debt grows at 2% per epoch)
  • A combination of both

The bot checks position.health === 'liquidatable' — the SDK calculates LTV from on-chain Raydium reserves and the loan's accrued debt.


SDK Functions Used

The bot uses a focused subset of the Torch SDK:

FunctionPurpose
getTokens(connection, { status: 'migrated' })Discover all tokens with active lending markets
getAllLoanPositions(connection, mint)Bulk scan all active loans for a token — returns positions pre-sorted by health (liquidatable first), fetches pool price once
getVault(connection, creator)Verify vault exists on startup
getVaultForWallet(connection, wallet)Verify agent is linked to vault
buildLiquidateTransaction(connection, params)Build the liquidation transaction (vault-routed)
confirmTransaction(connection, sig, wallet)Confirm transaction on-chain via RPC (verifies signer, checks Torch instructions)

Scan and Liquidate Pattern

import { getTokens, getAllLoanPositions, buildLiquidateTransaction } from 'torchsdk'

// 1. Discover migrated tokens
const { tokens } = await getTokens(connection, { status: 'migrated', sort: 'volume', limit: 50 })

for (const token of tokens) {
  // 2. Bulk scan — one RPC call per token, positions sorted liquidatable-first
  const { positions } = await getAllLoanPositions(connection, token.mint)

  for (const pos of positions) {
    if (pos.health !== 'liquidatable') bre

---

*Content truncated.*

seedream-image-gen

openclaw

Generate images via Seedream API (doubao-seedream models). Synchronous generation.

2359

ffmpeg-cli

openclaw

Comprehensive video/audio processing with FFmpeg. Use for: (1) Video transcoding and format conversion, (2) Cutting and merging clips, (3) Audio extraction and manipulation, (4) Thumbnail and GIF generation, (5) Resolution scaling and quality adjustment, (6) Adding subtitles or watermarks, (7) Speed adjustment (slow/fast motion), (8) Color correction and filters.

6623

context-optimizer

openclaw

Advanced context management with auto-compaction and dynamic context optimization for DeepSeek's 64k context window. Features intelligent compaction (merging, summarizing, extracting), query-aware relevance scoring, and hierarchical memory system with context archive. Logs optimization events to chat.

3622

a-stock-analysis

openclaw

A股实时行情与分时量能分析。获取沪深股票实时价格、涨跌、成交量,分析分时量能分布(早盘/尾盘放量)、主力动向(抢筹/出货信号)、涨停封单。支持持仓管理和盈亏分析。Use when: (1) 查询A股实时行情, (2) 分析主力资金动向, (3) 查看分时成交量分布, (4) 管理股票持仓, (5) 分析持仓盈亏。

9121

himalaya

openclaw

CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).

7921

garmin-connect

openclaw

Syncs daily health and fitness data from Garmin Connect into markdown files. Provides sleep, activity, heart rate, stress, body battery, HRV, SpO2, and weight data.

7321

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

643969

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

591705

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

318398

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

339397

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

451339

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

304231

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.