Skip to content

swimmiee/ethcon-korea-loanster

Repository files navigation

Loanster

Loanster Image

Make Various Strategies for LP

Contract Address

[Linea Mainnet]

[Polygon zkEVM]

[Taiko Testnet]

  • Menu Contract: [0xa48719d977e5823a7881ba3d7a49b81673adaebb]
  • Toaster Contract: [0xb8e0cdbad514edc1e8e790f4b6f5f613361802a7]

Problem

1. UniswapV3 Impermanent Loss (Unstable - stable pool)

Uniswap V3 is more damaging to ILs than the original Uniswap V2. Below is a graph of IL as a function of range for a pair of unstable and stable coins (x-axis is the percentage change in price, y-axis is the value of liquidity).

ethcon.mov

As you can see, the narrower the range, the more the value of liquidity changes per price change. In other words, the narrower the price range, the worse the IL.

2. Limited LP strategy

This is not possible with traditional LPs, who can make high-return, high-risk investments and low-return, low-risk investments based on the user's situation and appetite. They simply provide liquidity and earn fees for doing so.

However, there are 3 types of markets: rising(Bull Strategy), falling(Bear Strategy), and sideways(Crab Strategy), and LPs only benefit from sideways markets and do not suffer from IL.

In a rising market(Bull Strategy), it may be a better strategy to choose a product with more upside potential than the opportunity cost of suffering IL and investing LPs.

In a falling market(Bear Strategy), it may be a better choice to invest in other markets (Nasdaq, real estate) rather than crypto.

This is a very difficult problem in the Defi market, where liquidity is critical.

3. UniswapV3 Investment UX Problem

Unlike V2, Uniswap V3 will determine the amount of both tokens based on a price range (maximum, current, minimum) rather than providing liquidity with the value of both tokens being the same. Users will then have to calculate how much they need to swap to provide liquidity and what range they need to put it in to get all the value they want (exactly what I want to put in if I want to invest $1000).

However, if I'm using a pool that I'm trying to liquidate, the swaps that I'm executing to liquidate could actually impact the current price and cause me to put in less liquidity than I wanted to put in.

Solution

Use Lending Protocol(Spark Protocol) for hedging : Solution of Problem 1,2

We used pools of stablecoins and non-stablecoins to allow users to use different strategies. For example, let's take an ETH-DAI pool. We'll illustrate with examples using the values below.

LTV = 0.8, Borrow Rate = 0.75,current Price: ETH $2000

price range for addLiquidity: $1921.58272121$ ~ $2081.61738542$ [ Ticks for Equal Value of Assets ])

Initial Investment: 2000 $

Depending on market conditions, you can pursue different strategies to get the highest returns.

In a sideways market(Crab Strategy), you don't choose a hedging strategy, you choose a strategy that leaves all liquidity in place.

Slide 16_9 - 3

If you want to borrow DAI with ETH as collateral for , the result of using Hedging is shown below.(Bear Strategy)

Slide 16_9 - 5

If you want to borrow DAI against ETH for, you'll get the following result.(Bull Strategy)

Slide 16_9 - 9

So, as you can see, if you use ETH as collateral, you're choosing a lower yield strategy, but it's more effective in a less volatile market, with less damage to your IL and less damage to your hedging, which may be more effective in a down market. If you're using DAI as collateral, you're choosing a higher-yielding strategy, which is also more profitable in a bull market.

Toaster Contract : Solution of Problem 3

We deploy two contracts: Menu contract and Toaster contract

  • Menu Contract's Role: Search amount for swapping in single pool in onchain

  • Toaster Contract's Role: Router for UniswapV3 Mint(Similar to the swaprouter02 contract). Swap And Add in one transaction to use multicall contract

To address the UX of Uniswap V3, we need to consider the price impact of swapping. However, it's not possible to calculate the price impact through simple math because the amount of liquidity is very different in different zones, depending on the distribution of supplied liquidity in the pool. Therefore, we use binary exploration to determine the amount to swap. We identify the amount in the price range that is reached after the swap and use Uniswap V3's liquidity supply conversion formula (found in the Uniswap whitepaper 6.29,6.30) to find the case where the two values are the same. We added a function to the router (toaster) contract we created to perform the post-swap minting process in a single transaction using these values.

How to use Loanster?

1. Connect Wallet 스크린샷 2023-09-03 오전 10 16 31 2 .Select chain & Select Token for Deposit 스크린샷 2023-09-03 오전 10 17 48

3. Select Pair (Hedge Enable or impossible) 스크린샷 2023-09-03 오전 10 18 07

4. Select Price Range for UniswapV3 & Hedge Rate for how much deposit to lending protocol

스크린샷 2023-09-03 오전 10 18 51

5. Finally, Click the buttons to make the multiple transactions.(deposit + borrow + swap for matching rate + addliquidity)

스크린샷 2023-09-03 오전 11 39 07 스크린샷 2023-09-03 오전 11 39 25 스크린샷 2023-09-03 오전 11 40 04 스크린샷 2023-09-03 오전 11 40 22 스크린샷 2023-09-03 오전 11 40 40 스크린샷 2023-09-03 오전 11 42 54

About

ETHcon Seoul 2023 Hackathon repo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published