Single Sided Withdrawals will follow the same principles laid out in the single sided deposit section prior. The invariant is the core of these transactions and resulting equations are derived from there. As seen in the whitepaper the ratio of the change in the value function will yield the number of tokens redeemed.
This can be simplified for our purpose of a single sided withdrawal where all other tokens in a pool maintain constant balances. The token which we are removing from a pool will be denoted with the letter “t”. Amount Out (At), Balance-Out (Bt) before the transaction, Weight-Out (Wt) and the pool token supply will be the variables in concern. When simplified the equation is as follows:
Now let’s assume we are withdrawing from the BAL/WETH 80/20 Pool, we want to remove 5 WETH from the pool not knowing how many pool tokens we will need to redeem. We will be charged swap fees on the portion of our withdrawal which is “off-balance”. In this case 80% of our pool is not in the form of WETH, therefore that is the taxed portion. In this case we know we will receive the total of 5 WETH from the withdrawal, (At), this means our “sent” value will be unknown and slightly higher to compensate the swap fee we are charged.
The current pool traits are as follows:
Swap fee: 0.05%
BAL: 5,598,984
WETH: 5,798.4836
BPT: 2,816,401.77912812
This equation can be rearranged to solve for A (sent) in terms of our BPT (P_redeemed) as follows:
Using this equation, we can solve for A (sent):
For our Spot Price:
From here we can calculate the amount of pool tokens we redeemed to receive our 5 WETH:
Then, we must calculate the ratio of the pool’s invariant before and after the withdrawal.
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 needed to exchange for our WETH.
Knowing the amount of BPT we needed to redeem and the amount of WETH we received in the withdrawal we can determine the effective price of a pool token to compare with our spot price:
Please note the swap fee and pool traits change dynamically over time making calculations such as these valid for only a short period of time. The purpose of these examples is to deepen the understanding of our platform for those interested in are already utilizing Balancer Protocol.
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
Under the same conditions shown in the deposit example we will determine the amount of each token we would receive if we redeemed the 254.433587 pool tokens we were issued. The amount we receive should be the same as we would invest for the issued amount because the pool traits are constant in this example.
This solidifies the premise of accounting for the pool issuing and redeeming pool tokens Given the pool traits the minting or burning (investment or withdrawal) of pool tokens will respect the ratios of the balances within the pool and the percentage of total pool tokens.
The opposite operation is needed to calculate the amount of each token remove from a pool upon withdrawing. The value we calculate will correlate to the balances of the tokens within the pool. Given any pool an investor may have funds in, they can determine the tokens they will receive as a % of the token balances.
Equation:
The Balance term (Bk) will vary for every pool and each token within a pool however the portion of each balance an investor is entitled to is related to their share of the pool in reference to pool tokens always.
As the external market prices of assets change the balances of tokens will fluctuate due to trading. The portion of the pool owned by an investor can only be changed as investors enter and exit the pool. For example, you may own 10% of a pool and after a few months as more people invest you now own 4% due to total supply of tokens increasing.
Assuming our previous example where we hold 1,500 pool tokens let’s assume the pool, we invested in has attracted far more liquidity. Now the total supply is at 25,000 pool tokens. Let’s calculate the number of tokens we will receive when we redeem our BPTs.
Using the expression above we know that given the current balances of each asset in the pool (Bk) we will receive 6% of each token in our wallet upon redemption. These examples may be simple in nature but, coupled with swap fees, they are the first building block towards understanding the complexity of single of mixed asset deposits and withdrawals.
This section will breakdown the two core cases of asset withdrawals on Balancer Protocol.
Balancer Protocol allows users to redeem their investments from pools in a two possible ways. Proportional withdrawals yield no price impact and follow the ratios the pool is already in.
Single Sided withdrawals permit users to withdraw from a pool in the form of only one of the assets. A price impact due to shifting the internal relationship of the tokens will be accounted in this scenario.
See examples of each withdrawal type in the following pages: