Skip to content

Repository files navigation

SwapnStake

GNU GPLv3 + Commons Clause built with Python 3.12+ Solana TypeScript

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

Prerequisites

Before running SwapnStake, ensure you have the following installed:

Required

For Solana interaction

  • A Solana wallet with SOL for transaction fees
  • A funded wallet containing SKR tokens
  • Access to a Solana RPC endpoint (Devnet, Testnet, or Mainnet)

Installation

1. Clone the repository

git clone <repository-url>
cd SwapnStake

2. Set up Python environment

SwapnStake uses Python 3.12+ with uv for dependency management:

# Install project dependencies
uv sync

This will:

  • Create a virtual environment in .venv/
  • Install all Python dependencies from pyproject.toml

Python Dependencies:

  • solders>=0.27.1 - Solana transaction building and signing
  • httpx>=0.24.0 - Async HTTP client for RPC and APIs
  • rich>=13.0.0 - Rich terminal output
  • apscheduler>=3.10.0 - Task scheduling
  • pydantic>=2.0.0 - Configuration validation
  • python-dotenv>=1.0.0 - Environment variable management
  • base58>=2.1.0 - Base58 encoding/decoding

3. Set up Node.js/TypeScript components

npm install

Node 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 derivation
  • typescript>=6.0.3 - TypeScript compiler
  • ts-node>=10.9.2 - TypeScript execution for Node.js

4. Configure environment variables

Create a .env file in the project root:

cp .env.example .env

Edit .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

⚠️ Security Note: Never commit .env to version control. It's already in .gitignore.


Running the Program

source .venv/bin/activate
python main.py

This will:

  1. Load configuration from .env
  2. Initialize your wallet
  3. Start the scheduling service
  4. Begin executing stake/swap operations on configured intervals

Project Structure

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.```

About

Automated skr staking for Seeker

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages