Trading and Fees - TKN to TKN

Bootstrap requirements met for eth
Bootstrap requirements met for wbtc
Bootstrap requirements met for link
v3.describe()
Trading Liquidity Vault Staking ERC20 Contracts Vortex External Protection Protocol WalletState
0 bnt=20000.000000 eth=20.000000 bnt=22.384703 bnt=15.980730 bnbnt=0.000000 bnt=8.390787 bnt=0.000000 bnbnt=20000.000000
1 bnt=20000.000000 wbtc=1.250000 eth=101.000000 eth=101.000000 bneth=101.000000 eth=0.000000
2 bnt=20013.993917 link=3336.331433 wbtc=101.000000 wbtc=101.000000 bnwbtc=101.000000 wbtc=0.000000
3 link=10003.998100 link=10003.424242 bnlink=10001.000000 link=0.000000

Trading and Fees - TKN to TKN

Assume now that a trader wishes to exchange 1 ETH for wBTC. From their perspective the process is similar to that described above. A total of 1 ETH tokens are sent into the vault, and the vault sends 0.055712824 wBTC tokens back, and the change in the vault balances agree with the trader’s intuition (as before). However, this situation compounds the effects described in the previous two sections. The changes in the trading liquidity balances, and the accumulation of value to the vortex ledger, can be deduced by considering the two separate legs of the process:

  1. Swap 1 ETH for 942.857143 BNT

    • Add 7.619047619 BNT to the staking ledger

    • Add 1.904761905 BNT to the vortex ledger

  2. Swap 942.857143 BNT for 0.055712824 wBTC

    • Add 0.000450205 wBTC to the staking ledger

    • Add 1.973681795 BNT to the vortex ledger

v3.trade(tkn_amt=1, source_token='eth',  target_token='wbtc', user_name='Trader', timestamp=0)

v3.describe(decimals=4)
Trading Liquidity Vault Staking ERC20 Contracts Vortex External Protection Protocol WalletState
0 bnt=19055.2381 eth=21.0000 bnt=22.3847 bnt=23.5998 bnbnt=0.0000 bnt=12.2692 bnt=0.0000 bnbnt=20000.0000
1 bnt=20940.8835 wbtc=1.1943 eth=102.0000 eth=101.0000 bneth=101.0000 eth=0.0000
2 bnt=20013.9939 link=3336.3314 wbtc=100.9443 wbtc=101.0005 bnwbtc=101.0000 wbtc=0.0000
3 link=10003.9981 link=10003.4242 bnlink=10001.0000 link=0.0000

It is important to realize that there is no BNT transfer, despite both pools reporting a change to the BNT trading liquidity. A virtual trade has been performed, where BNT is still used as numeraire, and which allows for the relative value of ETH and wBTC to be known. Since the liquidity pools are virtual, their relative balance of BNT can be adjusted as though the tokens were sent, when in fact the BNT remains where it was in the vault. Thus, a quasi-single hop trade is achieved.

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 1 ETH into the vault, and received 0.055712824 wBTC from it. Therefore, the vault balance of ETH must have increased by 1 ETH, and decreased by 0.055712824 wBTC.

  2. The staking ledger. Trading fees are always taken from the target asset, in this case there are two:

  3. The first virtual trade to BNT, resulting in a 7.619047619 increase to the BNT staked balance.

  4. The second virtual trade, resulting in a 0.000450205 increase to the wBTC staked balance.

Therefore, the value of the bnBNT pool token, and wBTC pool token must be appreciated by 80% of the fee apparent to the trader (i.e. the total fee - vortex rate).

  1. The vortex ledger. Both virtual trades have an apparent effect on the vortex ledger. In the first virtual trade to BNT, one fifth of the fee paid by the trader is collected by the vortex directly; in the second virtual trade, one fifth of the fee in wBTC is swapped back to BNT. Both are added to the BNT balance of the vortex ledger.

  2. The trading liquidity. The changes to the trading liquidities on both pools can be understood after accounting for the effect of the collectionby the vortex.

The change in the BNT, ETH, and wBTC trading liquidity can be expressed as follows:

where a1† and a1 are the BNT trading liquidity balances of the source pool (BNT-ETH) after and before the trade, respectively, b1† and b1 are the TKN trading liquidity balances of the source pool (BNT-ETH) after and before the trade, respectively, a2† and a2 are the BNT trading liquidity balances of the destination pool (BNT-wBTC) after and before the trade, respectively, b2† and b2 are the TKN trading liquidity balances of the destination pool (BNT-wBTC) after and before the trade, respectively, d1 is the source pool fee (BNT-ETH, e.g. 0.01, or 1%), d2 is the destination pool fee (BNT-wBTC, e.g. 0.01, or 1%), and e is the Vortex rate (e.g. 0.2, or 20%). The number of ETH tokens being sent into the vault is x, and the number of wBTC tokens sent back to the trader is tknOut. The change in the ETH trading liquidity (and therefore the update to the available ETH trading liquidity) is unchanged from the standard case. The calculation of the fee awarded to the bnwBTC, and bnBNT pool token holders is:

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