Skip to content

mainul-islam-faruqi/Solana-Program-Trading-Bot

Repository files navigation

On-Chain Trading Bot Program

A Solana program for automated DCA (Dollar Cost Averaging) trading using Jupiter's DCA program.

Overview

This program provides functionality for:

  • Setting up DCA (Dollar Cost Averaging) strategies
  • Managing token swaps through Jupiter
  • Handling token escrow accounts
  • Airdrop distribution for participants

Program Architecture

Core Components

  1. Instructions

    • setup_dca: Create new DCA strategy
    • close: Close DCA positions and accounts
    • airdrop: Handle airdrop distribution
  2. State Management

    • Escrow: Manages user tokens and DCA state
    • Handles token accounts and permissions
  3. Integration

    • Jupiter DCA program integration
    • Token account management
    • Secure fund handling

Development

Prerequisites

  • Rust and Cargo
  • Solana Tool Suite
  • Anchor Framework

Build

anchor build

Test

anchor test

Deploy

anchor deploy

Program Structure

src/
├── lib.rs              # Program entry point and instruction handlers
├── instructions/       # Instruction implementation
│   ├── setup_dca.rs   # DCA setup logic
│   ├── close.rs       # Position closing logic
│   └── airdrop.rs     # Airdrop distribution
├── state/             # Program state definitions
│   └── escrow.rs      # Escrow account structure
└── errors/            # Custom error definitions

Usage

  1. Initialize DCA Strategy:
await program.methods
  .setupDca(
    applicationIdx,
    inAmount,
    inAmountPerCycle,
    cycleFrequency,
    minOutAmount,
    maxOutAmount,
    startAt
  )
  .accounts({...})
  .rpc();
  1. Close Position:
await program.methods
  .close()
  .accounts({...})
  .rpc();
  1. Handle Airdrop:
await program.methods
  .airdrop()
  .accounts({...})
  .rpc();

Security Considerations

  • All token transfers use PDAs
  • Input validation on amounts and intervals
  • Proper permission checks
  • Secure escrow account management

References

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published