Funding public goods through DeFi yield on Flare. Deposit stablecoins, generate impact automatically
Flare Public Goods is a decentralized funding mechanism that transforms idle crypto assets into sustained support for public goods on the Flare Network. Users deposit stablecoins (USDC) into a smart contract that automatically allocates them to yield-generating DeFi protocols like Kinetic Markets and Morpho Blue. The generated yield is then distributed to support public goods initiatives, open-source development, and community projects. Unlike traditional donation models, users never lose their principal - they can withdraw their full deposit at any time. This creates a sustainable, no-loss funding model where the passive income from DeFi protocols becomes a continuous stream of support for the commons. The system uses Flare's secure VRF (Verifiable Random Function) to ensure fair and transparent distribution of funds, and employs a novel time-decaying probability mechanism for periodic fund allocation. By leveraging the composability of DeFi and the security features of Flare Network, this project demonstrates how blockchain technology can create new economic models for funding public goods without relying on extractive mechanisms or requiring users to sacrifice their capital.
This project is built as a full-stack DeFi application combining Solidity smart contracts with a modern React frontend, specifically designed to leverage Flare Network's unique features. Smart Contract Architecture: The core contract (FlarePublicGoods.sol) implements an ERC4626-style vault system with a modular adapter pattern. We built two lending adapters: KineticAdapter for Flare's Kinetic Markets (Compound-style cToken interface) and Morpho4626Adapter for ERC4626-compliant vaults on other chains. This adapter pattern makes the system protocol-agnostic and easily extensible to other yield sources. For randomness, we integrated Flare's Secure Random Number V2 via FlareSecureRandomAdapter, which fetches verifiable random numbers from Flare's ContractRegistry. This was crucial for ensuring fair and tamper-proof fund distribution. We also implemented a sophisticated time-decaying probability system using exponential half-life mathematics - this creates a dynamic threshold where the likelihood of fund allocation increases over time, preventing gaming and ensuring regular distribution. Frontend: Built with React 18, TypeScript, and Vite for performance. We used Wagmi 2.16 for Ethereum interactions and RainbowKit for wallet connectivity, with custom chain configurations for Flare Coston2, Katana, and Flow EVM testnets. Framer Motion powers extensive animations throughout the UI. The app is fully responsive with mobile-first design. Notable Hacks: Implemented smooth probability interpolation within half-life periods using fixed-point arithmetic to avoid gas-expensive floating-point operations Used the "swap-and-pop" technique for O(1) depositor array removal instead of expensive array shifting Created a multi-chain contract address system that automatically detects the connected network and uses appropriate contract addresses Leveraged Flare's ContractRegistry for dynamic contract discovery, making the randomness adapter future-proof against network upgrades Technologies: Solidity 0.8.20, Foundry, OpenZeppelin contracts, Flare periphery contracts, React, Wagmi, RainbowKit, TanStack Query, Radix UI, Tailwind CSS.

