Chainlink Automation
Deep dive into the automated snapshot and yield distribution system powered by Chainlink Automation.
Why Chainlink Automation?
Traditional smart contracts cannot execute themselves. They require external transactions to trigger functions. This creates problems:
Without Automation:
❌ Property owner must manually trigger snapshot at exact maturity time
❌ Risk of delayed/missed snapshots
❌ Users must manually claim yield (poor UX)
❌ Gas costs for hundreds of individual claim transactions
❌ No guarantee of fair simultaneous distribution
With Chainlink Automation:
✅ Automatic snapshot trigger at maturity date
✅ Zero-touch for property owners
✅ Automatic yield delivery to all holders
✅ Single batch distribution (gas efficient)
✅ Guaranteed fair distribution
Architecture
How It Works
1. Upkeep Registration
When deploying AutoDistributor, we register an "Upkeep" with Chainlink:
Deployed Upkeep:
Network: Base Sepolia
Upkeep ID:
93020392068544314578722444806384967116734687134361189041908582162518677744524Status: ✅ Active
2. Continuous Monitoring (checkUpkeep)
Chainlink Keeper nodes call checkUpkeep() every block to check if work is needed:
What it checks:
Is period active?
Has maturity date been reached?
Is snapshot not taken yet?
Has yield been deposited?
If ALL conditions true → upkeepNeeded = true
3. Automatic Execution (performUpkeep)
When upkeepNeeded = true, Chainlink calls performUpkeep():
What happens:
Decodes
seriesIdandperiodIdfromperformDataValidates conditions
Calls
factory.triggerSnapshotForPeriod()Snapshot taken automatically! 📸
4. Manual Distribution (After Snapshot)
After snapshot, property owner calls distributeToAllHolders():
Result: USDC sent to all holders automatically!
Complete Flow Example
Timeline: Period 1 (90 Days)
Gas Costs & Economics
Upkeep Funding
Chainlink Automation requires LINK token funding:
Extremely cost-effective compared to manual operations!
Distribution Gas Costs
Batch distribution saves 3x gas!
Monitoring & Debugging
Check Upkeep Status
Get Pending Distributions
Check Distribution Status
Advanced Features
Batch Distribution
For large holder counts, distribute in batches to avoid gas limits:
Usage:
Manual Single Holder Distribution
For edge cases, distribute to single holder:
Security & Access Control
Roles
Deployed Roles:
DEFAULT_ADMIN_ROLE:
0x77c4a1cD22005b67Eb9CcEaE7E9577188d7Bca82(Deployer)MANAGER_ROLE:
0x77c4a1cD22005b67Eb9CcEaE7E9577188d7Bca82(Deployer)
Chainlink Permissions
Important: performUpkeep() can be called by anyone!
This is intentional - Chainlink Keepers are permissionless. However:
Function only succeeds if conditions met
Cannot manipulate snapshot (atomically recorded)
Cannot steal funds (distribution to snapshot holders only)
Why it's safe:
Troubleshooting
Problem: Snapshot Not Triggered
Possible causes:
Maturity date not reached
Yield not deposited
Snapshot already taken
Period inactive
Upkeep unfunded
Check LINK balance: Chainlink Automation App →
Add LINK if balance low
Problem: Distribution Failed
Possible causes:
Snapshot not taken
Insufficient yield balance
Gas limit exceeded (too many holders)
Solution: Use
batchDistribute()instead
Best Practices
For Property Owners
Deposit yield 1-2 days before maturity
Monitor Chainlink Upkeep
Check dashboard: https://automation.chain.link/base-sepolia
Ensure LINK balance > 5 LINK
Top up if needed
Call distributeToAllHolders() soon after snapshot
For Developers
Listen to events
Implement retry logic
Related Documentation
Snapshot System - How snapshots work
YRT Factory Overview - Multi-period system
Property Onboarding - Period management
Glossary - Term definitions
Key Takeaways:
Chainlink Automation provides zero-touch snapshot triggering
checkUpkeep() monitors all periods continuously
performUpkeep() triggers snapshot at maturity automatically
distributeToAllHolders() sends yield to all snapshot holders
Cost-effective: ~$2.40/year for automated operations
Deployed Contracts:
AutoDistributor:
0x8C9edAB077038B4f2e74d79663d79f3fc12Ca945Upkeep ID:
93020392068544314578722444806384967116734687134361189041908582162518677744524Network: Base Sepolia
Last Updated: october 2025
Last updated
