A flexible Solana automation tool for executing recurring token swaps and staking operations on the Solana blockchain. (Currently only set up for staking)
Features:
- Automated USDC ↔ USDT pair trading via Jupiter protocol (not currently enabled)
- Automated SKR staking to Solana Mobile validator Guardian Pool
- Configurable schedules and amounts
- CLI-based control with no external dependencies
Before running SwapnStake, ensure you have the following installed:
- A Solana wallet with SOL for transaction fees
- A funded wallet containing SKR tokens
- Access to a Solana RPC endpoint (Devnet, Testnet, or Mainnet)
git clone <repository-url>
cd SwapnStakeSwapnStake uses Python 3.12+ with uv for dependency management:
# Install project dependencies
uv syncThis will:
- Create a virtual environment in
.venv/ - Install all Python dependencies from
pyproject.toml
Python Dependencies:
solders>=0.27.1- Solana transaction building and signinghttpx>=0.24.0- Async HTTP client for RPC and APIsrich>=13.0.0- Rich terminal outputapscheduler>=3.10.0- Task schedulingpydantic>=2.0.0- Configuration validationpython-dotenv>=1.0.0- Environment variable managementbase58>=2.1.0- Base58 encoding/decoding
npm installNode Dependencies:
@solana/web3.js>=1.98.4- Solana JavaScript SDK@jup-ag/api>=6.0.48- Jupiter swap API@scure/bip32>=2.2.0- BIP32 key derivationtypescript>=6.0.3- TypeScript compilerts-node>=10.9.2- TypeScript execution for Node.js
Create a .env file in the project root:
cp .env.example .envEdit .env and configure:
# Solana RPC Configuration (use whatever RPC you want)
SOLANA_RPC_URL=https://your-quicknode-url.solana-devnet.quiknode.pro/
NETWORK=mainnet-beta
# Wallet Configuration (set this to your actual path)
KEYPAIR_PATH=./keypair.json
# Program Addresses
SKR_STAKING_PROGRAM=SKRskrmtL83pcL4YqLWt6iPefDqwXQWHSw9S9vz94BZ
SKR_GUARDIAN_POOL=DPJ58trLsF9yPrBa2pk6UaRkvqW8hWUYjawe788WBuqr
SKR_MINT=SKRbvo6Gf7GondiT3BbTfuRDPqLWei4j2Qy2NPGZhW3
# Token Mints
USDC_MINT=EPjFWaLb3odcccccccccccccccccccccccccccccccc
USDT_MINT=Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenErt
# Logging
LOG_LEVEL=INFO.env to version control. It's already in .gitignore.
source .venv/bin/activate
python main.pyThis will:
- Load configuration from
.env - Initialize your wallet
- Start the scheduling service
- Begin executing stake/swap operations on configured intervals
SwapnStake/
├── main.py # Main entry point
├── examples.py # Usage examples
├── test_jupiter_api.py # Jupiter API tests
├── pyproject.toml # Python dependencies
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
├── swapnstake/ # Python package
│ ├── __init__.py
│ ├── config.py # Configuration management
│ ├── wallet.py # Wallet operations
│ ├── rpc.py # RPC client
│ ├── tokens.py # Token definitions
│ ├── jupiter.py # Jupiter swap integration
│ ├── staking.py # Staking logic
│ ├── scheduler.py # Task scheduling
│ └── transactions.py # Transaction building
├── ts/ # TypeScript utilities
│ ├── swap.ts # Swap utilities
│ └── staking.ts # Staking utilities
└── BuildResources/ # Build and architecture docs
├── ARCHITECTURE.md
└── create_test_tokens.sh
---
## Licensing & Permitted Use Cases
SwapnStake is licensed under **GPLv3 + Commons Clause**. See the full [LICENSE](LICENSE) file for details.
### ✅ Permitted Use Cases
- Personal automation and staking operations
- Educational projects and portfolio work
- Contributing improvements back to the repository
- Creating personal forks for non-commercial use
- Deploying on personal infrastructure
- Experimentation and testing
### ❌ Restricted Use Cases
- Commercial products or services
- Offering as a paid service (SaaS)
- Monetizing derivative works
- Selling or licensing the software
For complete details and exceptions, see the [LICENSE](LICENSE) file.```