# Trading and Fees - BNT to TKN

```
Bootstrap requirements met for eth
Bootstrap requirements met for wbtc
Bootstrap requirements met for link
```

# Trading and Fees - BNT to TKN¶

Continuing from the system state described above, the details of how the trading pools are used as a price oracle, the behavior and purpose of the price EMA, and the response of the staking ledger to the accumulation of swap revenue will now be discussed in detail. For the purpose of demonstration, let each of these pools have a 1% swap fee, and a Vortex rate of 20%.

```
v3.describe()
```

bnt | eth | wbtc | link | bnbnt | bneth | bnwbtc | bnlink | ||
---|---|---|---|---|---|---|---|---|---|

Account | Alice | NaN | 0E-18 | NaN | NaN | NaN | 101.000000000000000000 | NaN | NaN |

Bob | NaN | NaN | 0E-18 | NaN | NaN | NaN | 101.000000000000000000 | NaN | |

Charlie | NaN | NaN | NaN | 0E-18 | NaN | NaN | NaN | 10001.000000000000000000 | |

Trader | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | |

Contract | EP Vault | 0 | 0 | 0 | 0 | NaN | NaN | NaN | NaN |

ER Vault | 0 | 0 | 0 | 0 | NaN | NaN | NaN | NaN | |

Master Vault | 60000.000000000000000000 | 101.000000000000000000 | 101.000000000000000000 | 10001.000000000000000000 | NaN | NaN | NaN | NaN | |

Protocol | NaN | NaN | NaN | NaN | 60000.000000000000000000 | 0 | 0 | 0 | |

Pool | a: TKN Staked Balance | NaN | 101.000000000000000000 | 101.000000000000000000 | 10001.000000000000000000 | NaN | NaN | NaN | NaN |

b: TKN Trading Liquidity | NaN | 20.000000000000000000 | 1.250000000000000000 | 3333.333333333333333333 | NaN | NaN | NaN | NaN | |

c: BNT Trading Liquidity | NaN | 20000.000000000000000000 | 20000.000000000000000000 | 20000.000000000000000000 | NaN | NaN | NaN | NaN | |

d: BNT Current Funding | NaN | 20000.000000000000000000 | 20000.000000000000000000 | 20000.000000000000000000 | NaN | NaN | NaN | NaN | |

e: Spot Rate | NaN | 1E+3 | 1.6E+4 | 6.000000000000000000000000000 | NaN | NaN | NaN | NaN | |

f: Average Rate | NaN | 1E+3 | 1.6E+4 | 6.000000000000000000000000000 | NaN | NaN | NaN | NaN | |

g: Average Inverse Rate | NaN | 0 | 0 | 0 | NaN | NaN | NaN | NaN |

Assume a trader swaps 2,000 BNT for LINK; from the perspective of the trader, 2,000 BNT are sent into the vault, and 300 LINK are removed from the vault and sent back to him. The change to the system state is much more involved. The change in the vault balances agrees with the trader; 2,000 BNT is received, and 300 LINK was emitted. However, the change in the available trading liquidity presents the first evidence of a consequence of the new design.

```
v3.create_user('Trader')
v3.set_user_balance(user_name='Trader', tkn_name='bnt', tkn_amt=2000, timestamp=0)
v3.describe(decimals=4)
```

bnt | eth | wbtc | link | bnbnt | bneth | bnwbtc | bnlink | ||
---|---|---|---|---|---|---|---|---|---|

Account | Alice | NaN | 0.0000 | NaN | NaN | NaN | 101.0000 | NaN | NaN |

Bob | NaN | NaN | 0.0000 | NaN | NaN | NaN | 101.0000 | NaN | |

Charlie | NaN | NaN | NaN | 0.0000 | NaN | NaN | NaN | 10001.0000 | |

Trader | 2000.0000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | |

Contract | EP Vault | 0.0000 | 0.0000 | 0.0000 | 0.0000 | NaN | NaN | NaN | NaN |

ER Vault | 0.0000 | 0.0000 | 0.0000 | 0.0000 | NaN | NaN | NaN | NaN | |

Master Vault | 60000.0000 | 101.0000 | 101.0000 | 10001.0000 | NaN | NaN | NaN | NaN | |

Protocol | NaN | NaN | NaN | NaN | 60000.0000 | 0.0000 | 0.0000 | 0.0000 | |

Pool | a: TKN Staked Balance | NaN | 101.0000 | 101.0000 | 10001.0000 | NaN | NaN | NaN | NaN |

b: TKN Trading Liquidity | NaN | 20.0000 | 1.2500 | 3333.3333 | NaN | NaN | NaN | NaN | |

c: BNT Trading Liquidity | NaN | 20000.0000 | 20000.0000 | 20000.0000 | NaN | NaN | NaN | NaN | |

d: BNT Current Funding | NaN | 20000.0000 | 20000.0000 | 20000.0000 | NaN | NaN | NaN | NaN | |

e: Spot Rate | NaN | 1000.0000 | 16000.0000 | 6.0000 | NaN | NaN | NaN | NaN | |

