**How are prices determined?**

Prices for tokens are determined by the liquidity pool for each token pair. Each liquidity pool is a smart contract that holds balances of the two tokens and enforces the rules around deposits and withdrawals, using the constant product formula (x*y=k) where k is a constant. Whenever a token is withdrawn from a pool, the constant must remain, and therefore an amount of the other token must be deposited. The ratio of the tokens in the pool in relation to the constant product formula determines the price of any swap.

**Pricing Trades**

Anyone who swaps naturally wants to receive the maximum amount of output tokens as possible for an exact input amount or to pay as little input tokens as possible for an exact output amount of tokens. The contract must look up the current deposits of the pairs to understand what the price is relative to the pool and the ratios. There are no external pricing oracles. There is a cost of manipulating the price for a specific time period, which, over time, costs more for the manipulation than the value at stake. Other factors can also reduce the cost of such an attack, such as network congestion & gas fees.