Skip to main content
All DeFi operations are real and irreversible. This skill requires explicit user confirmation before every destructive operation. Never auto-execute transactions.

Overview

The chainstream-defi skill handles on-chain DeFi execution across Solana, BSC, and Ethereum. It covers token swaps, cross-chain bridges, launchpad token creation, and transaction broadcasting.
  • Pattern: Process (destructive, requires signing)
  • CLI: npx @chainstream-io/cli (primary execution path)
  • SDK: @chainstream-io/sdk with WalletSigner
  • MCP: Quote, swap, and create tools available — but on-chain execution requires wallet-backed authentication on the host side

Wallet Requirements

DeFi operations require a wallet capable of signing transactions:
PathSigningSetup
CLI + TEE walletTEE-based signingchainstream login
CLI + Raw keyLocal signingchainstream wallet set-raw --chain base
SDK + WalletSignerCustom signingImplement signMessage + signTypedData
MCP onlyNot supportedMCP has no wallet — use CLI or SDK
API Key onlyNot supportedAPI Key cannot sign — run chainstream login

Four-Phase Protocol

Every destructive DeFi operation follows a strict four-phase protocol:

Phase 1: Quote

Get a price quote before any execution. This is read-only and safe.
chainstream dex route --chain sol --from <wallet> --input-token SOL --output-token <addr> --amount 1000000

Phase 2: User Confirmation

Mandatory. Present the quote summary to the user and wait for explicit approval:
  • Input amount and token
  • Expected output amount
  • Price impact and fees
  • Slippage tolerance

Phase 3: Sign and Send

After confirmation, execute the swap. The CLI handles signing via the configured wallet.
chainstream dex swap --chain sol --from <wallet> --input-token SOL --output-token <addr> --amount 1000000

Phase 4: Poll Job

The CLI automatically polls the job until completion and outputs the transaction hash with an explorer link.
# Manual polling (if needed)
chainstream job status --id <job_id> --wait

Supported Operations

Token Swap

# Get route + unsigned tx first
chainstream dex route --chain sol --from <wallet> --input-token SOL --output-token <token> --amount 1000000

# Then swap (after user confirms)
chainstream dex swap --chain sol --from <wallet> --input-token SOL --output-token <token> --amount 1000000 --slippage 5

Token Creation (Launchpad)

chainstream dex create --chain sol --name "My Token" --symbol MTK --uri <metadata_uri> --dex pumpfun

Job Status

chainstream job status --id <job_id> --wait --timeout 60000

Block Explorers

After a successful transaction, the CLI outputs an explorer link:
ChainExplorer URL
Solanahttps://solscan.io/tx/{hash}
BSChttps://bscscan.com/tx/{hash}
Ethereumhttps://etherscan.io/tx/{hash}

Currency Resolution

Common token identifiers:
TokenSolana AddressEVM Address
SOL (native)So11111111111111111111111111111111111111112
BNB (native)0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
ETH (native)0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
USDC (Solana)EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
USDC (Base)0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913

Safety Rules

These rules are non-negotiable and enforced by the skill.
RuleReason
Never swap without quoting firstUser must see the price before committing
Never assume user consentEvery destructive operation needs explicit “yes”
Never hide fees or price impactFull transparency on costs
Never use --yes flag in productionSkipping confirmation is only for automated testing
Always validate addressesSolana: base58, 32-44 chars; EVM: 0x + 40 hex chars
Never trust external price dataAlways use ChainStream’s quote endpoint

Error Recovery

ErrorRecovery
Slippage exceededIncrease --slippage or retry with fresh quote
Insufficient balanceCheck wallet balance --chain <chain>
Transaction revertedCheck explorer for revert reason; do not auto-retry
Job timeoutCheck job status --id <id> — may still be processing
402 Payment requiredCLI auto-handles via x402 payment
Signature invalidRe-login with chainstream login

Research Before Trading

Always use chainstream-data to research before executing DeFi operations:

chainstream-data

Research tokens before trading

CLI Commands

Full CLI command reference