Liquidity amounts calculation and AMM behavior in lower and upper boundaries points #87
              
                
                  
                  
                    Answered
                  
                  by
                    OoXooOx
                  
              
          
                  
                    
                      OoXooOx
                    
                  
                
                  asked this question in
                Milestone 1. First Swap
              
            Replies: 1 comment
-
        
  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
      Answer selected by
        OoXooOx
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
token0: 5000
token1: 20000
In this case:
Price current - 4
And I provide liquidity in range:
Price lower - 2
Price upper - 7
I calculate liquidity by formulas and choose lower value from them.
Next I must recalculate amounts which I must put in pool in real, because due rounding I must do this
and I receive amount0 4166 amount1 19999
So from my wallet will be subtracted only this amounts right? What happened with surplus?
They return to my wallet? Or this amounts must be calculated properly before transaction?
And here (Questions about liquidity calculation #60) you said that we do not have liquidity in
boundaries and price must go to next price range. And its logical, because if we have AMM formula xy=k on lower border point
y will be 0 and we receive p=0 and k=0. It's nonsense. Ok. But.
Next sight of this situation - price go to lower point - 2. And now I can use this position only for buying token0, but I can do it.
I have all position with toke0 and lower price - 2. So if I put in pool token1, then I receive some of token0. Right?
So question is how this happened. From first sight we can't use xy=k in boundaries. But from other side - we can use pool.
Beta Was this translation helpful? Give feedback.
All reactions