Documentation Index
Fetch the complete documentation index at: https://core.anylayer.org/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This example demonstrates how to integrate ZKScore contracts with a DeFi protocol to track user activity, calculate DeFi scores, and reward protocol participation.
DeFi Integration Example
class DeFiProtocolIntegration {
constructor(protocolContract, zkScoreContracts) {
this.protocol = protocolContract;
this.zkScore = zkScoreContracts;
}
async trackLiquidityProvision(user, amount) {
// Update protocol activity
await this.protocol.provideLiquidity(user, amount);
// Update ZKScore
await this.zkScore.scoreCalculator.updateCategoryScore(user, 0, amount / 1000);
// Check achievements
const liquidityAchievements = [100, 101, 102]; // Different tiers
for (const id of liquidityAchievements) {
const canClaim = await this.zkScore.achievementRegistry.canClaim(user, id);
if (canClaim) {
await this.zkScore.achievementRegistry.claimAchievement(id, '0x');
}
}
}
}
Best Practices
- Real-time Updates: Update scores as activities occur
- Achievement Tracking: Auto-claim eligible achievements
- Event Integration: Sync protocol events with ZKScore
- Gas Optimization: Batch updates when possible