yousaf_website

Yousaf

Yousaf

Available

I started building on Solana almost 2 years ago, with a strong focus on Rust development. My background includes building private infrastructure such as sniping bots, copy trading systems, and similar tooling.

Pakistan, UTC+5
use anchor_lang::prelude::*;
use solana_program::pubkey::Pubkey;

declare_id!("YsF7xKp9B3vGn2R4dW8m");

#[program]
pub mod trading_engine {
    use super::*;

    pub fn initialize(
        ctx: Context<Initialize>,
        config: EngineConfig,
    ) -> Result<()> {
        let state = &mut ctx.accounts.state;
        state.authority = ctx.accounts
            .authority.key();
        state.is_active = true;
        state.total_trades = 0;
        msg!("Engine initialized");
        Ok(())
    }

    pub fn execute_swap(
        ctx: Context<ExecuteSwap>,
        amount_in: u64,
        min_out: u64,
    ) -> Result<()> {
        require!(
            amount_in > 0,
            ErrorCode::InvalidAmount
        );
        let pool = &ctx.accounts.pool;
        let price = calculate_price(
            pool.reserve_a,
            pool.reserve_b,
        )?;
        let amount_out = amount_in
            .checked_mul(price)
            .ok_or(ErrorCode::Overflow)?;
        require!(
            amount_out >= min_out,
            ErrorCode::SlippageExceeded
        );
        emit!(SwapExecuted {
            user: ctx.accounts.user.key(),
            amount_in,
            amount_out,
            timestamp: Clock::get()?.unix_timestamp,
        });
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(
        init,
        payer = authority,
        space = 8 + State::LEN,
    )]
    pub state: Account<'info, State>,
    #[account(mut)]
    pub authority: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[account]
pub struct State {
    pub authority: Pubkey,
    pub is_active: bool,
    pub total_trades: u64,
    pub volume: u128,
}

impl State {
    pub const LEN: usize = 32 + 1 + 8 + 16;
}

#[error_code]
pub enum ErrorCode {
    #[msg("Invalid trade amount")]
    InvalidAmount,
    #[msg("Arithmetic overflow")]
    Overflow,
    #[msg("Slippage tolerance exceeded")]
    SlippageExceeded,
}
use anchor_lang::prelude::*;
use solana_program::pubkey::Pubkey;

declare_id!("YsF7xKp9B3vGn2R4dW8m");

#[program]
pub mod trading_engine {
    use super::*;

    pub fn initialize(
        ctx: Context<Initialize>,
        config: EngineConfig,
    ) -> Result<()> {
        let state = &mut ctx.accounts.state;
        state.authority = ctx.accounts
            .authority.key();
        state.is_active = true;
        state.total_trades = 0;
        msg!("Engine initialized");
        Ok(())
    }

    pub fn execute_swap(
        ctx: Context<ExecuteSwap>,
        amount_in: u64,
        min_out: u64,
    ) -> Result<()> {
        require!(
            amount_in > 0,
            ErrorCode::InvalidAmount
        );
        let pool = &ctx.accounts.pool;
        let price = calculate_price(
            pool.reserve_a,
            pool.reserve_b,
        )?;
        let amount_out = amount_in
            .checked_mul(price)
            .ok_or(ErrorCode::Overflow)?;
        require!(
            amount_out >= min_out,
            ErrorCode::SlippageExceeded
        );
        emit!(SwapExecuted {
            user: ctx.accounts.user.key(),
            amount_in,
            amount_out,
            timestamp: Clock::get()?.unix_timestamp,
        });
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(
        init,
        payer = authority,
        space = 8 + State::LEN,
    )]
    pub state: Account<'info, State>,
    #[account(mut)]
    pub authority: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[account]
pub struct State {
    pub authority: Pubkey,
    pub is_active: bool,
    pub total_trades: u64,
    pub volume: u128,
}

impl State {
    pub const LEN: usize = 32 + 1 + 8 + 16;
}

#[error_code]
pub enum ErrorCode {
    #[msg("Invalid trade amount")]
    InvalidAmount,
    #[msg("Arithmetic overflow")]
    Overflow,
    #[msg("Slippage tolerance exceeded")]
    SlippageExceeded,
}

Work

Projects that I worked on along the way

Work

Projects that I worked on along the way

Trading Engine

High-performance on-chain swap execution engine with multi-DEX routing and optimized transaction packing for Solana.

Rust Solana Anchor

Sniper Infrastructure

Real-time token launch monitoring and automated execution system with sub-second response times and configurable strategies.

Rust TypeScript WebSocket

Copy Trading System

Automated trade mirroring service that replicates transactions across multiple wallets with slippage protection and risk controls.

Rust Solana gRPC