# Balancer Pool Token(BPT) fair pricing
###### tags: `DeFi` `Balancer`
The invariant of a typical balancer pool is:
$$
V = \prod_{1}^{n} B_{i}^{W_{i}}
$$
where
$n$ is the number of tokens in the pool, e.g., 2 for BAL(80%)-ETH(20%) pool;
$B_{i}$ is the balance of token i in the pool;
$W_{i}$ is the normalized weight of token i in the pool
To calculate *the fair pricing* of BPT token, we need to get the *invariant* of the pool and *fair token price* from reliable feeds like chainlink
1. Get Invariant from pool: `V = pool.getInvariant()`
2. Get fair prices from reliable feeds:
$P_{i}$ is the fair USD price of token i
$P_{i/j} = \frac{P_{i}}{P_{j}}$ is the fair relative price of token i in units of token j
3. Calculate fair balances in the pool using *invariant, fair prices and the balancer pool mechanism* (which basically says that the **value weight ratio should keep the same** across swaps for a balance pool):
$\frac{W_{1}}{W_{2}} = \frac{B_{1Fair} * P_{1/2}}{B_{2Fair}}$
$\Rightarrow B_{2Fair} = \frac{W_{2}}{W_{1}} * B_{1Fair} * P_{1/2}, B_{1Fair} = \frac{W_{1}}{W_{2}} * \frac{B_{2Fair}}{P_{1/2}}$
$V = B_{1Fair}^{W_{1}} * B_{2Fair}^{W_{2}} \Rightarrow V = B_{1Fair}^{W_{1}} * B_{1Fair}^{W_{2}} * P_{1/2}^{W_{2}} * (\frac{W_{2}}{W_{1}})^{W_{2}} = B_{1Fair} * P_{1/2}^{W_{2}} * (\frac{W_{2}}{W_{1}})^{W_{2}} = \frac{B_{2Fair}}{P_{1/2}^{W_{1}}} * (\frac{W_{1}}{W_{2}})^{W_{1}}$
$\Rightarrow B_{1Fair} = \frac{V}{P_{1/2}^{W_{2}}} * (\frac{W_{1}}{W_{2}})^{W_{2}}, B_{2Fair} = V * P_{1/2}^{W_{1}} * (\frac{W_{2}}{W_{1}})^{W_{1}}$
4. Calculate the BPT price using fair balances:
$P_{bpt} = \frac{B_{1Fair} * P_{1} + B_{2Fair} * P_{2}}{totalSupply}$
$\frac{P_{bpt}}{P_{2}} = \frac{B_{1Fair} * P_{1/2} + B_{2Fair}}{totalSupply} = \frac{V * P_{1/2}^{W_{1}}}{totalSupply} * \frac{1}{W_{1}^{W_{1}} * W_{2}^{W_{2}}}$