How to be a relayer on the Lendroid protocol

Vii Sundaram
Lendroid
Published in
6 min readJul 2, 2019

--

Why it is a good idea to spin off your own relayer on Lendroid, and how we’ve simplified the onboarding process.

This is part two of the Lendroid Relayer Series, which follows from part one, where we introduced Reloanr. In this second part, we attempt to share with you all the information you will need to spin off your own Relayer.

Lendroid’s Relayer template is open source, and Version 1 enables peer-to-peer lending. It is customizable along six facets including the UI, token support, wranglers, loan terms, and order-book implementation. We are excited to have built this template which now gives more power to anybody that wants to put together a lending product Ikea-style!

Overview of the Relayer Engine

The core of Lendroid’s Relayer engine comprises of the following parts:

  1. The skeleton — Relayer Template
    Description : Comprises the source codes for UI and UX. Written in React.js
    Source code : https://github.com/lendroidproject/reloanr-ui
    Documentation: https://developers.lendroid.com/relayer-ui
  2. The veins and arteries — Order Server
    Description : An api server that stores, modifies and retrieves lend / borrow orders.
    Source code : https://github.com/lendroidproject/kernel-server
    Comments : The current implementation is written in Python to suit the Google Cloud framework. It contains a simple Order model and corresponding api endpoints. This logic can be replicated to other languages / web frameworks. In such cases, please ensure the existing fields as specified in the models.py file are preserved.
  3. The heart — Lendroid JS Library
    Description : JS api for Lendroid protocol smart contracts. Works under the hood.
    Source code : https://github.com/lendroidproject/lendroid-js/tree/master
    Documentation : https://developers.lendroid.com/lendroid-js

Note : The examples and instructions in this blog post refer only to the source code of the Order server (at this branch commit) and the Relayer template (at this branch commit) which uses Version 1 of the Lendroid Protocol. We do not cover the Lendroid-js library in this post. Therefore, if you’re curious to know how lendroid-js works under the hood, please feel free to check out to its source code and documentation.

Configuration and on-boarding process

Download the Reloanr code from this github repository and follow its README instructions to spin up your own Lendroid Relayer instance. You can customize the template in the following ways:

The UI skin — Reloanr comes with a fully finished UI, mated to the UX we defined for the play between Relayer, Lender, Borrower and Wrangler — a unique feature of the Lendroid protocol, incentivised to approve loan terms and monitor loan health. If you’re comfortable in our skin, you can use it as is, but if you’d rather have your own, you can customise it from the `src/assets` folder and the corresponding `.scss` file in each component folder.

ERC20 token support — Currently, Reloanr supports Dai, USDC, and Digix. It is built to accommodate any ERC20 token and you can set this up at your end from the `src/components/Contracts.js` file, as shown below.

Figure 1 : ERC20 token configuration example from this file

For testing, you can just include the network ID of your choice, and the ETH address of the deployed token contract. In the same file, you can also specify exclusively which tokens to display in the lend / borrow forms.
LST and WETH are included by default at this lendroid.js configuration file and this configuration need not be modified.

Since this is a protocol level modification, if you notice that the token is not supported by the protocol smart contract(s), drop up a line and we will enable that ERC20 token on the Lendroid protocol.

Relayer ETH address — The Relayer gets paid in LST for his services in matching orders. You can set up the Relayer address here — `src/components/Orders.jsx` file
The address can be added to the options object like this:
const options = _this => ({

relayer: “0x…”
})
In the absence of the relayer address, any order created on your interface is auto-filled with the ETH address 0x0000000000000000000000000000000000000000

Wrangler support — The Wrangler is a programmable server who checks and approves the loan terms, and also monitors loan health. The default wrangler is Lendroid, but you are free to spin off your own Wrangler as well (instructions soon). In any case, if you want to set your choice of wranglers, you need to go here —
`src/components/Orders.jsx`.
Edit the const object to include your list of wrangler objects as per the example here.
const options = _this => ({

wranglers: [
label: ‘Default Simple Wrangler’,
address: ‘0x0f02a30cA336EC791Ac8Cb40816e4Fc5aeB57E38’,
apiLoanRequests: ‘https://lendroidwrangler.com'
})
Note: Each wrangler object should include the following fields:
label : This text appears on the UI
address : ETH address of the wrangler
apiLoanRequests : The IP address / domain name where the wrangler server is hosted

Specify / Limit loan terms — We do understand that loan terms can’t be the same across the world. If you would like to change the terms according to the jurisdiction you are in, you can access this file — `src/FormTab/Forms.js`. For more information, refer https://developers.lendroid.com/relayer-ui#forminputs

Order book — By default, all orders are stored on a public server, whose code is available here : https://github.com/lendroidproject/kernel-server. The Order server api can be specified in the file `src/components/Orders.jsx`, under the const object like this (example):
const options = _this => ({

apiEndpoint: IP address / domain where the order server is hosted
})
You can also edit this line to include your own private Order book to handle api requests directly from your Relayer interface. Please ensure that the corresponding wrangler calls are made for api requests to fill / cancel an order.

A note on handling Order Books

Implementation can trigger some questions about some user journeys work or security. We have made every effort to address systemic and security concerns, but always welcome your suggestions and feedback. A couple of instances to illustrate this:

  1. Consider RelayerA and RelayerB source their order book from the common order server. If RelayerA hosts an order book which was created on RelayerB’s interface, who gets incentivized when that order is filled on RelayerA’s interface?
    Ans: RelayerB. LST goes to the relayer of the interface where an order was first created, irrespective of the interface where that order gets filled.
  2. Is it possible to manipulate the order books by sending api requests directly to the order server, eg for order fills and order cancels?
    Ans: No, that would be a security snafu. Every order is filled / updated only after confirmation from the Wrangler. For those implementing their own order book servers, we recommend this approach. Please feel free to reach out to us in case you need more clarification on this.

Just to reiterate, ERC20 token and wrangler support will be activated by the Lendroid Foundation at the protocol level, upon the relayer’s request.

Some background conversation

Why is spinning off your own relayer, and that too on the Lendroid Protocol, a good idea?

  1. Fulfilling a real need: We believe effective Relayers will champion the cause of user acquisition on the blockchain and consequently, liquidity and scale. With Lendroid’s lending engine at its core, more power is given to developers’ so they can build awesome interfaces for various financial use-cases Trading instruments, shorting, margin, and derivatives.
  2. Easy setup and upgradability: Spinning off a Relayer on a protocol like Lendroid is a one-time setup. You either replicate the structure and UI of Reloanr, or you add nifty embellishments to differentiate yourself from other Relayers. Either way, once you’re set up, you earn fees from Lenders and Borrowers for your services. Also, with further developments at the protocol level, you will only need to point to the latest version of the `lendroid.js` library.
  3. Collaboration and sowing the seeds of creativity: Feedback and conversations with our relayers will help the Lendroid ecosystem grow exponentially. You want to support more tokens, let us know and we’ll make it happen! You want a change in the process, do not hesitate to let us know.

For further details or assistance, write to us at connect@lendroid.com or drop us a message on the official Lendroid Telegram page.

We look forward to hearing from you.

--

--

#Libertarian, #Blockchain enthusiast, #Smart Contract Engineer, #Full-stack Web Engineer, #CelebratorOfLife