FlexiYeild

Auto-rebalancing stablecoin basket on Solana: deposit USDC, earn yield with de-peg safety

FlexiYeild

Created At

ETHOnline 2025

Project Description

FlexiYield: Dynamic Stablecoin Basket Protocol

FlexiYield is a Solana-native DeFi protocol that creates a dynamic stablecoin basket system, transforming traditional stablecoins into an auto-optimized, diversified portfolio. It is built specifically for a hackathon environment using devnet infrastructure.

Core Concept & Problem Solved:
FlexiYield addresses the manual complexity of stablecoin management by creating a “meta-stablecoin” called FLEX that automatically rebalances between different stablecoins based on:

  • Yield optimization through mock APY signals
  • De-peg protection via health monitoring
  • Risk diversification across multiple stablecoin assets
  • Rules-based rebalancing with configurable thresholds

Technical Architecture:

Smart Contract Layer (Rust/Anchor):

  1. Basket Program – Core deposit/withdrawal logic, NAV calculations, FLEX token minting
  2. Strategy Program – Target weight management, threshold controls, mock oracle integration
  3. Rebalance Program – Automated rebalancing execution with cap enforcement

Frontend (Next.js/TypeScript):

  • Real-time dashboard with composition charts and NAV tracking
  • Seamless wallet integration (Phantom devnet)
  • Admin controls for strategy parameter adjustments
  • Transaction monitoring with Solana explorer integration

Key Innovation Points:

Solana Speed & Cost Advantage:

  • Leverages Solana’s sub-second finality for frequent rebalancing
  • Ultra-low transaction fees enable micro-optimizations
  • Real-time UI updates showcasing blockchain performance

Hackathon-Optimized Features:

  • Devnet-only implementation with mock assets (USDCd, USDTd)
  • Internal swap simulator for reliable demo experience
  • One-command deployment via comprehensive script automation
  • Mock oracle system for APY/peg health simulation

Demo Flow & User Experience:

  1. Setup: Airdrop SOL and mint demo USDCd tokens
  2. Deposit: Convert 25 USDCd and receive 25 FLEX tokens (1:1 NAV)
  3. Strategy Control: Toggle APY preferences and trigger automatic rebalancing
  4. Monitoring: View real-time composition changes with transaction explorer links
  5. Withdrawal: Redeem FLEX and receive USDCd proportionally

Technical Specifications:

  • Token Standard: SPL Token with 6 decimals (stablecoin UX)
  • Architecture: PDA-based state management for deterministic reads
  • Security: Guardian pause functionality, admin multisig controls
  • Testing: Comprehensive unit tests for math operations and state transitions
  • Deployment: Automated scripts for devnet setup, token creation, and program deployment

Hackathon Compliance & Constraints:

Scope Limitations (By Design):

  • Devnet-only operation (no real funds at risk)
  • Single DEX path or internal simulator (no complex routing)
  • Mock oracles via admin UI (no external API dependencies)
  • Manual rebalancing triggers (keeper automation optional)

Deliverables:

  • Live devnet dApp at https://flexi-yield.vercel.app
  • Complete source code with /programs, /app, and /scripts
  • One-command setup for judges and developers
  • Comprehensive documentation and demo recordings

Innovation Impact:
FlexiYield demonstrates how Solana’s performance characteristics enable previously impractical DeFi strategies—frequent, cost-effective rebalancing that would be prohibitively expensive on other chains. This creates a foundation for next-generation automated portfolio management in the stablecoin ecosystem.

The project showcases practical blockchain UX with transparent, real-time updates and clear transaction tracking, making complex DeFi strategies accessible to mainstream users while maintaining full decentralization and user custody.

How it's Made

What i built: A Solana-native “meta-stablecoin” basket (FLEX) that auto-allocates between two devnet stables (USDCd, USDTd), with rules-based rebalancing, peg-health caps, and a clean, deterministic dashboard. Devnet-only, unaudited, no real funds. Single-DEX path with an internal swap simulator fallback for reliable demos.

Tech stack: On-chain: Rust + Anchor (programs: basket, strategy, rebalance), SPL Token (6 decimals), program events, PDA-based state. Frontend: Next.js (App Router) + TypeScript, @solana/web3.js, @coral-xyz/anchor, Solana wallet adapter (Phantom), pnpm workspace. Tooling: Anchor workspace (Anchor.toml), Cargo workspace, scripts in TypeScript for airdrop/mints/seed/deploy/demo. Hosting: Vercel (frontend). Optional DEX CPI: Raydium/Orca on devnet; if flaky, fallback to internal constant-product swap simulator.

How the pieces fit:

