Prices are determined by the amount of each token in a pool. The smart contract maintains a constant using the following function: x*y=k
. In this case x = token0
, y = token1
, k = constant
. For each trade a certain amount of tokens are removed from the pool for an amount of the other token. During the execution of To maintain k
, the balances update. So each trade will adjust the balances held by the smart contract therefor changing the price.
Comments
0 comments
Article is closed for comments.