Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Proportional deposits will yield newly minted Balancer Pool Tokens (BPT) for an investor. This function essentially states that the if the proportional amounts of all tokens deposited (Dk) in relation to the Balance of that given token (Bk) will yield that amount of the new total supply of pool tokens. The example in the whitepaper states that depositing 10% of each of the existing tokens in the pool an investor will receive 10% of the current BPT supply.
Equation:
Sample calculation:
Arbitrarily we will assume we are depositing 15% of the total balance meaning Dk divided by Bk will be 0.15
We will assume our total supply to be 10,000 BPTs at this time for the sake of simplicity. From here can make the following calculations:
Substituting 0.15 for our deposit over balance ratio and 10,000 for the supply value we can solve for the issued amount of pool tokens.
This shows that using the formula, based upon the number of tokens we deposit into a pool based upon the balance already we present we will be awarded a proportional number of pool tokens. These pool tokens are a user’s way to redeem their assets when the pool is exited.
This section will breakdown the three core cases of asset deposits on Balancer Protocol.
Balancer Protocol allows users to invest in pools in a variety of ways. Proportional deposits yield no price impact and follow the ratios the pool is already in.
Single Sided Deposits permit users to deposit into a pool with only one of the assets. A price impact due to shifting the internal relationship of the tokens will be accounted in this scenario.
Multi-token Deposits are when a user deposits the tokens they have in an unproportional way. Not a single asset but multiple in a non-proportionate way.
See examples of each deposit type in the following pages:
How does a single sided deposit work?
The pool tokens issued to a depositor of a single asset can be determined by utilizing the change in the value function (invariant) of the pool. As seen in the whitepaper the ratio of the change in the value function will yield the number of tokens issued. This information will become even more important when discussing multi-asset deposits:
This can be simplified for our purpose of a single sided deposit where all other tokens in a pool maintain constant balances. The token which we are investing into a pool will be denoted with the letter “t”. Amount in (At), Balance-In (Bt), Weight-In (Wt) and the pool token supply will be the variables in concern. When simplified the equation is as follows:
An example of a proportional Deposit into the BAL/WETH 80/20 liquidity pool
At the time of writing the BAL / WETH 80/20 pools has the following traits:
Swap fee: 0.05%
BAL: 5,682,882
WETH: 6,232.9054
BPT: 2,891,832.103892
Let’s assume we want to invest 500 BAL, and proportionally this would prompt us to invest 0.548393 WETH to maintain the pool balance (see The Value Function section for reference). We know our amount in and balance in of each token. The ratio of Dk over Bk will be the same regardless of which token is chosen in proportional investments and withdrawals:
See the BAL/WETH 80/20 Withdrawal Section to see that this transaction is reversible.
Pool token spot price (Assume A(t) = 1 BAL):
Then, we must calculate the ratio of the pool’s invariant before and after the exchange of 100,000 BAL.
Using the invariant ratio, we can determine the new total number of pool tokens and in the same stroke, calculate the amount of pool tokens which we received for the exchange.
Knowing the amount of BAL, we needed to invest and the pool tokens we received in exchange we can determine the effective price of a pool token to compare with our spot price:
Two examples of calculating price impact with the incorporation of swap fees in single asset deposit scenarios.
Now let’s assume we are depositing into the BAL/WETH 80/20 Pool with 10,000 BAL and no WETH. We will be charged swap fees on the portion of our investment which is “off-balance”. In this case 20% of our pool is not in the form of BAL, therefore that is the taxed portion. As referenced from the trading with swap fees section.
The calculation follows as:
The current pool traits are as follows:
Swap fee: 0.05%
BAL: 5,691,640
WETH: 6,194.1921
BPT: 2,891,789.44800306
Using the known amount for A(t) we can calculate the amount of pool tokens we will be issued for this deposit.\
We can see on the user interface completing this transaction will yield a price impact of 0.03% (0.18% for the larger interaction). What exactly does this mean for an investor? Well in short from price impact for trading we can note that the ratio between assets change as supply and demand shifts during an exchange. In this case we are essentially exchanging BAL for Pool tokens and in doing so Pool tokens are becoming more expensive in reference to BAL. This is a bit more complex than comparing prices of individual assets in a pool, but we will focus on the current example to start. The spot price of a pool token and effective price of a pool token are the variables we need to calculate to determine our price impact from an investment.
Pool token spot price (Assume A(t) = 1 BAL):
Next, we must calculate the ratio of the pool’s invariant before and after the exchange of 10,000 BAL.
Using the invariant ratio, we can determine the new total number of pool tokens and in the same stroke, calculate the amount of pool tokens which we received for the exchange.
Knowing the amount of BAL, we needed to invest and the pool tokens we received in exchange we can determine the effective price of a pool token to compare with our spot price:
Multi-token deposits encompass the single sided deposit knowledge base and emphasize how Balancer Protocol's invariant and swap fees are incorporated in complex scenarios.
Balancer Protocol has several features which differentiate it from all other core AMM platforms such as Uniswap and Curve. The one of focus in this section is the multi-token pools and the layer of complexity they add to the calculation of price impact, and ultimately disproportionate asset deposits.
Withdrawals only support proportional or single sided options in the current state; therefore, a single sided example will be solved. The principles defined in the proportional and single sided sections will be building blocks for the examples solved here.
For both examples we will utilize the WMATIC MTA WETH 40/40/20 Pool on Polygon as it highlights uneven weightings of assets as well as the multi-token aspects, we are interested in.
Here we will solve two examples using the pool above, weights are 40%, 40%, and 20% respectively.
Pool traits at the time of writing:
Swap fee: 0.25%
WMATIC: 273,763
MTA: 1,023,625
WETH: 66.0812
Total BPT: 249494.507172
For this example, we will choose to deposit 1,000 WMATIC and 2 WETH without altering the total MTA within the pool. Our alternate example will use a deposit of 10,000 WMATIC and 2 WETH to solidify understanding in a slightly more complex scenario. These instances are referenced below.
Firstly, we will determine our spot prices of each token in terms of 1 BPT. This can be done using the reciprocal of the redemption function most conveniently, making our input 1 BPT. We will do this for WMATIC and for WETH.
WMATIC
WETH
Next, we can determine the amount of BPT our investments would be worth based upon the spot price, this assumes zero price impact is occurring and sets our base case.
From here we must determine what value of our BPT are disproportionate from the ratios of the pool for an evenly distributed deposit this can be done simply by multiplying the Total BPT by the weight of each token as follows.
Using these values, we can determine how much of the total swap fee will be paid for each single token deposited. If our Base Value deposit for any token in BPT exceeds the Proportionate BPT deposit value, a swap fee will be implemented on the excess portion.
For example, because we deposited a Base Value of 364.5419683 BPT in WMATIC and the proportional deposit is 749.9135826 no swap fee will be implemented on the 1,000 WMATIC which were deposited. These will be crucial in determining our invariant ratio after the swap.
In the case of WETH our Base Value is 1510.241988 BPT, and proportional deposit is only 374.9567913 BPT. This yields the following calculation for a taxable amount:
Lastly, we must calculate our initial and post deposit invariant with fees to determine our net BPT and price impact based on the base case.
Our invariant ratio, multiplied by the initial total pool tokens, will yield the total pool tokens and therefore the amount which we will receive during our deposit. This value in comparison with our Base Case will determine our price impact.
This example shows an increase in WMATIC only which evens out the ratios of deposit compare to the previous Multi-token example. Notice the decrease in price impact as the ratio is better managed.
Pool traits at the time of writing:
Swap fee: 0.25%
WMATIC: 273,763
MTA: 1,023,625
WETH: 66.0812
Total BPT: 249494.507172\
The changes from the previous example will be notably base value of 10,000 WMATIC in BPT changing the calculations that follow.
The new Base Total BPT will change the proportional values as shown below.
In this case both of our Base Values for WMATIC and WETH are greater than the proportional values for an evenly distributed despot. This means that both deposits will be taxable in terms of the swap fee.
WMATIC
WETH
Finally, we can utilize these values to compare the invariant ratios between the initial and the after-swap fees are paid. This will determine the BPT we receive as opposed to what we would without any change in spot price.
Our invariant ratio, multiplied by the initial total pool tokens, will yield the total pool tokens and therefore the amount which we will receive during our deposit. This value in comparison with our Base Case will determine our price impact.