The Graph API
The Problem Lending is one of the most popular applications of decentralized finance in the world. An effective global economy begins with the ability for users to borrow funds to be repaid with interest in the future. Existing DeFi loan platforms heavily rely on “over-collateralization” of existing fungible tokens to secure a loan for the user. This means that the user has to collateralize more value than they are able to borrow. This results in nothing more than a conversion of one token into another, and forms a barrier for traditional loan customers who do not have existing funds available. Pawnspace aims to fix this issue by introducing the collateralization of non-fungible tokens. Pawnspace With Pawnspace, the user lists their NFT as collateral along with a small amount of stablecoin to be deposited into Aave. Upon depositing the collateral, the user sets their desired minimum loan price, and waits for another user (a lender) to provide the loan at this price. Lenders will have the ability to view all available NFTs that are put up for collateral. If they agree to the specific loan conditions and are willing to accept the NFT in case of default, their capital will be used to fund the loan amount. The collateral is locked until the loan is repaid (with interest), or the specified time expires. If the loan defaults, the lender receives the NFT.If the loan is paid back in time, the borrower receives their NFT back, along with the interest-bearing stablecoin. Technology The Pawnspace protocol consists of a factory smart contract that deploys a “pawnspace” for each existing NFT contract. Borrowers will interact with the pawnspace corresponding to their NFTs smart contract in order to create an “order”. Each “order” in pawnspace is also its own ERC721. Through the use of our UI, lenders will be able to view existing “order” NFTs and can choose to fund whicher “order” they desire. Upon accepting an “order”, the lender sends the loan amount to the borrower, while the collateralized NFT is locked and stablecoin deposited with Aave. The borrower must repay the loan before the specified timer expires, or else the lender can claim the collateralized NFT. Our UI utilizes a custom Pawnspace sub-graph, along with existing NFT sub-graphs, in order to pull blockchain data efficiently to the front-end. This eliminates long loading times for users who own a large library of NFTs. Interfaces are provided for both borrowers and lenders, with all functionality of the protocol made available within the Dapp.
How It's Made
All of our lending flows are executed in smart contracts (solidity). Smart contracts call the functions of moving collateral NFT tokens and deposit / withdraw Aave functions. In the frontend of Dapp, React is used and to access Metamask. Users can register their own NFT as collateral through Metamask. Besides, the user can see the list of all orders. To improve performance, the list data is obtained from The Graph's API.