@jmharvey lets plug into some examples.
If the market has 100-A coins, and 100 B coins.
I want to buy 20 B coins.
(100 - 20) * (100 + Cost) = 100 * 100
100 + Cost = 10000/80
Cost = 125 - 100
Cost = 25
So I would pay 25 A coins to buy 20 B coins.
Uniswap has no order book. So lets say I wanted to buy 1000 B coins, and I was willing to pay 5 A coins to get 4 B coins.
I would have to make an on-chain tx to buy 20 B coins.
Then wait for someone else to make the opposite trade so the price goes back.
Then I make an on-chain tx to buy 20 more B coins.
Then I wait for someone to make the opposite trade.
And this cycle would continue until each of use has done 50 on-chain txs.
So in this example, assuming I am willing to pay 20% above market price to buy B coins, it only takes 50 on-chain txs to make the purchase.
Now lets consider the case where I am not willing to over pay by such a large amount.
if I buy only 10 B coins per round.
(100 - 10)*(100 + cost) = 10000/
cost = (1000/9)-100
cost = 11.1
So in this case I am only over-paying by 11%. And it would take 100 on-chain txs to make the complete purchase.
In practice, traders are usually unwilling to pay even 1% fee.
So lets try to get a generalized formula out of this.
If the on-chain locked up liquidity is L.
And I am willing to over-pay by P.
and I want to buy B many coins.
the number of on-chain txs is T.
L*P ~= amount purchased per tx.
T = B/(amount purchased per tx)
T = B/(L*P)
So if you want to buy $10 000 of something in 1 tx, and you are only willing to over-pay by 1%, then uniswap would need around $1 000 000 locked up.
Having lots of money locked up in the contract is expensive by the interest rate. Especially since uniswap is using low market cap subcurrencies.