Programs (Anchor/Rust) Basket Program (complete):

  • Accounts/PDAs: BasketConfig, USDCd/USDTd vaults, FLEX mint authority.
  • Instructions: initialize_basket, deposit_usdc (mints FLEX vs NAV), redeem_flex (burn FLEX → USDCd), update_config.
  • Events: DepositEvent, RedeemEvent.
  • Token standard: switched from Token-2022 to standard SPL Token for compatibility; enforced 6 decimals for stablecoin UX.
  • NAV: sum of vault balances assuming 1.0 stable price for demo.

Strategy Program (compilation-ready):

  • Admin-gated setters: set_targets, set_thresholds, set_oracle_values.
  • Stores target weights, drift threshold, per-asset caps, and mock oracle flags (APY tilt, peg caution).

Rebalance Program (compilation-ready):

  • rebalance_once: compute deltas vs targets; enforce caps; execute single-DEX swap or internal simulator; update vaults; emit Rebalanced event.
  • Safety: guardian pause/unpause.

Rebalancing logic (demo rules):

  • Trigger when |current_weight - target_weight| > drift_threshold OR when APY preference flips.
  • Caps limit exposure; peg-health temporarily reduces max allocation to a risky asset.
  • Manual “Rebalance Now” supported (keeper optional).

Frontend (Next.js + TypeScript):

  • Wallet connect via Phantom (devnet), faucet CTA, one-click “Mint USDCd.”
  • Deposit/Withdraw flows; composition chart; NAV, FLEX supply, and mock APY/peg badges.
  • Admin mode: sliders/inputs for targets, thresholds, caps, and toggles for mock APY/peg; “Rebalance Now” button.
  • Deterministic reads from PDAs; optimistic UI updates followed by on-chain confirmation; explorer links for every transaction.
  • IDLs exported from programs into app/src/idl; client uses Anchor to derive accounts and deserialize state.

Scripts (TypeScript):

  • airdrop-devnet-sol.ts: fund devnet wallets.
  • create-mints.ts: create USDCd, USDTd, FLEX (6 decimals); persist mint addresses.
  • seed-balances.ts: seed demo vaults and user token accounts.
  • deploy-programs.ts: build/deploy Anchor programs; export fresh IDLs to app/src/idl and program IDs to .env.local.
  • demo-helper.ts: simulate strategy tweaks and trigger rebalances; record mock signatures to demo-recording.json.

Convenience runners:

  • pnpm setup-devnet → airdrop → create-mints → seed-balances → deploy-programs
  • pnpm full-demo → full setup + demo scenarios
  • Environment centralized in app/.env.local (mints, vaults, program IDs, RPC URL); keypairs in .root/.keypairs.json.

Data model and math:

  • 6-decimal SPL tokens across the board.
  • NAV and composition in USDC terms (price ~1.0 for both stables in demo).
  • Rebalance delta: compute desired vs current; apply cap-adjusted target weights; execute single-path swap; update vault state atomically.

What was hacky (on purpose):

  • Internal swap simulator: fallback when devnet DEX CPI is unreliable; ensures smooth demo.
  • Mock oracles via PDAs: APY preference and peg caution flags drive deterministic UI and rebalancing without external APIs.
  • IDL auto-export: build/deploy scripts automatically drop fresh IDLs into the frontend to avoid drift.
  • Stable UX simplification: standardized 6 decimals and ~1.0 price assumption to focus on rebalancing mechanics.
  • Optimistic UI + explorer links: highlight Solana speed and fees, then confirm state with on-chain reads.

Dev experience and testing:

  • Monorepo with pnpm-workspace.yaml and Cargo workspace for shared builds.
  • Quick start: cp app/.env.example app/.env.local → pnpm dev (frontend) → scripts for full devnet provisioning.
  • Unit tests planned for deposit/redeem math, NAV calc, cap enforcement, and rebalance deltas; early basket logic verified.
  • Clear loader/error/empty states to avoid UI confusion during devnet hiccups.
  • Fallback: demo recording/GIF if RPC/DEX unstable during live judging.

Why these partner tools helped:

  • Anchor: reduced Solana program boilerplate (accounts, PDAs, events, client bindings via IDLs).
  • Phantom + Solana wallet adapter: frictionless devnet UX (connect, airdrop, mint sample USDCd).
  • Vercel: zero-config deploys of the Next.js dashboard for live demo link.
  • Raydium/Orca devnet: optional real CPI target; fallback to simulator for reliability.

Constraints we embraced (ETHOnline-style hackathon scope):

  • Devnet-only; no bridges, no mainnet yield farms.
  • Single-DEX path; simple rules-based rebalancing (not an optimizer).
  • No external price/APY dependencies; everything mockable in admin UI.
  • Admin/multisig gating for config; guardian pause for rebalancing.

What we’d ship next (post-hackathon):

  • Robust oracles, multi-DEX routing, yield-bearing stable integrations, security audits, and governance.
background image mobile

Join the mailing list

Get the latest news and updates

FlexiYeild | ETHGlobal