Abstraction for an undercollateralized lending protocol designed to make usage seamless
Rainshower is a protocol used to control asset flows between counterparties. Users can use this to build financial instruments on top. This flexibility comes at the cost of UX, where users are required to find counterparties to take loans.
We created an entirely new abstraction, an asset pool that can act as a counterparty. Lenders deposit funds and get yield-bearing tokens. Borrowers can request loans, and the pool will be the facilitator. The borrower can then use these funds according to what they asked for. To demonstrate, we let the users trade on uniswap with leverage, with the asset pool being the counterparty.
The poool contract contains all the logic for the system. Users come to it to request quotes, deposit and withdraw assets. For the users to deposit, their assets must first be approved. We use Rainshower as a framework to control the lending logic.
When a user requests a quote, the system decodes the _data. _data includes risk parameters, like the token, amount of tokens borrowed, maintenance margin, etc...
We then use this data to assess the risk with the risk assessor contract. A DAO would set the thresholds of these parameters in production. Utilization rate is also taken into account when we're creating a borrow. Higher utilization means the interest rates will be higher. We use the @solmate library for the fixed point arithmetic. If the risk assessment passes, we create a new rainshower borrower, which the borrower can use.
Testing was done in hardhat, written in javascript, and the contracts were written in solidity. The frontend is built using react and uses ethers.js to interact with the chain.