In-Given-Price
Another approach or thought process that can be used between pools as opposed to increasing swap fees to make all pools equal in spot price, is the potential for arbitrage trading. Arbitrage trading is when a trader buys for example the excess BAL from the 80/20 pool and then sells it to the open market. If a large enough gap in price exists, then this will become an efficient transaction, after fees including gas payments are considered. Therefore, an arbitrager can make a profit by balancing out the spot prices of two sources.
The formula for the number of tokens traded to create the intended shift of this type of trading is defined in our whitepaper. A very important note here is the assumption that market depth is infinite for the new spot price. This will be elaborated on throughout the example.
In-Given-Price formula:
The additional variables are defined as follows:
For a further description on Spot Price and how it is calculated please refer to The Value Function and Spot Price sections of our documentation.
In-Given-Price-Proof - Please note the prerequisites of the spot price function and In-Given-Out Equations.
In-Given-Price Proof:
Firstly, we must site the spot price function:
2. Secondly, to consider the desired spot price (SP’) we must acknowledge that the Balance-In (Bi) and the Balance-Out (Bo) will be altered based on the Amount-In (Ai) and Amount-Out (Ao) as so:
3. The original spot price can be rearranged to isolate the Balance-Out (Bo):
4. The adjusted spot price equation (SP’) can be arranged to isolate Balance-Out minus the Amount-Out (Bo – Ao) as follows:
5. . Using these equations for substitution in our In-Given-Out equation below we can prove the In-Given-Price Equation is valid:
First, we replace the Balance-Out and Balance-Out minus Amount-Out statements with our equations from steps 3 and 4.
At this point the Weights-In and Weights-Out will neutralize one another reducing our equation size, once this is done the next step is to rationalize our fraction:
Now we need to isolate the spot price ratio to remove the Balance-In (Bi) and Amount-In (Ai) from our inner function:
We will move our exponent to the opposite side of the equation and then adjust our ratio of Balance-In over Balance-In minus Amount-In
Now using this adjusted ratio, we can multiply both sides of the equation by Amount-In, Balance-In portion combining the two terms and have the fraction of SP’ and SP on the right side of our equation as shown below:
By adjusting the exponents and reverting the bulk of our equation to the right side again we can solve for the Amount-In as intended for the In-Given-Price Equation:
80/20 BAL/ WETH Pool In-Given-Price problem and solution
Example
We will utilize our 80/20 BAL / WETH pool (0.05% Swap fee) as a benchmark and will assume the external market spot price to be 0.00455 WETH / BAL. Please note this market for the purpose of the example is considered infinite in depth. This means as we sell our tokens, the price is not impacted.
If the trade was occurring from one pool to another further optimization would be done to justify our swap. The method would then also consider the impact of the arbitrage opportunity on the second market we interact with.
Pool (Wo / Wi) | WETH Balance (Bi) | BAL Balance (Bo) |
---|
50/50 BAL/ WETH Pool In-Given-Price problem and solution
Alternate Example:
We will utilize our 50/50 BAL / WETH pool (0.1% Swap fee) as a benchmark and will assume the external market spot price to be 0.0048 WETH / BAL. Please note this market for the purpose of the example is considered infinite in depth. This means as we sell our tokens, the price is not impacted.
In comparison to our previous example, the following pool is much less deep in terms of total liquidity. Due to the lack of depth, we can expect to create a larger price impact using lower amounts of capital.
Pool (Wo / Wi) | WETH Balance (Bi) | BAL Balance (Bo) |
---|
80/20 | 6,005.3009 | 5,315,514 |
50/50 | 135.9922 | 30,158 |