Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In rebalanceVaultNft, GeneralSwap action is exactIn only, is exactOut swap better at times/needed? #346

Open
aleone opened this issue Apr 13, 2022 · 3 comments

Comments

@aleone
Copy link
Contributor

aleone commented Apr 13, 2022

Right now, only exactIn swaps are supported, are there case where we want/need an exact out swap?

@alpinechicken can you think about this?
@KMKoushik , for the front end is there one that would be better or worse?

An example of this would be:
Someone has an LP with 50 oSQTH and 50 ETH in it. The current price of oSQTH/ETH is 1:1.
One example is they want to rebalance to a new LP that has 75 oSQTH, with new ranges, and need to sell some ETH to do this. The front end has to figure out how much ETH the user can take from the existing LP and any additional ETH needed to get these extra 25 oSQTHs. For this, it seems easiest to do an exactOut swap where 25 OSQTH is the amount out and the amountIn is returned from the quoter.

If the user instead wants to reduce their oSQTH side of the LP to only have 25 oSQTH, it might be easiest/best to do an exactIn swap, where the exactIn amount is 25, and the ETH proceeds can be queried from the quoter.

It's likely possible for the front end to do both of these using only exactIn or exactOut swaps, but is it easier/better to do with both or does that add too much complexity?

@alexisgauba @zkoticha @KMKoushik this also ties in with the front end user experience. My thinking is that when a user specifies a new amount that is greater than the current asset balance for one of the LP assets the front end will look to do an exactOut swap and solve for the other asset in the LP (figure out how much it needs based on the ranges and the other asset). When a user specifies a new amount that is less than the current asset balance for one of the LP assets the f/e will look to do an exactIn swap and solve for the other asset in the LP (figure out how much it needs based on the ranges and the other asset).

@aleone
Copy link
Contributor Author

aleone commented Apr 13, 2022

@haythem96 can you look at how we can support both if that is the best thing to do?

@alpinechicken
Copy link
Contributor

thrts:

Possible to get approximately right with exactIn or exactOut using uniswap quoter contract, but def better with both exactIn and exactOut.

I still have to deal with some uncertainty either way. In your first example I choose 75 oSQTH and a range for the LP. I won't know exactly how much eth until I know the price tick. That's of the same kind of order of uncertainty as exactIn vs exactOut, though less uncertainty is better!

From a UI perspective:
choose: a new range for the LP and amount of one side
get: an approximation for the other side and the eth cost of the change

E.g.

I have a 0.25 -> 0.35 range with 50 oSQTH and 50 ETH
I want to go to a 0.3 -> 0.4 range with 75 oSQTH -> Fe tells me approx how much eth I'll get in the LP. Contract liquidates LP, exactOuts for 25, and uses vault eth and proceeds for the rest.

@alexisgauba
Copy link
Contributor

Defer to @KMKoushik when it comes to FE implementation

From a UX pov think its best for the user to be able to interact in ETH vs. needing to get any oSQTH so exactOut swap seems good for first scenario

For second scenario if we don't do exactIn could there be dust? That might be problematic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants