BSC protocol is based on the βConstant Productβ formula: xβy=k where x and y are reserve balances, and k is the invariant that remains unchanged during the trading operation. This formula underlies how the exchange price is calculated.
For example, the case where the initial reserves are x of token AAA and y of token BBB and the user sells aaa of token AAA. If no fees are charged, then the received amount of b is:
{xβy=k(x+a)β(yβb)=kβxβy=(x+a)β(yβb)xβy=xβy+aβyβbβ(x+a)bβ(x+a)=aβyb=aβy/(x+a) Then the price is p=(x+a)/y tokens AAA per token BBB. With fee charge things will be slightly different:
{xβy=k(x+0.997βa)β(yβb)=kβxβy=(x+0.997βa)β(yβb)xβy=xβy+0.997βaβyβbβ(x+0.997βa)bβ(x+0.997βa)=0.997βaβyb=0.997βaβy/(x+0.997βa) The price is then p=(x+0.997a)/(0.997y) tokens AAA per token BBB. The fee goes to the pool, increases the reserves, and thereby increases the k invariant. It entails the growth of the value underlying each share and becomes the source of LP providers' gains.
If price altering results in significant differences between internal and external market prices, arbitrage opportunities will push the price back to the rational value.