Loanster

Loanster

Leverage or Hedge UniswapV3 based positions using Lending Protocols(Spark, AAVE, LineaBank) to maximize profits and mitigate Impermanent Loss and enjoy a super smooth UX in a single application.

The problem Loanster solves

In Uniswap V3, liquidity providers face significant challenges:

  • Higher impermanent losses than Uniswap V2
  • A complex process for setting up token pairs
  • Limited strategic options
  • Fragmented DeFi infrastructure.

Although Uniswap V3 improved liquidity utilization and reduced price impacts through concentrated liquidity, it introduced a greater risk of impermanent loss, affecting over 50% of providers due to price fluctuations.

For example, if you invest in an ETH+DAI position and the ETH price surges, your position can shift to 0% ETH and 100% DAI, eliminating potential profits. Conversely, if ETH prices drop, your position may become 100% ETH and 0% DAI, leading to direct losses. Uniswap V3 is most profitable in stable markets with limited price fluctuations.

To diversify strategies and profit in bear or bull markets, we integrated a lending protocol to mitigate impermanent losses. In a bullish market, we borrow DAI against ETH collateral, enabling us to benefit from ETH price increases and earn LP fees for long-term profitability. Conversely, in a bearish market, we borrow ETH against DAI collateral. Users can optimize profits by adjusting borrowing rates based on anticipated LP fees and price changes.

Uniswap V3 also presents a complex UX when adding the exact asset amounts for liquidity. The ratio changes after swapping, making it challenging to align with the desired position. Loanster resolves this issue with the Loanster Contract, which calculates precise swap and liquidity amounts.

Additionally, DeFi infrastructures, like swaps and bridges, are fragmented, requiring navigation across various dApp pages. Loanster aggregates and simplifies these infrastructures, automating route calculations. Users can complete investments with a single approval click.

In summary, Loanster offers a seamless UX and diverse investment strategies on one platform, addressing Uniswap V3's challenges.

Challenges we ran into

The primary challenge we faced was improving the user experience (UX) for investing in Uniswap V3. Calculating the optimal ratio of two input tokens to add liquidity to your position proved to be extremely difficult. In V2, users could simply input assets in the same ratio, but V3 introduced complexity by tying this ratio to the current tick and tick range of the position. This made precise calculations a daunting task. Our challenge was determining the exact amount to swap in order to achieve the user's desired ratio.

To address this challenge, we needed to mathematically derive the inverse function of the 'exactInputSingle' function. However, the inherent complexity and high real-time volatility of liquidity posed significant hurdles. To overcome this, we adopted a heuristic approach, repeatedly calling the 'quoteInputSingle' function while minimizing calls through binary search. This approach reduced the margin of error to less than 1e-12.

Developing and proving the mathematical foundation for strategies through lending was also challenging. While there was a wealth of information for handling impermanent loss (IL) in the context of UniswapV2, UniswapV3 IL posed a different challenge.

So, we decided to mathematically calculate it, graphically simulate it, found that as the price range narrows, the pool's price volatility has a significant impact on IL. Additionally, creating a leverage strategy for Stable - Unstable pairs was mathematically challenging.

Therefore, we provided various usage examples and simulated value changes based on borrow rate changes in the Lending Protocol. This allowed users to employ a range of strategies. Calculating the relationship between borrow Rate and pool price volatility was very difficult. However, asking users to choose their Borrow Rate was a challenging issue, so we had to predefine it, such as 20%, 40%, or 100%. This required determining the Borrow Rate based on the pool's price volatility.

Discussion