Protected Yield Vaults on the Flow Blockchain
Higher net yield Β· Safer execution Β· Simpler DeFi
Transform static liquidity into protected, yield-bearing capital on the Flow blockchain.
- π© The Problem
- π‘ The Solution
- π Key Features
- ποΈ System Architecture
- π User Workflow
- π οΈ Technical Stack
- π Project Structure
- π Getting Started
- π§ͺ Testing
- π Smart Contracts
- π¬ Protection System Comparison
- πΊοΈ Roadmap
- π License
Most DeFi users face three fundamental challenges that keep their capital idle:
DeFi yield opportunities are scattered across hundreds of protocols. Managing positions requires constant attention β claiming rewards, restaking, rebalancing, and monitoring. Most users don't have the time or expertise to actively manage positions across multiple protocols.
π΄ The Hidden Cost of MEV
Every on-chain transaction is visible in the public mempool before confirmation. Maximal Extractable Value (MEV) bots exploit this visibility to frontrun, sandwich, and backrun trades β extracting >$500M annually from DeFi users. This invisible tax disproportionately impacts larger trades and automated strategies, silently eroding yields.
The vast majority of DeFi users hold assets in simple wallets earning zero yield. The complexity and risk of active management outweigh the perceived benefits, leaving billions in idle capital.
Flow Sentinel enables anyone to deploy capital into smart-contract vaults that autonomously execute yield-generating strategies on the Flow blockchain. Each vault is protected by a built-in 4-layer security system that guards against MEV attacks β ensuring you capture the returns you earn.
Think of it as a self-driving yield account for your FLOW tokens:
- Deposit once, vaults execute strategies automatically
- MEV protection built in β 4 layers, no configuration needed
- Real yields from Flow staking and DeFi protocols
- Full transparency β every operation verifiable on-chain
Flow Sentinel's vaults include a 4-layer execution protection system engineered directly in Cadence 1.0 smart contracts. It works silently in the background β you get higher net yields because attacks are blocked before they happen, not after.
| Threat | How It Steals Yield | How Sentinel Protects |
|---|---|---|
| Frontrunning | Bots see your transaction and buy ahead | Commit-Reveal: Execution details hidden from mempool until confirmed |
| Timing Attacks | Bots predict exactly when your trade executes | VRF Random Delay: Unpredictable 0-5 block delay |
| Price Manipulation | Bots move the market before your strategy runs | Deviation Guard: Checks real vs expected APY before executing |
| Sandwich Attacks | Bots bracket your trade with their own orders | Execution Queue: Random execution order β attackers can't predict position |
Deposit FLOW into smart-contract vaults that autonomously execute yield strategies. Each vault includes a 4-layer execution protection system that silently guards against MEV attacks β you earn higher net yields because value isn't lost to bots.
Three strategy contracts with oracle-powered yield from real Flow DeFi:
- Liquid Staking: Real epoch staking rewards from
FlowIDTableStaking(APY tracked via on-chain oracle) - Yield Farming: Multi-protocol allocation across IncrementFi, Flowty, FlowSwap with VRF-shuffled execution
- Arbitrage: Cross-DEX spread detection with VRF-shuffled DEX scan order
Every vault is protected by a stack of 4 on-chain guards that prevent frontrunning, sandwich attacks, timing exploitation, and price manipulation. Protection levels are configurable per vault (None β Basic β Standard β Full).
Real-time performance tracking with:
- On-chain vault balances and event history
- Sharpe and Sortino risk-adjusted return ratios
- Portfolio breakdown by strategy allocation
- Performance chart from real blockchain events
- Oracle freshness monitoring with staleness alerts
Once configured, vaults execute strategies through on-chain transactions without daily management. Yield accrues transparently and is claimable at any time. Scheduled execution via Netlify keeper functions (or your own automation).
Flow Wallet (native Cadence) and EVM wallets (MetaMask/RainbowKit via WalletConnect).
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Flow Sentinel β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββ¬βββββββββββββββββββββββ€
β Vault Contracts β Protection Layer β Strategies β
β β β β
β SentinelVaultFinal β MEVShieldCore β LiquidStakingStrat β
β ββββββββββββββββ β ββββββββββββββββ β ββββββββββββββββ β
β β Vault β β β Commits β β β Execute() β β
β β Resource βββββΆβ β Dictionary β β β β β
β β (per-user) β β ββββββββββββββββ β ββββββββββββββββ β
β ββββββββββββββββ β ββββββββββββββββ β ββββββββββββββββ β
β ββββββββββββββββ β β Pending β β β YieldFarming β β
β β Collection β β β Executions β β β Strategy β β
β β Resource βββββΆβ ββββββββββββββββ β ββββββββββββββββ β
β ββββββββββββββββ β ββββββββββββββββ β ββββββββββββββββ β
β β β VaultMEV β β β Arbitrage β β
β SentinelInterfaces β β Configs β β β Strategy β β
β ββββββββββββββββ β ββββββββββββββββ β ββββββββββββββββ β
β β IStrategy β β β β
β ββββββββββββββββ β MultiSigAdmin β StrategyRegistry β
β β ββββββββββββββββ β ββββββββββββββββ β
β SentinelVaultFinal β β Admin β β β Strategy β β
β (V2) β β Multi-Sig β β β Catalog β β
β β ββββββββββββββββ β ββββββββββββββββ β
ββββββββββββββββββββββββ΄βββββββββββββββββββββββ΄βββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββ
β SENTINEL PROTECTION SYSTEM β
β 4 Layers β Always Active β
βββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
βΌ βΌ βΌ
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Layer 1 β β Layer 2 β β Layer 3 β
β Commit-Revealβ β VRF Block- β β Price β
β β β Delay Jitter β β Deviation β
β Execution β β Random 0-5 β β Guard β
β hidden from β β block delay β β APY Β± slippageβ
β mempool β β (unpredict.) β β tolerance β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β
βΌ
ββββββββββββββββ
β Layer 4 β
β Execution β
β Queue β
β VRF-shuffled β
β order β
ββββββββββββββββ
graph LR
subgraph "Blockchain Layer"
SC[Smart Contracts<br/>Cadence 1.0]
EV[Events]
ST[Script Queries]
end
subgraph "Service Layer"
FCL[FCL Client<br/>@onflow/fcl]
FSV[FlowService<br/>TypeScript Class]
end
subgraph "State Layer"
Hooks[React Hooks<br/>useVaultData<br/>useActivityFeed]
CTX[FlowContext<br/>Wallet State]
end
subgraph "UI Layer"
Pages[Next.js Pages<br/>Dashboard / Vaults / Portfolio]
Comp[Components<br/>VaultCard / Charts]
end
SC -- Events --> FCL
SC -- Script Results --> FCL
FCL -- JSON Data --> FSV
FSV -- Typed Data --> Hooks
Hooks -- VaultInfo[] --> Pages
Hooks -- Protection Config --> Comp
CTX -- Wallet Status --> Pages
Choose Flow Wallet (native Cadence) or EVM Gateway (MetaMask/RainbowKit)
flow transactions send transactions/init_sentinel.cdc \
--args-json '[
{"type": "String", "value": "My Yield Vault"},
{"type": "String", "value": "Liquid Staking Pro"},
{"type": "String", "value": "liquid-staking-pro"}
]' --network testnetYour vault is created with Full Protection (Level 3) by default:
- β Layer 1 β Commit-Reveal: Active (hides execution details from mempool)
- β Layer 2 β VRF Block-Delay: Active (random 0-5 block delay)
- β Layer 3 β Price Deviation Guard: Active (3% slippage tolerance)
- β Layer 4 β Execution Queue: Active (random processing order)
Deposit FLOW tokens into your vault. The vault balance is tracked on-chain.
Two options:
π΄ Full Protection (Recommended): Two-step Commit-Reveal flow
# Step 1: Generate commit hash off-chain
# Step 2: Commit (hash hidden from mempool)
flow transactions send transactions/mev_commit.cdc \
--args-json '[...]' --network testnet
# Step 3: Reveal + Execute (after commit window)
flow transactions send transactions/mev_reveal.cdc \
--args-json '[...]' --network testnetπ‘ Standard Protection: Direct execution with VRF jitter + price guard
flow transactions send transactions/mev_execute_direct.cdc \
--args-json '[...]' --network testnetNote: Strategy execution requires manual transaction submission. There is no on-chain or off-chain automated scheduler. A user or keeper must call
mev_commit.cdc+mev_reveal.cdc(ormev_execute_direct.cdc) to trigger each execution cycle.
Use the web dashboard to:
- View real-time vault balance and yield accrued
- Monitor protection events and execution history
- Adjust protection level (None β Basic β Standard β Full)
- Claim accumulated yield
- View performance history with P&L charts
| Layer | Technology | Purpose |
|---|---|---|
| Blockchain | Flow (Cadence 1.0) | Smart contract runtime with native randomness |
| Smart Contracts | 9 Cadence contracts | Vault logic, execution protection, strategy execution |
| Web Framework | Next.js 16 (App Router) | SSR, React Server Components, optimized builds |
| UI Library | React 19 | Component-based UI architecture |
| Styling | Tailwind CSS 3 | Utility-first CSS with glassmorphism design |
| Animations | Framer Motion | Interactive UI animations |
| Wallet Connect | FCL + RainbowKit | Flow Wallet + EVM wallet support |
| Error Monitoring | Sentry | Error tracking with session replay |
| Diagrams | Mermaid | Architecture diagrams in README |
| Deployment | Netlify | Edge functions + SSR |
| Flow CLI | flow-cli | Contract deployment, scripts, transactions |
Flow-Sentinel/
βββ app/ # Next.js App Router pages
β βββ dashboard/ # Main dashboard with vault management
β βββ vaults/ # Vault list and details
β βββ portfolio/ # Portfolio analytics
β βββ analytics/ # Performance analytics
β βββ settings/ # User settings
β βββ docs/ # Documentation
β βββ landing/ # Marketing landing page
β βββ page.tsx # Root page
βββ components/
β βββ dashboard/ # VaultCard, CreateVaultModal, Charts
β βββ immersive/ # Animated text, cards, smooth scroll
β βββ layout/ # Navbar, Footer
β βββ ui/ # Reusable UI primitives
βββ contracts/
β βββ MEVShieldCore.cdc # 4-layer execution protection engine
β βββ SentinelVaultV2.cdc # Yield vault with protection (deployed as SentinelVaultFinal)
β βββ SentinelInterfaces.cdc # Core interfaces
β βββ StrategyRegistry.cdc # Strategy catalog
β βββ YieldOracle.cdc # Yield data oracle
β βββ MultiSigAdmin.cdc # Multi-sig admin
β βββ strategies/ # Strategy implementations
β βββ LiquidStakingStrategy.cdc
β βββ YieldFarmingStrategy.cdc
β βββ ArbitrageStrategy.cdc
βββ transactions/ # Cadence transactions
β βββ mev_commit.cdc # Create execution commitment
β βββ mev_reveal.cdc # Reveal and execute strategy
β βββ mev_execute_direct.cdc # Direct execution with protections
β βββ mev_set_protection.cdc # Update vault protection settings
β βββ init_sentinel.cdc # Initialize new yield vault
β βββ ... # 16 total transaction files
βββ scripts/ # Shell & Cadence scripts
β βββ test_mev_protection.sh # Protection system test suite
β βββ mev_status.cdc # Query protection status
β βββ get_vault_info.cdc # Query vault info
β βββ deploy-all-contracts.sh # Deploy all contracts
β βββ verify_deployment.js # Verify deployment
βββ hooks/ # React hooks
β βββ useVaultData.ts # Vault data fetching and transformation
β βββ useActivityFeed.ts # On-chain event feed
βββ lib/
β βββ flow-service.ts # Flow blockchain service layer
β βββ flow.tsx # FCL configuration + FlowProvider
β βββ wagmi.ts # EVM wallet config
β βββ addresses.ts # Single source of truth for contract addresses
βββ flow.json # Flow CLI config (networks, accounts, contracts)
βββ .env.local.example # Environment variable template
βββ netlify.toml # Netlify deployment config
βββ README.md # This file
- Node.js 18+ and npm/pnpm/yarn
- Flow CLI (
flowcommand in PATH) - A Flow wallet (e.g., Flow Wallet browser extension)
- (Optional) A testnet account with FLOW tokens from the Flow Testnet Faucet
# 1. Clone the repository
git clone https://github.com/Aaditya1273/Flow-Sentinel.git
cd Flow-Sentinel
# 2. Install dependencies
npm install
# 3. Copy environment configuration
cp .env.local.example .env.local
# Edit .env.local with your values (defaults work for testnet)
# 4. Start the development server
npm run dev
# Open http://localhost:3000
# 5. (Optional) Deploy contracts to testnet
flow deploy --network testnet
# 6. (Optional) Run the MEV test suite
bash scripts/test_mev_protection.sh testnetSee .env.local.example for the complete list. Key variables:
| Variable | Default (Testnet) | Mainnet |
|---|---|---|
NEXT_PUBLIC_FLOW_ACCESS_NODE |
https://rest-testnet.onflow.org |
https://rest-mainnet.onflow.org |
NEXT_PUBLIC_SENTINEL_VAULT_ADDRESS |
0xc13b08053be24e87 |
Deploy-specific |
NEXT_PUBLIC_SENTINEL_INTERFACES_ADDRESS |
0x136b642d0aa31ca9 |
Deploy-specific |
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID |
Your project ID | Your project ID |
NEXT_PUBLIC_FLOW_TOKEN_ADDRESS |
0x7e60df042a9c0868 |
0x1654653399040a61 |
NEXT_PUBLIC_FUNGIBLE_TOKEN_ADDRESS |
0x9a0766d93b6608b7 |
0xf233dcee88fe0abe |
The test suite verifies all 4 protection layers on-chain:
bash scripts/test_mev_protection.sh testnetThis will:
- Verify contract deployment status
- Create a vault with Full protection
- Layer 1: Commit a hash (execution hidden from mempool)
- Layer 2: Reveal + VRF block-delay jitter applied
- Layer 3: Price deviation guard check
- Layer 4: Execution queue tracking
- Query and verify protection statistics
- Update protection level settings
# Query global protection stats
flow scripts execute scripts/mev_status.cdc nil --network testnet
# Query vault-specific config
flow scripts execute scripts/mev_status.cdc 0 --network testnet
# Query all vault info
flow scripts execute scripts/get_vault_info.cdc 0xc13b08053be24e87 --network testnet# Full Next.js build (passes with zero errors)
npx next build
# TypeScript type checking (check known test file issues)
npx tsc --noEmit| Contract | Address (Testnet) | Description |
|---|---|---|
| MEVShieldCore | 0xc13b08053be24e87 |
4-layer execution protection engine β commit-reveal, VRF jitter, price guard, execution queue |
| SentinelVaultFinal | 0xc13b08053be24e87 |
Protected yield vault with full execution protection integration |
| SentinelInterfaces | 0x136b642d0aa31ca9 |
Core interfaces: IStrategy |
| StrategyRegistry | 0xc13b08053be24e87 |
Strategy catalog β register, query, and update strategy TVL |
| YieldOracle | 0xc13b08053be24e87 |
On-chain yield data feed for price deviation guard |
| MultiSigAdmin | 0xc13b08053be24e87 |
Multi-signature administration for yield reserve |
| Strategy | Description |
|---|---|
| LiquidStakingStrategy | Oracle-powered staking yield with Β±0.5% VRF jitter for MEV privacy |
| YieldFarmingStrategy | Multi-protocol allocation with VRF-shuffled execution order |
| ArbitrageStrategy | Cross-DEX scanning with VRF-shuffled protocol order |
| Transaction | Purpose |
|---|---|
mev_commit.cdc |
Create execution commitment (hides strategy details from mempool) |
mev_reveal.cdc |
Reveal commitment, apply protections, execute strategy |
mev_execute_direct.cdc |
Direct execution with protection (no commit-reveal) |
mev_set_protection.cdc |
Update vault protection level and slippage settings |
init_sentinel.cdc |
Initialize a new yield vault |
deposit_flow.cdc |
Deposit FLOW tokens into a vault |
withdraw_flow.cdc |
Withdraw FLOW tokens from a vault |
claim_yield.cdc |
Claim accumulated yield to wallet |
emergency_pause.cdc |
Pause a single vault |
resume_vault.cdc |
Resume a paused vault |
fund_yield_reserve.cdc |
Fund the yield reserve (MultiSig-guarded) |
trigger_strategy_v2.cdc |
Execute strategy with auto-generated protection parameters |
Contracts must be deployed in this order (dependency chain):
graph TD
A[SentinelInterfaces] --> B[YieldOracle]
A --> C[MultiSigAdmin]
B --> D[MEVShieldCore]
C --> D
D --> E[SentinelVaultFinal]
A --> F[LiquidStakingStrategy]
A --> G[YieldFarmingStrategy]
A --> H[ArbitrageStrategy]
E --> I[StrategyRegistry]
F --> I
G --> I
H --> I
# Deploy everything in one command (using flow.json config)
flow deploy --network testnet --updateConcept: Instead of submitting execution parameters to the mempool where bots can see them, the vault first submits a commitment hash β a one-way SHA3-256 hash of the execution preimage. The actual execution details are revealed later, after the commit has been confirmed. Bots see only the hash and cannot reverse it to discover your strategy.
Cadence Implementation:
// Step 1: Commit (only the 32-byte SHA3-256 hash is visible on-chain)
MEVShieldCore.createCommit(
vaultId: vaultId,
commitHash: commitHash,
protectionLevel: 3
)
// Step 2: Reveal + Execute (after commit window)
MEVShieldCore.revealExecution(
vaultId: vaultId,
commitHash: commitHash,
nonce: nonce,
amount: amount,
strategyId: strategyId,
deadlineBlock: deadlineBlock,
expectedAPY: expectedAPY,
slippageBps: slippageBps
)Properties:
- Execution details hidden from mempool until commit is confirmed
- Preimage includes a random nonce β unpredictable
- 200-block deadline window (~3 minutes) for honest reveal
- Commits are one-time use β cannot be reused after reveal
Concept: Even after execution is revealed, bots could predict its exact execution time. Flow's revertibleRandom() adds a random delay of 0-5 blocks β making execution timing unpredictable.
Cadence Implementation:
let jitterBlocks = revertibleRandom<UInt64>() % (self.getMEVDelayMax() + 1)
let executeAtBlock = currentBlock + jitterBlocks + 1Properties:
- Verifiable random delay β from Flow consensus, not external oracles
- 0-5 blocks β short enough for UX, long enough to break bot timing
- Configurable max delay adjustable without redeploying
Concept: Before executing any strategy, the vault compares the expected APY against the real-time oracle APY. If deviation exceeds the vault's configured slippage tolerance (default 3%), execution is rejected β protecting against price manipulation.
Cadence Implementation:
let oracleData = YieldOracle.getYieldData(self.strategyId)
let actualOracleAPY = oracleData?.apy ?? expectedAPY
let oracleCheck = MEVShieldCore.checkPriceDeviation(
vaultId: self.id,
expectedAPY: expectedAPY,
actualOracleAPY: actualOracleAPY,
slippageBps: self.slippageBps
)
if !oracleCheck.shouldExecute {
emit MEVExecutionGuard(vaultId: self.id, deviation: oracleCheck.deviation, allowed: false, reason: "Price deviation exceeds bounds")
return
}Properties:
- Real-time oracle data β fetches current APY at execution time
- Per-vault slippage β independent setting for each vault
- Hard upper bound β 50% absolute deviation limit as safety net
- Every guard trigger is auditable via on-chain events
Concept: When multiple executions are pending, they are shuffled using VRF randomness. No attacker can predict which execution processes first, preventing sandwich attacks.
Cadence Implementation:
access(self) fun vrfShuffle(_ items: [PendingExecution]): [PendingExecution] {
if items.length <= 1 { return items }
var shuffled: [PendingExecution] = []
var remaining = items
while remaining.length > 0 {
let randomIndex = revertibleRandom<UInt64>() % UInt64(remaining.length)
shuffled.append(remaining[randomIndex])
var newRemaining: [PendingExecution] = []
for i, item in remaining {
if UInt64(i) != randomIndex { newRemaining.append(item) }
}
remaining = newRemaining
}
return shuffled
}Properties:
- VRF-shuffled order β execution sequence is unpredictable
- Fisher-Yates algorithm β unbiased statistical shuffling
- Ready-only filter β only executions past their scheduled block are included
Each vault has independent protection settings:
| Level | Name | Active Layers | Default |
|---|---|---|---|
| 0 | None | No protection | β |
| 1 | Basic | VRF Block-Delay Jitter only | β |
| 2 | Standard | Commit-Reveal + Block-Delay Jitter | β |
| 3 | Full | All 4 layers active | β Default |
| Feature | Flow Sentinel | Typical DeFi Protocol | Ethereum mev-boost |
|---|---|---|---|
| Commit-Reveal Execution | β Cadence-native | β | β (PBS) |
| VRF Randomness | β
revertibleRandom() |
β | β (external oracles) |
| Price Deviation Guard | β On-chain oracle | β | β (Relay mux) |
| Execution Queue | β VRF-shuffled | β | β |
| Per-Vault Protection Config | β Yes | β | β |
| Native Flow Integration | β Yes | β | β (Ethereum only) |
| Off-Chain Dependencies | β Zero | Varies | Required (relays) |
- Phase 1: Core Vault Logic & Testnet Deployment
- Phase 2: Protection System β 4-Layer Architecture
- Phase 3: Professional Analytics Dashboard
- Phase 4: Multi-sig Governance for Community Vaults
- Phase 5: Mainnet Launch
- Phase 6: Institutional API & SDK
This project is licensed under the MIT License - see the LICENSE file for details.
Protected yield vaults on the Flow Blockchain
Higher net yield Β· Safer execution Β· Simpler DeFi
Built with Codebuff
Β·
Flow Blockchain
Β·
Cadence Language