This repository demonstrates how to build a Yield-Donating Strategy (YDS) using Octant V2.
The goal is to show how DeFi yield can automatically fund public goods — without reducing user principal.
It includes:
- 🧩 Solidity smart contracts (Vault, Adapter, Donation Router).
- ⚙️ Foundry scripts for testing and deployment.
- 💻 A simple frontend for live demo and interaction.
Before starting, make sure you have these installed:
git clone https://github.com/Bimajadivaaa/Octant-V2-Tutorial
cd Octant-V2-Tutorial/contractsUse Foundry to verify contracts and see the simulation.
forge test --match-contract YDSUnitTest -vvvThis will test:
- Yield-Donating Vault (YDSVault)
- Mock Yield Adapter
- Donation Router logic
Run Anvil to create a local test network:
anvil --host 0.0.0.0 --chain-id 31337This will start a local EVM node with 10 funded accounts. Each account has a private key — copy one for deployment later.
Deploy all smart contracts on your local chain.
forge script script/DeployLocal.s.sol:DeployLocal \
--rpc-url http://127.0.0.1:8545 \
--private-key <PRIVATE_KEY> \
--broadcastThis deploys:
Mock USDCMockYieldAdapterYDSVaultDonationRouter
After success, Foundry will print deployed contract addresses.
Go to the frontend configuration file:
frontend/app/lib/contractAddresses.json
Paste the new addresses printed from your deployment:
{
"USDC_MOCK": "<USDC_CONTRACT_ADDRESS>",
"YDS_VAULT": "<YDS_VAULT_CONTRACT_ADDRESS",
"MOCK_YIELD_ADAPTER": "<MOCK_YIELD_ADAPTER_CONTRACT_ADDRESS>",
"DONATION_ROUTER": "<DONATION_ROUTER_CONTRACT_ADDRESS>"
}cd ../frontend
pnpm install
# or
npm installStart the development server:
pnpm run dev
# or
npm run devOpen your browser at 👉 http://localhost:3000
You’ll see a dashboard where you can deposit, withdraw, and harvest donations.
- Copy one of the private keys from the Anvil terminal.
- Open MetaMask → Import Account → paste the key.
- Switch to Localhost 31337 network.
- Connect your wallet in the frontend
- Deposit mock USDC into the vault
- Trigger Harvest to donate simulated yield
- Watch funds automatically split between recipients
In Octant V2, a Funding Vault is a smart contract that lets users deposit tokens safely. It invests the capital through a yield source and donates only the generated profit.
This example implements a simplified Yield-Donating Strategy (YDS):
- Users deposit tokens into the vault
- The vault invests through a Yield Adapter
- When profit is detected, it’s sent to a Donation Router
- The router automatically distributes yield to recipient addresses
The result: 💸 Your money stays intact, and only the yield funds public impact.
| Layer | Tool / Framework | Description |
|---|---|---|
| Smart Contracts | Solidity + Foundry | Core logic for vault, adapter, and router |
| Frontend | Next.js 16 + Tailwind + Wagmi | Connect wallet and interact with the vault |
| Blockchain | Anvil (Local EVM) | Local testing environment |
| Package Manager | pnpm / npm | Frontend dependency management |
| Command | Description |
|---|---|
forge build |
Compile all contracts |
forge test -vvv |
Run full test suite |
anvil |
Start local testnet |
forge script ... --broadcast |
Deploy contracts |
pnpm run dev |
Run the frontend locally |
MIT © 2025 Bimajadivaaa
- 📘 Docs: https://docs.v2.octant.build
- 🎥 Tutorial Video: Youtube
- ✨ Medium Blog: Medium
This project is part of the Octant V2 Hackathon, demonstrating how on-chain yield can fund public goods transparently through a yield-donating vault.
