We are an IN-PERSON team.

We are competing for the DeFi category.

Inspiration

As Lunatics, we were disappointed to realize that there are several centralized exchangs with leverage tokens, but there are no decentralized protocols that help represent leverage on Terra. We understood the application of borrowing markets and how they can be used to increase exposure and decided to create MLev, a M(anaged) Leverage Protocol that utilizes various borrowing markets accross Terra to provided leveraged version of Terra assets. We also recognize that we can use the IBC transfers to utilize other lending markets and provided leveraged versions for other tokenized assets available on Cosmos networks.

What it does

MLev is a Managed Leverage Protocol. Our proof of concept is centered around using lending markets to borrow against assets to increase holdings of an asset.

Example

Consider buying a UST-bLuna 1.5X Leverage Token from MLev. Let's define some variables:

  • bLuna Price = 100 UST
  • Initial Deposit = 100 bLuna

With these parameters, to achieve 1.5X leverage, we can utilize Anchor Protocol's borrowing. The process is the following:

  1. Deposit 100 bLuna into Anchor's bLuna custody.
  2. Borrow 50% LTV (5000 UST)
  3. Swap 5000 UST for ~50 bLuna
  4. Deposit 50 bLuna back into Anchor.

Thus, we have 150 bLuna. Based on price fluctuations:

  • 33.33% Increase in bLuna price = 113 bLuna after paying off Anchor Loan, 113*133.33 =~ 15000 UST = 1.5X Leverage
  • 33.33% Decrease in bLuna price = 75 bLuna after paying off Anchor Loan, 75 * 66.67 =~ 5000 UST = 1.5X Leverage.

Upon rapid price decrease, we can manually sell collateral to manage a healty LTV to prevent loan liquidation from occuring.

This exanple is limited to UST and bLuna on the Anchor protocol. However, we can utilize Edge Protocol or Mars Protocol on Terra to create leveraged tokens for pair denominated in any asset, such as a ANC-MIR 1.5X Leverage. We can also use Cosmos' IBC transfer mechanism to create leveraged tokens using lending markets on other chains, such as Osmosis. This method does not limit us to 1.5X Leverage, since we can "loop" collateral to borrow more to increase leverage.

How we built it

Using the code given in workshops, sample wasm project and functions developed by our team we made and deployed a rust contract on the blockchain.

We obtained a lot of help from Vlad to learn how to interact with CW20 contracts and Anchor's contracts. Although we were not fully able to build out a leveraged token, we were able to learn enough about the ecosystem to send CW20 tokens to our contract and actually have our contract detect and perform further actions upon a deposit.

We also planned out a basic UI/UX design for what the protocol may look like using Figma.

Challenges we ran into

  1. Gathering a team - we started off with a lot of people wanting to work but eventually only ended up with 2 people as part of the team. Having only 2 people made it really difficult for us to rapidly progress in our project.

  2. Developing on blockchain is a new concept for us and we found the documentation is lacking and there isn't much help on platforms like stack-overflow.

  3. Rust, even though a very well designed and documented language, is new to both of us and because of that we had to ask for a lot of help from instructors.

  4. Terra's documentation is missing some crucial information which resulted in bugs that took time resolving. We were lucky to be able to figure out these issues unlike a lot of teams that gave up trying to setup the development environment.

  5. We had a lot of trouble properly understanding how looping and managing LTV will truly work with our idea. We talked with several mentors and Vlad =) to ensure that what we were designing our protocol right. Althought it took us a lot of time and brain power, we were able to come up with a design that should be a good starting point for development.

Accomplishments that we're proud of

  • Coming up with a good protocol design.
  • Getting involved and learning about the ecosystem from people at TFL.
  • Even though there was many hurdles we managed to come up with a prototype contract.

What we learned

  • We learned how to setup and use the Terra dev environment.
  • Never trust anyone who plans to team with you, unless they are extremely commited.
  • We learned a lot about Rust contract development.
  • We learned a lot of tricks from Vlad on how to reverse engineer other protocols to understand how they work to learn how to build things.

What's next for MLev Protocol

Both of us are definitely deeply interested in blockchain development and will continue learning more and developing this throughout the summer.

Built With

Share this project:

Updates