Potato

Smart auto-rebalancing crypto baskets especially for PYUSD holders—simple, secure, non-custodial.

Potato

Created At

ETHOnline 2025

Project Description

DETAILED DESCRIPTION

Potato Finance is a decentralized portfolio management platform that brings set-and-forget automation to crypto investing. Built on Ethereum, it allows users to create customizable "baskets" of cryptocurrencies with specific target allocations and automatically rebalances them when market movements cause drift.

THE PROBLEM WE SOLVE

Crypto investors face a common dilemma: maintaining balanced portfolio allocations requires constant monitoring and manual rebalancing, which is time-consuming, expensive (gas fees), and emotionally difficult. Most investors either HODL and watch their allocations drift wildly, or spend hours manually rebalancing and paying high transaction costs.

For PYUSD holders specifically, the barriers are even higher. Many PayPal users hold PYUSD as a stable store of value but want exposure to crypto assets like BTC and ETH without the complexity of: • Setting up separate crypto exchange accounts • Managing complex wallet addresses (0x...) • Learning DeFi protocols and swapping mechanisms • Dealing with private keys and seed phrases • Manually executing and monitoring rebalancing trades

Potato Finance eliminates these barriers by leveraging PYUSD's unique capability to send funds directly from your PayPal account to ENS names. Simply send PYUSD from PayPal to yourname.bb.pyusd.eth and watch it automatically diversify into your chosen crypto allocation—it's as simple as sending money to a friend on Venmo.

HOW POTATO FINANCE WORKS

  1. Create Your Basket: Users set up crypto baskets with custom allocations (e.g., "Balanced Blue": 40% BTC, 40% ETH, 20% PYUSD or "Cushioned Core": 50% BTC, 50% ETH)

  2. Deposit Funds: Simply send any supported token to your personalized ENS address (like yourname.bb.pyusd.eth). For PayPal users, this is a game-changer: open your PayPal app, send PYUSD to yourname.bb.pyusd.eth just like you'd send to a friend—no wallet setup, no 0x addresses, no complexity. PYUSD's unique ENS integration makes this the easiest crypto on-ramp imaginable

  3. Automatic Rebalancing: When market movements cause your allocations to drift beyond your threshold (e.g., 5%), the smart contract automatically rebalances back to target ratios using real-time Pyth Network price feeds

  4. Track Performance: Watch your portfolio maintain its target allocation while our backtests show rebalancing strategies outperform simple buy-and-hold by up to 4.65% in volatile markets

KEY FEATURES

• 🔐 Passkey Authentication: Login with your fingerprint or Face ID - no passwords, private keys, or seed phrases to manage • 💼 Non-Custodial: You always own your funds. Your baskets are smart contracts you control • ⛽ Gas-Friendly: Powered by ERC-4337 Account Abstraction and Pimlico, making transactions smoother and more efficient • 🎯 ENS Integration: Each basket gets a memorable ENS subdomain for easy deposits • 📊 Real-Time Pricing: Integrated with Pyth Network for accurate, tamper-proof price feeds • 🔄 Smart Rebalancing: Automated portfolio rebalancing based on configurable drift thresholds • 💙 PayPal PYUSD Ready: Full integration with PayPal's USD stablecoin for easy on/off ramping

WHO IT'S FOR

• PayPal PYUSD holders who want to diversify into BTC and ETH without leaving the PayPal ecosystem—send PYUSD directly from your PayPal app to your basket's ENS name and let it automatically allocate into crypto. No exchanges, no wallet setup, no complexity • Crypto investors who want diversified exposure without constant monitoring • DeFi users tired of manually rebalancing their portfolios • Traditional finance users dipping their toes into crypto who want a familiar, simple experience bridging PayPal and decentralized finance • Anyone who believes in the power of disciplined, algorithmic investing over emotional decision-making

How it's Made

SMART CONTRACT ARCHITECTURE

The heart of Potato Finance is a set of Solidity smart contracts deployed on Ethereum Sepolia:

  1. Basket Contract (Upgradeable) • Built with OpenZeppelin's upgradeable contracts pattern for future improvements • Stores token allocations, percentages, and Pyth price feed IDs • Implements rebalanceBasket() function that fetches live prices from Pyth Network and adjusts holdings to target allocations • Uses upgradeable proxy pattern for maintenance without losing user data

  2. BasketFoundry Contract • Factory pattern using OpenZeppelin's Clones library (EIP-1167) for gas-efficient basket creation • Creates minimal proxy clones of the Basket implementation, saving ~95% deployment gas • Tracks all user baskets via mappings • Automatically funds new baskets with 0.01 ETH for Pyth price feed updates

  3. PotatoFinanceEntrypoint Contract • One-transaction setup that creates both "Balanced Blue" and "Cushioned Core" baskets for each user • Integrates ENS registry and resolver to assign subdomains (e.g., alice.bb.pyusd.eth) • Maps user nicknames to wallet addresses for social features • Hardcoded asset configurations for demo simplicity

