Skip to content

saai07/risk-score

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Compound Wallet Risk Scoring (DeFi)

This project calculates a risk score (0–1000) for each Ethereum wallet address based on its on-chain behavior within the Compound V2/V3 protocolo. The goal is to identify wallets that present high default or liquidation risk based on real transactional data.


🚀 How It Works

For every wallet:

  1. Fetches transaction history via the Etherscan API
  2. Filters interactions with Compound protocol contracts
  3. Extracts and classifies borrow/supply/liquidation/repay activity
  4. Computes a risk score using weighted, non-linear logic

Input & Output

Input

  • wallet id.xlsx
    Must contain a column with wallet addresses.

Output

  • risk_scores.csv
    Format:

    wallet_id score
    0xfaa0...ef2 200

⚙️ Setup & Usage

pip install pandas requests openpyxl

# Set your Etherscan API key in api.py or directly in the script
python score_wallets.py

Risk Scoring Logic Explained

Data Collection Method

  • Transactions are retrieved using the Etherscan API:
    module=account&action=txlist&address=<wallet>
    
  • Filtered only for transactions involving known Compound V2/V3 contracts.

Feature Selection Rationale

Feature Description Why It Matters
liquidations Number of times wallet was liquidated Reflects history of default
utilization ratio Borrowed / Supplied Measures how leveraged the wallet is
repayment ratio Total repaid / borrowed Indicates financial responsibility
inactivity Days since last tx Stale accounts with debt = hidden risk
borrow frequency # borrows vs repays Repeated borrowing = riskier
no-collateral borrow Borrowing without supplying Exposes the protocol to full loss

Scoring Method

Wallets start with a base score of 100, and are penalized based on the following:

Component Max Penalty Notes
Liquidation Risk 700 Exponential: 3+ liquidations = major penalty
Utilization Risk 200 Risk increases with higher leverage
Repayment Behavior 200 Less repayment = more risk
Inactivity 150 More days idle = more risk
Borrow Frequency 100 More borrows vs repays = more risk
No Collateral 100 Borrowing without supply = full penalty

Total score capped at 1000.


Justification of Risk Indicators

  • Liquidation is a direct sign of poor debt management.
  • Borrowing without repayment is a strong default risk flag.
  • High leverage (utilization ratio) leaves no margin for volatility.
  • Inactivity makes wallets blind to liquidation risks.
  • Collateral-free borrowing is highly abnormal and dangerous.

This framework is:

  • Transparent and interpretable
  • Protocol-aware
  • Scalable to other protocols like Aave or Maker

Sample Risk Score

0xfaa0768bde629806739c3a4620656c5d26f44ef2 → Score: 732

  • 2 liquidations
  • High utilization (91%)
  • Repayment ratio: 0.3
  • Last activity: 220 days ago

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages