Originally built by Parrot Protocol. Revived for the Solana Graveyard Hackathon with modern Jupiter DEX integration.
A time-weighted average price (TWAP) bot for Solana. Execute recurring buy or sell orders on any token pair at configurable intervals — dollar-cost averaging on autopilot.
The original Parrot TWAP bot was tightly coupled to Raydium AMM v4 and Serum DEX — both of which are now defunct (Serum was sunset after the FTX collapse in 2022). The bot was completely non-functional.
Our revival:
- Replaced the dead Raydium/Serum swap backend with Jupiter Swap API — the dominant Solana DEX aggregator
- Supports any Solana token pair (not just PRT), using Jupiter's optimal routing across all DEXes
- Added well-known token symbol resolution (SOL, USDC, BONK, JUP, etc.) — no need to look up mint addresses
- Added configurable slippage tolerance
- Preserved the original architecture: scheduler, balance tracking, stop conditions, auto-transfers
- Go 1.17+
- A Solana wallet with some SOL for fees
- An RPC endpoint (e.g., from Helius, QuickNode, or the public endpoint)
Copy .env.example to .env and configure:
cp .env.example .envSet your wallet private key and RPC endpoints:
RPCURL=https://api.mainnet-beta.solana.com
RPCWS=wss://api.mainnet-beta.solana.com
WALLETPK=your_base58_private_key
Buy USDC with 0.1 SOL every 5 minutes:
go run cmd/cli.go --pair SOL:USDC --amount 0.1 --interval 5m --side buySell 1M BONK for SOL every hour:
go run cmd/cli.go --pair BONK:SOL --amount 1000000 --interval 1h --side sell --fromDecimals 5 --toDecimals 9DCA into JUP with stop condition:
go run cmd/cli.go --pair SOL:JUP --amount 0.05 --interval 30m --side buy --stopAmount 1000Use raw mint addresses:
go run cmd/cli.go --pair So11111111111111111111111111111111111111112:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v --amount 0.1 --interval 10mBuilt-in symbol resolution for: SOL, USDC, USDT, BONK, JUP, RAY, ORCA, MSOL, JITOSOL, WIF, PYTH
Any other token can be specified by its mint address.
| Flag | Description | Default |
|---|---|---|
--pair |
Token pair (e.g. SOL:USDC) | required |
--amount |
Amount per swap | required |
--interval |
Time between swaps (30s, 5m, 1h) | required |
--side |
buy or sell | buy |
--slippage |
Slippage in basis points | 200 (2%) |
--stopAmount |
Stop when to-token balance reaches this | unlimited |
--transferAddress |
Auto-transfer to-token to this address | — |
--transferThreshold |
Transfer when balance exceeds this | — |
--fromDecimals |
Decimals for the from-token | 9 |
--toDecimals |
Decimals for the to-token | 6 |
Specify --stopAmount to halt the bot when the target token balance reaches a threshold:
go run cmd/cli.go --pair SOL:USDC --amount 0.01 --interval 30s --stopAmount 100When the balance exceeds --transferThreshold, automatically transfer all accumulated tokens to --transferAddress:
go run cmd/cli.go --pair SOL:USDC --amount 0.5 --interval 10m --transferThreshold 500 --transferAddress YOUR_WALLET_ADDRESSBuild a binary:
make
./build/twap --pair SOL:USDC --amount 0.1 --interval 5mOr use Docker:
docker-compose build
docker run twap --pair SOL:USDC --amount 0.1 --interval 5mCross-compile for Linux:
env GOOS=linux GOARCH=amd64 go build -o ./twap ./cmd/cli.gocmd/cli.go — CLI entry point, argument parsing, scheduler
swap/swap.go — Core TWAP logic: balance checks, stop conditions, transfer
swap/jupiter.go — Jupiter Swap API integration (quote + swap)
swap/raydium.go — Original Raydium swap (preserved, non-functional)
swap/rpc.go — Solana RPC helpers, transaction building
config/jupiter.go — Token symbol resolution, pair parsing
config/tokens.go — Token metadata (decimals)
config/pools.go — Original Raydium pool configs (preserved)
price/coingeko.go — CoinGecko price oracle for price thresholds
store/json.go — Swap log persistence
Track: Competing for overall prizes ($15K/$10K/$5K)
Original Protocol: Parrot Protocol — a Solana DeFi protocol that offered PAI stablecoin, staking, and this TWAP bot. The protocol shut down, and this bot became non-functional when Serum DEX was sunset.
Revival: We modernized the TWAP concept by replacing dead infrastructure (Serum + Raydium) with Jupiter — making it a universal DCA tool for any Solana token pair.
Apache-2.0 (preserved from original)