Exploring the possibilities of a DeFi credit platform
The world is built on credit. How about Web3?
Credit makes the world go ‘round. For most individuals, financing major expenses like a home or car is a necessity, and credit cards are used over cash due to their reward programs, financial protections, and the opportunity to build credit lines.
However, in the crypto space, there is yet to be a comprehensive credit system. Current decentralized lending offerings are often too simple—once a user’s assets dip below a threshold, their collateral is immediately liquidated. This is equivalent to a bank instantly foreclosing your house when the stock market dips or there is a late mortgage payment. Though there have been improvements with user and collateral management and protection, decentralized lending is still largely unforgiving.
As for credit cards, existing crypto credit cards are tethered to traditional banking systems and do not solely operate off-chain. At most, they provide points and rewards via tokens. Currently, airdrops and whitelists, usually managed by individual projects, serve as the primary means of rewarding on-chain transactions. There isn’t a dedicated system to track points and build credit on-chain, despite the number of crypto users worldwide surging to 420 million in 2023, with 54 million in the US as reported by IMF. In addition, countries like Venezuela are experiencing widespread adoption of crypto for both salaries and everyday transactions.
What if we could establish an DeFi credit system that offers smart contract-backed credit cards for borrowing funds and earning rewards, akin to traditional credit cards?
By operating on the blockchain, this system would not only provide rewards for on-chain transactions, but also enhance credit scoring. Unlike traditional credit score formulas and criteria, an on-chain score calculation increases transparency. Moreover, while traditional credit scoring systems lack global standardization (e.g. FICO in the US, CIBIL in India, etc.), the blockchain operates on a global scale, allowing for a universal credit system.
The basic workflow of the on-chain credit platform can look like the following:
Here, the DeFi credit platform has its own token pool, which can have a variety of tokens such as USDC for better hedging. Like a classic DeFi protocol, customers (Fig. 1: User 1) can stake their tokens in the token pool to receive interest payments. The DeFi credit platform can provide interest payments by performing on-chain and off-chain investments.
On top of this, the DeFi credit platform will provide an on-chain credit card. Customers (Fig. 1: User 2) can borrow money and make payments with the on-chain credit card, along with interest payments if the user cannot pay their full outstanding balance. Here, all the components of the credit card borrowing solely exists on-chain.
Users can build an on-chain credit score through borrowing or staking history, and establish custom credit limits, interest rates, and late payment rules.
Of course, it wouldn’t be a true credit card without a solid rewards system. A potential rewards system, perhaps with Aave, may look like this:
Here, Aave contributes significantly to the token pool through staking, allowing the DeFi credit platform to invest in diverse projects across blockchain and traditional domains. To benefit Aave as well, the DeFi credit platform will allow users who interact with Aave through the credit card to gain heightened yields. Aave in turn gains customer expansion and passive interest earnings from the token pool.
Another potential rewards system can be with Yuga Labs:
In this scenario, by taking a percentage of the credit card fees, Yuga Labs will send airdrops to customers that purchased a Yuga Lab NFT with the on-chain credit card. In return, the DeFi credit platform will see increased usage and adoption of credit cards.
To measure how feasible this is, I’ve implemented a small proof of concept for the DeFi credit platform and the credit card. In this implementation, we utilize the ERC20 approve
function, which allows a user to spend a specified amount of the caller’s tokens. For our use case, the credit platform will call approve
for a credit card user to spend up to their credit limit.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract CreditPlatform is ERC20, Ownable {
uint256 public constant DEFAULT_CREDIT_LIMIT = 1000;
uint256 public constant DEFAULT_CREDIT_SCORE = 400;
mapping(address => uint256) public creditLimits;
mapping(address => uint256) public creditScores;
constructor(string memory name, string memory symbol, uint256 supply) ERC20(name, symbol) Ownable(msg.sender) {
_mint(msg.sender, supply);
}
function addCreditWallet(address creditWalletAddr) external onlyOwner {
setCreditLimit(creditWalletAddr, DEFAULT_CREDIT_LIMIT);
setCreditScore(creditWalletAddr, DEFAULT_CREDIT_SCORE);
approve(creditWalletAddr, DEFAULT_CREDIT_LIMIT);
}
function setCreditLimit(address user, uint256 limit) public onlyOwner {
creditLimits[user] = limit;
}
function creditLimit(address user) public view returns (uint256) {
return creditLimits[user];
}
function setCreditScore(address user, uint256 limit) public {
creditScores[user] = limit;
}
function creditScore(address user) public view returns (uint256) {
return creditScores[user];
}
function approve(address user, uint256 value) public override onlyOwner returns (bool) {
require(value <= creditLimits[user], "Allowance exceeds the credit limit for user");
return super.approve(user, value);
}
}
contract CreditCard is AccessControl {
CreditPlatform public creditPlatform;
bytes32 public constant AUTHORIZED_USER_ROLE = keccak256("AUTHORIZED_USER_ROLE");
address private creditPlatformAdmin;
uint256 private _balance;
uint256 private _point;
constructor(address creditPlatformAddr, address user) {
creditPlatform = CreditPlatform(creditPlatformAddr);
creditPlatformAdmin = msg.sender;
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(AUTHORIZED_USER_ROLE, user);
_grantRole(AUTHORIZED_USER_ROLE, msg.sender);
}
function balance() public view onlyRole(AUTHORIZED_USER_ROLE) returns (uint256) {
return _balance;
}
function point() public view onlyRole(AUTHORIZED_USER_ROLE) returns (uint256) {
return _point;
}
function setBalance(uint256 newBalance) external onlyRole(DEFAULT_ADMIN_ROLE) {
_balance = newBalance;
}
function setPoint(uint256 newPoint) external onlyRole(DEFAULT_ADMIN_ROLE) {
_point = newPoint;
}
function transfer(address to, uint256 value) external onlyRole(AUTHORIZED_USER_ROLE) {
creditPlatform.transferFrom(creditPlatformAdmin, to, value);
creditPlatform.setCreditScore(address(this), creditPlatform.creditScore(address(this)) - 100);
_setBalance(_balance + value);
}
function payBalance(uint256 value) external onlyRole(AUTHORIZED_USER_ROLE) {
creditPlatform.transfer(creditPlatformAdmin, value);
creditPlatform.setCreditScore(address(this), creditPlatform.creditScore(address(this)) + 100);
_setBalance(_balance - value);
}
function _setBalance(uint256 newBalance) internal virtual onlyRole(AUTHORIZED_USER_ROLE) {
_balance = newBalance;
}
}
The smart contract workflow will look like the following:
With the
CreditPlatform
admin wallet, deploy theCreditPlatform
contract.With the
CreditPlatform
admin wallet, deploy theCreditCard
contract, and pass in the address of the credit card’s authorized user.To borrow funds, the credit card user will call the
CreditCard
contract’stransfer
function.To payback the balance, the credit card user will first send funds to the
CreditCard
contract, and then call theCreditCard
contract’spayBalance
function. The code can be changed so that the credit card user can directly pay the balance with his/her address.
Such a DeFi credit platform seems quite feasible!
As a parting thought, I’ve outlined a few potentials of the DeFi credit platform below—personally, I’m excited about the prospect of using such a product:
The DeFi credit platform’s success will largely rely on the backing institution. If established institutions such as Amazon or JP Morgan created a DeFi credit platform, it could usher a new era of crypto utilization.
If an established institution backed the DeFi credit platform, an implicit KYC can be formed with the credit card.
On-chain credit scoring systems can expand to off-chain borrowing, which is especially useful for immigrants and travelers.
Customer can select credit cards and lenders based on its credit score calculation, as the formula is on-chain
Establishing tier-based on-chain credit cards (similar to Amex Platinum card vs Amex Blue Cash Everyday card) can provide further benefits
Confidentiality of transactions and credit scores may be achieved with ZK proofs or technologies such as Dusk
Sharp insight and thoughtful investigation backed with a solid proof of concept!
Will be looking forward to part two of this! This was a great read!!