What It Does
percolator-cli is a comprehensive command-line tool for interacting with the Percolator protocol on Solana. It supports all protocol operations: account management, trading, keeper cranking, LP setup, market analysis, and stress testing.
Installation
Configuration
Create ~/.config/percolator-cli.json:
{
"rpcUrl" : "https://api.devnet.solana.com" ,
"programId" : "2SSnp35m7FQ7cRLNKGdW5UzjYFF6RBUNq7d3m5mqNByp" ,
"walletPath" : "~/.config/solana/id.json"
}
Or use flags: --rpc, --program, --wallet, --json, --simulate.
Commands
User Operations
# Initialize user account
percolator-cli init-user --slab < pubke y >
# Deposit / withdraw collateral
percolator-cli deposit --slab < pubke y > --user-idx < n > --amount < lamport s >
percolator-cli withdraw --slab < pubke y > --user-idx < n > --amount < lamport s >
# Trade via matcher CPI
percolator-cli trade-cpi --slab < pubke y > --user-idx < n > --lp-idx < n > \
--size < i12 8> --matcher-program < pubke y > --matcher-ctx < pubke y > --oracle < pubke y >
# Trade without matcher (testing)
percolator-cli trade-nocpi --slab < pubke y > --user-idx < n > --lp-idx < n > \
--size < i12 8> --oracle < pubke y >
# Close account
percolator-cli close-account --slab < pubke y > --idx < n >
Keeper Operations
# Run keeper crank (permissionless)
percolator-cli keeper-crank --slab < pubke y > --oracle < pubke y >
# Check best LP prices before trading
percolator-cli best-price --slab < pubke y > --oracle < pubke y >
Risk-increasing trades require a recent keeper crank — within the last 200 slots (~80 seconds). Run the crank before trading or use the crank bot for continuous operation.
LP Operations
# Initialize LP account
percolator-cli init-lp --slab < pubke y >
# Deposit collateral to LP
percolator-cli deposit --slab < pubke y > --user-idx < lp-id x > --amount < lamport s >
Admin Operations
# Rotate admin
percolator-cli update-admin --slab < pubke y > --new-admin < pubke y >
# Set risk threshold
percolator-cli set-risk-threshold --slab < pubke y > --threshold-bps < n >
# Oracle authority (push custom prices)
percolator-cli set-oracle-authority --slab < pubke y > --authority < pubke y >
percolator-cli push-oracle-price --slab < pubke y > --price < us d >
# Update market configuration
percolator-cli update-config --slab < pubke y > --funding-horizon-slots < n > ...
Market Analysis
# View slab state
percolator-cli slab:get --slab < pubke y >
percolator-cli slab:header --slab < pubke y >
percolator-cli slab:config --slab < pubke y >
# Dump full market state to JSON
npx tsx scripts/dump-state.ts
npx tsx scripts/dump-market.ts
# Check liquidation risk / funding / parameters
npx tsx scripts/check-liquidation.ts
npx tsx scripts/check-funding.ts
npx tsx scripts/check-params.ts
# Find user account by owner
npx tsx scripts/find-user.ts < sla b > < owne r >
Bots & Scripts
Keeper Bot
Continuous crank every 5 seconds:
npx tsx scripts/crank-bot.ts
Random Traders
Simulates 5 traders with momentum bias, routing to the best LP by price:
npx tsx scripts/random-traders.ts
LP Setup
Create a vAMM-configured LP with matcher context + deposit:
npx tsx scripts/add-vamm-lp.ts
Market Setup
Full devnet market with funded LP and insurance:
npx tsx scripts/setup-devnet-market.ts
Stress Testing & Security
The CLI includes comprehensive stress tests and penetration testing scripts:
Script What it tests stress-haircut-system.tsConservation, insurance fund, undercollateralization stress-worst-case.tsGap risk, insurance exhaustion, socialized losses oracle-authority-stress.tsPrice manipulation scenarios pentest-oracle.tsFlash crash, price edges, timestamp attacks, funding manipulation test-price-profit.tsPrice-profit relationship validation test-threshold-increase.tsAuto-threshold adjustment verification test-lp-profit-realize.tsLP profit realization and withdrawal test-profit-withdrawal.tsProfit withdrawal limit enforcement
Testing
# Unit tests
pnpm test
# Devnet integration
./test-vectors.sh
# Live trading test (with PnL validation)
npx tsx tests/t21-live-trading.ts 3 # 3 minutes
npx tsx tests/t21-live-trading.ts 3 --inverted # inverted market
Original Source
Forked from aeyakovenko/percolator-cli .
View Repository Full CLI source, scripts, bots, and stress tests