Skip to content

degenSumi/perps-position-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Architecture

High Level Architecture (Perpetual Futures Platform)

Build & Deployment Guide - Perpetual Futures Platform

Complete guide for building and deploying the Solana smart contracts and Rust backend.


Table of Contents

  1. Prerequisites
  2. Smart Contract Deployment
  1. Backend Setup
  2. Monitoring & Maintenance

Prerequisites

Required Tools

Install Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

Install Solana CLI

sh -c "$(curl -sSfL https://release.solana.com/v1.17.0/install)"
export PATH="/home/$USER/.local/share/solana/install/active_release/bin:$PATH"

Install Anchor

cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
avm install latest
avm use latest

Smart Contract Deployment

1. Clone Repository

git clone git@github.com:degenSumi/perps-position-management.git
cd perps-position-management

2. Navigate to Contract Directory

cd position-management-system

3. Configure Solana CLI

For Devnet:

solana config set --url https://api.devnet.solana.com

For Mainnet:

solana config set --url https://api.mainnet-beta.solana.com

4. Create Wallet (if needed)

solana-keygen new --outfile ~/.config/solana/deployer.json

5. Airdrop SOL (Devnet only)

solana airdrop 2

6. Build Contract

anchor build

This generates:

  • Program binary: target/deploy/position_management_system.so
  • IDL: target/idl/position_management_system.json

7. Get Program ID

anchor keys list

Copy the program ID and update it in:

  • Anchor.toml
  • programs/position_management_system/src/lib.rs (at declare_id!)

8. Rebuild After Program ID Update

anchor build

9. Deploy to Devnet

anchor deploy

10. Verify Deployment

solana program show 

12. Run Tests

anchor test

Backend Setup

1. Navigate to Backend Directory

cd backend

2. Configure Environment

Create .env file: Or use the dev env

# Solana Configuration
SOLANA_RPC_URL=https://api.devnet.solana.com
PROGRAM_ID=9bca4kbDn7uyQWQaqfKpe8hCdbBh6KqJFNbkzwHhieC3
SOLANA_PRIVATE_KEY=<BASE58_PRIVATE_KEY> # imp used for all the transactions

# Redis Configuration
REDIS_URL=redis://localhost:6379

# Server Configuration
PORT=3000


# Monitoring
RUST_LOG=info

3. Install Dependencies

cargo build

4. Start Backend (Development)

cargo run

6. Build for Production

cargo build --release

Post-Deployment Checklist

  • Smart contracts deployed and verified
  • Backend running and accessible
  • Database initialized with schema
  • Redis connected
  • WebSocket connections working
  • Health check endpoint responds
  • Position opening/closing tested
  • Liquidation alerts working
  • Logs properly configured

Troubleshooting

Contract Deployment Fails

  • Check SOL balance: solana balance
  • Verify RPC URL: solana config get
  • Check program size: ls -lh target/deploy/*.so

Backend Won't Start

  • Check .env configuration
  • Check Redis connectivity
  • Review logs for errors

WebSocket Not Working

  • Check firewall rules
  • Verify port 3000 is open
  • Test with Postman or wscat

End of Deployment Guide

Other documentations and API Spec

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors