In-Given-Out

In-Given-Out

The In-Given-Out equation will be the opposite thought process as the Out-Given-In formula. The idea is a trader, you, or I, wants to receive a specific number of tokens and this equation will solve how many tokens need to trade into a pool to receive that amount out. Note the variables defined in the introduction have not changed.

For example, we will determine which of two pools is best to trade USDC for WMATIC on Balancer’s Polygon network pools. We will examine the two following pools TEL/WMATIC/USDC 60/20/20 (0.2%) and the WMATIC/USDC/WETH/BAL 25/25/25/25 (0.25%) pools.

Firstly, let us see what it will cost us to receive 1000 WMATIC as the amount we know we want out of our trade.

TEL/USDC/WMATIC 60/20/20:

WMATIC/USDC/WETH/BAL 25/25/25/25:

In the case we will spend less using our second option to receive the same amount of WMATIC making it the more desirable pool for the SOR to route us through. Now let’s incorporate swap fees.

Last updated