eclypse-labs / eclypse-core

The core contracts of the eclypse protocol
1 stars 0 forks source link

Need for updateTicks function #4

Closed devsquaaa closed 1 year ago

devsquaaa commented 1 year ago

I think there is a need for a updateTicks function (to change the range of the underlying LP position). There were discussions that led to it being removed because it's possible to implement it in the frontend, but I believe it will cost a lot more to do it like that.

What do you think?

@userdarius @NilsDelage @Lolshh

userdarius commented 1 year ago

I think doing this through flash loans is something we need to explore. Feel free to figure something out or we can do it together since I've already worked with AAVE flash loans before @devsquaaa .

devsquaaa commented 1 year ago

I think doing this through flash loans is something we need to explore. Feel free to figure something out or we can do it together since I've already worked with AAVE flash loans before @devsquaaa .

Doing this implies doing :

  1. a flashloan
  2. repaying the user's debt with it
  3. closing the (Eclypse) position to get back the Uniswap V3 LP
  4. updating the ticks of that Uniswap V3 LP (multiple steps but let's group them in a single one here)
  5. opening a new (Eclypse) position
  6. borrowing (from that position) whatever was repayed in step 2
  7. repaying the flashloan

Having an internal function would require only :

  1. calling our contract
  2. updating the ticks of the Uniswap V3 LP (multiple steps but let's group them in a single one here)
  3. Making sure this doesn't make the user's position liquidatable (a simple call to liquidatable() and revert if it returns true)
devsquaaa commented 1 year ago

Pushed (9dbb9317728990d339224d75fe6b7711eada30dd) with a test. Still needs more testing.