Smart Contracts

The core logic of KalshChain is secured by three primary Solana programs (smart contracts).

Program Overview

Each program handles a distinct, critical function to ensure security and modularity.

Market Program

Handles market creation, resolution, and lifecycle management. It defines the event, expiry, and outcome.

Address: KaLsH...MkT1

AMM Program

Automated Market Maker for liquidity pools and trade execution, implementing the CPMM formula.

Address: KaLsH...AMM2

Position Program

Manages user positions, claims, and profit/loss calculations post-settlement.

Address: KaLsH...POS3

Account Structure

The following structure defines the data accounts used by the programs:

MarketAccount.rs
#[account]
pub struct MarketAccount {
    pub creator: Pubkey,
    pub token_mint: Pubkey,
    pub yes_vault: Pubkey,
    pub no_vault: Pubkey,
    pub title: String,
    pub expiration_date: i64,
    pub is_resolved: bool,
    pub winning_outcome: u8, // 1 for YES, 0 for NO
}

AMM Implementation

KalshChain uses a Constant Product Market Maker (CPMM) with the formula x * y = k where:

  • x = YES share reserves
  • y = NO share reserves
  • k = constant product (derived from initial liquidity)