> ## 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.

# DeFi Integration

> Integrate ZKScore with DeFi protocols and applications

## Overview

Integrate ZKScore into DeFi applications to enable reputation-based lending, liquidity provision rewards, and protocol-specific achievements.

## Use Cases

### Reputation-Based Lending

Use ZKScore to offer better rates to high-reputation users:

<CodeGroup>
  ```javascript JavaScript theme={null}
  async function calculateLendingRate(borrower) {
    const score = await zkScore.getScore(borrower);
    const baseRate = 5.0; // 5% base APR
    
    // Better rates for higher scores
    if (score.total >= 800) return baseRate * 0.7; // 30% discount
    if (score.total >= 600) return baseRate * 0.85; // 15% discount
    if (score.total >= 400) return baseRate * 0.95; // 5% discount
    
    return baseRate;
  }
  ```

  ```python Python theme={null}
  async def calculate_lending_rate(borrower: str) -> float:
      score = await zk_score.get_score(borrower)
      base_rate = 5.0  # 5% base APR
      
      if score['total'] >= 800:
          return base_rate * 0.7  # 30% discount
      elif score['total'] >= 600:
          return base_rate * 0.85  # 15% discount
      elif score['total'] >= 400:
          return base_rate * 0.95  # 5% discount
      
      return base_rate
  ```
</CodeGroup>

### Liquidity Mining Rewards

Reward liquidity providers based on reputation:

<CodeGroup>
  ```javascript JavaScript theme={null}
  async function calculateRewards(provider, liquidityAmount) {
    const score = await zkScore.getScore(provider);
    const breakdown = await zkScore.getScoreBreakdown(provider);
    
    const baseReward = liquidityAmount * 0.05; // 5% base APY
    const defiBonus = breakdown.defi / 1000; // Up to 100% bonus
    
    return baseReward * (1 + defiBonus);
  }
  ```
</CodeGroup>

## Best Practices

1. **Fair Tiering**: Create reasonable score tiers
2. **Gradual Benefits**: Provide incremental benefits
3. **Clear Communication**: Explain score requirements
4. **Regular Updates**: Sync scores frequently
5. **Fallback Options**: Support users without ZKScore

## Related Documentation

* [Score Calculator](/contracts/score-calculator/overview)
* [Trust Gating](/guides/trust-gating)
* [DeFi Use Case](/use-cases/lending)
