rocketlend / protocol

GNU General Public License v3.0
3 stars 1 forks source link

Rocket Lend

Rocket Lend is a protocol for lending/borrowing RPL to stake on Rocket Pool nodes.

No additional collateral asset is required to borrow RPL from lenders because the borrowed RPL is immediately staked on a node, and the withdrawal address for the node is verified to be the Rocket Lend smart contract that will enforce the terms of the loan (as much as possible as withdrawal address). Another way to think of it is that the collateral for the loan is the node's staked ETH.

Technical Design

Rocket Lend consists of a single immutable smart contract ("the Rocket Lend contract"), used for all interaction with the protocol and designed to be the primary and RPL withdrawal address for Rocket Pool nodes that borrow RPL from the protocol.

The protocol participants come in two types: "lenders", who supply RPL to the protocol, and "borrowers" who borrow RPL from the protocol to stake on Rocket Pool nodes.

A lender is identified by their Ethereum address. They can create lending pools, which are transferable to other addresses.

A borrower is identified by the address of the Rocket Pool node they are borrowing for. They also provide an address (their "borrower address") to Rocket Lend (initially the node's withdrawal address before Rocket Lend), which can be changed, to which their funds are ultimately sent.

Lending Pools

The Rocket Lend contract manages pools of RPL that are made available by lenders to be used by borrowers. There may be many pools active at once. Each lender may have any number of pools.

Although each pool has a single lender, the relationship between borrowers and pools is many to many. A given pool may lend RPL to many borrowers, and a given borrower may borrow RPL from many pools.

In return for providing RPL to be staked, lenders expect to receive interest. The interest rate is specified by the lender when the pool is created. It is charged on RPL that is actually borrowed, for the time during the loan term that it is borrowed. After the loan term, if there is outstanding debt it is charged interest at double the rate. The lender also expects to eventually be repaid the RPL they supplied to a lending pool.

Each pool is identified by a unique number.

Pools are created with the following parameters which cannot be changed:

RPL may be supplied to a pool at any time. RPL that is not currently borrowed may be withdrawn from the pool at any time. Debt in a pool can be transferred to another pool (if the same lender owns both pools and specifies the extent to which they permit such transfers).

Lending pools can be restricted to a limited set of borrowers. The set of borrowers that are allowed to borrow from a pool can be changed at any time by the lender.

Borrower Actions

Borrowers can use the Rocket Lend contract to:

Borrow Limit

The total amount borrowed by a borrower (plus interest) is limited by the ETH staked (or deposited for staking) on their node (or withdrawn to Rocket Lend). This reduces the incentive for a node operator to lock up borrowed RPL with no intention of ever using it.

The borrow limit is 50% of the value of the borrower's "available ETH", defined as: ETH bonded to currently active minipools, ETH supplied (via stake on behalf) for creating new minipools, and ETH withdrawn from the node into the borrower's Rocket Lend balance. (Unclaimed rewards are not included.) It is denominated in RPL using the RPL price from Rocket Pool at the time the limit is checked, that is, when RPL is borrowed.

The borrow limit is also checked when ETH is withdrawn from Rocket Lend, but for withdrawals the limit is doubled. In other words, when withdrawing ETH from Rocket Lend, we ensure that the borrower's borrowed RPL plus unpaid interest remains below 100% of the borrower's available ETH.

Lender Actions

Lenders can use the Rocket Lend contract to:

Contract API

Constants

Most of these are explicit limits on dynamically sized types (as required by Vyper), chosen to be large enough to be practically unlimited.

Name Value Note
MAX_TOTAL_INTERVALS 2048 170+ years
MAX_CLAIM_INTERVALS 128 ~ 10 years
MAX_PROOF_LENGTH 32 ~ 4 billion claimers
MAX_NODE_MINIPOOLS 2048
MAX_ADDRESS_BATCH 2048
BORROW_LIMIT_PERCENT 50

Structs

Views

Lender functions

Borrower functions

Events

Additional Information

TODO: discuss RPL slashing TODO: discuss poorly performing or abandoned nodes TODO: discuss possible griefing vectors and mitigations TODO: discuss incentives for various scenarios TODO: discuss possibilities for funds getting locked TODO: discuss affects of RPL price volatility for defaults TODO: discuss upgrades (of Rocket Pool, beacon chain, Rocket Lend, etc.) TODO: smart contract risk, risks and benefits of the technical design, audits