💡Inspiration

In centralised financial (CeFi) system, we are concerned about our credit scores, because this score helps us to secure loans, credit cards, and other related banking products. Credit score is the main benchmark a bank used to determine how good an user Is in managing his financial. Based on the score, the bank can then determine the user’s credit limit. Sometimes, the credit limit could be raised based on human-factors, such as proven financial growth or reputation. There are several agencies in Malaysia, such as CTOS, provide credit scoring services.

Now, going back in DeFi lending, we observed that it has become increasingly popular in recent years due to their accessibility and flexibility, but they also come with inherent risks, including the potential for defaults and fraud. The identified problems are as follows:

  1. High risk of fraud: DeFi loans are highly vulnerable to fraudulent activities, such as fake collateral, false identities, and fake token values. Without proper identity verification and KYC (know your customer) procedures, it can be challenging to prevent fraud and protect the interests of lenders.
  2. High collateral amount: Today, most DeFi loan requires around 150% of collateral, which scares potential borrowers away.
  3. Limited credit scoring: DeFi loans often rely on collateralized lending, which means that the loan is secured by the borrower's cryptocurrency holdings. However, this may not provide a complete picture of the borrower's creditworthiness, making it challenging to assess the risk associated with lending to them.
  4. Lack of personalised loan offering: “reputation”or “trust”-based are widely unavailable in DeFi loans. Therefore, borrowers today do not prefer DeFi lending since it is less attractive compared to TradFi lending.
  5. Lack of liquidity: DeFi loans may face liquidity issues, especially during times of market stress, which can make it challenging for borrowers to access funds or for lenders to exit their positions.

Looking back the potential of implementing credit scoring in DeFi, this tool could help to create a more fair and accessible loans, by cultivating reputation and trust in crypto loans. Coupled with risk analysis, this tool could help to reduce crypto fraud cases by punishing the bad actors. Putting into perspective, if such tool is commonly used across parties, it could help to create a more trustable and safer cryptocurrency environment.

Why credit scoring in DeFi is important?

In CeFi, credit scoring and risk analysis are essential tools for lenders to assess the creditworthiness of borrowers and manage the risks associated with lending. Implementing credit scoring and risk analysis in DeFi loan is important for:

  1. Mitigating risks: Lending always involves risks, and DeFi lending is no exception. Credit scoring and risk analysis can help lenders assess the creditworthiness of borrowers and determine the risk associated with lending to them. This can help mitigate the risks of default and fraud, which can help maintain the stability and sustainability of the DeFi lending ecosystem.
  2. Pricing loans appropriately: Credit scoring and risk analysis can help lenders price loans appropriately based on the risk associated with lending to particular borrowers. This can help ensure that lenders earn a fair return on their investment, while borrowers can access loans at a reasonable cost.
  3. Protecting borrowers: Credit scoring and risk analysis can help protect borrowers from over-indebtedness by ensuring that lenders only lend to borrowers who can afford to repay their loans. This can help prevent borrowers from falling into a debt trap, which can be especially challenging in the DeFi ecosystem, where loans can be taken out with minimal collateral requirements.

❓Where this idea came out from?

I am an AI researcher, and I see good results of AI in doing almost everything. Besides, I am working individually, and I believe that such an idea is not only helpful, but I am capable of finishing the prototypes in time.

🎊 What it does

OCSRA is short for on-chain credit score and risk analysis. It is an open-source protocol which helps developers to offer better DeFi products, specifically those requiring background knowledge of the wallet, including the underlying risks (e.g fraud address, mule address, etc). The main customer of this product should be DeFi loan platform, which would help to provide users with customised lending terms for borrowers, without scaring them away with underlying terms or collaterals.

OCSRA is designed to be used for multi-chain environment, which could provide platforms or users with an overview of the financial status. Specifically, a credit scoring system, but for a wallet address. Besides, for loan platforms, the risk analysis would help to reduce the possibility of bad actors defaulting the loans, which would defame the platform.

