S

Stablecoin Borrowing Dapp

Deposit ETH as collateral, and get MSC Stablecoins as a loan!

23

The problem Stablecoin Borrowing Dapp solves

The aim of this project is to build a borrowing dapp that lets a user submit Ether to a smart contract as collateral and receive MSC stablecoin as a loan. A user could require MSC tokens for some other application but might not own it. Using this project, he can temporarily collateralise ETH that he owns and get some MSC tokens in exchange. This way he can interact with other applications using the MSC token without losing his position (i.e. without having to sell his Ether)

This application provides a clean, easy-to-use interface to deposit and withdraw assets. The data displayed on the interface helps the users view their balances and positions in this application. The buttons used to initiate transactions keep track of the transaction status and freeze accordingly while the transaction is still processing.

The smart contract depends on Chainlink Price Feeds to get the value of ETH (deposited by the user) in USD and borrows (mints) an equivalent number of MSC tokens to the user's account. When the user has finished utilising the MSC token, he can initiate a transaction to withdraw his collateralized ETH and the MSC tokens belonging to his account are burned. The use of Chainlink oracles ensures that this application is completely decentralised and does not have a single point of failure.

Challenges I ran into

The borrowing dapp is based on financial aspects of pegging the stablecoin to the price of USD. Initially, it was difficult to figure out how to implement the logic for this borrowing.

I also had a lot of confusion regarding the decimals and units of the token. I also had to pay attention to overflow errors while calculating the number of tokens that can be borrowed against given collateral.

The integration of Chainlink Price Feed and the implementation of the web application were relatively smooth. I also realised several bugs during unit testing which made me question the logic and keep making improvements.

Note: The dapp is currently configured on Rinkeby testnet (as the Mumbai network was having certain issues).

Discussion