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.