Velodrome Finance: Rewards Distribution Automation
Automated critical protocol operations for one of the largest AMMs on Optimism, eliminating manual intervention and enabling the protocol to scale from 50 to 400+ liquidity pools.

Executive Summary
Velodrome Finance, one of the largest automated market makers (AMMs) on Optimism, needed to automate critical protocol operations that were becoming unsustainable as the platform scaled. Manual processes that worked with dozens of liquidity pools couldn't keep pace with growth toward hundreds of pools - threatening both operational reliability and user trust.
Hack.bg designed and implemented a comprehensive automation system using Chainlink's decentralized oracle network. The solution eliminated manual intervention entirely, reduced operational costs through intelligent batching, and created a foundation that scales automatically with protocol growth.
Key Outcomes:
- Zero manual interventions required for weekly reward distributions
- 400+ active gauges processed automatically within the required time window
- Self-sustaining system that scales without human oversight
- Decentralized execution eliminates single points of failure
The Challenge
As Velodrome Finance scaled to become one of the largest AMMs on Optimism, the protocol faced two distinct but equally critical automation challenges that threatened operational sustainability.
Challenge 1: Weekly Reward Distributions
Every week, Velodrome must distribute rewards to all liquidity providers. This isn't just a technical operation - it's the core promise the protocol makes to its users. Miss the distribution window, and liquidity providers lose confidence; make errors, and funds could be at risk.
The Business Problem:
- Distributions must complete within a narrow two-hour window (one hour before and after the weekly epoch flip at midnight Wednesday-Thursday)
- Every active liquidity pool must receive its distribution within this window
- As the protocol grew from 50 to 400+ pools, manual execution became impossible
- The team was forced to maintain 24/7 operational readiness for a weekly two-hour window
The Technical Complexity:
- Single-transaction approaches hit blockchain gas limits
- The protocol tracks 600+ total pools, but only ~400 are active - naively processing all pools wastes significant resources
- Timing precision required constant monitoring and immediate response
Challenge 2: Automated Compounding (Relay System)
Velodrome's Relay system automatically compounds rewards for token holders, converting earned fees back into locked voting power. This "set and forget" feature is a key value proposition for users who want passive participation.
Two Relay Types:
- Compounder: Converts claimed rewards into VELO tokens and locks them for depositors
- Converter: Converts claimed rewards into USDC (used by the Velodrome Foundation)
Why the Existing System Hit a Wall:
The original relay automation tried to do everything at once - claim rewards, swap tokens, and compound - in a single execution. As the protocol grew, this monolithic approach exceeded the resource limits of automation infrastructure:
- If one step failed, everything failed
- Memory and compute constraints made large-scale processing impossible
- Debugging issues required understanding the entire flow, not isolated components
The architecture needed a fundamental rethink.
"The Hack.bg team brought much-needed expertise and clarity to a complex integration. They were thoughtful and adaptable as needs evolved, navigating a shifting technical landscape with smart workarounds and proactive solutions."
- Velodrome Contributors, Velodrome Finance
Our Approach
We designed a modular automation architecture that would eliminate manual intervention while maintaining the decentralization principles core to Velodrome's identity.
Why Chainlink Automation?
| Approach | Pros | Cons | Verdict |
|---|---|---|---|
| Centralized keeper bots | Simple, low cost | Single point of failure, trust assumptions | Rejected |
| Third-party automation services | Quick to implement | Vendor lock-in, ongoing costs, centralization | Rejected |
| Custom validator set | Maximum control | High complexity, bootstrap challenges | Rejected |
| Chainlink Automation | Decentralized, battle-tested, cost-efficient at scale | Integration complexity | Selected |
Chainlink's Decentralized Oracle Network (DON) provided the trustlessness Velodrome required, with proven reliability across billions in secured value. Users can verify that distributions happen through decentralized infrastructure - not because they trust a single operator.
Key Design Principles
-
Event-Driven, Not Polling: The system reacts to actual blockchain events (new pools created, pools removed) rather than constantly checking for changes. This reduces costs and ensures immediate response.
-
Modular Pipeline for Relays: Instead of one complex process, we broke relay operations into independent steps that trigger each other. Each step can fail and retry without affecting others.
-
Smart Resource Allocation: Only active pools are processed, not the full registry. Work is split across multiple parallel executions to stay within resource limits.
-
Self-Sustaining Economics: The system monitors its own funding and automatically tops up when needed, ensuring automation never stops due to depleted balances.
The Solution
We built a comprehensive automation system with three main components: Emissions (reward distribution), Prices (token pricing), and Utility infrastructure (self-maintenance).
Emissions Automation
A key insight drove the architecture: the protocol tracks 600+ total pools, but only ~400 are active and require distribution. Standard automation tools couldn't achieve the throughput needed, so we built a custom cost-optimized batching system.
GaugeUpkeepManager - The Orchestrator
This contract maintains awareness of which pools are active and manages the automation lifecycle:
- Smart Tracking: Maintains a curated list of only pools that need distribution, avoiding wasted resources on inactive pools
- Automatic Updates: Listens for blockchain events when pools are created, removed, or reactivated - no manual registry updates needed
- Dynamic Scaling: Automatically adds more automation capacity when pool count exceeds thresholds
GaugeUpkeep - The Executor
Custom contract that performs the actual reward distributions:
- Parallel Processing: Multiple executors handle different pool ranges simultaneously (e.g., pools 1-100, 101-200)
- Optimized Batching: Processes 5 pools per transaction by default, tuned for gas efficiency
- Automatic Capacity: New executors are registered only when needed, minimizing fixed costs
Price Automation
Keeps token pricing data fresh for protocol operations:
- Automatic Registration: When tokens are whitelisted for trading, price automation begins automatically
- Interval Updates: Ensures prices stay current without manual intervention
Utility Infrastructure
UpkeepBalanceMonitor - Self-Sustaining Operations
Ensures the entire automation system remains funded:
- Monitors balances across all active automation contracts
- Triggers automatic top-ups when balances fall below thresholds
- Prevents automation failures due to depleted funds
Relay Architecture (Modular Pipeline)
For the Relay system, we transformed the monolithic architecture into an event-driven pipeline:
┌─────────────────────────────────────────────────────────┐
│ Weekly Epoch Trigger │
└─────────────────────┬───────────────────────────────────┘
│
┌─────────────┴─────────────┐
▼ ▼
┌───────────────┐ ┌───────────────┐
│ Claim Rewards │ │ Claim Rebases │
└───────┬───────┘ └───────────────┘
│
▼
┌───────────────┐
│ Swap Rewards │
│ (VELO/USDC) │
└───────┬───────┘
│
▼ (Compounders only)
┌───────────────┐
│ Lock/Compound │
│ veVELO │
└───────────────┘
Benefits of This Architecture:
- Each step can fail and retry independently - no cascading failures
- Resource requirements distributed across multiple executions
- Easy to add new relay types or modify individual steps
- Issues can be debugged in isolation
Results
Business Impact
| Outcome | Before | After |
|---|---|---|
| Weekly operational burden | 24/7 readiness for 2-hour window | Zero manual intervention |
| Distribution reliability | Risk of missed distributions | 100% automated, on-time |
| Scalability | ~50 pools practical limit | 400+ pools and growing |
| Team focus | Diverted to operations | Free for protocol development |
Technical Performance
Live testing validated the cost-optimized design:
| Metric | Result |
|---|---|
| 100 pools distributed | ~2 minutes total |
| Batch size | 5 pools per execution |
| Dynamic scaling | Pools added/removed mid-distribution handled correctly |
| Capacity management | Automatic when thresholds exceeded |
Cost Optimization
| Metric | Before | After |
|---|---|---|
| Pools processed | 600+ (including inactive) | ~400 (active only) |
| Processing approach | Sequential, single executor | Parallel, multiple executors |
| Resource waste | Significant (inactive pools) | Eliminated |
| Capacity scaling | Manual | Automatic |
Relay System Transformation
| Metric | Before | After |
|---|---|---|
| Architecture | Monolithic (all-or-nothing) | Modular pipeline |
| Failure handling | Cascade failures | Isolated to single step |
| Debugging | Complex, full-flow analysis | Simple, step-by-step |
| Extensibility | Difficult | Easy to add new relay types |
Strategic Outcomes
- Trustless Operations: Protocol functions execute via Chainlink's decentralized network - users don't need to trust a single operator
- Future-Proof Foundation: Architecture supports continued growth without redesign
- Self-Sustaining System: Balance monitoring ensures continuous operation without oversight
- Enhanced Protocol Trust: Users can verify that distributions happen consistently and predictably
Open Source
The complete implementation is available at github.com/velodrome-finance/automations, demonstrating production-grade Chainlink Automation patterns for the DeFi ecosystem.
Related Repository: github.com/velodrome-finance/relay
Technologies Used
Solidity Hardhat Chainlink Automation Chainlink Log Triggers TypeScript Optimism Ethers.js
Ready to ship your blockchain project?
From smart contracts to full-stack dApps, we turn your Web3 vision into reality. Let's talk about what you're building.
hello@hack.bg