Trading and Fees - TKN to BNT

Bootstrap requirements met for eth
Bootstrap requirements met for wbtc
Bootstrap requirements met for link
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 0E-18 NaN NaN 300.000000000000000000 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 62000.000000000000000000 101.000000000000000000 101.000000000000000000 9701.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 10003.424242424242424242 NaN NaN NaN NaN
b: TKN Trading Liquidity NaN 20.000000000000000000 1.250000000000000000 3033.333333333333333333 NaN NaN NaN NaN
c: BNT Trading Liquidity NaN 20000.000000000000000000 20000.000000000000000000 21995.604395604395604396 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 7.251298152397053495955522121 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

Trading and Fees - TKN to BNT

Assume now that a trader wants to perform the opposite action, perhaps to close an arbitrage opportunity left open by the previous swap. The trader sends 302.9981 LINK into the vault, and the vault sends 1977.6155 BNT to the trader. As before, the trader’s intuition agrees with the changing state of the vault balances; however, the changes in the trading liquidity and staked balances require closer examination.

v3.trade(tkn_amt=302.9981, source_token='link',  target_token='bnt', 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 1977.6153 NaN NaN -2.9981 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 60022.3847 101.0000 101.0000 10003.9981 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 3336.3314 NaN NaN NaN NaN
c: BNT Trading Liquidity NaN 20000.0000 20000.0000 20013.9939 NaN NaN NaN NaN
d: BNT Current Funding NaN 20000.0000 20000.0000 20015.9807 NaN NaN NaN NaN
e: Spot Rate NaN 1000.0000 16000.0000 5.9988 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

In this trade, the target asset is BNT. Therefore, there is no need to perform a second, virtual swap at the end of the trade. Instead, the vortex fee is taken directly from the effective fee. Importantly, this results in a slightly reduced change in the growth of the BNT trading liquidity as judged from the trader’s perspective. The trader’s fee totals 19.9759 BNT, of which 3.9952 BNT becomes the property of the Bancor Vortex. The difference (15.9807 BNT) is added to the BNT staking ledger, and causes the value of the bnBNT pool token to appreciate.

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

  1. The vault balances. The change in the vault is always in agreement with the trader’s intuition. In this case, the trader sent 302.99814 LINK into the vault, and received 1977.615545 BNT from it. Therefore, the vault balance of LINK necessarily increased by 302.99814 LINK, and decreased by 1977.615545 BNT.

  2. The staking ledger. Trading fees are always taken from the target asset. Therefore, the value of the bnBNT pool token must be appreciated by 80% of the fee apparent to the trader (i.e. the total fee - vortex rate). A total of 15.980731 BNT tokens are added to the staked amount, which becomes the property of the bnBNT pool token holders (at this point in the narrative, is the protocol only).

  3. The vortex ledger. A portion of the fee paid by the trader is effectively collected, and added to the vortex ledger.

  4. The trading liquidity. The apparent disagreement between the intuitive result, and the one obtained, is accounted for by the effect of the BNT collection by the vortex.

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 LINK tokens being sent into the vault is x, and the number of BNT tokens sent back to the trader is bntOut. The change in the TKN trading liquidity (and therefore the update to the available LINK trading liquidity) is unchanged from the standard case. The calculation of the fee awarded to liquidity providers, denominated in BNT 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: