The trade is calculated using the formula X*Y=K, wherever X and Y are classified as the quantities of each asset and K is a predefined consistent.
An case in point flash swap agreement that withdraws ERC20 tokens, https://uniswapv3login.azurewebsites.net/