From 9f9219cdf06e4a602ce7060350ee391eb5055a10 Mon Sep 17 00:00:00 2001 From: mikewcasale Date: Fri, 16 Sep 2022 09:45:28 -0700 Subject: [PATCH 1/5] Create User Actions and State Transition Functions - (pt 1 of 4).ipynb - Notebook with code discussed during session 3 of the simulator tutorial series on Discord. --- ...e Transition Functions - (pt 1 of 4).ipynb | 4681 +++++++++++++++++ 1 file changed, 4681 insertions(+) create mode 100644 examples/artifacts/User Actions and State Transition Functions - (pt 1 of 4).ipynb diff --git a/examples/artifacts/User Actions and State Transition Functions - (pt 1 of 4).ipynb b/examples/artifacts/User Actions and State Transition Functions - (pt 1 of 4).ipynb new file mode 100644 index 0000000..da22b7d --- /dev/null +++ b/examples/artifacts/User Actions and State Transition Functions - (pt 1 of 4).ipynb @@ -0,0 +1,4681 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 70, + "metadata": {}, + "outputs": [], + "source": [ + "from bancor_research.bancor_simulator.v3.spec.state import *\n", + "from bancor_research.bancor_simulator.v3.spec.network import BancorDapp" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
bntethlinktknwbtcbnbntbnethbnlinkbntknbnwbtcvbnt
2Poola: TKN Staked Balance00000000000
b: TKN Trading Liquidity00000000000
c: BNT Trading Liquidity00000000000
d: BNT Current Funding00000000000
e: Spot Rate00000000000
f: Average Rate00000000000
g: Average Inverse Rate00000000000
3NetworkBNT Staked Balance00000000000
Master Vault00000000000
Protection Vault00000000000
Protocol Equity00000000000
Rewards Vault00000000000
\n", + "
" + ], + "text/plain": [ + " bnt eth link tkn wbtc bnbnt bneth bnlink \\\n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 0 0 0 \n", + "\n", + " bntkn bnwbtc vbnt \n", + "2 Pool a: TKN Staked Balance 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 \n", + " d: BNT Current Funding 0 0 0 \n", + " e: Spot Rate 0 0 0 \n", + " f: Average Rate 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 \n", + " Master Vault 0 0 0 \n", + " Protection Vault 0 0 0 \n", + " Protocol Equity 0 0 0 \n", + " Rewards Vault 0 0 0 " + ] + }, + "execution_count": 71, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v3 = BancorDapp()\n", + "v3.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
bntethlinktknwbtcusdcbnbntbnethbnlinkbntknbnwbtcbnusdcvbnt
2Poola: TKN Staked Balance0000000000000
b: TKN Trading Liquidity0000000000000
c: BNT Trading Liquidity0000000000000
d: BNT Current Funding0000000000000
e: Spot Rate0000000000000
f: Average Rate0000000000000
g: Average Inverse Rate0000000000000
3NetworkBNT Staked Balance0000000000000
Master Vault0000000000000
Protection Vault0000000000000
Protocol Equity0000000000000
Rewards Vault0000000000000
\n", + "
" + ], + "text/plain": [ + " bnt eth link tkn wbtc usdc bnbnt bneth \\\n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 0 0 0 \n", + "\n", + " bnlink bntkn bnwbtc bnusdc vbnt \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 " + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v3.whitelist_token('usdc')\n", + "v3.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'eth': {'decimals': 18,\n", + " 'trading_fee': Decimal('0.01'),\n", + " 'bnt_funding_limit': Decimal('1000000'),\n", + " 'ep_vault_balance': Decimal('0')},\n", + " 'link': {'decimals': 18,\n", + " 'trading_fee': Decimal('0.01'),\n", + " 'bnt_funding_limit': Decimal('1000000'),\n", + " 'ep_vault_balance': Decimal('0')},\n", + " 'tkn': {'decimals': 18,\n", + " 'trading_fee': Decimal('0.01'),\n", + " 'bnt_funding_limit': Decimal('1000000'),\n", + " 'ep_vault_balance': Decimal('0')},\n", + " 'wbtc': {'decimals': 18,\n", + " 'trading_fee': Decimal('0.01'),\n", + " 'bnt_funding_limit': Decimal('1000000'),\n", + " 'ep_vault_balance': Decimal('0')},\n", + " 'usdc': {'decimals': 18,\n", + " 'trading_fee': Decimal('0.01'),\n", + " 'bnt_funding_limit': Decimal('1000000'),\n", + " 'ep_vault_balance': '0'}}" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "state = v3.get_state()\n", + "state.whitelisted_tokens" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{}" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "state.users" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": {}, + "outputs": [], + "source": [ + "v3.whitelist_token('usdt')\n", + "v3.whitelist_token('dai')" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
bntethlinktknwbtcusdcusdtdaibnbntbnethbnlinkbntknbnwbtcbnusdcbnusdtbndaivbnt
1AccountAlice10000001000000100000000100000010000001000000000000000
Bob10000001000000100000000100000010000001000000000000000
2Poola: TKN Staked Balance00000000000000000
b: TKN Trading Liquidity00000000000000000
c: BNT Trading Liquidity00000000000000000
d: BNT Current Funding00000000000000000
e: Spot Rate00000000000000000
f: Average Rate00000000000000000
g: Average Inverse Rate00000000000000000
3NetworkBNT Staked Balance00000000000000000
Master Vault00000000000000000
Protection Vault00000000000000000
Protocol Equity00000000000000000
Rewards Vault00000000000000000
\n", + "
" + ], + "text/plain": [ + " bnt eth link tkn wbtc \\\n", + "1 Account Alice 1000000 1000000 1000000 0 0 \n", + " Bob 1000000 1000000 1000000 0 0 \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " usdc usdt dai bnbnt bneth \\\n", + "1 Account Alice 1000000 1000000 1000000 0 0 \n", + " Bob 1000000 1000000 1000000 0 0 \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " bnlink bntkn bnwbtc bnusdc bnusdt bndai \\\n", + "1 Account Alice 0 0 0 0 0 0 \n", + " Bob 0 0 0 0 0 0 \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 0 \n", + "\n", + " vbnt \n", + "1 Account Alice 0 \n", + " Bob 0 \n", + "2 Pool a: TKN Staked Balance 0 \n", + " b: TKN Trading Liquidity 0 \n", + " c: BNT Trading Liquidity 0 \n", + " d: BNT Current Funding 0 \n", + " e: Spot Rate 0 \n", + " f: Average Rate 0 \n", + " g: Average Inverse Rate 0 \n", + "3 Network BNT Staked Balance 0 \n", + " Master Vault 0 \n", + " Protection Vault 0 \n", + " Protocol Equity 0 \n", + " Rewards Vault 0 " + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Create the users\n", + "v3.create_user('Alice')\n", + "\n", + "# Set the initial starting balances\n", + "v3.set_user_balance(user_name='Alice', tkn_name='eth',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Alice', tkn_name='link',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Alice', tkn_name='bnt',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Alice', tkn_name='usdc',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Alice', tkn_name='usdt',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Alice', tkn_name='dai',tkn_amt=1000000)\n", + "\n", + "v3.create_user('Bob')\n", + "\n", + "# Set the initial starting balances\n", + "v3.set_user_balance(user_name='Bob', tkn_name='eth',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Bob', tkn_name='link',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Bob', tkn_name='bnt',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Bob', tkn_name='usdc',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Bob', tkn_name='usdt',tkn_amt=1000000)\n", + "v3.set_user_balance(user_name='Bob', tkn_name='dai',tkn_amt=1000000)\n", + "\n", + "v3.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
bntethlinktknwbtcusdcusdtdaibnbntbnethbnlinkbntknbnwbtcbnusdcbnusdtbndaivbnt
1AccountAlice100000010000001000000005000001000000100000000000500000000
Bob10000001000000100000000100000010000001000000000000000
2Poola: TKN Staked Balance0000050000000000000000
b: TKN Trading Liquidity00000000000000000
c: BNT Trading Liquidity00000000000000000
d: BNT Current Funding00000000000000000
e: Spot Rate00000000000000000
f: Average Rate00000000000000000
g: Average Inverse Rate00000000000000000
3NetworkBNT Staked Balance00000000000000000
Master Vault0000050000000000000000
Protection Vault00000000000000000
Protocol Equity00000000000000000
Rewards Vault00000000000000000
\n", + "
" + ], + "text/plain": [ + " bnt eth link tkn wbtc \\\n", + "1 Account Alice 1000000 1000000 1000000 0 0 \n", + " Bob 1000000 1000000 1000000 0 0 \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " usdc usdt dai bnbnt bneth \\\n", + "1 Account Alice 500000 1000000 1000000 0 0 \n", + " Bob 1000000 1000000 1000000 0 0 \n", + "2 Pool a: TKN Staked Balance 500000 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 500000 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " bnlink bntkn bnwbtc bnusdc bnusdt bndai \\\n", + "1 Account Alice 0 0 0 500000 0 0 \n", + " Bob 0 0 0 0 0 0 \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 0 \n", + "\n", + " vbnt \n", + "1 Account Alice 0 \n", + " Bob 0 \n", + "2 Pool a: TKN Staked Balance 0 \n", + " b: TKN Trading Liquidity 0 \n", + " c: BNT Trading Liquidity 0 \n", + " d: BNT Current Funding 0 \n", + " e: Spot Rate 0 \n", + " f: Average Rate 0 \n", + " g: Average Inverse Rate 0 \n", + "3 Network BNT Staked Balance 0 \n", + " Master Vault 0 \n", + " Protection Vault 0 \n", + " Protocol Equity 0 \n", + " Rewards Vault 0 " + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v3.deposit('usdc', '500000', 'Alice', timestamp=0)\n", + "v3.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
bntethlinktknwbtcusdcusdtdaibnbntbnethbnlinkbntknbnwbtcbnusdcbnusdtbndaivbnt
1AccountAlice100000095000010000000050000010000001000000050000000500000000
Bob10000001000000100000000100000010000001000000000000000
2Poola: TKN Staked Balance05000000050000000000000000
b: TKN Trading Liquidity00000000000000000
c: BNT Trading Liquidity00000000000000000
d: BNT Current Funding00000000000000000
e: Spot Rate00000000000000000
f: Average Rate00000000000000000
g: Average Inverse Rate00000000000000000
3NetworkBNT Staked Balance00000000000000000
Master Vault05000000050000000000000000
Protection Vault00000000000000000
Protocol Equity00000000000000000
Rewards Vault00000000000000000
\n", + "
" + ], + "text/plain": [ + " bnt eth link tkn wbtc \\\n", + "1 Account Alice 1000000 950000 1000000 0 0 \n", + " Bob 1000000 1000000 1000000 0 0 \n", + "2 Pool a: TKN Staked Balance 0 50000 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 0 50000 0 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " usdc usdt dai bnbnt bneth \\\n", + "1 Account Alice 500000 1000000 1000000 0 50000 \n", + " Bob 1000000 1000000 1000000 0 0 \n", + "2 Pool a: TKN Staked Balance 500000 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 500000 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " bnlink bntkn bnwbtc bnusdc bnusdt bndai \\\n", + "1 Account Alice 0 0 0 500000 0 0 \n", + " Bob 0 0 0 0 0 0 \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 0 \n", + "\n", + " vbnt \n", + "1 Account Alice 0 \n", + " Bob 0 \n", + "2 Pool a: TKN Staked Balance 0 \n", + " b: TKN Trading Liquidity 0 \n", + " c: BNT Trading Liquidity 0 \n", + " d: BNT Current Funding 0 \n", + " e: Spot Rate 0 \n", + " f: Average Rate 0 \n", + " g: Average Inverse Rate 0 \n", + "3 Network BNT Staked Balance 0 \n", + " Master Vault 0 \n", + " Protection Vault 0 \n", + " Protocol Equity 0 \n", + " Rewards Vault 0 " + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v3.deposit('eth', '50000', 'Alice', timestamp=0)\n", + "v3.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
bntethlinktknwbtcusdcusdtdaibnbntbnethbnlinkbntknbnwbtcbnusdcbnusdtbndaivbnt
1AccountAlice100000095000010000000050000010000001000000050000000500000000
Bob100000010000005000000010000001000000100000000500000000000
2Poola: TKN Staked Balance0500005000000050000000000000000
b: TKN Trading Liquidity00000000000000000
c: BNT Trading Liquidity00000000000000000
d: BNT Current Funding00000000000000000
e: Spot Rate00000000000000000
f: Average Rate00000000000000000
g: Average Inverse Rate00000000000000000
3NetworkBNT Staked Balance00000000000000000
Master Vault0500005000000050000000000000000
Protection Vault00000000000000000
Protocol Equity00000000000000000
Rewards Vault00000000000000000
\n", + "
" + ], + "text/plain": [ + " bnt eth link tkn wbtc \\\n", + "1 Account Alice 1000000 950000 1000000 0 0 \n", + " Bob 1000000 1000000 500000 0 0 \n", + "2 Pool a: TKN Staked Balance 0 50000 500000 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 0 50000 500000 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " usdc usdt dai bnbnt bneth \\\n", + "1 Account Alice 500000 1000000 1000000 0 50000 \n", + " Bob 1000000 1000000 1000000 0 0 \n", + "2 Pool a: TKN Staked Balance 500000 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 500000 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " bnlink bntkn bnwbtc bnusdc bnusdt bndai \\\n", + "1 Account Alice 0 0 0 500000 0 0 \n", + " Bob 500000 0 0 0 0 0 \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 0 \n", + "\n", + " vbnt \n", + "1 Account Alice 0 \n", + " Bob 0 \n", + "2 Pool a: TKN Staked Balance 0 \n", + " b: TKN Trading Liquidity 0 \n", + " c: BNT Trading Liquidity 0 \n", + " d: BNT Current Funding 0 \n", + " e: Spot Rate 0 \n", + " f: Average Rate 0 \n", + " g: Average Inverse Rate 0 \n", + "3 Network BNT Staked Balance 0 \n", + " Master Vault 0 \n", + " Protection Vault 0 \n", + " Protocol Equity 0 \n", + " Rewards Vault 0 " + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v3.deposit('link', '500000', 'Bob', timestamp=0)\n", + "v3.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
bntethlinktknwbtcusdcusdtdaibnbntbnethbnlinkbntknbnwbtcbnusdcbnusdtbndaivbnt
1AccountAlice100000095000010000000050000010000001000000050000000500000000
Bob100000010000004500000010000001000000100000000550000000000
2Poola: TKN Staked Balance0500005500000050000000000000000
b: TKN Trading Liquidity00000000000000000
c: BNT Trading Liquidity00000000000000000
d: BNT Current Funding00000000000000000
e: Spot Rate00000000000000000
f: Average Rate00000000000000000
g: Average Inverse Rate00000000000000000
3NetworkBNT Staked Balance00000000000000000
Master Vault0500005500000050000000000000000
Protection Vault00000000000000000
Protocol Equity00000000000000000
Rewards Vault00000000000000000
\n", + "
" + ], + "text/plain": [ + " bnt eth link tkn wbtc \\\n", + "1 Account Alice 1000000 950000 1000000 0 0 \n", + " Bob 1000000 1000000 450000 0 0 \n", + "2 Pool a: TKN Staked Balance 0 50000 550000 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 0 50000 550000 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " usdc usdt dai bnbnt bneth \\\n", + "1 Account Alice 500000 1000000 1000000 0 50000 \n", + " Bob 1000000 1000000 1000000 0 0 \n", + "2 Pool a: TKN Staked Balance 500000 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 \n", + " Master Vault 500000 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 \n", + "\n", + " bnlink bntkn bnwbtc bnusdc bnusdt bndai \\\n", + "1 Account Alice 0 0 0 500000 0 0 \n", + " Bob 550000 0 0 0 0 0 \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 0 \n", + " Master Vault 0 0 0 0 0 0 \n", + " Protection Vault 0 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 0 0 \n", + "\n", + " vbnt \n", + "1 Account Alice 0 \n", + " Bob 0 \n", + "2 Pool a: TKN Staked Balance 0 \n", + " b: TKN Trading Liquidity 0 \n", + " c: BNT Trading Liquidity 0 \n", + " d: BNT Current Funding 0 \n", + " e: Spot Rate 0 \n", + " f: Average Rate 0 \n", + " g: Average Inverse Rate 0 \n", + "3 Network BNT Staked Balance 0 \n", + " Master Vault 0 \n", + " Protection Vault 0 \n", + " Protocol Equity 0 \n", + " Rewards Vault 0 " + ] + }, + "execution_count": 79, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v3.deposit('link', '50000', 'Bob', timestamp=1)\n", + "v3.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [], + "source": [ + "v3.enable_trading('link')" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [], + "source": [ + "v3.enable_trading('eth')" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [], + "source": [ + "v3.enable_trading('usdc')" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
timestamplatest_actionlatest_amtlatest_user_nametkn_namemaster_vault_tknerc20contracts_bntknstaked_tknis_trading_enabledbnt_trading_liquidity...network_feewithdrawal_feebnt_min_liquiditycooldown_timeprotocol_wallet_bnbntvortex_bnterc20contracts_bnbntmaster_vault_bntstaked_bntbnbnt_rate
00deposit500000Aliceeth000False0...0.20.002510000604800000001
00deposit500000Alicelink000False0...0.20.002510000604800000001
00deposit500000Alicetkn000False0...0.20.002510000604800000001
00deposit500000Alicewbtc000False0...0.20.002510000604800000001
00deposit500000Aliceusdc500000500000500000False0...0.20.002510000604800000001
00deposit500000Aliceusdt000False0...0.20.002510000604800000001
00deposit500000Alicedai000False0...0.20.002510000604800000001
00deposit50000Aliceeth500005000050000False0...0.20.002510000604800000001
00deposit50000Alicelink000False0...0.20.002510000604800000001
00deposit50000Alicetkn000False0...0.20.002510000604800000001
00deposit50000Alicewbtc000False0...0.20.002510000604800000001
00deposit50000Aliceusdc500000500000500000False0...0.20.002510000604800000001
00deposit50000Aliceusdt000False0...0.20.002510000604800000001
00deposit50000Alicedai000False0...0.20.002510000604800000001
00deposit500000Bobeth500005000050000False0...0.20.002510000604800000001
00deposit500000Boblink500000500000500000False0...0.20.002510000604800000001
00deposit500000Bobtkn000False0...0.20.002510000604800000001
00deposit500000Bobwbtc000False0...0.20.002510000604800000001
00deposit500000Bobusdc500000500000500000False0...0.20.002510000604800000001
00deposit500000Bobusdt000False0...0.20.002510000604800000001
00deposit500000Bobdai000False0...0.20.002510000604800000001
00deposit50000Bobeth500005000050000False0...0.20.002510000604800000001
00deposit50000Boblink550000550000550000False0...0.20.002510000604800000001
00deposit50000Bobtkn000False0...0.20.002510000604800000001
00deposit50000Bobwbtc000False0...0.20.002510000604800000001
00deposit50000Bobusdc500000500000500000False0...0.20.002510000604800000001
00deposit50000Bobusdt000False0...0.20.002510000604800000001
00deposit50000Bobdai000False0...0.20.002510000604800000001
00enableTrading0protocoleth500005000050000False0...0.20.0025100006048002000002000020000200001
00enableTrading0protocollink550000550000550000True20000...0.20.0025100006048002000002000020000200001
00enableTrading0protocoltkn000False0...0.20.0025100006048002000002000020000200001
00enableTrading0protocolwbtc000False0...0.20.0025100006048002000002000020000200001
00enableTrading0protocolusdc500000500000500000False0...0.20.0025100006048002000002000020000200001
00enableTrading0protocolusdt000False0...0.20.0025100006048002000002000020000200001
00enableTrading0protocoldai000False0...0.20.0025100006048002000002000020000200001
00enableTrading0protocoleth500005000050000True20000...0.20.0025100006048004000004000040000400001
00enableTrading0protocollink550000550000550000True20000...0.20.0025100006048004000004000040000400001
00enableTrading0protocoltkn000False0...0.20.0025100006048004000004000040000400001
00enableTrading0protocolwbtc000False0...0.20.0025100006048004000004000040000400001
00enableTrading0protocolusdc500000500000500000False0...0.20.0025100006048004000004000040000400001
00enableTrading0protocolusdt000False0...0.20.0025100006048004000004000040000400001
00enableTrading0protocoldai000False0...0.20.0025100006048004000004000040000400001
00enableTrading0protocoleth500005000050000True20000...0.20.0025100006048006000006000060000600001
00enableTrading0protocollink550000550000550000True20000...0.20.0025100006048006000006000060000600001
00enableTrading0protocoltkn000False0...0.20.0025100006048006000006000060000600001
00enableTrading0protocolwbtc000False0...0.20.0025100006048006000006000060000600001
00enableTrading0protocolusdc500000500000500000True20000...0.20.0025100006048006000006000060000600001
00enableTrading0protocolusdt000False0...0.20.0025100006048006000006000060000600001
00enableTrading0protocoldai000False0...0.20.0025100006048006000006000060000600001
\n", + "

49 rows × 31 columns

\n", + "
" + ], + "text/plain": [ + " timestamp latest_action latest_amt latest_user_name tkn_name \\\n", + "0 0 deposit 500000 Alice eth \n", + "0 0 deposit 500000 Alice link \n", + "0 0 deposit 500000 Alice tkn \n", + "0 0 deposit 500000 Alice wbtc \n", + "0 0 deposit 500000 Alice usdc \n", + "0 0 deposit 500000 Alice usdt \n", + "0 0 deposit 500000 Alice dai \n", + "0 0 deposit 50000 Alice eth \n", + "0 0 deposit 50000 Alice link \n", + "0 0 deposit 50000 Alice tkn \n", + "0 0 deposit 50000 Alice wbtc \n", + "0 0 deposit 50000 Alice usdc \n", + "0 0 deposit 50000 Alice usdt \n", + "0 0 deposit 50000 Alice dai \n", + "0 0 deposit 500000 Bob eth \n", + "0 0 deposit 500000 Bob link \n", + "0 0 deposit 500000 Bob tkn \n", + "0 0 deposit 500000 Bob wbtc \n", + "0 0 deposit 500000 Bob usdc \n", + "0 0 deposit 500000 Bob usdt \n", + "0 0 deposit 500000 Bob dai \n", + "0 0 deposit 50000 Bob eth \n", + "0 0 deposit 50000 Bob link \n", + "0 0 deposit 50000 Bob tkn \n", + "0 0 deposit 50000 Bob wbtc \n", + "0 0 deposit 50000 Bob usdc \n", + "0 0 deposit 50000 Bob usdt \n", + "0 0 deposit 50000 Bob dai \n", + "0 0 enableTrading 0 protocol eth \n", + "0 0 enableTrading 0 protocol link \n", + "0 0 enableTrading 0 protocol tkn \n", + "0 0 enableTrading 0 protocol wbtc \n", + "0 0 enableTrading 0 protocol usdc \n", + "0 0 enableTrading 0 protocol usdt \n", + "0 0 enableTrading 0 protocol dai \n", + "0 0 enableTrading 0 protocol eth \n", + "0 0 enableTrading 0 protocol link \n", + "0 0 enableTrading 0 protocol tkn \n", + "0 0 enableTrading 0 protocol wbtc \n", + "0 0 enableTrading 0 protocol usdc \n", + "0 0 enableTrading 0 protocol usdt \n", + "0 0 enableTrading 0 protocol dai \n", + "0 0 enableTrading 0 protocol eth \n", + "0 0 enableTrading 0 protocol link \n", + "0 0 enableTrading 0 protocol tkn \n", + "0 0 enableTrading 0 protocol wbtc \n", + "0 0 enableTrading 0 protocol usdc \n", + "0 0 enableTrading 0 protocol usdt \n", + "0 0 enableTrading 0 protocol dai \n", + "\n", + " master_vault_tkn erc20contracts_bntkn staked_tkn is_trading_enabled \\\n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 500000 500000 500000 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 50000 50000 50000 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 500000 500000 500000 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 50000 50000 50000 False \n", + "0 500000 500000 500000 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 500000 500000 500000 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 50000 50000 50000 False \n", + "0 550000 550000 550000 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 500000 500000 500000 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 50000 50000 50000 False \n", + "0 550000 550000 550000 True \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 500000 500000 500000 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 50000 50000 50000 True \n", + "0 550000 550000 550000 True \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 500000 500000 500000 False \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 50000 50000 50000 True \n", + "0 550000 550000 550000 True \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "0 500000 500000 500000 True \n", + "0 0 0 0 False \n", + "0 0 0 0 False \n", + "\n", + " bnt_trading_liquidity ... network_fee withdrawal_fee bnt_min_liquidity \\\n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 20000 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 20000 ... 0.2 0.0025 10000 \n", + "0 20000 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 20000 ... 0.2 0.0025 10000 \n", + "0 20000 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 20000 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "0 0 ... 0.2 0.0025 10000 \n", + "\n", + " cooldown_time protocol_wallet_bnbnt vortex_bnt erc20contracts_bnbnt \\\n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 0 0 0 \n", + "0 604800 20000 0 20000 \n", + "0 604800 20000 0 20000 \n", + "0 604800 20000 0 20000 \n", + "0 604800 20000 0 20000 \n", + "0 604800 20000 0 20000 \n", + "0 604800 20000 0 20000 \n", + "0 604800 20000 0 20000 \n", + "0 604800 40000 0 40000 \n", + "0 604800 40000 0 40000 \n", + "0 604800 40000 0 40000 \n", + "0 604800 40000 0 40000 \n", + "0 604800 40000 0 40000 \n", + "0 604800 40000 0 40000 \n", + "0 604800 40000 0 40000 \n", + "0 604800 60000 0 60000 \n", + "0 604800 60000 0 60000 \n", + "0 604800 60000 0 60000 \n", + "0 604800 60000 0 60000 \n", + "0 604800 60000 0 60000 \n", + "0 604800 60000 0 60000 \n", + "0 604800 60000 0 60000 \n", + "\n", + " master_vault_bnt staked_bnt bnbnt_rate \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 0 0 1 \n", + "0 20000 20000 1 \n", + "0 20000 20000 1 \n", + "0 20000 20000 1 \n", + "0 20000 20000 1 \n", + "0 20000 20000 1 \n", + "0 20000 20000 1 \n", + "0 20000 20000 1 \n", + "0 40000 40000 1 \n", + "0 40000 40000 1 \n", + "0 40000 40000 1 \n", + "0 40000 40000 1 \n", + "0 40000 40000 1 \n", + "0 40000 40000 1 \n", + "0 40000 40000 1 \n", + "0 60000 60000 1 \n", + "0 60000 60000 1 \n", + "0 60000 60000 1 \n", + "0 60000 60000 1 \n", + "0 60000 60000 1 \n", + "0 60000 60000 1 \n", + "0 60000 60000 1 \n", + "\n", + "[49 rows x 31 columns]" + ] + }, + "execution_count": 83, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v3.show_history()" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
bntethlinktknwbtcusdcbnbntbnethbnlinkbntknbnwbtcbnusdcvbnt
1AccountAlice10000009499501001366.94560669456066945606694560669456066945...008999990500000001000010
Bob10000001000000900000001000000001000000000
2Poola: TKN Staked Balance050000100011.046025104602510460251046025104602510460...001000010000000
b: TKN Trading Liquidity070.0001966.38772663877266387726638772663877266387726...00200000000000
c: BNT Trading Liquidity05828.57142857142857142857142857142857142857142...34094.9084534870760844234140212578399683868156...00200000000000
d: BNT Current Funding020114.2857142857142857142857142857142857142857...2000000200000000000
e: Spot Rate083.2653061224489795918367346938775510204081632...17.3388533663027403025261279900999157793697048...0010000000
f: Average Rate01.0E+36.00000000000000000000000000000000000000000000...0010000000
g: Average Inverse Rate00.00100.16666666666666666666666666666666666666666666...0010000000
3NetworkBNT Staked Balance60114.2857142857142857142857142857142857142857...000000000000
Master Vault60000.0000000000000000000000000000000000000000...5005098633.0543933054393305439330543933054393305439...001000010000000
Protection Vault0000000000000
Protocol Equity00000060000000000
Rewards Vault0000000000000
\n", + "
" + ], + "text/plain": [ + " bnt \\\n", + "1 Account Alice 1000000 \n", + " Bob 1000000 \n", + "2 Pool a: TKN Staked Balance 0 \n", + " b: TKN Trading Liquidity 0 \n", + " c: BNT Trading Liquidity 0 \n", + " d: BNT Current Funding 0 \n", + " e: Spot Rate 0 \n", + " f: Average Rate 0 \n", + " g: Average Inverse Rate 0 \n", + "3 Network BNT Staked Balance 60114.2857142857142857142857142857142857142857... \n", + " Master Vault 60000.0000000000000000000000000000000000000000... \n", + " Protection Vault 0 \n", + " Protocol Equity 0 \n", + " Rewards Vault 0 \n", + "\n", + " eth \\\n", + "1 Account Alice 949950 \n", + " Bob 1000000 \n", + "2 Pool a: TKN Staked Balance 50000 \n", + " b: TKN Trading Liquidity 70.000 \n", + " c: BNT Trading Liquidity 5828.57142857142857142857142857142857142857142... \n", + " d: BNT Current Funding 20114.2857142857142857142857142857142857142857... \n", + " e: Spot Rate 83.2653061224489795918367346938775510204081632... \n", + " f: Average Rate 1.0E+3 \n", + " g: Average Inverse Rate 0.0010 \n", + "3 Network BNT Staked Balance 0 \n", + " Master Vault 50050 \n", + " Protection Vault 0 \n", + " Protocol Equity 0 \n", + " Rewards Vault 0 \n", + "\n", + " link \\\n", + "1 Account Alice 1001366.94560669456066945606694560669456066945... \n", + " Bob 900000 \n", + "2 Pool a: TKN Staked Balance 100011.046025104602510460251046025104602510460... \n", + " b: TKN Trading Liquidity 1966.38772663877266387726638772663877266387726... \n", + " c: BNT Trading Liquidity 34094.9084534870760844234140212578399683868156... \n", + " d: BNT Current Funding 20000 \n", + " e: Spot Rate 17.3388533663027403025261279900999157793697048... \n", + " f: Average Rate 6.00000000000000000000000000000000000000000000... \n", + " g: Average Inverse Rate 0.16666666666666666666666666666666666666666666... \n", + "3 Network BNT Staked Balance 0 \n", + " Master Vault 98633.0543933054393305439330543933054393305439... \n", + " Protection Vault 0 \n", + " Protocol Equity 0 \n", + " Rewards Vault 0 \n", + "\n", + " tkn wbtc usdc bnbnt bneth bnlink \\\n", + "1 Account Alice 0 0 899999 0 50000 0 \n", + " Bob 0 0 1000000 0 0 100000 \n", + "2 Pool a: TKN Staked Balance 0 0 100001 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 20000 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 20000 0 0 0 \n", + " d: BNT Current Funding 0 0 20000 0 0 0 \n", + " e: Spot Rate 0 0 1 0 0 0 \n", + " f: Average Rate 0 0 1 0 0 0 \n", + " g: Average Inverse Rate 0 0 1 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 0 0 \n", + " Master Vault 0 0 100001 0 0 0 \n", + " Protection Vault 0 0 0 0 0 0 \n", + " Protocol Equity 0 0 0 60000 0 0 \n", + " Rewards Vault 0 0 0 0 0 0 \n", + "\n", + " bntkn bnwbtc bnusdc vbnt \n", + "1 Account Alice 0 0 100001 0 \n", + " Bob 0 0 0 0 \n", + "2 Pool a: TKN Staked Balance 0 0 0 0 \n", + " b: TKN Trading Liquidity 0 0 0 0 \n", + " c: BNT Trading Liquidity 0 0 0 0 \n", + " d: BNT Current Funding 0 0 0 0 \n", + " e: Spot Rate 0 0 0 0 \n", + " f: Average Rate 0 0 0 0 \n", + " g: Average Inverse Rate 0 0 0 0 \n", + "3 Network BNT Staked Balance 0 0 0 0 \n", + " Master Vault 0 0 0 0 \n", + " Protection Vault 0 0 0 0 \n", + " Protocol Equity 0 0 0 0 \n", + " Rewards Vault 0 0 0 0 " + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v3.trade('50', 'eth','link', 'Alice', timestamp=2)\n", + "v3.describe()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.13" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} \ No newline at end of file From 908e15a439461933fb76a954ad351dd2c64287c2 Mon Sep 17 00:00:00 2001 From: mikewcasale Date: Fri, 16 Sep 2022 09:45:58 -0700 Subject: [PATCH 2/5] Update utils.py - reverting prior quickfix change --- .../bancor_simulator/v3/spec/utils.py | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/bancor_research/bancor_simulator/v3/spec/utils.py b/bancor_research/bancor_simulator/v3/spec/utils.py index a9a9d84..fa0c113 100644 --- a/bancor_research/bancor_simulator/v3/spec/utils.py +++ b/bancor_research/bancor_simulator/v3/spec/utils.py @@ -471,45 +471,45 @@ def handle_logging( """ state.iter_transaction_id = transaction_id for tkn_name in state.whitelisted_tokens: - try: - state_variables = { - "timestamp": [state.timestamp], - "latest_action": [action_name], - "latest_amt": [tkn_amt], - "latest_user_name": [user_name], - "tkn_name": [tkn_name], - "master_vault_tkn": [get_master_vault_balance(state, tkn_name)], - "erc20contracts_bntkn": [get_pooltoken_balance(state, tkn_name)], - "staked_tkn": [get_staked_balance(state, tkn_name)], - "is_trading_enabled": [get_is_trading_enabled(state, tkn_name)], - "bnt_trading_liquidity": [get_bnt_trading_liquidity(state, tkn_name)], - "tkn_trading_liquidity": [get_tkn_trading_liquidity(state, tkn_name)], - "trading_fee": [get_trading_fee(state, tkn_name)], - "bnt_funding_limit": [get_bnt_funding_limit(state, tkn_name)], - "bnt_remaining_funding": [get_bnt_remaining_funding(state, tkn_name)], - "bnt_funding_amt": [get_bnt_funding_amt(state, tkn_name)], - "external_protection_vault": [ - get_external_protection_vault_balance(state, tkn_name) - ], - "spot_rate": [get_spot_rate(state, tkn_name)], - "ema_rate": [get_ema_rate(state, tkn_name)], - "inv_spot_rate": [get_inv_spot_rate(state, tkn_name)], - "inv_ema_rate": [get_inv_ema_rate(state, tkn_name)], - "ema_last_updated": [state.tokens[tkn_name].ema_last_updated], - "network_fee": [state.network_fee], - "withdrawal_fee": [state.withdrawal_fee], - "bnt_min_liquidity": [state.bnt_min_liquidity], - "cooldown_time": [state.cooldown_time], - "protocol_wallet_bnbnt": [get_protocol_wallet_balance(state, "bnt")], - "vortex_bnt": [get_vortex_balance(state, "bnt")], - "erc20contracts_bnbnt": [get_pooltoken_balance(state, "bnt")], - "master_vault_bnt": [get_master_vault_balance(state, "bnt")], - "staked_bnt": [get_staked_balance(state, "bnt")], - "bnbnt_rate": [state.bnbnt_rate], - } - state.history.append(DataFrame(state_variables)) - except KeyError: - pass + # try: + state_variables = { + "timestamp": [state.timestamp], + "latest_action": [action_name], + "latest_amt": [tkn_amt], + "latest_user_name": [user_name], + "tkn_name": [tkn_name], + "master_vault_tkn": [get_master_vault_balance(state, tkn_name)], + "erc20contracts_bntkn": [get_pooltoken_balance(state, tkn_name)], + "staked_tkn": [get_staked_balance(state, tkn_name)], + "is_trading_enabled": [get_is_trading_enabled(state, tkn_name)], + "bnt_trading_liquidity": [get_bnt_trading_liquidity(state, tkn_name)], + "tkn_trading_liquidity": [get_tkn_trading_liquidity(state, tkn_name)], + "trading_fee": [get_trading_fee(state, tkn_name)], + "bnt_funding_limit": [get_bnt_funding_limit(state, tkn_name)], + "bnt_remaining_funding": [get_bnt_remaining_funding(state, tkn_name)], + "bnt_funding_amt": [get_bnt_funding_amt(state, tkn_name)], + "external_protection_vault": [ + get_external_protection_vault_balance(state, tkn_name) + ], + "spot_rate": [get_spot_rate(state, tkn_name)], + "ema_rate": [get_ema_rate(state, tkn_name)], + "inv_spot_rate": [get_inv_spot_rate(state, tkn_name)], + "inv_ema_rate": [get_inv_ema_rate(state, tkn_name)], + "ema_last_updated": [state.tokens[tkn_name].ema_last_updated], + "network_fee": [state.network_fee], + "withdrawal_fee": [state.withdrawal_fee], + "bnt_min_liquidity": [state.bnt_min_liquidity], + "cooldown_time": [state.cooldown_time], + "protocol_wallet_bnbnt": [get_protocol_wallet_balance(state, "bnt")], + "vortex_bnt": [get_vortex_balance(state, "bnt")], + "erc20contracts_bnbnt": [get_pooltoken_balance(state, "bnt")], + "master_vault_bnt": [get_master_vault_balance(state, "bnt")], + "staked_bnt": [get_staked_balance(state, "bnt")], + "bnbnt_rate": [state.bnbnt_rate], + } + state.history.append(DataFrame(state_variables)) + # except KeyError: + # pass return state From b98dec1db462bdc33c1aae7c4610747aa748197f Mon Sep 17 00:00:00 2001 From: mikewcasale Date: Fri, 16 Sep 2022 16:46:00 +0000 Subject: [PATCH 3/5] fixup: Format Python code with Black --- bancor_research/bancor_simulator/v3/spec/network.py | 3 ++- bancor_research/bancor_simulator/v3/spec/state.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bancor_research/bancor_simulator/v3/spec/network.py b/bancor_research/bancor_simulator/v3/spec/network.py index 5a72360..eb8f7e7 100644 --- a/bancor_research/bancor_simulator/v3/spec/network.py +++ b/bancor_research/bancor_simulator/v3/spec/network.py @@ -19,6 +19,7 @@ def to_decimal(percent: str): except TypeError: return percent + def to_user_amount(state: State, tkn_name: str, user_name: str, amount: str): if amount.endswith("%"): return get_user_balance(state, user_name, tkn_name) * to_decimal(amount) @@ -429,7 +430,7 @@ def whitelist_token(self, tkn_name: str, timestamp: int = 0): """ state = self.get_state(copy_type="initial", timestamp=timestamp) tkn_name = tkn_name.lower() - state.price_feeds[tkn_name]=[0 for _ in range(len(state.price_feeds))] + state.price_feeds[tkn_name] = [0 for _ in range(len(state.price_feeds))] state.create_whitelisted_tkn(tkn_name) handle_whitelisting_tokens(state) diff --git a/bancor_research/bancor_simulator/v3/spec/state.py b/bancor_research/bancor_simulator/v3/spec/state.py index 4296dd8..5728bea 100644 --- a/bancor_research/bancor_simulator/v3/spec/state.py +++ b/bancor_research/bancor_simulator/v3/spec/state.py @@ -777,7 +777,7 @@ def create_whitelisted_tkn(self, tkn_name: str): "decimals": 18, "trading_fee": DEFAULT_TRADING_FEE, "bnt_funding_limit": DEFAULT_BNT_FUNDING_LIMIT, - "ep_vault_balance": DEFAULT.EP_VAULT_BALANCE + "ep_vault_balance": DEFAULT.EP_VAULT_BALANCE, } return self From 93f6d113361347b5114f409eb99da3cddbed666e Mon Sep 17 00:00:00 2001 From: mikewcasale Date: Fri, 16 Sep 2022 09:46:28 -0700 Subject: [PATCH 4/5] Update network.py - fixed historical logging functionality --- .../bancor_simulator/v3/spec/network.py | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/bancor_research/bancor_simulator/v3/spec/network.py b/bancor_research/bancor_simulator/v3/spec/network.py index 5a72360..62f2106 100644 --- a/bancor_research/bancor_simulator/v3/spec/network.py +++ b/bancor_research/bancor_simulator/v3/spec/network.py @@ -206,8 +206,7 @@ def deposit( state = deposit_tkn( state=state, tkn_name=tkn_name, tkn_amt=tkn_amt, user_name=user_name ) - self.next_transaction(state) - handle_logging( + state = handle_logging( tkn_name=tkn_name, tkn_amt=tkn_amt, action_name=action_name, @@ -215,6 +214,8 @@ def deposit( transaction_id=self.transaction_id, state=state, ) + self.next_transaction(state) + def trade( self, @@ -239,8 +240,7 @@ def trade( state = process_trade( state, tkn_amt, source_token, target_token, user_name, timestamp ) - self.next_transaction(state) - handle_logging( + state = handle_logging( source_token + "->" + target_token, tkn_amt, transaction_type, @@ -248,6 +248,8 @@ def trade( self.transaction_id, state, ) + self.next_transaction(state) + def begin_cooldown_by_rtkn( self, @@ -268,10 +270,11 @@ def begin_cooldown_by_rtkn( id_number = begin_withdrawal_cooldown_by_rtkn( state, tkn_amt, tkn_name, user_name ) - self.next_transaction(state) - handle_logging( + state = handle_logging( tkn_name, tkn_amt, action_name, user_name, self.transaction_id, state ) + self.next_transaction(state) + return id_number def begin_cooldown_by_ptkn( @@ -312,8 +315,6 @@ def withdraw( state = self.get_state(copy_type="initial", timestamp=timestamp) tkn_name = state.users[user_name].pending_withdrawals[id_number].tkn_name state = process_withdrawal(state, user_name, id_number, timestamp) - - self.next_transaction(state) state = handle_logging( tkn_name, Decimal(0), @@ -322,6 +323,8 @@ def withdraw( self.transaction_id, state, ) + self.next_transaction(state) + def enable_trading( self, @@ -341,8 +344,7 @@ def enable_trading( if bnt_price: state.price_feeds.at[state.timestamp, "bnt"] = bnt_price state = enable_trading(state, tkn_name) - self.next_transaction(state) - handle_logging( + state = handle_logging( tkn_name, Decimal("0"), transaction_type, @@ -350,6 +352,8 @@ def enable_trading( state.transaction_id, state, ) + self.next_transaction(state) + def describe(self, decimals: int = -1): """ @@ -429,7 +433,7 @@ def whitelist_token(self, tkn_name: str, timestamp: int = 0): """ state = self.get_state(copy_type="initial", timestamp=timestamp) tkn_name = tkn_name.lower() - state.price_feeds[tkn_name]=[0 for _ in range(len(state.price_feeds))] + state.price_feeds[tkn_name]=state.price_feeds['bnt'].values state.create_whitelisted_tkn(tkn_name) handle_whitelisting_tokens(state) From 9ddf44239fbde558776f73538896e12aac4eb4aa Mon Sep 17 00:00:00 2001 From: mikewcasale Date: Fri, 16 Sep 2022 16:47:37 +0000 Subject: [PATCH 5/5] fixup: Format Python code with Black --- bancor_research/bancor_simulator/v3/spec/network.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bancor_research/bancor_simulator/v3/spec/network.py b/bancor_research/bancor_simulator/v3/spec/network.py index 9c3dd62..6949a0d 100644 --- a/bancor_research/bancor_simulator/v3/spec/network.py +++ b/bancor_research/bancor_simulator/v3/spec/network.py @@ -217,7 +217,6 @@ def deposit( ) self.next_transaction(state) - def trade( self, tkn_amt: str, @@ -251,7 +250,6 @@ def trade( ) self.next_transaction(state) - def begin_cooldown_by_rtkn( self, tkn_amt: str, @@ -326,7 +324,6 @@ def withdraw( ) self.next_transaction(state) - def enable_trading( self, tkn_name: str, @@ -355,7 +352,6 @@ def enable_trading( ) self.next_transaction(state) - def describe(self, decimals: int = -1): """ Describes the state ledger in a format similar to BIP15 documentation. @@ -434,7 +430,7 @@ def whitelist_token(self, tkn_name: str, timestamp: int = 0): """ state = self.get_state(copy_type="initial", timestamp=timestamp) tkn_name = tkn_name.lower() - state.price_feeds[tkn_name]=state.price_feeds['bnt'].values + state.price_feeds[tkn_name] = state.price_feeds["bnt"].values state.create_whitelisted_tkn(tkn_name) handle_whitelisting_tokens(state)