🤔 How I built it

The ultimate goal of OCSRA is to have multi-chain supported to provide the most robust solution for all chains. Since this is huge work for an individual project, instead I picked to work with Ethereum chain only, which is the most commonly used chain.

To obtain the information of a given wallet, such as transactional data, wallet metadata, and movement of funds, Etherscan API is used. The information collected was stated in the calculation table above. The data is then extracted and analysed. Finally, a simple mathematical model is used to calculate the final score. The front-end of this solution is built on top of React (hosted on Vercel), and the back-end is a Python webserver, which is responsible to calculate the score.

The mathematical model threshold (max score) is obtained such that the Top 10 wallet address in Ethereum chain should achieve 95 to 100 marks. From this information, I solve the multiple simultaneous equation to obtain the threshold score.

In short, the process is as follow:

  1. Extract wallet and transactional data from Etherscan API.
  2. Calculate the credit score based on the extracted data, and perform simple addition based on the calculation table below.
  3. The risk analysis is done by checking if the wallet address exists in the fraud database and credit score.
  4. The score, wallet metadata and summary is summarised in a user-friendly UI.

🪄 The Magic Calculations

The equations involved in calculating the credit score is listed as follows.

Items Max score Criteria
Wallet Age 0.3234 <1 m: 0.0714, <12 m: 0.36, <24 m: 0.60, >24m: 1.00
Balance 0.2688 <0: 0.077, <0.2: 0.2305, <0.4: 0.2223, <0.7: 0.6598, >0.7: 1.00
Total Transactions 0.0999 <1: 0.0372, <10: 0.0716, <100: 0.1357, <1000: 0.2679, >1000: 0.4877
Wallet Turnover 0.1631 <10: 0.0276, <50: 0.0638, <100: 0.1471, <1000: 0.3327, >1000: 0.6007
Tokens Holding 0.0386 <1: 0.0352, <5: 0.0678, <10: 0.1575, <100: 0.3013, >100: 0.4567
Transactions Per Month 0.1800 <1: 0.0235, <10: 0.0544, <50: 0.1256, <100: 0.2839, >100: 0.5126
Transactions Performed Last Month 0.1034 <1: 0.0235, <10: 0.0544, <50: 0.1256, <100: 0.2839, >100: 51.26

To score is taking the criteria marks multiply with max score, over all the criteria above.

As for risk-analysis, the criteria use is to check if the address is available in GreySafe. If the address is in the database, it is instantly tagged as risky. If not, based on the credit score, the risk is given such that score <65 is considered risky.

🛑 Challenges I ran into

I am very new to web3 development. Therefore, I believe this application is the great hybrid between web2 and web3, since it involves lesser web3 elements, but relatively helpful in the web3 world. Sometimes great solution requires great integration and good use of available solution.

The first challenge I ran into was the connection of wallet. I found out that Rainbowkit and Wagmi provide the best match for this use cases. The second challenge I ran into was the seperation of client-side and server-side rendering. Instead, I segment the calculation to another server with exposing an API endpoint to do the calculation. The calculation detail is discussed above, and is coded using Python.

😇 Accomplishments to brag of

Within a week time, and little knowledge of web3 development, I am able to produce a working MVP. Not to mention several awesome boilerplate of nice UI, the MVP looks decent and user friendly. Most importantly, the prototype produces correct data given any Ethereum address.

📚 What I learned

A lot! Most importantly, I learn how Wagmi, Etherscan API, and connecting to wallet. Besides, I get to refresh my coding skill with React JS.

⏭️ What's next for OCSRA

  1. Expanding OCSRA to another chain.
  2. Continuing monitoring a given address to produce historical credit score data.
  3. Revamp risk analysis and credit scoring with a better Machine Learning model.
  4. Allow user to mint the credit score.

Built With

  • etherscan
  • mathematical-modelling
  • rainbow-kit
  • react
  • wagmi
Share this project:

Updates