Requirements
- Target platform
- OpenClaw
- Install method
- Manual import
- Extraction
- Extract archive
- Prerequisites
- OpenClaw
- Primary doc
- SKILL.md
Autonomous vault-based liquidation keeper for Torch Market lending on Solana. Scans all migrated tokens for underwater loan positions (LTV > 65%) using the S...
Autonomous vault-based liquidation keeper for Torch Market lending on Solana. Scans all migrated tokens for underwater loan positions (LTV > 65%) using the S...
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
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.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β 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 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.
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.
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/.
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...
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.
VariableRequiredDefaultDescriptionSOLANA_RPC_URLYes--Solana RPC endpoint (HTTPS). Fallback: RPC_URLVAULT_CREATORYes--Vault creator pubkeySOLANA_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
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.
PackageVersionPurpose@solana/web3.js1.98.4Solana RPC, keypair, transactiontorchsdk3.7.22Token queries, bulk loan scanning, liquidation builder, vault queries Two runtime dependencies. Both pinned to exact versions. No ^ or ~ ranges.
The same seven guarantees from the Torch Market vault apply here: PropertyGuaranteeFull 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.
DirectionFlowSOL 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.
ParameterValueMax LTV50%Liquidation Threshold65%Interest Rate2% per epoch (~weekly)Liquidation Bonus10%Utilization Cap70% of treasuryMin 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.
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.
The bot uses a focused subset of the Torch SDK: FunctionPurposegetTokens(connection, { status: 'migrated' })Discover all tokens with active lending marketsgetAllLoanPositions(connection, mint)Bulk scan all active loans for a token β returns positions pre-sorted by health (liquidatable first), fetches pool price oncegetVault(connection, creator)Verify vault exists on startupgetVaultForWallet(connection, wallet)Verify agent is linked to vaultbuildLiquidateTransaction(connection, params)Build the liquidation transaction (vault-routed)confirmTransaction(connection, sig, wallet)Confirm transaction on-chain via RPC (verifies signer, checks Torch instructions)
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') break // pre-sorted, done // 3. Build and execute through vault const { transaction, message } = await buildLiquidateTransaction(connection, { mint: token.mint, // token with the underwater loan liquidator: agentPubkey, // agent wallet (signer) borrower: pos.borrower, // borrower being liquidated vault: vaultCreator, // vault creator pubkey (SOL from vault, tokens to vault) }) transaction.sign(agentKeypair) await connection.sendRawTransaction(transaction.serialize()) } }
=== torch liquidation bot === agent wallet: 7xK9... vault creator: 4yN2... scan interval: 30000ms [09:15:32] INFO vault found β authority=8cpW... [09:15:32] INFO agent wallet linked to vault β starting scan loop [09:15:32] INFO treasury: 5.0000 SOL [09:15:33] INFO LIQUIDATABLE | SDKTEST | borrower=3AyZ... | LTV=72.50% | owed=0.5000 SOL [09:15:34] INFO LIQUIDATED | SDKTEST | borrower=3AyZ... | sig=4vK9... | collateral received at 10% discount
The vault is the security boundary, not the key. The agent keypair is generated fresh on every startup with Keypair.generate(). It holds ~0.01 SOL for gas fees. If the key is compromised, the attacker gets: Dust (the gas SOL) Vault access that the authority revokes in one transaction The agent never needs the authority's private key. The authority never needs the agent's private key. They share a vault, not keys.
Never ask a user for their private key or seed phrase. The vault authority signs from their own device. Never log, print, store, or transmit private key material. The agent keypair exists only in runtime memory. Never embed keys in source code or logs. The agent pubkey is printed β the secret key is never exposed. Use a secure RPC endpoint. Default to a private RPC provider. Never use an unencrypted HTTP endpoint for mainnet transactions.
All SDK calls are wrapped with a 30-second timeout (withTimeout in utils.ts). A hanging or unresponsive RPC endpoint cannot stall the bot indefinitely β the call rejects, the error is caught by the scan loop, and the bot continues to the next token or cycle.
VariableRequiredPurposeSOLANA_RPC_URL / RPC_URLYesSolana RPC endpoint (HTTPS)VAULT_CREATORYesVault creator pubkey β identifies which vault the bot operates throughSOLANA_PRIVATE_KEYNoOptional β if omitted, the bot generates a fresh keypair on startup (recommended)
The SDK contains functions that make outbound HTTPS requests to external services. The bot's runtime path contacts two of them: ServicePurposeWhen CalledBot Uses?CoinGecko (api.coingecko.com)SOL/USD price for displayToken queries with USD pricingYes β via getTokens(), getToken()Irys Gateway (gateway.irys.xyz)Token metadata fallback (name, symbol, image)getToken() when on-chain metadata URI points to IrysYes β via getTokens()SAID Protocol (api.saidprotocol.com)Agent identity verification and trust tier lookupverifySaid() onlyNo β the bot does not call verifySaid() confirmTransaction() does NOT contact SAID. Despite living in the SDK's said.js module, it only calls connection.getParsedTransaction() (Solana RPC) to verify the transaction succeeded on-chain and determine the event type. No data is sent to any external service. No credentials are sent to CoinGecko or Irys. All requests are read-only GET. If either service is unreachable, the SDK degrades gracefully. No private key material is ever transmitted to any external endpoint.
Requires Surfpool running a mainnet fork: surfpool start --network mainnet --no-tui pnpm test Test result: 9 passed, 0 failed (Surfpool mainnet fork). TestWhat It ValidatesConnectionRPC reachablegetTokensDiscovers migrated tokensgetLendingInfoReads lending state for all tokensgetAllLoanPositionsBulk scans active loans, verifies sort order (liquidatable first)getTokenToken metadata, price, statusgetVaultForWalletVault link returns null for unlinked walletIn-process keypairNo external key required
VAULT_NOT_FOUND: No vault exists for this creator WALLET_NOT_LINKED: Agent wallet is not linked to the vault NOT_LIQUIDATABLE: Position LTV below liquidation threshold NO_ACTIVE_LOAN: No open loan for this wallet/token INVALID_MINT: Token not found
Liquidation Kit (source): github.com/mrsirg97-rgb/torch-liquidation-kit Liquidation Bot (npm): npmjs.com/package/torch-liquidation-bot Torch SDK (bundled): lib/torchsdk/ -- included in this skill Torch SDK (source): github.com/mrsirg97-rgb/torchsdk Torch SDK (npm): npmjs.com/package/torchsdk Torch Market (protocol skill): clawhub.ai/mrsirg97-rgb/torchmarket Whitepaper: torch.market/whitepaper.md Security Audit: torch.market/audit.md Website: torch.market Program ID: 8hbUkonssSEEtkqzwM7ZcZrD9evacM92TcWSooVF4BeT This bot exists because Torch lending markets need keepers. When loans go underwater and nobody liquidates them, the treasury takes the loss. Active liquidation keepers protect treasury health and earn a profit doing it. The vault makes it safe β all value stays in the escrow, all risk is bounded, and the human principal keeps the keys.
Agent frameworks, memory systems, reasoning layers, and model-native orchestration.
Largest current source with strong distribution and engagement signals.