ACCOUNT ABSTRACTION & WEB3 UX

Pimlico + Safe Smart Accounts • Leveraged Pimlico bundler services and paymasters for ERC-4337 Account Abstraction • Users interact with a Safe multisig smart contract wallet (deployed via toSafeSmartAccount) • Enables gasless transactions (paymaster sponsors gas) and batched operations • Users never need ETH to interact - they just use their crypto holdings

Passkey Authentication • Implemented WebAuthn/FIDO2 passkey-based authentication (no passwords!) • Private keys are deterministically derived from passkey credential IDs (SHA-256 hash mapped to secp256k1) • Passkeys stored securely in device TPM/Secure Enclave - never leaves user's device • Supports both creating new passkeys and recovering existing ones • This was particularly hacky but notable: we're deriving Ethereum private keys from biometric authentication in a deterministic way, making wallet recovery seamless

PRICE FEEDS & REBALANCING

Pyth Network Integration • Real-time, tamper-proof price feeds for BTC, ETH, and PYUSD • On-chain price updates submitted with each rebalance transaction • Price feeds include confidence intervals and exponential notation for precision • Updates cost ~0.001 ETH per rebalance (paid from basket's balance)

Rebalancing Logic • Calculates current portfolio value in USD using Pyth prices • Compares current allocation percentages to target percentages • When drift exceeds threshold (default 5%), triggers rebalance • Uses MockERC20 setBalance() for demo purposes - production would use actual DEX swaps

FRONTEND STACK

React + TypeScript + Vite • Modern React app with TypeScript for type safety • Vite for blazing-fast development and builds • Custom components for potato-themed UI (dancing potato animation, wavy separators) • Real-time basket monitoring with 10-second polling • Responsive design with CSS variables for theming

Web3 Libraries • viem: Modern Ethereum library (replaces ethers.js) for contract interactions • permissionless: Account abstraction SDK for building on ERC-4337 • Direct integration with Pimlico bundler and paymaster APIs

ENS INTEGRATION

• Contracts interact directly with ENS registry on mainnet/testnets • Each user gets two ENS subdomains under pyusd.eth:

  • nickname.bb.pyusd.eth → Balanced Blue basket
  • nickname.cc.pyusd.eth → Cushioned Core basket • ENS resolvers automatically point to basket contract addresses • Enables sending funds to human-readable addresses instead of 0x addresses

DEVELOPMENT & TESTING

Hardhat 3 Beta • Used Hardhat for contract development, testing, and deployment • Hardhat Ignition modules for deterministic deployments • Foundry-compatible test suite in Solidity • TypeScript integration tests with node:test

Backtesting Scripts • Built a complete portfolio rebalancing backtester in TypeScript • Processes historical CSV data from CoinMarketCap • Simulates daily price movements and rebalancing events • Proves rebalancing outperforms buy-and-hold by 3.5-4.65% in provided data • Also includes TradingView Pine Script version for interactive backtesting

NOTABLE HACKS & DESIGN DECISIONS

  1. Deterministic Passkey-to-PrivateKey Mapping: Instead of traditional seed phrases, we hash WebAuthn credential IDs to generate Ethereum private keys. This is demo-grade (production would use proper key derivation), but it elegantly solves wallet recovery.

  2. Clone Pattern for Baskets: Using EIP-1167 minimal proxies saves ~10x gas on basket deployment compared to full contract deployment.

  3. Mock Rebalancing: For demo purposes, baskets use MockERC20.setBalance() instead of real DEX trades. Production would integrate with Uniswap/1inch for actual swaps.

  4. Single Setup Transaction: The Entrypoint contract creates both baskets + ENS records in one transaction, reducing user friction and gas costs.

  5. No Private Key Management: Users never see private keys. Everything is handled via passkeys + AA smart wallets, making Web3 feel like Web2.

TECHNOLOGY STACK SUMMARY

Smart Contracts • Solidity ^0.8.28 • OpenZeppelin Contracts (Upgradeable) • Hardhat 3 Beta • Foundry Testing Framework

Blockchain & Web3 • Ethereum (Sepolia Testnet) • ERC-4337 Account Abstraction • Pyth Network (Price Feeds) • ENS (Ethereum Name Service) • PayPal USD (PYUSD)

Frontend • React 18 • TypeScript • Vite • CSS3 with Custom Properties

Web3 Libraries • viem • permissionless • Pimlico SDK

Authentication • WebAuthn / FIDO2 Passkeys • Safe Smart Accounts

Analytics & Backtesting • TypeScript (Node.js/Bun) • TradingView Pine Script • Historical data from CoinMarketCap

THE RESULT

Potato Finance delivers a genuinely user-friendly crypto portfolio manager that feels more like using a banking app than interacting with blockchain - all while maintaining the core principles of decentralization and self-custody. The platform proves that DeFi doesn't have to be complicated or scary; it can be as simple as setting your allocations and letting a friendly potato handle the rest. 🥔

background image mobile

Join the mailing list

Get the latest news and updates