Technical Architecture

Table of Content

Table of Content

Table of Content

Smart Contract Architecture

Deep dive into Stakefy’s Solana-based contracts — including staking vault logic, event emissions, and on-chain verification flow.

We use Anchor Framework (Rust-based) for all Solana smart contracts.

Core Programs:

1. StakeManager

  • Handles user stake deposits and withdrawals

  • Tracks stake positions per (user, service) pair

  • Enforces minimum stake requirements

  • Manages unstaking requests and epochs

  • Emits events for access control

Key Instructions:

pub fn stake(
    ctx: Context<Stake>,
    amount: u64,
    service_id: Pubkey
) -> Result<()>

pub fn unstake(
    ctx: Context<Unstake>,
    service_id: Pubkey
) -> Result<()>

pub fn claim_principal(
    ctx: Context<ClaimPrincipal>,
    stake_id: Pubkey
) -> Result<()

2. YieldRouter

  • Aggregates staking rewards from multiple sources

  • Routes yield to service provider wallets

  • Calculates and deducts protocol fees

  • Handles yield distribution schedules (daily, weekly, monthly)

  • Supports multiple yield sources (native staking, liquid staking, DeFi)

Yield Flow:

Validator Rewards
       
YieldRouter (deducts 0.5% fee)
       
Provider Wallet (99.5% of yield)
Protocol Treasury (0.5% fee)

3. AccessRegistry

  • On-chain registry mapping stake positions → access permissions

  • Real-time stake status verification

  • Grace period logic (temporary stake drops don't immediately revoke access)

  • Tiered access management (Bronze/Silver/Gold)

Query Example:

pub fn verify_access(
    user: Pubkey,
    service_id: Pubkey
) -> Result<AccessStatus> {
    // Returns: Active, Expired, Grace Period, or None
}

4. ServiceRegistry

  • On-chain catalog of providers

  • Stores stake requirements per service

  • Provider wallet addresses for yield routing

  • Metadata (name, description, tiers, APY targets)

  • Governance-approved services (prevents scams)

5. SFY Token Program

  • SPL token standard

  • Staking rewards distribution

  • Governance voting mechanisms

  • Burn functionality for deflationary events