Skip to content

StakeFlow

Solana SPL staking dApp built with Anchor + React: stake tokens, accrue rewards, and claim later via PDA-managed config/vaults and program-owned reward mint authority.

SolanaAnchorReact

Overview

StakeFlow is an Anchor-based SPL token staking dApp on Solana. Users stake a token, accrue rewards over time, and claim them later. The program manages all core state via PDAs (config + vaults + reward mint authority), while the frontend focuses on a clean staking UX (stake / unstake / claim + dev tooling).


What it demonstrates

  • Solana program architecture with Anchor (IDL-driven client, typed accounts)
  • PDA design for config + vaults + mint authority ownership
  • Practical staking flows: stake → pending rewards → claim → unstake (with penalties)
  • Frontend integration with Solana Wallet Adapter (Phantom/Solflare) and clear tx feedback

Key features

  • Stake SPL tokens and track your position state
  • Claim rewards minted by the program-controlled mint authority PDA
  • Configurable staking parameters (APR, lock duration, early-unstake penalty)
  • Vault separation (stake vault vs penalty vault)
  • Devnet-friendly tooling (addresses in config.ts, explorer links, optional faucet UI)

StakeFlow runs on Solana devnet for testing. Do not treat devnet tokens or balances as real value.


Live demo


Onchain architecture notes

  • Config PDA stores staking parameters (APR, lock, penalty).
  • Vault PDAs hold stake tokens and route penalties separately.
  • Reward mint authority PDA owns the reward mint authority so rewards are issued by the program (not by a server-side key).
  • The frontend derives PDAs/ATAs deterministically from the IDL/program ID for safe, consistent account addressing.

Quickstart

If you want to run it locally, the project is split into two parts:

  • Program (Anchor/Rust): build, deploy, initialize PDAs/config
  • Frontend (React + Vite): connect wallet and run stake/claim/unstake flows

See the repository READMEs for full devnet setup steps (mints, ATAs, anchor run init, and config wiring).


Notes

  • Before any demo, verify mint authorities and ATAs (devnet) to avoid confusing “no balance / no ATA” failures.
  • In production-style setups, disable dev-only faucet UI and avoid any endpoint that requires a private mint authority key.
  • Reward issuance should remain program-controlled (PDA authority), not server-controlled.

Next steps

If I were to evolve StakeFlow further:

  • Add a richer position/history view (events + indexed timeline)
  • Add multiple pools (pool PDA per mint pair + pool-level config)
  • Add stronger UX guardrails (lock timers, penalty preview, simulation)
  • Add a more production-like RPC strategy (fallback RPCs + rate limit handling)