mriusero commited on
Commit
03d9ec3
·
verified ·
1 Parent(s): 7091f36

Improve Readme

Browse files
Files changed (1) hide show
  1. README.md +114 -354
README.md CHANGED
@@ -5,392 +5,152 @@ tags:
5
  size_categories:
6
  - 1M<n<10M
7
  ---
8
- This dataset include several steps involved in preparing the dataset for analyzing decentralized finance (DeFi) protocols and transactions.
9
- The process to build it includes selecting DeFi protocols, extracting relevant contract data, collecting transaction information, and analyzing market trends.
10
- The dataset enables a comprehensive analysis of user behavior, protocol usage, transaction dynamics, and market performance on ethereum blockchain.
11
 
12
  ---
13
- ## Data
14
- ```
15
- ├── protocols.parquet # Contains protocols details for selected DeFi protocols.
16
  ├── contracts.parquet # Contains contract details for selected DeFi protocols.
17
  ├── transactions.parquet # Contains transaction data for Ethereum-based contracts.
18
  ├── market.parquet # Contains enriched market data with aggregated transaction metrics.
19
  └── users.parquet # User profiles based on transaction data.
20
- ```
21
 
22
- ## Table of Contents
23
- 1. [Selection of DeFi Protocols](#1-selection-of-defi-protocols)
24
- 2. [Collection of Contract Data for Selected DeFi Protocols *(CoinGecko API)*](#2-collection-of-contract-data-for-selected-defi-protocols-coingecko-api)
25
- 3. [Collection of Transactions for Ethereum-Based Contracts *(Etherscan API)*](#3-collection-of-transactions-for-ethereum-based-contracts-etherscan-api)
26
- 4. [Generation of User Profiles Based on Transaction Data](#4-generation-of-user-profiles-based-on-transaction-data)
27
- 5. [Collection of Market OHLC Data for Tokens *(YahooFinance API)*](#5-collection-of-market-ohlc-data-for-tokens-yahoofinance-api)
28
- 6. [Enrichment of Market Data via Transaction Aggregation](#6-enrichment-of-market-data-via-transaction-aggregation)
29
- ---
30
- ## 1. Selection of DeFi Protocols
31
- In this first step, we select multiple DeFi protocols that represent different categories of financial services in the decentralized ecosystem. This includes protocols for decentralized exchanges (DEX), lending platforms, stablecoins, and NFT-based finance.
32
-
33
- ### Protocols type: `('DEX': 3, 'Lending': 2, 'Yield Farming': 2, 'Stablecoin': 3, 'NFT-Fi': 1)`
34
 
35
- ```python
36
- KEY_PROTOCOLS = [
37
- "uniswap", # DEX
38
- "curve-dao-token", # DEX
39
- "balancer", # DEX
40
- "aave", # Lending
41
- "maker", # Lending
42
- "yearn-finance", # Yield Farming
43
- "harvest-finance", # Yield Farming
44
- "dai", # Stablecoin
45
- "usd-coin", # Stablecoin
46
- "tether", # Stablecoin
47
- "nftfi", # NFT-Fi (optionnel)
48
- ]
49
- ```
50
- ### Objective
51
- To define a set of popular and diverse DeFi protocols that will serve as the basis for data collection and analysis.
52
 
53
  ---
54
- ## 2. Collection of Contract Data for Selected DeFi Protocols *(CoinGecko API)*
55
- ### Collection name: `protocols` - *(11 documents)*
56
- For each selected protocol, we extract contract information from *CoinGecko’s API*. This data contains the contract addresses on the blockchain, the type of protocol, and additional details like market capitalization rank and protocol description.
57
 
58
- ### Fields
59
- #### 1. `_id` *(ObjectId)* - The unique identifier for this document in the database.
60
- #### 2. `protocol_id` *(String)* - A unique identifier for the protocol (in this case, for Uniswap).
61
- #### 3. `blockchain_contracts` *(Array of Objects)* - Contains a list of blockchain contracts associated with the asset.
62
- - `blockchain` *(String)* - The name of the blockchain.
63
- - `contract` *(String)* - The address of the protocol contract on the blockchain.
64
- #### 4. `description` *(String)* - A brief description of the protocol.
65
- #### 5. `market_cap_rank` *(Integer)* - The rank of the protocol based on market capitalization.
66
- #### 6. `name` *(String)* - The name of the protocol.
67
- #### 7. `symbol` *(String)* - The symbol of the protocol.
68
- #### 8. `type` *(String)* - The type of protocol (e.g., DEX, Lending).
69
- #### 9. `website_url` *(String)* - The URL of the protocol's official website.
70
 
71
- ### Exemple
72
- ```json
73
- {
74
- "_id": {
75
- "$oid": "678a6dbb7824a40cf5948a3a"
76
- },
77
- "protocol_id": "a32977262a1f49ca460aa0f158e86b03",
78
- "blockchain_contracts": [
79
- {
80
- "blockchain": "ethereum",
81
- "contract": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"
82
- }
83
- ],
84
- "description": "UNI is the governance token for Uniswap, an Automated Market Marker DEX on the Ethereum blockchain. The UNI token allows token holders to participate in the governance of the protocol. Key decisions such as usage of the treasury or future upgrades ca",
85
- "market_cap_rank": 26,
86
- "name": "Uniswap",
87
- "symbol": "uni",
88
- "type": "DEX",
89
- "website_url": "https://uniswap.org/"
90
- }
91
- ```
92
- ### Objective
93
- To retrieve the smart contract details associated with each protocol, enabling further analysis of transactions and interactions with the protocol on the blockchain.
94
 
95
  ---
96
- ## 3. Collection of Transactions for Ethereum-Based Contracts *(Etherscan API)*
97
- ### Collection name: `transactions` - *(22 682 739 documents)*
98
- We use an API such as Etherscan to gather transaction data related to the selected Ethereum-based contracts. The data includes transaction hashes, sender and receiver addresses, gas usage, and transaction values.
99
 
100
- #### Timeframe:
101
- * Start: `2022-12-31T22:59:59.000Z`
102
- * End: `2024-12-30T23:00:11.000Z`
 
 
103
 
104
- ### Fields
105
- #### 1. `_id` *(ObjectId)* - The unique identifier for this document in the database.
106
- #### 2. `transaction_hash` *(String)* - The hash of the transaction.
107
- #### 3. `error_code` *(String)* - The error code for the transaction, if any.
108
- #### 4. `from` *(String)* - The address of the sender.
109
- #### 5. `gas` *(Integer)* - The amount of gas proposed for the transaction.
110
- #### 6. `gas_used` *(Integer)* - The amount of gas actually used in the transaction.
111
- #### 7. `is_error` *(String)* - Indicates if there was an error during the transaction ("0" for no error, "1" for error).
112
- #### 8. `metadata` *(Object)* - Contains additional details about the protocol.
113
- - `protocol_name` *(String)* - The name of the protocol associated with the transaction.
114
- - `type` *(String)* - The type of the protocol (e.g., DEX, Lending).
115
- - `blockchain` *(String)* - The name of the blockchain (in this case, Ethereum).
116
- - `contract_id` *(String)* - The unique identifier of the contract involved in the transaction.
117
- #### 9. `timestamp` *(Date)* - The timestamp when the transaction occurred.
118
- #### 10. `to` *(String)* - The address of the recipient.
119
- #### 11. `trace_id` *(String)* - The trace identifier for tracking the transaction.
120
- #### 12. `tx_hash` *(String)* - A duplicate of the `transaction_hash` field.
121
- #### 13. `value (ETH)` *(Float)* - The amount of ETH transferred in the transaction.
122
 
123
- ### Example
124
- ```json
125
- {
126
- "_id": {
127
- "$oid": "678bf7cf9ebf7cf7c1a3a88e"
128
- },
129
- "transaction_hash": "0x50edd2873907a3454a9c8cc8d242b6d0e365ec71263e4fb8cb9e935e151fcbaa",
130
- "error_code": "",
131
- "from": "0xbe6e45661c633fd1a1825389dec680e62c1c7d51",
132
- "gas": 57218,
133
- "gas_used": 52418,
134
- "is_error": "0",
135
- "metadata": {
136
- "protocol_name": "Uniswap",
137
- "type": "DEX",
138
- "blockchain": "ethereum",
139
- "contract_id": "c944b5855a3b2d8cbe4367a3f7561854"
140
- },
141
- "timestamp": {
142
- "$date": "2023-12-31T23:00:23.000Z"
143
- },
144
- "to": "0x0231b537b8f1c46b6cb4f7d9ec6d56951a66ff41",
145
- "trace_id": "",
146
- "tx_hash": "0x50edd2873907a3454a9c8cc8d242b6d0e365ec71263e4fb8cb9e935e151fcbaa",
147
- "value (ETH)": 12.201526377331376
148
- }
149
- ```
150
- ### Objective
151
- To collect transaction data associated with the Ethereum smart contracts, allowing for an analysis of activity, user behavior, and protocol usage over time.
152
 
153
  ---
154
- ## 4. Generation of User Profiles Based on Transaction Data
155
- ### Collection name: `users` - *(6 876 845 documents)*
156
- By analyzing transaction data, we identify and create user profiles based on the Ethereum addresses involved in transactions. This step allows for tracking users’ activities across different protocols and their total received and sent amounts.
157
 
158
- ### Fields
159
- #### 1. `_id` *(ObjectId)* - The unique identifier for this document in the database.
160
- #### 2. `address` *(String)* - The Ethereum address of the user.
161
- #### 3. `first_seen` *(Date)* - The timestamp when the address was first observed in the dataset.
162
- #### 4. `last_seen` *(Date)* - The timestamp when the address was last observed in the dataset.
163
- #### 5. `protocol_types` *(Object)* - A count of the types of protocols the user has interacted with, grouped by protocol type (e.g., DEX, Lending).
164
- #### 6. `protocols_used` *(Object)* - A breakdown of protocols the user interacted with, containing:
165
- - **Protocol name** *(String)* - The name of the protocol (e.g., Curve DAO, Aave).
166
- - `count` *(Integer)* - The number of interactions with the protocol.
167
- - `blockchain` *(String)* - The blockchain on which the protocol operates.
168
- - `contract_id` *(String)* - The unique identifier of the protocol's contract.
169
- #### 7. `received_count` *(Integer)* - The number of transactions in which the user received assets.
170
- #### 8. `sent_count` *(Integer)* - The number of transactions in which the user sent assets.
171
- #### 9. `total_received (ETH)` *(Float)* - The total amount of ETH received by the user.
172
- #### 10. `total_sent (ETH)` *(Float)* - The total amount of ETH sent by the user.
173
- #### 11. `transactions` *(Array of Objects)* - Details of individual transactions involving the user.
174
- - `transaction_hash` *(String)* - The hash of the transaction.
175
- - `timestamp` *(Date)* - The timestamp of the transaction.
176
- - `value (ETH)` *(Float)* - The amount of ETH transferred in the transaction.
177
- - `is_sender` *(Boolean)* - Indicates whether the user was the sender in the transaction.
178
- - `gas_used` *(Integer)* - The amount of gas used in the transaction.
179
- - `protocol_name` *(String)* - The name of the protocol associated with the transaction.
180
- - `protocol_type` *(String)* - The type of protocol (e.g., DEX, Lending).
181
- - `blockchain` *(String)* - The name of the blockchain (e.g., Ethereum).
182
- - `contract_id` *(String)* - The unique identifier of the protocol's contract involved in the transaction.
183
 
184
- ### Example
185
- ```json
186
- {
187
- "_id": {
188
- "$oid": "678cf88798ededf702ec1766"
189
- },
190
- "address": "0x2deacac3a34ace696d3fe214a07882949311e81b",
191
- "first_seen": {
192
- "$date": "2023-01-07T22:05:35.000Z"
193
- },
194
- "last_seen": {
195
- "$date": "2023-01-21T12:46:35.000Z"
196
- },
197
- "protocol_types": {
198
- "DEX": 1,
199
- "Lending": 1
200
- },
201
- "protocols_used": {
202
- "Curve DAO": {
203
- "count": 1,
204
- "blockchain": "ethereum",
205
- "contract_id": "6c78ebb89739952c2d1b03a051f79287"
206
- },
207
- "Aave": {
208
- "count": 1,
209
- "blockchain": "ethereum",
210
- "contract_id": "e82fc843c812403d08dca5ab89b772d5"
211
- }
212
- },
213
- "received_count": 2,
214
- "sent_count": 0,
215
- "total_received (ETH)": 23.00372511606387,
216
- "total_sent (ETH)": 0,
217
- "transactions": [
218
- {
219
- "transaction_hash": "0x7de2510bd9efdb0fcbb358aac92473361026ad6cc8a49cbfcef5d88856eb1fe5",
220
- "timestamp": {
221
- "$date": "2023-01-07T22:05:35.000Z"
222
- },
223
- "value (ETH)": 23,
224
- "is_sender": false,
225
- "gas_used": 34225,
226
- "protocol_name": "Curve DAO",
227
- "protocol_type": "DEX",
228
- "blockchain": "ethereum",
229
- "contract_id": "6c78ebb89739952c2d1b03a051f79287"
230
- },
231
- {
232
- "transaction_hash": "0xb355bdf9cf819810d09ed6041358d3dd4bfc45b0a55ea9555b5e8360f68c3a98",
233
- "timestamp": {
234
- "$date": "2023-01-21T12:46:35.000Z"
235
- },
236
- "value (ETH)": 0.003725116063867235,
237
- "is_sender": false,
238
- "gas_used": 237828,
239
- "protocol_name": "Aave",
240
- "protocol_type": "Lending",
241
- "blockchain": "ethereum",
242
- "contract_id": "e82fc843c812403d08dca5ab89b772d5"
243
- }
244
- ]
245
- }
246
- ```
247
- ### Objective
248
- To track user behavior across different DeFi protocols, focusing on received and sent transaction counts and totals. This will help in understanding user engagement with various protocols.
249
 
250
  ---
251
- ## 5. Collection of Market OHLC Data for Tokens *(YahooFinance API)*
252
- ### Collection name: `market` - *(177 955 documents)*
253
- We then enrich the transaction data by extracting market data for the associated tokens using sources like YahooFinance API. This includes Open, High, Low, and Close (OHLC) values for the token in USD.
254
 
255
- ### Fields
256
- #### 1. `_id` *(ObjectId)* - The unique identifier for this document in the database.
257
- #### 2. `timestamp` *(Date)* - The date and time when the market data was recorded.
258
- #### 3. `contract_address` *(String)* - The address of the token contract associated with the market data.
259
- #### 4. `symbol` *(String)* - The symbol of the token (e.g., UNI for Uniswap).
260
- #### 5. `blockchain` *(String)* - The blockchain where the token operates (e.g., Ethereum).
261
- #### 6. `close (usd)` *(Float)* - The closing price of the token in USD for the specified timestamp.
262
- #### 7. `high (usd)` *(Float)* - The highest price of the token in USD during the specified period.
263
- #### 8. `low (usd)` *(Float)* - The lowest price of the token in USD during the specified period.
264
- #### 9. `open (usd)` *(Float)* - The opening price of the token in USD for the specified timestamp.
265
- #### 10. `protocol_name` *(String)* - The name of the protocol associated with the token (e.g., Uniswap).
266
- #### 11. `type` *(String)* - The type of the protocol (e.g., DEX, Lending).
267
- #### 12. `volume` *(Float)* - The trading volume for the token during the specified period.
268
 
269
- ### Example
270
- ```json
271
- {
272
- "_id": {
273
- "$oid": "678e7d11a552daf8aeb188c3"
274
- },
275
- "timestamp": {
276
- "$date": "2023-01-22T00:00:00.000Z"
277
- },
278
- "contract_address": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
279
- "symbol": "uni",
280
- "blockchain": "ethereum",
281
- "close (usd)": 0.0002288398682139814,
282
- "high (usd)": 0.00022923298820387572,
283
- "low (usd)": 0.00022784991597291082,
284
- "open (usd)": 0.00022784991597291082,
285
- "protocol_name": "Uniswap",
286
- "type": "DEX",
287
- "volume": 0
288
- }
289
- ```
290
- ### Objective
291
- To integrate market data into the transaction dataset, enabling the analysis of token price movements and their correlation with transaction activity over time.
292
 
293
  ---
294
- ## 6. Enrichment of Market Data via Transaction Aggregation
295
- ### Collection name: `market_enriched` - *(177 955 documents)*
296
- We aggregate transaction data to calculate key metrics like average gas used, transaction value, and unique participants over specified time frames. This enriched data allows for better insights into transaction trends and protocol usage.
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
- ### Fields
299
- #### 1. `_id` *(ObjectId)* - The unique identifier for this document in the database.
300
- #### 2. `avg_gas_used` *(Float)* - The average gas used in transactions over the last hour and 24 hours.
301
- #### 3. `avg_value_eth_per_tx` *(Float)* - The average transaction value in ETH over the last hour and 24 hours.
302
- #### 4. `blockchain` *(String)* - The blockchain where the protocol operates (e.g., Ethereum).
303
- #### 5. `close (usd)` *(Float)* - The closing price of the token in USD for the specified timestamp.
304
- #### 6. `contract_address` *(String)* - The address of the token contract associated with the data.
305
- #### 7. `error_rate` *(Float)* - The percentage of transactions with errors over the last hour and 24 hours.
306
- #### 8. `high (usd)` *(Float)* - The highest price of the token in USD during the specified period.
307
- #### 9. `low (usd)` *(Float)* - The lowest price of the token in USD during the specified period.
308
- #### 10. `max_gas_used` *(Integer)* - The maximum gas used in a transaction over the last hour and 24 hours.
309
- #### 11. `max_value_eth` *(Float)* - The maximum transaction value in ETH over the last hour and 24 hours.
310
- #### 12. `median_value_eth` *(Float)* - The median transaction value in ETH over the last hour and 24 hours.
311
- #### 13. `min_gas_used` *(Integer)* - The minimum gas used in a transaction over the last hour and 24 hours.
312
- #### 14. `min_value_eth` *(Float)* - The minimum transaction value in ETH over the last hour and 24 hours.
313
- #### 15. `nb_tx` *(Integer)* - The total number of transactions over the last hour and 24 hours.
314
- #### 16. `nb_unique_receivers` *(Integer)* - The number of unique receiver addresses over the last hour and 24 hours.
315
- #### 17. `nb_unique_senders` *(Integer)* - The number of unique sender addresses over the last hour and 24 hours.
316
- #### 18. `num_errors` *(Integer)* - The total number of transactions with errors over the last hour and 24 hours.
317
- #### 19. `open (usd)` *(Float)* - The opening price of the token in USD for the specified timestamp.
318
- #### 20. `protocol_name` *(String)* - The name of the protocol associated with the token.
319
- #### 21. `std_gas_used` *(Float)* - The standard deviation of gas used in transactions over the last hour and 24 hours.
320
- #### 22. `std_value_eth` *(Float)* - The standard deviation of transaction values in ETH over the last hour and 24 hours.
321
- #### 23. `symbol` *(String)* - The symbol of the token (e.g., NFTFI).
322
- #### 24. `timestamp` *(Date)* - The date and time of the aggregated data.
323
- #### 25. `total_gas_used` *(Integer)* - The total gas used in transactions over the last hour and 24 hours.
324
- #### 26. `total_value_eth` *(Float)* - The total transaction value in ETH over the last hour and 24 hours.
325
- #### 27. `type` *(String)* - The type of the protocol (e.g., NFT-Fi).
326
- #### 28. `volume` *(Float)* - The trading volume for the token during the specified period.
327
 
328
- ### Example
329
- ```json
330
- {
331
- "_id": {
332
- "$oid": "678e7d1ca552daf8aeb42f81"
333
- },
334
- "avg_gas_used_1h": 0,
335
- "avg_gas_used_24h": 88387.36363636363,
336
- "avg_value_eth_per_tx_1h": 0,
337
- "avg_value_eth_per_tx_24h": 98435.44979489372,
338
- "blockchain": "ethereum",
339
- "close (usd)": 0.0033522879239171743,
340
- "contract_address": "0x09d6f0f5a21f5be4f59e209747e2d07f50bc694c",
341
- "error_rate_1h": 0,
342
- "error_rate_24h": 0,
343
- "high (usd)": 0.003360767150297761,
344
- "low (usd)": 0.003341925796121359,
345
- "max_gas_used_1h": 0,
346
- "max_gas_used_24h": 128672,
347
- "max_value_eth_1h": 0,
348
- "max_value_eth_24h": 173027.368086,
349
- "median_value_eth_1h": 0,
350
- "median_value_eth_24h": 20308,
351
- "min_gas_used_1h": 0,
352
- "min_gas_used_24h": 46674,
353
- "min_value_eth_1h": 0,
354
- "min_value_eth_24h": 8627,
355
- "nb_tx_1h": 0,
356
- "nb_tx_24h": 11,
357
- "nb_unique_receivers_1h": 0,
358
- "nb_unique_receivers_24h": 6,
359
- "nb_unique_senders_1h": 0,
360
- "nb_unique_senders_24h": 6,
361
- "num_errors_1h": 0,
362
- "num_errors_24h": 0,
363
- "open (usd)": 0.003341925796121359,
364
- "protocol_name": "NFTFI",
365
- "std_gas_used_1h": 0,
366
- "std_gas_used_24h": 27197.175038036337,
367
- "std_value_eth_1h": 0,
368
- "std_value_eth_24h": 61448.22032504086,
369
- "symbol": "nftfi",
370
- "timestamp": {
371
- "$date": "2024-08-10T06:00:00.000Z"
372
- },
373
- "total_gas_used_1h": 0,
374
- "total_gas_used_24h": 972261,
375
- "total_value_eth_1h": 0,
376
- "total_value_eth_24h": 1082789.947743831,
377
- "type": "NFT-Fi",
378
- "volume": 0
379
- }
380
- ```
381
- ### Objective
382
- To aggregate transaction and market data into meaningful metrics that represent the overall health and activity of the protocols, facilitating trend analysis.
383
 
384
  ---
385
- ## Credits
386
- This dataset preparation process establishes the foundation for analysis of user behavior, market trends, and protocol performance within the DeFi space. Each step builds upon the previous one, ensuring that the final dataset is rich and well-structured for deeper insights. It includes various technical steps for data extraction, user profiling, and market data aggregation, based on a combination of APIs and data sources. Special thanks to the following sources and tools used in this process:
387
- 1. **CoinGecko API** - For contract data related to DeFi protocols and their market details.
388
- 2. **Etherscan API** - For transaction data extraction on Ethereum smart contracts.
389
- 3. **Yahoo Finance API** - For market data including OHLC values of tokens and trading volume.
390
- 4. **MongoDB** - For managing and storing large volumes of transaction and protocol data in a structured format.
391
- 5. **Ethereum Blockchain** - For the decentralized financial infrastructure that powers these protocols and transactions.
392
 
393
- Code is available on [GitHub](https://github.com/mriusero/defi-user-behavior-clustering).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
 
395
  ---
396
  license: mit
 
5
  size_categories:
6
  - 1M<n<10M
7
  ---
8
+
9
+ Decentralized finance (DeFi) has emerged as a significant sector within the blockchain and cryptocurrency space. DeFi protocols enable users to access financial services without traditional intermediaries, offering a wide range of applications such as lending, borrowing, trading, and yield farming. Understanding user behavior, protocol interactions, and market trends is crucial for analyzing the DeFi ecosystem's dynamics and identifying opportunities for innovation and growth.
 
10
 
11
  ---
12
+ # About Dataset
13
+ This dataset include several steps involved in preparing the dataset for analyzing decentralized finance (DeFi) protocols and transactions. The process to build it includes selecting DeFi protocols, extracting relevant contract data, collecting transaction information, and analyzing market trends. The dataset enables a comprehensive analysis of user behavior, protocol usage, transaction dynamics, and market performance on Ethereum blockchain.
14
+
15
  ├── contracts.parquet # Contains contract details for selected DeFi protocols.
16
  ├── transactions.parquet # Contains transaction data for Ethereum-based contracts.
17
  ├── market.parquet # Contains enriched market data with aggregated transaction metrics.
18
  └── users.parquet # User profiles based on transaction data.
 
19
 
20
+ Each file serves a distinct purpose in facilitating analysis of the DeFi ecosystem.
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ #### Timeframe:
23
+ * Start: `2022-12-31T22:59:59.000Z`
24
+ * End: `2024-12-30T23:00:11.000Z`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  ---
 
 
 
27
 
28
+ ## Objectives
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ ### `users.parquet`
31
+ This file focuses on user-level data and is aimed at answering questions related to user behavior, activity trends, and protocol interactions. Potential use cases include:
32
+ - Analyzing the lifecycle of user activity in DeFi.
33
+ - Identifying power users or dormant users.
34
+ - Mapping the interaction between users and various protocols.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  ---
 
 
 
37
 
38
+ ### `market.parquet`
39
+ This file aggregates market-related data over time intervals, offering insights into protocol performance and market dynamics. Objectives include:
40
+ - Understanding market trends across DeFi protocols and tokens.
41
+ - Analyzing trading volumes, transaction activity, and price fluctuations.
42
+ - Identifying periods of high or low activity for specific tokens or protocols.
43
 
44
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ ### `transactions.parquet`
47
+ This file provides granular transaction-level data, which is crucial for understanding the flow of assets within the DeFi ecosystem. Applications include:
48
+ - Tracing the movement of funds between addresses.
49
+ - Analyzing transaction costs (gas) and failure rates.
50
+ - Identifying anomalous or fraudulent transactions.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  ---
 
 
 
53
 
54
+ ### `contracts.parquet`
55
+ This file documents details about the smart contracts associated with various DeFi protocols. It supports:
56
+ - Categorizing contracts by protocol, type, and use case.
57
+ - Analyzing the adoption of specific contract standards (e.g., ERC-20, ERC-721).
58
+ - Exploring the relationship between contract attributes and protocol performance.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
+ ---
61
+ ## Conclusion
62
+ This dataset preparation process establishes the foundation for analysis of user behavior, market trends, and protocol performance within the DeFi space. Each step builds upon the previous one, ensuring that the final dataset is rich and well-structured for deeper insights. It includes various technical steps for data extraction, user profiling, and market data aggregation, based on a combination of APIs and data sources.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  ---
65
+ ## Source
 
 
66
 
67
+ Tools used in this process:
68
+ 1. **CoinGecko API** - For contract data related to DeFi protocols and their market details.
69
+ 2. **Etherscan API** - For transaction data extraction on Ethereum smart contracts.
70
+ 3. **Yahoo Finance API** - For market data including OHLC values of tokens and trading volume.
71
+ 4. **MongoDB** - For managing and storing large volumes of transaction and protocol data in a structured format.
72
+ 5. **Ethereum Blockchain** - For the decentralized financial infrastructure that powers these protocols and transactions.
 
 
 
 
 
 
 
73
 
74
+ Code is available on [GitHub](https://github.com/mriusero/defi-user-behavior-clustering) and the ETL process is explained [here](https://github.com/mriusero/defi-user-behavior-clustering/blob/main/docs/etl_pipeline_flow.md).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ---
77
+ # Variables Descriptions
78
+
79
+ ## `users.parquet`
80
+ This dataset contains information about user activities and transactions. The variables are:
81
+
82
+ - **`address`** *(string)*: The wallet address of the user.
83
+ - **`first_seen`** *(datetime)*: The first recorded activity of the user.
84
+ - **`last_seen`** *(datetime)*: The most recent activity of the user.
85
+ - **`protocol_types`** *(list/string)*: Types of protocols the user interacted with.
86
+ - **`protocols_used`** *(list/string)*: Specific protocols the user interacted with.
87
+ - **`received_count`** *(integer)*: The total number of transactions received by the user.
88
+ - **`total_received (ETH)`** *(float)*: The total amount of ETH received by the user.
89
+ - **`sent_count`** *(integer)*: The total number of transactions sent by the user.
90
+ - **`total_sent (ETH)`** *(float)*: The total amount of ETH sent by the user.
91
+ - **`transactions`** *(integer)*: The total number of transactions the user participated in.
92
 
93
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
+ ## `market.parquet`
96
+ This dataset contains market-related data aggregated over specific time intervals. The variables are:
97
+
98
+ - **`timestamp`** *(datetime)*: The time when the data was recorded.
99
+ - **`blockchain`** *(string)*: The blockchain network (e.g., Ethereum, Binance Smart Chain).
100
+ - **`protocol_name`** *(string)*: The name of the protocol associated with the data.
101
+ - **`symbol`** *(string)*: The symbol of the cryptocurrency or token.
102
+ - **`type`** *(string)*: The type of asset (e.g., token, NFT).
103
+ - **`contract_address`** *(string)*: The contract address associated with the asset.
104
+ - **`open (usd)`** *(float)*: The opening price in USD during the interval.
105
+ - **`high (usd)`** *(float)*: The highest price in USD during the interval.
106
+ - **`low (usd)`** *(float)*: The lowest price in USD during the interval.
107
+ - **`close (usd)`** *(float)*: The closing price in USD during the interval.
108
+ - **`volume`** *(float)*: The total trading volume during the interval.
109
+ - **`nb_tx_1h`**, **`nb_tx_24h`** *(integer)*: The number of transactions in the last 1 hour and 24 hours, respectively.
110
+ - **`total_value_eth_1h`**, **`total_value_eth_24h`** *(float)*: The total value transferred in ETH in the last 1 hour and 24 hours.
111
+ - **`total_gas_used_1h`**, **`total_gas_used_24h`** *(float)*: The total gas used in the last 1 hour and 24 hours.
112
+ - **`nb_unique_receivers_1h`**, **`nb_unique_receivers_24h`** *(integer)*: The number of unique receiving addresses in the last 1 hour and 24 hours.
113
+ - **`nb_unique_senders_1h`**, **`nb_unique_senders_24h`** *(integer)*: The number of unique sending addresses in the last 1 hour and 24 hours.
114
+ - **`std_value_eth_1h`**, **`std_value_eth_24h`** *(float)*: The standard deviation of transaction values in ETH in the last 1 hour and 24 hours.
115
+ - **`std_gas_used_1h`**, **`std_gas_used_24h`** *(float)*: The standard deviation of gas used in the last 1 hour and 24 hours.
116
+ - **`avg_gas_used_1h`**, **`avg_gas_used_24h`** *(float)*: The average gas used in the last 1 hour and 24 hours.
117
+ - **`avg_value_eth_per_tx_1h`**, **`avg_value_eth_per_tx_24h`** *(float)*: The average ETH value per transaction in the last 1 hour and 24 hours.
118
+ - **`max_gas_used_1h`**, **`max_gas_used_24h`** *(float)*: The maximum gas used in the last 1 hour and 24 hours.
119
+ - **`max_value_eth_1h`**, **`max_value_eth_24h`** *(float)*: The maximum ETH value transferred in the last 1 hour and 24 hours.
120
+ - **`median_value_eth_1h`**, **`median_value_eth_24h`** *(float)*: The median transaction value in ETH in the last 1 hour and 24 hours.
121
+ - **`min_gas_used_1h`**, **`min_gas_used_24h`** *(float)*: The minimum gas used in the last 1 hour and 24 hours.
122
+ - **`min_value_eth_1h`**, **`min_value_eth_24h`** *(float)*: The minimum ETH value transferred in the last 1 hour and 24 hours.
123
+ - **`num_errors_1h`**, **`num_errors_24h`** *(integer)*: The number of errors in the last 1 hour and 24 hours.
124
+ - **`error_rate_1h`**, **`error_rate_24h`** *(float)*: The rate of errors in the last 1 hour and 24 hours.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
  ---
 
 
 
 
 
 
 
127
 
128
+ ## `transactions.parquet`
129
+ This dataset contains individual transaction-level data. The variables are:
130
+
131
+ - **`timestamp`** *(datetime)*: The time when the transaction occurred.
132
+ - **`transaction_hash`** *(string)*: The unique hash identifying the transaction.
133
+ - **`from`** *(string)*: The sender's wallet address.
134
+ - **`to`** *(string)*: The receiver's wallet address.
135
+ - **`value (ETH)`** *(float)*: The value transferred in ETH.
136
+ - **`gas`** *(integer)*: The gas limit specified for the transaction.
137
+ - **`gas_used`** *(integer)*: The actual gas used by the transaction.
138
+ - **`is_error`** *(boolean)*: Indicates if the transaction resulted in an error.
139
+ - **`error_code`** *(string)*: The error code, if applicable.
140
+ - **`metadata`** *(json/object)*: Additional metadata related to the transaction.
141
+
142
+ ---
143
+
144
+ ## `contracts.parquet`
145
+ This dataset contains information about blockchain contracts. The variables are:
146
+
147
+ - **`contract_address`** *(string)*: The unique address of the smart contract.
148
+ - **`blockchain`** *(string)*: The blockchain network where the contract is deployed.
149
+ - **`type`** *(string)*: The type of contract (e.g., ERC-20, ERC-721).
150
+ - **`protocol_name`** *(string)*: The name of the protocol the contract belongs to.
151
+ - **`protocol_symbol`** *(string)*: The symbol of the protocol or token.
152
+ - **`description`** *(string)*: A description of the contract's purpose or functionality.
153
+ - **`website_url`** *(string)*: The URL of the contract or protocol's official website.
154
 
155
  ---
156
  license: mit