Liquity V2 is currently live on ETH Sepolia Testnet. Mainnet Launch is coming soon
Instadapp for Frontend Operators
Liquity V1
Liquity V2
Ed Mulraney
·
September 7, 2021
Instadapp for Frontend Operators

Instadapp recently released a frontend for Liquity protocol which made it easier for borrowers to leverage their ETH multiple times with a single click. Protecting loans from liquidation is also now a lot simpler, and cheaper, as borrowers can swap some of their ETH collateral to LUSD to increase their collateral ratio, also in a single click.

While this is great for borrowers, in this article we’re going to explore how Frontend Operators can also benefit from Instadapp.

What does Instadapp offer?

Instadapp uses a proxy smart contract, known as a “Defi Smart Account” (DSA) to act on behalf of Liquity borrowers. Any frontend can interact with DSAs through Instadapp’s Javascript SDK. This SDK allows you to execute smart contract function calls from Javascript code. Where this becomes particularly powerful is when you combine smart contract calls from different protocols into a single transaction, without needing to write any Solidity code.

An example of combining smart contract calls across different DeFi protocols could be:

This would allow users to earn passive income on their LUSD, in one-click, as a single transaction.

Instadapp have a getting started guide which explains how to integrate the SDK into your frontend.

Building on top of Liquity’s stock UI

The stock UI we built for Liquity serves as a building block for Frontend Operators to innovate on top of. We’ve already seen some great products emerge such as B.Protocol’s auto-compounding Stability Pool derivative, and DeFi Saver’s automated leverage.

We wanted to make it easy for Frontend operators to receive ideas and feedback from Liquity users, so we created a #frontend-suggestions channel in our Discord which enables users and operators to communicate directly. However, there’s one type of request from users which has been difficult to implement:

  • “Can you add a button which claims my LUSD gain from the Staking Pool and deposits it into the Stability Pool?”
  • “Can you add a button which claims my LQTY gain from the Stability Pool and stakes it?”
  • “Can you add a button which lets me do X, Y, Z all at once?” etc.

Currently Frontend operators could implement this functionality on the frontend by “stacking” a queue of transactions, but this would be slow, laborious, and expensive (gas intensive). With a DSA managed Trove, you can instead combine these calls into a one-click “recipe” which gets executed as a single transaction, without needing to write a line of Solidity code.

Let’s take a look at what such a frontend recipe would look like.

Recipes

Recipe #1: Move LUSD gains from Staking Pool to the Stability Pool.

When users accumulate LUSD gains from their staked LQTY, they can move it to the Stability Pool to earn yield, rather than having it sit idle. This would normally require two manual transactions from the user. Frontend operators could use a recipe such as this to achieve it as one transaction:

Breaking down the spells 🧙

  1. Claim gains from the Staking Pool (includes LUSD gains from borrowing fees, and ETH gains from redemption fees)
  2. Deposit the LUSD gain into the Stability Pool

Here you can see we’ve composed two transactions (“spells”) together into a recipe which can be executed as a single transaction. This function could, for example, be called in response to a button click.

Recipe #2: Migrate a Maker Vault to a Liquity Trove

Instadapp users with a Maker vault might be interested in taking up Liquity’s 0% interest loan as an alternative to the recurring interest fees required in Maker. This operation would normally require a lot of manual transactions across Maker, Liquity, and Curve, as well as requiring the the user to have the upfront DAI to repay their vault debt. With this recipe, we can use flash loans to repay the Maker vault without requiring any upfront funds.

Breaking down the spells 🧙

  1. Get the amount of ETH collateral and DAI debt stored in the Maker vault
  2. Flash loan the same amount of ETH from dYdX
  3. Open a Liquity Trove with the flash loaned ETH and borrow the same amount of LUSD as DAI debt
  4. Swap the borrowed LUSD to DAI using 1inch
  5. Repay all the Maker vault debt using the swapped DAI
  6. Withdraw all the Maker vault ETH collateral
  7. Repay the dYdX ETH flash loan using the withdrawn ETH

These recipes only skim the surface of what you can build on top of Instadapp’s DSAs. There are many powerful and useful features to be built, such as refinancing your Trove from another DeFi protocol 👀

We look forward to seeing what you’ll build!

Footnotes

Instadapp supported protocols

To call a DeFi protocol in a recipe, there must be a “connector” contract which integrates with the desired protocol — these connectors can be contributed by anyone via pull request.

Supporting existing DSA users

To support DSA owned Troves in your frontend you need to integrate Instadapp’s frontend SDK and check if the the user has a DSA account or not. If they do have a DSA owned Trove you’ll need your frontend smart contract calls to go through Instadapp’s Liquity connector instead of directly to Liquity’s own smart contracts.

Enabling existing Liquity users to migrate to a DSA

To enable your existing users to move their Trove to a DSA you’ll need to guide them through closing their Trove, creating a DSA, and reopening the Trove with the DSA account. This would be three transactions:

  1. Repay Liquity Trove debt
  2. Create a DSA
  3. Open a new Trove on the DSA

Additional resources

To learn more about Instadapp, here are some resources to get you started:

If you want to discuss anything in this article we’d be happy to talk — join our Discord #frontend-operators channel.

Liquity Resources:

Website | Twitter | Discord | Telegram | Github | Reddit | LiquityCN

-->