NexusEarn

Adaptive multi-chain yield optimizer with rebalancing via Avail Nexus cross-chain execution

NexusEarn

Created At

ETHOnline 2025

Project Description

NexusEarn is an adaptive multi-chain yield optimization platform that automatically finds the highest APY opportunities for stablecoins (USDC, USDT, DAI) across major DeFi protocols (Aave, Compound, Yearn, Curve, Beefy) on Ethereum, Polygon, and Arbitrum.The Problem DeFi users face significant friction managing yields across chains: constant APY monitoring, complex multi-step rebalancing (4+ transactions, $50+ fees, 30-60 minutes), and missed opportunities leaving 1-3% APY on the table.Our Solution1. Intelligent Yield Scanner

Real-time APY aggregation from DeFiLlama across 15+ protocol-chain pairs Risk-adjusted scoring (TVL, audits, exploits history) Automated opportunity ranking 2. AI-Powered Rebalance Engine

Complete cost analysis (gas, bridge fees, slippage) Break-even calculations and net yearly gain projections Only suggests profitable rebalances passing user-defined guardrails 3. One-Transaction Cross-Chain Execution via Avail Nexus ⭐ Traditional rebalancing: Withdraw (tx1) → Bridge (tx2, wait 30min) → Approve (tx3) → Deposit (tx4) = 4 transactions, $50+, 1 hourWith CrossYield + Avail Nexus: Withdraw → Bridge → Deposit in ONE atomic transaction = 1 transaction, lower fees, minutesKey Features

Unified dashboard tracking all positions across chains Real-time yield calculations with automatic compounding Customizable safety guardrails (slippage, APY thresholds, risk limits) Emergency withdrawal capability Transaction verification on Avail DA Impact

$50B+ stablecoin liquidity in DeFi Average user leaves $150/year on table (1.5% APY on $10k) 95% never rebalance due to complexity NexusEarn makes optimal yield management effortless

How it's Made

Tech Stack Frontend: Next.js 14, React 18, TypeScript, TailwindCSS, shadcn/ui, Wagmi v2, Viem Smart Contracts: Solidity 0.8.20, Foundry, OpenZeppelin Blockchain: Avail Nexus SDK ⭐, Viem, Ethers Data: DeFiLlama Yields API, Avail DA, Alchemy RPC

Core Technical Implementation

  1. Yield Aggregation Engine

Fetches real-time APY from DeFiLlama API with 60s caching Protocol-specific parsers for Aave, Compound, Yearn data schemas Custom fuzzy matching algorithm for inconsistent pool IDs (95% accuracy)

Algorithm: typescriptscore = (APY × riskMultiplier × tvlScore) + auditBonus riskMultiplier = 1 - (riskScore / 10) 2. Rebalance Optimizer

Gas estimation via eth_estimateGas with 20% safety buffer Bridge fee calculation from Avail Nexus SDK Multi-layer guardrails validation engine Off-chain simulation using Foundry forge test --fork to catch bugs before execution

  1. Avail Nexus Integration ⭐ THE KEY INNOVATION Traditional Rebalance (without Nexus): typescript// 4+ separate transactions await aave.withdraw() // tx1, ~$15 gas await bridge.bridge() // tx2, ~$20 + 30min wait await usdc.approve() // tx3, ~$5 gas await yearn.deposit() // tx4, ~$10 gas CrossYield with Avail Nexus: typescript// ONE atomic transaction await nexusSDK.bridgeAndExecute({ fromChainId: ETHEREUM, toChainId: ARBITRUM, token: 'USDC', amount: '10000', execute: { contractAddress: yearnVault, functionName: 'deposit', functionParams: [amount, user], tokenApproval: { token: 'USDC', amount } } }); Why Avail Nexus is Critical:

✅ Atomic Execution: All-or-nothing guarantee (no stuck funds) ✅ Gas Optimization: Single transaction, pay gas only on source chain ✅ Speed: 10x faster (minutes vs. hours) ✅ UX: One signature, one confirmation ✅ Reliability: Validator network ensures cross-chain message delivery

  1. Protocol Data Readers Built unified interface for reading positions from different protocols:

Aave: Direct balance queries via getUserAccountData() Compound: Balance via balanceOf() on Comet contracts Yearn: Shares × pricePerShare() conversion Handles different ABIs and contract versions across chains

  1. Mock Transaction System Complete simulation environment for testing without real funds:

Simulates approvals, deposits, withdrawals with realistic timing Tracks yield accrual over time (updates every 10s) Generates mock transaction hashes for UI testing Allows full demo without wallet connection

Technical Highlights:

Used Viem over Ethers for 40% smaller bundle size Implemented optimistic UI updates with TanStack Query Built custom ABI encoder for complex nested function calls Protocol contract addresses dynamically resolved per chain

background image mobile

Join the mailing list

Get the latest news and updates