Hi All,

I have a quick question on DEX liquidity algorithms. For example, let’s say I create an ASA called EXP with 100 total tokens. I add the 100 EXP to a DEX liquidity pool with 100 USDC. This gives 1 EXP a price of 1 USDC and EXP has a total market cap of ~$100.00.

If Bob wants to buy 1 EXP, it should cost him about 1 USDC. This would be probably be about right with a relatively small transaction in the pool. But, let’s say Bob wants to buy 90 EXP, which would be a much larger transaction in the pool. My intuition is if Bob goes to swap 90 USDC to the EXP/USDC pool, he will not get 90 EXP in return. It will probably be less than that. Either way, the resulting EXP/USDC pool will have 190 USDC and `X`

EXP. But, I am not sure how the exact calculation is made or how to solve for `X`

.

What is the general algorithm that determines the swap ratio for assets in DEX liquidity pools? Are there any examples of this in open source code for Algorand DEXs?

Thanks!

Brian