How Does an Automated Market Maker (AMM) Calculate the Price of an Asset?
An AMM uses a constant product formula, most commonly $x cdot y = k$, where $x$ and $y$ are the quantities of the two tokens in the pool, and $k$ is a constant. The price of one token in terms of the other is determined by the ratio $y/x$.
When a user trades, the quantities $x$ and $y$ change, which must maintain the constant $k$, thus automatically adjusting the price for the next trade.