LogoLogo
  • Learn about Balancer
  • Background
    • Team Goal
  • Fundamentals
    • White Paper
      • The Value Function
        • USDC WETH WBTC 33/33/33
        • BAL WETH 80/20
        • Price Change Proof
      • Spot & Effective Price
        • Spot Price
        • Effective Price
        • Price Impact
        • Price Impact - With Swap Fees
      • Trading Formulas
        • Out-Given-In
          • Including Swap Fees
        • In-Given-Out
          • Including Swap Fees
        • In-Given-Price
          • In-Given-Price Proof
          • Arbitrage 80/20
          • Arbitrage 50/50
        • Summary
      • Deposits & Withdrawals
        • Deposits
          • Proportional Deposits
            • BAL / WETH 80/20
          • Single Sided Deposits
            • Price Impact; 10,000 BAL
            • Price Impact; 100,000 BAL
          • Multi-token Deposits
            • Price Impact WMATIC / MTA / WETH
            • Price Impact [2] WMATIC / MTA / WETH
        • Withdrawals
          • Proportional Withdrawals
            • BAL/WETH 80/20
          • Singled Sided Withdrawals
            • Withdrawal Price Impact
    • Impermanent Loss
      • 50/50 Pools
      • 80/20 Pools
      • Multi-token Pools
    • veBAL Tokenomics
      • TLDR
      • Vote-Escrowed Governance
      • Financial Implications
        • Boosting BAL Incentives
          • Minimum veBAL for Max Boost
          • Maximum Boost
          • Calculating my Boost
          • Boost Delegation for Contract Wallet
        • Protocol Revenue Distribution
        • Gauge Voting
      • Inflation Schedule
      • veBAL FAQ
  • More Information
    • For Developers
      • GitHub Integration
    • For Support
    • References & Related Content
  • Documented Questions
    • Coming soon
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Fundamentals
  2. White Paper
  3. Trading Formulas
  4. In-Given-Price

In-Given-Price Proof

In-Given-Price-Proof - Please note the prerequisites of the spot price function and In-Given-Out Equations.

PreviousIn-Given-PriceNextArbitrage 80/20

Last updated 3 years ago

Was this helpful?

In-Given-Price Proof:

  1. Firstly, we must site the spot price function:

SPio=BiWiBoWoSP_{i}^{o}={\frac {\frac {B_{i}}{W_{i}}}{\frac {B_{o}}{W_{o}}}}SPio​=Wo​Bo​​Wi​Bi​​​

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:

SPi′o=Bi+AiWiBo−AoWoSP_{i}^{'o}={\frac {\frac {B_{i}+A_{i}}{W_{i}}}{\frac {B_{o}-A_{o}}{W_{o}}}}SPi′o​=Wo​Bo​−Ao​​Wi​Bi​+Ai​​​

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:

Ai=Bi ∗ ((BoBo−Ao)WoWi−1)A_{i} = B_{i} \ * \ \Bigg(\bigg({\frac {B_{o}}{B_{o}-A_{o}}}\bigg)^{{\frac {W_{o}}{W_{i}}}}-1\Bigg)Ai​=Bi​ ∗ ((Bo​−Ao​Bo​​)Wi​Wo​​−1)

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: