LAYs is a proof of concept and a very simple borrowing smart contract.
LAY tokens are stable coins pegged to the US Dollar by using ETH as collateral and the Chainlnk pricefeeds.
When the users deposit
ETH
or borrowLAYs
from the smart contract, theirETH
is locked up as collateral. The chainlink price feeds are used to fetch price ofETH/USD
. This price is used to calculate the amount of LAYs that should be issued as loan to the user.Let's say you're done getting LAYed and you want your collateral back. Just call the
withdraw
function and specify the amount of LAYs you want to give back. LAYs will be burned and ETH will be returned to your account proportional to it's worth.The UI is fairly simple and it consists of one tab each for borrowing and withdrawing. The code uses Moralis for fetching data and ChakraUI to make everything look nice and smooth.
LAYs Token Contract SimpleVault Token Contract
The most challenging part about web3 and crypto projects it keeping yourself from falling into a rabbit hole. I couldn't and I did fall for quite some time with this project.
Spent a lot of time researching borrowing and lending protocols for this project. Although my limited knowledge in building smart contracts created a challenge to come up with a better architecture than this one.
I also struggled a little with handling all the decimal calculations and using the pricefeeds to allocate appropriate amounts of tokens.
Discussion