f: Average Rate | NaN | 1000.0000 | 16000.0000 | 6.0000 | NaN | NaN | NaN | NaN | |

g: Average Inverse Rate | NaN | 0.0000 | 0.0000 | 0.0000 | NaN | NaN | NaN | NaN |

```
v3.trade(tkn_amt=2000, source_token='bnt', target_token='link', user_name='Trader', timestamp=0)
v3.describe(decimals=4)
```

bnt | eth | wbtc | link | bnbnt | bneth | bnwbtc | bnlink | ||
---|---|---|---|---|---|---|---|---|---|

Account | Alice | NaN | 0.0000 | NaN | NaN | NaN | 101.0000 | NaN | NaN |

Bob | NaN | NaN | 0.0000 | NaN | NaN | NaN | 101.0000 | NaN | |

Charlie | NaN | NaN | NaN | 0.0000 | NaN | NaN | NaN | 10001.0000 | |

Trader | 0.0000 | NaN | NaN | 300.0000 | NaN | NaN | NaN | NaN | |

Contract | EP Vault | 0.0000 | 0.0000 | 0.0000 | 0.0000 | NaN | NaN | NaN | NaN |

ER Vault | 0.0000 | 0.0000 | 0.0000 | 0.0000 | NaN | NaN | NaN | NaN | |

Master Vault | 62000.0000 | 101.0000 | 101.0000 | 9701.0000 | NaN | NaN | NaN | NaN | |

Protocol | NaN | NaN | NaN | NaN | 60000.0000 | 0.0000 | 0.0000 | 0.0000 | |

Pool | a: TKN Staked Balance | NaN | 101.0000 | 101.0000 | 10003.4242 | NaN | NaN | NaN | NaN |

b: TKN Trading Liquidity | NaN | 20.0000 | 1.2500 | 3033.3333 | NaN | NaN | NaN | NaN | |

c: BNT Trading Liquidity | NaN | 20000.0000 | 20000.0000 | 21995.6044 | NaN | NaN | NaN | NaN | |

d: BNT Current Funding | NaN | 20000.0000 | 20000.0000 | 20000.0000 | NaN | NaN | NaN | NaN | |

e: Spot Rate | NaN | 1000.0000 | 16000.0000 | 7.2513 | NaN | NaN | NaN | NaN | |

f: Average Rate | NaN | 1000.0000 | 16000.0000 | 6.0000 | NaN | NaN | NaN | NaN | |

g: Average Inverse Rate | NaN | 0.0000 | 0.0000 | 0.0000 | NaN | NaN | NaN | NaN |

While the vault balance of BNT was increased by the expected amount, the change in the available trading liquidity is less than this amount. The difference is due to the effect of the Bancor Vortex, which confiscates a portion of trade revenue as a form of insurance premium, that helps to stabilise the BNT economy. In this case, the fee apparent to the trader is 0.303 LINK; the Bancor protocol awards 80% of this amount to LINK liquidity providers (i.e. 0.2424 LINK) by simply iterating the staking ledger. The remaining 0.0606 LINK are used to perform a reverse swap, and purchase BNT atomically at the tail end of the trade. This BNT is removed from the trading liquidity, but it continues to reside in the vault. The fraction of the BNT tokens belonging to the vortex is recorded on the Vortex Ledger; the fate of these BNT tokens is discussed in detail in a later section.

Therefore, during the trade the following components of the system were changed:

The vault balances. The change in the vault is always in agreement with the trader’s intuition. In this case, the trader sent 2,000 BNT into the vault, and received 300 LINK from it. Therefore, the vault balance of BNT must have increased by 2,000 BNT, and decreased by 300 LINK.

The staking ledger. Trading fees are always taken from the target asset. Therefore, the value of the bnLINK pool token must be appreciated by 80% of the fee apparent to the trader (i.e. the total fee - vortex rate). A total of 2.42424 LINK tokens are added to the staked amount, which becomes the property of the bnLINK pool token holders.

The vortex ledger. One fifth of the fee paid by the trader is collected, and swapped back to BNT. The BNT purchased during this step is left where it is inside the vault, and the amount is added to the vortex ledger.

The trading liquidity. After accounting for the effect of the collection by the vortex, and the swap back to BNT, the reason for the changes in the trading liquidity to appear as they do, become apparent.

The change in the BNT and LINK trading liquidity can be expressed as follows:

where a1† and a1 are the BNT trading liquidity balances of the pool after and before the trade, respectively, b1† and b1 are the LINK trading liquidity balances of the pool after and before the trade, respectively, d1 is the pool fee (e.g. 0.01, or 1%) and e is the Vortex rate (e.g. 0.2, or 20%). The number of BNT tokens being sent into the vault is x, and the number of LINK tokens sent back to the trader is tknOut. The change in the TKN trading liquidity (and therefore the amount of TKN received by the trader) is unchanged from the standard case. The calculation of the fee awarded to liquidity providers, denominated in its own TKN and added to the staking ledger is:

And the calculation for the fee given to the Bancor Vortex, denominated exclusively in BNT and added to the vortex ledger is: