The Gelato Smart Vault

This project, written for the ChainLink hackathon 2020, implements a Debt Bridge, composed of an interface composed with React (, deployed here, and an SDK to interact with Maker, Compound and Aave through InstaDapp and Gelato.

What is a Debt Bridge

Maker and Compound are two financial services that allow a user to deposit ETH as a collateral and borrow another token up to a certain ratio (66% for ETHDAI).

For example, if the ETHDAI price is 300, and I deposit 10ETH in a Maker Vault, I can borrow 300 x 10 x 0.666 = 2000 DAI. This costs a yearly rate. Now if Compound offers a better rate for the same financial product, I might want to move my borrow position to a Compound vault.

A Debt Bridge uses a Gelato Automation to automatically refinance a Maker Vault to a Compound position (and vice versa), depending which is the most profitable for the user.

This reuses two existing deployed InstaDapp Connectors (ConnectMaker and ConnectCompound) to provision Gelato with a refinancing sequence, that would only be triggered if one is better than the other.

The refinancing sequence is the following:

  • Instapool: borrow DAI
  • MakerDAO: payback DAI
  • MakerDAO: withdraw ETH
  • Compound: deposit ETH
  • Compound: borrow DAI
  • Instapool: return DAI

An interface for that can be found here

The difference is that thanks to Gelato, someone deploying a vault from our interface wouldn't need to refinance manually, as Gelato executors will trigger the call when the conditions are met.

More products

This app can serve as a template for many more interesting lending applications. We included two more examples in this repository:

Refinance to an Aave

The createGelatoOptimizerAave function can setup an automation to refinance to an Aave lending position.

Liquidate on threshold

To avoid losing the liquidation fee, one can use Gelato to automatically liquidate a Maker Vault before the -50% mark on the ETHDAI price. This is showcase in the createGelatoAutoLiquidator function.


The hardest part was to connect the different financial services. Another hard part was to adapt the sdk to the front end.

What's next for The Gelato Smart Vault

  • Flash Loans with Aave and Compound
  • More lending plateforms and a multi-platform optimizer

Built With

  • aave
  • chainlink
  • compound
  • gelato
  • instadapp
  • maker
  • react
Share this project: