Overview
Using raw transaction-level data from lending platforms on the blockchain, I:
- Engineered meaningful behavioral features for each wallet
- Normalized these features
- Scored wallets using a heuristic-based approach
- Output scores and analyze behavior patterns
Methodology
I used heuristic scoring based on engineered behavioral features. Each wallet is scored between 0 and 1000 based on how reliably and responsibly it interacted with the lending protocol.
Processing Flow
- Load & Parse: Read the raw transaction JSON file, convert timestamps, and extract the action and amount fields.
- Group by Wallet: Aggregate transactions by
userWalletto compute wallet-level features. - Feature Engineering: Extract behavioral metrics such as number of deposits, borrowing behavior, liquidations, action diversity, etc.
- Normalize Features: Apply MinMaxScaler to ensure features are on the same scale.
- Score Computation: Multiply normalized features by defined weights and scale to range [0, 1000].
- Export Results: Save credit scores as a CSV and generate a score distribution plot.
Features Engineered
repay_ratio: total repaid / total borrowedborrow_to_deposit_ratio: leverage measurenum_liquidations: penalizes risky usersavg_time_between_actions: irregularity suggests organic usedistinct_days_active: higher = long-term useraction_entropy: measures diversity of actions
These are engineered by grouping the transaction data per wallet and calculating metrics that indicate responsible DeFi behavior
Technologies Used
- Python: as the programming language.
- Pandas: to extract the raw JSON data and access it when needed.
- NumPy: to define heuristic weights
- Scikit-learn: to normalize, apply weighted scores and scale to the 0-1000 range.
- Matplotlib: to plot the histogram bar chart.
- ChatGPT: as my coding companion.
Outcome
- A CSV file with all the credit scores
- And a histogram plot showing the distribution of scores across all wallets.