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.
For every wallet:
- Fetches transaction history via the Etherscan API
- Filters interactions with Compound protocol contracts
- Extracts and classifies borrow/supply/liquidation/repay activity
- Computes a risk score using weighted, non-linear logic
wallet id.xlsx
Must contain a column with wallet addresses.
-
risk_scores.csv
Format:wallet_id score 0xfaa0...ef2 200
pip install pandas requests openpyxl
# Set your Etherscan API key in api.py or directly in the script
python score_wallets.py
- Transactions are retrieved using the Etherscan API:
module=account&action=txlist&address=<wallet>
- Filtered only for transactions involving known Compound V2/V3 contracts.
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 |
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.
- 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
0xfaa0768bde629806739c3a4620656c5d26f44ef2 → Score: 732
- 2 liquidations
- High utilization (91%)
- Repayment ratio: 0.3
- Last activity: 220 days ago