A Margin Trader in Decentralized Wonderland
A Margin Trader’s journey on the Lendroid protocol. This is new ground for a trader; familiar tropes, packed with a sweet surprise. #LendroidExplains
It’s never been decentralized before. Ever. Trading in decentralized assets don’t count, when you’re trading them via a centralized exchange. You run the very same risk and friction you’ve been trying to run away from.
Before you go further on in this piece, we recommend you take a quick, fun detour into a previous blog, where we explored What Margin Trading is and How it works. And also, a little pompously, why it is essential to the blockchain.
But what is the experience like for a trader? What is it like in a centralized system, and what differences would he see when trading on Lendroid? Let’s walk in his shoes for a bit.
In a centralized system, the Margin Trader places his trust on his fund manager, on the exchange, and, if he is so inclined, on a higher power. He is removed from the system, by opacity of process and the necessity of intermediaries. On Lendroid, he has a well-defined role in the ecosystem.
Figure 1: In the Thick of It
The trader opens a margin account, within which he is free to change positions or add collateral. He can withdraw his collateral or liquidate his Margin Account when there are no loans owed. Here’s how those actions play out, broadly.
a. Locking in Collateral
Lendroid is compatible with any ERC20-based token. This gives the Margin Trader a high level of flexibility with respect to the nature of collateral he can deposit against a loan. He is free to deposit not just one kind of collateral in a token of his choice, but multiple kinds of ERC20-based tokens at the same time, in the same margin account.
However, the support for a token has other considerations besides compatibility alone. In what is envisioned as a community-driven governance model, the protocol will add or remove support for a token based on the current volatility of the token.
If the Margin Trader finds that the health of the margin account has dipped, he can add collateral at any time before the liquidation process is initiated on his account.
b. Availing a Loan
Lendroid, first and foremost, is a decentralized lending protocol. This is a foundation for margin trading. With an array of highly competent relayers allying with the protocol, the trader has a wide range of offers to choose from.
Here’s a quick extract from the whitepaper detailing how this will pan out — When the Margin Trader finds one that is suitable for his needs, he calls the availLoan function on the Smart Contract, by including the offer object in the function call. Using the ecrecover function, the smart contract will then verify that the signature is valid and, based on the timestamp, that the offer has not expired. The Smart Contract also checks the Lender’s funding account to make sure there are sufficient funds to carry out the offer. Once ratified, the funds are credited to the Trader’s Margin Account and debited from the Lender’s Funding Account.
c. The Margin Account
In a centralized system, the trader has negligible control over the margin account. In fact, instant liquidation in the case of ‘flash crashes’ are not uncommon. On Lendroid, however, the Margin Trader operates in a more transparent, empowering space.
Figure 2: It’s showtime
The Margin Trader stakes Lendroid Support Tokens (LST) when opening a Margin Account. This stake is refundable, when the Trader closes trade positions and repays the loan. However, in case the account drops below the liquidation level, the deposit is repurposed into bounty for the Wranglers (who monitor the account and identify under-performers).
In the Margin Account, neither the collateral nor the positions can be withdrawn without honouring the terms of the loan. However, a Margin Trader is free to manipulate both elements at any time to maximize returns. He can top up collateral in a flagging account, and calibrate his positions with the help of decentralized order book protocols.
In the first row of Figure 2, there’s the Margin Account on the extreme right, which contains the capital borrowed for the trade. The trade positions haven’t been set yet.
In the next row, we see that the Margin Trader has calibrated his trade positions. This intent is recorded on-chain, and executed using a decentralized order book protocol. Lendroid is capable of integrating with multiple order book protocols, including 0x, Kyber, Omega, and others. When positions need to be updated or rearranged, the Margin Trader can delegate the function to the most liquid order book protocol in the ecosystem.
In the third row, we see that at the end of a trading session, the trade positions have done well for the Margin Trader and a profit has been accrued over and above the borrowed capital.
d. Closing a Loan
The loan terms are specified by the Lender right at the beginning, when the offer is made. There are three scenarios in which the loan is closed.
1. The first is the scenario is when the trader has made a successful trade and is able to close the loan, repaying it without incident.
2. Alternatively, the term of one or many loans might be close to expiry even when the Margin Trader is not ready to unwind his trade positions. Monitoring this can be delegated to incentivized actors called Wranglers, who will help replace or ‘roll-over’ an expiring loan with a fresh one. Though not built into the protocol, this specific function is a logical extension of a Wrangler’s primary role — that of monitoring the margin account.
3. In the third scenario, a Margin Account underperforms and warrants immediate action. A Wrangler has identified the account. The Wrangler then repays the loan to the Lender himself, and also triggers an auction of the Margin Trader’s collateral and positions.
4. A fourth and less likely scenario is a Black Swan event, where a Margin Account has been left unattended by both Wrangler and Margin Trader and, for enough time to cause damage, by the Lender himself. In such a case, the Lender can call in his loans and as a result will take over and choose to withdraw the collateral and trade positions as a compensation.
That’s pretty much how the Margin Trader rolls in Lendroid. Each of these stages will assume several more layers as the development of the protocol progresses, but we believe the foundation of the process — with the intent of protecting the interests of not just the lender but also the margin trader — is solid.
To reiterate, as things stand, margin trading is impossible in a decentralized manner. The functions of margin monitoring, order book and offer book keeping, accounting, loan repayment and liquidation and, above all, fund custodianship, are all under one centralized entity. The Lendroid structure for Margin Trading is a first of its kind, on the blockchain or off it. We’re excited about it. We think the traders will love it.