Uniswap Contract Reading – Understanding Contract Methods like klast, getReserves, price0CumulativeLast, price1CumulativeLast

tokensuniswap

https://etherscan.io/address/0x3139Ffc91B99aa94DA8A2dc13f1fC36F9BDc98eE#readContract

I'm trying to understand what data these function output: klast(), getReserves(), price0CumulativeLast(), price1CumulativeLast().

I'm assuming price0CumulativeLast & price1CumulativeLast are the latest prices of their respective token in Ether.

getReserves I believe is the liquidity of the respective token in Ether.

kLast i have no guess what it is.

Best Answer

  • price0CumulativeLast and price1CumulativeLast are indeed the latest prices of their respective tokens in Ether.
  • getReserves is a function that returns the current liquidity of both tokens and the timestamp of the last liquidity event.
  • kLast is a public variable that stores the product amount of the first token and the second token as of immediately after the most recent liquidity event. It may be useful in calculating the current price of the tokens being traded.