krystal-defi-api

SKILL.md

Krystal API

DeFi liquidity pool explorer and transaction API supporting 13+ blockchains.

Quick Start

Base URL: https://api.krystal.app

# Get top pools across all chains
curl "https://api.krystal.app/all/v2/lp_explorer/top_pools?skipCheckAutomation=true"

# Get pool details
curl "https://api.krystal.app/all/v1/lp_explorer/pool_detail?chainId=8453&poolAddress=0x..."

Instructions

Finding Pools

  1. Use Top Pools to discover high-performing pools
  2. Use Pool Detail for specific pool information
  3. Use Pool Chart for liquidity distribution visualization

Creating LP Positions

  1. Get pool details including tickSpacing from Pool Detail
  2. Calculate tick range aligned with pool's tick spacing
  3. Use Zap In to build the transaction
  4. Sign and send txData using a web3 provider

Increasing Liquidity (Swap and Increase)

  1. Get position tokenId from User Positions (for Solana, also pass nftMintAddress)
  2. Use Swap and Increase with tokenInAddress, amountIn, swapSlippage, and liquiditySlippage
  3. Set fundFromOwner=true and isVault=true when adding to a Krystal auto-farm vault position
  4. Sign and send txData using a web3 provider (same as Zap In)

Withdrawing LP Positions (Zap Out)

  1. Get position tokenId from User Positions (for Solana, also pass nftMintAddress)
  2. Use Zap Out with targetToken, liquidityPercent, swapSlippage, and withdrawSlippage
    • Set liquidityPercent = 0 to claim only fees (principal stays in the pool; claimed tokens are swapped to targetToken)
    • Use 0 < liquidityPercent ≤ 1 to withdraw principal liquidity (plus any fees) to targetToken
  3. Sign and send txData using a web3 provider (same as Zap In)

Compounding Fees into a Position

  1. Get position tokenId from User Positions (for Solana, also pass nftMintAddress)
  2. Use Compound with swapSlippage and liquiditySlippage to reinvest unclaimed fees back into the same position
  3. Set isVault=true when compounding a Krystal auto-farm vault position
  4. Sign and send txData using a web3 provider

Rebalancing Positions (Adjust Range)

  1. Get position tokenId from User Positions (for Solana, also pass nftMintAddress)
  2. Get pool tickSpacing from Pool Detail and choose new newTickLower and newTickUpper aligned with it
  3. Use Adjust Range with swapSlippage, liquiditySlippage, and withdrawSlippage
  4. On EVM chains, sign and send txData directly. On Solana, call with buildTx=true first to get txData, then sign and send it.

Exploring Vaults

  1. Use Vaults to list available vaults
  2. Filter by category (ALL_VAULT, NEW_VAULT, BOOST_VAULT) and isAutoFarmVault to narrow results
  3. Evaluate vaults by tvl, apr, riskScore, and vaultSecurities
  4. Use Vault Profile Stats to get a wallet's aggregate vault statistics (owned, joined, yields, PnL)

Viewing Positions

  1. Use User Positions to list a wallet's liquidity positions
  2. Check statsByChain["all"] for aggregate portfolio metrics (total PnL, APR, unclaimed fees)
  3. Filter by chainIds or positionStatus (open/closed) to narrow results
  4. Evaluate individual positions by pnl, apr, impermanentLoss, compareWithHodl, and status (IN_RANGE/OUT_RANGE)
  5. Use refreshAll=true for fresh on-chain data (slower) or omit for cached data (faster)

Wallet Operations

  1. Use Token Search to get user's token balances
  2. Select input token for swap/zap operations

Key Conventions

  • Always use skipCheckAutomation=true for faster responses
  • Monetary values: Returned as strings to preserve precision
  • APR values: Returned as numbers (percentages)
  • Native tokens: Use NativeTokenAddress placeholders
  • Amounts: Always in wei (smallest unit)

Endpoints Reference

Endpoint Purpose
Top Pools Discover pools by TVL, volume, APR
Pool Detail Get pool info, tick spacing, incentives
Pool Chart Liquidity distribution and price history
Zap In Build swap + mint transaction
Swap and Increase Add liquidity to existing position (swap + increase)
Zap Out Build withdraw + swap transaction
Compound Reinvest unclaimed fees into existing position
Adjust Range Rebalance position to new tick range
User Positions List wallet LP positions & stats
Vaults List shared & auto-farm vaults
Token Search Query wallet token balances

Types Reference

See types.md for complete type definitions:

Core Types: Token, Pool, PoolDetail, ChainId, LPProtocolAlias

Chart Types: PoolChartData, Tick, PricePoint

Transaction Types: TxData, ZapTxInfo, SwapAmount

Position Types: UserPosition, PositionChainStats, PositionTokenAmount, PositionPool

Vault Types: Vault, VaultOwner, VaultSecurity, VaultStats

Wallet Types: WalletToken, TokenBalance

Weekly Installs
6
First Seen
Feb 9, 2026
Installed on
cursor5
opencode4
github-copilot4
codex4
kimi-cli4
gemini-cli4