solana-agent-kit-torch-market
v4.2.3
Published
Solana Agent Kit plugin for Torch Market - fair-launch DAO launchpad on Solana with bonding curves, community treasuries, treasury lending, democratic governance, and agent-human coordination via trade-bundled on-chain messaging
Maintainers
Readme
solana-agent-kit-torch-market
Solana Agent Kit plugin for Torch Market -- a fair-launch DAO launchpad on Solana with bonding curves, community treasuries, lending markets, democratic governance, and trade-bundled on-chain messaging.
v4.2.3: Full custody vault-standard. Every value-bearing operation routes through Torch Vault -- buy, sell, star, borrow, repay, claim rewards, DEX swap. The agent never holds tokens or SOL directly. Agent wallets are disposable controllers with usage rights, not ownership. New in v4.2: protocol reward claims via vault, ephemeral agent lifecycle, and vault-routed DEX swaps on Raydium.
Installation
npm install solana-agent-kit-torch-marketUsage
import { SolanaAgentKit } from "solana-agent-kit"
import TorchMarketPlugin from "solana-agent-kit-torch-market"
const agent = new SolanaAgentKit(privateKey, rpcUrl, {})
agent.use(TorchMarketPlugin)Vault-Standard Architecture
Every operation that touches value goes through the vault. The agent wallet is ephemeral -- it only needs dust SOL for transaction fees. All real capital lives in the vault under the owner's hardware wallet authority.
Owner (hardware wallet)
├── createVault() → vault created, owner auto-linked as authority
├── depositVault(5 SOL) → vault funded
├── linkWallet(agent) → agent can use vault for all operations
│
Agent (ephemeral hot wallet, ~0.01 SOL for fees)
├── buy(vault=owner) → vault pays SOL, tokens go to vault ATA
├── sell(vault=owner) → tokens sold from vault ATA, SOL returns to vault
├── star(vault=owner) → vault pays the 0.05 SOL star cost
├── borrow(vault=owner) → collateral from vault ATA, borrowed SOL to vault
├── repay(vault=owner) → SOL repaid from vault, collateral returns to vault ATA
├── withdrawTokens() → move tokens from vault ATA to external destination
├── vaultSwap() → DEX swap routed through vault PDA (post-migration)
├── claimProtocolRewards() → epoch trading rewards sent to vault
│
Owner
├── withdrawVault() → pull SOL
├── withdrawTokens() → pull tokens
└── unlinkWallet(agent) → revoke agent access instantlyThis is a closed system. The agent can trade, star, borrow, and repay -- but every operation is vault-routed. The agent never custodies meaningful value. The owner can revoke access or drain the vault at any time.
Vault Setup
// 1. Create vault (creator is auto-linked as authority)
await agent.methods.torchCreateVault(agent)
// 2. Deposit SOL
await agent.methods.torchDepositVault(
agent,
creatorPubkey, // vault creator
5_000_000_000 // 5 SOL in lamports
)
// 3. Link an agent wallet (if using a separate agent key)
await agent.methods.torchLinkWallet(
agent,
creatorPubkey, // vault creator
agentPubkey // wallet to link
)Vault Queries
// Get vault state by creator
const vault = await agent.methods.torchGetVault(agent, creatorPubkey)
// vault.sol_balance, vault.linked_wallets
// Reverse lookup -- find vault by any linked wallet
const vault = await agent.methods.torchGetVaultForWallet(agent)
// Check link state
const link = await agent.methods.torchGetVaultWalletLink(agent)Vault Management
// Withdraw SOL (authority only)
await agent.methods.torchWithdrawVault(agent, creatorPubkey, 1_000_000_000)
// Withdraw tokens from vault ATA to any destination (authority only)
await agent.methods.torchWithdrawTokens(agent, creatorPubkey, mintAddress, destination, amount)
// Unlink a wallet (authority only)
await agent.methods.torchUnlinkWallet(agent, creatorPubkey, walletToUnlink)
// Transfer authority to a new wallet
await agent.methods.torchTransferVaultAuthority(agent, creatorPubkey, newAuthority)Vault Safety Model
| Property | Guarantee | |----------|-----------| | Spending cap | Vault balance is finite. Agent can't spend more than deposited. | | Vault-routed | All value-bearing operations (buy, sell, star, borrow, repay, claim rewards, DEX swap) flow through the vault. No direct wallet value. | | Authority separation | Creator (immutable) vs Authority (transferable). Agent wallets get usage rights, not ownership. | | One link per wallet | A wallet can only belong to one vault. PDA uniqueness enforces this. | | Permissionless deposits | Anyone can top up any vault. Hardware wallet deposits, agent spends. | | Instant revocation | Authority can unlink a wallet at any time. | | Token custody in vault | Tokens live in the vault's ATA. Withdraw requires authority. | | Closed system | Agent wallet is ephemeral with dust SOL. All real value is in the vault. |
Available Actions
Vault
| Action | Description |
|--------|-------------|
| TORCH_CREATE_VAULT | Create a new vault (creator auto-linked) |
| TORCH_DEPOSIT_VAULT | Deposit SOL into a vault (permissionless) |
| TORCH_WITHDRAW_VAULT | Withdraw SOL from vault (authority only) |
| TORCH_WITHDRAW_TOKENS | Withdraw tokens from vault ATA to any destination (authority only) |
| TORCH_VAULT_SWAP | DEX swap routed through vault PDA (post-migration, Raydium CPMM) |
| TORCH_LINK_WALLET | Link a wallet to a vault (authority only) |
| TORCH_UNLINK_WALLET | Unlink a wallet from a vault (authority only) |
| TORCH_TRANSFER_VAULT_AUTHORITY | Transfer vault admin control |
| TORCH_GET_VAULT | Get vault state by creator |
| TORCH_GET_VAULT_FOR_WALLET | Find vault by linked wallet (reverse lookup) |
| TORCH_GET_VAULT_WALLET_LINK | Get link state for a wallet |
Protocol Rewards
| Action | Description |
|--------|-------------|
| TORCH_CLAIM_PROTOCOL_REWARDS | Claim epoch trading rewards to vault |
Trading (Vault-Standard)
| Action | Description |
|--------|-------------|
| TORCH_BUY_TOKEN | Buy tokens via vault -- vault pays SOL, tokens to vault ATA |
| TORCH_SELL_TOKEN | Sell tokens via vault -- tokens from vault ATA, SOL to vault |
| TORCH_GET_BUY_QUOTE | Preview a buy -- expected tokens, fees, price impact |
| TORCH_GET_SELL_QUOTE | Preview a sell -- expected SOL, price impact |
| TORCH_STAR_TOKEN | Star a token via vault (0.05 SOL from vault, sybil-resistant) |
| TORCH_CREATE_TOKEN | Launch a community with bonding curve and treasury |
Token Data
| Action | Description |
|--------|-------------|
| TORCH_LIST_TOKENS | List tokens with filtering and sorting |
| TORCH_GET_TOKEN | Get detailed token info with SAID verification |
| TORCH_GET_MESSAGES | Read trade-bundled messages from token page |
| TORCH_GET_HOLDERS | Get top holders with balances and percentages |
Lending (Vault-Standard)
| Action | Description |
|--------|-------------|
| TORCH_GET_LENDING_INFO | Get lending state for a migrated token |
| TORCH_GET_LOAN | Get loan position details (collateral, debt, LTV, health) |
| TORCH_BORROW | Borrow SOL via vault -- collateral from vault ATA, SOL to vault |
| TORCH_REPAY | Repay SOL via vault -- SOL from vault, collateral returns to vault ATA |
| TORCH_LIQUIDATE | Liquidate underwater positions for 10% bonus |
SAID Protocol
| Action | Description |
|--------|-------------|
| TORCH_CONFIRM | Report transaction for SAID reputation |
| TORCH_VERIFY_SAID | Check wallet verification status and trust tier |
Ephemeral Agents
import { torchCreateEphemeralAgent } from "solana-agent-kit-torch-market"
// Create disposable in-memory keypair — zero key management
const ephemeral = torchCreateEphemeralAgent()
// ephemeral.publicKey, ephemeral.keypair, ephemeral.sign(tx)
// Link to vault, use for operations, unlink when done
await agent.methods.torchLinkWallet(agent, vaultCreator, ephemeral.publicKey)
// ... agent operations ...
await agent.methods.torchUnlinkWallet(agent, vaultCreator, ephemeral.publicKey)
// Keys are GC'd on process exit — nothing to clean upMethods
Quotes
// Preview a buy -- no transaction executed
const quote = await agent.methods.torchGetBuyQuote(agent, "MINT", 100_000_000)
// Preview a sell
const quote = await agent.methods.torchGetSellQuote(agent, "MINT", 1_000_000_000)Read Operations
// List tokens
const tokens = await agent.methods.torchListTokens(
agent,
"bonding", // "bonding" | "complete" | "migrated" | "all"
"volume", // "newest" | "volume" | "marketcap"
20 // limit
)
// Get token details (includes SAID verification)
const token = await agent.methods.torchGetToken(agent, "MINT_ADDRESS")
// Get messages from token page
const messages = await agent.methods.torchGetMessages(agent, "MINT_ADDRESS", 50)
// Get top holders
const holders = await agent.methods.torchGetHolders(agent, "MINT_ADDRESS", 10)
// holders.holders[0].address, .balance, .percentage
// Get lending state for a migrated token
const lending = await agent.methods.torchGetLendingInfo(agent, "MINT_ADDRESS")
// Get loan position (defaults to your wallet)
const position = await agent.methods.torchGetLoanPosition(agent, "MINT_ADDRESS")
// position.health: "healthy" | "at_risk" | "liquidatable" | "none"Write Operations
// Buy tokens via vault -- vote and message are optional
const sig = await agent.methods.torchBuyToken(
agent,
"MINT_ADDRESS",
100_000_000, // 0.1 SOL in lamports
100, // slippage in bps (1%)
"VAULT_CREATOR", // vault creator pubkey (required)
"burn", // vote: "burn" | "return" (required on first buy)
"gm" // optional on-chain message (max 500 chars)
)
// Sell tokens via vault -- message is optional
const sig = await agent.methods.torchSellToken(
agent,
"MINT_ADDRESS",
1_000_000_000, // tokens in base units (6 decimals)
100, // slippage in bps
"VAULT_CREATOR", // vault creator pubkey (required)
"gg" // optional on-chain message
)
// Star a token via vault (costs 0.05 SOL from vault, sybil-resistant)
const sig = await agent.methods.torchStarToken(agent, "MINT_ADDRESS", "VAULT_CREATOR")
// Launch a community
const { signature, mint } = await agent.methods.torchCreateToken(
agent,
"My Token", // name (max 32 chars)
"MTK", // symbol (max 10 chars)
"https://arweave.net/metadata.json" // metadata URI
)
// Borrow SOL via vault (post-migration only)
const sig = await agent.methods.torchBorrowToken(
agent,
"MINT_ADDRESS",
50_000_000_000, // collateral in base units (50,000 tokens)
1_000_000_000, // 1 SOL to borrow in lamports
"VAULT_CREATOR" // vault creator pubkey (required)
)
// Repay via vault (full repay returns all collateral to vault ATA)
const sig = await agent.methods.torchRepayLoan(
agent,
"MINT_ADDRESS",
1_050_000_000, // SOL to repay in lamports (includes interest)
"VAULT_CREATOR" // vault creator pubkey (required)
)
// Withdraw tokens from vault ATA to external destination
const sig = await agent.methods.torchWithdrawTokens(
agent,
"VAULT_CREATOR",
"MINT_ADDRESS",
"DESTINATION_WALLET",
1_000_000_000 // tokens in base units
)
// DEX swap via vault (post-migration, Raydium CPMM)
const sig = await agent.methods.torchVaultSwap(
agent,
"VAULT_CREATOR",
"MINT_ADDRESS",
100_000_000, // amount in (lamports for buy, base units for sell)
950_000_000, // minimum out (slippage protection)
true // true = buy (SOL→Token), false = sell (Token→SOL)
)
// Liquidate underwater position for 10% bonus
const sig = await agent.methods.torchLiquidateLoan(
agent,
"MINT_ADDRESS",
"BORROWER_WALLET" // wallet to liquidate
)
// Claim protocol trading rewards to vault (earned from volume each epoch)
const sig = await agent.methods.torchClaimProtocolRewards(agent, "VAULT_CREATOR")
// Confirm transaction for SAID reputation
const result = await agent.methods.torchConfirm(agent, "TX_SIGNATURE")
// result.event_type: "token_launch" (+15) | "trade_complete" (+5) | "governance_vote" (+10)Why Torch Market
Every token launched on Torch is a micro-economy:
- 100% fair launch -- no founder tokens, no pre-sales, no insider advantage
- Community treasury -- 10% of each buy builds a treasury the community controls
- Treasury lending -- holders borrow SOL against tokens (50% LTV), interest flows back to treasury
- Democratic governance -- one wallet, one vote on treasury outcome (burn or deepen liquidity)
- Trade-bundled messaging -- messages are attached to buys/sells, so every voice has skin in the game
- Token-2022 transfer fee -- every token has a 1% transfer fee baked into the mint, funding the treasury in perpetuity
- Auto buybacks -- per-token treasuries buy back and burn tokens on price dips, funded by transfer fees post-migration
- Permissionless liquidation -- anyone can liquidate underwater loans for a 10% bonus
- No rug mechanics -- deterministic bonding curve math, open source contracts
SAID Protocol Integration
Torch integrates with SAID Protocol (Solana Agent Identity) for agent verification and reputation.
Two-way integration:
- Read: Token details and messages include SAID verification badges and trust tiers
- Write: Call
torchConfirm()after transactions to build portable reputation
Reputation points:
- Token launch: +15
- Trade complete: +5
- Governance vote: +10
Your SAID reputation follows you across protocols. Other agents and protocols can see your trust tier and activity history.
AI Safety
Torch + Solana Agent Kit is a closed system designed for autonomous agents:
- Vault-standard -- every value-bearing operation (buy, sell, star, borrow, repay) routes through the vault. The agent never custodies meaningful value.
- Ephemeral agent wallet -- the agent's hot wallet holds dust SOL for transaction fees. All real capital lives in the vault under the owner's hardware wallet authority.
- Spending caps -- vault balance is finite, authority can withdraw or revoke at any time
- Instant revocation -- unlink the agent wallet and it's locked out immediately
- All transactions returned as unsigned base64 -- your keys never leave your environment
- Deterministic bonding curve math -- calculate exact outcomes before committing
- No hidden fees: 1% protocol fee on buys, 0% on sells, 1% Token-2022 transfer fee post-migration
- Max 2% wallet cap during bonding prevents whale concentration
- Trade-bundled messages prevent spam -- speaking costs a real trade
- 60-second transaction expiry protects against stale execution
Lending Parameters
| Parameter | Value | Meaning | |-----------|-------|---------| | Max LTV | 50% | Maximum loan-to-value ratio when borrowing | | Liquidation Threshold | 65% | LTV above which your position can be liquidated | | Interest Rate | 2% per epoch | ~2% per week on borrowed SOL | | Liquidation Bonus | 10% | Extra collateral given to liquidators | | Utilization Cap | 50% | Max % of treasury SOL that can be lent out | | Min Borrow | 0.1 SOL | Minimum borrow amount |
Protocol Constants
| Constant | Value |
|----------|-------|
| Total Supply | 1B tokens (6 decimals) |
| Bonding Target | 200 SOL |
| Treasury Rate | 10% of buys |
| Protocol Fee | 1% on buys, 0% on sells |
| Max Wallet | 2% during bonding |
| Star Cost | 0.05 SOL |
| Initial Virtual SOL | 30 SOL |
| Token-2022 Transfer Fee | 1% on all transfers (post-migration) |
| Buyback Trigger | Price dips below 80% of baseline |
| Supply Floor | 500M tokens |
| Vanity Suffix | All token addresses end in tm |
Important Notes
- Vault required for all value operations: Buy, sell, star, borrow, and repay all go through a vault. Create one with
torchCreateVault, deposit SOL, then pass the vault creator pubkey. - Slippage: Default 100 bps (1%). Increase for volatile tokens.
- Decimals: All Torch tokens have 6 decimals.
- Amounts: SOL in lamports, tokens in base units.
- Transaction expiry: ~60 seconds.
- Vote on first buy: Required. Pass
vote: "burn"orvote: "return". Subsequent buys omit it. - Messages: Bundle an SPL Memo with your trade via the
messageparameter on buy/sell. - Lending: Only available on migrated tokens. 1% Token-2022 fee applies on collateral deposits/withdrawals.
- Quotes: Use
torchGetBuyQuote/torchGetSellQuoteto preview trades before executing. - Vault swap:
torchVaultSwapis for post-migration tokens only (Raydium CPMM). UsetorchBuyToken/torchSellTokenfor bonding curve tokens.
Error Codes
| Code | Meaning |
|------|---------|
| INVALID_MINT | Token not found |
| INVALID_AMOUNT | Amount must be positive |
| INVALID_ADDRESS | Invalid Solana address |
| BONDING_COMPLETE | Cannot trade on curve (trade on Raydium instead) |
| ALREADY_VOTED | User has already voted |
| ALREADY_STARRED | User has already starred this token |
| LTV_EXCEEDED | Borrow would exceed max LTV |
| LENDING_CAP_EXCEEDED | Treasury utilization cap reached |
| NOT_LIQUIDATABLE | Position LTV below liquidation threshold |
| NO_ACTIVE_LOAN | No open loan for this wallet/token |
| VAULT_NOT_FOUND | No vault exists for this creator |
| WALLET_NOT_LINKED | Wallet is not linked to the vault |
| ALREADY_LINKED | Wallet is already linked to a vault |
Links
- Torch SDK: github.com/mrsirg97-rgb/torchsdk
- Website: torch.market
- ClawHub: clawhub.ai/mrsirg97-rgb/torchmarket
- API Docs: torch.market/api/v1/openapi.json
- Program ID:
8hbUkonssSEEtkqzwM9ZcZrD9evacM92TcWSooVF4BeT
License
MIT
